diff --git a/AccessApproval/composer.json b/AccessApproval/composer.json index 30c86a2d7fa1..892afdd51e59 100644 --- a/AccessApproval/composer.json +++ b/AccessApproval/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/AccessApproval/src/V1/Client/AccessApprovalClient.php b/AccessApproval/src/V1/Client/AccessApprovalClient.php index b7e979122824..2ec8d06925c5 100644 --- a/AccessApproval/src/V1/Client/AccessApprovalClient.php +++ b/AccessApproval/src/V1/Client/AccessApprovalClient.php @@ -24,17 +24,653 @@ namespace Google\Cloud\AccessApproval\V1\Client; -use Google\Cloud\AccessApproval\V1\Client\BaseClient\AccessApprovalBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AccessApproval\V1\AccessApprovalServiceAccount; +use Google\Cloud\AccessApproval\V1\AccessApprovalSettings; +use Google\Cloud\AccessApproval\V1\ApprovalRequest; +use Google\Cloud\AccessApproval\V1\ApproveApprovalRequestMessage; +use Google\Cloud\AccessApproval\V1\DeleteAccessApprovalSettingsMessage; +use Google\Cloud\AccessApproval\V1\DismissApprovalRequestMessage; +use Google\Cloud\AccessApproval\V1\GetAccessApprovalServiceAccountMessage; +use Google\Cloud\AccessApproval\V1\GetAccessApprovalSettingsMessage; +use Google\Cloud\AccessApproval\V1\GetApprovalRequestMessage; +use Google\Cloud\AccessApproval\V1\InvalidateApprovalRequestMessage; +use Google\Cloud\AccessApproval\V1\ListApprovalRequestsMessage; +use Google\Cloud\AccessApproval\V1\UpdateAccessApprovalSettingsMessage; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: This API allows a customer to manage accesses to cloud resources by + * Google personnel. It defines the following resource model: * - * This class is currently experimental and may be subject to changes. + * - The API has a collection of + * [ApprovalRequest][google.cloud.accessapproval.v1.ApprovalRequest] + * resources, named `approvalRequests/{approval_request}` + * - The API has top-level settings per Project/Folder/Organization, named + * `accessApprovalSettings` + * + * The service also periodically emails a list of recipients, defined at the + * Project/Folder/Organization level in the accessApprovalSettings, when there + * is a pending ApprovalRequest for them to act on. The ApprovalRequests can + * also optionally be published to a Pub/Sub topic owned by the customer + * (contact support if you would like to enable Pub/Sub notifications). + * + * ApprovalRequests can be approved or dismissed. Google personnel can only + * access the indicated resource or resources if the request is approved + * (subject to some exclusions: + * https://cloud.google.com/access-approval/docs/overview#exclusions). + * + * Note: Using Access Approval functionality will mean that Google may not be + * able to meet the SLAs for your chosen products, as any support response times + * may be dramatically increased. As such the SLAs do not apply to any service + * disruption to the extent impacted by Customer's use of Access Approval. Do + * not enable Access Approval for projects where you may require high service + * availability and rapid response by Google Cloud Support. + * + * After a request is approved or dismissed, no further action may be taken on + * it. Requests with the requested_expiration in the past or with no activity + * for 14 days are considered dismissed. When an approval expires, the request + * is considered dismissed. + * + * If a request is not approved or dismissed, we call it pending. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AccessApproval\V1\AccessApprovalClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface approveApprovalRequestAsync(ApproveApprovalRequestMessage $request, array $optionalArgs = []) + * @method PromiseInterface deleteAccessApprovalSettingsAsync(DeleteAccessApprovalSettingsMessage $request, array $optionalArgs = []) + * @method PromiseInterface dismissApprovalRequestAsync(DismissApprovalRequestMessage $request, array $optionalArgs = []) + * @method PromiseInterface getAccessApprovalServiceAccountAsync(GetAccessApprovalServiceAccountMessage $request, array $optionalArgs = []) + * @method PromiseInterface getAccessApprovalSettingsAsync(GetAccessApprovalSettingsMessage $request, array $optionalArgs = []) + * @method PromiseInterface getApprovalRequestAsync(GetApprovalRequestMessage $request, array $optionalArgs = []) + * @method PromiseInterface invalidateApprovalRequestAsync(InvalidateApprovalRequestMessage $request, array $optionalArgs = []) + * @method PromiseInterface listApprovalRequestsAsync(ListApprovalRequestsMessage $request, array $optionalArgs = []) + * @method PromiseInterface updateAccessApprovalSettingsAsync(UpdateAccessApprovalSettingsMessage $request, array $optionalArgs = []) */ -final class AccessApprovalClient extends AccessApprovalBaseClient +final class AccessApprovalClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AccessApprovalBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.accessapproval.v1.AccessApproval'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'accessapproval.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/access_approval_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/access_approval_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/access_approval_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/access_approval_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * access_approval_settings resource. + * + * @param string $project + * + * @return string The formatted access_approval_settings resource. + */ + public static function accessApprovalSettingsName(string $project): string + { + return self::getPathTemplate('accessApprovalSettings')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * approval_request resource. + * + * @param string $project + * @param string $approvalRequest + * + * @return string The formatted approval_request resource. + */ + public static function approvalRequestName(string $project, string $approvalRequest): string + { + return self::getPathTemplate('approvalRequest')->render([ + 'project' => $project, + 'approval_request' => $approvalRequest, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a folder + * resource. + * + * @param string $folder + * + * @return string The formatted folder resource. + */ + public static function folderName(string $folder): string + { + return self::getPathTemplate('folder')->render([ + 'folder' => $folder, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_accessApprovalSettings resource. + * + * @param string $folder + * + * @return string The formatted folder_accessApprovalSettings resource. + */ + public static function folderAccessApprovalSettingsName(string $folder): string + { + return self::getPathTemplate('folderAccessApprovalSettings')->render([ + 'folder' => $folder, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_approval_request resource. + * + * @param string $folder + * @param string $approvalRequest + * + * @return string The formatted folder_approval_request resource. + */ + public static function folderApprovalRequestName(string $folder, string $approvalRequest): string + { + return self::getPathTemplate('folderApprovalRequest')->render([ + 'folder' => $folder, + 'approval_request' => $approvalRequest, + ]); + } + + /** + * 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(string $organization): string + { + return self::getPathTemplate('organization')->render([ + 'organization' => $organization, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_accessApprovalSettings resource. + * + * @param string $organization + * + * @return string The formatted organization_accessApprovalSettings resource. + */ + public static function organizationAccessApprovalSettingsName(string $organization): string + { + return self::getPathTemplate('organizationAccessApprovalSettings')->render([ + 'organization' => $organization, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_approval_request resource. + * + * @param string $organization + * @param string $approvalRequest + * + * @return string The formatted organization_approval_request resource. + */ + public static function organizationApprovalRequestName(string $organization, string $approvalRequest): string + { + return self::getPathTemplate('organizationApprovalRequest')->render([ + 'organization' => $organization, + 'approval_request' => $approvalRequest, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_accessApprovalSettings resource. + * + * @param string $project + * + * @return string The formatted project_accessApprovalSettings resource. + */ + public static function projectAccessApprovalSettingsName(string $project): string + { + return self::getPathTemplate('projectAccessApprovalSettings')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_approval_request resource. + * + * @param string $project + * @param string $approvalRequest + * + * @return string The formatted project_approval_request resource. + */ + public static function projectApprovalRequestName(string $project, string $approvalRequest): string + { + return self::getPathTemplate('projectApprovalRequest')->render([ + 'project' => $project, + 'approval_request' => $approvalRequest, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - accessApprovalSettings: projects/{project}/accessApprovalSettings + * - approvalRequest: projects/{project}/approvalRequests/{approval_request} + * - folder: folders/{folder} + * - folderAccessApprovalSettings: folders/{folder}/accessApprovalSettings + * - folderApprovalRequest: folders/{folder}/approvalRequests/{approval_request} + * - organization: organizations/{organization} + * - organizationAccessApprovalSettings: organizations/{organization}/accessApprovalSettings + * - organizationApprovalRequest: organizations/{organization}/approvalRequests/{approval_request} + * - project: projects/{project} + * - projectAccessApprovalSettings: projects/{project}/accessApprovalSettings + * - projectApprovalRequest: projects/{project}/approvalRequests/{approval_request} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'accessapproval.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Approves a request and returns the updated ApprovalRequest. + * + * Returns NOT_FOUND if the request does not exist. Returns + * FAILED_PRECONDITION if the request exists but is not in a pending state. + * + * The async variant is {@see AccessApprovalClient::approveApprovalRequestAsync()} + * . + * + * @param ApproveApprovalRequestMessage $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ApprovalRequest + * + * @throws ApiException Thrown if the API call fails. + */ + public function approveApprovalRequest(ApproveApprovalRequestMessage $request, array $callOptions = []): ApprovalRequest + { + return $this->startApiCall('ApproveApprovalRequest', $request, $callOptions)->wait(); + } + + /** + * Deletes the settings associated with a project, folder, or organization. + * This will have the effect of disabling Access Approval for the project, + * folder, or organization, but only if all ancestors also have Access + * Approval disabled. If Access Approval is enabled at a higher level of the + * hierarchy, then Access Approval will still be enabled at this level as + * the settings are inherited. + * + * The async variant is + * {@see AccessApprovalClient::deleteAccessApprovalSettingsAsync()} . + * + * @param DeleteAccessApprovalSettingsMessage $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAccessApprovalSettings(DeleteAccessApprovalSettingsMessage $request, array $callOptions = []): void + { + $this->startApiCall('DeleteAccessApprovalSettings', $request, $callOptions)->wait(); + } + + /** + * Dismisses a request. Returns the updated ApprovalRequest. + * + * NOTE: This does not deny access to the resource if another request has been + * made and approved. It is equivalent in effect to ignoring the request + * altogether. + * + * Returns NOT_FOUND if the request does not exist. + * + * Returns FAILED_PRECONDITION if the request exists but is not in a pending + * state. + * + * The async variant is {@see AccessApprovalClient::dismissApprovalRequestAsync()} + * . + * + * @param DismissApprovalRequestMessage $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ApprovalRequest + * + * @throws ApiException Thrown if the API call fails. + */ + public function dismissApprovalRequest(DismissApprovalRequestMessage $request, array $callOptions = []): ApprovalRequest + { + return $this->startApiCall('DismissApprovalRequest', $request, $callOptions)->wait(); + } + + /** + * Retrieves the service account that is used by Access Approval to access KMS + * keys for signing approved approval requests. + * + * The async variant is + * {@see AccessApprovalClient::getAccessApprovalServiceAccountAsync()} . + * + * @param GetAccessApprovalServiceAccountMessage $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AccessApprovalServiceAccount + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAccessApprovalServiceAccount(GetAccessApprovalServiceAccountMessage $request, array $callOptions = []): AccessApprovalServiceAccount + { + return $this->startApiCall('GetAccessApprovalServiceAccount', $request, $callOptions)->wait(); + } + + /** + * Gets the settings associated with a project, folder, or organization. + * + * The async variant is + * {@see AccessApprovalClient::getAccessApprovalSettingsAsync()} . + * + * @param GetAccessApprovalSettingsMessage $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AccessApprovalSettings + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAccessApprovalSettings(GetAccessApprovalSettingsMessage $request, array $callOptions = []): AccessApprovalSettings + { + return $this->startApiCall('GetAccessApprovalSettings', $request, $callOptions)->wait(); + } + + /** + * Gets an approval request. Returns NOT_FOUND if the request does not exist. + * + * The async variant is {@see AccessApprovalClient::getApprovalRequestAsync()} . + * + * @param GetApprovalRequestMessage $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ApprovalRequest + * + * @throws ApiException Thrown if the API call fails. + */ + public function getApprovalRequest(GetApprovalRequestMessage $request, array $callOptions = []): ApprovalRequest + { + return $this->startApiCall('GetApprovalRequest', $request, $callOptions)->wait(); + } + + /** + * Invalidates an existing ApprovalRequest. Returns the updated + * ApprovalRequest. + * + * NOTE: This does not deny access to the resource if another request has been + * made and approved. It only invalidates a single approval. + * + * Returns FAILED_PRECONDITION if the request exists but is not in an approved + * state. + * + * The async variant is + * {@see AccessApprovalClient::invalidateApprovalRequestAsync()} . + * + * @param InvalidateApprovalRequestMessage $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ApprovalRequest + * + * @throws ApiException Thrown if the API call fails. + */ + public function invalidateApprovalRequest(InvalidateApprovalRequestMessage $request, array $callOptions = []): ApprovalRequest + { + return $this->startApiCall('InvalidateApprovalRequest', $request, $callOptions)->wait(); + } + + /** + * Lists approval requests associated with a project, folder, or organization. + * Approval requests can be filtered by state (pending, active, dismissed). + * The order is reverse chronological. + * + * The async variant is {@see AccessApprovalClient::listApprovalRequestsAsync()} . + * + * @param ListApprovalRequestsMessage $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listApprovalRequests(ListApprovalRequestsMessage $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListApprovalRequests', $request, $callOptions); + } + + /** + * Updates the settings associated with a project, folder, or organization. + * Settings to update are determined by the value of field_mask. + * + * The async variant is + * {@see AccessApprovalClient::updateAccessApprovalSettingsAsync()} . + * + * @param UpdateAccessApprovalSettingsMessage $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AccessApprovalSettings + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAccessApprovalSettings(UpdateAccessApprovalSettingsMessage $request, array $callOptions = []): AccessApprovalSettings + { + return $this->startApiCall('UpdateAccessApprovalSettings', $request, $callOptions)->wait(); + } } diff --git a/AccessApproval/src/V1/Client/BaseClient/AccessApprovalBaseClient.php b/AccessApproval/src/V1/Client/BaseClient/AccessApprovalBaseClient.php deleted file mode 100644 index d9e3166cffbd..000000000000 --- a/AccessApproval/src/V1/Client/BaseClient/AccessApprovalBaseClient.php +++ /dev/null @@ -1,671 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/access_approval_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/access_approval_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/access_approval_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/access_approval_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * access_approval_settings resource. - * - * @param string $project - * - * @return string The formatted access_approval_settings resource. - */ - public static function accessApprovalSettingsName(string $project): string - { - return self::getPathTemplate('accessApprovalSettings')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * approval_request resource. - * - * @param string $project - * @param string $approvalRequest - * - * @return string The formatted approval_request resource. - */ - public static function approvalRequestName(string $project, string $approvalRequest): string - { - return self::getPathTemplate('approvalRequest')->render([ - 'project' => $project, - 'approval_request' => $approvalRequest, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a folder - * resource. - * - * @param string $folder - * - * @return string The formatted folder resource. - */ - public static function folderName(string $folder): string - { - return self::getPathTemplate('folder')->render([ - 'folder' => $folder, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_accessApprovalSettings resource. - * - * @param string $folder - * - * @return string The formatted folder_accessApprovalSettings resource. - */ - public static function folderAccessApprovalSettingsName(string $folder): string - { - return self::getPathTemplate('folderAccessApprovalSettings')->render([ - 'folder' => $folder, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_approval_request resource. - * - * @param string $folder - * @param string $approvalRequest - * - * @return string The formatted folder_approval_request resource. - */ - public static function folderApprovalRequestName(string $folder, string $approvalRequest): string - { - return self::getPathTemplate('folderApprovalRequest')->render([ - 'folder' => $folder, - 'approval_request' => $approvalRequest, - ]); - } - - /** - * 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(string $organization): string - { - return self::getPathTemplate('organization')->render([ - 'organization' => $organization, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_accessApprovalSettings resource. - * - * @param string $organization - * - * @return string The formatted organization_accessApprovalSettings resource. - */ - public static function organizationAccessApprovalSettingsName(string $organization): string - { - return self::getPathTemplate('organizationAccessApprovalSettings')->render([ - 'organization' => $organization, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_approval_request resource. - * - * @param string $organization - * @param string $approvalRequest - * - * @return string The formatted organization_approval_request resource. - */ - public static function organizationApprovalRequestName(string $organization, string $approvalRequest): string - { - return self::getPathTemplate('organizationApprovalRequest')->render([ - 'organization' => $organization, - 'approval_request' => $approvalRequest, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_accessApprovalSettings resource. - * - * @param string $project - * - * @return string The formatted project_accessApprovalSettings resource. - */ - public static function projectAccessApprovalSettingsName(string $project): string - { - return self::getPathTemplate('projectAccessApprovalSettings')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_approval_request resource. - * - * @param string $project - * @param string $approvalRequest - * - * @return string The formatted project_approval_request resource. - */ - public static function projectApprovalRequestName(string $project, string $approvalRequest): string - { - return self::getPathTemplate('projectApprovalRequest')->render([ - 'project' => $project, - 'approval_request' => $approvalRequest, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - accessApprovalSettings: projects/{project}/accessApprovalSettings - * - approvalRequest: projects/{project}/approvalRequests/{approval_request} - * - folder: folders/{folder} - * - folderAccessApprovalSettings: folders/{folder}/accessApprovalSettings - * - folderApprovalRequest: folders/{folder}/approvalRequests/{approval_request} - * - organization: organizations/{organization} - * - organizationAccessApprovalSettings: organizations/{organization}/accessApprovalSettings - * - organizationApprovalRequest: organizations/{organization}/approvalRequests/{approval_request} - * - project: projects/{project} - * - projectAccessApprovalSettings: projects/{project}/accessApprovalSettings - * - projectApprovalRequest: projects/{project}/approvalRequests/{approval_request} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'accessapproval.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Approves a request and returns the updated ApprovalRequest. - * - * Returns NOT_FOUND if the request does not exist. Returns - * FAILED_PRECONDITION if the request exists but is not in a pending state. - * - * The async variant is {@see self::approveApprovalRequestAsync()} . - * - * @param ApproveApprovalRequestMessage $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ApprovalRequest - * - * @throws ApiException Thrown if the API call fails. - */ - public function approveApprovalRequest(ApproveApprovalRequestMessage $request, array $callOptions = []): ApprovalRequest - { - return $this->startApiCall('ApproveApprovalRequest', $request, $callOptions)->wait(); - } - - /** - * Deletes the settings associated with a project, folder, or organization. - * This will have the effect of disabling Access Approval for the project, - * folder, or organization, but only if all ancestors also have Access - * Approval disabled. If Access Approval is enabled at a higher level of the - * hierarchy, then Access Approval will still be enabled at this level as - * the settings are inherited. - * - * The async variant is {@see self::deleteAccessApprovalSettingsAsync()} . - * - * @param DeleteAccessApprovalSettingsMessage $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAccessApprovalSettings(DeleteAccessApprovalSettingsMessage $request, array $callOptions = []): void - { - $this->startApiCall('DeleteAccessApprovalSettings', $request, $callOptions)->wait(); - } - - /** - * Dismisses a request. Returns the updated ApprovalRequest. - * - * NOTE: This does not deny access to the resource if another request has been - * made and approved. It is equivalent in effect to ignoring the request - * altogether. - * - * Returns NOT_FOUND if the request does not exist. - * - * Returns FAILED_PRECONDITION if the request exists but is not in a pending - * state. - * - * The async variant is {@see self::dismissApprovalRequestAsync()} . - * - * @param DismissApprovalRequestMessage $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ApprovalRequest - * - * @throws ApiException Thrown if the API call fails. - */ - public function dismissApprovalRequest(DismissApprovalRequestMessage $request, array $callOptions = []): ApprovalRequest - { - return $this->startApiCall('DismissApprovalRequest', $request, $callOptions)->wait(); - } - - /** - * Retrieves the service account that is used by Access Approval to access KMS - * keys for signing approved approval requests. - * - * The async variant is {@see self::getAccessApprovalServiceAccountAsync()} . - * - * @param GetAccessApprovalServiceAccountMessage $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AccessApprovalServiceAccount - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAccessApprovalServiceAccount(GetAccessApprovalServiceAccountMessage $request, array $callOptions = []): AccessApprovalServiceAccount - { - return $this->startApiCall('GetAccessApprovalServiceAccount', $request, $callOptions)->wait(); - } - - /** - * Gets the settings associated with a project, folder, or organization. - * - * The async variant is {@see self::getAccessApprovalSettingsAsync()} . - * - * @param GetAccessApprovalSettingsMessage $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AccessApprovalSettings - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAccessApprovalSettings(GetAccessApprovalSettingsMessage $request, array $callOptions = []): AccessApprovalSettings - { - return $this->startApiCall('GetAccessApprovalSettings', $request, $callOptions)->wait(); - } - - /** - * Gets an approval request. Returns NOT_FOUND if the request does not exist. - * - * The async variant is {@see self::getApprovalRequestAsync()} . - * - * @param GetApprovalRequestMessage $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ApprovalRequest - * - * @throws ApiException Thrown if the API call fails. - */ - public function getApprovalRequest(GetApprovalRequestMessage $request, array $callOptions = []): ApprovalRequest - { - return $this->startApiCall('GetApprovalRequest', $request, $callOptions)->wait(); - } - - /** - * Invalidates an existing ApprovalRequest. Returns the updated - * ApprovalRequest. - * - * NOTE: This does not deny access to the resource if another request has been - * made and approved. It only invalidates a single approval. - * - * Returns FAILED_PRECONDITION if the request exists but is not in an approved - * state. - * - * The async variant is {@see self::invalidateApprovalRequestAsync()} . - * - * @param InvalidateApprovalRequestMessage $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ApprovalRequest - * - * @throws ApiException Thrown if the API call fails. - */ - public function invalidateApprovalRequest(InvalidateApprovalRequestMessage $request, array $callOptions = []): ApprovalRequest - { - return $this->startApiCall('InvalidateApprovalRequest', $request, $callOptions)->wait(); - } - - /** - * Lists approval requests associated with a project, folder, or organization. - * Approval requests can be filtered by state (pending, active, dismissed). - * The order is reverse chronological. - * - * The async variant is {@see self::listApprovalRequestsAsync()} . - * - * @param ListApprovalRequestsMessage $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listApprovalRequests(ListApprovalRequestsMessage $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListApprovalRequests', $request, $callOptions); - } - - /** - * Updates the settings associated with a project, folder, or organization. - * Settings to update are determined by the value of field_mask. - * - * The async variant is {@see self::updateAccessApprovalSettingsAsync()} . - * - * @param UpdateAccessApprovalSettingsMessage $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AccessApprovalSettings - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAccessApprovalSettings(UpdateAccessApprovalSettingsMessage $request, array $callOptions = []): AccessApprovalSettings - { - return $this->startApiCall('UpdateAccessApprovalSettings', $request, $callOptions)->wait(); - } -} diff --git a/AccessContextManager/composer.json b/AccessContextManager/composer.json index 140a2c5e876a..60a6853d6e04 100644 --- a/AccessContextManager/composer.json +++ b/AccessContextManager/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/AccessContextManager/src/V1/Client/AccessContextManagerClient.php b/AccessContextManager/src/V1/Client/AccessContextManagerClient.php index 86d454f2746f..ff644bca931f 100644 --- a/AccessContextManager/src/V1/Client/AccessContextManagerClient.php +++ b/AccessContextManager/src/V1/Client/AccessContextManagerClient.php @@ -24,17 +24,1191 @@ namespace Google\Identity\AccessContextManager\V1\Client; -use Google\Identity\AccessContextManager\V1\Client\BaseClient\AccessContextManagerBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Identity\AccessContextManager\V1\AccessLevel; +use Google\Identity\AccessContextManager\V1\AccessPolicy; +use Google\Identity\AccessContextManager\V1\CommitServicePerimetersRequest; +use Google\Identity\AccessContextManager\V1\CommitServicePerimetersResponse; +use Google\Identity\AccessContextManager\V1\CreateAccessLevelRequest; +use Google\Identity\AccessContextManager\V1\CreateGcpUserAccessBindingRequest; +use Google\Identity\AccessContextManager\V1\CreateServicePerimeterRequest; +use Google\Identity\AccessContextManager\V1\DeleteAccessLevelRequest; +use Google\Identity\AccessContextManager\V1\DeleteAccessPolicyRequest; +use Google\Identity\AccessContextManager\V1\DeleteGcpUserAccessBindingRequest; +use Google\Identity\AccessContextManager\V1\DeleteServicePerimeterRequest; +use Google\Identity\AccessContextManager\V1\GcpUserAccessBinding; +use Google\Identity\AccessContextManager\V1\GetAccessLevelRequest; +use Google\Identity\AccessContextManager\V1\GetAccessPolicyRequest; +use Google\Identity\AccessContextManager\V1\GetGcpUserAccessBindingRequest; +use Google\Identity\AccessContextManager\V1\GetServicePerimeterRequest; +use Google\Identity\AccessContextManager\V1\ListAccessLevelsRequest; +use Google\Identity\AccessContextManager\V1\ListAccessPoliciesRequest; +use Google\Identity\AccessContextManager\V1\ListGcpUserAccessBindingsRequest; +use Google\Identity\AccessContextManager\V1\ListServicePerimetersRequest; +use Google\Identity\AccessContextManager\V1\ReplaceAccessLevelsRequest; +use Google\Identity\AccessContextManager\V1\ReplaceAccessLevelsResponse; +use Google\Identity\AccessContextManager\V1\ReplaceServicePerimetersRequest; +use Google\Identity\AccessContextManager\V1\ReplaceServicePerimetersResponse; +use Google\Identity\AccessContextManager\V1\ServicePerimeter; +use Google\Identity\AccessContextManager\V1\UpdateAccessLevelRequest; +use Google\Identity\AccessContextManager\V1\UpdateAccessPolicyRequest; +use Google\Identity\AccessContextManager\V1\UpdateGcpUserAccessBindingRequest; +use Google\Identity\AccessContextManager\V1\UpdateServicePerimeterRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: API for setting [access levels] + * [google.identity.accesscontextmanager.v1.AccessLevel] and [service + * perimeters] [google.identity.accesscontextmanager.v1.ServicePerimeter] + * for Google Cloud projects. Each organization has one [access policy] + * [google.identity.accesscontextmanager.v1.AccessPolicy] that contains the + * [access levels] [google.identity.accesscontextmanager.v1.AccessLevel] + * and [service perimeters] + * [google.identity.accesscontextmanager.v1.ServicePerimeter]. This + * [access policy] [google.identity.accesscontextmanager.v1.AccessPolicy] is + * applicable to all resources in the organization. + * AccessPolicies * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Identity\AccessContextManager\V1\AccessContextManagerClient} for the + * stable implementation * * @experimental + * + * @method PromiseInterface commitServicePerimetersAsync(CommitServicePerimetersRequest $request, array $optionalArgs = []) + * @method PromiseInterface createAccessLevelAsync(CreateAccessLevelRequest $request, array $optionalArgs = []) + * @method PromiseInterface createAccessPolicyAsync(AccessPolicy $request, array $optionalArgs = []) + * @method PromiseInterface createGcpUserAccessBindingAsync(CreateGcpUserAccessBindingRequest $request, array $optionalArgs = []) + * @method PromiseInterface createServicePerimeterAsync(CreateServicePerimeterRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAccessLevelAsync(DeleteAccessLevelRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAccessPolicyAsync(DeleteAccessPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteGcpUserAccessBindingAsync(DeleteGcpUserAccessBindingRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteServicePerimeterAsync(DeleteServicePerimeterRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAccessLevelAsync(GetAccessLevelRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAccessPolicyAsync(GetAccessPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getGcpUserAccessBindingAsync(GetGcpUserAccessBindingRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getServicePerimeterAsync(GetServicePerimeterRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAccessLevelsAsync(ListAccessLevelsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAccessPoliciesAsync(ListAccessPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listGcpUserAccessBindingsAsync(ListGcpUserAccessBindingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listServicePerimetersAsync(ListServicePerimetersRequest $request, array $optionalArgs = []) + * @method PromiseInterface replaceAccessLevelsAsync(ReplaceAccessLevelsRequest $request, array $optionalArgs = []) + * @method PromiseInterface replaceServicePerimetersAsync(ReplaceServicePerimetersRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAccessLevelAsync(UpdateAccessLevelRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAccessPolicyAsync(UpdateAccessPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateGcpUserAccessBindingAsync(UpdateGcpUserAccessBindingRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateServicePerimeterAsync(UpdateServicePerimeterRequest $request, array $optionalArgs = []) */ -final class AccessContextManagerClient extends AccessContextManagerBaseClient +final class AccessContextManagerClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AccessContextManagerBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.identity.accesscontextmanager.v1.AccessContextManager'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'accesscontextmanager.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/access_context_manager_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/access_context_manager_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/access_context_manager_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/access_context_manager_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a access_level + * resource. + * + * @param string $accessPolicy + * @param string $accessLevel + * + * @return string The formatted access_level resource. + */ + public static function accessLevelName(string $accessPolicy, string $accessLevel): string + { + return self::getPathTemplate('accessLevel')->render([ + 'access_policy' => $accessPolicy, + 'access_level' => $accessLevel, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * access_policy resource. + * + * @param string $accessPolicy + * + * @return string The formatted access_policy resource. + */ + public static function accessPolicyName(string $accessPolicy): string + { + return self::getPathTemplate('accessPolicy')->render([ + 'access_policy' => $accessPolicy, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * gcp_user_access_binding resource. + * + * @param string $organization + * @param string $gcpUserAccessBinding + * + * @return string The formatted gcp_user_access_binding resource. + */ + public static function gcpUserAccessBindingName(string $organization, string $gcpUserAccessBinding): string + { + return self::getPathTemplate('gcpUserAccessBinding')->render([ + 'organization' => $organization, + 'gcp_user_access_binding' => $gcpUserAccessBinding, + ]); + } + + /** + * 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(string $organization): string + { + return self::getPathTemplate('organization')->render([ + 'organization' => $organization, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * service_perimeter resource. + * + * @param string $accessPolicy + * @param string $servicePerimeter + * + * @return string The formatted service_perimeter resource. + */ + public static function servicePerimeterName(string $accessPolicy, string $servicePerimeter): string + { + return self::getPathTemplate('servicePerimeter')->render([ + 'access_policy' => $accessPolicy, + 'service_perimeter' => $servicePerimeter, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - accessLevel: accessPolicies/{access_policy}/accessLevels/{access_level} + * - accessPolicy: accessPolicies/{access_policy} + * - gcpUserAccessBinding: organizations/{organization}/gcpUserAccessBindings/{gcp_user_access_binding} + * - organization: organizations/{organization} + * - servicePerimeter: accessPolicies/{access_policy}/servicePerimeters/{service_perimeter} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'accesscontextmanager.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Commits the dry-run specification for all the [service perimeters] + * [google.identity.accesscontextmanager.v1.ServicePerimeter] in an + * [access policy][google.identity.accesscontextmanager.v1.AccessPolicy]. + * A commit operation on a service perimeter involves copying its `spec` field + * to the `status` field of the service perimeter. Only [service perimeters] + * [google.identity.accesscontextmanager.v1.ServicePerimeter] with + * `use_explicit_dry_run_spec` field set to true are affected by a commit + * operation. The long-running operation from this RPC has a successful + * status after the dry-run specifications for all the [service perimeters] + * [google.identity.accesscontextmanager.v1.ServicePerimeter] have been + * committed. If a commit fails, it causes the long-running operation to + * return an error response and the entire commit operation is cancelled. + * When successful, the Operation.response field contains + * CommitServicePerimetersResponse. The `dry_run` and the `spec` fields are + * cleared after a successful commit operation. + * + * The async variant is + * {@see AccessContextManagerClient::commitServicePerimetersAsync()} . + * + * @example samples/V1/AccessContextManagerClient/commit_service_perimeters.php + * + * @param CommitServicePerimetersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function commitServicePerimeters(CommitServicePerimetersRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CommitServicePerimeters', $request, $callOptions)->wait(); + } + + /** + * Creates an [access level] + * [google.identity.accesscontextmanager.v1.AccessLevel]. The long-running + * operation from this RPC has a successful status after the [access + * level] [google.identity.accesscontextmanager.v1.AccessLevel] + * propagates to long-lasting storage. If [access levels] + * [google.identity.accesscontextmanager.v1.AccessLevel] contain + * errors, an error response is returned for the first error encountered. + * + * The async variant is {@see AccessContextManagerClient::createAccessLevelAsync()} + * . + * + * @example samples/V1/AccessContextManagerClient/create_access_level.php + * + * @param CreateAccessLevelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAccessLevel(CreateAccessLevelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateAccessLevel', $request, $callOptions)->wait(); + } + + /** + * Creates an access policy. This method fails if the organization already has + * an access policy. The long-running operation has a successful status + * after the access policy propagates to long-lasting storage. + * Syntactic and basic semantic errors are returned in `metadata` as a + * BadRequest proto. + * + * The async variant is + * {@see AccessContextManagerClient::createAccessPolicyAsync()} . + * + * @example samples/V1/AccessContextManagerClient/create_access_policy.php + * + * @param AccessPolicy $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAccessPolicy(AccessPolicy $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateAccessPolicy', $request, $callOptions)->wait(); + } + + /** + * Creates a [GcpUserAccessBinding] + * [google.identity.accesscontextmanager.v1.GcpUserAccessBinding]. If the + * client specifies a [name] + * [google.identity.accesscontextmanager.v1.GcpUserAccessBinding.name], + * the server ignores it. Fails if a resource already exists with the same + * [group_key] + * [google.identity.accesscontextmanager.v1.GcpUserAccessBinding.group_key]. + * Completion of this long-running operation does not necessarily signify that + * the new binding is deployed onto all affected users, which may take more + * time. + * + * The async variant is + * {@see AccessContextManagerClient::createGcpUserAccessBindingAsync()} . + * + * @example samples/V1/AccessContextManagerClient/create_gcp_user_access_binding.php + * + * @param CreateGcpUserAccessBindingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createGcpUserAccessBinding(CreateGcpUserAccessBindingRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateGcpUserAccessBinding', $request, $callOptions)->wait(); + } + + /** + * Creates a [service perimeter] + * [google.identity.accesscontextmanager.v1.ServicePerimeter]. The + * long-running operation from this RPC has a successful status after the + * [service perimeter] + * [google.identity.accesscontextmanager.v1.ServicePerimeter] + * propagates to long-lasting storage. If a [service perimeter] + * [google.identity.accesscontextmanager.v1.ServicePerimeter] contains + * errors, an error response is returned for the first error encountered. + * + * The async variant is + * {@see AccessContextManagerClient::createServicePerimeterAsync()} . + * + * @example samples/V1/AccessContextManagerClient/create_service_perimeter.php + * + * @param CreateServicePerimeterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createServicePerimeter(CreateServicePerimeterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateServicePerimeter', $request, $callOptions)->wait(); + } + + /** + * Deletes an [access level] + * [google.identity.accesscontextmanager.v1.AccessLevel] based on the resource + * name. The long-running operation from this RPC has a successful status + * after the [access level] + * [google.identity.accesscontextmanager.v1.AccessLevel] has been removed + * from long-lasting storage. + * + * The async variant is {@see AccessContextManagerClient::deleteAccessLevelAsync()} + * . + * + * @example samples/V1/AccessContextManagerClient/delete_access_level.php + * + * @param DeleteAccessLevelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAccessLevel(DeleteAccessLevelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteAccessLevel', $request, $callOptions)->wait(); + } + + /** + * Deletes an [access policy] + * [google.identity.accesscontextmanager.v1.AccessPolicy] based on the + * resource name. The long-running operation has a successful status after the + * [access policy] [google.identity.accesscontextmanager.v1.AccessPolicy] + * is removed from long-lasting storage. + * + * The async variant is + * {@see AccessContextManagerClient::deleteAccessPolicyAsync()} . + * + * @example samples/V1/AccessContextManagerClient/delete_access_policy.php + * + * @param DeleteAccessPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAccessPolicy(DeleteAccessPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteAccessPolicy', $request, $callOptions)->wait(); + } + + /** + * Deletes a [GcpUserAccessBinding] + * [google.identity.accesscontextmanager.v1.GcpUserAccessBinding]. + * Completion of this long-running operation does not necessarily signify that + * the binding deletion is deployed onto all affected users, which may take + * more time. + * + * The async variant is + * {@see AccessContextManagerClient::deleteGcpUserAccessBindingAsync()} . + * + * @example samples/V1/AccessContextManagerClient/delete_gcp_user_access_binding.php + * + * @param DeleteGcpUserAccessBindingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteGcpUserAccessBinding(DeleteGcpUserAccessBindingRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteGcpUserAccessBinding', $request, $callOptions)->wait(); + } + + /** + * Deletes a [service perimeter] + * [google.identity.accesscontextmanager.v1.ServicePerimeter] based on the + * resource name. The long-running operation from this RPC has a successful + * status after the [service perimeter] + * [google.identity.accesscontextmanager.v1.ServicePerimeter] is removed from + * long-lasting storage. + * + * The async variant is + * {@see AccessContextManagerClient::deleteServicePerimeterAsync()} . + * + * @example samples/V1/AccessContextManagerClient/delete_service_perimeter.php + * + * @param DeleteServicePerimeterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteServicePerimeter(DeleteServicePerimeterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteServicePerimeter', $request, $callOptions)->wait(); + } + + /** + * Gets an [access level] + * [google.identity.accesscontextmanager.v1.AccessLevel] based on the resource + * name. + * + * The async variant is {@see AccessContextManagerClient::getAccessLevelAsync()} . + * + * @example samples/V1/AccessContextManagerClient/get_access_level.php + * + * @param GetAccessLevelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AccessLevel + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAccessLevel(GetAccessLevelRequest $request, array $callOptions = []): AccessLevel + { + return $this->startApiCall('GetAccessLevel', $request, $callOptions)->wait(); + } + + /** + * Returns an [access policy] + * [google.identity.accesscontextmanager.v1.AccessPolicy] based on the name. + * + * The async variant is {@see AccessContextManagerClient::getAccessPolicyAsync()} . + * + * @example samples/V1/AccessContextManagerClient/get_access_policy.php + * + * @param GetAccessPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AccessPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAccessPolicy(GetAccessPolicyRequest $request, array $callOptions = []): AccessPolicy + { + return $this->startApiCall('GetAccessPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets the [GcpUserAccessBinding] + * [google.identity.accesscontextmanager.v1.GcpUserAccessBinding] with + * the given name. + * + * The async variant is + * {@see AccessContextManagerClient::getGcpUserAccessBindingAsync()} . + * + * @example samples/V1/AccessContextManagerClient/get_gcp_user_access_binding.php + * + * @param GetGcpUserAccessBindingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GcpUserAccessBinding + * + * @throws ApiException Thrown if the API call fails. + */ + public function getGcpUserAccessBinding(GetGcpUserAccessBindingRequest $request, array $callOptions = []): GcpUserAccessBinding + { + return $this->startApiCall('GetGcpUserAccessBinding', $request, $callOptions)->wait(); + } + + /** + * Gets the IAM policy for the specified Access Context Manager + * [access policy][google.identity.accesscontextmanager.v1.AccessPolicy]. + * + * The async variant is {@see AccessContextManagerClient::getIamPolicyAsync()} . + * + * @example samples/V1/AccessContextManagerClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets a [service perimeter] + * [google.identity.accesscontextmanager.v1.ServicePerimeter] based on the + * resource name. + * + * The async variant is + * {@see AccessContextManagerClient::getServicePerimeterAsync()} . + * + * @example samples/V1/AccessContextManagerClient/get_service_perimeter.php + * + * @param GetServicePerimeterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ServicePerimeter + * + * @throws ApiException Thrown if the API call fails. + */ + public function getServicePerimeter(GetServicePerimeterRequest $request, array $callOptions = []): ServicePerimeter + { + return $this->startApiCall('GetServicePerimeter', $request, $callOptions)->wait(); + } + + /** + * Lists all [access levels] + * [google.identity.accesscontextmanager.v1.AccessLevel] for an access + * policy. + * + * The async variant is {@see AccessContextManagerClient::listAccessLevelsAsync()} + * . + * + * @example samples/V1/AccessContextManagerClient/list_access_levels.php + * + * @param ListAccessLevelsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAccessLevels(ListAccessLevelsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAccessLevels', $request, $callOptions); + } + + /** + * Lists all [access policies] + * [google.identity.accesscontextmanager.v1.AccessPolicy] in an + * organization. + * + * The async variant is + * {@see AccessContextManagerClient::listAccessPoliciesAsync()} . + * + * @example samples/V1/AccessContextManagerClient/list_access_policies.php + * + * @param ListAccessPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAccessPolicies(ListAccessPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAccessPolicies', $request, $callOptions); + } + + /** + * Lists all [GcpUserAccessBindings] + * [google.identity.accesscontextmanager.v1.GcpUserAccessBinding] for a + * Google Cloud organization. + * + * The async variant is + * {@see AccessContextManagerClient::listGcpUserAccessBindingsAsync()} . + * + * @example samples/V1/AccessContextManagerClient/list_gcp_user_access_bindings.php + * + * @param ListGcpUserAccessBindingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listGcpUserAccessBindings(ListGcpUserAccessBindingsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListGcpUserAccessBindings', $request, $callOptions); + } + + /** + * Lists all [service perimeters] + * [google.identity.accesscontextmanager.v1.ServicePerimeter] for an + * access policy. + * + * The async variant is + * {@see AccessContextManagerClient::listServicePerimetersAsync()} . + * + * @example samples/V1/AccessContextManagerClient/list_service_perimeters.php + * + * @param ListServicePerimetersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listServicePerimeters(ListServicePerimetersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListServicePerimeters', $request, $callOptions); + } + + /** + * Replaces all existing [access levels] + * [google.identity.accesscontextmanager.v1.AccessLevel] in an [access + * policy] [google.identity.accesscontextmanager.v1.AccessPolicy] with + * the [access levels] + * [google.identity.accesscontextmanager.v1.AccessLevel] provided. This + * is done atomically. The long-running operation from this RPC has a + * successful status after all replacements propagate to long-lasting + * storage. If the replacement contains errors, an error response is returned + * for the first error encountered. Upon error, the replacement is cancelled, + * and existing [access levels] + * [google.identity.accesscontextmanager.v1.AccessLevel] are not + * affected. The Operation.response field contains + * ReplaceAccessLevelsResponse. Removing [access levels] + * [google.identity.accesscontextmanager.v1.AccessLevel] contained in existing + * [service perimeters] + * [google.identity.accesscontextmanager.v1.ServicePerimeter] result in an + * error. + * + * The async variant is + * {@see AccessContextManagerClient::replaceAccessLevelsAsync()} . + * + * @example samples/V1/AccessContextManagerClient/replace_access_levels.php + * + * @param ReplaceAccessLevelsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function replaceAccessLevels(ReplaceAccessLevelsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ReplaceAccessLevels', $request, $callOptions)->wait(); + } + + /** + * Replace all existing [service perimeters] + * [google.identity.accesscontextmanager.v1.ServicePerimeter] in an [access + * policy] [google.identity.accesscontextmanager.v1.AccessPolicy] with the + * [service perimeters] + * [google.identity.accesscontextmanager.v1.ServicePerimeter] provided. This + * is done atomically. The long-running operation from this RPC has a + * successful status after all replacements propagate to long-lasting storage. + * Replacements containing errors result in an error response for the first + * error encountered. Upon an error, replacement are cancelled and existing + * [service perimeters] + * [google.identity.accesscontextmanager.v1.ServicePerimeter] are not + * affected. The Operation.response field contains + * ReplaceServicePerimetersResponse. + * + * The async variant is + * {@see AccessContextManagerClient::replaceServicePerimetersAsync()} . + * + * @example samples/V1/AccessContextManagerClient/replace_service_perimeters.php + * + * @param ReplaceServicePerimetersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function replaceServicePerimeters(ReplaceServicePerimetersRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ReplaceServicePerimeters', $request, $callOptions)->wait(); + } + + /** + * Sets the IAM policy for the specified Access Context Manager + * [access policy][google.identity.accesscontextmanager.v1.AccessPolicy]. + * This method replaces the existing IAM policy on the access policy. The IAM + * policy controls the set of users who can perform specific operations on the + * Access Context Manager [access + * policy][google.identity.accesscontextmanager.v1.AccessPolicy]. + * + * The async variant is {@see AccessContextManagerClient::setIamPolicyAsync()} . + * + * @example samples/V1/AccessContextManagerClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns the IAM permissions that the caller has on the specified Access + * Context Manager resource. The resource can be an + * [AccessPolicy][google.identity.accesscontextmanager.v1.AccessPolicy], + * [AccessLevel][google.identity.accesscontextmanager.v1.AccessLevel], or + * [ServicePerimeter][google.identity.accesscontextmanager.v1.ServicePerimeter + * ]. This method does not support other resources. + * + * The async variant is + * {@see AccessContextManagerClient::testIamPermissionsAsync()} . + * + * @example samples/V1/AccessContextManagerClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates an [access level] + * [google.identity.accesscontextmanager.v1.AccessLevel]. The long-running + * operation from this RPC has a successful status after the changes to + * the [access level] + * [google.identity.accesscontextmanager.v1.AccessLevel] propagate + * to long-lasting storage. If [access levels] + * [google.identity.accesscontextmanager.v1.AccessLevel] contain + * errors, an error response is returned for the first error encountered. + * + * The async variant is {@see AccessContextManagerClient::updateAccessLevelAsync()} + * . + * + * @example samples/V1/AccessContextManagerClient/update_access_level.php + * + * @param UpdateAccessLevelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAccessLevel(UpdateAccessLevelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateAccessLevel', $request, $callOptions)->wait(); + } + + /** + * Updates an [access policy] + * [google.identity.accesscontextmanager.v1.AccessPolicy]. The + * long-running operation from this RPC has a successful status after the + * changes to the [access policy] + * [google.identity.accesscontextmanager.v1.AccessPolicy] propagate + * to long-lasting storage. + * + * The async variant is + * {@see AccessContextManagerClient::updateAccessPolicyAsync()} . + * + * @example samples/V1/AccessContextManagerClient/update_access_policy.php + * + * @param UpdateAccessPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAccessPolicy(UpdateAccessPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateAccessPolicy', $request, $callOptions)->wait(); + } + + /** + * Updates a [GcpUserAccessBinding] + * [google.identity.accesscontextmanager.v1.GcpUserAccessBinding]. + * Completion of this long-running operation does not necessarily signify that + * the changed binding is deployed onto all affected users, which may take + * more time. + * + * The async variant is + * {@see AccessContextManagerClient::updateGcpUserAccessBindingAsync()} . + * + * @example samples/V1/AccessContextManagerClient/update_gcp_user_access_binding.php + * + * @param UpdateGcpUserAccessBindingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateGcpUserAccessBinding(UpdateGcpUserAccessBindingRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateGcpUserAccessBinding', $request, $callOptions)->wait(); + } + + /** + * Updates a [service perimeter] + * [google.identity.accesscontextmanager.v1.ServicePerimeter]. The + * long-running operation from this RPC has a successful status after the + * [service perimeter] + * [google.identity.accesscontextmanager.v1.ServicePerimeter] + * propagates to long-lasting storage. If a [service perimeter] + * [google.identity.accesscontextmanager.v1.ServicePerimeter] contains + * errors, an error response is returned for the first error encountered. + * + * The async variant is + * {@see AccessContextManagerClient::updateServicePerimeterAsync()} . + * + * @example samples/V1/AccessContextManagerClient/update_service_perimeter.php + * + * @param UpdateServicePerimeterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateServicePerimeter(UpdateServicePerimeterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateServicePerimeter', $request, $callOptions)->wait(); + } } diff --git a/AccessContextManager/src/V1/Client/BaseClient/AccessContextManagerBaseClient.php b/AccessContextManager/src/V1/Client/BaseClient/AccessContextManagerBaseClient.php deleted file mode 100644 index fd46605ac7c9..000000000000 --- a/AccessContextManager/src/V1/Client/BaseClient/AccessContextManagerBaseClient.php +++ /dev/null @@ -1,1194 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/access_context_manager_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/access_context_manager_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/access_context_manager_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/access_context_manager_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a access_level - * resource. - * - * @param string $accessPolicy - * @param string $accessLevel - * - * @return string The formatted access_level resource. - */ - public static function accessLevelName(string $accessPolicy, string $accessLevel): string - { - return self::getPathTemplate('accessLevel')->render([ - 'access_policy' => $accessPolicy, - 'access_level' => $accessLevel, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * access_policy resource. - * - * @param string $accessPolicy - * - * @return string The formatted access_policy resource. - */ - public static function accessPolicyName(string $accessPolicy): string - { - return self::getPathTemplate('accessPolicy')->render([ - 'access_policy' => $accessPolicy, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * gcp_user_access_binding resource. - * - * @param string $organization - * @param string $gcpUserAccessBinding - * - * @return string The formatted gcp_user_access_binding resource. - */ - public static function gcpUserAccessBindingName(string $organization, string $gcpUserAccessBinding): string - { - return self::getPathTemplate('gcpUserAccessBinding')->render([ - 'organization' => $organization, - 'gcp_user_access_binding' => $gcpUserAccessBinding, - ]); - } - - /** - * 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(string $organization): string - { - return self::getPathTemplate('organization')->render([ - 'organization' => $organization, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * service_perimeter resource. - * - * @param string $accessPolicy - * @param string $servicePerimeter - * - * @return string The formatted service_perimeter resource. - */ - public static function servicePerimeterName(string $accessPolicy, string $servicePerimeter): string - { - return self::getPathTemplate('servicePerimeter')->render([ - 'access_policy' => $accessPolicy, - 'service_perimeter' => $servicePerimeter, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - accessLevel: accessPolicies/{access_policy}/accessLevels/{access_level} - * - accessPolicy: accessPolicies/{access_policy} - * - gcpUserAccessBinding: organizations/{organization}/gcpUserAccessBindings/{gcp_user_access_binding} - * - organization: organizations/{organization} - * - servicePerimeter: accessPolicies/{access_policy}/servicePerimeters/{service_perimeter} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'accesscontextmanager.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Commits the dry-run specification for all the [service perimeters] - * [google.identity.accesscontextmanager.v1.ServicePerimeter] in an - * [access policy][google.identity.accesscontextmanager.v1.AccessPolicy]. - * A commit operation on a service perimeter involves copying its `spec` field - * to the `status` field of the service perimeter. Only [service perimeters] - * [google.identity.accesscontextmanager.v1.ServicePerimeter] with - * `use_explicit_dry_run_spec` field set to true are affected by a commit - * operation. The long-running operation from this RPC has a successful - * status after the dry-run specifications for all the [service perimeters] - * [google.identity.accesscontextmanager.v1.ServicePerimeter] have been - * committed. If a commit fails, it causes the long-running operation to - * return an error response and the entire commit operation is cancelled. - * When successful, the Operation.response field contains - * CommitServicePerimetersResponse. The `dry_run` and the `spec` fields are - * cleared after a successful commit operation. - * - * The async variant is {@see self::commitServicePerimetersAsync()} . - * - * @example samples/V1/AccessContextManagerClient/commit_service_perimeters.php - * - * @param CommitServicePerimetersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function commitServicePerimeters(CommitServicePerimetersRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CommitServicePerimeters', $request, $callOptions)->wait(); - } - - /** - * Creates an [access level] - * [google.identity.accesscontextmanager.v1.AccessLevel]. The long-running - * operation from this RPC has a successful status after the [access - * level] [google.identity.accesscontextmanager.v1.AccessLevel] - * propagates to long-lasting storage. If [access levels] - * [google.identity.accesscontextmanager.v1.AccessLevel] contain - * errors, an error response is returned for the first error encountered. - * - * The async variant is {@see self::createAccessLevelAsync()} . - * - * @example samples/V1/AccessContextManagerClient/create_access_level.php - * - * @param CreateAccessLevelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAccessLevel(CreateAccessLevelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateAccessLevel', $request, $callOptions)->wait(); - } - - /** - * Creates an access policy. This method fails if the organization already has - * an access policy. The long-running operation has a successful status - * after the access policy propagates to long-lasting storage. - * Syntactic and basic semantic errors are returned in `metadata` as a - * BadRequest proto. - * - * The async variant is {@see self::createAccessPolicyAsync()} . - * - * @example samples/V1/AccessContextManagerClient/create_access_policy.php - * - * @param AccessPolicy $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAccessPolicy(AccessPolicy $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateAccessPolicy', $request, $callOptions)->wait(); - } - - /** - * Creates a [GcpUserAccessBinding] - * [google.identity.accesscontextmanager.v1.GcpUserAccessBinding]. If the - * client specifies a [name] - * [google.identity.accesscontextmanager.v1.GcpUserAccessBinding.name], - * the server ignores it. Fails if a resource already exists with the same - * [group_key] - * [google.identity.accesscontextmanager.v1.GcpUserAccessBinding.group_key]. - * Completion of this long-running operation does not necessarily signify that - * the new binding is deployed onto all affected users, which may take more - * time. - * - * The async variant is {@see self::createGcpUserAccessBindingAsync()} . - * - * @example samples/V1/AccessContextManagerClient/create_gcp_user_access_binding.php - * - * @param CreateGcpUserAccessBindingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createGcpUserAccessBinding(CreateGcpUserAccessBindingRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateGcpUserAccessBinding', $request, $callOptions)->wait(); - } - - /** - * Creates a [service perimeter] - * [google.identity.accesscontextmanager.v1.ServicePerimeter]. The - * long-running operation from this RPC has a successful status after the - * [service perimeter] - * [google.identity.accesscontextmanager.v1.ServicePerimeter] - * propagates to long-lasting storage. If a [service perimeter] - * [google.identity.accesscontextmanager.v1.ServicePerimeter] contains - * errors, an error response is returned for the first error encountered. - * - * The async variant is {@see self::createServicePerimeterAsync()} . - * - * @example samples/V1/AccessContextManagerClient/create_service_perimeter.php - * - * @param CreateServicePerimeterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createServicePerimeter(CreateServicePerimeterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateServicePerimeter', $request, $callOptions)->wait(); - } - - /** - * Deletes an [access level] - * [google.identity.accesscontextmanager.v1.AccessLevel] based on the resource - * name. The long-running operation from this RPC has a successful status - * after the [access level] - * [google.identity.accesscontextmanager.v1.AccessLevel] has been removed - * from long-lasting storage. - * - * The async variant is {@see self::deleteAccessLevelAsync()} . - * - * @example samples/V1/AccessContextManagerClient/delete_access_level.php - * - * @param DeleteAccessLevelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAccessLevel(DeleteAccessLevelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteAccessLevel', $request, $callOptions)->wait(); - } - - /** - * Deletes an [access policy] - * [google.identity.accesscontextmanager.v1.AccessPolicy] based on the - * resource name. The long-running operation has a successful status after the - * [access policy] [google.identity.accesscontextmanager.v1.AccessPolicy] - * is removed from long-lasting storage. - * - * The async variant is {@see self::deleteAccessPolicyAsync()} . - * - * @example samples/V1/AccessContextManagerClient/delete_access_policy.php - * - * @param DeleteAccessPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAccessPolicy(DeleteAccessPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteAccessPolicy', $request, $callOptions)->wait(); - } - - /** - * Deletes a [GcpUserAccessBinding] - * [google.identity.accesscontextmanager.v1.GcpUserAccessBinding]. - * Completion of this long-running operation does not necessarily signify that - * the binding deletion is deployed onto all affected users, which may take - * more time. - * - * The async variant is {@see self::deleteGcpUserAccessBindingAsync()} . - * - * @example samples/V1/AccessContextManagerClient/delete_gcp_user_access_binding.php - * - * @param DeleteGcpUserAccessBindingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteGcpUserAccessBinding(DeleteGcpUserAccessBindingRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteGcpUserAccessBinding', $request, $callOptions)->wait(); - } - - /** - * Deletes a [service perimeter] - * [google.identity.accesscontextmanager.v1.ServicePerimeter] based on the - * resource name. The long-running operation from this RPC has a successful - * status after the [service perimeter] - * [google.identity.accesscontextmanager.v1.ServicePerimeter] is removed from - * long-lasting storage. - * - * The async variant is {@see self::deleteServicePerimeterAsync()} . - * - * @example samples/V1/AccessContextManagerClient/delete_service_perimeter.php - * - * @param DeleteServicePerimeterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteServicePerimeter(DeleteServicePerimeterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteServicePerimeter', $request, $callOptions)->wait(); - } - - /** - * Gets an [access level] - * [google.identity.accesscontextmanager.v1.AccessLevel] based on the resource - * name. - * - * The async variant is {@see self::getAccessLevelAsync()} . - * - * @example samples/V1/AccessContextManagerClient/get_access_level.php - * - * @param GetAccessLevelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AccessLevel - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAccessLevel(GetAccessLevelRequest $request, array $callOptions = []): AccessLevel - { - return $this->startApiCall('GetAccessLevel', $request, $callOptions)->wait(); - } - - /** - * Returns an [access policy] - * [google.identity.accesscontextmanager.v1.AccessPolicy] based on the name. - * - * The async variant is {@see self::getAccessPolicyAsync()} . - * - * @example samples/V1/AccessContextManagerClient/get_access_policy.php - * - * @param GetAccessPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AccessPolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAccessPolicy(GetAccessPolicyRequest $request, array $callOptions = []): AccessPolicy - { - return $this->startApiCall('GetAccessPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets the [GcpUserAccessBinding] - * [google.identity.accesscontextmanager.v1.GcpUserAccessBinding] with - * the given name. - * - * The async variant is {@see self::getGcpUserAccessBindingAsync()} . - * - * @example samples/V1/AccessContextManagerClient/get_gcp_user_access_binding.php - * - * @param GetGcpUserAccessBindingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GcpUserAccessBinding - * - * @throws ApiException Thrown if the API call fails. - */ - public function getGcpUserAccessBinding(GetGcpUserAccessBindingRequest $request, array $callOptions = []): GcpUserAccessBinding - { - return $this->startApiCall('GetGcpUserAccessBinding', $request, $callOptions)->wait(); - } - - /** - * Gets the IAM policy for the specified Access Context Manager - * [access policy][google.identity.accesscontextmanager.v1.AccessPolicy]. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/AccessContextManagerClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets a [service perimeter] - * [google.identity.accesscontextmanager.v1.ServicePerimeter] based on the - * resource name. - * - * The async variant is {@see self::getServicePerimeterAsync()} . - * - * @example samples/V1/AccessContextManagerClient/get_service_perimeter.php - * - * @param GetServicePerimeterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ServicePerimeter - * - * @throws ApiException Thrown if the API call fails. - */ - public function getServicePerimeter(GetServicePerimeterRequest $request, array $callOptions = []): ServicePerimeter - { - return $this->startApiCall('GetServicePerimeter', $request, $callOptions)->wait(); - } - - /** - * Lists all [access levels] - * [google.identity.accesscontextmanager.v1.AccessLevel] for an access - * policy. - * - * The async variant is {@see self::listAccessLevelsAsync()} . - * - * @example samples/V1/AccessContextManagerClient/list_access_levels.php - * - * @param ListAccessLevelsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAccessLevels(ListAccessLevelsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAccessLevels', $request, $callOptions); - } - - /** - * Lists all [access policies] - * [google.identity.accesscontextmanager.v1.AccessPolicy] in an - * organization. - * - * The async variant is {@see self::listAccessPoliciesAsync()} . - * - * @example samples/V1/AccessContextManagerClient/list_access_policies.php - * - * @param ListAccessPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAccessPolicies(ListAccessPoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAccessPolicies', $request, $callOptions); - } - - /** - * Lists all [GcpUserAccessBindings] - * [google.identity.accesscontextmanager.v1.GcpUserAccessBinding] for a - * Google Cloud organization. - * - * The async variant is {@see self::listGcpUserAccessBindingsAsync()} . - * - * @example samples/V1/AccessContextManagerClient/list_gcp_user_access_bindings.php - * - * @param ListGcpUserAccessBindingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listGcpUserAccessBindings(ListGcpUserAccessBindingsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListGcpUserAccessBindings', $request, $callOptions); - } - - /** - * Lists all [service perimeters] - * [google.identity.accesscontextmanager.v1.ServicePerimeter] for an - * access policy. - * - * The async variant is {@see self::listServicePerimetersAsync()} . - * - * @example samples/V1/AccessContextManagerClient/list_service_perimeters.php - * - * @param ListServicePerimetersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listServicePerimeters(ListServicePerimetersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListServicePerimeters', $request, $callOptions); - } - - /** - * Replaces all existing [access levels] - * [google.identity.accesscontextmanager.v1.AccessLevel] in an [access - * policy] [google.identity.accesscontextmanager.v1.AccessPolicy] with - * the [access levels] - * [google.identity.accesscontextmanager.v1.AccessLevel] provided. This - * is done atomically. The long-running operation from this RPC has a - * successful status after all replacements propagate to long-lasting - * storage. If the replacement contains errors, an error response is returned - * for the first error encountered. Upon error, the replacement is cancelled, - * and existing [access levels] - * [google.identity.accesscontextmanager.v1.AccessLevel] are not - * affected. The Operation.response field contains - * ReplaceAccessLevelsResponse. Removing [access levels] - * [google.identity.accesscontextmanager.v1.AccessLevel] contained in existing - * [service perimeters] - * [google.identity.accesscontextmanager.v1.ServicePerimeter] result in an - * error. - * - * The async variant is {@see self::replaceAccessLevelsAsync()} . - * - * @example samples/V1/AccessContextManagerClient/replace_access_levels.php - * - * @param ReplaceAccessLevelsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function replaceAccessLevels(ReplaceAccessLevelsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ReplaceAccessLevels', $request, $callOptions)->wait(); - } - - /** - * Replace all existing [service perimeters] - * [google.identity.accesscontextmanager.v1.ServicePerimeter] in an [access - * policy] [google.identity.accesscontextmanager.v1.AccessPolicy] with the - * [service perimeters] - * [google.identity.accesscontextmanager.v1.ServicePerimeter] provided. This - * is done atomically. The long-running operation from this RPC has a - * successful status after all replacements propagate to long-lasting storage. - * Replacements containing errors result in an error response for the first - * error encountered. Upon an error, replacement are cancelled and existing - * [service perimeters] - * [google.identity.accesscontextmanager.v1.ServicePerimeter] are not - * affected. The Operation.response field contains - * ReplaceServicePerimetersResponse. - * - * The async variant is {@see self::replaceServicePerimetersAsync()} . - * - * @example samples/V1/AccessContextManagerClient/replace_service_perimeters.php - * - * @param ReplaceServicePerimetersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function replaceServicePerimeters(ReplaceServicePerimetersRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ReplaceServicePerimeters', $request, $callOptions)->wait(); - } - - /** - * Sets the IAM policy for the specified Access Context Manager - * [access policy][google.identity.accesscontextmanager.v1.AccessPolicy]. - * This method replaces the existing IAM policy on the access policy. The IAM - * policy controls the set of users who can perform specific operations on the - * Access Context Manager [access - * policy][google.identity.accesscontextmanager.v1.AccessPolicy]. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/AccessContextManagerClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns the IAM permissions that the caller has on the specified Access - * Context Manager resource. The resource can be an - * [AccessPolicy][google.identity.accesscontextmanager.v1.AccessPolicy], - * [AccessLevel][google.identity.accesscontextmanager.v1.AccessLevel], or - * [ServicePerimeter][google.identity.accesscontextmanager.v1.ServicePerimeter - * ]. This method does not support other resources. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/AccessContextManagerClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Updates an [access level] - * [google.identity.accesscontextmanager.v1.AccessLevel]. The long-running - * operation from this RPC has a successful status after the changes to - * the [access level] - * [google.identity.accesscontextmanager.v1.AccessLevel] propagate - * to long-lasting storage. If [access levels] - * [google.identity.accesscontextmanager.v1.AccessLevel] contain - * errors, an error response is returned for the first error encountered. - * - * The async variant is {@see self::updateAccessLevelAsync()} . - * - * @example samples/V1/AccessContextManagerClient/update_access_level.php - * - * @param UpdateAccessLevelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAccessLevel(UpdateAccessLevelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateAccessLevel', $request, $callOptions)->wait(); - } - - /** - * Updates an [access policy] - * [google.identity.accesscontextmanager.v1.AccessPolicy]. The - * long-running operation from this RPC has a successful status after the - * changes to the [access policy] - * [google.identity.accesscontextmanager.v1.AccessPolicy] propagate - * to long-lasting storage. - * - * The async variant is {@see self::updateAccessPolicyAsync()} . - * - * @example samples/V1/AccessContextManagerClient/update_access_policy.php - * - * @param UpdateAccessPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAccessPolicy(UpdateAccessPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateAccessPolicy', $request, $callOptions)->wait(); - } - - /** - * Updates a [GcpUserAccessBinding] - * [google.identity.accesscontextmanager.v1.GcpUserAccessBinding]. - * Completion of this long-running operation does not necessarily signify that - * the changed binding is deployed onto all affected users, which may take - * more time. - * - * The async variant is {@see self::updateGcpUserAccessBindingAsync()} . - * - * @example samples/V1/AccessContextManagerClient/update_gcp_user_access_binding.php - * - * @param UpdateGcpUserAccessBindingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateGcpUserAccessBinding(UpdateGcpUserAccessBindingRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateGcpUserAccessBinding', $request, $callOptions)->wait(); - } - - /** - * Updates a [service perimeter] - * [google.identity.accesscontextmanager.v1.ServicePerimeter]. The - * long-running operation from this RPC has a successful status after the - * [service perimeter] - * [google.identity.accesscontextmanager.v1.ServicePerimeter] - * propagates to long-lasting storage. If a [service perimeter] - * [google.identity.accesscontextmanager.v1.ServicePerimeter] contains - * errors, an error response is returned for the first error encountered. - * - * The async variant is {@see self::updateServicePerimeterAsync()} . - * - * @example samples/V1/AccessContextManagerClient/update_service_perimeter.php - * - * @param UpdateServicePerimeterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateServicePerimeter(UpdateServicePerimeterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateServicePerimeter', $request, $callOptions)->wait(); - } -} diff --git a/AdvisoryNotifications/composer.json b/AdvisoryNotifications/composer.json index 4cd362bd1aa2..4c093eebd71c 100644 --- a/AdvisoryNotifications/composer.json +++ b/AdvisoryNotifications/composer.json @@ -18,7 +18,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/AdvisoryNotifications/src/V1/Client/AdvisoryNotificationsServiceClient.php b/AdvisoryNotifications/src/V1/Client/AdvisoryNotificationsServiceClient.php index eec5ae8e684f..9fec0786cf75 100644 --- a/AdvisoryNotifications/src/V1/Client/AdvisoryNotificationsServiceClient.php +++ b/AdvisoryNotifications/src/V1/Client/AdvisoryNotificationsServiceClient.php @@ -24,17 +24,341 @@ namespace Google\Cloud\AdvisoryNotifications\V1\Client; -use Google\Cloud\AdvisoryNotifications\V1\Client\BaseClient\AdvisoryNotificationsServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AdvisoryNotifications\V1\GetNotificationRequest; +use Google\Cloud\AdvisoryNotifications\V1\GetSettingsRequest; +use Google\Cloud\AdvisoryNotifications\V1\ListNotificationsRequest; +use Google\Cloud\AdvisoryNotifications\V1\Notification; +use Google\Cloud\AdvisoryNotifications\V1\Settings; +use Google\Cloud\AdvisoryNotifications\V1\UpdateSettingsRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service to manage Security and Privacy Notifications. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AdvisoryNotifications\V1\AdvisoryNotificationsServiceClient} for + * the stable implementation * * @experimental + * + * @method PromiseInterface getNotificationAsync(GetNotificationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSettingsAsync(GetSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listNotificationsAsync(ListNotificationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSettingsAsync(UpdateSettingsRequest $request, array $optionalArgs = []) */ -final class AdvisoryNotificationsServiceClient extends AdvisoryNotificationsServiceBaseClient +final class AdvisoryNotificationsServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AdvisoryNotificationsServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.advisorynotifications.v1.AdvisoryNotificationsService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'advisorynotifications.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/advisory_notifications_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/advisory_notifications_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/advisory_notifications_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/advisory_notifications_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $organization + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $organization, string $location): string + { + return self::getPathTemplate('location')->render([ + 'organization' => $organization, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a notification + * resource. + * + * @param string $organization + * @param string $location + * @param string $notification + * + * @return string The formatted notification resource. + */ + public static function notificationName(string $organization, string $location, string $notification): string + { + return self::getPathTemplate('notification')->render([ + 'organization' => $organization, + 'location' => $location, + 'notification' => $notification, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a settings + * resource. + * + * @param string $organization + * @param string $location + * + * @return string The formatted settings resource. + */ + public static function settingsName(string $organization, string $location): string + { + return self::getPathTemplate('settings')->render([ + 'organization' => $organization, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - location: organizations/{organization}/locations/{location} + * - notification: organizations/{organization}/locations/{location}/notifications/{notification} + * - settings: organizations/{organization}/locations/{location}/settings + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'advisorynotifications.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Gets a notification. + * + * The async variant is + * {@see AdvisoryNotificationsServiceClient::getNotificationAsync()} . + * + * @example samples/V1/AdvisoryNotificationsServiceClient/get_notification.php + * + * @param GetNotificationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Notification + * + * @throws ApiException Thrown if the API call fails. + */ + public function getNotification(GetNotificationRequest $request, array $callOptions = []): Notification + { + return $this->startApiCall('GetNotification', $request, $callOptions)->wait(); + } + + /** + * Get notification settings. + * + * The async variant is + * {@see AdvisoryNotificationsServiceClient::getSettingsAsync()} . + * + * @example samples/V1/AdvisoryNotificationsServiceClient/get_settings.php + * + * @param GetSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Settings + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSettings(GetSettingsRequest $request, array $callOptions = []): Settings + { + return $this->startApiCall('GetSettings', $request, $callOptions)->wait(); + } + + /** + * Lists notifications under a given parent. + * + * The async variant is + * {@see AdvisoryNotificationsServiceClient::listNotificationsAsync()} . + * + * @example samples/V1/AdvisoryNotificationsServiceClient/list_notifications.php + * + * @param ListNotificationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listNotifications(ListNotificationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListNotifications', $request, $callOptions); + } + + /** + * Update notification settings. + * + * The async variant is + * {@see AdvisoryNotificationsServiceClient::updateSettingsAsync()} . + * + * @example samples/V1/AdvisoryNotificationsServiceClient/update_settings.php + * + * @param UpdateSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Settings + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSettings(UpdateSettingsRequest $request, array $callOptions = []): Settings + { + return $this->startApiCall('UpdateSettings', $request, $callOptions)->wait(); + } } diff --git a/AdvisoryNotifications/src/V1/Client/BaseClient/AdvisoryNotificationsServiceBaseClient.php b/AdvisoryNotifications/src/V1/Client/BaseClient/AdvisoryNotificationsServiceBaseClient.php deleted file mode 100644 index 0a0537d384f8..000000000000 --- a/AdvisoryNotifications/src/V1/Client/BaseClient/AdvisoryNotificationsServiceBaseClient.php +++ /dev/null @@ -1,362 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/advisory_notifications_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/advisory_notifications_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/advisory_notifications_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/advisory_notifications_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $organization - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $organization, string $location): string - { - return self::getPathTemplate('location')->render([ - 'organization' => $organization, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a notification - * resource. - * - * @param string $organization - * @param string $location - * @param string $notification - * - * @return string The formatted notification resource. - */ - public static function notificationName(string $organization, string $location, string $notification): string - { - return self::getPathTemplate('notification')->render([ - 'organization' => $organization, - 'location' => $location, - 'notification' => $notification, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a settings - * resource. - * - * @param string $organization - * @param string $location - * - * @return string The formatted settings resource. - */ - public static function settingsName(string $organization, string $location): string - { - return self::getPathTemplate('settings')->render([ - 'organization' => $organization, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - location: organizations/{organization}/locations/{location} - * - notification: organizations/{organization}/locations/{location}/notifications/{notification} - * - settings: organizations/{organization}/locations/{location}/settings - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'advisorynotifications.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Gets a notification. - * - * The async variant is {@see self::getNotificationAsync()} . - * - * @example samples/V1/AdvisoryNotificationsServiceClient/get_notification.php - * - * @param GetNotificationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Notification - * - * @throws ApiException Thrown if the API call fails. - */ - public function getNotification(GetNotificationRequest $request, array $callOptions = []): Notification - { - return $this->startApiCall('GetNotification', $request, $callOptions)->wait(); - } - - /** - * Get notification settings. - * - * The async variant is {@see self::getSettingsAsync()} . - * - * @example samples/V1/AdvisoryNotificationsServiceClient/get_settings.php - * - * @param GetSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Settings - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSettings(GetSettingsRequest $request, array $callOptions = []): Settings - { - return $this->startApiCall('GetSettings', $request, $callOptions)->wait(); - } - - /** - * Lists notifications under a given parent. - * - * The async variant is {@see self::listNotificationsAsync()} . - * - * @example samples/V1/AdvisoryNotificationsServiceClient/list_notifications.php - * - * @param ListNotificationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listNotifications(ListNotificationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListNotifications', $request, $callOptions); - } - - /** - * Update notification settings. - * - * The async variant is {@see self::updateSettingsAsync()} . - * - * @example samples/V1/AdvisoryNotificationsServiceClient/update_settings.php - * - * @param UpdateSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Settings - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSettings(UpdateSettingsRequest $request, array $callOptions = []): Settings - { - return $this->startApiCall('UpdateSettings', $request, $callOptions)->wait(); - } -} diff --git a/AiPlatform/VERSION b/AiPlatform/VERSION index d21d277be513..4e8f395fa5e3 100644 --- a/AiPlatform/VERSION +++ b/AiPlatform/VERSION @@ -1 +1 @@ -0.25.0 +0.26.0 diff --git a/AiPlatform/composer.json b/AiPlatform/composer.json index 719c78e4d727..79509f1c4c5a 100644 --- a/AiPlatform/composer.json +++ b/AiPlatform/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/AiPlatform/metadata/V1/DatasetService.php b/AiPlatform/metadata/V1/DatasetService.php index 226fe9ce5647..8808e795c3cb 100644 Binary files a/AiPlatform/metadata/V1/DatasetService.php and b/AiPlatform/metadata/V1/DatasetService.php differ diff --git a/AiPlatform/metadata/V1/DatasetVersion.php b/AiPlatform/metadata/V1/DatasetVersion.php new file mode 100644 index 000000000000..ec2c2b7b26c5 --- /dev/null +++ b/AiPlatform/metadata/V1/DatasetVersion.php @@ -0,0 +1,37 @@ +internalAddGeneratedFile( + ' +º +0google/cloud/aiplatform/v1/dataset_version.protogoogle.cloud.aiplatform.v1google/api/resource.protogoogle/protobuf/timestamp.proto"Ñ +DatasetVersion +name ( BàA4 + create_time ( 2.google.protobuf.TimestampBàA4 + update_time ( 2.google.protobuf.TimestampBàA +etag ( # +big_query_dataset_name ( BàA:ŒêAˆ +(aiplatform.googleapis.com/DatasetVersion\\projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}BÑ +com.google.cloud.aiplatform.v1BDatasetVersionProtoPZ>cloud.google.com/go/aiplatform/apiv1/aiplatformpb;aiplatformpbªGoogle.Cloud.AIPlatform.V1ÊGoogle\\Cloud\\AIPlatform\\V1êGoogle::Cloud::AIPlatform::V1bproto3' + , true); + + static::$is_initialized = true; + } +} + diff --git a/AiPlatform/metadata/V1/MachineResources.php b/AiPlatform/metadata/V1/MachineResources.php index 3c5bc0e41a71..1e8653307b18 100644 --- a/AiPlatform/metadata/V1/MachineResources.php +++ b/AiPlatform/metadata/V1/MachineResources.php @@ -18,7 +18,8 @@ public static function initOnce() { \GPBMetadata\Google\Cloud\Aiplatform\V1\AcceleratorType::initOnce(); $pool->internalAddGeneratedFile( ' -í +¬ + 2google/cloud/aiplatform/v1/machine_resources.protogoogle.cloud.aiplatform.v11google/cloud/aiplatform/v1/accelerator_type.proto" MachineSpec machine_type ( BàAJ @@ -40,7 +41,10 @@ public static function initOnce() { replica_hours (BàA"= DiskSpec boot_disk_type (  -boot_disk_size_gb ("L +boot_disk_size_gb ("= +PersistentDiskSpec + disk_type (  + disk_size_gb ("L NfsMount server ( BàA path ( BàA diff --git a/AiPlatform/metadata/V1/ModelMonitoring.php b/AiPlatform/metadata/V1/ModelMonitoring.php index 43f211d8a999..ad96792e444f 100644 Binary files a/AiPlatform/metadata/V1/ModelMonitoring.php and b/AiPlatform/metadata/V1/ModelMonitoring.php differ diff --git a/AiPlatform/samples/V1/DatasetServiceClient/create_dataset_version.php b/AiPlatform/samples/V1/DatasetServiceClient/create_dataset_version.php new file mode 100644 index 000000000000..cded506064ac --- /dev/null +++ b/AiPlatform/samples/V1/DatasetServiceClient/create_dataset_version.php @@ -0,0 +1,87 @@ +setParent($formattedParent) + ->setDatasetVersion($datasetVersion); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $datasetServiceClient->createDatasetVersion($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var DatasetVersion $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = DatasetServiceClient::datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + + create_dataset_version_sample($formattedParent); +} +// [END aiplatform_v1_generated_DatasetService_CreateDatasetVersion_sync] diff --git a/AiPlatform/samples/V1/DatasetServiceClient/delete_dataset_version.php b/AiPlatform/samples/V1/DatasetServiceClient/delete_dataset_version.php new file mode 100644 index 000000000000..64cf118a22a4 --- /dev/null +++ b/AiPlatform/samples/V1/DatasetServiceClient/delete_dataset_version.php @@ -0,0 +1,87 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $datasetServiceClient->deleteDatasetVersion($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + printf('Operation completed successfully.' . PHP_EOL); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedName = DatasetServiceClient::datasetVersionName( + '[PROJECT]', + '[LOCATION]', + '[DATASET]', + '[DATASET_VERSION]' + ); + + delete_dataset_version_sample($formattedName); +} +// [END aiplatform_v1_generated_DatasetService_DeleteDatasetVersion_sync] diff --git a/AiPlatform/samples/V1/DatasetServiceClient/get_dataset_version.php b/AiPlatform/samples/V1/DatasetServiceClient/get_dataset_version.php new file mode 100644 index 000000000000..f7d901ae07f1 --- /dev/null +++ b/AiPlatform/samples/V1/DatasetServiceClient/get_dataset_version.php @@ -0,0 +1,78 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var DatasetVersion $response */ + $response = $datasetServiceClient->getDatasetVersion($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedName = DatasetServiceClient::datasetVersionName( + '[PROJECT]', + '[LOCATION]', + '[DATASET]', + '[DATASET_VERSION]' + ); + + get_dataset_version_sample($formattedName); +} +// [END aiplatform_v1_generated_DatasetService_GetDatasetVersion_sync] diff --git a/AiPlatform/samples/V1/DatasetServiceClient/list_dataset_versions.php b/AiPlatform/samples/V1/DatasetServiceClient/list_dataset_versions.php new file mode 100644 index 000000000000..f8e3c7f4c38b --- /dev/null +++ b/AiPlatform/samples/V1/DatasetServiceClient/list_dataset_versions.php @@ -0,0 +1,78 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $datasetServiceClient->listDatasetVersions($request); + + /** @var DatasetVersion $element */ + foreach ($response as $element) { + printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = DatasetServiceClient::datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + + list_dataset_versions_sample($formattedParent); +} +// [END aiplatform_v1_generated_DatasetService_ListDatasetVersions_sync] diff --git a/AiPlatform/samples/V1/DatasetServiceClient/restore_dataset_version.php b/AiPlatform/samples/V1/DatasetServiceClient/restore_dataset_version.php new file mode 100644 index 000000000000..f5b620dbda77 --- /dev/null +++ b/AiPlatform/samples/V1/DatasetServiceClient/restore_dataset_version.php @@ -0,0 +1,90 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $datasetServiceClient->restoreDatasetVersion($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var DatasetVersion $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedName = DatasetServiceClient::datasetVersionName( + '[PROJECT]', + '[LOCATION]', + '[DATASET]', + '[DATASET_VERSION]' + ); + + restore_dataset_version_sample($formattedName); +} +// [END aiplatform_v1_generated_DatasetService_RestoreDatasetVersion_sync] diff --git a/AiPlatform/samples/V1/TensorboardServiceClient/batch_create_tensorboard_runs.php b/AiPlatform/samples/V1/TensorboardServiceClient/batch_create_tensorboard_runs.php index ae0c13139969..5df38ca6af76 100644 --- a/AiPlatform/samples/V1/TensorboardServiceClient/batch_create_tensorboard_runs.php +++ b/AiPlatform/samples/V1/TensorboardServiceClient/batch_create_tensorboard_runs.php @@ -50,7 +50,7 @@ * component of the Tensorboard run's resource name. * * This value should be 1-128 characters, and valid characters - * are /[a-z][0-9]-/. + * are `/[a-z][0-9]-/`. */ function batch_create_tensorboard_runs_sample( string $formattedParent, diff --git a/AiPlatform/samples/V1/TensorboardServiceClient/create_tensorboard_experiment.php b/AiPlatform/samples/V1/TensorboardServiceClient/create_tensorboard_experiment.php index 11a157b7e5a2..e8de6cd3f616 100644 --- a/AiPlatform/samples/V1/TensorboardServiceClient/create_tensorboard_experiment.php +++ b/AiPlatform/samples/V1/TensorboardServiceClient/create_tensorboard_experiment.php @@ -39,7 +39,7 @@ * final component of the Tensorboard experiment's resource name. * * This value should be 1-128 characters, and valid characters - * are /[a-z][0-9]-/. + * are `/[a-z][0-9]-/`. */ function create_tensorboard_experiment_sample( string $formattedParent, diff --git a/AiPlatform/samples/V1/TensorboardServiceClient/create_tensorboard_run.php b/AiPlatform/samples/V1/TensorboardServiceClient/create_tensorboard_run.php index 0a04ff38308c..bcbc7322810f 100644 --- a/AiPlatform/samples/V1/TensorboardServiceClient/create_tensorboard_run.php +++ b/AiPlatform/samples/V1/TensorboardServiceClient/create_tensorboard_run.php @@ -42,7 +42,7 @@ * component of the Tensorboard run's resource name. * * This value should be 1-128 characters, and valid characters - * are /[a-z][0-9]-/. + * are `/[a-z][0-9]-/`. */ function create_tensorboard_run_sample( string $formattedParent, diff --git a/AiPlatform/src/V1/Client/BaseClient/DatasetServiceBaseClient.php b/AiPlatform/src/V1/Client/BaseClient/DatasetServiceBaseClient.php deleted file mode 100644 index 708cfc9c46b7..000000000000 --- a/AiPlatform/src/V1/Client/BaseClient/DatasetServiceBaseClient.php +++ /dev/null @@ -1,850 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/dataset_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/dataset_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/dataset_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/dataset_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * annotation_spec resource. - * - * @param string $project - * @param string $location - * @param string $dataset - * @param string $annotationSpec - * - * @return string The formatted annotation_spec resource. - */ - public static function annotationSpecName(string $project, string $location, string $dataset, string $annotationSpec): string - { - return self::getPathTemplate('annotationSpec')->render([ - 'project' => $project, - 'location' => $location, - 'dataset' => $dataset, - 'annotation_spec' => $annotationSpec, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a data_item - * resource. - * - * @param string $project - * @param string $location - * @param string $dataset - * @param string $dataItem - * - * @return string The formatted data_item resource. - */ - public static function dataItemName(string $project, string $location, string $dataset, string $dataItem): string - { - return self::getPathTemplate('dataItem')->render([ - 'project' => $project, - 'location' => $location, - 'dataset' => $dataset, - 'data_item' => $dataItem, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a dataset - * resource. - * - * @param string $project - * @param string $location - * @param string $dataset - * - * @return string The formatted dataset resource. - */ - public static function datasetName(string $project, string $location, string $dataset): string - { - return self::getPathTemplate('dataset')->render([ - 'project' => $project, - 'location' => $location, - 'dataset' => $dataset, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a saved_query - * resource. - * - * @param string $project - * @param string $location - * @param string $dataset - * @param string $savedQuery - * - * @return string The formatted saved_query resource. - */ - public static function savedQueryName(string $project, string $location, string $dataset, string $savedQuery): string - { - return self::getPathTemplate('savedQuery')->render([ - 'project' => $project, - 'location' => $location, - 'dataset' => $dataset, - 'saved_query' => $savedQuery, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - annotationSpec: projects/{project}/locations/{location}/datasets/{dataset}/annotationSpecs/{annotation_spec} - * - dataItem: projects/{project}/locations/{location}/datasets/{dataset}/dataItems/{data_item} - * - dataset: projects/{project}/locations/{location}/datasets/{dataset} - * - location: projects/{project}/locations/{location} - * - savedQuery: projects/{project}/locations/{location}/datasets/{dataset}/savedQueries/{saved_query} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'aiplatform.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a Dataset. - * - * The async variant is {@see self::createDatasetAsync()} . - * - * @example samples/V1/DatasetServiceClient/create_dataset.php - * - * @param CreateDatasetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDataset(CreateDatasetRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateDataset', $request, $callOptions)->wait(); - } - - /** - * Deletes a Dataset. - * - * The async variant is {@see self::deleteDatasetAsync()} . - * - * @example samples/V1/DatasetServiceClient/delete_dataset.php - * - * @param DeleteDatasetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDataset(DeleteDatasetRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteDataset', $request, $callOptions)->wait(); - } - - /** - * Deletes a SavedQuery. - * - * The async variant is {@see self::deleteSavedQueryAsync()} . - * - * @example samples/V1/DatasetServiceClient/delete_saved_query.php - * - * @param DeleteSavedQueryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSavedQuery(DeleteSavedQueryRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteSavedQuery', $request, $callOptions)->wait(); - } - - /** - * Exports data from a Dataset. - * - * The async variant is {@see self::exportDataAsync()} . - * - * @example samples/V1/DatasetServiceClient/export_data.php - * - * @param ExportDataRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function exportData(ExportDataRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ExportData', $request, $callOptions)->wait(); - } - - /** - * Gets an AnnotationSpec. - * - * The async variant is {@see self::getAnnotationSpecAsync()} . - * - * @example samples/V1/DatasetServiceClient/get_annotation_spec.php - * - * @param GetAnnotationSpecRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AnnotationSpec - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAnnotationSpec(GetAnnotationSpecRequest $request, array $callOptions = []): AnnotationSpec - { - return $this->startApiCall('GetAnnotationSpec', $request, $callOptions)->wait(); - } - - /** - * Gets a Dataset. - * - * The async variant is {@see self::getDatasetAsync()} . - * - * @example samples/V1/DatasetServiceClient/get_dataset.php - * - * @param GetDatasetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Dataset - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDataset(GetDatasetRequest $request, array $callOptions = []): Dataset - { - return $this->startApiCall('GetDataset', $request, $callOptions)->wait(); - } - - /** - * Imports data into a Dataset. - * - * The async variant is {@see self::importDataAsync()} . - * - * @example samples/V1/DatasetServiceClient/import_data.php - * - * @param ImportDataRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function importData(ImportDataRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ImportData', $request, $callOptions)->wait(); - } - - /** - * Lists Annotations belongs to a dataitem - * - * The async variant is {@see self::listAnnotationsAsync()} . - * - * @example samples/V1/DatasetServiceClient/list_annotations.php - * - * @param ListAnnotationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAnnotations(ListAnnotationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAnnotations', $request, $callOptions); - } - - /** - * Lists DataItems in a Dataset. - * - * The async variant is {@see self::listDataItemsAsync()} . - * - * @example samples/V1/DatasetServiceClient/list_data_items.php - * - * @param ListDataItemsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDataItems(ListDataItemsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDataItems', $request, $callOptions); - } - - /** - * Lists Datasets in a Location. - * - * The async variant is {@see self::listDatasetsAsync()} . - * - * @example samples/V1/DatasetServiceClient/list_datasets.php - * - * @param ListDatasetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDatasets(ListDatasetsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDatasets', $request, $callOptions); - } - - /** - * Lists SavedQueries in a Dataset. - * - * The async variant is {@see self::listSavedQueriesAsync()} . - * - * @example samples/V1/DatasetServiceClient/list_saved_queries.php - * - * @param ListSavedQueriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSavedQueries(ListSavedQueriesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSavedQueries', $request, $callOptions); - } - - /** - * Searches DataItems in a Dataset. - * - * The async variant is {@see self::searchDataItemsAsync()} . - * - * @example samples/V1/DatasetServiceClient/search_data_items.php - * - * @param SearchDataItemsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchDataItems(SearchDataItemsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchDataItems', $request, $callOptions); - } - - /** - * Updates a Dataset. - * - * The async variant is {@see self::updateDatasetAsync()} . - * - * @example samples/V1/DatasetServiceClient/update_dataset.php - * - * @param UpdateDatasetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Dataset - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDataset(UpdateDatasetRequest $request, array $callOptions = []): Dataset - { - return $this->startApiCall('UpdateDataset', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/DatasetServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/DatasetServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/DatasetServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/DatasetServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/DatasetServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/AiPlatform/src/V1/Client/BaseClient/EndpointServiceBaseClient.php b/AiPlatform/src/V1/Client/BaseClient/EndpointServiceBaseClient.php deleted file mode 100644 index 1dbbc5b49478..000000000000 --- a/AiPlatform/src/V1/Client/BaseClient/EndpointServiceBaseClient.php +++ /dev/null @@ -1,747 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/endpoint_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/endpoint_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/endpoint_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/endpoint_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a endpoint - * resource. - * - * @param string $project - * @param string $location - * @param string $endpoint - * - * @return string The formatted endpoint resource. - */ - public static function endpointName(string $project, string $location, string $endpoint): string - { - return self::getPathTemplate('endpoint')->render([ - 'project' => $project, - 'location' => $location, - 'endpoint' => $endpoint, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a model - * resource. - * - * @param string $project - * @param string $location - * @param string $model - * - * @return string The formatted model resource. - */ - public static function modelName(string $project, string $location, string $model): string - { - return self::getPathTemplate('model')->render([ - 'project' => $project, - 'location' => $location, - 'model' => $model, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * model_deployment_monitoring_job resource. - * - * @param string $project - * @param string $location - * @param string $modelDeploymentMonitoringJob - * - * @return string The formatted model_deployment_monitoring_job resource. - */ - public static function modelDeploymentMonitoringJobName(string $project, string $location, string $modelDeploymentMonitoringJob): string - { - return self::getPathTemplate('modelDeploymentMonitoringJob')->render([ - 'project' => $project, - 'location' => $location, - 'model_deployment_monitoring_job' => $modelDeploymentMonitoringJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a network - * resource. - * - * @param string $project - * @param string $network - * - * @return string The formatted network resource. - */ - public static function networkName(string $project, string $network): string - { - return self::getPathTemplate('network')->render([ - 'project' => $project, - 'network' => $network, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_endpoint resource. - * - * @param string $project - * @param string $location - * @param string $endpoint - * - * @return string The formatted project_location_endpoint resource. - */ - public static function projectLocationEndpointName(string $project, string $location, string $endpoint): string - { - return self::getPathTemplate('projectLocationEndpoint')->render([ - 'project' => $project, - 'location' => $location, - 'endpoint' => $endpoint, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_publisher_model resource. - * - * @param string $project - * @param string $location - * @param string $publisher - * @param string $model - * - * @return string The formatted project_location_publisher_model resource. - */ - public static function projectLocationPublisherModelName(string $project, string $location, string $publisher, string $model): string - { - return self::getPathTemplate('projectLocationPublisherModel')->render([ - 'project' => $project, - 'location' => $location, - 'publisher' => $publisher, - 'model' => $model, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - endpoint: projects/{project}/locations/{location}/endpoints/{endpoint} - * - location: projects/{project}/locations/{location} - * - model: projects/{project}/locations/{location}/models/{model} - * - modelDeploymentMonitoringJob: projects/{project}/locations/{location}/modelDeploymentMonitoringJobs/{model_deployment_monitoring_job} - * - network: projects/{project}/global/networks/{network} - * - projectLocationEndpoint: projects/{project}/locations/{location}/endpoints/{endpoint} - * - projectLocationPublisherModel: projects/{project}/locations/{location}/publishers/{publisher}/models/{model} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'aiplatform.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates an Endpoint. - * - * The async variant is {@see self::createEndpointAsync()} . - * - * @example samples/V1/EndpointServiceClient/create_endpoint.php - * - * @param CreateEndpointRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createEndpoint(CreateEndpointRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateEndpoint', $request, $callOptions)->wait(); - } - - /** - * Deletes an Endpoint. - * - * The async variant is {@see self::deleteEndpointAsync()} . - * - * @example samples/V1/EndpointServiceClient/delete_endpoint.php - * - * @param DeleteEndpointRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteEndpoint(DeleteEndpointRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteEndpoint', $request, $callOptions)->wait(); - } - - /** - * Deploys a Model into this Endpoint, creating a DeployedModel within it. - * - * The async variant is {@see self::deployModelAsync()} . - * - * @example samples/V1/EndpointServiceClient/deploy_model.php - * - * @param DeployModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deployModel(DeployModelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeployModel', $request, $callOptions)->wait(); - } - - /** - * Gets an Endpoint. - * - * The async variant is {@see self::getEndpointAsync()} . - * - * @example samples/V1/EndpointServiceClient/get_endpoint.php - * - * @param GetEndpointRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Endpoint - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEndpoint(GetEndpointRequest $request, array $callOptions = []): Endpoint - { - return $this->startApiCall('GetEndpoint', $request, $callOptions)->wait(); - } - - /** - * Lists Endpoints in a Location. - * - * The async variant is {@see self::listEndpointsAsync()} . - * - * @example samples/V1/EndpointServiceClient/list_endpoints.php - * - * @param ListEndpointsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listEndpoints(ListEndpointsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListEndpoints', $request, $callOptions); - } - - /** - * Updates an existing deployed model. Updatable fields include - * `min_replica_count`, `max_replica_count`, `autoscaling_metric_specs`, - * `disable_container_logging` (v1 only), and `enable_container_logging` - * (v1beta1 only). - * - * The async variant is {@see self::mutateDeployedModelAsync()} . - * - * @example samples/V1/EndpointServiceClient/mutate_deployed_model.php - * - * @param MutateDeployedModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function mutateDeployedModel(MutateDeployedModelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('MutateDeployedModel', $request, $callOptions)->wait(); - } - - /** - * Undeploys a Model from an Endpoint, removing a DeployedModel from it, and - * freeing all resources it's using. - * - * The async variant is {@see self::undeployModelAsync()} . - * - * @example samples/V1/EndpointServiceClient/undeploy_model.php - * - * @param UndeployModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function undeployModel(UndeployModelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UndeployModel', $request, $callOptions)->wait(); - } - - /** - * Updates an Endpoint. - * - * The async variant is {@see self::updateEndpointAsync()} . - * - * @example samples/V1/EndpointServiceClient/update_endpoint.php - * - * @param UpdateEndpointRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Endpoint - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateEndpoint(UpdateEndpointRequest $request, array $callOptions = []): Endpoint - { - return $this->startApiCall('UpdateEndpoint', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/EndpointServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/EndpointServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/EndpointServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/EndpointServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/EndpointServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/AiPlatform/src/V1/Client/BaseClient/FeaturestoreOnlineServingServiceBaseClient.php b/AiPlatform/src/V1/Client/BaseClient/FeaturestoreOnlineServingServiceBaseClient.php deleted file mode 100644 index 76231a7990a0..000000000000 --- a/AiPlatform/src/V1/Client/BaseClient/FeaturestoreOnlineServingServiceBaseClient.php +++ /dev/null @@ -1,458 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/featurestore_online_serving_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/featurestore_online_serving_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/featurestore_online_serving_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/featurestore_online_serving_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a entity_type - * resource. - * - * @param string $project - * @param string $location - * @param string $featurestore - * @param string $entityType - * - * @return string The formatted entity_type resource. - */ - public static function entityTypeName(string $project, string $location, string $featurestore, string $entityType): string - { - return self::getPathTemplate('entityType')->render([ - 'project' => $project, - 'location' => $location, - 'featurestore' => $featurestore, - 'entity_type' => $entityType, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - entityType: projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entity_type} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'aiplatform.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Reads Feature values of a specific entity of an EntityType. For reading - * feature values of multiple entities of an EntityType, please use - * StreamingReadFeatureValues. - * - * The async variant is {@see self::readFeatureValuesAsync()} . - * - * @example samples/V1/FeaturestoreOnlineServingServiceClient/read_feature_values.php - * - * @param ReadFeatureValuesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ReadFeatureValuesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function readFeatureValues(ReadFeatureValuesRequest $request, array $callOptions = []): ReadFeatureValuesResponse - { - return $this->startApiCall('ReadFeatureValues', $request, $callOptions)->wait(); - } - - /** - * Reads Feature values for multiple entities. Depending on their size, data - * for different entities may be broken - * up across multiple responses. - * - * @example samples/V1/FeaturestoreOnlineServingServiceClient/streaming_read_feature_values.php - * - * @param StreamingReadFeatureValuesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return ServerStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function streamingReadFeatureValues(StreamingReadFeatureValuesRequest $request, array $callOptions = []): ServerStream - { - return $this->startApiCall('StreamingReadFeatureValues', $request, $callOptions); - } - - /** - * Writes Feature values of one or more entities of an EntityType. - * - * The Feature values are merged into existing entities if any. The Feature - * values to be written must have timestamp within the online storage - * retention. - * - * The async variant is {@see self::writeFeatureValuesAsync()} . - * - * @example samples/V1/FeaturestoreOnlineServingServiceClient/write_feature_values.php - * - * @param WriteFeatureValuesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 WriteFeatureValuesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function writeFeatureValues(WriteFeatureValuesRequest $request, array $callOptions = []): WriteFeatureValuesResponse - { - return $this->startApiCall('WriteFeatureValues', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/FeaturestoreOnlineServingServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/FeaturestoreOnlineServingServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/FeaturestoreOnlineServingServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/FeaturestoreOnlineServingServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/FeaturestoreOnlineServingServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/AiPlatform/src/V1/Client/BaseClient/FeaturestoreServiceBaseClient.php b/AiPlatform/src/V1/Client/BaseClient/FeaturestoreServiceBaseClient.php deleted file mode 100644 index 9909de394ad8..000000000000 --- a/AiPlatform/src/V1/Client/BaseClient/FeaturestoreServiceBaseClient.php +++ /dev/null @@ -1,1091 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/featurestore_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/featurestore_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/featurestore_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/featurestore_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a entity_type - * resource. - * - * @param string $project - * @param string $location - * @param string $featurestore - * @param string $entityType - * - * @return string The formatted entity_type resource. - */ - public static function entityTypeName(string $project, string $location, string $featurestore, string $entityType): string - { - return self::getPathTemplate('entityType')->render([ - 'project' => $project, - 'location' => $location, - 'featurestore' => $featurestore, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a feature - * resource. - * - * @param string $project - * @param string $location - * @param string $featurestore - * @param string $entityType - * @param string $feature - * - * @return string The formatted feature resource. - */ - public static function featureName(string $project, string $location, string $featurestore, string $entityType, string $feature): string - { - return self::getPathTemplate('feature')->render([ - 'project' => $project, - 'location' => $location, - 'featurestore' => $featurestore, - 'entity_type' => $entityType, - 'feature' => $feature, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a featurestore - * resource. - * - * @param string $project - * @param string $location - * @param string $featurestore - * - * @return string The formatted featurestore resource. - */ - public static function featurestoreName(string $project, string $location, string $featurestore): string - { - return self::getPathTemplate('featurestore')->render([ - 'project' => $project, - 'location' => $location, - 'featurestore' => $featurestore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - entityType: projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entity_type} - * - feature: projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entity_type}/features/{feature} - * - featurestore: projects/{project}/locations/{location}/featurestores/{featurestore} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'aiplatform.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a batch of Features in a given EntityType. - * - * The async variant is {@see self::batchCreateFeaturesAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/batch_create_features.php - * - * @param BatchCreateFeaturesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchCreateFeatures(BatchCreateFeaturesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BatchCreateFeatures', $request, $callOptions)->wait(); - } - - /** - * Batch reads Feature values from a Featurestore. - * - * This API enables batch reading Feature values, where each read - * instance in the batch may read Feature values of entities from one or - * more EntityTypes. Point-in-time correctness is guaranteed for Feature - * values of each read instance as of each instance's read timestamp. - * - * The async variant is {@see self::batchReadFeatureValuesAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/batch_read_feature_values.php - * - * @param BatchReadFeatureValuesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchReadFeatureValues(BatchReadFeatureValuesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BatchReadFeatureValues', $request, $callOptions)->wait(); - } - - /** - * Creates a new EntityType in a given Featurestore. - * - * The async variant is {@see self::createEntityTypeAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/create_entity_type.php - * - * @param CreateEntityTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createEntityType(CreateEntityTypeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateEntityType', $request, $callOptions)->wait(); - } - - /** - * Creates a new Feature in a given EntityType. - * - * The async variant is {@see self::createFeatureAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/create_feature.php - * - * @param CreateFeatureRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createFeature(CreateFeatureRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateFeature', $request, $callOptions)->wait(); - } - - /** - * Creates a new Featurestore in a given project and location. - * - * The async variant is {@see self::createFeaturestoreAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/create_featurestore.php - * - * @param CreateFeaturestoreRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createFeaturestore(CreateFeaturestoreRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateFeaturestore', $request, $callOptions)->wait(); - } - - /** - * Deletes a single EntityType. The EntityType must not have any Features - * or `force` must be set to true for the request to succeed. - * - * The async variant is {@see self::deleteEntityTypeAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/delete_entity_type.php - * - * @param DeleteEntityTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteEntityType(DeleteEntityTypeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteEntityType', $request, $callOptions)->wait(); - } - - /** - * Deletes a single Feature. - * - * The async variant is {@see self::deleteFeatureAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/delete_feature.php - * - * @param DeleteFeatureRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteFeature(DeleteFeatureRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteFeature', $request, $callOptions)->wait(); - } - - /** - * Delete Feature values from Featurestore. - * - * The progress of the deletion is tracked by the returned operation. The - * deleted feature values are guaranteed to be invisible to subsequent read - * operations after the operation is marked as successfully done. - * - * If a delete feature values operation fails, the feature values - * returned from reads and exports may be inconsistent. If consistency is - * required, the caller must retry the same delete request again and wait till - * the new operation returned is marked as successfully done. - * - * The async variant is {@see self::deleteFeatureValuesAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/delete_feature_values.php - * - * @param DeleteFeatureValuesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteFeatureValues(DeleteFeatureValuesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteFeatureValues', $request, $callOptions)->wait(); - } - - /** - * Deletes a single Featurestore. The Featurestore must not contain any - * EntityTypes or `force` must be set to true for the request to succeed. - * - * The async variant is {@see self::deleteFeaturestoreAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/delete_featurestore.php - * - * @param DeleteFeaturestoreRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteFeaturestore(DeleteFeaturestoreRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteFeaturestore', $request, $callOptions)->wait(); - } - - /** - * Exports Feature values from all the entities of a target EntityType. - * - * The async variant is {@see self::exportFeatureValuesAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/export_feature_values.php - * - * @param ExportFeatureValuesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function exportFeatureValues(ExportFeatureValuesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ExportFeatureValues', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single EntityType. - * - * The async variant is {@see self::getEntityTypeAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/get_entity_type.php - * - * @param GetEntityTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 EntityType - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEntityType(GetEntityTypeRequest $request, array $callOptions = []): EntityType - { - return $this->startApiCall('GetEntityType', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single Feature. - * - * The async variant is {@see self::getFeatureAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/get_feature.php - * - * @param GetFeatureRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Feature - * - * @throws ApiException Thrown if the API call fails. - */ - public function getFeature(GetFeatureRequest $request, array $callOptions = []): Feature - { - return $this->startApiCall('GetFeature', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single Featurestore. - * - * The async variant is {@see self::getFeaturestoreAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/get_featurestore.php - * - * @param GetFeaturestoreRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Featurestore - * - * @throws ApiException Thrown if the API call fails. - */ - public function getFeaturestore(GetFeaturestoreRequest $request, array $callOptions = []): Featurestore - { - return $this->startApiCall('GetFeaturestore', $request, $callOptions)->wait(); - } - - /** - * Imports Feature values into the Featurestore from a source storage. - * - * The progress of the import is tracked by the returned operation. The - * imported features are guaranteed to be visible to subsequent read - * operations after the operation is marked as successfully done. - * - * If an import operation fails, the Feature values returned from - * reads and exports may be inconsistent. If consistency is - * required, the caller must retry the same import request again and wait till - * the new operation returned is marked as successfully done. - * - * There are also scenarios where the caller can cause inconsistency. - * - * - Source data for import contains multiple distinct Feature values for - * the same entity ID and timestamp. - * - Source is modified during an import. This includes adding, updating, or - * removing source data and/or metadata. Examples of updating metadata - * include but are not limited to changing storage location, storage class, - * or retention policy. - * - Online serving cluster is under-provisioned. - * - * The async variant is {@see self::importFeatureValuesAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/import_feature_values.php - * - * @param ImportFeatureValuesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function importFeatureValues(ImportFeatureValuesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ImportFeatureValues', $request, $callOptions)->wait(); - } - - /** - * Lists EntityTypes in a given Featurestore. - * - * The async variant is {@see self::listEntityTypesAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/list_entity_types.php - * - * @param ListEntityTypesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listEntityTypes(ListEntityTypesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListEntityTypes', $request, $callOptions); - } - - /** - * Lists Features in a given EntityType. - * - * The async variant is {@see self::listFeaturesAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/list_features.php - * - * @param ListFeaturesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listFeatures(ListFeaturesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListFeatures', $request, $callOptions); - } - - /** - * Lists Featurestores in a given project and location. - * - * The async variant is {@see self::listFeaturestoresAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/list_featurestores.php - * - * @param ListFeaturestoresRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listFeaturestores(ListFeaturestoresRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListFeaturestores', $request, $callOptions); - } - - /** - * Searches Features matching a query in a given project. - * - * The async variant is {@see self::searchFeaturesAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/search_features.php - * - * @param SearchFeaturesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchFeatures(SearchFeaturesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchFeatures', $request, $callOptions); - } - - /** - * Updates the parameters of a single EntityType. - * - * The async variant is {@see self::updateEntityTypeAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/update_entity_type.php - * - * @param UpdateEntityTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 EntityType - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateEntityType(UpdateEntityTypeRequest $request, array $callOptions = []): EntityType - { - return $this->startApiCall('UpdateEntityType', $request, $callOptions)->wait(); - } - - /** - * Updates the parameters of a single Feature. - * - * The async variant is {@see self::updateFeatureAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/update_feature.php - * - * @param UpdateFeatureRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Feature - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateFeature(UpdateFeatureRequest $request, array $callOptions = []): Feature - { - return $this->startApiCall('UpdateFeature', $request, $callOptions)->wait(); - } - - /** - * Updates the parameters of a single Featurestore. - * - * The async variant is {@see self::updateFeaturestoreAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/update_featurestore.php - * - * @param UpdateFeaturestoreRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateFeaturestore(UpdateFeaturestoreRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateFeaturestore', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/FeaturestoreServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/AiPlatform/src/V1/Client/BaseClient/IndexEndpointServiceBaseClient.php b/AiPlatform/src/V1/Client/BaseClient/IndexEndpointServiceBaseClient.php deleted file mode 100644 index c2e0988ab832..000000000000 --- a/AiPlatform/src/V1/Client/BaseClient/IndexEndpointServiceBaseClient.php +++ /dev/null @@ -1,667 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/index_endpoint_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/index_endpoint_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/index_endpoint_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/index_endpoint_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a index - * resource. - * - * @param string $project - * @param string $location - * @param string $index - * - * @return string The formatted index resource. - */ - public static function indexName(string $project, string $location, string $index): string - { - return self::getPathTemplate('index')->render([ - 'project' => $project, - 'location' => $location, - 'index' => $index, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * index_endpoint resource. - * - * @param string $project - * @param string $location - * @param string $indexEndpoint - * - * @return string The formatted index_endpoint resource. - */ - public static function indexEndpointName(string $project, string $location, string $indexEndpoint): string - { - return self::getPathTemplate('indexEndpoint')->render([ - 'project' => $project, - 'location' => $location, - 'index_endpoint' => $indexEndpoint, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - index: projects/{project}/locations/{location}/indexes/{index} - * - indexEndpoint: projects/{project}/locations/{location}/indexEndpoints/{index_endpoint} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'aiplatform.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates an IndexEndpoint. - * - * The async variant is {@see self::createIndexEndpointAsync()} . - * - * @example samples/V1/IndexEndpointServiceClient/create_index_endpoint.php - * - * @param CreateIndexEndpointRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createIndexEndpoint(CreateIndexEndpointRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateIndexEndpoint', $request, $callOptions)->wait(); - } - - /** - * Deletes an IndexEndpoint. - * - * The async variant is {@see self::deleteIndexEndpointAsync()} . - * - * @example samples/V1/IndexEndpointServiceClient/delete_index_endpoint.php - * - * @param DeleteIndexEndpointRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteIndexEndpoint(DeleteIndexEndpointRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteIndexEndpoint', $request, $callOptions)->wait(); - } - - /** - * Deploys an Index into this IndexEndpoint, creating a DeployedIndex within - * it. - * Only non-empty Indexes can be deployed. - * - * The async variant is {@see self::deployIndexAsync()} . - * - * @example samples/V1/IndexEndpointServiceClient/deploy_index.php - * - * @param DeployIndexRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deployIndex(DeployIndexRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeployIndex', $request, $callOptions)->wait(); - } - - /** - * Gets an IndexEndpoint. - * - * The async variant is {@see self::getIndexEndpointAsync()} . - * - * @example samples/V1/IndexEndpointServiceClient/get_index_endpoint.php - * - * @param GetIndexEndpointRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 IndexEndpoint - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIndexEndpoint(GetIndexEndpointRequest $request, array $callOptions = []): IndexEndpoint - { - return $this->startApiCall('GetIndexEndpoint', $request, $callOptions)->wait(); - } - - /** - * Lists IndexEndpoints in a Location. - * - * The async variant is {@see self::listIndexEndpointsAsync()} . - * - * @example samples/V1/IndexEndpointServiceClient/list_index_endpoints.php - * - * @param ListIndexEndpointsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listIndexEndpoints(ListIndexEndpointsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListIndexEndpoints', $request, $callOptions); - } - - /** - * Update an existing DeployedIndex under an IndexEndpoint. - * - * The async variant is {@see self::mutateDeployedIndexAsync()} . - * - * @example samples/V1/IndexEndpointServiceClient/mutate_deployed_index.php - * - * @param MutateDeployedIndexRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function mutateDeployedIndex(MutateDeployedIndexRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('MutateDeployedIndex', $request, $callOptions)->wait(); - } - - /** - * Undeploys an Index from an IndexEndpoint, removing a DeployedIndex from it, - * and freeing all resources it's using. - * - * The async variant is {@see self::undeployIndexAsync()} . - * - * @example samples/V1/IndexEndpointServiceClient/undeploy_index.php - * - * @param UndeployIndexRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function undeployIndex(UndeployIndexRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UndeployIndex', $request, $callOptions)->wait(); - } - - /** - * Updates an IndexEndpoint. - * - * The async variant is {@see self::updateIndexEndpointAsync()} . - * - * @example samples/V1/IndexEndpointServiceClient/update_index_endpoint.php - * - * @param UpdateIndexEndpointRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 IndexEndpoint - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateIndexEndpoint(UpdateIndexEndpointRequest $request, array $callOptions = []): IndexEndpoint - { - return $this->startApiCall('UpdateIndexEndpoint', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/IndexEndpointServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/IndexEndpointServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/IndexEndpointServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/IndexEndpointServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/IndexEndpointServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/AiPlatform/src/V1/Client/BaseClient/IndexServiceBaseClient.php b/AiPlatform/src/V1/Client/BaseClient/IndexServiceBaseClient.php deleted file mode 100644 index 1d2215e55411..000000000000 --- a/AiPlatform/src/V1/Client/BaseClient/IndexServiceBaseClient.php +++ /dev/null @@ -1,640 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/index_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/index_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/index_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/index_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a index - * resource. - * - * @param string $project - * @param string $location - * @param string $index - * - * @return string The formatted index resource. - */ - public static function indexName(string $project, string $location, string $index): string - { - return self::getPathTemplate('index')->render([ - 'project' => $project, - 'location' => $location, - 'index' => $index, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * index_endpoint resource. - * - * @param string $project - * @param string $location - * @param string $indexEndpoint - * - * @return string The formatted index_endpoint resource. - */ - public static function indexEndpointName(string $project, string $location, string $indexEndpoint): string - { - return self::getPathTemplate('indexEndpoint')->render([ - 'project' => $project, - 'location' => $location, - 'index_endpoint' => $indexEndpoint, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - index: projects/{project}/locations/{location}/indexes/{index} - * - indexEndpoint: projects/{project}/locations/{location}/indexEndpoints/{index_endpoint} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'aiplatform.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates an Index. - * - * The async variant is {@see self::createIndexAsync()} . - * - * @example samples/V1/IndexServiceClient/create_index.php - * - * @param CreateIndexRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createIndex(CreateIndexRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateIndex', $request, $callOptions)->wait(); - } - - /** - * Deletes an Index. - * An Index can only be deleted when all its - * [DeployedIndexes][google.cloud.aiplatform.v1.Index.deployed_indexes] had - * been undeployed. - * - * The async variant is {@see self::deleteIndexAsync()} . - * - * @example samples/V1/IndexServiceClient/delete_index.php - * - * @param DeleteIndexRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteIndex(DeleteIndexRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteIndex', $request, $callOptions)->wait(); - } - - /** - * Gets an Index. - * - * The async variant is {@see self::getIndexAsync()} . - * - * @example samples/V1/IndexServiceClient/get_index.php - * - * @param GetIndexRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Index - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIndex(GetIndexRequest $request, array $callOptions = []): Index - { - return $this->startApiCall('GetIndex', $request, $callOptions)->wait(); - } - - /** - * Lists Indexes in a Location. - * - * The async variant is {@see self::listIndexesAsync()} . - * - * @example samples/V1/IndexServiceClient/list_indexes.php - * - * @param ListIndexesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listIndexes(ListIndexesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListIndexes', $request, $callOptions); - } - - /** - * Remove Datapoints from an Index. - * - * The async variant is {@see self::removeDatapointsAsync()} . - * - * @example samples/V1/IndexServiceClient/remove_datapoints.php - * - * @param RemoveDatapointsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RemoveDatapointsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function removeDatapoints(RemoveDatapointsRequest $request, array $callOptions = []): RemoveDatapointsResponse - { - return $this->startApiCall('RemoveDatapoints', $request, $callOptions)->wait(); - } - - /** - * Updates an Index. - * - * The async variant is {@see self::updateIndexAsync()} . - * - * @example samples/V1/IndexServiceClient/update_index.php - * - * @param UpdateIndexRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateIndex(UpdateIndexRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateIndex', $request, $callOptions)->wait(); - } - - /** - * Add/update Datapoints into an Index. - * - * The async variant is {@see self::upsertDatapointsAsync()} . - * - * @example samples/V1/IndexServiceClient/upsert_datapoints.php - * - * @param UpsertDatapointsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 UpsertDatapointsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function upsertDatapoints(UpsertDatapointsRequest $request, array $callOptions = []): UpsertDatapointsResponse - { - return $this->startApiCall('UpsertDatapoints', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/IndexServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/IndexServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/IndexServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/IndexServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/IndexServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/AiPlatform/src/V1/Client/BaseClient/JobServiceBaseClient.php b/AiPlatform/src/V1/Client/BaseClient/JobServiceBaseClient.php deleted file mode 100644 index f14156e51ce2..000000000000 --- a/AiPlatform/src/V1/Client/BaseClient/JobServiceBaseClient.php +++ /dev/null @@ -1,1756 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/job_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/job_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/job_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/job_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * batch_prediction_job resource. - * - * @param string $project - * @param string $location - * @param string $batchPredictionJob - * - * @return string The formatted batch_prediction_job resource. - */ - public static function batchPredictionJobName(string $project, string $location, string $batchPredictionJob): string - { - return self::getPathTemplate('batchPredictionJob')->render([ - 'project' => $project, - 'location' => $location, - 'batch_prediction_job' => $batchPredictionJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a context - * resource. - * - * @param string $project - * @param string $location - * @param string $metadataStore - * @param string $context - * - * @return string The formatted context resource. - */ - public static function contextName(string $project, string $location, string $metadataStore, string $context): string - { - return self::getPathTemplate('context')->render([ - 'project' => $project, - 'location' => $location, - 'metadata_store' => $metadataStore, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a custom_job - * resource. - * - * @param string $project - * @param string $location - * @param string $customJob - * - * @return string The formatted custom_job resource. - */ - public static function customJobName(string $project, string $location, string $customJob): string - { - return self::getPathTemplate('customJob')->render([ - 'project' => $project, - 'location' => $location, - 'custom_job' => $customJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * data_labeling_job resource. - * - * @param string $project - * @param string $location - * @param string $dataLabelingJob - * - * @return string The formatted data_labeling_job resource. - */ - public static function dataLabelingJobName(string $project, string $location, string $dataLabelingJob): string - { - return self::getPathTemplate('dataLabelingJob')->render([ - 'project' => $project, - 'location' => $location, - 'data_labeling_job' => $dataLabelingJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a dataset - * resource. - * - * @param string $project - * @param string $location - * @param string $dataset - * - * @return string The formatted dataset resource. - */ - public static function datasetName(string $project, string $location, string $dataset): string - { - return self::getPathTemplate('dataset')->render([ - 'project' => $project, - 'location' => $location, - 'dataset' => $dataset, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a endpoint - * resource. - * - * @param string $project - * @param string $location - * @param string $endpoint - * - * @return string The formatted endpoint resource. - */ - public static function endpointName(string $project, string $location, string $endpoint): string - { - return self::getPathTemplate('endpoint')->render([ - 'project' => $project, - 'location' => $location, - 'endpoint' => $endpoint, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * hyperparameter_tuning_job resource. - * - * @param string $project - * @param string $location - * @param string $hyperparameterTuningJob - * - * @return string The formatted hyperparameter_tuning_job resource. - */ - public static function hyperparameterTuningJobName(string $project, string $location, string $hyperparameterTuningJob): string - { - return self::getPathTemplate('hyperparameterTuningJob')->render([ - 'project' => $project, - 'location' => $location, - 'hyperparameter_tuning_job' => $hyperparameterTuningJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a model - * resource. - * - * @param string $project - * @param string $location - * @param string $model - * - * @return string The formatted model resource. - */ - public static function modelName(string $project, string $location, string $model): string - { - return self::getPathTemplate('model')->render([ - 'project' => $project, - 'location' => $location, - 'model' => $model, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * model_deployment_monitoring_job resource. - * - * @param string $project - * @param string $location - * @param string $modelDeploymentMonitoringJob - * - * @return string The formatted model_deployment_monitoring_job resource. - */ - public static function modelDeploymentMonitoringJobName(string $project, string $location, string $modelDeploymentMonitoringJob): string - { - return self::getPathTemplate('modelDeploymentMonitoringJob')->render([ - 'project' => $project, - 'location' => $location, - 'model_deployment_monitoring_job' => $modelDeploymentMonitoringJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a nas_job - * resource. - * - * @param string $project - * @param string $location - * @param string $nasJob - * - * @return string The formatted nas_job resource. - */ - public static function nasJobName(string $project, string $location, string $nasJob): string - { - return self::getPathTemplate('nasJob')->render([ - 'project' => $project, - 'location' => $location, - 'nas_job' => $nasJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * nas_trial_detail resource. - * - * @param string $project - * @param string $location - * @param string $nasJob - * @param string $nasTrialDetail - * - * @return string The formatted nas_trial_detail resource. - */ - public static function nasTrialDetailName(string $project, string $location, string $nasJob, string $nasTrialDetail): string - { - return self::getPathTemplate('nasTrialDetail')->render([ - 'project' => $project, - 'location' => $location, - 'nas_job' => $nasJob, - 'nas_trial_detail' => $nasTrialDetail, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a network - * resource. - * - * @param string $project - * @param string $network - * - * @return string The formatted network resource. - */ - public static function networkName(string $project, string $network): string - { - return self::getPathTemplate('network')->render([ - 'project' => $project, - 'network' => $network, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_endpoint resource. - * - * @param string $project - * @param string $location - * @param string $endpoint - * - * @return string The formatted project_location_endpoint resource. - */ - public static function projectLocationEndpointName(string $project, string $location, string $endpoint): string - { - return self::getPathTemplate('projectLocationEndpoint')->render([ - 'project' => $project, - 'location' => $location, - 'endpoint' => $endpoint, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_publisher_model resource. - * - * @param string $project - * @param string $location - * @param string $publisher - * @param string $model - * - * @return string The formatted project_location_publisher_model resource. - */ - public static function projectLocationPublisherModelName(string $project, string $location, string $publisher, string $model): string - { - return self::getPathTemplate('projectLocationPublisherModel')->render([ - 'project' => $project, - 'location' => $location, - 'publisher' => $publisher, - 'model' => $model, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a tensorboard - * resource. - * - * @param string $project - * @param string $location - * @param string $tensorboard - * - * @return string The formatted tensorboard resource. - */ - public static function tensorboardName(string $project, string $location, string $tensorboard): string - { - return self::getPathTemplate('tensorboard')->render([ - 'project' => $project, - 'location' => $location, - 'tensorboard' => $tensorboard, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a trial - * resource. - * - * @param string $project - * @param string $location - * @param string $study - * @param string $trial - * - * @return string The formatted trial resource. - */ - public static function trialName(string $project, string $location, string $study, string $trial): string - { - return self::getPathTemplate('trial')->render([ - 'project' => $project, - 'location' => $location, - 'study' => $study, - 'trial' => $trial, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - batchPredictionJob: projects/{project}/locations/{location}/batchPredictionJobs/{batch_prediction_job} - * - context: projects/{project}/locations/{location}/metadataStores/{metadata_store}/contexts/{context} - * - customJob: projects/{project}/locations/{location}/customJobs/{custom_job} - * - dataLabelingJob: projects/{project}/locations/{location}/dataLabelingJobs/{data_labeling_job} - * - dataset: projects/{project}/locations/{location}/datasets/{dataset} - * - endpoint: projects/{project}/locations/{location}/endpoints/{endpoint} - * - hyperparameterTuningJob: projects/{project}/locations/{location}/hyperparameterTuningJobs/{hyperparameter_tuning_job} - * - location: projects/{project}/locations/{location} - * - model: projects/{project}/locations/{location}/models/{model} - * - modelDeploymentMonitoringJob: projects/{project}/locations/{location}/modelDeploymentMonitoringJobs/{model_deployment_monitoring_job} - * - nasJob: projects/{project}/locations/{location}/nasJobs/{nas_job} - * - nasTrialDetail: projects/{project}/locations/{location}/nasJobs/{nas_job}/nasTrialDetails/{nas_trial_detail} - * - network: projects/{project}/global/networks/{network} - * - projectLocationEndpoint: projects/{project}/locations/{location}/endpoints/{endpoint} - * - projectLocationPublisherModel: projects/{project}/locations/{location}/publishers/{publisher}/models/{model} - * - tensorboard: projects/{project}/locations/{location}/tensorboards/{tensorboard} - * - trial: projects/{project}/locations/{location}/studies/{study}/trials/{trial} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'aiplatform.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Cancels a BatchPredictionJob. - * - * Starts asynchronous cancellation on the BatchPredictionJob. The server - * makes the best effort to cancel the job, but success is not - * guaranteed. Clients can use - * [JobService.GetBatchPredictionJob][google.cloud.aiplatform.v1.JobService.GetBatchPredictionJob] - * or other methods to check whether the cancellation succeeded or whether the - * job completed despite cancellation. On a successful cancellation, - * the BatchPredictionJob is not deleted;instead its - * [BatchPredictionJob.state][google.cloud.aiplatform.v1.BatchPredictionJob.state] - * is set to `CANCELLED`. Any files already outputted by the job are not - * deleted. - * - * The async variant is {@see self::cancelBatchPredictionJobAsync()} . - * - * @example samples/V1/JobServiceClient/cancel_batch_prediction_job.php - * - * @param CancelBatchPredictionJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function cancelBatchPredictionJob(CancelBatchPredictionJobRequest $request, array $callOptions = []): void - { - $this->startApiCall('CancelBatchPredictionJob', $request, $callOptions)->wait(); - } - - /** - * Cancels a CustomJob. - * Starts asynchronous cancellation on the CustomJob. The server - * makes a best effort to cancel the job, but success is not - * guaranteed. Clients can use - * [JobService.GetCustomJob][google.cloud.aiplatform.v1.JobService.GetCustomJob] - * or other methods to check whether the cancellation succeeded or whether the - * job completed despite cancellation. On successful cancellation, - * the CustomJob is not deleted; instead it becomes a job with - * a [CustomJob.error][google.cloud.aiplatform.v1.CustomJob.error] value with - * a [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to - * `Code.CANCELLED`, and - * [CustomJob.state][google.cloud.aiplatform.v1.CustomJob.state] is set to - * `CANCELLED`. - * - * The async variant is {@see self::cancelCustomJobAsync()} . - * - * @example samples/V1/JobServiceClient/cancel_custom_job.php - * - * @param CancelCustomJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function cancelCustomJob(CancelCustomJobRequest $request, array $callOptions = []): void - { - $this->startApiCall('CancelCustomJob', $request, $callOptions)->wait(); - } - - /** - * Cancels a DataLabelingJob. Success of cancellation is not guaranteed. - * - * The async variant is {@see self::cancelDataLabelingJobAsync()} . - * - * @example samples/V1/JobServiceClient/cancel_data_labeling_job.php - * - * @param CancelDataLabelingJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function cancelDataLabelingJob(CancelDataLabelingJobRequest $request, array $callOptions = []): void - { - $this->startApiCall('CancelDataLabelingJob', $request, $callOptions)->wait(); - } - - /** - * Cancels a HyperparameterTuningJob. - * Starts asynchronous cancellation on the HyperparameterTuningJob. The server - * makes a best effort to cancel the job, but success is not - * guaranteed. Clients can use - * [JobService.GetHyperparameterTuningJob][google.cloud.aiplatform.v1.JobService.GetHyperparameterTuningJob] - * or other methods to check whether the cancellation succeeded or whether the - * job completed despite cancellation. On successful cancellation, - * the HyperparameterTuningJob is not deleted; instead it becomes a job with - * a - * [HyperparameterTuningJob.error][google.cloud.aiplatform.v1.HyperparameterTuningJob.error] - * value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, - * corresponding to `Code.CANCELLED`, and - * [HyperparameterTuningJob.state][google.cloud.aiplatform.v1.HyperparameterTuningJob.state] - * is set to `CANCELLED`. - * - * The async variant is {@see self::cancelHyperparameterTuningJobAsync()} . - * - * @example samples/V1/JobServiceClient/cancel_hyperparameter_tuning_job.php - * - * @param CancelHyperparameterTuningJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function cancelHyperparameterTuningJob(CancelHyperparameterTuningJobRequest $request, array $callOptions = []): void - { - $this->startApiCall('CancelHyperparameterTuningJob', $request, $callOptions)->wait(); - } - - /** - * Cancels a NasJob. - * Starts asynchronous cancellation on the NasJob. The server - * makes a best effort to cancel the job, but success is not - * guaranteed. Clients can use - * [JobService.GetNasJob][google.cloud.aiplatform.v1.JobService.GetNasJob] or - * other methods to check whether the cancellation succeeded or whether the - * job completed despite cancellation. On successful cancellation, - * the NasJob is not deleted; instead it becomes a job with - * a [NasJob.error][google.cloud.aiplatform.v1.NasJob.error] value with a - * [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to - * `Code.CANCELLED`, and - * [NasJob.state][google.cloud.aiplatform.v1.NasJob.state] is set to - * `CANCELLED`. - * - * The async variant is {@see self::cancelNasJobAsync()} . - * - * @example samples/V1/JobServiceClient/cancel_nas_job.php - * - * @param CancelNasJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function cancelNasJob(CancelNasJobRequest $request, array $callOptions = []): void - { - $this->startApiCall('CancelNasJob', $request, $callOptions)->wait(); - } - - /** - * Creates a BatchPredictionJob. A BatchPredictionJob once created will - * right away be attempted to start. - * - * The async variant is {@see self::createBatchPredictionJobAsync()} . - * - * @example samples/V1/JobServiceClient/create_batch_prediction_job.php - * - * @param CreateBatchPredictionJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BatchPredictionJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function createBatchPredictionJob(CreateBatchPredictionJobRequest $request, array $callOptions = []): BatchPredictionJob - { - return $this->startApiCall('CreateBatchPredictionJob', $request, $callOptions)->wait(); - } - - /** - * Creates a CustomJob. A created CustomJob right away - * will be attempted to be run. - * - * The async variant is {@see self::createCustomJobAsync()} . - * - * @example samples/V1/JobServiceClient/create_custom_job.php - * - * @param CreateCustomJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CustomJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCustomJob(CreateCustomJobRequest $request, array $callOptions = []): CustomJob - { - return $this->startApiCall('CreateCustomJob', $request, $callOptions)->wait(); - } - - /** - * Creates a DataLabelingJob. - * - * The async variant is {@see self::createDataLabelingJobAsync()} . - * - * @example samples/V1/JobServiceClient/create_data_labeling_job.php - * - * @param CreateDataLabelingJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataLabelingJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDataLabelingJob(CreateDataLabelingJobRequest $request, array $callOptions = []): DataLabelingJob - { - return $this->startApiCall('CreateDataLabelingJob', $request, $callOptions)->wait(); - } - - /** - * Creates a HyperparameterTuningJob - * - * The async variant is {@see self::createHyperparameterTuningJobAsync()} . - * - * @example samples/V1/JobServiceClient/create_hyperparameter_tuning_job.php - * - * @param CreateHyperparameterTuningJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 HyperparameterTuningJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function createHyperparameterTuningJob(CreateHyperparameterTuningJobRequest $request, array $callOptions = []): HyperparameterTuningJob - { - return $this->startApiCall('CreateHyperparameterTuningJob', $request, $callOptions)->wait(); - } - - /** - * Creates a ModelDeploymentMonitoringJob. It will run periodically on a - * configured interval. - * - * The async variant is {@see self::createModelDeploymentMonitoringJobAsync()} . - * - * @example samples/V1/JobServiceClient/create_model_deployment_monitoring_job.php - * - * @param CreateModelDeploymentMonitoringJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ModelDeploymentMonitoringJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function createModelDeploymentMonitoringJob(CreateModelDeploymentMonitoringJobRequest $request, array $callOptions = []): ModelDeploymentMonitoringJob - { - return $this->startApiCall('CreateModelDeploymentMonitoringJob', $request, $callOptions)->wait(); - } - - /** - * Creates a NasJob - * - * The async variant is {@see self::createNasJobAsync()} . - * - * @example samples/V1/JobServiceClient/create_nas_job.php - * - * @param CreateNasJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NasJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function createNasJob(CreateNasJobRequest $request, array $callOptions = []): NasJob - { - return $this->startApiCall('CreateNasJob', $request, $callOptions)->wait(); - } - - /** - * Deletes a BatchPredictionJob. Can only be called on jobs that already - * finished. - * - * The async variant is {@see self::deleteBatchPredictionJobAsync()} . - * - * @example samples/V1/JobServiceClient/delete_batch_prediction_job.php - * - * @param DeleteBatchPredictionJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteBatchPredictionJob(DeleteBatchPredictionJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteBatchPredictionJob', $request, $callOptions)->wait(); - } - - /** - * Deletes a CustomJob. - * - * The async variant is {@see self::deleteCustomJobAsync()} . - * - * @example samples/V1/JobServiceClient/delete_custom_job.php - * - * @param DeleteCustomJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteCustomJob(DeleteCustomJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteCustomJob', $request, $callOptions)->wait(); - } - - /** - * Deletes a DataLabelingJob. - * - * The async variant is {@see self::deleteDataLabelingJobAsync()} . - * - * @example samples/V1/JobServiceClient/delete_data_labeling_job.php - * - * @param DeleteDataLabelingJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDataLabelingJob(DeleteDataLabelingJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteDataLabelingJob', $request, $callOptions)->wait(); - } - - /** - * Deletes a HyperparameterTuningJob. - * - * The async variant is {@see self::deleteHyperparameterTuningJobAsync()} . - * - * @example samples/V1/JobServiceClient/delete_hyperparameter_tuning_job.php - * - * @param DeleteHyperparameterTuningJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteHyperparameterTuningJob(DeleteHyperparameterTuningJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteHyperparameterTuningJob', $request, $callOptions)->wait(); - } - - /** - * Deletes a ModelDeploymentMonitoringJob. - * - * The async variant is {@see self::deleteModelDeploymentMonitoringJobAsync()} . - * - * @example samples/V1/JobServiceClient/delete_model_deployment_monitoring_job.php - * - * @param DeleteModelDeploymentMonitoringJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteModelDeploymentMonitoringJob(DeleteModelDeploymentMonitoringJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteModelDeploymentMonitoringJob', $request, $callOptions)->wait(); - } - - /** - * Deletes a NasJob. - * - * The async variant is {@see self::deleteNasJobAsync()} . - * - * @example samples/V1/JobServiceClient/delete_nas_job.php - * - * @param DeleteNasJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteNasJob(DeleteNasJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteNasJob', $request, $callOptions)->wait(); - } - - /** - * Gets a BatchPredictionJob - * - * The async variant is {@see self::getBatchPredictionJobAsync()} . - * - * @example samples/V1/JobServiceClient/get_batch_prediction_job.php - * - * @param GetBatchPredictionJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BatchPredictionJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function getBatchPredictionJob(GetBatchPredictionJobRequest $request, array $callOptions = []): BatchPredictionJob - { - return $this->startApiCall('GetBatchPredictionJob', $request, $callOptions)->wait(); - } - - /** - * Gets a CustomJob. - * - * The async variant is {@see self::getCustomJobAsync()} . - * - * @example samples/V1/JobServiceClient/get_custom_job.php - * - * @param GetCustomJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CustomJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCustomJob(GetCustomJobRequest $request, array $callOptions = []): CustomJob - { - return $this->startApiCall('GetCustomJob', $request, $callOptions)->wait(); - } - - /** - * Gets a DataLabelingJob. - * - * The async variant is {@see self::getDataLabelingJobAsync()} . - * - * @example samples/V1/JobServiceClient/get_data_labeling_job.php - * - * @param GetDataLabelingJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataLabelingJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDataLabelingJob(GetDataLabelingJobRequest $request, array $callOptions = []): DataLabelingJob - { - return $this->startApiCall('GetDataLabelingJob', $request, $callOptions)->wait(); - } - - /** - * Gets a HyperparameterTuningJob - * - * The async variant is {@see self::getHyperparameterTuningJobAsync()} . - * - * @example samples/V1/JobServiceClient/get_hyperparameter_tuning_job.php - * - * @param GetHyperparameterTuningJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 HyperparameterTuningJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function getHyperparameterTuningJob(GetHyperparameterTuningJobRequest $request, array $callOptions = []): HyperparameterTuningJob - { - return $this->startApiCall('GetHyperparameterTuningJob', $request, $callOptions)->wait(); - } - - /** - * Gets a ModelDeploymentMonitoringJob. - * - * The async variant is {@see self::getModelDeploymentMonitoringJobAsync()} . - * - * @example samples/V1/JobServiceClient/get_model_deployment_monitoring_job.php - * - * @param GetModelDeploymentMonitoringJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ModelDeploymentMonitoringJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function getModelDeploymentMonitoringJob(GetModelDeploymentMonitoringJobRequest $request, array $callOptions = []): ModelDeploymentMonitoringJob - { - return $this->startApiCall('GetModelDeploymentMonitoringJob', $request, $callOptions)->wait(); - } - - /** - * Gets a NasJob - * - * The async variant is {@see self::getNasJobAsync()} . - * - * @example samples/V1/JobServiceClient/get_nas_job.php - * - * @param GetNasJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NasJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function getNasJob(GetNasJobRequest $request, array $callOptions = []): NasJob - { - return $this->startApiCall('GetNasJob', $request, $callOptions)->wait(); - } - - /** - * Gets a NasTrialDetail. - * - * The async variant is {@see self::getNasTrialDetailAsync()} . - * - * @example samples/V1/JobServiceClient/get_nas_trial_detail.php - * - * @param GetNasTrialDetailRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NasTrialDetail - * - * @throws ApiException Thrown if the API call fails. - */ - public function getNasTrialDetail(GetNasTrialDetailRequest $request, array $callOptions = []): NasTrialDetail - { - return $this->startApiCall('GetNasTrialDetail', $request, $callOptions)->wait(); - } - - /** - * Lists BatchPredictionJobs in a Location. - * - * The async variant is {@see self::listBatchPredictionJobsAsync()} . - * - * @example samples/V1/JobServiceClient/list_batch_prediction_jobs.php - * - * @param ListBatchPredictionJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listBatchPredictionJobs(ListBatchPredictionJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListBatchPredictionJobs', $request, $callOptions); - } - - /** - * Lists CustomJobs in a Location. - * - * The async variant is {@see self::listCustomJobsAsync()} . - * - * @example samples/V1/JobServiceClient/list_custom_jobs.php - * - * @param ListCustomJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCustomJobs(ListCustomJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCustomJobs', $request, $callOptions); - } - - /** - * Lists DataLabelingJobs in a Location. - * - * The async variant is {@see self::listDataLabelingJobsAsync()} . - * - * @example samples/V1/JobServiceClient/list_data_labeling_jobs.php - * - * @param ListDataLabelingJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDataLabelingJobs(ListDataLabelingJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDataLabelingJobs', $request, $callOptions); - } - - /** - * Lists HyperparameterTuningJobs in a Location. - * - * The async variant is {@see self::listHyperparameterTuningJobsAsync()} . - * - * @example samples/V1/JobServiceClient/list_hyperparameter_tuning_jobs.php - * - * @param ListHyperparameterTuningJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listHyperparameterTuningJobs(ListHyperparameterTuningJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListHyperparameterTuningJobs', $request, $callOptions); - } - - /** - * Lists ModelDeploymentMonitoringJobs in a Location. - * - * The async variant is {@see self::listModelDeploymentMonitoringJobsAsync()} . - * - * @example samples/V1/JobServiceClient/list_model_deployment_monitoring_jobs.php - * - * @param ListModelDeploymentMonitoringJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listModelDeploymentMonitoringJobs(ListModelDeploymentMonitoringJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListModelDeploymentMonitoringJobs', $request, $callOptions); - } - - /** - * Lists NasJobs in a Location. - * - * The async variant is {@see self::listNasJobsAsync()} . - * - * @example samples/V1/JobServiceClient/list_nas_jobs.php - * - * @param ListNasJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listNasJobs(ListNasJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListNasJobs', $request, $callOptions); - } - - /** - * List top NasTrialDetails of a NasJob. - * - * The async variant is {@see self::listNasTrialDetailsAsync()} . - * - * @example samples/V1/JobServiceClient/list_nas_trial_details.php - * - * @param ListNasTrialDetailsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listNasTrialDetails(ListNasTrialDetailsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListNasTrialDetails', $request, $callOptions); - } - - /** - * Pauses a ModelDeploymentMonitoringJob. If the job is running, the server - * makes a best effort to cancel the job. Will mark - * [ModelDeploymentMonitoringJob.state][google.cloud.aiplatform.v1.ModelDeploymentMonitoringJob.state] - * to 'PAUSED'. - * - * The async variant is {@see self::pauseModelDeploymentMonitoringJobAsync()} . - * - * @example samples/V1/JobServiceClient/pause_model_deployment_monitoring_job.php - * - * @param PauseModelDeploymentMonitoringJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function pauseModelDeploymentMonitoringJob(PauseModelDeploymentMonitoringJobRequest $request, array $callOptions = []): void - { - $this->startApiCall('PauseModelDeploymentMonitoringJob', $request, $callOptions)->wait(); - } - - /** - * Resumes a paused ModelDeploymentMonitoringJob. It will start to run from - * next scheduled time. A deleted ModelDeploymentMonitoringJob can't be - * resumed. - * - * The async variant is {@see self::resumeModelDeploymentMonitoringJobAsync()} . - * - * @example samples/V1/JobServiceClient/resume_model_deployment_monitoring_job.php - * - * @param ResumeModelDeploymentMonitoringJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function resumeModelDeploymentMonitoringJob(ResumeModelDeploymentMonitoringJobRequest $request, array $callOptions = []): void - { - $this->startApiCall('ResumeModelDeploymentMonitoringJob', $request, $callOptions)->wait(); - } - - /** - * Searches Model Monitoring Statistics generated within a given time window. - * - * The async variant is - * {@see self::searchModelDeploymentMonitoringStatsAnomaliesAsync()} . - * - * @example samples/V1/JobServiceClient/search_model_deployment_monitoring_stats_anomalies.php - * - * @param SearchModelDeploymentMonitoringStatsAnomaliesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchModelDeploymentMonitoringStatsAnomalies(SearchModelDeploymentMonitoringStatsAnomaliesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchModelDeploymentMonitoringStatsAnomalies', $request, $callOptions); - } - - /** - * Updates a ModelDeploymentMonitoringJob. - * - * The async variant is {@see self::updateModelDeploymentMonitoringJobAsync()} . - * - * @example samples/V1/JobServiceClient/update_model_deployment_monitoring_job.php - * - * @param UpdateModelDeploymentMonitoringJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateModelDeploymentMonitoringJob(UpdateModelDeploymentMonitoringJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateModelDeploymentMonitoringJob', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/JobServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/JobServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/JobServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/JobServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/JobServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/AiPlatform/src/V1/Client/BaseClient/MatchServiceBaseClient.php b/AiPlatform/src/V1/Client/BaseClient/MatchServiceBaseClient.php deleted file mode 100644 index 21047330848b..000000000000 --- a/AiPlatform/src/V1/Client/BaseClient/MatchServiceBaseClient.php +++ /dev/null @@ -1,425 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/match_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/match_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/match_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/match_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * index_endpoint resource. - * - * @param string $project - * @param string $location - * @param string $indexEndpoint - * - * @return string The formatted index_endpoint resource. - */ - public static function indexEndpointName(string $project, string $location, string $indexEndpoint): string - { - return self::getPathTemplate('indexEndpoint')->render([ - 'project' => $project, - 'location' => $location, - 'index_endpoint' => $indexEndpoint, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - indexEndpoint: projects/{project}/locations/{location}/indexEndpoints/{index_endpoint} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'aiplatform.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Finds the nearest neighbors of each vector within the request. - * - * The async variant is {@see self::findNeighborsAsync()} . - * - * @example samples/V1/MatchServiceClient/find_neighbors.php - * - * @param FindNeighborsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FindNeighborsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function findNeighbors(FindNeighborsRequest $request, array $callOptions = []): FindNeighborsResponse - { - return $this->startApiCall('FindNeighbors', $request, $callOptions)->wait(); - } - - /** - * Reads the datapoints/vectors of the given IDs. - * A maximum of 1000 datapoints can be retrieved in a batch. - * - * The async variant is {@see self::readIndexDatapointsAsync()} . - * - * @example samples/V1/MatchServiceClient/read_index_datapoints.php - * - * @param ReadIndexDatapointsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ReadIndexDatapointsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function readIndexDatapoints(ReadIndexDatapointsRequest $request, array $callOptions = []): ReadIndexDatapointsResponse - { - return $this->startApiCall('ReadIndexDatapoints', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/MatchServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/MatchServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/MatchServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/MatchServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/MatchServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/AiPlatform/src/V1/Client/BaseClient/MetadataServiceBaseClient.php b/AiPlatform/src/V1/Client/BaseClient/MetadataServiceBaseClient.php deleted file mode 100644 index cb728f607304..000000000000 --- a/AiPlatform/src/V1/Client/BaseClient/MetadataServiceBaseClient.php +++ /dev/null @@ -1,1429 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/metadata_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/metadata_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/metadata_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/metadata_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a artifact - * resource. - * - * @param string $project - * @param string $location - * @param string $metadataStore - * @param string $artifact - * - * @return string The formatted artifact resource. - */ - public static function artifactName(string $project, string $location, string $metadataStore, string $artifact): string - { - return self::getPathTemplate('artifact')->render([ - 'project' => $project, - 'location' => $location, - 'metadata_store' => $metadataStore, - 'artifact' => $artifact, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a context - * resource. - * - * @param string $project - * @param string $location - * @param string $metadataStore - * @param string $context - * - * @return string The formatted context resource. - */ - public static function contextName(string $project, string $location, string $metadataStore, string $context): string - { - return self::getPathTemplate('context')->render([ - 'project' => $project, - 'location' => $location, - 'metadata_store' => $metadataStore, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a execution - * resource. - * - * @param string $project - * @param string $location - * @param string $metadataStore - * @param string $execution - * - * @return string The formatted execution resource. - */ - public static function executionName(string $project, string $location, string $metadataStore, string $execution): string - { - return self::getPathTemplate('execution')->render([ - 'project' => $project, - 'location' => $location, - 'metadata_store' => $metadataStore, - 'execution' => $execution, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * metadata_schema resource. - * - * @param string $project - * @param string $location - * @param string $metadataStore - * @param string $metadataSchema - * - * @return string The formatted metadata_schema resource. - */ - public static function metadataSchemaName(string $project, string $location, string $metadataStore, string $metadataSchema): string - { - return self::getPathTemplate('metadataSchema')->render([ - 'project' => $project, - 'location' => $location, - 'metadata_store' => $metadataStore, - 'metadata_schema' => $metadataSchema, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * metadata_store resource. - * - * @param string $project - * @param string $location - * @param string $metadataStore - * - * @return string The formatted metadata_store resource. - */ - public static function metadataStoreName(string $project, string $location, string $metadataStore): string - { - return self::getPathTemplate('metadataStore')->render([ - 'project' => $project, - 'location' => $location, - 'metadata_store' => $metadataStore, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - artifact: projects/{project}/locations/{location}/metadataStores/{metadata_store}/artifacts/{artifact} - * - context: projects/{project}/locations/{location}/metadataStores/{metadata_store}/contexts/{context} - * - execution: projects/{project}/locations/{location}/metadataStores/{metadata_store}/executions/{execution} - * - location: projects/{project}/locations/{location} - * - metadataSchema: projects/{project}/locations/{location}/metadataStores/{metadata_store}/metadataSchemas/{metadata_schema} - * - metadataStore: projects/{project}/locations/{location}/metadataStores/{metadata_store} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'aiplatform.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Adds a set of Artifacts and Executions to a Context. If any of the - * Artifacts or Executions have already been added to a Context, they are - * simply skipped. - * - * The async variant is {@see self::addContextArtifactsAndExecutionsAsync()} . - * - * @example samples/V1/MetadataServiceClient/add_context_artifacts_and_executions.php - * - * @param AddContextArtifactsAndExecutionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AddContextArtifactsAndExecutionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addContextArtifactsAndExecutions(AddContextArtifactsAndExecutionsRequest $request, array $callOptions = []): AddContextArtifactsAndExecutionsResponse - { - return $this->startApiCall('AddContextArtifactsAndExecutions', $request, $callOptions)->wait(); - } - - /** - * Adds a set of Contexts as children to a parent Context. If any of the - * child Contexts have already been added to the parent Context, they are - * simply skipped. If this call would create a cycle or cause any Context to - * have more than 10 parents, the request will fail with an INVALID_ARGUMENT - * error. - * - * The async variant is {@see self::addContextChildrenAsync()} . - * - * @example samples/V1/MetadataServiceClient/add_context_children.php - * - * @param AddContextChildrenRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AddContextChildrenResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addContextChildren(AddContextChildrenRequest $request, array $callOptions = []): AddContextChildrenResponse - { - return $this->startApiCall('AddContextChildren', $request, $callOptions)->wait(); - } - - /** - * Adds Events to the specified Execution. An Event indicates whether an - * Artifact was used as an input or output for an Execution. If an Event - * already exists between the Execution and the Artifact, the Event is - * skipped. - * - * The async variant is {@see self::addExecutionEventsAsync()} . - * - * @example samples/V1/MetadataServiceClient/add_execution_events.php - * - * @param AddExecutionEventsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AddExecutionEventsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addExecutionEvents(AddExecutionEventsRequest $request, array $callOptions = []): AddExecutionEventsResponse - { - return $this->startApiCall('AddExecutionEvents', $request, $callOptions)->wait(); - } - - /** - * Creates an Artifact associated with a MetadataStore. - * - * The async variant is {@see self::createArtifactAsync()} . - * - * @example samples/V1/MetadataServiceClient/create_artifact.php - * - * @param CreateArtifactRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Artifact - * - * @throws ApiException Thrown if the API call fails. - */ - public function createArtifact(CreateArtifactRequest $request, array $callOptions = []): Artifact - { - return $this->startApiCall('CreateArtifact', $request, $callOptions)->wait(); - } - - /** - * Creates a Context associated with a MetadataStore. - * - * The async variant is {@see self::createContextAsync()} . - * - * @example samples/V1/MetadataServiceClient/create_context.php - * - * @param CreateContextRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Context - * - * @throws ApiException Thrown if the API call fails. - */ - public function createContext(CreateContextRequest $request, array $callOptions = []): Context - { - return $this->startApiCall('CreateContext', $request, $callOptions)->wait(); - } - - /** - * Creates an Execution associated with a MetadataStore. - * - * The async variant is {@see self::createExecutionAsync()} . - * - * @example samples/V1/MetadataServiceClient/create_execution.php - * - * @param CreateExecutionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Execution - * - * @throws ApiException Thrown if the API call fails. - */ - public function createExecution(CreateExecutionRequest $request, array $callOptions = []): Execution - { - return $this->startApiCall('CreateExecution', $request, $callOptions)->wait(); - } - - /** - * Creates a MetadataSchema. - * - * The async variant is {@see self::createMetadataSchemaAsync()} . - * - * @example samples/V1/MetadataServiceClient/create_metadata_schema.php - * - * @param CreateMetadataSchemaRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MetadataSchema - * - * @throws ApiException Thrown if the API call fails. - */ - public function createMetadataSchema(CreateMetadataSchemaRequest $request, array $callOptions = []): MetadataSchema - { - return $this->startApiCall('CreateMetadataSchema', $request, $callOptions)->wait(); - } - - /** - * Initializes a MetadataStore, including allocation of resources. - * - * The async variant is {@see self::createMetadataStoreAsync()} . - * - * @example samples/V1/MetadataServiceClient/create_metadata_store.php - * - * @param CreateMetadataStoreRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createMetadataStore(CreateMetadataStoreRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateMetadataStore', $request, $callOptions)->wait(); - } - - /** - * Deletes an Artifact. - * - * The async variant is {@see self::deleteArtifactAsync()} . - * - * @example samples/V1/MetadataServiceClient/delete_artifact.php - * - * @param DeleteArtifactRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteArtifact(DeleteArtifactRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteArtifact', $request, $callOptions)->wait(); - } - - /** - * Deletes a stored Context. - * - * The async variant is {@see self::deleteContextAsync()} . - * - * @example samples/V1/MetadataServiceClient/delete_context.php - * - * @param DeleteContextRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteContext(DeleteContextRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteContext', $request, $callOptions)->wait(); - } - - /** - * Deletes an Execution. - * - * The async variant is {@see self::deleteExecutionAsync()} . - * - * @example samples/V1/MetadataServiceClient/delete_execution.php - * - * @param DeleteExecutionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteExecution(DeleteExecutionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteExecution', $request, $callOptions)->wait(); - } - - /** - * Deletes a single MetadataStore and all its child resources (Artifacts, - * Executions, and Contexts). - * - * The async variant is {@see self::deleteMetadataStoreAsync()} . - * - * @example samples/V1/MetadataServiceClient/delete_metadata_store.php - * - * @param DeleteMetadataStoreRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteMetadataStore(DeleteMetadataStoreRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteMetadataStore', $request, $callOptions)->wait(); - } - - /** - * Retrieves a specific Artifact. - * - * The async variant is {@see self::getArtifactAsync()} . - * - * @example samples/V1/MetadataServiceClient/get_artifact.php - * - * @param GetArtifactRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Artifact - * - * @throws ApiException Thrown if the API call fails. - */ - public function getArtifact(GetArtifactRequest $request, array $callOptions = []): Artifact - { - return $this->startApiCall('GetArtifact', $request, $callOptions)->wait(); - } - - /** - * Retrieves a specific Context. - * - * The async variant is {@see self::getContextAsync()} . - * - * @example samples/V1/MetadataServiceClient/get_context.php - * - * @param GetContextRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Context - * - * @throws ApiException Thrown if the API call fails. - */ - public function getContext(GetContextRequest $request, array $callOptions = []): Context - { - return $this->startApiCall('GetContext', $request, $callOptions)->wait(); - } - - /** - * Retrieves a specific Execution. - * - * The async variant is {@see self::getExecutionAsync()} . - * - * @example samples/V1/MetadataServiceClient/get_execution.php - * - * @param GetExecutionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Execution - * - * @throws ApiException Thrown if the API call fails. - */ - public function getExecution(GetExecutionRequest $request, array $callOptions = []): Execution - { - return $this->startApiCall('GetExecution', $request, $callOptions)->wait(); - } - - /** - * Retrieves a specific MetadataSchema. - * - * The async variant is {@see self::getMetadataSchemaAsync()} . - * - * @example samples/V1/MetadataServiceClient/get_metadata_schema.php - * - * @param GetMetadataSchemaRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MetadataSchema - * - * @throws ApiException Thrown if the API call fails. - */ - public function getMetadataSchema(GetMetadataSchemaRequest $request, array $callOptions = []): MetadataSchema - { - return $this->startApiCall('GetMetadataSchema', $request, $callOptions)->wait(); - } - - /** - * Retrieves a specific MetadataStore. - * - * The async variant is {@see self::getMetadataStoreAsync()} . - * - * @example samples/V1/MetadataServiceClient/get_metadata_store.php - * - * @param GetMetadataStoreRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MetadataStore - * - * @throws ApiException Thrown if the API call fails. - */ - public function getMetadataStore(GetMetadataStoreRequest $request, array $callOptions = []): MetadataStore - { - return $this->startApiCall('GetMetadataStore', $request, $callOptions)->wait(); - } - - /** - * Lists Artifacts in the MetadataStore. - * - * The async variant is {@see self::listArtifactsAsync()} . - * - * @example samples/V1/MetadataServiceClient/list_artifacts.php - * - * @param ListArtifactsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listArtifacts(ListArtifactsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListArtifacts', $request, $callOptions); - } - - /** - * Lists Contexts on the MetadataStore. - * - * The async variant is {@see self::listContextsAsync()} . - * - * @example samples/V1/MetadataServiceClient/list_contexts.php - * - * @param ListContextsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listContexts(ListContextsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListContexts', $request, $callOptions); - } - - /** - * Lists Executions in the MetadataStore. - * - * The async variant is {@see self::listExecutionsAsync()} . - * - * @example samples/V1/MetadataServiceClient/list_executions.php - * - * @param ListExecutionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listExecutions(ListExecutionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListExecutions', $request, $callOptions); - } - - /** - * Lists MetadataSchemas. - * - * The async variant is {@see self::listMetadataSchemasAsync()} . - * - * @example samples/V1/MetadataServiceClient/list_metadata_schemas.php - * - * @param ListMetadataSchemasRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listMetadataSchemas(ListMetadataSchemasRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListMetadataSchemas', $request, $callOptions); - } - - /** - * Lists MetadataStores for a Location. - * - * The async variant is {@see self::listMetadataStoresAsync()} . - * - * @example samples/V1/MetadataServiceClient/list_metadata_stores.php - * - * @param ListMetadataStoresRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listMetadataStores(ListMetadataStoresRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListMetadataStores', $request, $callOptions); - } - - /** - * Purges Artifacts. - * - * The async variant is {@see self::purgeArtifactsAsync()} . - * - * @example samples/V1/MetadataServiceClient/purge_artifacts.php - * - * @param PurgeArtifactsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function purgeArtifacts(PurgeArtifactsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('PurgeArtifacts', $request, $callOptions)->wait(); - } - - /** - * Purges Contexts. - * - * The async variant is {@see self::purgeContextsAsync()} . - * - * @example samples/V1/MetadataServiceClient/purge_contexts.php - * - * @param PurgeContextsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function purgeContexts(PurgeContextsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('PurgeContexts', $request, $callOptions)->wait(); - } - - /** - * Purges Executions. - * - * The async variant is {@see self::purgeExecutionsAsync()} . - * - * @example samples/V1/MetadataServiceClient/purge_executions.php - * - * @param PurgeExecutionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function purgeExecutions(PurgeExecutionsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('PurgeExecutions', $request, $callOptions)->wait(); - } - - /** - * Retrieves lineage of an Artifact represented through Artifacts and - * Executions connected by Event edges and returned as a LineageSubgraph. - * - * The async variant is {@see self::queryArtifactLineageSubgraphAsync()} . - * - * @example samples/V1/MetadataServiceClient/query_artifact_lineage_subgraph.php - * - * @param QueryArtifactLineageSubgraphRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LineageSubgraph - * - * @throws ApiException Thrown if the API call fails. - */ - public function queryArtifactLineageSubgraph(QueryArtifactLineageSubgraphRequest $request, array $callOptions = []): LineageSubgraph - { - return $this->startApiCall('QueryArtifactLineageSubgraph', $request, $callOptions)->wait(); - } - - /** - * Retrieves Artifacts and Executions within the specified Context, connected - * by Event edges and returned as a LineageSubgraph. - * - * The async variant is {@see self::queryContextLineageSubgraphAsync()} . - * - * @example samples/V1/MetadataServiceClient/query_context_lineage_subgraph.php - * - * @param QueryContextLineageSubgraphRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LineageSubgraph - * - * @throws ApiException Thrown if the API call fails. - */ - public function queryContextLineageSubgraph(QueryContextLineageSubgraphRequest $request, array $callOptions = []): LineageSubgraph - { - return $this->startApiCall('QueryContextLineageSubgraph', $request, $callOptions)->wait(); - } - - /** - * Obtains the set of input and output Artifacts for this Execution, in the - * form of LineageSubgraph that also contains the Execution and connecting - * Events. - * - * The async variant is {@see self::queryExecutionInputsAndOutputsAsync()} . - * - * @example samples/V1/MetadataServiceClient/query_execution_inputs_and_outputs.php - * - * @param QueryExecutionInputsAndOutputsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LineageSubgraph - * - * @throws ApiException Thrown if the API call fails. - */ - public function queryExecutionInputsAndOutputs(QueryExecutionInputsAndOutputsRequest $request, array $callOptions = []): LineageSubgraph - { - return $this->startApiCall('QueryExecutionInputsAndOutputs', $request, $callOptions)->wait(); - } - - /** - * Remove a set of children contexts from a parent Context. If any of the - * child Contexts were NOT added to the parent Context, they are - * simply skipped. - * - * The async variant is {@see self::removeContextChildrenAsync()} . - * - * @example samples/V1/MetadataServiceClient/remove_context_children.php - * - * @param RemoveContextChildrenRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RemoveContextChildrenResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function removeContextChildren(RemoveContextChildrenRequest $request, array $callOptions = []): RemoveContextChildrenResponse - { - return $this->startApiCall('RemoveContextChildren', $request, $callOptions)->wait(); - } - - /** - * Updates a stored Artifact. - * - * The async variant is {@see self::updateArtifactAsync()} . - * - * @example samples/V1/MetadataServiceClient/update_artifact.php - * - * @param UpdateArtifactRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Artifact - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateArtifact(UpdateArtifactRequest $request, array $callOptions = []): Artifact - { - return $this->startApiCall('UpdateArtifact', $request, $callOptions)->wait(); - } - - /** - * Updates a stored Context. - * - * The async variant is {@see self::updateContextAsync()} . - * - * @example samples/V1/MetadataServiceClient/update_context.php - * - * @param UpdateContextRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Context - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateContext(UpdateContextRequest $request, array $callOptions = []): Context - { - return $this->startApiCall('UpdateContext', $request, $callOptions)->wait(); - } - - /** - * Updates a stored Execution. - * - * The async variant is {@see self::updateExecutionAsync()} . - * - * @example samples/V1/MetadataServiceClient/update_execution.php - * - * @param UpdateExecutionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Execution - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateExecution(UpdateExecutionRequest $request, array $callOptions = []): Execution - { - return $this->startApiCall('UpdateExecution', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/MetadataServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/MetadataServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/MetadataServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/MetadataServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/MetadataServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/AiPlatform/src/V1/Client/BaseClient/MigrationServiceBaseClient.php b/AiPlatform/src/V1/Client/BaseClient/MigrationServiceBaseClient.php deleted file mode 100644 index 4fdcf6fbd218..000000000000 --- a/AiPlatform/src/V1/Client/BaseClient/MigrationServiceBaseClient.php +++ /dev/null @@ -1,539 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/migration_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/migration_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/migration_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/migration_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * annotated_dataset resource. - * - * @param string $project - * @param string $dataset - * @param string $annotatedDataset - * - * @return string The formatted annotated_dataset resource. - */ - public static function annotatedDatasetName(string $project, string $dataset, string $annotatedDataset): string - { - return self::getPathTemplate('annotatedDataset')->render([ - 'project' => $project, - 'dataset' => $dataset, - 'annotated_dataset' => $annotatedDataset, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a dataset - * resource. - * - * @param string $project - * @param string $location - * @param string $dataset - * - * @return string The formatted dataset resource. - */ - public static function datasetName(string $project, string $location, string $dataset): string - { - return self::getPathTemplate('dataset')->render([ - 'project' => $project, - 'location' => $location, - 'dataset' => $dataset, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a model - * resource. - * - * @param string $project - * @param string $location - * @param string $model - * - * @return string The formatted model resource. - */ - public static function modelName(string $project, string $location, string $model): string - { - return self::getPathTemplate('model')->render([ - 'project' => $project, - 'location' => $location, - 'model' => $model, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a version - * resource. - * - * @param string $project - * @param string $model - * @param string $version - * - * @return string The formatted version resource. - */ - public static function versionName(string $project, string $model, string $version): string - { - return self::getPathTemplate('version')->render([ - 'project' => $project, - 'model' => $model, - 'version' => $version, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - annotatedDataset: projects/{project}/datasets/{dataset}/annotatedDatasets/{annotated_dataset} - * - dataset: projects/{project}/locations/{location}/datasets/{dataset} - * - location: projects/{project}/locations/{location} - * - model: projects/{project}/locations/{location}/models/{model} - * - version: projects/{project}/models/{model}/versions/{version} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'aiplatform.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Batch migrates resources from ml.googleapis.com, automl.googleapis.com, - * and datalabeling.googleapis.com to Vertex AI. - * - * The async variant is {@see self::batchMigrateResourcesAsync()} . - * - * @example samples/V1/MigrationServiceClient/batch_migrate_resources.php - * - * @param BatchMigrateResourcesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchMigrateResources(BatchMigrateResourcesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BatchMigrateResources', $request, $callOptions)->wait(); - } - - /** - * Searches all of the resources in automl.googleapis.com, - * datalabeling.googleapis.com and ml.googleapis.com that can be migrated to - * Vertex AI's given location. - * - * The async variant is {@see self::searchMigratableResourcesAsync()} . - * - * @example samples/V1/MigrationServiceClient/search_migratable_resources.php - * - * @param SearchMigratableResourcesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchMigratableResources(SearchMigratableResourcesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchMigratableResources', $request, $callOptions); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/MigrationServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/MigrationServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/MigrationServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/MigrationServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/MigrationServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/AiPlatform/src/V1/Client/BaseClient/ModelGardenServiceBaseClient.php b/AiPlatform/src/V1/Client/BaseClient/ModelGardenServiceBaseClient.php deleted file mode 100644 index 67c2bdab0829..000000000000 --- a/AiPlatform/src/V1/Client/BaseClient/ModelGardenServiceBaseClient.php +++ /dev/null @@ -1,393 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/model_garden_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/model_garden_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/model_garden_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/model_garden_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * publisher_model resource. - * - * @param string $publisher - * @param string $model - * - * @return string The formatted publisher_model resource. - */ - public static function publisherModelName(string $publisher, string $model): string - { - return self::getPathTemplate('publisherModel')->render([ - 'publisher' => $publisher, - 'model' => $model, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - publisherModel: publishers/{publisher}/models/{model} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'aiplatform.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Gets a Model Garden publisher model. - * - * The async variant is {@see self::getPublisherModelAsync()} . - * - * @example samples/V1/ModelGardenServiceClient/get_publisher_model.php - * - * @param GetPublisherModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PublisherModel - * - * @throws ApiException Thrown if the API call fails. - */ - public function getPublisherModel(GetPublisherModelRequest $request, array $callOptions = []): PublisherModel - { - return $this->startApiCall('GetPublisherModel', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/ModelGardenServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/ModelGardenServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/ModelGardenServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/ModelGardenServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/ModelGardenServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/AiPlatform/src/V1/Client/BaseClient/ModelServiceBaseClient.php b/AiPlatform/src/V1/Client/BaseClient/ModelServiceBaseClient.php deleted file mode 100644 index f28bd08e3a2d..000000000000 --- a/AiPlatform/src/V1/Client/BaseClient/ModelServiceBaseClient.php +++ /dev/null @@ -1,1096 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/model_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/model_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/model_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/model_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a endpoint - * resource. - * - * @param string $project - * @param string $location - * @param string $endpoint - * - * @return string The formatted endpoint resource. - */ - public static function endpointName(string $project, string $location, string $endpoint): string - { - return self::getPathTemplate('endpoint')->render([ - 'project' => $project, - 'location' => $location, - 'endpoint' => $endpoint, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a model - * resource. - * - * @param string $project - * @param string $location - * @param string $model - * - * @return string The formatted model resource. - */ - public static function modelName(string $project, string $location, string $model): string - { - return self::getPathTemplate('model')->render([ - 'project' => $project, - 'location' => $location, - 'model' => $model, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * model_evaluation resource. - * - * @param string $project - * @param string $location - * @param string $model - * @param string $evaluation - * - * @return string The formatted model_evaluation resource. - */ - public static function modelEvaluationName(string $project, string $location, string $model, string $evaluation): string - { - return self::getPathTemplate('modelEvaluation')->render([ - 'project' => $project, - 'location' => $location, - 'model' => $model, - 'evaluation' => $evaluation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * model_evaluation_slice resource. - * - * @param string $project - * @param string $location - * @param string $model - * @param string $evaluation - * @param string $slice - * - * @return string The formatted model_evaluation_slice resource. - */ - public static function modelEvaluationSliceName(string $project, string $location, string $model, string $evaluation, string $slice): string - { - return self::getPathTemplate('modelEvaluationSlice')->render([ - 'project' => $project, - 'location' => $location, - 'model' => $model, - 'evaluation' => $evaluation, - 'slice' => $slice, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a pipeline_job - * resource. - * - * @param string $project - * @param string $location - * @param string $pipelineJob - * - * @return string The formatted pipeline_job resource. - */ - public static function pipelineJobName(string $project, string $location, string $pipelineJob): string - { - return self::getPathTemplate('pipelineJob')->render([ - 'project' => $project, - 'location' => $location, - 'pipeline_job' => $pipelineJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_endpoint resource. - * - * @param string $project - * @param string $location - * @param string $endpoint - * - * @return string The formatted project_location_endpoint resource. - */ - public static function projectLocationEndpointName(string $project, string $location, string $endpoint): string - { - return self::getPathTemplate('projectLocationEndpoint')->render([ - 'project' => $project, - 'location' => $location, - 'endpoint' => $endpoint, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_publisher_model resource. - * - * @param string $project - * @param string $location - * @param string $publisher - * @param string $model - * - * @return string The formatted project_location_publisher_model resource. - */ - public static function projectLocationPublisherModelName(string $project, string $location, string $publisher, string $model): string - { - return self::getPathTemplate('projectLocationPublisherModel')->render([ - 'project' => $project, - 'location' => $location, - 'publisher' => $publisher, - 'model' => $model, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * training_pipeline resource. - * - * @param string $project - * @param string $location - * @param string $trainingPipeline - * - * @return string The formatted training_pipeline resource. - */ - public static function trainingPipelineName(string $project, string $location, string $trainingPipeline): string - { - return self::getPathTemplate('trainingPipeline')->render([ - 'project' => $project, - 'location' => $location, - 'training_pipeline' => $trainingPipeline, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - endpoint: projects/{project}/locations/{location}/endpoints/{endpoint} - * - location: projects/{project}/locations/{location} - * - model: projects/{project}/locations/{location}/models/{model} - * - modelEvaluation: projects/{project}/locations/{location}/models/{model}/evaluations/{evaluation} - * - modelEvaluationSlice: projects/{project}/locations/{location}/models/{model}/evaluations/{evaluation}/slices/{slice} - * - pipelineJob: projects/{project}/locations/{location}/pipelineJobs/{pipeline_job} - * - projectLocationEndpoint: projects/{project}/locations/{location}/endpoints/{endpoint} - * - projectLocationPublisherModel: projects/{project}/locations/{location}/publishers/{publisher}/models/{model} - * - trainingPipeline: projects/{project}/locations/{location}/trainingPipelines/{training_pipeline} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'aiplatform.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Imports a list of externally generated EvaluatedAnnotations. - * - * The async variant is {@see self::batchImportEvaluatedAnnotationsAsync()} . - * - * @example samples/V1/ModelServiceClient/batch_import_evaluated_annotations.php - * - * @param BatchImportEvaluatedAnnotationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BatchImportEvaluatedAnnotationsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchImportEvaluatedAnnotations(BatchImportEvaluatedAnnotationsRequest $request, array $callOptions = []): BatchImportEvaluatedAnnotationsResponse - { - return $this->startApiCall('BatchImportEvaluatedAnnotations', $request, $callOptions)->wait(); - } - - /** - * Imports a list of externally generated ModelEvaluationSlice. - * - * The async variant is {@see self::batchImportModelEvaluationSlicesAsync()} . - * - * @example samples/V1/ModelServiceClient/batch_import_model_evaluation_slices.php - * - * @param BatchImportModelEvaluationSlicesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BatchImportModelEvaluationSlicesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchImportModelEvaluationSlices(BatchImportModelEvaluationSlicesRequest $request, array $callOptions = []): BatchImportModelEvaluationSlicesResponse - { - return $this->startApiCall('BatchImportModelEvaluationSlices', $request, $callOptions)->wait(); - } - - /** - * Copies an already existing Vertex AI Model into the specified Location. - * The source Model must exist in the same Project. - * When copying custom Models, the users themselves are responsible for - * [Model.metadata][google.cloud.aiplatform.v1.Model.metadata] content to be - * region-agnostic, as well as making sure that any resources (e.g. files) it - * depends on remain accessible. - * - * The async variant is {@see self::copyModelAsync()} . - * - * @example samples/V1/ModelServiceClient/copy_model.php - * - * @param CopyModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function copyModel(CopyModelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CopyModel', $request, $callOptions)->wait(); - } - - /** - * Deletes a Model. - * - * A model cannot be deleted if any - * [Endpoint][google.cloud.aiplatform.v1.Endpoint] resource has a - * [DeployedModel][google.cloud.aiplatform.v1.DeployedModel] based on the - * model in its - * [deployed_models][google.cloud.aiplatform.v1.Endpoint.deployed_models] - * field. - * - * The async variant is {@see self::deleteModelAsync()} . - * - * @example samples/V1/ModelServiceClient/delete_model.php - * - * @param DeleteModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteModel(DeleteModelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteModel', $request, $callOptions)->wait(); - } - - /** - * Deletes a Model version. - * - * Model version can only be deleted if there are no - * [DeployedModels][google.cloud.aiplatform.v1.DeployedModel] created from it. - * Deleting the only version in the Model is not allowed. Use - * [DeleteModel][google.cloud.aiplatform.v1.ModelService.DeleteModel] for - * deleting the Model instead. - * - * The async variant is {@see self::deleteModelVersionAsync()} . - * - * @example samples/V1/ModelServiceClient/delete_model_version.php - * - * @param DeleteModelVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteModelVersion(DeleteModelVersionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteModelVersion', $request, $callOptions)->wait(); - } - - /** - * Exports a trained, exportable Model to a location specified by the - * user. A Model is considered to be exportable if it has at least one - * [supported export - * format][google.cloud.aiplatform.v1.Model.supported_export_formats]. - * - * The async variant is {@see self::exportModelAsync()} . - * - * @example samples/V1/ModelServiceClient/export_model.php - * - * @param ExportModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function exportModel(ExportModelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ExportModel', $request, $callOptions)->wait(); - } - - /** - * Gets a Model. - * - * The async variant is {@see self::getModelAsync()} . - * - * @example samples/V1/ModelServiceClient/get_model.php - * - * @param GetModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Model - * - * @throws ApiException Thrown if the API call fails. - */ - public function getModel(GetModelRequest $request, array $callOptions = []): Model - { - return $this->startApiCall('GetModel', $request, $callOptions)->wait(); - } - - /** - * Gets a ModelEvaluation. - * - * The async variant is {@see self::getModelEvaluationAsync()} . - * - * @example samples/V1/ModelServiceClient/get_model_evaluation.php - * - * @param GetModelEvaluationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ModelEvaluation - * - * @throws ApiException Thrown if the API call fails. - */ - public function getModelEvaluation(GetModelEvaluationRequest $request, array $callOptions = []): ModelEvaluation - { - return $this->startApiCall('GetModelEvaluation', $request, $callOptions)->wait(); - } - - /** - * Gets a ModelEvaluationSlice. - * - * The async variant is {@see self::getModelEvaluationSliceAsync()} . - * - * @example samples/V1/ModelServiceClient/get_model_evaluation_slice.php - * - * @param GetModelEvaluationSliceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ModelEvaluationSlice - * - * @throws ApiException Thrown if the API call fails. - */ - public function getModelEvaluationSlice(GetModelEvaluationSliceRequest $request, array $callOptions = []): ModelEvaluationSlice - { - return $this->startApiCall('GetModelEvaluationSlice', $request, $callOptions)->wait(); - } - - /** - * Imports an externally generated ModelEvaluation. - * - * The async variant is {@see self::importModelEvaluationAsync()} . - * - * @example samples/V1/ModelServiceClient/import_model_evaluation.php - * - * @param ImportModelEvaluationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ModelEvaluation - * - * @throws ApiException Thrown if the API call fails. - */ - public function importModelEvaluation(ImportModelEvaluationRequest $request, array $callOptions = []): ModelEvaluation - { - return $this->startApiCall('ImportModelEvaluation', $request, $callOptions)->wait(); - } - - /** - * Lists ModelEvaluationSlices in a ModelEvaluation. - * - * The async variant is {@see self::listModelEvaluationSlicesAsync()} . - * - * @example samples/V1/ModelServiceClient/list_model_evaluation_slices.php - * - * @param ListModelEvaluationSlicesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listModelEvaluationSlices(ListModelEvaluationSlicesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListModelEvaluationSlices', $request, $callOptions); - } - - /** - * Lists ModelEvaluations in a Model. - * - * The async variant is {@see self::listModelEvaluationsAsync()} . - * - * @example samples/V1/ModelServiceClient/list_model_evaluations.php - * - * @param ListModelEvaluationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listModelEvaluations(ListModelEvaluationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListModelEvaluations', $request, $callOptions); - } - - /** - * Lists versions of the specified model. - * - * The async variant is {@see self::listModelVersionsAsync()} . - * - * @example samples/V1/ModelServiceClient/list_model_versions.php - * - * @param ListModelVersionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listModelVersions(ListModelVersionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListModelVersions', $request, $callOptions); - } - - /** - * Lists Models in a Location. - * - * The async variant is {@see self::listModelsAsync()} . - * - * @example samples/V1/ModelServiceClient/list_models.php - * - * @param ListModelsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listModels(ListModelsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListModels', $request, $callOptions); - } - - /** - * Merges a set of aliases for a Model version. - * - * The async variant is {@see self::mergeVersionAliasesAsync()} . - * - * @example samples/V1/ModelServiceClient/merge_version_aliases.php - * - * @param MergeVersionAliasesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Model - * - * @throws ApiException Thrown if the API call fails. - */ - public function mergeVersionAliases(MergeVersionAliasesRequest $request, array $callOptions = []): Model - { - return $this->startApiCall('MergeVersionAliases', $request, $callOptions)->wait(); - } - - /** - * Incrementally update the dataset used for an examples model. - * - * The async variant is {@see self::updateExplanationDatasetAsync()} . - * - * @example samples/V1/ModelServiceClient/update_explanation_dataset.php - * - * @param UpdateExplanationDatasetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateExplanationDataset(UpdateExplanationDatasetRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateExplanationDataset', $request, $callOptions)->wait(); - } - - /** - * Updates a Model. - * - * The async variant is {@see self::updateModelAsync()} . - * - * @example samples/V1/ModelServiceClient/update_model.php - * - * @param UpdateModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Model - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateModel(UpdateModelRequest $request, array $callOptions = []): Model - { - return $this->startApiCall('UpdateModel', $request, $callOptions)->wait(); - } - - /** - * Uploads a Model artifact into Vertex AI. - * - * The async variant is {@see self::uploadModelAsync()} . - * - * @example samples/V1/ModelServiceClient/upload_model.php - * - * @param UploadModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function uploadModel(UploadModelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UploadModel', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/ModelServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/ModelServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/ModelServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/ModelServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/ModelServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/AiPlatform/src/V1/Client/BaseClient/PipelineServiceBaseClient.php b/AiPlatform/src/V1/Client/BaseClient/PipelineServiceBaseClient.php deleted file mode 100644 index e9c242ffbdd3..000000000000 --- a/AiPlatform/src/V1/Client/BaseClient/PipelineServiceBaseClient.php +++ /dev/null @@ -1,950 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/pipeline_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/pipeline_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/pipeline_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/pipeline_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a artifact - * resource. - * - * @param string $project - * @param string $location - * @param string $metadataStore - * @param string $artifact - * - * @return string The formatted artifact resource. - */ - public static function artifactName(string $project, string $location, string $metadataStore, string $artifact): string - { - return self::getPathTemplate('artifact')->render([ - 'project' => $project, - 'location' => $location, - 'metadata_store' => $metadataStore, - 'artifact' => $artifact, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a context - * resource. - * - * @param string $project - * @param string $location - * @param string $metadataStore - * @param string $context - * - * @return string The formatted context resource. - */ - public static function contextName(string $project, string $location, string $metadataStore, string $context): string - { - return self::getPathTemplate('context')->render([ - 'project' => $project, - 'location' => $location, - 'metadata_store' => $metadataStore, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a custom_job - * resource. - * - * @param string $project - * @param string $location - * @param string $customJob - * - * @return string The formatted custom_job resource. - */ - public static function customJobName(string $project, string $location, string $customJob): string - { - return self::getPathTemplate('customJob')->render([ - 'project' => $project, - 'location' => $location, - 'custom_job' => $customJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a endpoint - * resource. - * - * @param string $project - * @param string $location - * @param string $endpoint - * - * @return string The formatted endpoint resource. - */ - public static function endpointName(string $project, string $location, string $endpoint): string - { - return self::getPathTemplate('endpoint')->render([ - 'project' => $project, - 'location' => $location, - 'endpoint' => $endpoint, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a execution - * resource. - * - * @param string $project - * @param string $location - * @param string $metadataStore - * @param string $execution - * - * @return string The formatted execution resource. - */ - public static function executionName(string $project, string $location, string $metadataStore, string $execution): string - { - return self::getPathTemplate('execution')->render([ - 'project' => $project, - 'location' => $location, - 'metadata_store' => $metadataStore, - 'execution' => $execution, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * metadata_store resource. - * - * @param string $project - * @param string $location - * @param string $metadataStore - * - * @return string The formatted metadata_store resource. - */ - public static function metadataStoreName(string $project, string $location, string $metadataStore): string - { - return self::getPathTemplate('metadataStore')->render([ - 'project' => $project, - 'location' => $location, - 'metadata_store' => $metadataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a model - * resource. - * - * @param string $project - * @param string $location - * @param string $model - * - * @return string The formatted model resource. - */ - public static function modelName(string $project, string $location, string $model): string - { - return self::getPathTemplate('model')->render([ - 'project' => $project, - 'location' => $location, - 'model' => $model, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a network - * resource. - * - * @param string $project - * @param string $network - * - * @return string The formatted network resource. - */ - public static function networkName(string $project, string $network): string - { - return self::getPathTemplate('network')->render([ - 'project' => $project, - 'network' => $network, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a pipeline_job - * resource. - * - * @param string $project - * @param string $location - * @param string $pipelineJob - * - * @return string The formatted pipeline_job resource. - */ - public static function pipelineJobName(string $project, string $location, string $pipelineJob): string - { - return self::getPathTemplate('pipelineJob')->render([ - 'project' => $project, - 'location' => $location, - 'pipeline_job' => $pipelineJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_endpoint resource. - * - * @param string $project - * @param string $location - * @param string $endpoint - * - * @return string The formatted project_location_endpoint resource. - */ - public static function projectLocationEndpointName(string $project, string $location, string $endpoint): string - { - return self::getPathTemplate('projectLocationEndpoint')->render([ - 'project' => $project, - 'location' => $location, - 'endpoint' => $endpoint, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_publisher_model resource. - * - * @param string $project - * @param string $location - * @param string $publisher - * @param string $model - * - * @return string The formatted project_location_publisher_model resource. - */ - public static function projectLocationPublisherModelName(string $project, string $location, string $publisher, string $model): string - { - return self::getPathTemplate('projectLocationPublisherModel')->render([ - 'project' => $project, - 'location' => $location, - 'publisher' => $publisher, - 'model' => $model, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * training_pipeline resource. - * - * @param string $project - * @param string $location - * @param string $trainingPipeline - * - * @return string The formatted training_pipeline resource. - */ - public static function trainingPipelineName(string $project, string $location, string $trainingPipeline): string - { - return self::getPathTemplate('trainingPipeline')->render([ - 'project' => $project, - 'location' => $location, - 'training_pipeline' => $trainingPipeline, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - artifact: projects/{project}/locations/{location}/metadataStores/{metadata_store}/artifacts/{artifact} - * - context: projects/{project}/locations/{location}/metadataStores/{metadata_store}/contexts/{context} - * - customJob: projects/{project}/locations/{location}/customJobs/{custom_job} - * - endpoint: projects/{project}/locations/{location}/endpoints/{endpoint} - * - execution: projects/{project}/locations/{location}/metadataStores/{metadata_store}/executions/{execution} - * - location: projects/{project}/locations/{location} - * - metadataStore: projects/{project}/locations/{location}/metadataStores/{metadata_store} - * - model: projects/{project}/locations/{location}/models/{model} - * - network: projects/{project}/global/networks/{network} - * - pipelineJob: projects/{project}/locations/{location}/pipelineJobs/{pipeline_job} - * - projectLocationEndpoint: projects/{project}/locations/{location}/endpoints/{endpoint} - * - projectLocationPublisherModel: projects/{project}/locations/{location}/publishers/{publisher}/models/{model} - * - trainingPipeline: projects/{project}/locations/{location}/trainingPipelines/{training_pipeline} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'aiplatform.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Cancels a PipelineJob. - * Starts asynchronous cancellation on the PipelineJob. The server - * makes a best effort to cancel the pipeline, but success is not - * guaranteed. Clients can use - * [PipelineService.GetPipelineJob][google.cloud.aiplatform.v1.PipelineService.GetPipelineJob] - * or other methods to check whether the cancellation succeeded or whether the - * pipeline completed despite cancellation. On successful cancellation, - * the PipelineJob is not deleted; instead it becomes a pipeline with - * a [PipelineJob.error][google.cloud.aiplatform.v1.PipelineJob.error] value - * with a [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding - * to `Code.CANCELLED`, and - * [PipelineJob.state][google.cloud.aiplatform.v1.PipelineJob.state] is set to - * `CANCELLED`. - * - * The async variant is {@see self::cancelPipelineJobAsync()} . - * - * @example samples/V1/PipelineServiceClient/cancel_pipeline_job.php - * - * @param CancelPipelineJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function cancelPipelineJob(CancelPipelineJobRequest $request, array $callOptions = []): void - { - $this->startApiCall('CancelPipelineJob', $request, $callOptions)->wait(); - } - - /** - * Cancels a TrainingPipeline. - * Starts asynchronous cancellation on the TrainingPipeline. The server - * makes a best effort to cancel the pipeline, but success is not - * guaranteed. Clients can use - * [PipelineService.GetTrainingPipeline][google.cloud.aiplatform.v1.PipelineService.GetTrainingPipeline] - * or other methods to check whether the cancellation succeeded or whether the - * pipeline completed despite cancellation. On successful cancellation, - * the TrainingPipeline is not deleted; instead it becomes a pipeline with - * a - * [TrainingPipeline.error][google.cloud.aiplatform.v1.TrainingPipeline.error] - * value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, - * corresponding to `Code.CANCELLED`, and - * [TrainingPipeline.state][google.cloud.aiplatform.v1.TrainingPipeline.state] - * is set to `CANCELLED`. - * - * The async variant is {@see self::cancelTrainingPipelineAsync()} . - * - * @example samples/V1/PipelineServiceClient/cancel_training_pipeline.php - * - * @param CancelTrainingPipelineRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function cancelTrainingPipeline(CancelTrainingPipelineRequest $request, array $callOptions = []): void - { - $this->startApiCall('CancelTrainingPipeline', $request, $callOptions)->wait(); - } - - /** - * Creates a PipelineJob. A PipelineJob will run immediately when created. - * - * The async variant is {@see self::createPipelineJobAsync()} . - * - * @example samples/V1/PipelineServiceClient/create_pipeline_job.php - * - * @param CreatePipelineJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PipelineJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function createPipelineJob(CreatePipelineJobRequest $request, array $callOptions = []): PipelineJob - { - return $this->startApiCall('CreatePipelineJob', $request, $callOptions)->wait(); - } - - /** - * Creates a TrainingPipeline. A created TrainingPipeline right away will be - * attempted to be run. - * - * The async variant is {@see self::createTrainingPipelineAsync()} . - * - * @example samples/V1/PipelineServiceClient/create_training_pipeline.php - * - * @param CreateTrainingPipelineRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TrainingPipeline - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTrainingPipeline(CreateTrainingPipelineRequest $request, array $callOptions = []): TrainingPipeline - { - return $this->startApiCall('CreateTrainingPipeline', $request, $callOptions)->wait(); - } - - /** - * Deletes a PipelineJob. - * - * The async variant is {@see self::deletePipelineJobAsync()} . - * - * @example samples/V1/PipelineServiceClient/delete_pipeline_job.php - * - * @param DeletePipelineJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deletePipelineJob(DeletePipelineJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeletePipelineJob', $request, $callOptions)->wait(); - } - - /** - * Deletes a TrainingPipeline. - * - * The async variant is {@see self::deleteTrainingPipelineAsync()} . - * - * @example samples/V1/PipelineServiceClient/delete_training_pipeline.php - * - * @param DeleteTrainingPipelineRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTrainingPipeline(DeleteTrainingPipelineRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteTrainingPipeline', $request, $callOptions)->wait(); - } - - /** - * Gets a PipelineJob. - * - * The async variant is {@see self::getPipelineJobAsync()} . - * - * @example samples/V1/PipelineServiceClient/get_pipeline_job.php - * - * @param GetPipelineJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PipelineJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function getPipelineJob(GetPipelineJobRequest $request, array $callOptions = []): PipelineJob - { - return $this->startApiCall('GetPipelineJob', $request, $callOptions)->wait(); - } - - /** - * Gets a TrainingPipeline. - * - * The async variant is {@see self::getTrainingPipelineAsync()} . - * - * @example samples/V1/PipelineServiceClient/get_training_pipeline.php - * - * @param GetTrainingPipelineRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TrainingPipeline - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTrainingPipeline(GetTrainingPipelineRequest $request, array $callOptions = []): TrainingPipeline - { - return $this->startApiCall('GetTrainingPipeline', $request, $callOptions)->wait(); - } - - /** - * Lists PipelineJobs in a Location. - * - * The async variant is {@see self::listPipelineJobsAsync()} . - * - * @example samples/V1/PipelineServiceClient/list_pipeline_jobs.php - * - * @param ListPipelineJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPipelineJobs(ListPipelineJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPipelineJobs', $request, $callOptions); - } - - /** - * Lists TrainingPipelines in a Location. - * - * The async variant is {@see self::listTrainingPipelinesAsync()} . - * - * @example samples/V1/PipelineServiceClient/list_training_pipelines.php - * - * @param ListTrainingPipelinesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTrainingPipelines(ListTrainingPipelinesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTrainingPipelines', $request, $callOptions); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/PipelineServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/PipelineServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/PipelineServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/PipelineServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/PipelineServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/AiPlatform/src/V1/Client/BaseClient/PredictionServiceBaseClient.php b/AiPlatform/src/V1/Client/BaseClient/PredictionServiceBaseClient.php deleted file mode 100644 index c9a40a852dfe..000000000000 --- a/AiPlatform/src/V1/Client/BaseClient/PredictionServiceBaseClient.php +++ /dev/null @@ -1,540 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/prediction_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/prediction_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/prediction_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/prediction_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a endpoint - * resource. - * - * @param string $project - * @param string $location - * @param string $endpoint - * - * @return string The formatted endpoint resource. - */ - public static function endpointName(string $project, string $location, string $endpoint): string - { - return self::getPathTemplate('endpoint')->render([ - 'project' => $project, - 'location' => $location, - 'endpoint' => $endpoint, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_endpoint resource. - * - * @param string $project - * @param string $location - * @param string $endpoint - * - * @return string The formatted project_location_endpoint resource. - */ - public static function projectLocationEndpointName(string $project, string $location, string $endpoint): string - { - return self::getPathTemplate('projectLocationEndpoint')->render([ - 'project' => $project, - 'location' => $location, - 'endpoint' => $endpoint, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_publisher_model resource. - * - * @param string $project - * @param string $location - * @param string $publisher - * @param string $model - * - * @return string The formatted project_location_publisher_model resource. - */ - public static function projectLocationPublisherModelName(string $project, string $location, string $publisher, string $model): string - { - return self::getPathTemplate('projectLocationPublisherModel')->render([ - 'project' => $project, - 'location' => $location, - 'publisher' => $publisher, - 'model' => $model, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - endpoint: projects/{project}/locations/{location}/endpoints/{endpoint} - * - projectLocationEndpoint: projects/{project}/locations/{location}/endpoints/{endpoint} - * - projectLocationPublisherModel: projects/{project}/locations/{location}/publishers/{publisher}/models/{model} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'aiplatform.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Perform an online explanation. - * - * If - * [deployed_model_id][google.cloud.aiplatform.v1.ExplainRequest.deployed_model_id] - * is specified, the corresponding DeployModel must have - * [explanation_spec][google.cloud.aiplatform.v1.DeployedModel.explanation_spec] - * populated. If - * [deployed_model_id][google.cloud.aiplatform.v1.ExplainRequest.deployed_model_id] - * is not specified, all DeployedModels must have - * [explanation_spec][google.cloud.aiplatform.v1.DeployedModel.explanation_spec] - * populated. - * - * The async variant is {@see self::explainAsync()} . - * - * @example samples/V1/PredictionServiceClient/explain.php - * - * @param ExplainRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ExplainResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function explain(ExplainRequest $request, array $callOptions = []): ExplainResponse - { - return $this->startApiCall('Explain', $request, $callOptions)->wait(); - } - - /** - * Perform an online prediction. - * - * The async variant is {@see self::predictAsync()} . - * - * @example samples/V1/PredictionServiceClient/predict.php - * - * @param PredictRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PredictResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function predict(PredictRequest $request, array $callOptions = []): PredictResponse - { - return $this->startApiCall('Predict', $request, $callOptions)->wait(); - } - - /** - * Perform an online prediction with an arbitrary HTTP payload. - * - * The response includes the following HTTP headers: - * - * * `X-Vertex-AI-Endpoint-Id`: ID of the - * [Endpoint][google.cloud.aiplatform.v1.Endpoint] that served this - * prediction. - * - * * `X-Vertex-AI-Deployed-Model-Id`: ID of the Endpoint's - * [DeployedModel][google.cloud.aiplatform.v1.DeployedModel] that served this - * prediction. - * - * The async variant is {@see self::rawPredictAsync()} . - * - * @example samples/V1/PredictionServiceClient/raw_predict.php - * - * @param RawPredictRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 HttpBody - * - * @throws ApiException Thrown if the API call fails. - */ - public function rawPredict(RawPredictRequest $request, array $callOptions = []): HttpBody - { - return $this->startApiCall('RawPredict', $request, $callOptions)->wait(); - } - - /** - * Perform a server-side streaming online prediction request for Vertex - * LLM streaming. - * - * @example samples/V1/PredictionServiceClient/server_streaming_predict.php - * - * @param StreamingPredictRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return ServerStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function serverStreamingPredict(StreamingPredictRequest $request, array $callOptions = []): ServerStream - { - return $this->startApiCall('ServerStreamingPredict', $request, $callOptions); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/PredictionServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/PredictionServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/PredictionServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/PredictionServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/PredictionServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/AiPlatform/src/V1/Client/BaseClient/ScheduleServiceBaseClient.php b/AiPlatform/src/V1/Client/BaseClient/ScheduleServiceBaseClient.php deleted file mode 100644 index 3a59d3644717..000000000000 --- a/AiPlatform/src/V1/Client/BaseClient/ScheduleServiceBaseClient.php +++ /dev/null @@ -1,772 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/schedule_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/schedule_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/schedule_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/schedule_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a artifact - * resource. - * - * @param string $project - * @param string $location - * @param string $metadataStore - * @param string $artifact - * - * @return string The formatted artifact resource. - */ - public static function artifactName(string $project, string $location, string $metadataStore, string $artifact): string - { - return self::getPathTemplate('artifact')->render([ - 'project' => $project, - 'location' => $location, - 'metadata_store' => $metadataStore, - 'artifact' => $artifact, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a context - * resource. - * - * @param string $project - * @param string $location - * @param string $metadataStore - * @param string $context - * - * @return string The formatted context resource. - */ - public static function contextName(string $project, string $location, string $metadataStore, string $context): string - { - return self::getPathTemplate('context')->render([ - 'project' => $project, - 'location' => $location, - 'metadata_store' => $metadataStore, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a custom_job - * resource. - * - * @param string $project - * @param string $location - * @param string $customJob - * - * @return string The formatted custom_job resource. - */ - public static function customJobName(string $project, string $location, string $customJob): string - { - return self::getPathTemplate('customJob')->render([ - 'project' => $project, - 'location' => $location, - 'custom_job' => $customJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a execution - * resource. - * - * @param string $project - * @param string $location - * @param string $metadataStore - * @param string $execution - * - * @return string The formatted execution resource. - */ - public static function executionName(string $project, string $location, string $metadataStore, string $execution): string - { - return self::getPathTemplate('execution')->render([ - 'project' => $project, - 'location' => $location, - 'metadata_store' => $metadataStore, - 'execution' => $execution, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * metadata_store resource. - * - * @param string $project - * @param string $location - * @param string $metadataStore - * - * @return string The formatted metadata_store resource. - */ - public static function metadataStoreName(string $project, string $location, string $metadataStore): string - { - return self::getPathTemplate('metadataStore')->render([ - 'project' => $project, - 'location' => $location, - 'metadata_store' => $metadataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a network - * resource. - * - * @param string $project - * @param string $network - * - * @return string The formatted network resource. - */ - public static function networkName(string $project, string $network): string - { - return self::getPathTemplate('network')->render([ - 'project' => $project, - 'network' => $network, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a pipeline_job - * resource. - * - * @param string $project - * @param string $location - * @param string $pipelineJob - * - * @return string The formatted pipeline_job resource. - */ - public static function pipelineJobName(string $project, string $location, string $pipelineJob): string - { - return self::getPathTemplate('pipelineJob')->render([ - 'project' => $project, - 'location' => $location, - 'pipeline_job' => $pipelineJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a schedule - * resource. - * - * @param string $project - * @param string $location - * @param string $schedule - * - * @return string The formatted schedule resource. - */ - public static function scheduleName(string $project, string $location, string $schedule): string - { - return self::getPathTemplate('schedule')->render([ - 'project' => $project, - 'location' => $location, - 'schedule' => $schedule, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - artifact: projects/{project}/locations/{location}/metadataStores/{metadata_store}/artifacts/{artifact} - * - context: projects/{project}/locations/{location}/metadataStores/{metadata_store}/contexts/{context} - * - customJob: projects/{project}/locations/{location}/customJobs/{custom_job} - * - execution: projects/{project}/locations/{location}/metadataStores/{metadata_store}/executions/{execution} - * - location: projects/{project}/locations/{location} - * - metadataStore: projects/{project}/locations/{location}/metadataStores/{metadata_store} - * - network: projects/{project}/global/networks/{network} - * - pipelineJob: projects/{project}/locations/{location}/pipelineJobs/{pipeline_job} - * - schedule: projects/{project}/locations/{location}/schedules/{schedule} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'aiplatform.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a Schedule. - * - * The async variant is {@see self::createScheduleAsync()} . - * - * @example samples/V1/ScheduleServiceClient/create_schedule.php - * - * @param CreateScheduleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Schedule - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSchedule(CreateScheduleRequest $request, array $callOptions = []): Schedule - { - return $this->startApiCall('CreateSchedule', $request, $callOptions)->wait(); - } - - /** - * Deletes a Schedule. - * - * The async variant is {@see self::deleteScheduleAsync()} . - * - * @example samples/V1/ScheduleServiceClient/delete_schedule.php - * - * @param DeleteScheduleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSchedule(DeleteScheduleRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteSchedule', $request, $callOptions)->wait(); - } - - /** - * Gets a Schedule. - * - * The async variant is {@see self::getScheduleAsync()} . - * - * @example samples/V1/ScheduleServiceClient/get_schedule.php - * - * @param GetScheduleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Schedule - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSchedule(GetScheduleRequest $request, array $callOptions = []): Schedule - { - return $this->startApiCall('GetSchedule', $request, $callOptions)->wait(); - } - - /** - * Lists Schedules in a Location. - * - * The async variant is {@see self::listSchedulesAsync()} . - * - * @example samples/V1/ScheduleServiceClient/list_schedules.php - * - * @param ListSchedulesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSchedules(ListSchedulesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSchedules', $request, $callOptions); - } - - /** - * Pauses a Schedule. Will mark - * [Schedule.state][google.cloud.aiplatform.v1.Schedule.state] to 'PAUSED'. If - * the schedule is paused, no new runs will be created. Already created runs - * will NOT be paused or canceled. - * - * The async variant is {@see self::pauseScheduleAsync()} . - * - * @example samples/V1/ScheduleServiceClient/pause_schedule.php - * - * @param PauseScheduleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function pauseSchedule(PauseScheduleRequest $request, array $callOptions = []): void - { - $this->startApiCall('PauseSchedule', $request, $callOptions)->wait(); - } - - /** - * Resumes a paused Schedule to start scheduling new runs. Will mark - * [Schedule.state][google.cloud.aiplatform.v1.Schedule.state] to 'ACTIVE'. - * Only paused Schedule can be resumed. - * - * When the Schedule is resumed, new runs will be scheduled starting from the - * next execution time after the current time based on the time_specification - * in the Schedule. If [Schedule.catchUp][] is set up true, all - * missed runs will be scheduled for backfill first. - * - * The async variant is {@see self::resumeScheduleAsync()} . - * - * @example samples/V1/ScheduleServiceClient/resume_schedule.php - * - * @param ResumeScheduleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function resumeSchedule(ResumeScheduleRequest $request, array $callOptions = []): void - { - $this->startApiCall('ResumeSchedule', $request, $callOptions)->wait(); - } - - /** - * Updates an active or paused Schedule. - * - * When the Schedule is updated, new runs will be scheduled starting from the - * updated next execution time after the update time based on the - * time_specification in the updated Schedule. All unstarted runs before the - * update time will be skipped while already created runs will NOT be paused - * or canceled. - * - * The async variant is {@see self::updateScheduleAsync()} . - * - * @example samples/V1/ScheduleServiceClient/update_schedule.php - * - * @param UpdateScheduleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Schedule - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSchedule(UpdateScheduleRequest $request, array $callOptions = []): Schedule - { - return $this->startApiCall('UpdateSchedule', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/ScheduleServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/ScheduleServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/ScheduleServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/ScheduleServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/ScheduleServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/AiPlatform/src/V1/Client/BaseClient/SpecialistPoolServiceBaseClient.php b/AiPlatform/src/V1/Client/BaseClient/SpecialistPoolServiceBaseClient.php deleted file mode 100644 index 0881e2ff57be..000000000000 --- a/AiPlatform/src/V1/Client/BaseClient/SpecialistPoolServiceBaseClient.php +++ /dev/null @@ -1,565 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/specialist_pool_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/specialist_pool_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/specialist_pool_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/specialist_pool_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * specialist_pool resource. - * - * @param string $project - * @param string $location - * @param string $specialistPool - * - * @return string The formatted specialist_pool resource. - */ - public static function specialistPoolName(string $project, string $location, string $specialistPool): string - { - return self::getPathTemplate('specialistPool')->render([ - 'project' => $project, - 'location' => $location, - 'specialist_pool' => $specialistPool, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - location: projects/{project}/locations/{location} - * - specialistPool: projects/{project}/locations/{location}/specialistPools/{specialist_pool} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'aiplatform.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a SpecialistPool. - * - * The async variant is {@see self::createSpecialistPoolAsync()} . - * - * @example samples/V1/SpecialistPoolServiceClient/create_specialist_pool.php - * - * @param CreateSpecialistPoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSpecialistPool(CreateSpecialistPoolRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateSpecialistPool', $request, $callOptions)->wait(); - } - - /** - * Deletes a SpecialistPool as well as all Specialists in the pool. - * - * The async variant is {@see self::deleteSpecialistPoolAsync()} . - * - * @example samples/V1/SpecialistPoolServiceClient/delete_specialist_pool.php - * - * @param DeleteSpecialistPoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSpecialistPool(DeleteSpecialistPoolRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteSpecialistPool', $request, $callOptions)->wait(); - } - - /** - * Gets a SpecialistPool. - * - * The async variant is {@see self::getSpecialistPoolAsync()} . - * - * @example samples/V1/SpecialistPoolServiceClient/get_specialist_pool.php - * - * @param GetSpecialistPoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SpecialistPool - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSpecialistPool(GetSpecialistPoolRequest $request, array $callOptions = []): SpecialistPool - { - return $this->startApiCall('GetSpecialistPool', $request, $callOptions)->wait(); - } - - /** - * Lists SpecialistPools in a Location. - * - * The async variant is {@see self::listSpecialistPoolsAsync()} . - * - * @example samples/V1/SpecialistPoolServiceClient/list_specialist_pools.php - * - * @param ListSpecialistPoolsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSpecialistPools(ListSpecialistPoolsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSpecialistPools', $request, $callOptions); - } - - /** - * Updates a SpecialistPool. - * - * The async variant is {@see self::updateSpecialistPoolAsync()} . - * - * @example samples/V1/SpecialistPoolServiceClient/update_specialist_pool.php - * - * @param UpdateSpecialistPoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSpecialistPool(UpdateSpecialistPoolRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateSpecialistPool', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/SpecialistPoolServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/SpecialistPoolServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/SpecialistPoolServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/SpecialistPoolServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/SpecialistPoolServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/AiPlatform/src/V1/Client/BaseClient/TensorboardServiceBaseClient.php b/AiPlatform/src/V1/Client/BaseClient/TensorboardServiceBaseClient.php deleted file mode 100644 index 5f6d8d95fed9..000000000000 --- a/AiPlatform/src/V1/Client/BaseClient/TensorboardServiceBaseClient.php +++ /dev/null @@ -1,1354 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/tensorboard_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/tensorboard_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/tensorboard_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/tensorboard_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a tensorboard - * resource. - * - * @param string $project - * @param string $location - * @param string $tensorboard - * - * @return string The formatted tensorboard resource. - */ - public static function tensorboardName(string $project, string $location, string $tensorboard): string - { - return self::getPathTemplate('tensorboard')->render([ - 'project' => $project, - 'location' => $location, - 'tensorboard' => $tensorboard, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * tensorboard_experiment resource. - * - * @param string $project - * @param string $location - * @param string $tensorboard - * @param string $experiment - * - * @return string The formatted tensorboard_experiment resource. - */ - public static function tensorboardExperimentName(string $project, string $location, string $tensorboard, string $experiment): string - { - return self::getPathTemplate('tensorboardExperiment')->render([ - 'project' => $project, - 'location' => $location, - 'tensorboard' => $tensorboard, - 'experiment' => $experiment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * tensorboard_run resource. - * - * @param string $project - * @param string $location - * @param string $tensorboard - * @param string $experiment - * @param string $run - * - * @return string The formatted tensorboard_run resource. - */ - public static function tensorboardRunName(string $project, string $location, string $tensorboard, string $experiment, string $run): string - { - return self::getPathTemplate('tensorboardRun')->render([ - 'project' => $project, - 'location' => $location, - 'tensorboard' => $tensorboard, - 'experiment' => $experiment, - 'run' => $run, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * tensorboard_time_series resource. - * - * @param string $project - * @param string $location - * @param string $tensorboard - * @param string $experiment - * @param string $run - * @param string $timeSeries - * - * @return string The formatted tensorboard_time_series resource. - */ - public static function tensorboardTimeSeriesName(string $project, string $location, string $tensorboard, string $experiment, string $run, string $timeSeries): string - { - return self::getPathTemplate('tensorboardTimeSeries')->render([ - 'project' => $project, - 'location' => $location, - 'tensorboard' => $tensorboard, - 'experiment' => $experiment, - 'run' => $run, - 'time_series' => $timeSeries, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - location: projects/{project}/locations/{location} - * - tensorboard: projects/{project}/locations/{location}/tensorboards/{tensorboard} - * - tensorboardExperiment: projects/{project}/locations/{location}/tensorboards/{tensorboard}/experiments/{experiment} - * - tensorboardRun: projects/{project}/locations/{location}/tensorboards/{tensorboard}/experiments/{experiment}/runs/{run} - * - tensorboardTimeSeries: projects/{project}/locations/{location}/tensorboards/{tensorboard}/experiments/{experiment}/runs/{run}/timeSeries/{time_series} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'aiplatform.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Batch create TensorboardRuns. - * - * The async variant is {@see self::batchCreateTensorboardRunsAsync()} . - * - * @example samples/V1/TensorboardServiceClient/batch_create_tensorboard_runs.php - * - * @param BatchCreateTensorboardRunsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BatchCreateTensorboardRunsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchCreateTensorboardRuns(BatchCreateTensorboardRunsRequest $request, array $callOptions = []): BatchCreateTensorboardRunsResponse - { - return $this->startApiCall('BatchCreateTensorboardRuns', $request, $callOptions)->wait(); - } - - /** - * Batch create TensorboardTimeSeries that belong to a TensorboardExperiment. - * - * The async variant is {@see self::batchCreateTensorboardTimeSeriesAsync()} . - * - * @example samples/V1/TensorboardServiceClient/batch_create_tensorboard_time_series.php - * - * @param BatchCreateTensorboardTimeSeriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BatchCreateTensorboardTimeSeriesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchCreateTensorboardTimeSeries(BatchCreateTensorboardTimeSeriesRequest $request, array $callOptions = []): BatchCreateTensorboardTimeSeriesResponse - { - return $this->startApiCall('BatchCreateTensorboardTimeSeries', $request, $callOptions)->wait(); - } - - /** - * Reads multiple TensorboardTimeSeries' data. The data point number limit is - * 1000 for scalars, 100 for tensors and blob references. If the number of - * data points stored is less than the limit, all data is returned. - * Otherwise, the number limit of data points is randomly selected from - * this time series and returned. - * - * The async variant is {@see self::batchReadTensorboardTimeSeriesDataAsync()} . - * - * @example samples/V1/TensorboardServiceClient/batch_read_tensorboard_time_series_data.php - * - * @param BatchReadTensorboardTimeSeriesDataRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BatchReadTensorboardTimeSeriesDataResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchReadTensorboardTimeSeriesData(BatchReadTensorboardTimeSeriesDataRequest $request, array $callOptions = []): BatchReadTensorboardTimeSeriesDataResponse - { - return $this->startApiCall('BatchReadTensorboardTimeSeriesData', $request, $callOptions)->wait(); - } - - /** - * Creates a Tensorboard. - * - * The async variant is {@see self::createTensorboardAsync()} . - * - * @example samples/V1/TensorboardServiceClient/create_tensorboard.php - * - * @param CreateTensorboardRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTensorboard(CreateTensorboardRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateTensorboard', $request, $callOptions)->wait(); - } - - /** - * Creates a TensorboardExperiment. - * - * The async variant is {@see self::createTensorboardExperimentAsync()} . - * - * @example samples/V1/TensorboardServiceClient/create_tensorboard_experiment.php - * - * @param CreateTensorboardExperimentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TensorboardExperiment - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTensorboardExperiment(CreateTensorboardExperimentRequest $request, array $callOptions = []): TensorboardExperiment - { - return $this->startApiCall('CreateTensorboardExperiment', $request, $callOptions)->wait(); - } - - /** - * Creates a TensorboardRun. - * - * The async variant is {@see self::createTensorboardRunAsync()} . - * - * @example samples/V1/TensorboardServiceClient/create_tensorboard_run.php - * - * @param CreateTensorboardRunRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TensorboardRun - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTensorboardRun(CreateTensorboardRunRequest $request, array $callOptions = []): TensorboardRun - { - return $this->startApiCall('CreateTensorboardRun', $request, $callOptions)->wait(); - } - - /** - * Creates a TensorboardTimeSeries. - * - * The async variant is {@see self::createTensorboardTimeSeriesAsync()} . - * - * @example samples/V1/TensorboardServiceClient/create_tensorboard_time_series.php - * - * @param CreateTensorboardTimeSeriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TensorboardTimeSeries - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTensorboardTimeSeries(CreateTensorboardTimeSeriesRequest $request, array $callOptions = []): TensorboardTimeSeries - { - return $this->startApiCall('CreateTensorboardTimeSeries', $request, $callOptions)->wait(); - } - - /** - * Deletes a Tensorboard. - * - * The async variant is {@see self::deleteTensorboardAsync()} . - * - * @example samples/V1/TensorboardServiceClient/delete_tensorboard.php - * - * @param DeleteTensorboardRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTensorboard(DeleteTensorboardRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteTensorboard', $request, $callOptions)->wait(); - } - - /** - * Deletes a TensorboardExperiment. - * - * The async variant is {@see self::deleteTensorboardExperimentAsync()} . - * - * @example samples/V1/TensorboardServiceClient/delete_tensorboard_experiment.php - * - * @param DeleteTensorboardExperimentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTensorboardExperiment(DeleteTensorboardExperimentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteTensorboardExperiment', $request, $callOptions)->wait(); - } - - /** - * Deletes a TensorboardRun. - * - * The async variant is {@see self::deleteTensorboardRunAsync()} . - * - * @example samples/V1/TensorboardServiceClient/delete_tensorboard_run.php - * - * @param DeleteTensorboardRunRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTensorboardRun(DeleteTensorboardRunRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteTensorboardRun', $request, $callOptions)->wait(); - } - - /** - * Deletes a TensorboardTimeSeries. - * - * The async variant is {@see self::deleteTensorboardTimeSeriesAsync()} . - * - * @example samples/V1/TensorboardServiceClient/delete_tensorboard_time_series.php - * - * @param DeleteTensorboardTimeSeriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTensorboardTimeSeries(DeleteTensorboardTimeSeriesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteTensorboardTimeSeries', $request, $callOptions)->wait(); - } - - /** - * Exports a TensorboardTimeSeries' data. Data is returned in paginated - * responses. - * - * The async variant is {@see self::exportTensorboardTimeSeriesDataAsync()} . - * - * @example samples/V1/TensorboardServiceClient/export_tensorboard_time_series_data.php - * - * @param ExportTensorboardTimeSeriesDataRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function exportTensorboardTimeSeriesData(ExportTensorboardTimeSeriesDataRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ExportTensorboardTimeSeriesData', $request, $callOptions); - } - - /** - * Gets a Tensorboard. - * - * The async variant is {@see self::getTensorboardAsync()} . - * - * @example samples/V1/TensorboardServiceClient/get_tensorboard.php - * - * @param GetTensorboardRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Tensorboard - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTensorboard(GetTensorboardRequest $request, array $callOptions = []): Tensorboard - { - return $this->startApiCall('GetTensorboard', $request, $callOptions)->wait(); - } - - /** - * Gets a TensorboardExperiment. - * - * The async variant is {@see self::getTensorboardExperimentAsync()} . - * - * @example samples/V1/TensorboardServiceClient/get_tensorboard_experiment.php - * - * @param GetTensorboardExperimentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TensorboardExperiment - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTensorboardExperiment(GetTensorboardExperimentRequest $request, array $callOptions = []): TensorboardExperiment - { - return $this->startApiCall('GetTensorboardExperiment', $request, $callOptions)->wait(); - } - - /** - * Gets a TensorboardRun. - * - * The async variant is {@see self::getTensorboardRunAsync()} . - * - * @example samples/V1/TensorboardServiceClient/get_tensorboard_run.php - * - * @param GetTensorboardRunRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TensorboardRun - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTensorboardRun(GetTensorboardRunRequest $request, array $callOptions = []): TensorboardRun - { - return $this->startApiCall('GetTensorboardRun', $request, $callOptions)->wait(); - } - - /** - * Gets a TensorboardTimeSeries. - * - * The async variant is {@see self::getTensorboardTimeSeriesAsync()} . - * - * @example samples/V1/TensorboardServiceClient/get_tensorboard_time_series.php - * - * @param GetTensorboardTimeSeriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TensorboardTimeSeries - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTensorboardTimeSeries(GetTensorboardTimeSeriesRequest $request, array $callOptions = []): TensorboardTimeSeries - { - return $this->startApiCall('GetTensorboardTimeSeries', $request, $callOptions)->wait(); - } - - /** - * Lists TensorboardExperiments in a Location. - * - * The async variant is {@see self::listTensorboardExperimentsAsync()} . - * - * @example samples/V1/TensorboardServiceClient/list_tensorboard_experiments.php - * - * @param ListTensorboardExperimentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTensorboardExperiments(ListTensorboardExperimentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTensorboardExperiments', $request, $callOptions); - } - - /** - * Lists TensorboardRuns in a Location. - * - * The async variant is {@see self::listTensorboardRunsAsync()} . - * - * @example samples/V1/TensorboardServiceClient/list_tensorboard_runs.php - * - * @param ListTensorboardRunsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTensorboardRuns(ListTensorboardRunsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTensorboardRuns', $request, $callOptions); - } - - /** - * Lists TensorboardTimeSeries in a Location. - * - * The async variant is {@see self::listTensorboardTimeSeriesAsync()} . - * - * @example samples/V1/TensorboardServiceClient/list_tensorboard_time_series.php - * - * @param ListTensorboardTimeSeriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTensorboardTimeSeries(ListTensorboardTimeSeriesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTensorboardTimeSeries', $request, $callOptions); - } - - /** - * Lists Tensorboards in a Location. - * - * The async variant is {@see self::listTensorboardsAsync()} . - * - * @example samples/V1/TensorboardServiceClient/list_tensorboards.php - * - * @param ListTensorboardsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTensorboards(ListTensorboardsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTensorboards', $request, $callOptions); - } - - /** - * Gets bytes of TensorboardBlobs. - * This is to allow reading blob data stored in consumer project's Cloud - * Storage bucket without users having to obtain Cloud Storage access - * permission. - * - * @example samples/V1/TensorboardServiceClient/read_tensorboard_blob_data.php - * - * @param ReadTensorboardBlobDataRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return ServerStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function readTensorboardBlobData(ReadTensorboardBlobDataRequest $request, array $callOptions = []): ServerStream - { - return $this->startApiCall('ReadTensorboardBlobData', $request, $callOptions); - } - - /** - * Returns the storage size for a given TensorBoard instance. - * - * The async variant is {@see self::readTensorboardSizeAsync()} . - * - * @example samples/V1/TensorboardServiceClient/read_tensorboard_size.php - * - * @param ReadTensorboardSizeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ReadTensorboardSizeResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function readTensorboardSize(ReadTensorboardSizeRequest $request, array $callOptions = []): ReadTensorboardSizeResponse - { - return $this->startApiCall('ReadTensorboardSize', $request, $callOptions)->wait(); - } - - /** - * Reads a TensorboardTimeSeries' data. By default, if the number of data - * points stored is less than 1000, all data is returned. Otherwise, 1000 - * data points is randomly selected from this time series and returned. - * This value can be changed by changing max_data_points, which can't be - * greater than 10k. - * - * The async variant is {@see self::readTensorboardTimeSeriesDataAsync()} . - * - * @example samples/V1/TensorboardServiceClient/read_tensorboard_time_series_data.php - * - * @param ReadTensorboardTimeSeriesDataRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ReadTensorboardTimeSeriesDataResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function readTensorboardTimeSeriesData(ReadTensorboardTimeSeriesDataRequest $request, array $callOptions = []): ReadTensorboardTimeSeriesDataResponse - { - return $this->startApiCall('ReadTensorboardTimeSeriesData', $request, $callOptions)->wait(); - } - - /** - * Returns a list of monthly active users for a given TensorBoard instance. - * - * The async variant is {@see self::readTensorboardUsageAsync()} . - * - * @example samples/V1/TensorboardServiceClient/read_tensorboard_usage.php - * - * @param ReadTensorboardUsageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ReadTensorboardUsageResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function readTensorboardUsage(ReadTensorboardUsageRequest $request, array $callOptions = []): ReadTensorboardUsageResponse - { - return $this->startApiCall('ReadTensorboardUsage', $request, $callOptions)->wait(); - } - - /** - * Updates a Tensorboard. - * - * The async variant is {@see self::updateTensorboardAsync()} . - * - * @example samples/V1/TensorboardServiceClient/update_tensorboard.php - * - * @param UpdateTensorboardRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateTensorboard(UpdateTensorboardRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateTensorboard', $request, $callOptions)->wait(); - } - - /** - * Updates a TensorboardExperiment. - * - * The async variant is {@see self::updateTensorboardExperimentAsync()} . - * - * @example samples/V1/TensorboardServiceClient/update_tensorboard_experiment.php - * - * @param UpdateTensorboardExperimentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TensorboardExperiment - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateTensorboardExperiment(UpdateTensorboardExperimentRequest $request, array $callOptions = []): TensorboardExperiment - { - return $this->startApiCall('UpdateTensorboardExperiment', $request, $callOptions)->wait(); - } - - /** - * Updates a TensorboardRun. - * - * The async variant is {@see self::updateTensorboardRunAsync()} . - * - * @example samples/V1/TensorboardServiceClient/update_tensorboard_run.php - * - * @param UpdateTensorboardRunRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TensorboardRun - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateTensorboardRun(UpdateTensorboardRunRequest $request, array $callOptions = []): TensorboardRun - { - return $this->startApiCall('UpdateTensorboardRun', $request, $callOptions)->wait(); - } - - /** - * Updates a TensorboardTimeSeries. - * - * The async variant is {@see self::updateTensorboardTimeSeriesAsync()} . - * - * @example samples/V1/TensorboardServiceClient/update_tensorboard_time_series.php - * - * @param UpdateTensorboardTimeSeriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TensorboardTimeSeries - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateTensorboardTimeSeries(UpdateTensorboardTimeSeriesRequest $request, array $callOptions = []): TensorboardTimeSeries - { - return $this->startApiCall('UpdateTensorboardTimeSeries', $request, $callOptions)->wait(); - } - - /** - * Write time series data points of multiple TensorboardTimeSeries in multiple - * TensorboardRun's. If any data fail to be ingested, an error is returned. - * - * The async variant is {@see self::writeTensorboardExperimentDataAsync()} . - * - * @example samples/V1/TensorboardServiceClient/write_tensorboard_experiment_data.php - * - * @param WriteTensorboardExperimentDataRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 WriteTensorboardExperimentDataResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function writeTensorboardExperimentData(WriteTensorboardExperimentDataRequest $request, array $callOptions = []): WriteTensorboardExperimentDataResponse - { - return $this->startApiCall('WriteTensorboardExperimentData', $request, $callOptions)->wait(); - } - - /** - * Write time series data points into multiple TensorboardTimeSeries under - * a TensorboardRun. If any data fail to be ingested, an error is returned. - * - * The async variant is {@see self::writeTensorboardRunDataAsync()} . - * - * @example samples/V1/TensorboardServiceClient/write_tensorboard_run_data.php - * - * @param WriteTensorboardRunDataRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 WriteTensorboardRunDataResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function writeTensorboardRunData(WriteTensorboardRunDataRequest $request, array $callOptions = []): WriteTensorboardRunDataResponse - { - return $this->startApiCall('WriteTensorboardRunData', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/TensorboardServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/TensorboardServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/TensorboardServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/TensorboardServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/TensorboardServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/AiPlatform/src/V1/Client/BaseClient/VizierServiceBaseClient.php b/AiPlatform/src/V1/Client/BaseClient/VizierServiceBaseClient.php deleted file mode 100644 index 90ad21c44bd6..000000000000 --- a/AiPlatform/src/V1/Client/BaseClient/VizierServiceBaseClient.php +++ /dev/null @@ -1,899 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/vizier_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/vizier_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/vizier_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/vizier_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a custom_job - * resource. - * - * @param string $project - * @param string $location - * @param string $customJob - * - * @return string The formatted custom_job resource. - */ - public static function customJobName(string $project, string $location, string $customJob): string - { - return self::getPathTemplate('customJob')->render([ - 'project' => $project, - 'location' => $location, - 'custom_job' => $customJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a study - * resource. - * - * @param string $project - * @param string $location - * @param string $study - * - * @return string The formatted study resource. - */ - public static function studyName(string $project, string $location, string $study): string - { - return self::getPathTemplate('study')->render([ - 'project' => $project, - 'location' => $location, - 'study' => $study, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a trial - * resource. - * - * @param string $project - * @param string $location - * @param string $study - * @param string $trial - * - * @return string The formatted trial resource. - */ - public static function trialName(string $project, string $location, string $study, string $trial): string - { - return self::getPathTemplate('trial')->render([ - 'project' => $project, - 'location' => $location, - 'study' => $study, - 'trial' => $trial, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - customJob: projects/{project}/locations/{location}/customJobs/{custom_job} - * - location: projects/{project}/locations/{location} - * - study: projects/{project}/locations/{location}/studies/{study} - * - trial: projects/{project}/locations/{location}/studies/{study}/trials/{trial} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'aiplatform.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Adds a measurement of the objective metrics to a Trial. This measurement - * is assumed to have been taken before the Trial is complete. - * - * The async variant is {@see self::addTrialMeasurementAsync()} . - * - * @example samples/V1/VizierServiceClient/add_trial_measurement.php - * - * @param AddTrialMeasurementRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Trial - * - * @throws ApiException Thrown if the API call fails. - */ - public function addTrialMeasurement(AddTrialMeasurementRequest $request, array $callOptions = []): Trial - { - return $this->startApiCall('AddTrialMeasurement', $request, $callOptions)->wait(); - } - - /** - * Checks whether a Trial should stop or not. Returns a - * long-running operation. When the operation is successful, - * it will contain a - * [CheckTrialEarlyStoppingStateResponse][google.cloud.aiplatform.v1.CheckTrialEarlyStoppingStateResponse]. - * - * The async variant is {@see self::checkTrialEarlyStoppingStateAsync()} . - * - * @example samples/V1/VizierServiceClient/check_trial_early_stopping_state.php - * - * @param CheckTrialEarlyStoppingStateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function checkTrialEarlyStoppingState(CheckTrialEarlyStoppingStateRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CheckTrialEarlyStoppingState', $request, $callOptions)->wait(); - } - - /** - * Marks a Trial as complete. - * - * The async variant is {@see self::completeTrialAsync()} . - * - * @example samples/V1/VizierServiceClient/complete_trial.php - * - * @param CompleteTrialRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Trial - * - * @throws ApiException Thrown if the API call fails. - */ - public function completeTrial(CompleteTrialRequest $request, array $callOptions = []): Trial - { - return $this->startApiCall('CompleteTrial', $request, $callOptions)->wait(); - } - - /** - * Creates a Study. A resource name will be generated after creation of the - * Study. - * - * The async variant is {@see self::createStudyAsync()} . - * - * @example samples/V1/VizierServiceClient/create_study.php - * - * @param CreateStudyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Study - * - * @throws ApiException Thrown if the API call fails. - */ - public function createStudy(CreateStudyRequest $request, array $callOptions = []): Study - { - return $this->startApiCall('CreateStudy', $request, $callOptions)->wait(); - } - - /** - * Adds a user provided Trial to a Study. - * - * The async variant is {@see self::createTrialAsync()} . - * - * @example samples/V1/VizierServiceClient/create_trial.php - * - * @param CreateTrialRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Trial - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTrial(CreateTrialRequest $request, array $callOptions = []): Trial - { - return $this->startApiCall('CreateTrial', $request, $callOptions)->wait(); - } - - /** - * Deletes a Study. - * - * The async variant is {@see self::deleteStudyAsync()} . - * - * @example samples/V1/VizierServiceClient/delete_study.php - * - * @param DeleteStudyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteStudy(DeleteStudyRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteStudy', $request, $callOptions)->wait(); - } - - /** - * Deletes a Trial. - * - * The async variant is {@see self::deleteTrialAsync()} . - * - * @example samples/V1/VizierServiceClient/delete_trial.php - * - * @param DeleteTrialRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTrial(DeleteTrialRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteTrial', $request, $callOptions)->wait(); - } - - /** - * Gets a Study by name. - * - * The async variant is {@see self::getStudyAsync()} . - * - * @example samples/V1/VizierServiceClient/get_study.php - * - * @param GetStudyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Study - * - * @throws ApiException Thrown if the API call fails. - */ - public function getStudy(GetStudyRequest $request, array $callOptions = []): Study - { - return $this->startApiCall('GetStudy', $request, $callOptions)->wait(); - } - - /** - * Gets a Trial. - * - * The async variant is {@see self::getTrialAsync()} . - * - * @example samples/V1/VizierServiceClient/get_trial.php - * - * @param GetTrialRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Trial - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTrial(GetTrialRequest $request, array $callOptions = []): Trial - { - return $this->startApiCall('GetTrial', $request, $callOptions)->wait(); - } - - /** - * Lists the pareto-optimal Trials for multi-objective Study or the - * optimal Trials for single-objective Study. The definition of - * pareto-optimal can be checked in wiki page. - * https://en.wikipedia.org/wiki/Pareto_efficiency - * - * The async variant is {@see self::listOptimalTrialsAsync()} . - * - * @example samples/V1/VizierServiceClient/list_optimal_trials.php - * - * @param ListOptimalTrialsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ListOptimalTrialsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listOptimalTrials(ListOptimalTrialsRequest $request, array $callOptions = []): ListOptimalTrialsResponse - { - return $this->startApiCall('ListOptimalTrials', $request, $callOptions)->wait(); - } - - /** - * Lists all the studies in a region for an associated project. - * - * The async variant is {@see self::listStudiesAsync()} . - * - * @example samples/V1/VizierServiceClient/list_studies.php - * - * @param ListStudiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listStudies(ListStudiesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListStudies', $request, $callOptions); - } - - /** - * Lists the Trials associated with a Study. - * - * The async variant is {@see self::listTrialsAsync()} . - * - * @example samples/V1/VizierServiceClient/list_trials.php - * - * @param ListTrialsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTrials(ListTrialsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTrials', $request, $callOptions); - } - - /** - * Looks a study up using the user-defined display_name field instead of the - * fully qualified resource name. - * - * The async variant is {@see self::lookupStudyAsync()} . - * - * @example samples/V1/VizierServiceClient/lookup_study.php - * - * @param LookupStudyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Study - * - * @throws ApiException Thrown if the API call fails. - */ - public function lookupStudy(LookupStudyRequest $request, array $callOptions = []): Study - { - return $this->startApiCall('LookupStudy', $request, $callOptions)->wait(); - } - - /** - * Stops a Trial. - * - * The async variant is {@see self::stopTrialAsync()} . - * - * @example samples/V1/VizierServiceClient/stop_trial.php - * - * @param StopTrialRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Trial - * - * @throws ApiException Thrown if the API call fails. - */ - public function stopTrial(StopTrialRequest $request, array $callOptions = []): Trial - { - return $this->startApiCall('StopTrial', $request, $callOptions)->wait(); - } - - /** - * Adds one or more Trials to a Study, with parameter values - * suggested by Vertex AI Vizier. Returns a long-running - * operation associated with the generation of Trial suggestions. - * When this long-running operation succeeds, it will contain - * a - * [SuggestTrialsResponse][google.cloud.aiplatform.v1.SuggestTrialsResponse]. - * - * The async variant is {@see self::suggestTrialsAsync()} . - * - * @example samples/V1/VizierServiceClient/suggest_trials.php - * - * @param SuggestTrialsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function suggestTrials(SuggestTrialsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SuggestTrials', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/VizierServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/VizierServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/VizierServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/VizierServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/VizierServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/AiPlatform/src/V1/Client/DatasetServiceClient.php b/AiPlatform/src/V1/Client/DatasetServiceClient.php index da12fe504f6e..f122648e2a38 100644 --- a/AiPlatform/src/V1/Client/DatasetServiceClient.php +++ b/AiPlatform/src/V1/Client/DatasetServiceClient.php @@ -24,17 +24,988 @@ namespace Google\Cloud\AIPlatform\V1\Client; -use Google\Cloud\AIPlatform\V1\Client\BaseClient\DatasetServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AIPlatform\V1\AnnotationSpec; +use Google\Cloud\AIPlatform\V1\CreateDatasetRequest; +use Google\Cloud\AIPlatform\V1\CreateDatasetVersionRequest; +use Google\Cloud\AIPlatform\V1\Dataset; +use Google\Cloud\AIPlatform\V1\DatasetVersion; +use Google\Cloud\AIPlatform\V1\DeleteDatasetRequest; +use Google\Cloud\AIPlatform\V1\DeleteDatasetVersionRequest; +use Google\Cloud\AIPlatform\V1\DeleteSavedQueryRequest; +use Google\Cloud\AIPlatform\V1\ExportDataRequest; +use Google\Cloud\AIPlatform\V1\GetAnnotationSpecRequest; +use Google\Cloud\AIPlatform\V1\GetDatasetRequest; +use Google\Cloud\AIPlatform\V1\GetDatasetVersionRequest; +use Google\Cloud\AIPlatform\V1\ImportDataRequest; +use Google\Cloud\AIPlatform\V1\ListAnnotationsRequest; +use Google\Cloud\AIPlatform\V1\ListDataItemsRequest; +use Google\Cloud\AIPlatform\V1\ListDatasetVersionsRequest; +use Google\Cloud\AIPlatform\V1\ListDatasetsRequest; +use Google\Cloud\AIPlatform\V1\ListSavedQueriesRequest; +use Google\Cloud\AIPlatform\V1\RestoreDatasetVersionRequest; +use Google\Cloud\AIPlatform\V1\SearchDataItemsRequest; +use Google\Cloud\AIPlatform\V1\UpdateDatasetRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The service that manages Vertex AI Dataset and its child resources. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AIPlatform\V1\DatasetServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createDatasetAsync(CreateDatasetRequest $request, array $optionalArgs = []) + * @method PromiseInterface createDatasetVersionAsync(CreateDatasetVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDatasetAsync(DeleteDatasetRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDatasetVersionAsync(DeleteDatasetVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSavedQueryAsync(DeleteSavedQueryRequest $request, array $optionalArgs = []) + * @method PromiseInterface exportDataAsync(ExportDataRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAnnotationSpecAsync(GetAnnotationSpecRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDatasetAsync(GetDatasetRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDatasetVersionAsync(GetDatasetVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface importDataAsync(ImportDataRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAnnotationsAsync(ListAnnotationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDataItemsAsync(ListDataItemsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDatasetVersionsAsync(ListDatasetVersionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDatasetsAsync(ListDatasetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSavedQueriesAsync(ListSavedQueriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface restoreDatasetVersionAsync(RestoreDatasetVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchDataItemsAsync(SearchDataItemsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDatasetAsync(UpdateDatasetRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class DatasetServiceClient extends DatasetServiceBaseClient +final class DatasetServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DatasetServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.aiplatform.v1.DatasetService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'aiplatform.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/dataset_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/dataset_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/dataset_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/dataset_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * annotation_spec resource. + * + * @param string $project + * @param string $location + * @param string $dataset + * @param string $annotationSpec + * + * @return string The formatted annotation_spec resource. + */ + public static function annotationSpecName(string $project, string $location, string $dataset, string $annotationSpec): string + { + return self::getPathTemplate('annotationSpec')->render([ + 'project' => $project, + 'location' => $location, + 'dataset' => $dataset, + 'annotation_spec' => $annotationSpec, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a data_item + * resource. + * + * @param string $project + * @param string $location + * @param string $dataset + * @param string $dataItem + * + * @return string The formatted data_item resource. + */ + public static function dataItemName(string $project, string $location, string $dataset, string $dataItem): string + { + return self::getPathTemplate('dataItem')->render([ + 'project' => $project, + 'location' => $location, + 'dataset' => $dataset, + 'data_item' => $dataItem, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a dataset + * resource. + * + * @param string $project + * @param string $location + * @param string $dataset + * + * @return string The formatted dataset resource. + */ + public static function datasetName(string $project, string $location, string $dataset): string + { + return self::getPathTemplate('dataset')->render([ + 'project' => $project, + 'location' => $location, + 'dataset' => $dataset, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * dataset_version resource. + * + * @param string $project + * @param string $location + * @param string $dataset + * @param string $datasetVersion + * + * @return string The formatted dataset_version resource. + */ + public static function datasetVersionName(string $project, string $location, string $dataset, string $datasetVersion): string + { + return self::getPathTemplate('datasetVersion')->render([ + 'project' => $project, + 'location' => $location, + 'dataset' => $dataset, + 'dataset_version' => $datasetVersion, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a saved_query + * resource. + * + * @param string $project + * @param string $location + * @param string $dataset + * @param string $savedQuery + * + * @return string The formatted saved_query resource. + */ + public static function savedQueryName(string $project, string $location, string $dataset, string $savedQuery): string + { + return self::getPathTemplate('savedQuery')->render([ + 'project' => $project, + 'location' => $location, + 'dataset' => $dataset, + 'saved_query' => $savedQuery, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - annotationSpec: projects/{project}/locations/{location}/datasets/{dataset}/annotationSpecs/{annotation_spec} + * - dataItem: projects/{project}/locations/{location}/datasets/{dataset}/dataItems/{data_item} + * - dataset: projects/{project}/locations/{location}/datasets/{dataset} + * - datasetVersion: projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version} + * - location: projects/{project}/locations/{location} + * - savedQuery: projects/{project}/locations/{location}/datasets/{dataset}/savedQueries/{saved_query} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'aiplatform.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a Dataset. + * + * The async variant is {@see DatasetServiceClient::createDatasetAsync()} . + * + * @example samples/V1/DatasetServiceClient/create_dataset.php + * + * @param CreateDatasetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDataset(CreateDatasetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateDataset', $request, $callOptions)->wait(); + } + + /** + * Create a version from a Dataset. + * + * The async variant is {@see DatasetServiceClient::createDatasetVersionAsync()} . + * + * @example samples/V1/DatasetServiceClient/create_dataset_version.php + * + * @param CreateDatasetVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDatasetVersion(CreateDatasetVersionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateDatasetVersion', $request, $callOptions)->wait(); + } + + /** + * Deletes a Dataset. + * + * The async variant is {@see DatasetServiceClient::deleteDatasetAsync()} . + * + * @example samples/V1/DatasetServiceClient/delete_dataset.php + * + * @param DeleteDatasetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDataset(DeleteDatasetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteDataset', $request, $callOptions)->wait(); + } + + /** + * Deletes a Dataset version. + * + * The async variant is {@see DatasetServiceClient::deleteDatasetVersionAsync()} . + * + * @example samples/V1/DatasetServiceClient/delete_dataset_version.php + * + * @param DeleteDatasetVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDatasetVersion(DeleteDatasetVersionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteDatasetVersion', $request, $callOptions)->wait(); + } + + /** + * Deletes a SavedQuery. + * + * The async variant is {@see DatasetServiceClient::deleteSavedQueryAsync()} . + * + * @example samples/V1/DatasetServiceClient/delete_saved_query.php + * + * @param DeleteSavedQueryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSavedQuery(DeleteSavedQueryRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteSavedQuery', $request, $callOptions)->wait(); + } + + /** + * Exports data from a Dataset. + * + * The async variant is {@see DatasetServiceClient::exportDataAsync()} . + * + * @example samples/V1/DatasetServiceClient/export_data.php + * + * @param ExportDataRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportData(ExportDataRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ExportData', $request, $callOptions)->wait(); + } + + /** + * Gets an AnnotationSpec. + * + * The async variant is {@see DatasetServiceClient::getAnnotationSpecAsync()} . + * + * @example samples/V1/DatasetServiceClient/get_annotation_spec.php + * + * @param GetAnnotationSpecRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AnnotationSpec + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAnnotationSpec(GetAnnotationSpecRequest $request, array $callOptions = []): AnnotationSpec + { + return $this->startApiCall('GetAnnotationSpec', $request, $callOptions)->wait(); + } + + /** + * Gets a Dataset. + * + * The async variant is {@see DatasetServiceClient::getDatasetAsync()} . + * + * @example samples/V1/DatasetServiceClient/get_dataset.php + * + * @param GetDatasetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Dataset + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDataset(GetDatasetRequest $request, array $callOptions = []): Dataset + { + return $this->startApiCall('GetDataset', $request, $callOptions)->wait(); + } + + /** + * Gets a Dataset version. + * + * The async variant is {@see DatasetServiceClient::getDatasetVersionAsync()} . + * + * @example samples/V1/DatasetServiceClient/get_dataset_version.php + * + * @param GetDatasetVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DatasetVersion + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDatasetVersion(GetDatasetVersionRequest $request, array $callOptions = []): DatasetVersion + { + return $this->startApiCall('GetDatasetVersion', $request, $callOptions)->wait(); + } + + /** + * Imports data into a Dataset. + * + * The async variant is {@see DatasetServiceClient::importDataAsync()} . + * + * @example samples/V1/DatasetServiceClient/import_data.php + * + * @param ImportDataRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importData(ImportDataRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportData', $request, $callOptions)->wait(); + } + + /** + * Lists Annotations belongs to a dataitem + * + * The async variant is {@see DatasetServiceClient::listAnnotationsAsync()} . + * + * @example samples/V1/DatasetServiceClient/list_annotations.php + * + * @param ListAnnotationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAnnotations(ListAnnotationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAnnotations', $request, $callOptions); + } + + /** + * Lists DataItems in a Dataset. + * + * The async variant is {@see DatasetServiceClient::listDataItemsAsync()} . + * + * @example samples/V1/DatasetServiceClient/list_data_items.php + * + * @param ListDataItemsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDataItems(ListDataItemsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDataItems', $request, $callOptions); + } + + /** + * Lists DatasetVersions in a Dataset. + * + * The async variant is {@see DatasetServiceClient::listDatasetVersionsAsync()} . + * + * @example samples/V1/DatasetServiceClient/list_dataset_versions.php + * + * @param ListDatasetVersionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDatasetVersions(ListDatasetVersionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDatasetVersions', $request, $callOptions); + } + + /** + * Lists Datasets in a Location. + * + * The async variant is {@see DatasetServiceClient::listDatasetsAsync()} . + * + * @example samples/V1/DatasetServiceClient/list_datasets.php + * + * @param ListDatasetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDatasets(ListDatasetsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDatasets', $request, $callOptions); + } + + /** + * Lists SavedQueries in a Dataset. + * + * The async variant is {@see DatasetServiceClient::listSavedQueriesAsync()} . + * + * @example samples/V1/DatasetServiceClient/list_saved_queries.php + * + * @param ListSavedQueriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSavedQueries(ListSavedQueriesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSavedQueries', $request, $callOptions); + } + + /** + * Restores a dataset version. + * + * The async variant is {@see DatasetServiceClient::restoreDatasetVersionAsync()} . + * + * @example samples/V1/DatasetServiceClient/restore_dataset_version.php + * + * @param RestoreDatasetVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function restoreDatasetVersion(RestoreDatasetVersionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RestoreDatasetVersion', $request, $callOptions)->wait(); + } + + /** + * Searches DataItems in a Dataset. + * + * The async variant is {@see DatasetServiceClient::searchDataItemsAsync()} . + * + * @example samples/V1/DatasetServiceClient/search_data_items.php + * + * @param SearchDataItemsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchDataItems(SearchDataItemsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchDataItems', $request, $callOptions); + } + + /** + * Updates a Dataset. + * + * The async variant is {@see DatasetServiceClient::updateDatasetAsync()} . + * + * @example samples/V1/DatasetServiceClient/update_dataset.php + * + * @param UpdateDatasetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Dataset + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDataset(UpdateDatasetRequest $request, array $callOptions = []): Dataset + { + return $this->startApiCall('UpdateDataset', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see DatasetServiceClient::getLocationAsync()} . + * + * @example samples/V1/DatasetServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see DatasetServiceClient::listLocationsAsync()} . + * + * @example samples/V1/DatasetServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see DatasetServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/DatasetServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see DatasetServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/DatasetServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see DatasetServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/DatasetServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/AiPlatform/src/V1/Client/EndpointServiceClient.php b/AiPlatform/src/V1/Client/EndpointServiceClient.php index f282c1320642..1375be3a41b6 100644 --- a/AiPlatform/src/V1/Client/EndpointServiceClient.php +++ b/AiPlatform/src/V1/Client/EndpointServiceClient.php @@ -24,17 +24,722 @@ namespace Google\Cloud\AIPlatform\V1\Client; -use Google\Cloud\AIPlatform\V1\Client\BaseClient\EndpointServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AIPlatform\V1\CreateEndpointRequest; +use Google\Cloud\AIPlatform\V1\DeleteEndpointRequest; +use Google\Cloud\AIPlatform\V1\DeployModelRequest; +use Google\Cloud\AIPlatform\V1\Endpoint; +use Google\Cloud\AIPlatform\V1\GetEndpointRequest; +use Google\Cloud\AIPlatform\V1\ListEndpointsRequest; +use Google\Cloud\AIPlatform\V1\MutateDeployedModelRequest; +use Google\Cloud\AIPlatform\V1\UndeployModelRequest; +use Google\Cloud\AIPlatform\V1\UpdateEndpointRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service for managing Vertex AI's Endpoints. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AIPlatform\V1\EndpointServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createEndpointAsync(CreateEndpointRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteEndpointAsync(DeleteEndpointRequest $request, array $optionalArgs = []) + * @method PromiseInterface deployModelAsync(DeployModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEndpointAsync(GetEndpointRequest $request, array $optionalArgs = []) + * @method PromiseInterface listEndpointsAsync(ListEndpointsRequest $request, array $optionalArgs = []) + * @method PromiseInterface mutateDeployedModelAsync(MutateDeployedModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface undeployModelAsync(UndeployModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateEndpointAsync(UpdateEndpointRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class EndpointServiceClient extends EndpointServiceBaseClient +final class EndpointServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see EndpointServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.aiplatform.v1.EndpointService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'aiplatform.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/endpoint_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/endpoint_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/endpoint_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/endpoint_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a endpoint + * resource. + * + * @param string $project + * @param string $location + * @param string $endpoint + * + * @return string The formatted endpoint resource. + */ + public static function endpointName(string $project, string $location, string $endpoint): string + { + return self::getPathTemplate('endpoint')->render([ + 'project' => $project, + 'location' => $location, + 'endpoint' => $endpoint, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a model + * resource. + * + * @param string $project + * @param string $location + * @param string $model + * + * @return string The formatted model resource. + */ + public static function modelName(string $project, string $location, string $model): string + { + return self::getPathTemplate('model')->render([ + 'project' => $project, + 'location' => $location, + 'model' => $model, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * model_deployment_monitoring_job resource. + * + * @param string $project + * @param string $location + * @param string $modelDeploymentMonitoringJob + * + * @return string The formatted model_deployment_monitoring_job resource. + */ + public static function modelDeploymentMonitoringJobName(string $project, string $location, string $modelDeploymentMonitoringJob): string + { + return self::getPathTemplate('modelDeploymentMonitoringJob')->render([ + 'project' => $project, + 'location' => $location, + 'model_deployment_monitoring_job' => $modelDeploymentMonitoringJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a network + * resource. + * + * @param string $project + * @param string $network + * + * @return string The formatted network resource. + */ + public static function networkName(string $project, string $network): string + { + return self::getPathTemplate('network')->render([ + 'project' => $project, + 'network' => $network, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_endpoint resource. + * + * @param string $project + * @param string $location + * @param string $endpoint + * + * @return string The formatted project_location_endpoint resource. + */ + public static function projectLocationEndpointName(string $project, string $location, string $endpoint): string + { + return self::getPathTemplate('projectLocationEndpoint')->render([ + 'project' => $project, + 'location' => $location, + 'endpoint' => $endpoint, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_publisher_model resource. + * + * @param string $project + * @param string $location + * @param string $publisher + * @param string $model + * + * @return string The formatted project_location_publisher_model resource. + */ + public static function projectLocationPublisherModelName(string $project, string $location, string $publisher, string $model): string + { + return self::getPathTemplate('projectLocationPublisherModel')->render([ + 'project' => $project, + 'location' => $location, + 'publisher' => $publisher, + 'model' => $model, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - endpoint: projects/{project}/locations/{location}/endpoints/{endpoint} + * - location: projects/{project}/locations/{location} + * - model: projects/{project}/locations/{location}/models/{model} + * - modelDeploymentMonitoringJob: projects/{project}/locations/{location}/modelDeploymentMonitoringJobs/{model_deployment_monitoring_job} + * - network: projects/{project}/global/networks/{network} + * - projectLocationEndpoint: projects/{project}/locations/{location}/endpoints/{endpoint} + * - projectLocationPublisherModel: projects/{project}/locations/{location}/publishers/{publisher}/models/{model} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'aiplatform.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates an Endpoint. + * + * The async variant is {@see EndpointServiceClient::createEndpointAsync()} . + * + * @example samples/V1/EndpointServiceClient/create_endpoint.php + * + * @param CreateEndpointRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createEndpoint(CreateEndpointRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateEndpoint', $request, $callOptions)->wait(); + } + + /** + * Deletes an Endpoint. + * + * The async variant is {@see EndpointServiceClient::deleteEndpointAsync()} . + * + * @example samples/V1/EndpointServiceClient/delete_endpoint.php + * + * @param DeleteEndpointRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteEndpoint(DeleteEndpointRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteEndpoint', $request, $callOptions)->wait(); + } + + /** + * Deploys a Model into this Endpoint, creating a DeployedModel within it. + * + * The async variant is {@see EndpointServiceClient::deployModelAsync()} . + * + * @example samples/V1/EndpointServiceClient/deploy_model.php + * + * @param DeployModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deployModel(DeployModelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeployModel', $request, $callOptions)->wait(); + } + + /** + * Gets an Endpoint. + * + * The async variant is {@see EndpointServiceClient::getEndpointAsync()} . + * + * @example samples/V1/EndpointServiceClient/get_endpoint.php + * + * @param GetEndpointRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Endpoint + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEndpoint(GetEndpointRequest $request, array $callOptions = []): Endpoint + { + return $this->startApiCall('GetEndpoint', $request, $callOptions)->wait(); + } + + /** + * Lists Endpoints in a Location. + * + * The async variant is {@see EndpointServiceClient::listEndpointsAsync()} . + * + * @example samples/V1/EndpointServiceClient/list_endpoints.php + * + * @param ListEndpointsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listEndpoints(ListEndpointsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEndpoints', $request, $callOptions); + } + + /** + * Updates an existing deployed model. Updatable fields include + * `min_replica_count`, `max_replica_count`, `autoscaling_metric_specs`, + * `disable_container_logging` (v1 only), and `enable_container_logging` + * (v1beta1 only). + * + * The async variant is {@see EndpointServiceClient::mutateDeployedModelAsync()} . + * + * @example samples/V1/EndpointServiceClient/mutate_deployed_model.php + * + * @param MutateDeployedModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function mutateDeployedModel(MutateDeployedModelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('MutateDeployedModel', $request, $callOptions)->wait(); + } + + /** + * Undeploys a Model from an Endpoint, removing a DeployedModel from it, and + * freeing all resources it's using. + * + * The async variant is {@see EndpointServiceClient::undeployModelAsync()} . + * + * @example samples/V1/EndpointServiceClient/undeploy_model.php + * + * @param UndeployModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function undeployModel(UndeployModelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UndeployModel', $request, $callOptions)->wait(); + } + + /** + * Updates an Endpoint. + * + * The async variant is {@see EndpointServiceClient::updateEndpointAsync()} . + * + * @example samples/V1/EndpointServiceClient/update_endpoint.php + * + * @param UpdateEndpointRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Endpoint + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateEndpoint(UpdateEndpointRequest $request, array $callOptions = []): Endpoint + { + return $this->startApiCall('UpdateEndpoint', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see EndpointServiceClient::getLocationAsync()} . + * + * @example samples/V1/EndpointServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see EndpointServiceClient::listLocationsAsync()} . + * + * @example samples/V1/EndpointServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see EndpointServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/EndpointServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see EndpointServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/EndpointServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see EndpointServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/EndpointServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/AiPlatform/src/V1/Client/FeaturestoreOnlineServingServiceClient.php b/AiPlatform/src/V1/Client/FeaturestoreOnlineServingServiceClient.php index 5129fba609b4..a4e2460ca222 100644 --- a/AiPlatform/src/V1/Client/FeaturestoreOnlineServingServiceClient.php +++ b/AiPlatform/src/V1/Client/FeaturestoreOnlineServingServiceClient.php @@ -24,17 +24,440 @@ namespace Google\Cloud\AIPlatform\V1\Client; -use Google\Cloud\AIPlatform\V1\Client\BaseClient\FeaturestoreOnlineServingServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\ServerStream; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AIPlatform\V1\ReadFeatureValuesRequest; +use Google\Cloud\AIPlatform\V1\ReadFeatureValuesResponse; +use Google\Cloud\AIPlatform\V1\StreamingReadFeatureValuesRequest; +use Google\Cloud\AIPlatform\V1\WriteFeatureValuesRequest; +use Google\Cloud\AIPlatform\V1\WriteFeatureValuesResponse; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service for serving online feature values. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AIPlatform\V1\FeaturestoreOnlineServingServiceClient} for the + * stable implementation * * @experimental + * + * @method PromiseInterface readFeatureValuesAsync(ReadFeatureValuesRequest $request, array $optionalArgs = []) + * @method PromiseInterface writeFeatureValuesAsync(WriteFeatureValuesRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class FeaturestoreOnlineServingServiceClient extends FeaturestoreOnlineServingServiceBaseClient +final class FeaturestoreOnlineServingServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see FeaturestoreOnlineServingServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.aiplatform.v1.FeaturestoreOnlineServingService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'aiplatform.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/featurestore_online_serving_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/featurestore_online_serving_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/featurestore_online_serving_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/featurestore_online_serving_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a entity_type + * resource. + * + * @param string $project + * @param string $location + * @param string $featurestore + * @param string $entityType + * + * @return string The formatted entity_type resource. + */ + public static function entityTypeName(string $project, string $location, string $featurestore, string $entityType): string + { + return self::getPathTemplate('entityType')->render([ + 'project' => $project, + 'location' => $location, + 'featurestore' => $featurestore, + 'entity_type' => $entityType, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - entityType: projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entity_type} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'aiplatform.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Reads Feature values of a specific entity of an EntityType. For reading + * feature values of multiple entities of an EntityType, please use + * StreamingReadFeatureValues. + * + * The async variant is + * {@see FeaturestoreOnlineServingServiceClient::readFeatureValuesAsync()} . + * + * @example samples/V1/FeaturestoreOnlineServingServiceClient/read_feature_values.php + * + * @param ReadFeatureValuesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ReadFeatureValuesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function readFeatureValues(ReadFeatureValuesRequest $request, array $callOptions = []): ReadFeatureValuesResponse + { + return $this->startApiCall('ReadFeatureValues', $request, $callOptions)->wait(); + } + + /** + * Reads Feature values for multiple entities. Depending on their size, data + * for different entities may be broken + * up across multiple responses. + * + * @example samples/V1/FeaturestoreOnlineServingServiceClient/streaming_read_feature_values.php + * + * @param StreamingReadFeatureValuesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return ServerStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function streamingReadFeatureValues(StreamingReadFeatureValuesRequest $request, array $callOptions = []): ServerStream + { + return $this->startApiCall('StreamingReadFeatureValues', $request, $callOptions); + } + + /** + * Writes Feature values of one or more entities of an EntityType. + * + * The Feature values are merged into existing entities if any. The Feature + * values to be written must have timestamp within the online storage + * retention. + * + * The async variant is + * {@see FeaturestoreOnlineServingServiceClient::writeFeatureValuesAsync()} . + * + * @example samples/V1/FeaturestoreOnlineServingServiceClient/write_feature_values.php + * + * @param WriteFeatureValuesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 WriteFeatureValuesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function writeFeatureValues(WriteFeatureValuesRequest $request, array $callOptions = []): WriteFeatureValuesResponse + { + return $this->startApiCall('WriteFeatureValues', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is + * {@see FeaturestoreOnlineServingServiceClient::getLocationAsync()} . + * + * @example samples/V1/FeaturestoreOnlineServingServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is + * {@see FeaturestoreOnlineServingServiceClient::listLocationsAsync()} . + * + * @example samples/V1/FeaturestoreOnlineServingServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is + * {@see FeaturestoreOnlineServingServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/FeaturestoreOnlineServingServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is + * {@see FeaturestoreOnlineServingServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/FeaturestoreOnlineServingServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is + * {@see FeaturestoreOnlineServingServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/FeaturestoreOnlineServingServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/AiPlatform/src/V1/Client/FeaturestoreServiceClient.php b/AiPlatform/src/V1/Client/FeaturestoreServiceClient.php index ea1a5de9598f..3c0299ea6172 100644 --- a/AiPlatform/src/V1/Client/FeaturestoreServiceClient.php +++ b/AiPlatform/src/V1/Client/FeaturestoreServiceClient.php @@ -24,17 +24,1076 @@ namespace Google\Cloud\AIPlatform\V1\Client; -use Google\Cloud\AIPlatform\V1\Client\BaseClient\FeaturestoreServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AIPlatform\V1\BatchCreateFeaturesRequest; +use Google\Cloud\AIPlatform\V1\BatchReadFeatureValuesRequest; +use Google\Cloud\AIPlatform\V1\CreateEntityTypeRequest; +use Google\Cloud\AIPlatform\V1\CreateFeatureRequest; +use Google\Cloud\AIPlatform\V1\CreateFeaturestoreRequest; +use Google\Cloud\AIPlatform\V1\DeleteEntityTypeRequest; +use Google\Cloud\AIPlatform\V1\DeleteFeatureRequest; +use Google\Cloud\AIPlatform\V1\DeleteFeatureValuesRequest; +use Google\Cloud\AIPlatform\V1\DeleteFeaturestoreRequest; +use Google\Cloud\AIPlatform\V1\EntityType; +use Google\Cloud\AIPlatform\V1\ExportFeatureValuesRequest; +use Google\Cloud\AIPlatform\V1\Feature; +use Google\Cloud\AIPlatform\V1\Featurestore; +use Google\Cloud\AIPlatform\V1\GetEntityTypeRequest; +use Google\Cloud\AIPlatform\V1\GetFeatureRequest; +use Google\Cloud\AIPlatform\V1\GetFeaturestoreRequest; +use Google\Cloud\AIPlatform\V1\ImportFeatureValuesRequest; +use Google\Cloud\AIPlatform\V1\ListEntityTypesRequest; +use Google\Cloud\AIPlatform\V1\ListFeaturesRequest; +use Google\Cloud\AIPlatform\V1\ListFeaturestoresRequest; +use Google\Cloud\AIPlatform\V1\SearchFeaturesRequest; +use Google\Cloud\AIPlatform\V1\UpdateEntityTypeRequest; +use Google\Cloud\AIPlatform\V1\UpdateFeatureRequest; +use Google\Cloud\AIPlatform\V1\UpdateFeaturestoreRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The service that handles CRUD and List for resources for Featurestore. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AIPlatform\V1\FeaturestoreServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface batchCreateFeaturesAsync(BatchCreateFeaturesRequest $request, array $optionalArgs = []) + * @method PromiseInterface batchReadFeatureValuesAsync(BatchReadFeatureValuesRequest $request, array $optionalArgs = []) + * @method PromiseInterface createEntityTypeAsync(CreateEntityTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface createFeatureAsync(CreateFeatureRequest $request, array $optionalArgs = []) + * @method PromiseInterface createFeaturestoreAsync(CreateFeaturestoreRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteEntityTypeAsync(DeleteEntityTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteFeatureAsync(DeleteFeatureRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteFeatureValuesAsync(DeleteFeatureValuesRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteFeaturestoreAsync(DeleteFeaturestoreRequest $request, array $optionalArgs = []) + * @method PromiseInterface exportFeatureValuesAsync(ExportFeatureValuesRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEntityTypeAsync(GetEntityTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getFeatureAsync(GetFeatureRequest $request, array $optionalArgs = []) + * @method PromiseInterface getFeaturestoreAsync(GetFeaturestoreRequest $request, array $optionalArgs = []) + * @method PromiseInterface importFeatureValuesAsync(ImportFeatureValuesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listEntityTypesAsync(ListEntityTypesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listFeaturesAsync(ListFeaturesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listFeaturestoresAsync(ListFeaturestoresRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchFeaturesAsync(SearchFeaturesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateEntityTypeAsync(UpdateEntityTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateFeatureAsync(UpdateFeatureRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateFeaturestoreAsync(UpdateFeaturestoreRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class FeaturestoreServiceClient extends FeaturestoreServiceBaseClient +final class FeaturestoreServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see FeaturestoreServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.aiplatform.v1.FeaturestoreService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'aiplatform.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/featurestore_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/featurestore_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/featurestore_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/featurestore_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a entity_type + * resource. + * + * @param string $project + * @param string $location + * @param string $featurestore + * @param string $entityType + * + * @return string The formatted entity_type resource. + */ + public static function entityTypeName(string $project, string $location, string $featurestore, string $entityType): string + { + return self::getPathTemplate('entityType')->render([ + 'project' => $project, + 'location' => $location, + 'featurestore' => $featurestore, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a feature + * resource. + * + * @param string $project + * @param string $location + * @param string $featurestore + * @param string $entityType + * @param string $feature + * + * @return string The formatted feature resource. + */ + public static function featureName(string $project, string $location, string $featurestore, string $entityType, string $feature): string + { + return self::getPathTemplate('feature')->render([ + 'project' => $project, + 'location' => $location, + 'featurestore' => $featurestore, + 'entity_type' => $entityType, + 'feature' => $feature, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a featurestore + * resource. + * + * @param string $project + * @param string $location + * @param string $featurestore + * + * @return string The formatted featurestore resource. + */ + public static function featurestoreName(string $project, string $location, string $featurestore): string + { + return self::getPathTemplate('featurestore')->render([ + 'project' => $project, + 'location' => $location, + 'featurestore' => $featurestore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - entityType: projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entity_type} + * - feature: projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entity_type}/features/{feature} + * - featurestore: projects/{project}/locations/{location}/featurestores/{featurestore} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'aiplatform.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a batch of Features in a given EntityType. + * + * The async variant is + * {@see FeaturestoreServiceClient::batchCreateFeaturesAsync()} . + * + * @example samples/V1/FeaturestoreServiceClient/batch_create_features.php + * + * @param BatchCreateFeaturesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchCreateFeatures(BatchCreateFeaturesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchCreateFeatures', $request, $callOptions)->wait(); + } + + /** + * Batch reads Feature values from a Featurestore. + * + * This API enables batch reading Feature values, where each read + * instance in the batch may read Feature values of entities from one or + * more EntityTypes. Point-in-time correctness is guaranteed for Feature + * values of each read instance as of each instance's read timestamp. + * + * The async variant is + * {@see FeaturestoreServiceClient::batchReadFeatureValuesAsync()} . + * + * @example samples/V1/FeaturestoreServiceClient/batch_read_feature_values.php + * + * @param BatchReadFeatureValuesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchReadFeatureValues(BatchReadFeatureValuesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchReadFeatureValues', $request, $callOptions)->wait(); + } + + /** + * Creates a new EntityType in a given Featurestore. + * + * The async variant is {@see FeaturestoreServiceClient::createEntityTypeAsync()} . + * + * @example samples/V1/FeaturestoreServiceClient/create_entity_type.php + * + * @param CreateEntityTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createEntityType(CreateEntityTypeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateEntityType', $request, $callOptions)->wait(); + } + + /** + * Creates a new Feature in a given EntityType. + * + * The async variant is {@see FeaturestoreServiceClient::createFeatureAsync()} . + * + * @example samples/V1/FeaturestoreServiceClient/create_feature.php + * + * @param CreateFeatureRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createFeature(CreateFeatureRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateFeature', $request, $callOptions)->wait(); + } + + /** + * Creates a new Featurestore in a given project and location. + * + * The async variant is {@see FeaturestoreServiceClient::createFeaturestoreAsync()} + * . + * + * @example samples/V1/FeaturestoreServiceClient/create_featurestore.php + * + * @param CreateFeaturestoreRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createFeaturestore(CreateFeaturestoreRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateFeaturestore', $request, $callOptions)->wait(); + } + + /** + * Deletes a single EntityType. The EntityType must not have any Features + * or `force` must be set to true for the request to succeed. + * + * The async variant is {@see FeaturestoreServiceClient::deleteEntityTypeAsync()} . + * + * @example samples/V1/FeaturestoreServiceClient/delete_entity_type.php + * + * @param DeleteEntityTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteEntityType(DeleteEntityTypeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteEntityType', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Feature. + * + * The async variant is {@see FeaturestoreServiceClient::deleteFeatureAsync()} . + * + * @example samples/V1/FeaturestoreServiceClient/delete_feature.php + * + * @param DeleteFeatureRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteFeature(DeleteFeatureRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteFeature', $request, $callOptions)->wait(); + } + + /** + * Delete Feature values from Featurestore. + * + * The progress of the deletion is tracked by the returned operation. The + * deleted feature values are guaranteed to be invisible to subsequent read + * operations after the operation is marked as successfully done. + * + * If a delete feature values operation fails, the feature values + * returned from reads and exports may be inconsistent. If consistency is + * required, the caller must retry the same delete request again and wait till + * the new operation returned is marked as successfully done. + * + * The async variant is + * {@see FeaturestoreServiceClient::deleteFeatureValuesAsync()} . + * + * @example samples/V1/FeaturestoreServiceClient/delete_feature_values.php + * + * @param DeleteFeatureValuesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteFeatureValues(DeleteFeatureValuesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteFeatureValues', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Featurestore. The Featurestore must not contain any + * EntityTypes or `force` must be set to true for the request to succeed. + * + * The async variant is {@see FeaturestoreServiceClient::deleteFeaturestoreAsync()} + * . + * + * @example samples/V1/FeaturestoreServiceClient/delete_featurestore.php + * + * @param DeleteFeaturestoreRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteFeaturestore(DeleteFeaturestoreRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteFeaturestore', $request, $callOptions)->wait(); + } + + /** + * Exports Feature values from all the entities of a target EntityType. + * + * The async variant is + * {@see FeaturestoreServiceClient::exportFeatureValuesAsync()} . + * + * @example samples/V1/FeaturestoreServiceClient/export_feature_values.php + * + * @param ExportFeatureValuesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportFeatureValues(ExportFeatureValuesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ExportFeatureValues', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single EntityType. + * + * The async variant is {@see FeaturestoreServiceClient::getEntityTypeAsync()} . + * + * @example samples/V1/FeaturestoreServiceClient/get_entity_type.php + * + * @param GetEntityTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 EntityType + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEntityType(GetEntityTypeRequest $request, array $callOptions = []): EntityType + { + return $this->startApiCall('GetEntityType', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Feature. + * + * The async variant is {@see FeaturestoreServiceClient::getFeatureAsync()} . + * + * @example samples/V1/FeaturestoreServiceClient/get_feature.php + * + * @param GetFeatureRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Feature + * + * @throws ApiException Thrown if the API call fails. + */ + public function getFeature(GetFeatureRequest $request, array $callOptions = []): Feature + { + return $this->startApiCall('GetFeature', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Featurestore. + * + * The async variant is {@see FeaturestoreServiceClient::getFeaturestoreAsync()} . + * + * @example samples/V1/FeaturestoreServiceClient/get_featurestore.php + * + * @param GetFeaturestoreRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Featurestore + * + * @throws ApiException Thrown if the API call fails. + */ + public function getFeaturestore(GetFeaturestoreRequest $request, array $callOptions = []): Featurestore + { + return $this->startApiCall('GetFeaturestore', $request, $callOptions)->wait(); + } + + /** + * Imports Feature values into the Featurestore from a source storage. + * + * The progress of the import is tracked by the returned operation. The + * imported features are guaranteed to be visible to subsequent read + * operations after the operation is marked as successfully done. + * + * If an import operation fails, the Feature values returned from + * reads and exports may be inconsistent. If consistency is + * required, the caller must retry the same import request again and wait till + * the new operation returned is marked as successfully done. + * + * There are also scenarios where the caller can cause inconsistency. + * + * - Source data for import contains multiple distinct Feature values for + * the same entity ID and timestamp. + * - Source is modified during an import. This includes adding, updating, or + * removing source data and/or metadata. Examples of updating metadata + * include but are not limited to changing storage location, storage class, + * or retention policy. + * - Online serving cluster is under-provisioned. + * + * The async variant is + * {@see FeaturestoreServiceClient::importFeatureValuesAsync()} . + * + * @example samples/V1/FeaturestoreServiceClient/import_feature_values.php + * + * @param ImportFeatureValuesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importFeatureValues(ImportFeatureValuesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportFeatureValues', $request, $callOptions)->wait(); + } + + /** + * Lists EntityTypes in a given Featurestore. + * + * The async variant is {@see FeaturestoreServiceClient::listEntityTypesAsync()} . + * + * @example samples/V1/FeaturestoreServiceClient/list_entity_types.php + * + * @param ListEntityTypesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listEntityTypes(ListEntityTypesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEntityTypes', $request, $callOptions); + } + + /** + * Lists Features in a given EntityType. + * + * The async variant is {@see FeaturestoreServiceClient::listFeaturesAsync()} . + * + * @example samples/V1/FeaturestoreServiceClient/list_features.php + * + * @param ListFeaturesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listFeatures(ListFeaturesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListFeatures', $request, $callOptions); + } + + /** + * Lists Featurestores in a given project and location. + * + * The async variant is {@see FeaturestoreServiceClient::listFeaturestoresAsync()} + * . + * + * @example samples/V1/FeaturestoreServiceClient/list_featurestores.php + * + * @param ListFeaturestoresRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listFeaturestores(ListFeaturestoresRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListFeaturestores', $request, $callOptions); + } + + /** + * Searches Features matching a query in a given project. + * + * The async variant is {@see FeaturestoreServiceClient::searchFeaturesAsync()} . + * + * @example samples/V1/FeaturestoreServiceClient/search_features.php + * + * @param SearchFeaturesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchFeatures(SearchFeaturesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchFeatures', $request, $callOptions); + } + + /** + * Updates the parameters of a single EntityType. + * + * The async variant is {@see FeaturestoreServiceClient::updateEntityTypeAsync()} . + * + * @example samples/V1/FeaturestoreServiceClient/update_entity_type.php + * + * @param UpdateEntityTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 EntityType + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateEntityType(UpdateEntityTypeRequest $request, array $callOptions = []): EntityType + { + return $this->startApiCall('UpdateEntityType', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single Feature. + * + * The async variant is {@see FeaturestoreServiceClient::updateFeatureAsync()} . + * + * @example samples/V1/FeaturestoreServiceClient/update_feature.php + * + * @param UpdateFeatureRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Feature + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateFeature(UpdateFeatureRequest $request, array $callOptions = []): Feature + { + return $this->startApiCall('UpdateFeature', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single Featurestore. + * + * The async variant is {@see FeaturestoreServiceClient::updateFeaturestoreAsync()} + * . + * + * @example samples/V1/FeaturestoreServiceClient/update_featurestore.php + * + * @param UpdateFeaturestoreRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateFeaturestore(UpdateFeaturestoreRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateFeaturestore', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see FeaturestoreServiceClient::getLocationAsync()} . + * + * @example samples/V1/FeaturestoreServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see FeaturestoreServiceClient::listLocationsAsync()} . + * + * @example samples/V1/FeaturestoreServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see FeaturestoreServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/FeaturestoreServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see FeaturestoreServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/FeaturestoreServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see FeaturestoreServiceClient::testIamPermissionsAsync()} + * . + * + * @example samples/V1/FeaturestoreServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/AiPlatform/src/V1/Client/IndexEndpointServiceClient.php b/AiPlatform/src/V1/Client/IndexEndpointServiceClient.php index 48e2759cd7c7..240773b8ee6e 100644 --- a/AiPlatform/src/V1/Client/IndexEndpointServiceClient.php +++ b/AiPlatform/src/V1/Client/IndexEndpointServiceClient.php @@ -24,17 +24,649 @@ namespace Google\Cloud\AIPlatform\V1\Client; -use Google\Cloud\AIPlatform\V1\Client\BaseClient\IndexEndpointServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AIPlatform\V1\CreateIndexEndpointRequest; +use Google\Cloud\AIPlatform\V1\DeleteIndexEndpointRequest; +use Google\Cloud\AIPlatform\V1\DeployIndexRequest; +use Google\Cloud\AIPlatform\V1\GetIndexEndpointRequest; +use Google\Cloud\AIPlatform\V1\IndexEndpoint; +use Google\Cloud\AIPlatform\V1\ListIndexEndpointsRequest; +use Google\Cloud\AIPlatform\V1\MutateDeployedIndexRequest; +use Google\Cloud\AIPlatform\V1\UndeployIndexRequest; +use Google\Cloud\AIPlatform\V1\UpdateIndexEndpointRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service for managing Vertex AI's IndexEndpoints. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AIPlatform\V1\IndexEndpointServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createIndexEndpointAsync(CreateIndexEndpointRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteIndexEndpointAsync(DeleteIndexEndpointRequest $request, array $optionalArgs = []) + * @method PromiseInterface deployIndexAsync(DeployIndexRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIndexEndpointAsync(GetIndexEndpointRequest $request, array $optionalArgs = []) + * @method PromiseInterface listIndexEndpointsAsync(ListIndexEndpointsRequest $request, array $optionalArgs = []) + * @method PromiseInterface mutateDeployedIndexAsync(MutateDeployedIndexRequest $request, array $optionalArgs = []) + * @method PromiseInterface undeployIndexAsync(UndeployIndexRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateIndexEndpointAsync(UpdateIndexEndpointRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class IndexEndpointServiceClient extends IndexEndpointServiceBaseClient +final class IndexEndpointServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see IndexEndpointServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.aiplatform.v1.IndexEndpointService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'aiplatform.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/index_endpoint_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/index_endpoint_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/index_endpoint_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/index_endpoint_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a index + * resource. + * + * @param string $project + * @param string $location + * @param string $index + * + * @return string The formatted index resource. + */ + public static function indexName(string $project, string $location, string $index): string + { + return self::getPathTemplate('index')->render([ + 'project' => $project, + 'location' => $location, + 'index' => $index, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * index_endpoint resource. + * + * @param string $project + * @param string $location + * @param string $indexEndpoint + * + * @return string The formatted index_endpoint resource. + */ + public static function indexEndpointName(string $project, string $location, string $indexEndpoint): string + { + return self::getPathTemplate('indexEndpoint')->render([ + 'project' => $project, + 'location' => $location, + 'index_endpoint' => $indexEndpoint, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - index: projects/{project}/locations/{location}/indexes/{index} + * - indexEndpoint: projects/{project}/locations/{location}/indexEndpoints/{index_endpoint} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'aiplatform.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates an IndexEndpoint. + * + * The async variant is + * {@see IndexEndpointServiceClient::createIndexEndpointAsync()} . + * + * @example samples/V1/IndexEndpointServiceClient/create_index_endpoint.php + * + * @param CreateIndexEndpointRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createIndexEndpoint(CreateIndexEndpointRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateIndexEndpoint', $request, $callOptions)->wait(); + } + + /** + * Deletes an IndexEndpoint. + * + * The async variant is + * {@see IndexEndpointServiceClient::deleteIndexEndpointAsync()} . + * + * @example samples/V1/IndexEndpointServiceClient/delete_index_endpoint.php + * + * @param DeleteIndexEndpointRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteIndexEndpoint(DeleteIndexEndpointRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteIndexEndpoint', $request, $callOptions)->wait(); + } + + /** + * Deploys an Index into this IndexEndpoint, creating a DeployedIndex within + * it. + * Only non-empty Indexes can be deployed. + * + * The async variant is {@see IndexEndpointServiceClient::deployIndexAsync()} . + * + * @example samples/V1/IndexEndpointServiceClient/deploy_index.php + * + * @param DeployIndexRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deployIndex(DeployIndexRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeployIndex', $request, $callOptions)->wait(); + } + + /** + * Gets an IndexEndpoint. + * + * The async variant is {@see IndexEndpointServiceClient::getIndexEndpointAsync()} + * . + * + * @example samples/V1/IndexEndpointServiceClient/get_index_endpoint.php + * + * @param GetIndexEndpointRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 IndexEndpoint + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIndexEndpoint(GetIndexEndpointRequest $request, array $callOptions = []): IndexEndpoint + { + return $this->startApiCall('GetIndexEndpoint', $request, $callOptions)->wait(); + } + + /** + * Lists IndexEndpoints in a Location. + * + * The async variant is + * {@see IndexEndpointServiceClient::listIndexEndpointsAsync()} . + * + * @example samples/V1/IndexEndpointServiceClient/list_index_endpoints.php + * + * @param ListIndexEndpointsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listIndexEndpoints(ListIndexEndpointsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListIndexEndpoints', $request, $callOptions); + } + + /** + * Update an existing DeployedIndex under an IndexEndpoint. + * + * The async variant is + * {@see IndexEndpointServiceClient::mutateDeployedIndexAsync()} . + * + * @example samples/V1/IndexEndpointServiceClient/mutate_deployed_index.php + * + * @param MutateDeployedIndexRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function mutateDeployedIndex(MutateDeployedIndexRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('MutateDeployedIndex', $request, $callOptions)->wait(); + } + + /** + * Undeploys an Index from an IndexEndpoint, removing a DeployedIndex from it, + * and freeing all resources it's using. + * + * The async variant is {@see IndexEndpointServiceClient::undeployIndexAsync()} . + * + * @example samples/V1/IndexEndpointServiceClient/undeploy_index.php + * + * @param UndeployIndexRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function undeployIndex(UndeployIndexRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UndeployIndex', $request, $callOptions)->wait(); + } + + /** + * Updates an IndexEndpoint. + * + * The async variant is + * {@see IndexEndpointServiceClient::updateIndexEndpointAsync()} . + * + * @example samples/V1/IndexEndpointServiceClient/update_index_endpoint.php + * + * @param UpdateIndexEndpointRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 IndexEndpoint + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateIndexEndpoint(UpdateIndexEndpointRequest $request, array $callOptions = []): IndexEndpoint + { + return $this->startApiCall('UpdateIndexEndpoint', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see IndexEndpointServiceClient::getLocationAsync()} . + * + * @example samples/V1/IndexEndpointServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see IndexEndpointServiceClient::listLocationsAsync()} . + * + * @example samples/V1/IndexEndpointServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see IndexEndpointServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/IndexEndpointServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see IndexEndpointServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/IndexEndpointServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is + * {@see IndexEndpointServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/IndexEndpointServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/AiPlatform/src/V1/Client/IndexServiceClient.php b/AiPlatform/src/V1/Client/IndexServiceClient.php index 4f9ef191b325..7a49e0c55a9f 100644 --- a/AiPlatform/src/V1/Client/IndexServiceClient.php +++ b/AiPlatform/src/V1/Client/IndexServiceClient.php @@ -24,17 +24,615 @@ namespace Google\Cloud\AIPlatform\V1\Client; -use Google\Cloud\AIPlatform\V1\Client\BaseClient\IndexServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AIPlatform\V1\CreateIndexRequest; +use Google\Cloud\AIPlatform\V1\DeleteIndexRequest; +use Google\Cloud\AIPlatform\V1\GetIndexRequest; +use Google\Cloud\AIPlatform\V1\Index; +use Google\Cloud\AIPlatform\V1\ListIndexesRequest; +use Google\Cloud\AIPlatform\V1\RemoveDatapointsRequest; +use Google\Cloud\AIPlatform\V1\RemoveDatapointsResponse; +use Google\Cloud\AIPlatform\V1\UpdateIndexRequest; +use Google\Cloud\AIPlatform\V1\UpsertDatapointsRequest; +use Google\Cloud\AIPlatform\V1\UpsertDatapointsResponse; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service for creating and managing Vertex AI's Index resources. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AIPlatform\V1\IndexServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createIndexAsync(CreateIndexRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteIndexAsync(DeleteIndexRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIndexAsync(GetIndexRequest $request, array $optionalArgs = []) + * @method PromiseInterface listIndexesAsync(ListIndexesRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeDatapointsAsync(RemoveDatapointsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateIndexAsync(UpdateIndexRequest $request, array $optionalArgs = []) + * @method PromiseInterface upsertDatapointsAsync(UpsertDatapointsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class IndexServiceClient extends IndexServiceBaseClient +final class IndexServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see IndexServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.aiplatform.v1.IndexService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'aiplatform.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/index_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/index_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/index_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/index_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a index + * resource. + * + * @param string $project + * @param string $location + * @param string $index + * + * @return string The formatted index resource. + */ + public static function indexName(string $project, string $location, string $index): string + { + return self::getPathTemplate('index')->render([ + 'project' => $project, + 'location' => $location, + 'index' => $index, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * index_endpoint resource. + * + * @param string $project + * @param string $location + * @param string $indexEndpoint + * + * @return string The formatted index_endpoint resource. + */ + public static function indexEndpointName(string $project, string $location, string $indexEndpoint): string + { + return self::getPathTemplate('indexEndpoint')->render([ + 'project' => $project, + 'location' => $location, + 'index_endpoint' => $indexEndpoint, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - index: projects/{project}/locations/{location}/indexes/{index} + * - indexEndpoint: projects/{project}/locations/{location}/indexEndpoints/{index_endpoint} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'aiplatform.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates an Index. + * + * The async variant is {@see IndexServiceClient::createIndexAsync()} . + * + * @example samples/V1/IndexServiceClient/create_index.php + * + * @param CreateIndexRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createIndex(CreateIndexRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateIndex', $request, $callOptions)->wait(); + } + + /** + * Deletes an Index. + * An Index can only be deleted when all its + * [DeployedIndexes][google.cloud.aiplatform.v1.Index.deployed_indexes] had + * been undeployed. + * + * The async variant is {@see IndexServiceClient::deleteIndexAsync()} . + * + * @example samples/V1/IndexServiceClient/delete_index.php + * + * @param DeleteIndexRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteIndex(DeleteIndexRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteIndex', $request, $callOptions)->wait(); + } + + /** + * Gets an Index. + * + * The async variant is {@see IndexServiceClient::getIndexAsync()} . + * + * @example samples/V1/IndexServiceClient/get_index.php + * + * @param GetIndexRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Index + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIndex(GetIndexRequest $request, array $callOptions = []): Index + { + return $this->startApiCall('GetIndex', $request, $callOptions)->wait(); + } + + /** + * Lists Indexes in a Location. + * + * The async variant is {@see IndexServiceClient::listIndexesAsync()} . + * + * @example samples/V1/IndexServiceClient/list_indexes.php + * + * @param ListIndexesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listIndexes(ListIndexesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListIndexes', $request, $callOptions); + } + + /** + * Remove Datapoints from an Index. + * + * The async variant is {@see IndexServiceClient::removeDatapointsAsync()} . + * + * @example samples/V1/IndexServiceClient/remove_datapoints.php + * + * @param RemoveDatapointsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RemoveDatapointsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeDatapoints(RemoveDatapointsRequest $request, array $callOptions = []): RemoveDatapointsResponse + { + return $this->startApiCall('RemoveDatapoints', $request, $callOptions)->wait(); + } + + /** + * Updates an Index. + * + * The async variant is {@see IndexServiceClient::updateIndexAsync()} . + * + * @example samples/V1/IndexServiceClient/update_index.php + * + * @param UpdateIndexRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateIndex(UpdateIndexRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateIndex', $request, $callOptions)->wait(); + } + + /** + * Add/update Datapoints into an Index. + * + * The async variant is {@see IndexServiceClient::upsertDatapointsAsync()} . + * + * @example samples/V1/IndexServiceClient/upsert_datapoints.php + * + * @param UpsertDatapointsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 UpsertDatapointsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function upsertDatapoints(UpsertDatapointsRequest $request, array $callOptions = []): UpsertDatapointsResponse + { + return $this->startApiCall('UpsertDatapoints', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see IndexServiceClient::getLocationAsync()} . + * + * @example samples/V1/IndexServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see IndexServiceClient::listLocationsAsync()} . + * + * @example samples/V1/IndexServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see IndexServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/IndexServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see IndexServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/IndexServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see IndexServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/IndexServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/AiPlatform/src/V1/Client/JobServiceClient.php b/AiPlatform/src/V1/Client/JobServiceClient.php index 2976d060811a..630b8113a104 100644 --- a/AiPlatform/src/V1/Client/JobServiceClient.php +++ b/AiPlatform/src/V1/Client/JobServiceClient.php @@ -24,17 +24,1761 @@ namespace Google\Cloud\AIPlatform\V1\Client; -use Google\Cloud\AIPlatform\V1\Client\BaseClient\JobServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AIPlatform\V1\BatchPredictionJob; +use Google\Cloud\AIPlatform\V1\CancelBatchPredictionJobRequest; +use Google\Cloud\AIPlatform\V1\CancelCustomJobRequest; +use Google\Cloud\AIPlatform\V1\CancelDataLabelingJobRequest; +use Google\Cloud\AIPlatform\V1\CancelHyperparameterTuningJobRequest; +use Google\Cloud\AIPlatform\V1\CancelNasJobRequest; +use Google\Cloud\AIPlatform\V1\CreateBatchPredictionJobRequest; +use Google\Cloud\AIPlatform\V1\CreateCustomJobRequest; +use Google\Cloud\AIPlatform\V1\CreateDataLabelingJobRequest; +use Google\Cloud\AIPlatform\V1\CreateHyperparameterTuningJobRequest; +use Google\Cloud\AIPlatform\V1\CreateModelDeploymentMonitoringJobRequest; +use Google\Cloud\AIPlatform\V1\CreateNasJobRequest; +use Google\Cloud\AIPlatform\V1\CustomJob; +use Google\Cloud\AIPlatform\V1\DataLabelingJob; +use Google\Cloud\AIPlatform\V1\DeleteBatchPredictionJobRequest; +use Google\Cloud\AIPlatform\V1\DeleteCustomJobRequest; +use Google\Cloud\AIPlatform\V1\DeleteDataLabelingJobRequest; +use Google\Cloud\AIPlatform\V1\DeleteHyperparameterTuningJobRequest; +use Google\Cloud\AIPlatform\V1\DeleteModelDeploymentMonitoringJobRequest; +use Google\Cloud\AIPlatform\V1\DeleteNasJobRequest; +use Google\Cloud\AIPlatform\V1\GetBatchPredictionJobRequest; +use Google\Cloud\AIPlatform\V1\GetCustomJobRequest; +use Google\Cloud\AIPlatform\V1\GetDataLabelingJobRequest; +use Google\Cloud\AIPlatform\V1\GetHyperparameterTuningJobRequest; +use Google\Cloud\AIPlatform\V1\GetModelDeploymentMonitoringJobRequest; +use Google\Cloud\AIPlatform\V1\GetNasJobRequest; +use Google\Cloud\AIPlatform\V1\GetNasTrialDetailRequest; +use Google\Cloud\AIPlatform\V1\HyperparameterTuningJob; +use Google\Cloud\AIPlatform\V1\ListBatchPredictionJobsRequest; +use Google\Cloud\AIPlatform\V1\ListCustomJobsRequest; +use Google\Cloud\AIPlatform\V1\ListDataLabelingJobsRequest; +use Google\Cloud\AIPlatform\V1\ListHyperparameterTuningJobsRequest; +use Google\Cloud\AIPlatform\V1\ListModelDeploymentMonitoringJobsRequest; +use Google\Cloud\AIPlatform\V1\ListNasJobsRequest; +use Google\Cloud\AIPlatform\V1\ListNasTrialDetailsRequest; +use Google\Cloud\AIPlatform\V1\ModelDeploymentMonitoringJob; +use Google\Cloud\AIPlatform\V1\NasJob; +use Google\Cloud\AIPlatform\V1\NasTrialDetail; +use Google\Cloud\AIPlatform\V1\PauseModelDeploymentMonitoringJobRequest; +use Google\Cloud\AIPlatform\V1\ResumeModelDeploymentMonitoringJobRequest; +use Google\Cloud\AIPlatform\V1\SearchModelDeploymentMonitoringStatsAnomaliesRequest; +use Google\Cloud\AIPlatform\V1\UpdateModelDeploymentMonitoringJobRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service for creating and managing Vertex AI's jobs. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AIPlatform\V1\JobServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface cancelBatchPredictionJobAsync(CancelBatchPredictionJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface cancelCustomJobAsync(CancelCustomJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface cancelDataLabelingJobAsync(CancelDataLabelingJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface cancelHyperparameterTuningJobAsync(CancelHyperparameterTuningJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface cancelNasJobAsync(CancelNasJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface createBatchPredictionJobAsync(CreateBatchPredictionJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface createCustomJobAsync(CreateCustomJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface createDataLabelingJobAsync(CreateDataLabelingJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface createHyperparameterTuningJobAsync(CreateHyperparameterTuningJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface createModelDeploymentMonitoringJobAsync(CreateModelDeploymentMonitoringJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface createNasJobAsync(CreateNasJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteBatchPredictionJobAsync(DeleteBatchPredictionJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteCustomJobAsync(DeleteCustomJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDataLabelingJobAsync(DeleteDataLabelingJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteHyperparameterTuningJobAsync(DeleteHyperparameterTuningJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteModelDeploymentMonitoringJobAsync(DeleteModelDeploymentMonitoringJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteNasJobAsync(DeleteNasJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getBatchPredictionJobAsync(GetBatchPredictionJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCustomJobAsync(GetCustomJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDataLabelingJobAsync(GetDataLabelingJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getHyperparameterTuningJobAsync(GetHyperparameterTuningJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getModelDeploymentMonitoringJobAsync(GetModelDeploymentMonitoringJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getNasJobAsync(GetNasJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getNasTrialDetailAsync(GetNasTrialDetailRequest $request, array $optionalArgs = []) + * @method PromiseInterface listBatchPredictionJobsAsync(ListBatchPredictionJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCustomJobsAsync(ListCustomJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDataLabelingJobsAsync(ListDataLabelingJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listHyperparameterTuningJobsAsync(ListHyperparameterTuningJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listModelDeploymentMonitoringJobsAsync(ListModelDeploymentMonitoringJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listNasJobsAsync(ListNasJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listNasTrialDetailsAsync(ListNasTrialDetailsRequest $request, array $optionalArgs = []) + * @method PromiseInterface pauseModelDeploymentMonitoringJobAsync(PauseModelDeploymentMonitoringJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface resumeModelDeploymentMonitoringJobAsync(ResumeModelDeploymentMonitoringJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchModelDeploymentMonitoringStatsAnomaliesAsync(SearchModelDeploymentMonitoringStatsAnomaliesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateModelDeploymentMonitoringJobAsync(UpdateModelDeploymentMonitoringJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class JobServiceClient extends JobServiceBaseClient +final class JobServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see JobServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.aiplatform.v1.JobService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'aiplatform.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/job_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/job_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/job_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/job_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * batch_prediction_job resource. + * + * @param string $project + * @param string $location + * @param string $batchPredictionJob + * + * @return string The formatted batch_prediction_job resource. + */ + public static function batchPredictionJobName(string $project, string $location, string $batchPredictionJob): string + { + return self::getPathTemplate('batchPredictionJob')->render([ + 'project' => $project, + 'location' => $location, + 'batch_prediction_job' => $batchPredictionJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a context + * resource. + * + * @param string $project + * @param string $location + * @param string $metadataStore + * @param string $context + * + * @return string The formatted context resource. + */ + public static function contextName(string $project, string $location, string $metadataStore, string $context): string + { + return self::getPathTemplate('context')->render([ + 'project' => $project, + 'location' => $location, + 'metadata_store' => $metadataStore, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a custom_job + * resource. + * + * @param string $project + * @param string $location + * @param string $customJob + * + * @return string The formatted custom_job resource. + */ + public static function customJobName(string $project, string $location, string $customJob): string + { + return self::getPathTemplate('customJob')->render([ + 'project' => $project, + 'location' => $location, + 'custom_job' => $customJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * data_labeling_job resource. + * + * @param string $project + * @param string $location + * @param string $dataLabelingJob + * + * @return string The formatted data_labeling_job resource. + */ + public static function dataLabelingJobName(string $project, string $location, string $dataLabelingJob): string + { + return self::getPathTemplate('dataLabelingJob')->render([ + 'project' => $project, + 'location' => $location, + 'data_labeling_job' => $dataLabelingJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a dataset + * resource. + * + * @param string $project + * @param string $location + * @param string $dataset + * + * @return string The formatted dataset resource. + */ + public static function datasetName(string $project, string $location, string $dataset): string + { + return self::getPathTemplate('dataset')->render([ + 'project' => $project, + 'location' => $location, + 'dataset' => $dataset, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a endpoint + * resource. + * + * @param string $project + * @param string $location + * @param string $endpoint + * + * @return string The formatted endpoint resource. + */ + public static function endpointName(string $project, string $location, string $endpoint): string + { + return self::getPathTemplate('endpoint')->render([ + 'project' => $project, + 'location' => $location, + 'endpoint' => $endpoint, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * hyperparameter_tuning_job resource. + * + * @param string $project + * @param string $location + * @param string $hyperparameterTuningJob + * + * @return string The formatted hyperparameter_tuning_job resource. + */ + public static function hyperparameterTuningJobName(string $project, string $location, string $hyperparameterTuningJob): string + { + return self::getPathTemplate('hyperparameterTuningJob')->render([ + 'project' => $project, + 'location' => $location, + 'hyperparameter_tuning_job' => $hyperparameterTuningJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a model + * resource. + * + * @param string $project + * @param string $location + * @param string $model + * + * @return string The formatted model resource. + */ + public static function modelName(string $project, string $location, string $model): string + { + return self::getPathTemplate('model')->render([ + 'project' => $project, + 'location' => $location, + 'model' => $model, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * model_deployment_monitoring_job resource. + * + * @param string $project + * @param string $location + * @param string $modelDeploymentMonitoringJob + * + * @return string The formatted model_deployment_monitoring_job resource. + */ + public static function modelDeploymentMonitoringJobName(string $project, string $location, string $modelDeploymentMonitoringJob): string + { + return self::getPathTemplate('modelDeploymentMonitoringJob')->render([ + 'project' => $project, + 'location' => $location, + 'model_deployment_monitoring_job' => $modelDeploymentMonitoringJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a nas_job + * resource. + * + * @param string $project + * @param string $location + * @param string $nasJob + * + * @return string The formatted nas_job resource. + */ + public static function nasJobName(string $project, string $location, string $nasJob): string + { + return self::getPathTemplate('nasJob')->render([ + 'project' => $project, + 'location' => $location, + 'nas_job' => $nasJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * nas_trial_detail resource. + * + * @param string $project + * @param string $location + * @param string $nasJob + * @param string $nasTrialDetail + * + * @return string The formatted nas_trial_detail resource. + */ + public static function nasTrialDetailName(string $project, string $location, string $nasJob, string $nasTrialDetail): string + { + return self::getPathTemplate('nasTrialDetail')->render([ + 'project' => $project, + 'location' => $location, + 'nas_job' => $nasJob, + 'nas_trial_detail' => $nasTrialDetail, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a network + * resource. + * + * @param string $project + * @param string $network + * + * @return string The formatted network resource. + */ + public static function networkName(string $project, string $network): string + { + return self::getPathTemplate('network')->render([ + 'project' => $project, + 'network' => $network, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * notification_channel resource. + * + * @param string $project + * @param string $notificationChannel + * + * @return string The formatted notification_channel resource. + */ + public static function notificationChannelName(string $project, string $notificationChannel): string + { + return self::getPathTemplate('notificationChannel')->render([ + 'project' => $project, + 'notification_channel' => $notificationChannel, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_endpoint resource. + * + * @param string $project + * @param string $location + * @param string $endpoint + * + * @return string The formatted project_location_endpoint resource. + */ + public static function projectLocationEndpointName(string $project, string $location, string $endpoint): string + { + return self::getPathTemplate('projectLocationEndpoint')->render([ + 'project' => $project, + 'location' => $location, + 'endpoint' => $endpoint, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_publisher_model resource. + * + * @param string $project + * @param string $location + * @param string $publisher + * @param string $model + * + * @return string The formatted project_location_publisher_model resource. + */ + public static function projectLocationPublisherModelName(string $project, string $location, string $publisher, string $model): string + { + return self::getPathTemplate('projectLocationPublisherModel')->render([ + 'project' => $project, + 'location' => $location, + 'publisher' => $publisher, + 'model' => $model, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a tensorboard + * resource. + * + * @param string $project + * @param string $location + * @param string $tensorboard + * + * @return string The formatted tensorboard resource. + */ + public static function tensorboardName(string $project, string $location, string $tensorboard): string + { + return self::getPathTemplate('tensorboard')->render([ + 'project' => $project, + 'location' => $location, + 'tensorboard' => $tensorboard, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a trial + * resource. + * + * @param string $project + * @param string $location + * @param string $study + * @param string $trial + * + * @return string The formatted trial resource. + */ + public static function trialName(string $project, string $location, string $study, string $trial): string + { + return self::getPathTemplate('trial')->render([ + 'project' => $project, + 'location' => $location, + 'study' => $study, + 'trial' => $trial, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - batchPredictionJob: projects/{project}/locations/{location}/batchPredictionJobs/{batch_prediction_job} + * - context: projects/{project}/locations/{location}/metadataStores/{metadata_store}/contexts/{context} + * - customJob: projects/{project}/locations/{location}/customJobs/{custom_job} + * - dataLabelingJob: projects/{project}/locations/{location}/dataLabelingJobs/{data_labeling_job} + * - dataset: projects/{project}/locations/{location}/datasets/{dataset} + * - endpoint: projects/{project}/locations/{location}/endpoints/{endpoint} + * - hyperparameterTuningJob: projects/{project}/locations/{location}/hyperparameterTuningJobs/{hyperparameter_tuning_job} + * - location: projects/{project}/locations/{location} + * - model: projects/{project}/locations/{location}/models/{model} + * - modelDeploymentMonitoringJob: projects/{project}/locations/{location}/modelDeploymentMonitoringJobs/{model_deployment_monitoring_job} + * - nasJob: projects/{project}/locations/{location}/nasJobs/{nas_job} + * - nasTrialDetail: projects/{project}/locations/{location}/nasJobs/{nas_job}/nasTrialDetails/{nas_trial_detail} + * - network: projects/{project}/global/networks/{network} + * - notificationChannel: projects/{project}/notificationChannels/{notification_channel} + * - projectLocationEndpoint: projects/{project}/locations/{location}/endpoints/{endpoint} + * - projectLocationPublisherModel: projects/{project}/locations/{location}/publishers/{publisher}/models/{model} + * - tensorboard: projects/{project}/locations/{location}/tensorboards/{tensorboard} + * - trial: projects/{project}/locations/{location}/studies/{study}/trials/{trial} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'aiplatform.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Cancels a BatchPredictionJob. + * + * Starts asynchronous cancellation on the BatchPredictionJob. The server + * makes the best effort to cancel the job, but success is not + * guaranteed. Clients can use + * [JobService.GetBatchPredictionJob][google.cloud.aiplatform.v1.JobService.GetBatchPredictionJob] + * or other methods to check whether the cancellation succeeded or whether the + * job completed despite cancellation. On a successful cancellation, + * the BatchPredictionJob is not deleted;instead its + * [BatchPredictionJob.state][google.cloud.aiplatform.v1.BatchPredictionJob.state] + * is set to `CANCELLED`. Any files already outputted by the job are not + * deleted. + * + * The async variant is {@see JobServiceClient::cancelBatchPredictionJobAsync()} . + * + * @example samples/V1/JobServiceClient/cancel_batch_prediction_job.php + * + * @param CancelBatchPredictionJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function cancelBatchPredictionJob(CancelBatchPredictionJobRequest $request, array $callOptions = []): void + { + $this->startApiCall('CancelBatchPredictionJob', $request, $callOptions)->wait(); + } + + /** + * Cancels a CustomJob. + * Starts asynchronous cancellation on the CustomJob. The server + * makes a best effort to cancel the job, but success is not + * guaranteed. Clients can use + * [JobService.GetCustomJob][google.cloud.aiplatform.v1.JobService.GetCustomJob] + * or other methods to check whether the cancellation succeeded or whether the + * job completed despite cancellation. On successful cancellation, + * the CustomJob is not deleted; instead it becomes a job with + * a [CustomJob.error][google.cloud.aiplatform.v1.CustomJob.error] value with + * a [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to + * `Code.CANCELLED`, and + * [CustomJob.state][google.cloud.aiplatform.v1.CustomJob.state] is set to + * `CANCELLED`. + * + * The async variant is {@see JobServiceClient::cancelCustomJobAsync()} . + * + * @example samples/V1/JobServiceClient/cancel_custom_job.php + * + * @param CancelCustomJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function cancelCustomJob(CancelCustomJobRequest $request, array $callOptions = []): void + { + $this->startApiCall('CancelCustomJob', $request, $callOptions)->wait(); + } + + /** + * Cancels a DataLabelingJob. Success of cancellation is not guaranteed. + * + * The async variant is {@see JobServiceClient::cancelDataLabelingJobAsync()} . + * + * @example samples/V1/JobServiceClient/cancel_data_labeling_job.php + * + * @param CancelDataLabelingJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function cancelDataLabelingJob(CancelDataLabelingJobRequest $request, array $callOptions = []): void + { + $this->startApiCall('CancelDataLabelingJob', $request, $callOptions)->wait(); + } + + /** + * Cancels a HyperparameterTuningJob. + * Starts asynchronous cancellation on the HyperparameterTuningJob. The server + * makes a best effort to cancel the job, but success is not + * guaranteed. Clients can use + * [JobService.GetHyperparameterTuningJob][google.cloud.aiplatform.v1.JobService.GetHyperparameterTuningJob] + * or other methods to check whether the cancellation succeeded or whether the + * job completed despite cancellation. On successful cancellation, + * the HyperparameterTuningJob is not deleted; instead it becomes a job with + * a + * [HyperparameterTuningJob.error][google.cloud.aiplatform.v1.HyperparameterTuningJob.error] + * value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + * corresponding to `Code.CANCELLED`, and + * [HyperparameterTuningJob.state][google.cloud.aiplatform.v1.HyperparameterTuningJob.state] + * is set to `CANCELLED`. + * + * The async variant is + * {@see JobServiceClient::cancelHyperparameterTuningJobAsync()} . + * + * @example samples/V1/JobServiceClient/cancel_hyperparameter_tuning_job.php + * + * @param CancelHyperparameterTuningJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function cancelHyperparameterTuningJob(CancelHyperparameterTuningJobRequest $request, array $callOptions = []): void + { + $this->startApiCall('CancelHyperparameterTuningJob', $request, $callOptions)->wait(); + } + + /** + * Cancels a NasJob. + * Starts asynchronous cancellation on the NasJob. The server + * makes a best effort to cancel the job, but success is not + * guaranteed. Clients can use + * [JobService.GetNasJob][google.cloud.aiplatform.v1.JobService.GetNasJob] or + * other methods to check whether the cancellation succeeded or whether the + * job completed despite cancellation. On successful cancellation, + * the NasJob is not deleted; instead it becomes a job with + * a [NasJob.error][google.cloud.aiplatform.v1.NasJob.error] value with a + * [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to + * `Code.CANCELLED`, and + * [NasJob.state][google.cloud.aiplatform.v1.NasJob.state] is set to + * `CANCELLED`. + * + * The async variant is {@see JobServiceClient::cancelNasJobAsync()} . + * + * @example samples/V1/JobServiceClient/cancel_nas_job.php + * + * @param CancelNasJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function cancelNasJob(CancelNasJobRequest $request, array $callOptions = []): void + { + $this->startApiCall('CancelNasJob', $request, $callOptions)->wait(); + } + + /** + * Creates a BatchPredictionJob. A BatchPredictionJob once created will + * right away be attempted to start. + * + * The async variant is {@see JobServiceClient::createBatchPredictionJobAsync()} . + * + * @example samples/V1/JobServiceClient/create_batch_prediction_job.php + * + * @param CreateBatchPredictionJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BatchPredictionJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function createBatchPredictionJob(CreateBatchPredictionJobRequest $request, array $callOptions = []): BatchPredictionJob + { + return $this->startApiCall('CreateBatchPredictionJob', $request, $callOptions)->wait(); + } + + /** + * Creates a CustomJob. A created CustomJob right away + * will be attempted to be run. + * + * The async variant is {@see JobServiceClient::createCustomJobAsync()} . + * + * @example samples/V1/JobServiceClient/create_custom_job.php + * + * @param CreateCustomJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CustomJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCustomJob(CreateCustomJobRequest $request, array $callOptions = []): CustomJob + { + return $this->startApiCall('CreateCustomJob', $request, $callOptions)->wait(); + } + + /** + * Creates a DataLabelingJob. + * + * The async variant is {@see JobServiceClient::createDataLabelingJobAsync()} . + * + * @example samples/V1/JobServiceClient/create_data_labeling_job.php + * + * @param CreateDataLabelingJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataLabelingJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDataLabelingJob(CreateDataLabelingJobRequest $request, array $callOptions = []): DataLabelingJob + { + return $this->startApiCall('CreateDataLabelingJob', $request, $callOptions)->wait(); + } + + /** + * Creates a HyperparameterTuningJob + * + * The async variant is + * {@see JobServiceClient::createHyperparameterTuningJobAsync()} . + * + * @example samples/V1/JobServiceClient/create_hyperparameter_tuning_job.php + * + * @param CreateHyperparameterTuningJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 HyperparameterTuningJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function createHyperparameterTuningJob(CreateHyperparameterTuningJobRequest $request, array $callOptions = []): HyperparameterTuningJob + { + return $this->startApiCall('CreateHyperparameterTuningJob', $request, $callOptions)->wait(); + } + + /** + * Creates a ModelDeploymentMonitoringJob. It will run periodically on a + * configured interval. + * + * The async variant is + * {@see JobServiceClient::createModelDeploymentMonitoringJobAsync()} . + * + * @example samples/V1/JobServiceClient/create_model_deployment_monitoring_job.php + * + * @param CreateModelDeploymentMonitoringJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ModelDeploymentMonitoringJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function createModelDeploymentMonitoringJob(CreateModelDeploymentMonitoringJobRequest $request, array $callOptions = []): ModelDeploymentMonitoringJob + { + return $this->startApiCall('CreateModelDeploymentMonitoringJob', $request, $callOptions)->wait(); + } + + /** + * Creates a NasJob + * + * The async variant is {@see JobServiceClient::createNasJobAsync()} . + * + * @example samples/V1/JobServiceClient/create_nas_job.php + * + * @param CreateNasJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NasJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function createNasJob(CreateNasJobRequest $request, array $callOptions = []): NasJob + { + return $this->startApiCall('CreateNasJob', $request, $callOptions)->wait(); + } + + /** + * Deletes a BatchPredictionJob. Can only be called on jobs that already + * finished. + * + * The async variant is {@see JobServiceClient::deleteBatchPredictionJobAsync()} . + * + * @example samples/V1/JobServiceClient/delete_batch_prediction_job.php + * + * @param DeleteBatchPredictionJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteBatchPredictionJob(DeleteBatchPredictionJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteBatchPredictionJob', $request, $callOptions)->wait(); + } + + /** + * Deletes a CustomJob. + * + * The async variant is {@see JobServiceClient::deleteCustomJobAsync()} . + * + * @example samples/V1/JobServiceClient/delete_custom_job.php + * + * @param DeleteCustomJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteCustomJob(DeleteCustomJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteCustomJob', $request, $callOptions)->wait(); + } + + /** + * Deletes a DataLabelingJob. + * + * The async variant is {@see JobServiceClient::deleteDataLabelingJobAsync()} . + * + * @example samples/V1/JobServiceClient/delete_data_labeling_job.php + * + * @param DeleteDataLabelingJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDataLabelingJob(DeleteDataLabelingJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteDataLabelingJob', $request, $callOptions)->wait(); + } + + /** + * Deletes a HyperparameterTuningJob. + * + * The async variant is + * {@see JobServiceClient::deleteHyperparameterTuningJobAsync()} . + * + * @example samples/V1/JobServiceClient/delete_hyperparameter_tuning_job.php + * + * @param DeleteHyperparameterTuningJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteHyperparameterTuningJob(DeleteHyperparameterTuningJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteHyperparameterTuningJob', $request, $callOptions)->wait(); + } + + /** + * Deletes a ModelDeploymentMonitoringJob. + * + * The async variant is + * {@see JobServiceClient::deleteModelDeploymentMonitoringJobAsync()} . + * + * @example samples/V1/JobServiceClient/delete_model_deployment_monitoring_job.php + * + * @param DeleteModelDeploymentMonitoringJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteModelDeploymentMonitoringJob(DeleteModelDeploymentMonitoringJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteModelDeploymentMonitoringJob', $request, $callOptions)->wait(); + } + + /** + * Deletes a NasJob. + * + * The async variant is {@see JobServiceClient::deleteNasJobAsync()} . + * + * @example samples/V1/JobServiceClient/delete_nas_job.php + * + * @param DeleteNasJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteNasJob(DeleteNasJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteNasJob', $request, $callOptions)->wait(); + } + + /** + * Gets a BatchPredictionJob + * + * The async variant is {@see JobServiceClient::getBatchPredictionJobAsync()} . + * + * @example samples/V1/JobServiceClient/get_batch_prediction_job.php + * + * @param GetBatchPredictionJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BatchPredictionJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function getBatchPredictionJob(GetBatchPredictionJobRequest $request, array $callOptions = []): BatchPredictionJob + { + return $this->startApiCall('GetBatchPredictionJob', $request, $callOptions)->wait(); + } + + /** + * Gets a CustomJob. + * + * The async variant is {@see JobServiceClient::getCustomJobAsync()} . + * + * @example samples/V1/JobServiceClient/get_custom_job.php + * + * @param GetCustomJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CustomJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCustomJob(GetCustomJobRequest $request, array $callOptions = []): CustomJob + { + return $this->startApiCall('GetCustomJob', $request, $callOptions)->wait(); + } + + /** + * Gets a DataLabelingJob. + * + * The async variant is {@see JobServiceClient::getDataLabelingJobAsync()} . + * + * @example samples/V1/JobServiceClient/get_data_labeling_job.php + * + * @param GetDataLabelingJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataLabelingJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDataLabelingJob(GetDataLabelingJobRequest $request, array $callOptions = []): DataLabelingJob + { + return $this->startApiCall('GetDataLabelingJob', $request, $callOptions)->wait(); + } + + /** + * Gets a HyperparameterTuningJob + * + * The async variant is {@see JobServiceClient::getHyperparameterTuningJobAsync()} + * . + * + * @example samples/V1/JobServiceClient/get_hyperparameter_tuning_job.php + * + * @param GetHyperparameterTuningJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 HyperparameterTuningJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function getHyperparameterTuningJob(GetHyperparameterTuningJobRequest $request, array $callOptions = []): HyperparameterTuningJob + { + return $this->startApiCall('GetHyperparameterTuningJob', $request, $callOptions)->wait(); + } + + /** + * Gets a ModelDeploymentMonitoringJob. + * + * The async variant is + * {@see JobServiceClient::getModelDeploymentMonitoringJobAsync()} . + * + * @example samples/V1/JobServiceClient/get_model_deployment_monitoring_job.php + * + * @param GetModelDeploymentMonitoringJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ModelDeploymentMonitoringJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function getModelDeploymentMonitoringJob(GetModelDeploymentMonitoringJobRequest $request, array $callOptions = []): ModelDeploymentMonitoringJob + { + return $this->startApiCall('GetModelDeploymentMonitoringJob', $request, $callOptions)->wait(); + } + + /** + * Gets a NasJob + * + * The async variant is {@see JobServiceClient::getNasJobAsync()} . + * + * @example samples/V1/JobServiceClient/get_nas_job.php + * + * @param GetNasJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NasJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function getNasJob(GetNasJobRequest $request, array $callOptions = []): NasJob + { + return $this->startApiCall('GetNasJob', $request, $callOptions)->wait(); + } + + /** + * Gets a NasTrialDetail. + * + * The async variant is {@see JobServiceClient::getNasTrialDetailAsync()} . + * + * @example samples/V1/JobServiceClient/get_nas_trial_detail.php + * + * @param GetNasTrialDetailRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NasTrialDetail + * + * @throws ApiException Thrown if the API call fails. + */ + public function getNasTrialDetail(GetNasTrialDetailRequest $request, array $callOptions = []): NasTrialDetail + { + return $this->startApiCall('GetNasTrialDetail', $request, $callOptions)->wait(); + } + + /** + * Lists BatchPredictionJobs in a Location. + * + * The async variant is {@see JobServiceClient::listBatchPredictionJobsAsync()} . + * + * @example samples/V1/JobServiceClient/list_batch_prediction_jobs.php + * + * @param ListBatchPredictionJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listBatchPredictionJobs(ListBatchPredictionJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListBatchPredictionJobs', $request, $callOptions); + } + + /** + * Lists CustomJobs in a Location. + * + * The async variant is {@see JobServiceClient::listCustomJobsAsync()} . + * + * @example samples/V1/JobServiceClient/list_custom_jobs.php + * + * @param ListCustomJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCustomJobs(ListCustomJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCustomJobs', $request, $callOptions); + } + + /** + * Lists DataLabelingJobs in a Location. + * + * The async variant is {@see JobServiceClient::listDataLabelingJobsAsync()} . + * + * @example samples/V1/JobServiceClient/list_data_labeling_jobs.php + * + * @param ListDataLabelingJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDataLabelingJobs(ListDataLabelingJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDataLabelingJobs', $request, $callOptions); + } + + /** + * Lists HyperparameterTuningJobs in a Location. + * + * The async variant is + * {@see JobServiceClient::listHyperparameterTuningJobsAsync()} . + * + * @example samples/V1/JobServiceClient/list_hyperparameter_tuning_jobs.php + * + * @param ListHyperparameterTuningJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listHyperparameterTuningJobs(ListHyperparameterTuningJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListHyperparameterTuningJobs', $request, $callOptions); + } + + /** + * Lists ModelDeploymentMonitoringJobs in a Location. + * + * The async variant is + * {@see JobServiceClient::listModelDeploymentMonitoringJobsAsync()} . + * + * @example samples/V1/JobServiceClient/list_model_deployment_monitoring_jobs.php + * + * @param ListModelDeploymentMonitoringJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listModelDeploymentMonitoringJobs(ListModelDeploymentMonitoringJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListModelDeploymentMonitoringJobs', $request, $callOptions); + } + + /** + * Lists NasJobs in a Location. + * + * The async variant is {@see JobServiceClient::listNasJobsAsync()} . + * + * @example samples/V1/JobServiceClient/list_nas_jobs.php + * + * @param ListNasJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listNasJobs(ListNasJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListNasJobs', $request, $callOptions); + } + + /** + * List top NasTrialDetails of a NasJob. + * + * The async variant is {@see JobServiceClient::listNasTrialDetailsAsync()} . + * + * @example samples/V1/JobServiceClient/list_nas_trial_details.php + * + * @param ListNasTrialDetailsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listNasTrialDetails(ListNasTrialDetailsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListNasTrialDetails', $request, $callOptions); + } + + /** + * Pauses a ModelDeploymentMonitoringJob. If the job is running, the server + * makes a best effort to cancel the job. Will mark + * [ModelDeploymentMonitoringJob.state][google.cloud.aiplatform.v1.ModelDeploymentMonitoringJob.state] + * to 'PAUSED'. + * + * The async variant is + * {@see JobServiceClient::pauseModelDeploymentMonitoringJobAsync()} . + * + * @example samples/V1/JobServiceClient/pause_model_deployment_monitoring_job.php + * + * @param PauseModelDeploymentMonitoringJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function pauseModelDeploymentMonitoringJob(PauseModelDeploymentMonitoringJobRequest $request, array $callOptions = []): void + { + $this->startApiCall('PauseModelDeploymentMonitoringJob', $request, $callOptions)->wait(); + } + + /** + * Resumes a paused ModelDeploymentMonitoringJob. It will start to run from + * next scheduled time. A deleted ModelDeploymentMonitoringJob can't be + * resumed. + * + * The async variant is + * {@see JobServiceClient::resumeModelDeploymentMonitoringJobAsync()} . + * + * @example samples/V1/JobServiceClient/resume_model_deployment_monitoring_job.php + * + * @param ResumeModelDeploymentMonitoringJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function resumeModelDeploymentMonitoringJob(ResumeModelDeploymentMonitoringJobRequest $request, array $callOptions = []): void + { + $this->startApiCall('ResumeModelDeploymentMonitoringJob', $request, $callOptions)->wait(); + } + + /** + * Searches Model Monitoring Statistics generated within a given time window. + * + * The async variant is + * {@see JobServiceClient::searchModelDeploymentMonitoringStatsAnomaliesAsync()} . + * + * @example samples/V1/JobServiceClient/search_model_deployment_monitoring_stats_anomalies.php + * + * @param SearchModelDeploymentMonitoringStatsAnomaliesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchModelDeploymentMonitoringStatsAnomalies(SearchModelDeploymentMonitoringStatsAnomaliesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchModelDeploymentMonitoringStatsAnomalies', $request, $callOptions); + } + + /** + * Updates a ModelDeploymentMonitoringJob. + * + * The async variant is + * {@see JobServiceClient::updateModelDeploymentMonitoringJobAsync()} . + * + * @example samples/V1/JobServiceClient/update_model_deployment_monitoring_job.php + * + * @param UpdateModelDeploymentMonitoringJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateModelDeploymentMonitoringJob(UpdateModelDeploymentMonitoringJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateModelDeploymentMonitoringJob', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see JobServiceClient::getLocationAsync()} . + * + * @example samples/V1/JobServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see JobServiceClient::listLocationsAsync()} . + * + * @example samples/V1/JobServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see JobServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/JobServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see JobServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/JobServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see JobServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/JobServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/AiPlatform/src/V1/Client/MatchServiceClient.php b/AiPlatform/src/V1/Client/MatchServiceClient.php index 3b13a9bd6604..4ea7657d16f3 100644 --- a/AiPlatform/src/V1/Client/MatchServiceClient.php +++ b/AiPlatform/src/V1/Client/MatchServiceClient.php @@ -24,17 +24,400 @@ namespace Google\Cloud\AIPlatform\V1\Client; -use Google\Cloud\AIPlatform\V1\Client\BaseClient\MatchServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AIPlatform\V1\FindNeighborsRequest; +use Google\Cloud\AIPlatform\V1\FindNeighborsResponse; +use Google\Cloud\AIPlatform\V1\ReadIndexDatapointsRequest; +use Google\Cloud\AIPlatform\V1\ReadIndexDatapointsResponse; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: MatchService is a Google managed service for efficient vector similarity + * search at scale. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AIPlatform\V1\MatchServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface findNeighborsAsync(FindNeighborsRequest $request, array $optionalArgs = []) + * @method PromiseInterface readIndexDatapointsAsync(ReadIndexDatapointsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class MatchServiceClient extends MatchServiceBaseClient +final class MatchServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see MatchServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.aiplatform.v1.MatchService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'aiplatform.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/match_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/match_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/match_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/match_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * index_endpoint resource. + * + * @param string $project + * @param string $location + * @param string $indexEndpoint + * + * @return string The formatted index_endpoint resource. + */ + public static function indexEndpointName(string $project, string $location, string $indexEndpoint): string + { + return self::getPathTemplate('indexEndpoint')->render([ + 'project' => $project, + 'location' => $location, + 'index_endpoint' => $indexEndpoint, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - indexEndpoint: projects/{project}/locations/{location}/indexEndpoints/{index_endpoint} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'aiplatform.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Finds the nearest neighbors of each vector within the request. + * + * The async variant is {@see MatchServiceClient::findNeighborsAsync()} . + * + * @example samples/V1/MatchServiceClient/find_neighbors.php + * + * @param FindNeighborsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FindNeighborsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function findNeighbors(FindNeighborsRequest $request, array $callOptions = []): FindNeighborsResponse + { + return $this->startApiCall('FindNeighbors', $request, $callOptions)->wait(); + } + + /** + * Reads the datapoints/vectors of the given IDs. + * A maximum of 1000 datapoints can be retrieved in a batch. + * + * The async variant is {@see MatchServiceClient::readIndexDatapointsAsync()} . + * + * @example samples/V1/MatchServiceClient/read_index_datapoints.php + * + * @param ReadIndexDatapointsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ReadIndexDatapointsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function readIndexDatapoints(ReadIndexDatapointsRequest $request, array $callOptions = []): ReadIndexDatapointsResponse + { + return $this->startApiCall('ReadIndexDatapoints', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see MatchServiceClient::getLocationAsync()} . + * + * @example samples/V1/MatchServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see MatchServiceClient::listLocationsAsync()} . + * + * @example samples/V1/MatchServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see MatchServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/MatchServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see MatchServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/MatchServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see MatchServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/MatchServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/AiPlatform/src/V1/Client/MetadataServiceClient.php b/AiPlatform/src/V1/Client/MetadataServiceClient.php index 8f2e034a367f..864b244f9e6c 100644 --- a/AiPlatform/src/V1/Client/MetadataServiceClient.php +++ b/AiPlatform/src/V1/Client/MetadataServiceClient.php @@ -24,17 +24,1409 @@ namespace Google\Cloud\AIPlatform\V1\Client; -use Google\Cloud\AIPlatform\V1\Client\BaseClient\MetadataServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AIPlatform\V1\AddContextArtifactsAndExecutionsRequest; +use Google\Cloud\AIPlatform\V1\AddContextArtifactsAndExecutionsResponse; +use Google\Cloud\AIPlatform\V1\AddContextChildrenRequest; +use Google\Cloud\AIPlatform\V1\AddContextChildrenResponse; +use Google\Cloud\AIPlatform\V1\AddExecutionEventsRequest; +use Google\Cloud\AIPlatform\V1\AddExecutionEventsResponse; +use Google\Cloud\AIPlatform\V1\Artifact; +use Google\Cloud\AIPlatform\V1\Context; +use Google\Cloud\AIPlatform\V1\CreateArtifactRequest; +use Google\Cloud\AIPlatform\V1\CreateContextRequest; +use Google\Cloud\AIPlatform\V1\CreateExecutionRequest; +use Google\Cloud\AIPlatform\V1\CreateMetadataSchemaRequest; +use Google\Cloud\AIPlatform\V1\CreateMetadataStoreRequest; +use Google\Cloud\AIPlatform\V1\DeleteArtifactRequest; +use Google\Cloud\AIPlatform\V1\DeleteContextRequest; +use Google\Cloud\AIPlatform\V1\DeleteExecutionRequest; +use Google\Cloud\AIPlatform\V1\DeleteMetadataStoreRequest; +use Google\Cloud\AIPlatform\V1\Event; +use Google\Cloud\AIPlatform\V1\Execution; +use Google\Cloud\AIPlatform\V1\GetArtifactRequest; +use Google\Cloud\AIPlatform\V1\GetContextRequest; +use Google\Cloud\AIPlatform\V1\GetExecutionRequest; +use Google\Cloud\AIPlatform\V1\GetMetadataSchemaRequest; +use Google\Cloud\AIPlatform\V1\GetMetadataStoreRequest; +use Google\Cloud\AIPlatform\V1\LineageSubgraph; +use Google\Cloud\AIPlatform\V1\ListArtifactsRequest; +use Google\Cloud\AIPlatform\V1\ListContextsRequest; +use Google\Cloud\AIPlatform\V1\ListExecutionsRequest; +use Google\Cloud\AIPlatform\V1\ListMetadataSchemasRequest; +use Google\Cloud\AIPlatform\V1\ListMetadataStoresRequest; +use Google\Cloud\AIPlatform\V1\MetadataSchema; +use Google\Cloud\AIPlatform\V1\MetadataStore; +use Google\Cloud\AIPlatform\V1\PurgeArtifactsRequest; +use Google\Cloud\AIPlatform\V1\PurgeContextsRequest; +use Google\Cloud\AIPlatform\V1\PurgeExecutionsRequest; +use Google\Cloud\AIPlatform\V1\QueryArtifactLineageSubgraphRequest; +use Google\Cloud\AIPlatform\V1\QueryContextLineageSubgraphRequest; +use Google\Cloud\AIPlatform\V1\QueryExecutionInputsAndOutputsRequest; +use Google\Cloud\AIPlatform\V1\RemoveContextChildrenRequest; +use Google\Cloud\AIPlatform\V1\RemoveContextChildrenResponse; +use Google\Cloud\AIPlatform\V1\UpdateArtifactRequest; +use Google\Cloud\AIPlatform\V1\UpdateContextRequest; +use Google\Cloud\AIPlatform\V1\UpdateExecutionRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for reading and writing metadata entries. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AIPlatform\V1\MetadataServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface addContextArtifactsAndExecutionsAsync(AddContextArtifactsAndExecutionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface addContextChildrenAsync(AddContextChildrenRequest $request, array $optionalArgs = []) + * @method PromiseInterface addExecutionEventsAsync(AddExecutionEventsRequest $request, array $optionalArgs = []) + * @method PromiseInterface createArtifactAsync(CreateArtifactRequest $request, array $optionalArgs = []) + * @method PromiseInterface createContextAsync(CreateContextRequest $request, array $optionalArgs = []) + * @method PromiseInterface createExecutionAsync(CreateExecutionRequest $request, array $optionalArgs = []) + * @method PromiseInterface createMetadataSchemaAsync(CreateMetadataSchemaRequest $request, array $optionalArgs = []) + * @method PromiseInterface createMetadataStoreAsync(CreateMetadataStoreRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteArtifactAsync(DeleteArtifactRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteContextAsync(DeleteContextRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteExecutionAsync(DeleteExecutionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteMetadataStoreAsync(DeleteMetadataStoreRequest $request, array $optionalArgs = []) + * @method PromiseInterface getArtifactAsync(GetArtifactRequest $request, array $optionalArgs = []) + * @method PromiseInterface getContextAsync(GetContextRequest $request, array $optionalArgs = []) + * @method PromiseInterface getExecutionAsync(GetExecutionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getMetadataSchemaAsync(GetMetadataSchemaRequest $request, array $optionalArgs = []) + * @method PromiseInterface getMetadataStoreAsync(GetMetadataStoreRequest $request, array $optionalArgs = []) + * @method PromiseInterface listArtifactsAsync(ListArtifactsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listContextsAsync(ListContextsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listExecutionsAsync(ListExecutionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listMetadataSchemasAsync(ListMetadataSchemasRequest $request, array $optionalArgs = []) + * @method PromiseInterface listMetadataStoresAsync(ListMetadataStoresRequest $request, array $optionalArgs = []) + * @method PromiseInterface purgeArtifactsAsync(PurgeArtifactsRequest $request, array $optionalArgs = []) + * @method PromiseInterface purgeContextsAsync(PurgeContextsRequest $request, array $optionalArgs = []) + * @method PromiseInterface purgeExecutionsAsync(PurgeExecutionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface queryArtifactLineageSubgraphAsync(QueryArtifactLineageSubgraphRequest $request, array $optionalArgs = []) + * @method PromiseInterface queryContextLineageSubgraphAsync(QueryContextLineageSubgraphRequest $request, array $optionalArgs = []) + * @method PromiseInterface queryExecutionInputsAndOutputsAsync(QueryExecutionInputsAndOutputsRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeContextChildrenAsync(RemoveContextChildrenRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateArtifactAsync(UpdateArtifactRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateContextAsync(UpdateContextRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateExecutionAsync(UpdateExecutionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class MetadataServiceClient extends MetadataServiceBaseClient +final class MetadataServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see MetadataServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.aiplatform.v1.MetadataService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'aiplatform.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/metadata_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/metadata_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/metadata_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/metadata_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a artifact + * resource. + * + * @param string $project + * @param string $location + * @param string $metadataStore + * @param string $artifact + * + * @return string The formatted artifact resource. + */ + public static function artifactName(string $project, string $location, string $metadataStore, string $artifact): string + { + return self::getPathTemplate('artifact')->render([ + 'project' => $project, + 'location' => $location, + 'metadata_store' => $metadataStore, + 'artifact' => $artifact, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a context + * resource. + * + * @param string $project + * @param string $location + * @param string $metadataStore + * @param string $context + * + * @return string The formatted context resource. + */ + public static function contextName(string $project, string $location, string $metadataStore, string $context): string + { + return self::getPathTemplate('context')->render([ + 'project' => $project, + 'location' => $location, + 'metadata_store' => $metadataStore, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a execution + * resource. + * + * @param string $project + * @param string $location + * @param string $metadataStore + * @param string $execution + * + * @return string The formatted execution resource. + */ + public static function executionName(string $project, string $location, string $metadataStore, string $execution): string + { + return self::getPathTemplate('execution')->render([ + 'project' => $project, + 'location' => $location, + 'metadata_store' => $metadataStore, + 'execution' => $execution, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * metadata_schema resource. + * + * @param string $project + * @param string $location + * @param string $metadataStore + * @param string $metadataSchema + * + * @return string The formatted metadata_schema resource. + */ + public static function metadataSchemaName(string $project, string $location, string $metadataStore, string $metadataSchema): string + { + return self::getPathTemplate('metadataSchema')->render([ + 'project' => $project, + 'location' => $location, + 'metadata_store' => $metadataStore, + 'metadata_schema' => $metadataSchema, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * metadata_store resource. + * + * @param string $project + * @param string $location + * @param string $metadataStore + * + * @return string The formatted metadata_store resource. + */ + public static function metadataStoreName(string $project, string $location, string $metadataStore): string + { + return self::getPathTemplate('metadataStore')->render([ + 'project' => $project, + 'location' => $location, + 'metadata_store' => $metadataStore, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - artifact: projects/{project}/locations/{location}/metadataStores/{metadata_store}/artifacts/{artifact} + * - context: projects/{project}/locations/{location}/metadataStores/{metadata_store}/contexts/{context} + * - execution: projects/{project}/locations/{location}/metadataStores/{metadata_store}/executions/{execution} + * - location: projects/{project}/locations/{location} + * - metadataSchema: projects/{project}/locations/{location}/metadataStores/{metadata_store}/metadataSchemas/{metadata_schema} + * - metadataStore: projects/{project}/locations/{location}/metadataStores/{metadata_store} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'aiplatform.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Adds a set of Artifacts and Executions to a Context. If any of the + * Artifacts or Executions have already been added to a Context, they are + * simply skipped. + * + * The async variant is + * {@see MetadataServiceClient::addContextArtifactsAndExecutionsAsync()} . + * + * @example samples/V1/MetadataServiceClient/add_context_artifacts_and_executions.php + * + * @param AddContextArtifactsAndExecutionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AddContextArtifactsAndExecutionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addContextArtifactsAndExecutions(AddContextArtifactsAndExecutionsRequest $request, array $callOptions = []): AddContextArtifactsAndExecutionsResponse + { + return $this->startApiCall('AddContextArtifactsAndExecutions', $request, $callOptions)->wait(); + } + + /** + * Adds a set of Contexts as children to a parent Context. If any of the + * child Contexts have already been added to the parent Context, they are + * simply skipped. If this call would create a cycle or cause any Context to + * have more than 10 parents, the request will fail with an INVALID_ARGUMENT + * error. + * + * The async variant is {@see MetadataServiceClient::addContextChildrenAsync()} . + * + * @example samples/V1/MetadataServiceClient/add_context_children.php + * + * @param AddContextChildrenRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AddContextChildrenResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addContextChildren(AddContextChildrenRequest $request, array $callOptions = []): AddContextChildrenResponse + { + return $this->startApiCall('AddContextChildren', $request, $callOptions)->wait(); + } + + /** + * Adds Events to the specified Execution. An Event indicates whether an + * Artifact was used as an input or output for an Execution. If an Event + * already exists between the Execution and the Artifact, the Event is + * skipped. + * + * The async variant is {@see MetadataServiceClient::addExecutionEventsAsync()} . + * + * @example samples/V1/MetadataServiceClient/add_execution_events.php + * + * @param AddExecutionEventsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AddExecutionEventsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addExecutionEvents(AddExecutionEventsRequest $request, array $callOptions = []): AddExecutionEventsResponse + { + return $this->startApiCall('AddExecutionEvents', $request, $callOptions)->wait(); + } + + /** + * Creates an Artifact associated with a MetadataStore. + * + * The async variant is {@see MetadataServiceClient::createArtifactAsync()} . + * + * @example samples/V1/MetadataServiceClient/create_artifact.php + * + * @param CreateArtifactRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Artifact + * + * @throws ApiException Thrown if the API call fails. + */ + public function createArtifact(CreateArtifactRequest $request, array $callOptions = []): Artifact + { + return $this->startApiCall('CreateArtifact', $request, $callOptions)->wait(); + } + + /** + * Creates a Context associated with a MetadataStore. + * + * The async variant is {@see MetadataServiceClient::createContextAsync()} . + * + * @example samples/V1/MetadataServiceClient/create_context.php + * + * @param CreateContextRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Context + * + * @throws ApiException Thrown if the API call fails. + */ + public function createContext(CreateContextRequest $request, array $callOptions = []): Context + { + return $this->startApiCall('CreateContext', $request, $callOptions)->wait(); + } + + /** + * Creates an Execution associated with a MetadataStore. + * + * The async variant is {@see MetadataServiceClient::createExecutionAsync()} . + * + * @example samples/V1/MetadataServiceClient/create_execution.php + * + * @param CreateExecutionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Execution + * + * @throws ApiException Thrown if the API call fails. + */ + public function createExecution(CreateExecutionRequest $request, array $callOptions = []): Execution + { + return $this->startApiCall('CreateExecution', $request, $callOptions)->wait(); + } + + /** + * Creates a MetadataSchema. + * + * The async variant is {@see MetadataServiceClient::createMetadataSchemaAsync()} . + * + * @example samples/V1/MetadataServiceClient/create_metadata_schema.php + * + * @param CreateMetadataSchemaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MetadataSchema + * + * @throws ApiException Thrown if the API call fails. + */ + public function createMetadataSchema(CreateMetadataSchemaRequest $request, array $callOptions = []): MetadataSchema + { + return $this->startApiCall('CreateMetadataSchema', $request, $callOptions)->wait(); + } + + /** + * Initializes a MetadataStore, including allocation of resources. + * + * The async variant is {@see MetadataServiceClient::createMetadataStoreAsync()} . + * + * @example samples/V1/MetadataServiceClient/create_metadata_store.php + * + * @param CreateMetadataStoreRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createMetadataStore(CreateMetadataStoreRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateMetadataStore', $request, $callOptions)->wait(); + } + + /** + * Deletes an Artifact. + * + * The async variant is {@see MetadataServiceClient::deleteArtifactAsync()} . + * + * @example samples/V1/MetadataServiceClient/delete_artifact.php + * + * @param DeleteArtifactRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteArtifact(DeleteArtifactRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteArtifact', $request, $callOptions)->wait(); + } + + /** + * Deletes a stored Context. + * + * The async variant is {@see MetadataServiceClient::deleteContextAsync()} . + * + * @example samples/V1/MetadataServiceClient/delete_context.php + * + * @param DeleteContextRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteContext(DeleteContextRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteContext', $request, $callOptions)->wait(); + } + + /** + * Deletes an Execution. + * + * The async variant is {@see MetadataServiceClient::deleteExecutionAsync()} . + * + * @example samples/V1/MetadataServiceClient/delete_execution.php + * + * @param DeleteExecutionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteExecution(DeleteExecutionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteExecution', $request, $callOptions)->wait(); + } + + /** + * Deletes a single MetadataStore and all its child resources (Artifacts, + * Executions, and Contexts). + * + * The async variant is {@see MetadataServiceClient::deleteMetadataStoreAsync()} . + * + * @example samples/V1/MetadataServiceClient/delete_metadata_store.php + * + * @param DeleteMetadataStoreRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteMetadataStore(DeleteMetadataStoreRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteMetadataStore', $request, $callOptions)->wait(); + } + + /** + * Retrieves a specific Artifact. + * + * The async variant is {@see MetadataServiceClient::getArtifactAsync()} . + * + * @example samples/V1/MetadataServiceClient/get_artifact.php + * + * @param GetArtifactRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Artifact + * + * @throws ApiException Thrown if the API call fails. + */ + public function getArtifact(GetArtifactRequest $request, array $callOptions = []): Artifact + { + return $this->startApiCall('GetArtifact', $request, $callOptions)->wait(); + } + + /** + * Retrieves a specific Context. + * + * The async variant is {@see MetadataServiceClient::getContextAsync()} . + * + * @example samples/V1/MetadataServiceClient/get_context.php + * + * @param GetContextRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Context + * + * @throws ApiException Thrown if the API call fails. + */ + public function getContext(GetContextRequest $request, array $callOptions = []): Context + { + return $this->startApiCall('GetContext', $request, $callOptions)->wait(); + } + + /** + * Retrieves a specific Execution. + * + * The async variant is {@see MetadataServiceClient::getExecutionAsync()} . + * + * @example samples/V1/MetadataServiceClient/get_execution.php + * + * @param GetExecutionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Execution + * + * @throws ApiException Thrown if the API call fails. + */ + public function getExecution(GetExecutionRequest $request, array $callOptions = []): Execution + { + return $this->startApiCall('GetExecution', $request, $callOptions)->wait(); + } + + /** + * Retrieves a specific MetadataSchema. + * + * The async variant is {@see MetadataServiceClient::getMetadataSchemaAsync()} . + * + * @example samples/V1/MetadataServiceClient/get_metadata_schema.php + * + * @param GetMetadataSchemaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MetadataSchema + * + * @throws ApiException Thrown if the API call fails. + */ + public function getMetadataSchema(GetMetadataSchemaRequest $request, array $callOptions = []): MetadataSchema + { + return $this->startApiCall('GetMetadataSchema', $request, $callOptions)->wait(); + } + + /** + * Retrieves a specific MetadataStore. + * + * The async variant is {@see MetadataServiceClient::getMetadataStoreAsync()} . + * + * @example samples/V1/MetadataServiceClient/get_metadata_store.php + * + * @param GetMetadataStoreRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MetadataStore + * + * @throws ApiException Thrown if the API call fails. + */ + public function getMetadataStore(GetMetadataStoreRequest $request, array $callOptions = []): MetadataStore + { + return $this->startApiCall('GetMetadataStore', $request, $callOptions)->wait(); + } + + /** + * Lists Artifacts in the MetadataStore. + * + * The async variant is {@see MetadataServiceClient::listArtifactsAsync()} . + * + * @example samples/V1/MetadataServiceClient/list_artifacts.php + * + * @param ListArtifactsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listArtifacts(ListArtifactsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListArtifacts', $request, $callOptions); + } + + /** + * Lists Contexts on the MetadataStore. + * + * The async variant is {@see MetadataServiceClient::listContextsAsync()} . + * + * @example samples/V1/MetadataServiceClient/list_contexts.php + * + * @param ListContextsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listContexts(ListContextsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListContexts', $request, $callOptions); + } + + /** + * Lists Executions in the MetadataStore. + * + * The async variant is {@see MetadataServiceClient::listExecutionsAsync()} . + * + * @example samples/V1/MetadataServiceClient/list_executions.php + * + * @param ListExecutionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listExecutions(ListExecutionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListExecutions', $request, $callOptions); + } + + /** + * Lists MetadataSchemas. + * + * The async variant is {@see MetadataServiceClient::listMetadataSchemasAsync()} . + * + * @example samples/V1/MetadataServiceClient/list_metadata_schemas.php + * + * @param ListMetadataSchemasRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listMetadataSchemas(ListMetadataSchemasRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListMetadataSchemas', $request, $callOptions); + } + + /** + * Lists MetadataStores for a Location. + * + * The async variant is {@see MetadataServiceClient::listMetadataStoresAsync()} . + * + * @example samples/V1/MetadataServiceClient/list_metadata_stores.php + * + * @param ListMetadataStoresRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listMetadataStores(ListMetadataStoresRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListMetadataStores', $request, $callOptions); + } + + /** + * Purges Artifacts. + * + * The async variant is {@see MetadataServiceClient::purgeArtifactsAsync()} . + * + * @example samples/V1/MetadataServiceClient/purge_artifacts.php + * + * @param PurgeArtifactsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function purgeArtifacts(PurgeArtifactsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('PurgeArtifacts', $request, $callOptions)->wait(); + } + + /** + * Purges Contexts. + * + * The async variant is {@see MetadataServiceClient::purgeContextsAsync()} . + * + * @example samples/V1/MetadataServiceClient/purge_contexts.php + * + * @param PurgeContextsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function purgeContexts(PurgeContextsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('PurgeContexts', $request, $callOptions)->wait(); + } + + /** + * Purges Executions. + * + * The async variant is {@see MetadataServiceClient::purgeExecutionsAsync()} . + * + * @example samples/V1/MetadataServiceClient/purge_executions.php + * + * @param PurgeExecutionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function purgeExecutions(PurgeExecutionsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('PurgeExecutions', $request, $callOptions)->wait(); + } + + /** + * Retrieves lineage of an Artifact represented through Artifacts and + * Executions connected by Event edges and returned as a LineageSubgraph. + * + * The async variant is + * {@see MetadataServiceClient::queryArtifactLineageSubgraphAsync()} . + * + * @example samples/V1/MetadataServiceClient/query_artifact_lineage_subgraph.php + * + * @param QueryArtifactLineageSubgraphRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LineageSubgraph + * + * @throws ApiException Thrown if the API call fails. + */ + public function queryArtifactLineageSubgraph(QueryArtifactLineageSubgraphRequest $request, array $callOptions = []): LineageSubgraph + { + return $this->startApiCall('QueryArtifactLineageSubgraph', $request, $callOptions)->wait(); + } + + /** + * Retrieves Artifacts and Executions within the specified Context, connected + * by Event edges and returned as a LineageSubgraph. + * + * The async variant is + * {@see MetadataServiceClient::queryContextLineageSubgraphAsync()} . + * + * @example samples/V1/MetadataServiceClient/query_context_lineage_subgraph.php + * + * @param QueryContextLineageSubgraphRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LineageSubgraph + * + * @throws ApiException Thrown if the API call fails. + */ + public function queryContextLineageSubgraph(QueryContextLineageSubgraphRequest $request, array $callOptions = []): LineageSubgraph + { + return $this->startApiCall('QueryContextLineageSubgraph', $request, $callOptions)->wait(); + } + + /** + * Obtains the set of input and output Artifacts for this Execution, in the + * form of LineageSubgraph that also contains the Execution and connecting + * Events. + * + * The async variant is + * {@see MetadataServiceClient::queryExecutionInputsAndOutputsAsync()} . + * + * @example samples/V1/MetadataServiceClient/query_execution_inputs_and_outputs.php + * + * @param QueryExecutionInputsAndOutputsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LineageSubgraph + * + * @throws ApiException Thrown if the API call fails. + */ + public function queryExecutionInputsAndOutputs(QueryExecutionInputsAndOutputsRequest $request, array $callOptions = []): LineageSubgraph + { + return $this->startApiCall('QueryExecutionInputsAndOutputs', $request, $callOptions)->wait(); + } + + /** + * Remove a set of children contexts from a parent Context. If any of the + * child Contexts were NOT added to the parent Context, they are + * simply skipped. + * + * The async variant is {@see MetadataServiceClient::removeContextChildrenAsync()} + * . + * + * @example samples/V1/MetadataServiceClient/remove_context_children.php + * + * @param RemoveContextChildrenRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RemoveContextChildrenResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeContextChildren(RemoveContextChildrenRequest $request, array $callOptions = []): RemoveContextChildrenResponse + { + return $this->startApiCall('RemoveContextChildren', $request, $callOptions)->wait(); + } + + /** + * Updates a stored Artifact. + * + * The async variant is {@see MetadataServiceClient::updateArtifactAsync()} . + * + * @example samples/V1/MetadataServiceClient/update_artifact.php + * + * @param UpdateArtifactRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Artifact + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateArtifact(UpdateArtifactRequest $request, array $callOptions = []): Artifact + { + return $this->startApiCall('UpdateArtifact', $request, $callOptions)->wait(); + } + + /** + * Updates a stored Context. + * + * The async variant is {@see MetadataServiceClient::updateContextAsync()} . + * + * @example samples/V1/MetadataServiceClient/update_context.php + * + * @param UpdateContextRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Context + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateContext(UpdateContextRequest $request, array $callOptions = []): Context + { + return $this->startApiCall('UpdateContext', $request, $callOptions)->wait(); + } + + /** + * Updates a stored Execution. + * + * The async variant is {@see MetadataServiceClient::updateExecutionAsync()} . + * + * @example samples/V1/MetadataServiceClient/update_execution.php + * + * @param UpdateExecutionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Execution + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateExecution(UpdateExecutionRequest $request, array $callOptions = []): Execution + { + return $this->startApiCall('UpdateExecution', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see MetadataServiceClient::getLocationAsync()} . + * + * @example samples/V1/MetadataServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see MetadataServiceClient::listLocationsAsync()} . + * + * @example samples/V1/MetadataServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see MetadataServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/MetadataServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see MetadataServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/MetadataServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see MetadataServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/MetadataServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/AiPlatform/src/V1/Client/MigrationServiceClient.php b/AiPlatform/src/V1/Client/MigrationServiceClient.php index 34f991564ff1..8a9416cc04c3 100644 --- a/AiPlatform/src/V1/Client/MigrationServiceClient.php +++ b/AiPlatform/src/V1/Client/MigrationServiceClient.php @@ -24,17 +24,516 @@ namespace Google\Cloud\AIPlatform\V1\Client; -use Google\Cloud\AIPlatform\V1\Client\BaseClient\MigrationServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AIPlatform\V1\BatchMigrateResourcesRequest; +use Google\Cloud\AIPlatform\V1\SearchMigratableResourcesRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service that migrates resources from automl.googleapis.com, + * datalabeling.googleapis.com and ml.googleapis.com to Vertex AI. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AIPlatform\V1\MigrationServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface batchMigrateResourcesAsync(BatchMigrateResourcesRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchMigratableResourcesAsync(SearchMigratableResourcesRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class MigrationServiceClient extends MigrationServiceBaseClient +final class MigrationServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see MigrationServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.aiplatform.v1.MigrationService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'aiplatform.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/migration_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/migration_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/migration_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/migration_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * annotated_dataset resource. + * + * @param string $project + * @param string $dataset + * @param string $annotatedDataset + * + * @return string The formatted annotated_dataset resource. + */ + public static function annotatedDatasetName(string $project, string $dataset, string $annotatedDataset): string + { + return self::getPathTemplate('annotatedDataset')->render([ + 'project' => $project, + 'dataset' => $dataset, + 'annotated_dataset' => $annotatedDataset, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a dataset + * resource. + * + * @param string $project + * @param string $location + * @param string $dataset + * + * @return string The formatted dataset resource. + */ + public static function datasetName(string $project, string $location, string $dataset): string + { + return self::getPathTemplate('dataset')->render([ + 'project' => $project, + 'location' => $location, + 'dataset' => $dataset, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a model + * resource. + * + * @param string $project + * @param string $location + * @param string $model + * + * @return string The formatted model resource. + */ + public static function modelName(string $project, string $location, string $model): string + { + return self::getPathTemplate('model')->render([ + 'project' => $project, + 'location' => $location, + 'model' => $model, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a version + * resource. + * + * @param string $project + * @param string $model + * @param string $version + * + * @return string The formatted version resource. + */ + public static function versionName(string $project, string $model, string $version): string + { + return self::getPathTemplate('version')->render([ + 'project' => $project, + 'model' => $model, + 'version' => $version, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - annotatedDataset: projects/{project}/datasets/{dataset}/annotatedDatasets/{annotated_dataset} + * - dataset: projects/{project}/locations/{location}/datasets/{dataset} + * - location: projects/{project}/locations/{location} + * - model: projects/{project}/locations/{location}/models/{model} + * - version: projects/{project}/models/{model}/versions/{version} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'aiplatform.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Batch migrates resources from ml.googleapis.com, automl.googleapis.com, + * and datalabeling.googleapis.com to Vertex AI. + * + * The async variant is {@see MigrationServiceClient::batchMigrateResourcesAsync()} + * . + * + * @example samples/V1/MigrationServiceClient/batch_migrate_resources.php + * + * @param BatchMigrateResourcesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchMigrateResources(BatchMigrateResourcesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchMigrateResources', $request, $callOptions)->wait(); + } + + /** + * Searches all of the resources in automl.googleapis.com, + * datalabeling.googleapis.com and ml.googleapis.com that can be migrated to + * Vertex AI's given location. + * + * The async variant is + * {@see MigrationServiceClient::searchMigratableResourcesAsync()} . + * + * @example samples/V1/MigrationServiceClient/search_migratable_resources.php + * + * @param SearchMigratableResourcesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchMigratableResources(SearchMigratableResourcesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchMigratableResources', $request, $callOptions); + } + + /** + * Gets information about a location. + * + * The async variant is {@see MigrationServiceClient::getLocationAsync()} . + * + * @example samples/V1/MigrationServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see MigrationServiceClient::listLocationsAsync()} . + * + * @example samples/V1/MigrationServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see MigrationServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/MigrationServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see MigrationServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/MigrationServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see MigrationServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/MigrationServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/AiPlatform/src/V1/Client/ModelGardenServiceClient.php b/AiPlatform/src/V1/Client/ModelGardenServiceClient.php index 9b35bb028e8e..9ca028188a07 100644 --- a/AiPlatform/src/V1/Client/ModelGardenServiceClient.php +++ b/AiPlatform/src/V1/Client/ModelGardenServiceClient.php @@ -24,17 +24,369 @@ namespace Google\Cloud\AIPlatform\V1\Client; -use Google\Cloud\AIPlatform\V1\Client\BaseClient\ModelGardenServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AIPlatform\V1\GetPublisherModelRequest; +use Google\Cloud\AIPlatform\V1\PublisherModel; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The interface of Model Garden Service. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AIPlatform\V1\ModelGardenServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface getPublisherModelAsync(GetPublisherModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class ModelGardenServiceClient extends ModelGardenServiceBaseClient +final class ModelGardenServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ModelGardenServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.aiplatform.v1.ModelGardenService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'aiplatform.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/model_garden_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/model_garden_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/model_garden_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/model_garden_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * publisher_model resource. + * + * @param string $publisher + * @param string $model + * + * @return string The formatted publisher_model resource. + */ + public static function publisherModelName(string $publisher, string $model): string + { + return self::getPathTemplate('publisherModel')->render([ + 'publisher' => $publisher, + 'model' => $model, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - publisherModel: publishers/{publisher}/models/{model} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'aiplatform.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Gets a Model Garden publisher model. + * + * The async variant is {@see ModelGardenServiceClient::getPublisherModelAsync()} . + * + * @example samples/V1/ModelGardenServiceClient/get_publisher_model.php + * + * @param GetPublisherModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PublisherModel + * + * @throws ApiException Thrown if the API call fails. + */ + public function getPublisherModel(GetPublisherModelRequest $request, array $callOptions = []): PublisherModel + { + return $this->startApiCall('GetPublisherModel', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see ModelGardenServiceClient::getLocationAsync()} . + * + * @example samples/V1/ModelGardenServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see ModelGardenServiceClient::listLocationsAsync()} . + * + * @example samples/V1/ModelGardenServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see ModelGardenServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/ModelGardenServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see ModelGardenServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/ModelGardenServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see ModelGardenServiceClient::testIamPermissionsAsync()} + * . + * + * @example samples/V1/ModelGardenServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/AiPlatform/src/V1/Client/ModelServiceClient.php b/AiPlatform/src/V1/Client/ModelServiceClient.php index 557c0c469aca..33e3a065f0aa 100644 --- a/AiPlatform/src/V1/Client/ModelServiceClient.php +++ b/AiPlatform/src/V1/Client/ModelServiceClient.php @@ -24,17 +24,1075 @@ namespace Google\Cloud\AIPlatform\V1\Client; -use Google\Cloud\AIPlatform\V1\Client\BaseClient\ModelServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AIPlatform\V1\BatchImportEvaluatedAnnotationsRequest; +use Google\Cloud\AIPlatform\V1\BatchImportEvaluatedAnnotationsResponse; +use Google\Cloud\AIPlatform\V1\BatchImportModelEvaluationSlicesRequest; +use Google\Cloud\AIPlatform\V1\BatchImportModelEvaluationSlicesResponse; +use Google\Cloud\AIPlatform\V1\CopyModelRequest; +use Google\Cloud\AIPlatform\V1\DeleteModelRequest; +use Google\Cloud\AIPlatform\V1\DeleteModelVersionRequest; +use Google\Cloud\AIPlatform\V1\ExportModelRequest; +use Google\Cloud\AIPlatform\V1\GetModelEvaluationRequest; +use Google\Cloud\AIPlatform\V1\GetModelEvaluationSliceRequest; +use Google\Cloud\AIPlatform\V1\GetModelRequest; +use Google\Cloud\AIPlatform\V1\ImportModelEvaluationRequest; +use Google\Cloud\AIPlatform\V1\ListModelEvaluationSlicesRequest; +use Google\Cloud\AIPlatform\V1\ListModelEvaluationsRequest; +use Google\Cloud\AIPlatform\V1\ListModelVersionsRequest; +use Google\Cloud\AIPlatform\V1\ListModelsRequest; +use Google\Cloud\AIPlatform\V1\MergeVersionAliasesRequest; +use Google\Cloud\AIPlatform\V1\Model; +use Google\Cloud\AIPlatform\V1\ModelEvaluation; +use Google\Cloud\AIPlatform\V1\ModelEvaluationSlice; +use Google\Cloud\AIPlatform\V1\UpdateExplanationDatasetRequest; +use Google\Cloud\AIPlatform\V1\UpdateModelRequest; +use Google\Cloud\AIPlatform\V1\UploadModelRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service for managing Vertex AI's machine learning Models. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AIPlatform\V1\ModelServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface batchImportEvaluatedAnnotationsAsync(BatchImportEvaluatedAnnotationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface batchImportModelEvaluationSlicesAsync(BatchImportModelEvaluationSlicesRequest $request, array $optionalArgs = []) + * @method PromiseInterface copyModelAsync(CopyModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteModelAsync(DeleteModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteModelVersionAsync(DeleteModelVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface exportModelAsync(ExportModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface getModelAsync(GetModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface getModelEvaluationAsync(GetModelEvaluationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getModelEvaluationSliceAsync(GetModelEvaluationSliceRequest $request, array $optionalArgs = []) + * @method PromiseInterface importModelEvaluationAsync(ImportModelEvaluationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listModelEvaluationSlicesAsync(ListModelEvaluationSlicesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listModelEvaluationsAsync(ListModelEvaluationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listModelVersionsAsync(ListModelVersionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listModelsAsync(ListModelsRequest $request, array $optionalArgs = []) + * @method PromiseInterface mergeVersionAliasesAsync(MergeVersionAliasesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateExplanationDatasetAsync(UpdateExplanationDatasetRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateModelAsync(UpdateModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface uploadModelAsync(UploadModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class ModelServiceClient extends ModelServiceBaseClient +final class ModelServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ModelServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.aiplatform.v1.ModelService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'aiplatform.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/model_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/model_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/model_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/model_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a endpoint + * resource. + * + * @param string $project + * @param string $location + * @param string $endpoint + * + * @return string The formatted endpoint resource. + */ + public static function endpointName(string $project, string $location, string $endpoint): string + { + return self::getPathTemplate('endpoint')->render([ + 'project' => $project, + 'location' => $location, + 'endpoint' => $endpoint, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a model + * resource. + * + * @param string $project + * @param string $location + * @param string $model + * + * @return string The formatted model resource. + */ + public static function modelName(string $project, string $location, string $model): string + { + return self::getPathTemplate('model')->render([ + 'project' => $project, + 'location' => $location, + 'model' => $model, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * model_evaluation resource. + * + * @param string $project + * @param string $location + * @param string $model + * @param string $evaluation + * + * @return string The formatted model_evaluation resource. + */ + public static function modelEvaluationName(string $project, string $location, string $model, string $evaluation): string + { + return self::getPathTemplate('modelEvaluation')->render([ + 'project' => $project, + 'location' => $location, + 'model' => $model, + 'evaluation' => $evaluation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * model_evaluation_slice resource. + * + * @param string $project + * @param string $location + * @param string $model + * @param string $evaluation + * @param string $slice + * + * @return string The formatted model_evaluation_slice resource. + */ + public static function modelEvaluationSliceName(string $project, string $location, string $model, string $evaluation, string $slice): string + { + return self::getPathTemplate('modelEvaluationSlice')->render([ + 'project' => $project, + 'location' => $location, + 'model' => $model, + 'evaluation' => $evaluation, + 'slice' => $slice, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a pipeline_job + * resource. + * + * @param string $project + * @param string $location + * @param string $pipelineJob + * + * @return string The formatted pipeline_job resource. + */ + public static function pipelineJobName(string $project, string $location, string $pipelineJob): string + { + return self::getPathTemplate('pipelineJob')->render([ + 'project' => $project, + 'location' => $location, + 'pipeline_job' => $pipelineJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_endpoint resource. + * + * @param string $project + * @param string $location + * @param string $endpoint + * + * @return string The formatted project_location_endpoint resource. + */ + public static function projectLocationEndpointName(string $project, string $location, string $endpoint): string + { + return self::getPathTemplate('projectLocationEndpoint')->render([ + 'project' => $project, + 'location' => $location, + 'endpoint' => $endpoint, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_publisher_model resource. + * + * @param string $project + * @param string $location + * @param string $publisher + * @param string $model + * + * @return string The formatted project_location_publisher_model resource. + */ + public static function projectLocationPublisherModelName(string $project, string $location, string $publisher, string $model): string + { + return self::getPathTemplate('projectLocationPublisherModel')->render([ + 'project' => $project, + 'location' => $location, + 'publisher' => $publisher, + 'model' => $model, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * training_pipeline resource. + * + * @param string $project + * @param string $location + * @param string $trainingPipeline + * + * @return string The formatted training_pipeline resource. + */ + public static function trainingPipelineName(string $project, string $location, string $trainingPipeline): string + { + return self::getPathTemplate('trainingPipeline')->render([ + 'project' => $project, + 'location' => $location, + 'training_pipeline' => $trainingPipeline, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - endpoint: projects/{project}/locations/{location}/endpoints/{endpoint} + * - location: projects/{project}/locations/{location} + * - model: projects/{project}/locations/{location}/models/{model} + * - modelEvaluation: projects/{project}/locations/{location}/models/{model}/evaluations/{evaluation} + * - modelEvaluationSlice: projects/{project}/locations/{location}/models/{model}/evaluations/{evaluation}/slices/{slice} + * - pipelineJob: projects/{project}/locations/{location}/pipelineJobs/{pipeline_job} + * - projectLocationEndpoint: projects/{project}/locations/{location}/endpoints/{endpoint} + * - projectLocationPublisherModel: projects/{project}/locations/{location}/publishers/{publisher}/models/{model} + * - trainingPipeline: projects/{project}/locations/{location}/trainingPipelines/{training_pipeline} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'aiplatform.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Imports a list of externally generated EvaluatedAnnotations. + * + * The async variant is + * {@see ModelServiceClient::batchImportEvaluatedAnnotationsAsync()} . + * + * @example samples/V1/ModelServiceClient/batch_import_evaluated_annotations.php + * + * @param BatchImportEvaluatedAnnotationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BatchImportEvaluatedAnnotationsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchImportEvaluatedAnnotations(BatchImportEvaluatedAnnotationsRequest $request, array $callOptions = []): BatchImportEvaluatedAnnotationsResponse + { + return $this->startApiCall('BatchImportEvaluatedAnnotations', $request, $callOptions)->wait(); + } + + /** + * Imports a list of externally generated ModelEvaluationSlice. + * + * The async variant is + * {@see ModelServiceClient::batchImportModelEvaluationSlicesAsync()} . + * + * @example samples/V1/ModelServiceClient/batch_import_model_evaluation_slices.php + * + * @param BatchImportModelEvaluationSlicesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BatchImportModelEvaluationSlicesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchImportModelEvaluationSlices(BatchImportModelEvaluationSlicesRequest $request, array $callOptions = []): BatchImportModelEvaluationSlicesResponse + { + return $this->startApiCall('BatchImportModelEvaluationSlices', $request, $callOptions)->wait(); + } + + /** + * Copies an already existing Vertex AI Model into the specified Location. + * The source Model must exist in the same Project. + * When copying custom Models, the users themselves are responsible for + * [Model.metadata][google.cloud.aiplatform.v1.Model.metadata] content to be + * region-agnostic, as well as making sure that any resources (e.g. files) it + * depends on remain accessible. + * + * The async variant is {@see ModelServiceClient::copyModelAsync()} . + * + * @example samples/V1/ModelServiceClient/copy_model.php + * + * @param CopyModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function copyModel(CopyModelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CopyModel', $request, $callOptions)->wait(); + } + + /** + * Deletes a Model. + * + * A model cannot be deleted if any + * [Endpoint][google.cloud.aiplatform.v1.Endpoint] resource has a + * [DeployedModel][google.cloud.aiplatform.v1.DeployedModel] based on the + * model in its + * [deployed_models][google.cloud.aiplatform.v1.Endpoint.deployed_models] + * field. + * + * The async variant is {@see ModelServiceClient::deleteModelAsync()} . + * + * @example samples/V1/ModelServiceClient/delete_model.php + * + * @param DeleteModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteModel(DeleteModelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteModel', $request, $callOptions)->wait(); + } + + /** + * Deletes a Model version. + * + * Model version can only be deleted if there are no + * [DeployedModels][google.cloud.aiplatform.v1.DeployedModel] created from it. + * Deleting the only version in the Model is not allowed. Use + * [DeleteModel][google.cloud.aiplatform.v1.ModelService.DeleteModel] for + * deleting the Model instead. + * + * The async variant is {@see ModelServiceClient::deleteModelVersionAsync()} . + * + * @example samples/V1/ModelServiceClient/delete_model_version.php + * + * @param DeleteModelVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteModelVersion(DeleteModelVersionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteModelVersion', $request, $callOptions)->wait(); + } + + /** + * Exports a trained, exportable Model to a location specified by the + * user. A Model is considered to be exportable if it has at least one + * [supported export + * format][google.cloud.aiplatform.v1.Model.supported_export_formats]. + * + * The async variant is {@see ModelServiceClient::exportModelAsync()} . + * + * @example samples/V1/ModelServiceClient/export_model.php + * + * @param ExportModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportModel(ExportModelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ExportModel', $request, $callOptions)->wait(); + } + + /** + * Gets a Model. + * + * The async variant is {@see ModelServiceClient::getModelAsync()} . + * + * @example samples/V1/ModelServiceClient/get_model.php + * + * @param GetModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Model + * + * @throws ApiException Thrown if the API call fails. + */ + public function getModel(GetModelRequest $request, array $callOptions = []): Model + { + return $this->startApiCall('GetModel', $request, $callOptions)->wait(); + } + + /** + * Gets a ModelEvaluation. + * + * The async variant is {@see ModelServiceClient::getModelEvaluationAsync()} . + * + * @example samples/V1/ModelServiceClient/get_model_evaluation.php + * + * @param GetModelEvaluationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ModelEvaluation + * + * @throws ApiException Thrown if the API call fails. + */ + public function getModelEvaluation(GetModelEvaluationRequest $request, array $callOptions = []): ModelEvaluation + { + return $this->startApiCall('GetModelEvaluation', $request, $callOptions)->wait(); + } + + /** + * Gets a ModelEvaluationSlice. + * + * The async variant is {@see ModelServiceClient::getModelEvaluationSliceAsync()} . + * + * @example samples/V1/ModelServiceClient/get_model_evaluation_slice.php + * + * @param GetModelEvaluationSliceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ModelEvaluationSlice + * + * @throws ApiException Thrown if the API call fails. + */ + public function getModelEvaluationSlice(GetModelEvaluationSliceRequest $request, array $callOptions = []): ModelEvaluationSlice + { + return $this->startApiCall('GetModelEvaluationSlice', $request, $callOptions)->wait(); + } + + /** + * Imports an externally generated ModelEvaluation. + * + * The async variant is {@see ModelServiceClient::importModelEvaluationAsync()} . + * + * @example samples/V1/ModelServiceClient/import_model_evaluation.php + * + * @param ImportModelEvaluationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ModelEvaluation + * + * @throws ApiException Thrown if the API call fails. + */ + public function importModelEvaluation(ImportModelEvaluationRequest $request, array $callOptions = []): ModelEvaluation + { + return $this->startApiCall('ImportModelEvaluation', $request, $callOptions)->wait(); + } + + /** + * Lists ModelEvaluationSlices in a ModelEvaluation. + * + * The async variant is {@see ModelServiceClient::listModelEvaluationSlicesAsync()} + * . + * + * @example samples/V1/ModelServiceClient/list_model_evaluation_slices.php + * + * @param ListModelEvaluationSlicesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listModelEvaluationSlices(ListModelEvaluationSlicesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListModelEvaluationSlices', $request, $callOptions); + } + + /** + * Lists ModelEvaluations in a Model. + * + * The async variant is {@see ModelServiceClient::listModelEvaluationsAsync()} . + * + * @example samples/V1/ModelServiceClient/list_model_evaluations.php + * + * @param ListModelEvaluationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listModelEvaluations(ListModelEvaluationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListModelEvaluations', $request, $callOptions); + } + + /** + * Lists versions of the specified model. + * + * The async variant is {@see ModelServiceClient::listModelVersionsAsync()} . + * + * @example samples/V1/ModelServiceClient/list_model_versions.php + * + * @param ListModelVersionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listModelVersions(ListModelVersionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListModelVersions', $request, $callOptions); + } + + /** + * Lists Models in a Location. + * + * The async variant is {@see ModelServiceClient::listModelsAsync()} . + * + * @example samples/V1/ModelServiceClient/list_models.php + * + * @param ListModelsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listModels(ListModelsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListModels', $request, $callOptions); + } + + /** + * Merges a set of aliases for a Model version. + * + * The async variant is {@see ModelServiceClient::mergeVersionAliasesAsync()} . + * + * @example samples/V1/ModelServiceClient/merge_version_aliases.php + * + * @param MergeVersionAliasesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Model + * + * @throws ApiException Thrown if the API call fails. + */ + public function mergeVersionAliases(MergeVersionAliasesRequest $request, array $callOptions = []): Model + { + return $this->startApiCall('MergeVersionAliases', $request, $callOptions)->wait(); + } + + /** + * Incrementally update the dataset used for an examples model. + * + * The async variant is {@see ModelServiceClient::updateExplanationDatasetAsync()} + * . + * + * @example samples/V1/ModelServiceClient/update_explanation_dataset.php + * + * @param UpdateExplanationDatasetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateExplanationDataset(UpdateExplanationDatasetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateExplanationDataset', $request, $callOptions)->wait(); + } + + /** + * Updates a Model. + * + * The async variant is {@see ModelServiceClient::updateModelAsync()} . + * + * @example samples/V1/ModelServiceClient/update_model.php + * + * @param UpdateModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Model + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateModel(UpdateModelRequest $request, array $callOptions = []): Model + { + return $this->startApiCall('UpdateModel', $request, $callOptions)->wait(); + } + + /** + * Uploads a Model artifact into Vertex AI. + * + * The async variant is {@see ModelServiceClient::uploadModelAsync()} . + * + * @example samples/V1/ModelServiceClient/upload_model.php + * + * @param UploadModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function uploadModel(UploadModelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UploadModel', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see ModelServiceClient::getLocationAsync()} . + * + * @example samples/V1/ModelServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see ModelServiceClient::listLocationsAsync()} . + * + * @example samples/V1/ModelServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see ModelServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/ModelServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see ModelServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/ModelServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see ModelServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/ModelServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/AiPlatform/src/V1/Client/PipelineServiceClient.php b/AiPlatform/src/V1/Client/PipelineServiceClient.php index 19b541231277..96589631e879 100644 --- a/AiPlatform/src/V1/Client/PipelineServiceClient.php +++ b/AiPlatform/src/V1/Client/PipelineServiceClient.php @@ -24,17 +24,929 @@ namespace Google\Cloud\AIPlatform\V1\Client; -use Google\Cloud\AIPlatform\V1\Client\BaseClient\PipelineServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AIPlatform\V1\CancelPipelineJobRequest; +use Google\Cloud\AIPlatform\V1\CancelTrainingPipelineRequest; +use Google\Cloud\AIPlatform\V1\CreatePipelineJobRequest; +use Google\Cloud\AIPlatform\V1\CreateTrainingPipelineRequest; +use Google\Cloud\AIPlatform\V1\DeletePipelineJobRequest; +use Google\Cloud\AIPlatform\V1\DeleteTrainingPipelineRequest; +use Google\Cloud\AIPlatform\V1\GetPipelineJobRequest; +use Google\Cloud\AIPlatform\V1\GetTrainingPipelineRequest; +use Google\Cloud\AIPlatform\V1\ListPipelineJobsRequest; +use Google\Cloud\AIPlatform\V1\ListTrainingPipelinesRequest; +use Google\Cloud\AIPlatform\V1\PipelineJob; +use Google\Cloud\AIPlatform\V1\TrainingPipeline; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service for creating and managing Vertex AI's pipelines. This includes both + * `TrainingPipeline` resources (used for AutoML and custom training) and + * `PipelineJob` resources (used for Vertex AI Pipelines). * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AIPlatform\V1\PipelineServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface cancelPipelineJobAsync(CancelPipelineJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface cancelTrainingPipelineAsync(CancelTrainingPipelineRequest $request, array $optionalArgs = []) + * @method PromiseInterface createPipelineJobAsync(CreatePipelineJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface createTrainingPipelineAsync(CreateTrainingPipelineRequest $request, array $optionalArgs = []) + * @method PromiseInterface deletePipelineJobAsync(DeletePipelineJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTrainingPipelineAsync(DeleteTrainingPipelineRequest $request, array $optionalArgs = []) + * @method PromiseInterface getPipelineJobAsync(GetPipelineJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTrainingPipelineAsync(GetTrainingPipelineRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPipelineJobsAsync(ListPipelineJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTrainingPipelinesAsync(ListTrainingPipelinesRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class PipelineServiceClient extends PipelineServiceBaseClient +final class PipelineServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see PipelineServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.aiplatform.v1.PipelineService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'aiplatform.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/pipeline_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/pipeline_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/pipeline_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/pipeline_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a artifact + * resource. + * + * @param string $project + * @param string $location + * @param string $metadataStore + * @param string $artifact + * + * @return string The formatted artifact resource. + */ + public static function artifactName(string $project, string $location, string $metadataStore, string $artifact): string + { + return self::getPathTemplate('artifact')->render([ + 'project' => $project, + 'location' => $location, + 'metadata_store' => $metadataStore, + 'artifact' => $artifact, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a context + * resource. + * + * @param string $project + * @param string $location + * @param string $metadataStore + * @param string $context + * + * @return string The formatted context resource. + */ + public static function contextName(string $project, string $location, string $metadataStore, string $context): string + { + return self::getPathTemplate('context')->render([ + 'project' => $project, + 'location' => $location, + 'metadata_store' => $metadataStore, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a custom_job + * resource. + * + * @param string $project + * @param string $location + * @param string $customJob + * + * @return string The formatted custom_job resource. + */ + public static function customJobName(string $project, string $location, string $customJob): string + { + return self::getPathTemplate('customJob')->render([ + 'project' => $project, + 'location' => $location, + 'custom_job' => $customJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a endpoint + * resource. + * + * @param string $project + * @param string $location + * @param string $endpoint + * + * @return string The formatted endpoint resource. + */ + public static function endpointName(string $project, string $location, string $endpoint): string + { + return self::getPathTemplate('endpoint')->render([ + 'project' => $project, + 'location' => $location, + 'endpoint' => $endpoint, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a execution + * resource. + * + * @param string $project + * @param string $location + * @param string $metadataStore + * @param string $execution + * + * @return string The formatted execution resource. + */ + public static function executionName(string $project, string $location, string $metadataStore, string $execution): string + { + return self::getPathTemplate('execution')->render([ + 'project' => $project, + 'location' => $location, + 'metadata_store' => $metadataStore, + 'execution' => $execution, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * metadata_store resource. + * + * @param string $project + * @param string $location + * @param string $metadataStore + * + * @return string The formatted metadata_store resource. + */ + public static function metadataStoreName(string $project, string $location, string $metadataStore): string + { + return self::getPathTemplate('metadataStore')->render([ + 'project' => $project, + 'location' => $location, + 'metadata_store' => $metadataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a model + * resource. + * + * @param string $project + * @param string $location + * @param string $model + * + * @return string The formatted model resource. + */ + public static function modelName(string $project, string $location, string $model): string + { + return self::getPathTemplate('model')->render([ + 'project' => $project, + 'location' => $location, + 'model' => $model, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a network + * resource. + * + * @param string $project + * @param string $network + * + * @return string The formatted network resource. + */ + public static function networkName(string $project, string $network): string + { + return self::getPathTemplate('network')->render([ + 'project' => $project, + 'network' => $network, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a pipeline_job + * resource. + * + * @param string $project + * @param string $location + * @param string $pipelineJob + * + * @return string The formatted pipeline_job resource. + */ + public static function pipelineJobName(string $project, string $location, string $pipelineJob): string + { + return self::getPathTemplate('pipelineJob')->render([ + 'project' => $project, + 'location' => $location, + 'pipeline_job' => $pipelineJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_endpoint resource. + * + * @param string $project + * @param string $location + * @param string $endpoint + * + * @return string The formatted project_location_endpoint resource. + */ + public static function projectLocationEndpointName(string $project, string $location, string $endpoint): string + { + return self::getPathTemplate('projectLocationEndpoint')->render([ + 'project' => $project, + 'location' => $location, + 'endpoint' => $endpoint, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_publisher_model resource. + * + * @param string $project + * @param string $location + * @param string $publisher + * @param string $model + * + * @return string The formatted project_location_publisher_model resource. + */ + public static function projectLocationPublisherModelName(string $project, string $location, string $publisher, string $model): string + { + return self::getPathTemplate('projectLocationPublisherModel')->render([ + 'project' => $project, + 'location' => $location, + 'publisher' => $publisher, + 'model' => $model, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * training_pipeline resource. + * + * @param string $project + * @param string $location + * @param string $trainingPipeline + * + * @return string The formatted training_pipeline resource. + */ + public static function trainingPipelineName(string $project, string $location, string $trainingPipeline): string + { + return self::getPathTemplate('trainingPipeline')->render([ + 'project' => $project, + 'location' => $location, + 'training_pipeline' => $trainingPipeline, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - artifact: projects/{project}/locations/{location}/metadataStores/{metadata_store}/artifacts/{artifact} + * - context: projects/{project}/locations/{location}/metadataStores/{metadata_store}/contexts/{context} + * - customJob: projects/{project}/locations/{location}/customJobs/{custom_job} + * - endpoint: projects/{project}/locations/{location}/endpoints/{endpoint} + * - execution: projects/{project}/locations/{location}/metadataStores/{metadata_store}/executions/{execution} + * - location: projects/{project}/locations/{location} + * - metadataStore: projects/{project}/locations/{location}/metadataStores/{metadata_store} + * - model: projects/{project}/locations/{location}/models/{model} + * - network: projects/{project}/global/networks/{network} + * - pipelineJob: projects/{project}/locations/{location}/pipelineJobs/{pipeline_job} + * - projectLocationEndpoint: projects/{project}/locations/{location}/endpoints/{endpoint} + * - projectLocationPublisherModel: projects/{project}/locations/{location}/publishers/{publisher}/models/{model} + * - trainingPipeline: projects/{project}/locations/{location}/trainingPipelines/{training_pipeline} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'aiplatform.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Cancels a PipelineJob. + * Starts asynchronous cancellation on the PipelineJob. The server + * makes a best effort to cancel the pipeline, but success is not + * guaranteed. Clients can use + * [PipelineService.GetPipelineJob][google.cloud.aiplatform.v1.PipelineService.GetPipelineJob] + * or other methods to check whether the cancellation succeeded or whether the + * pipeline completed despite cancellation. On successful cancellation, + * the PipelineJob is not deleted; instead it becomes a pipeline with + * a [PipelineJob.error][google.cloud.aiplatform.v1.PipelineJob.error] value + * with a [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding + * to `Code.CANCELLED`, and + * [PipelineJob.state][google.cloud.aiplatform.v1.PipelineJob.state] is set to + * `CANCELLED`. + * + * The async variant is {@see PipelineServiceClient::cancelPipelineJobAsync()} . + * + * @example samples/V1/PipelineServiceClient/cancel_pipeline_job.php + * + * @param CancelPipelineJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function cancelPipelineJob(CancelPipelineJobRequest $request, array $callOptions = []): void + { + $this->startApiCall('CancelPipelineJob', $request, $callOptions)->wait(); + } + + /** + * Cancels a TrainingPipeline. + * Starts asynchronous cancellation on the TrainingPipeline. The server + * makes a best effort to cancel the pipeline, but success is not + * guaranteed. Clients can use + * [PipelineService.GetTrainingPipeline][google.cloud.aiplatform.v1.PipelineService.GetTrainingPipeline] + * or other methods to check whether the cancellation succeeded or whether the + * pipeline completed despite cancellation. On successful cancellation, + * the TrainingPipeline is not deleted; instead it becomes a pipeline with + * a + * [TrainingPipeline.error][google.cloud.aiplatform.v1.TrainingPipeline.error] + * value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, + * corresponding to `Code.CANCELLED`, and + * [TrainingPipeline.state][google.cloud.aiplatform.v1.TrainingPipeline.state] + * is set to `CANCELLED`. + * + * The async variant is {@see PipelineServiceClient::cancelTrainingPipelineAsync()} + * . + * + * @example samples/V1/PipelineServiceClient/cancel_training_pipeline.php + * + * @param CancelTrainingPipelineRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function cancelTrainingPipeline(CancelTrainingPipelineRequest $request, array $callOptions = []): void + { + $this->startApiCall('CancelTrainingPipeline', $request, $callOptions)->wait(); + } + + /** + * Creates a PipelineJob. A PipelineJob will run immediately when created. + * + * The async variant is {@see PipelineServiceClient::createPipelineJobAsync()} . + * + * @example samples/V1/PipelineServiceClient/create_pipeline_job.php + * + * @param CreatePipelineJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PipelineJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function createPipelineJob(CreatePipelineJobRequest $request, array $callOptions = []): PipelineJob + { + return $this->startApiCall('CreatePipelineJob', $request, $callOptions)->wait(); + } + + /** + * Creates a TrainingPipeline. A created TrainingPipeline right away will be + * attempted to be run. + * + * The async variant is {@see PipelineServiceClient::createTrainingPipelineAsync()} + * . + * + * @example samples/V1/PipelineServiceClient/create_training_pipeline.php + * + * @param CreateTrainingPipelineRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TrainingPipeline + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTrainingPipeline(CreateTrainingPipelineRequest $request, array $callOptions = []): TrainingPipeline + { + return $this->startApiCall('CreateTrainingPipeline', $request, $callOptions)->wait(); + } + + /** + * Deletes a PipelineJob. + * + * The async variant is {@see PipelineServiceClient::deletePipelineJobAsync()} . + * + * @example samples/V1/PipelineServiceClient/delete_pipeline_job.php + * + * @param DeletePipelineJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deletePipelineJob(DeletePipelineJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeletePipelineJob', $request, $callOptions)->wait(); + } + + /** + * Deletes a TrainingPipeline. + * + * The async variant is {@see PipelineServiceClient::deleteTrainingPipelineAsync()} + * . + * + * @example samples/V1/PipelineServiceClient/delete_training_pipeline.php + * + * @param DeleteTrainingPipelineRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTrainingPipeline(DeleteTrainingPipelineRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteTrainingPipeline', $request, $callOptions)->wait(); + } + + /** + * Gets a PipelineJob. + * + * The async variant is {@see PipelineServiceClient::getPipelineJobAsync()} . + * + * @example samples/V1/PipelineServiceClient/get_pipeline_job.php + * + * @param GetPipelineJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PipelineJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function getPipelineJob(GetPipelineJobRequest $request, array $callOptions = []): PipelineJob + { + return $this->startApiCall('GetPipelineJob', $request, $callOptions)->wait(); + } + + /** + * Gets a TrainingPipeline. + * + * The async variant is {@see PipelineServiceClient::getTrainingPipelineAsync()} . + * + * @example samples/V1/PipelineServiceClient/get_training_pipeline.php + * + * @param GetTrainingPipelineRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TrainingPipeline + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTrainingPipeline(GetTrainingPipelineRequest $request, array $callOptions = []): TrainingPipeline + { + return $this->startApiCall('GetTrainingPipeline', $request, $callOptions)->wait(); + } + + /** + * Lists PipelineJobs in a Location. + * + * The async variant is {@see PipelineServiceClient::listPipelineJobsAsync()} . + * + * @example samples/V1/PipelineServiceClient/list_pipeline_jobs.php + * + * @param ListPipelineJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPipelineJobs(ListPipelineJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPipelineJobs', $request, $callOptions); + } + + /** + * Lists TrainingPipelines in a Location. + * + * The async variant is {@see PipelineServiceClient::listTrainingPipelinesAsync()} + * . + * + * @example samples/V1/PipelineServiceClient/list_training_pipelines.php + * + * @param ListTrainingPipelinesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTrainingPipelines(ListTrainingPipelinesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTrainingPipelines', $request, $callOptions); + } + + /** + * Gets information about a location. + * + * The async variant is {@see PipelineServiceClient::getLocationAsync()} . + * + * @example samples/V1/PipelineServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see PipelineServiceClient::listLocationsAsync()} . + * + * @example samples/V1/PipelineServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see PipelineServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/PipelineServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see PipelineServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/PipelineServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see PipelineServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/PipelineServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/AiPlatform/src/V1/Client/PredictionServiceClient.php b/AiPlatform/src/V1/Client/PredictionServiceClient.php index 1123b9ebeeaa..1e4a21d4d423 100644 --- a/AiPlatform/src/V1/Client/PredictionServiceClient.php +++ b/AiPlatform/src/V1/Client/PredictionServiceClient.php @@ -24,17 +24,515 @@ namespace Google\Cloud\AIPlatform\V1\Client; -use Google\Cloud\AIPlatform\V1\Client\BaseClient\PredictionServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\ServerStream; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Api\HttpBody; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AIPlatform\V1\ExplainRequest; +use Google\Cloud\AIPlatform\V1\ExplainResponse; +use Google\Cloud\AIPlatform\V1\PredictRequest; +use Google\Cloud\AIPlatform\V1\PredictResponse; +use Google\Cloud\AIPlatform\V1\RawPredictRequest; +use Google\Cloud\AIPlatform\V1\StreamingPredictRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service for online predictions and explanations. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AIPlatform\V1\PredictionServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface explainAsync(ExplainRequest $request, array $optionalArgs = []) + * @method PromiseInterface predictAsync(PredictRequest $request, array $optionalArgs = []) + * @method PromiseInterface rawPredictAsync(RawPredictRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class PredictionServiceClient extends PredictionServiceBaseClient +final class PredictionServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see PredictionServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.aiplatform.v1.PredictionService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'aiplatform.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/prediction_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/prediction_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/prediction_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/prediction_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a endpoint + * resource. + * + * @param string $project + * @param string $location + * @param string $endpoint + * + * @return string The formatted endpoint resource. + */ + public static function endpointName(string $project, string $location, string $endpoint): string + { + return self::getPathTemplate('endpoint')->render([ + 'project' => $project, + 'location' => $location, + 'endpoint' => $endpoint, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_endpoint resource. + * + * @param string $project + * @param string $location + * @param string $endpoint + * + * @return string The formatted project_location_endpoint resource. + */ + public static function projectLocationEndpointName(string $project, string $location, string $endpoint): string + { + return self::getPathTemplate('projectLocationEndpoint')->render([ + 'project' => $project, + 'location' => $location, + 'endpoint' => $endpoint, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_publisher_model resource. + * + * @param string $project + * @param string $location + * @param string $publisher + * @param string $model + * + * @return string The formatted project_location_publisher_model resource. + */ + public static function projectLocationPublisherModelName(string $project, string $location, string $publisher, string $model): string + { + return self::getPathTemplate('projectLocationPublisherModel')->render([ + 'project' => $project, + 'location' => $location, + 'publisher' => $publisher, + 'model' => $model, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - endpoint: projects/{project}/locations/{location}/endpoints/{endpoint} + * - projectLocationEndpoint: projects/{project}/locations/{location}/endpoints/{endpoint} + * - projectLocationPublisherModel: projects/{project}/locations/{location}/publishers/{publisher}/models/{model} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'aiplatform.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Perform an online explanation. + * + * If + * [deployed_model_id][google.cloud.aiplatform.v1.ExplainRequest.deployed_model_id] + * is specified, the corresponding DeployModel must have + * [explanation_spec][google.cloud.aiplatform.v1.DeployedModel.explanation_spec] + * populated. If + * [deployed_model_id][google.cloud.aiplatform.v1.ExplainRequest.deployed_model_id] + * is not specified, all DeployedModels must have + * [explanation_spec][google.cloud.aiplatform.v1.DeployedModel.explanation_spec] + * populated. + * + * The async variant is {@see PredictionServiceClient::explainAsync()} . + * + * @example samples/V1/PredictionServiceClient/explain.php + * + * @param ExplainRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ExplainResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function explain(ExplainRequest $request, array $callOptions = []): ExplainResponse + { + return $this->startApiCall('Explain', $request, $callOptions)->wait(); + } + + /** + * Perform an online prediction. + * + * The async variant is {@see PredictionServiceClient::predictAsync()} . + * + * @example samples/V1/PredictionServiceClient/predict.php + * + * @param PredictRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PredictResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function predict(PredictRequest $request, array $callOptions = []): PredictResponse + { + return $this->startApiCall('Predict', $request, $callOptions)->wait(); + } + + /** + * Perform an online prediction with an arbitrary HTTP payload. + * + * The response includes the following HTTP headers: + * + * * `X-Vertex-AI-Endpoint-Id`: ID of the + * [Endpoint][google.cloud.aiplatform.v1.Endpoint] that served this + * prediction. + * + * * `X-Vertex-AI-Deployed-Model-Id`: ID of the Endpoint's + * [DeployedModel][google.cloud.aiplatform.v1.DeployedModel] that served this + * prediction. + * + * The async variant is {@see PredictionServiceClient::rawPredictAsync()} . + * + * @example samples/V1/PredictionServiceClient/raw_predict.php + * + * @param RawPredictRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 HttpBody + * + * @throws ApiException Thrown if the API call fails. + */ + public function rawPredict(RawPredictRequest $request, array $callOptions = []): HttpBody + { + return $this->startApiCall('RawPredict', $request, $callOptions)->wait(); + } + + /** + * Perform a server-side streaming online prediction request for Vertex + * LLM streaming. + * + * @example samples/V1/PredictionServiceClient/server_streaming_predict.php + * + * @param StreamingPredictRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return ServerStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function serverStreamingPredict(StreamingPredictRequest $request, array $callOptions = []): ServerStream + { + return $this->startApiCall('ServerStreamingPredict', $request, $callOptions); + } + + /** + * Gets information about a location. + * + * The async variant is {@see PredictionServiceClient::getLocationAsync()} . + * + * @example samples/V1/PredictionServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see PredictionServiceClient::listLocationsAsync()} . + * + * @example samples/V1/PredictionServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see PredictionServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/PredictionServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see PredictionServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/PredictionServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see PredictionServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/PredictionServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/AiPlatform/src/V1/Client/ScheduleServiceClient.php b/AiPlatform/src/V1/Client/ScheduleServiceClient.php index e58349fce1ce..866c528428db 100644 --- a/AiPlatform/src/V1/Client/ScheduleServiceClient.php +++ b/AiPlatform/src/V1/Client/ScheduleServiceClient.php @@ -24,17 +24,747 @@ namespace Google\Cloud\AIPlatform\V1\Client; -use Google\Cloud\AIPlatform\V1\Client\BaseClient\ScheduleServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AIPlatform\V1\CreateScheduleRequest; +use Google\Cloud\AIPlatform\V1\DeleteScheduleRequest; +use Google\Cloud\AIPlatform\V1\GetScheduleRequest; +use Google\Cloud\AIPlatform\V1\ListSchedulesRequest; +use Google\Cloud\AIPlatform\V1\PauseScheduleRequest; +use Google\Cloud\AIPlatform\V1\ResumeScheduleRequest; +use Google\Cloud\AIPlatform\V1\Schedule; +use Google\Cloud\AIPlatform\V1\UpdateScheduleRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service for creating and managing Vertex AI's Schedule resources to + * periodically launch shceudled runs to make API calls. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AIPlatform\V1\ScheduleServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createScheduleAsync(CreateScheduleRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteScheduleAsync(DeleteScheduleRequest $request, array $optionalArgs = []) + * @method PromiseInterface getScheduleAsync(GetScheduleRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSchedulesAsync(ListSchedulesRequest $request, array $optionalArgs = []) + * @method PromiseInterface pauseScheduleAsync(PauseScheduleRequest $request, array $optionalArgs = []) + * @method PromiseInterface resumeScheduleAsync(ResumeScheduleRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateScheduleAsync(UpdateScheduleRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class ScheduleServiceClient extends ScheduleServiceBaseClient +final class ScheduleServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ScheduleServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.aiplatform.v1.ScheduleService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'aiplatform.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/schedule_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/schedule_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/schedule_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/schedule_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a artifact + * resource. + * + * @param string $project + * @param string $location + * @param string $metadataStore + * @param string $artifact + * + * @return string The formatted artifact resource. + */ + public static function artifactName(string $project, string $location, string $metadataStore, string $artifact): string + { + return self::getPathTemplate('artifact')->render([ + 'project' => $project, + 'location' => $location, + 'metadata_store' => $metadataStore, + 'artifact' => $artifact, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a context + * resource. + * + * @param string $project + * @param string $location + * @param string $metadataStore + * @param string $context + * + * @return string The formatted context resource. + */ + public static function contextName(string $project, string $location, string $metadataStore, string $context): string + { + return self::getPathTemplate('context')->render([ + 'project' => $project, + 'location' => $location, + 'metadata_store' => $metadataStore, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a custom_job + * resource. + * + * @param string $project + * @param string $location + * @param string $customJob + * + * @return string The formatted custom_job resource. + */ + public static function customJobName(string $project, string $location, string $customJob): string + { + return self::getPathTemplate('customJob')->render([ + 'project' => $project, + 'location' => $location, + 'custom_job' => $customJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a execution + * resource. + * + * @param string $project + * @param string $location + * @param string $metadataStore + * @param string $execution + * + * @return string The formatted execution resource. + */ + public static function executionName(string $project, string $location, string $metadataStore, string $execution): string + { + return self::getPathTemplate('execution')->render([ + 'project' => $project, + 'location' => $location, + 'metadata_store' => $metadataStore, + 'execution' => $execution, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * metadata_store resource. + * + * @param string $project + * @param string $location + * @param string $metadataStore + * + * @return string The formatted metadata_store resource. + */ + public static function metadataStoreName(string $project, string $location, string $metadataStore): string + { + return self::getPathTemplate('metadataStore')->render([ + 'project' => $project, + 'location' => $location, + 'metadata_store' => $metadataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a network + * resource. + * + * @param string $project + * @param string $network + * + * @return string The formatted network resource. + */ + public static function networkName(string $project, string $network): string + { + return self::getPathTemplate('network')->render([ + 'project' => $project, + 'network' => $network, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a pipeline_job + * resource. + * + * @param string $project + * @param string $location + * @param string $pipelineJob + * + * @return string The formatted pipeline_job resource. + */ + public static function pipelineJobName(string $project, string $location, string $pipelineJob): string + { + return self::getPathTemplate('pipelineJob')->render([ + 'project' => $project, + 'location' => $location, + 'pipeline_job' => $pipelineJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a schedule + * resource. + * + * @param string $project + * @param string $location + * @param string $schedule + * + * @return string The formatted schedule resource. + */ + public static function scheduleName(string $project, string $location, string $schedule): string + { + return self::getPathTemplate('schedule')->render([ + 'project' => $project, + 'location' => $location, + 'schedule' => $schedule, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - artifact: projects/{project}/locations/{location}/metadataStores/{metadata_store}/artifacts/{artifact} + * - context: projects/{project}/locations/{location}/metadataStores/{metadata_store}/contexts/{context} + * - customJob: projects/{project}/locations/{location}/customJobs/{custom_job} + * - execution: projects/{project}/locations/{location}/metadataStores/{metadata_store}/executions/{execution} + * - location: projects/{project}/locations/{location} + * - metadataStore: projects/{project}/locations/{location}/metadataStores/{metadata_store} + * - network: projects/{project}/global/networks/{network} + * - pipelineJob: projects/{project}/locations/{location}/pipelineJobs/{pipeline_job} + * - schedule: projects/{project}/locations/{location}/schedules/{schedule} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'aiplatform.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a Schedule. + * + * The async variant is {@see ScheduleServiceClient::createScheduleAsync()} . + * + * @example samples/V1/ScheduleServiceClient/create_schedule.php + * + * @param CreateScheduleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Schedule + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSchedule(CreateScheduleRequest $request, array $callOptions = []): Schedule + { + return $this->startApiCall('CreateSchedule', $request, $callOptions)->wait(); + } + + /** + * Deletes a Schedule. + * + * The async variant is {@see ScheduleServiceClient::deleteScheduleAsync()} . + * + * @example samples/V1/ScheduleServiceClient/delete_schedule.php + * + * @param DeleteScheduleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSchedule(DeleteScheduleRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteSchedule', $request, $callOptions)->wait(); + } + + /** + * Gets a Schedule. + * + * The async variant is {@see ScheduleServiceClient::getScheduleAsync()} . + * + * @example samples/V1/ScheduleServiceClient/get_schedule.php + * + * @param GetScheduleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Schedule + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSchedule(GetScheduleRequest $request, array $callOptions = []): Schedule + { + return $this->startApiCall('GetSchedule', $request, $callOptions)->wait(); + } + + /** + * Lists Schedules in a Location. + * + * The async variant is {@see ScheduleServiceClient::listSchedulesAsync()} . + * + * @example samples/V1/ScheduleServiceClient/list_schedules.php + * + * @param ListSchedulesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSchedules(ListSchedulesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSchedules', $request, $callOptions); + } + + /** + * Pauses a Schedule. Will mark + * [Schedule.state][google.cloud.aiplatform.v1.Schedule.state] to 'PAUSED'. If + * the schedule is paused, no new runs will be created. Already created runs + * will NOT be paused or canceled. + * + * The async variant is {@see ScheduleServiceClient::pauseScheduleAsync()} . + * + * @example samples/V1/ScheduleServiceClient/pause_schedule.php + * + * @param PauseScheduleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function pauseSchedule(PauseScheduleRequest $request, array $callOptions = []): void + { + $this->startApiCall('PauseSchedule', $request, $callOptions)->wait(); + } + + /** + * Resumes a paused Schedule to start scheduling new runs. Will mark + * [Schedule.state][google.cloud.aiplatform.v1.Schedule.state] to 'ACTIVE'. + * Only paused Schedule can be resumed. + * + * When the Schedule is resumed, new runs will be scheduled starting from the + * next execution time after the current time based on the time_specification + * in the Schedule. If [Schedule.catchUp][] is set up true, all + * missed runs will be scheduled for backfill first. + * + * The async variant is {@see ScheduleServiceClient::resumeScheduleAsync()} . + * + * @example samples/V1/ScheduleServiceClient/resume_schedule.php + * + * @param ResumeScheduleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function resumeSchedule(ResumeScheduleRequest $request, array $callOptions = []): void + { + $this->startApiCall('ResumeSchedule', $request, $callOptions)->wait(); + } + + /** + * Updates an active or paused Schedule. + * + * When the Schedule is updated, new runs will be scheduled starting from the + * updated next execution time after the update time based on the + * time_specification in the updated Schedule. All unstarted runs before the + * update time will be skipped while already created runs will NOT be paused + * or canceled. + * + * The async variant is {@see ScheduleServiceClient::updateScheduleAsync()} . + * + * @example samples/V1/ScheduleServiceClient/update_schedule.php + * + * @param UpdateScheduleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Schedule + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSchedule(UpdateScheduleRequest $request, array $callOptions = []): Schedule + { + return $this->startApiCall('UpdateSchedule', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see ScheduleServiceClient::getLocationAsync()} . + * + * @example samples/V1/ScheduleServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see ScheduleServiceClient::listLocationsAsync()} . + * + * @example samples/V1/ScheduleServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see ScheduleServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/ScheduleServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see ScheduleServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/ScheduleServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see ScheduleServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/ScheduleServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/AiPlatform/src/V1/Client/SpecialistPoolServiceClient.php b/AiPlatform/src/V1/Client/SpecialistPoolServiceClient.php index 4e9015e346a0..c5eac4b2f54b 100644 --- a/AiPlatform/src/V1/Client/SpecialistPoolServiceClient.php +++ b/AiPlatform/src/V1/Client/SpecialistPoolServiceClient.php @@ -24,17 +24,546 @@ namespace Google\Cloud\AIPlatform\V1\Client; -use Google\Cloud\AIPlatform\V1\Client\BaseClient\SpecialistPoolServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AIPlatform\V1\CreateSpecialistPoolRequest; +use Google\Cloud\AIPlatform\V1\DeleteSpecialistPoolRequest; +use Google\Cloud\AIPlatform\V1\GetSpecialistPoolRequest; +use Google\Cloud\AIPlatform\V1\ListSpecialistPoolsRequest; +use Google\Cloud\AIPlatform\V1\SpecialistPool; +use Google\Cloud\AIPlatform\V1\UpdateSpecialistPoolRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service for creating and managing Customer SpecialistPools. + * When customers start Data Labeling jobs, they can reuse/create Specialist + * Pools to bring their own Specialists to label the data. + * Customers can add/remove Managers for the Specialist Pool on Cloud console, + * then Managers will get email notifications to manage Specialists and tasks on + * CrowdCompute console. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AIPlatform\V1\SpecialistPoolServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createSpecialistPoolAsync(CreateSpecialistPoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSpecialistPoolAsync(DeleteSpecialistPoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSpecialistPoolAsync(GetSpecialistPoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSpecialistPoolsAsync(ListSpecialistPoolsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSpecialistPoolAsync(UpdateSpecialistPoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class SpecialistPoolServiceClient extends SpecialistPoolServiceBaseClient +final class SpecialistPoolServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SpecialistPoolServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.aiplatform.v1.SpecialistPoolService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'aiplatform.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/specialist_pool_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/specialist_pool_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/specialist_pool_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/specialist_pool_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * specialist_pool resource. + * + * @param string $project + * @param string $location + * @param string $specialistPool + * + * @return string The formatted specialist_pool resource. + */ + public static function specialistPoolName(string $project, string $location, string $specialistPool): string + { + return self::getPathTemplate('specialistPool')->render([ + 'project' => $project, + 'location' => $location, + 'specialist_pool' => $specialistPool, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - location: projects/{project}/locations/{location} + * - specialistPool: projects/{project}/locations/{location}/specialistPools/{specialist_pool} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'aiplatform.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a SpecialistPool. + * + * The async variant is + * {@see SpecialistPoolServiceClient::createSpecialistPoolAsync()} . + * + * @example samples/V1/SpecialistPoolServiceClient/create_specialist_pool.php + * + * @param CreateSpecialistPoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSpecialistPool(CreateSpecialistPoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateSpecialistPool', $request, $callOptions)->wait(); + } + + /** + * Deletes a SpecialistPool as well as all Specialists in the pool. + * + * The async variant is + * {@see SpecialistPoolServiceClient::deleteSpecialistPoolAsync()} . + * + * @example samples/V1/SpecialistPoolServiceClient/delete_specialist_pool.php + * + * @param DeleteSpecialistPoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSpecialistPool(DeleteSpecialistPoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteSpecialistPool', $request, $callOptions)->wait(); + } + + /** + * Gets a SpecialistPool. + * + * The async variant is + * {@see SpecialistPoolServiceClient::getSpecialistPoolAsync()} . + * + * @example samples/V1/SpecialistPoolServiceClient/get_specialist_pool.php + * + * @param GetSpecialistPoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SpecialistPool + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSpecialistPool(GetSpecialistPoolRequest $request, array $callOptions = []): SpecialistPool + { + return $this->startApiCall('GetSpecialistPool', $request, $callOptions)->wait(); + } + + /** + * Lists SpecialistPools in a Location. + * + * The async variant is + * {@see SpecialistPoolServiceClient::listSpecialistPoolsAsync()} . + * + * @example samples/V1/SpecialistPoolServiceClient/list_specialist_pools.php + * + * @param ListSpecialistPoolsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSpecialistPools(ListSpecialistPoolsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSpecialistPools', $request, $callOptions); + } + + /** + * Updates a SpecialistPool. + * + * The async variant is + * {@see SpecialistPoolServiceClient::updateSpecialistPoolAsync()} . + * + * @example samples/V1/SpecialistPoolServiceClient/update_specialist_pool.php + * + * @param UpdateSpecialistPoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSpecialistPool(UpdateSpecialistPoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateSpecialistPool', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see SpecialistPoolServiceClient::getLocationAsync()} . + * + * @example samples/V1/SpecialistPoolServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see SpecialistPoolServiceClient::listLocationsAsync()} . + * + * @example samples/V1/SpecialistPoolServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see SpecialistPoolServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/SpecialistPoolServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see SpecialistPoolServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/SpecialistPoolServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is + * {@see SpecialistPoolServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/SpecialistPoolServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/AiPlatform/src/V1/Client/TensorboardServiceClient.php b/AiPlatform/src/V1/Client/TensorboardServiceClient.php index 7aa76b0240f3..dbe2446d34b9 100644 --- a/AiPlatform/src/V1/Client/TensorboardServiceClient.php +++ b/AiPlatform/src/V1/Client/TensorboardServiceClient.php @@ -24,17 +24,1353 @@ namespace Google\Cloud\AIPlatform\V1\Client; -use Google\Cloud\AIPlatform\V1\Client\BaseClient\TensorboardServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\ServerStream; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AIPlatform\V1\BatchCreateTensorboardRunsRequest; +use Google\Cloud\AIPlatform\V1\BatchCreateTensorboardRunsResponse; +use Google\Cloud\AIPlatform\V1\BatchCreateTensorboardTimeSeriesRequest; +use Google\Cloud\AIPlatform\V1\BatchCreateTensorboardTimeSeriesResponse; +use Google\Cloud\AIPlatform\V1\BatchReadTensorboardTimeSeriesDataRequest; +use Google\Cloud\AIPlatform\V1\BatchReadTensorboardTimeSeriesDataResponse; +use Google\Cloud\AIPlatform\V1\CreateTensorboardExperimentRequest; +use Google\Cloud\AIPlatform\V1\CreateTensorboardRequest; +use Google\Cloud\AIPlatform\V1\CreateTensorboardRunRequest; +use Google\Cloud\AIPlatform\V1\CreateTensorboardTimeSeriesRequest; +use Google\Cloud\AIPlatform\V1\DeleteTensorboardExperimentRequest; +use Google\Cloud\AIPlatform\V1\DeleteTensorboardRequest; +use Google\Cloud\AIPlatform\V1\DeleteTensorboardRunRequest; +use Google\Cloud\AIPlatform\V1\DeleteTensorboardTimeSeriesRequest; +use Google\Cloud\AIPlatform\V1\ExportTensorboardTimeSeriesDataRequest; +use Google\Cloud\AIPlatform\V1\GetTensorboardExperimentRequest; +use Google\Cloud\AIPlatform\V1\GetTensorboardRequest; +use Google\Cloud\AIPlatform\V1\GetTensorboardRunRequest; +use Google\Cloud\AIPlatform\V1\GetTensorboardTimeSeriesRequest; +use Google\Cloud\AIPlatform\V1\ListTensorboardExperimentsRequest; +use Google\Cloud\AIPlatform\V1\ListTensorboardRunsRequest; +use Google\Cloud\AIPlatform\V1\ListTensorboardTimeSeriesRequest; +use Google\Cloud\AIPlatform\V1\ListTensorboardsRequest; +use Google\Cloud\AIPlatform\V1\ReadTensorboardBlobDataRequest; +use Google\Cloud\AIPlatform\V1\ReadTensorboardSizeRequest; +use Google\Cloud\AIPlatform\V1\ReadTensorboardSizeResponse; +use Google\Cloud\AIPlatform\V1\ReadTensorboardTimeSeriesDataRequest; +use Google\Cloud\AIPlatform\V1\ReadTensorboardTimeSeriesDataResponse; +use Google\Cloud\AIPlatform\V1\ReadTensorboardUsageRequest; +use Google\Cloud\AIPlatform\V1\ReadTensorboardUsageResponse; +use Google\Cloud\AIPlatform\V1\Tensorboard; +use Google\Cloud\AIPlatform\V1\TensorboardExperiment; +use Google\Cloud\AIPlatform\V1\TensorboardRun; +use Google\Cloud\AIPlatform\V1\TensorboardTimeSeries; +use Google\Cloud\AIPlatform\V1\UpdateTensorboardExperimentRequest; +use Google\Cloud\AIPlatform\V1\UpdateTensorboardRequest; +use Google\Cloud\AIPlatform\V1\UpdateTensorboardRunRequest; +use Google\Cloud\AIPlatform\V1\UpdateTensorboardTimeSeriesRequest; +use Google\Cloud\AIPlatform\V1\WriteTensorboardExperimentDataRequest; +use Google\Cloud\AIPlatform\V1\WriteTensorboardExperimentDataResponse; +use Google\Cloud\AIPlatform\V1\WriteTensorboardRunDataRequest; +use Google\Cloud\AIPlatform\V1\WriteTensorboardRunDataResponse; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: TensorboardService * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AIPlatform\V1\TensorboardServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface batchCreateTensorboardRunsAsync(BatchCreateTensorboardRunsRequest $request, array $optionalArgs = []) + * @method PromiseInterface batchCreateTensorboardTimeSeriesAsync(BatchCreateTensorboardTimeSeriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface batchReadTensorboardTimeSeriesDataAsync(BatchReadTensorboardTimeSeriesDataRequest $request, array $optionalArgs = []) + * @method PromiseInterface createTensorboardAsync(CreateTensorboardRequest $request, array $optionalArgs = []) + * @method PromiseInterface createTensorboardExperimentAsync(CreateTensorboardExperimentRequest $request, array $optionalArgs = []) + * @method PromiseInterface createTensorboardRunAsync(CreateTensorboardRunRequest $request, array $optionalArgs = []) + * @method PromiseInterface createTensorboardTimeSeriesAsync(CreateTensorboardTimeSeriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTensorboardAsync(DeleteTensorboardRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTensorboardExperimentAsync(DeleteTensorboardExperimentRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTensorboardRunAsync(DeleteTensorboardRunRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTensorboardTimeSeriesAsync(DeleteTensorboardTimeSeriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface exportTensorboardTimeSeriesDataAsync(ExportTensorboardTimeSeriesDataRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTensorboardAsync(GetTensorboardRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTensorboardExperimentAsync(GetTensorboardExperimentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTensorboardRunAsync(GetTensorboardRunRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTensorboardTimeSeriesAsync(GetTensorboardTimeSeriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTensorboardExperimentsAsync(ListTensorboardExperimentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTensorboardRunsAsync(ListTensorboardRunsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTensorboardTimeSeriesAsync(ListTensorboardTimeSeriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTensorboardsAsync(ListTensorboardsRequest $request, array $optionalArgs = []) + * @method PromiseInterface readTensorboardSizeAsync(ReadTensorboardSizeRequest $request, array $optionalArgs = []) + * @method PromiseInterface readTensorboardTimeSeriesDataAsync(ReadTensorboardTimeSeriesDataRequest $request, array $optionalArgs = []) + * @method PromiseInterface readTensorboardUsageAsync(ReadTensorboardUsageRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateTensorboardAsync(UpdateTensorboardRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateTensorboardExperimentAsync(UpdateTensorboardExperimentRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateTensorboardRunAsync(UpdateTensorboardRunRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateTensorboardTimeSeriesAsync(UpdateTensorboardTimeSeriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface writeTensorboardExperimentDataAsync(WriteTensorboardExperimentDataRequest $request, array $optionalArgs = []) + * @method PromiseInterface writeTensorboardRunDataAsync(WriteTensorboardRunDataRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class TensorboardServiceClient extends TensorboardServiceBaseClient +final class TensorboardServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TensorboardServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.aiplatform.v1.TensorboardService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'aiplatform.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/tensorboard_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/tensorboard_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/tensorboard_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/tensorboard_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a tensorboard + * resource. + * + * @param string $project + * @param string $location + * @param string $tensorboard + * + * @return string The formatted tensorboard resource. + */ + public static function tensorboardName(string $project, string $location, string $tensorboard): string + { + return self::getPathTemplate('tensorboard')->render([ + 'project' => $project, + 'location' => $location, + 'tensorboard' => $tensorboard, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * tensorboard_experiment resource. + * + * @param string $project + * @param string $location + * @param string $tensorboard + * @param string $experiment + * + * @return string The formatted tensorboard_experiment resource. + */ + public static function tensorboardExperimentName(string $project, string $location, string $tensorboard, string $experiment): string + { + return self::getPathTemplate('tensorboardExperiment')->render([ + 'project' => $project, + 'location' => $location, + 'tensorboard' => $tensorboard, + 'experiment' => $experiment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * tensorboard_run resource. + * + * @param string $project + * @param string $location + * @param string $tensorboard + * @param string $experiment + * @param string $run + * + * @return string The formatted tensorboard_run resource. + */ + public static function tensorboardRunName(string $project, string $location, string $tensorboard, string $experiment, string $run): string + { + return self::getPathTemplate('tensorboardRun')->render([ + 'project' => $project, + 'location' => $location, + 'tensorboard' => $tensorboard, + 'experiment' => $experiment, + 'run' => $run, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * tensorboard_time_series resource. + * + * @param string $project + * @param string $location + * @param string $tensorboard + * @param string $experiment + * @param string $run + * @param string $timeSeries + * + * @return string The formatted tensorboard_time_series resource. + */ + public static function tensorboardTimeSeriesName(string $project, string $location, string $tensorboard, string $experiment, string $run, string $timeSeries): string + { + return self::getPathTemplate('tensorboardTimeSeries')->render([ + 'project' => $project, + 'location' => $location, + 'tensorboard' => $tensorboard, + 'experiment' => $experiment, + 'run' => $run, + 'time_series' => $timeSeries, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - location: projects/{project}/locations/{location} + * - tensorboard: projects/{project}/locations/{location}/tensorboards/{tensorboard} + * - tensorboardExperiment: projects/{project}/locations/{location}/tensorboards/{tensorboard}/experiments/{experiment} + * - tensorboardRun: projects/{project}/locations/{location}/tensorboards/{tensorboard}/experiments/{experiment}/runs/{run} + * - tensorboardTimeSeries: projects/{project}/locations/{location}/tensorboards/{tensorboard}/experiments/{experiment}/runs/{run}/timeSeries/{time_series} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'aiplatform.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Batch create TensorboardRuns. + * + * The async variant is + * {@see TensorboardServiceClient::batchCreateTensorboardRunsAsync()} . + * + * @example samples/V1/TensorboardServiceClient/batch_create_tensorboard_runs.php + * + * @param BatchCreateTensorboardRunsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BatchCreateTensorboardRunsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchCreateTensorboardRuns(BatchCreateTensorboardRunsRequest $request, array $callOptions = []): BatchCreateTensorboardRunsResponse + { + return $this->startApiCall('BatchCreateTensorboardRuns', $request, $callOptions)->wait(); + } + + /** + * Batch create TensorboardTimeSeries that belong to a TensorboardExperiment. + * + * The async variant is + * {@see TensorboardServiceClient::batchCreateTensorboardTimeSeriesAsync()} . + * + * @example samples/V1/TensorboardServiceClient/batch_create_tensorboard_time_series.php + * + * @param BatchCreateTensorboardTimeSeriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BatchCreateTensorboardTimeSeriesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchCreateTensorboardTimeSeries(BatchCreateTensorboardTimeSeriesRequest $request, array $callOptions = []): BatchCreateTensorboardTimeSeriesResponse + { + return $this->startApiCall('BatchCreateTensorboardTimeSeries', $request, $callOptions)->wait(); + } + + /** + * Reads multiple TensorboardTimeSeries' data. The data point number limit is + * 1000 for scalars, 100 for tensors and blob references. If the number of + * data points stored is less than the limit, all data is returned. + * Otherwise, the number limit of data points is randomly selected from + * this time series and returned. + * + * The async variant is + * {@see TensorboardServiceClient::batchReadTensorboardTimeSeriesDataAsync()} . + * + * @example samples/V1/TensorboardServiceClient/batch_read_tensorboard_time_series_data.php + * + * @param BatchReadTensorboardTimeSeriesDataRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BatchReadTensorboardTimeSeriesDataResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchReadTensorboardTimeSeriesData(BatchReadTensorboardTimeSeriesDataRequest $request, array $callOptions = []): BatchReadTensorboardTimeSeriesDataResponse + { + return $this->startApiCall('BatchReadTensorboardTimeSeriesData', $request, $callOptions)->wait(); + } + + /** + * Creates a Tensorboard. + * + * The async variant is {@see TensorboardServiceClient::createTensorboardAsync()} . + * + * @example samples/V1/TensorboardServiceClient/create_tensorboard.php + * + * @param CreateTensorboardRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTensorboard(CreateTensorboardRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateTensorboard', $request, $callOptions)->wait(); + } + + /** + * Creates a TensorboardExperiment. + * + * The async variant is + * {@see TensorboardServiceClient::createTensorboardExperimentAsync()} . + * + * @example samples/V1/TensorboardServiceClient/create_tensorboard_experiment.php + * + * @param CreateTensorboardExperimentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TensorboardExperiment + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTensorboardExperiment(CreateTensorboardExperimentRequest $request, array $callOptions = []): TensorboardExperiment + { + return $this->startApiCall('CreateTensorboardExperiment', $request, $callOptions)->wait(); + } + + /** + * Creates a TensorboardRun. + * + * The async variant is + * {@see TensorboardServiceClient::createTensorboardRunAsync()} . + * + * @example samples/V1/TensorboardServiceClient/create_tensorboard_run.php + * + * @param CreateTensorboardRunRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TensorboardRun + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTensorboardRun(CreateTensorboardRunRequest $request, array $callOptions = []): TensorboardRun + { + return $this->startApiCall('CreateTensorboardRun', $request, $callOptions)->wait(); + } + + /** + * Creates a TensorboardTimeSeries. + * + * The async variant is + * {@see TensorboardServiceClient::createTensorboardTimeSeriesAsync()} . + * + * @example samples/V1/TensorboardServiceClient/create_tensorboard_time_series.php + * + * @param CreateTensorboardTimeSeriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TensorboardTimeSeries + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTensorboardTimeSeries(CreateTensorboardTimeSeriesRequest $request, array $callOptions = []): TensorboardTimeSeries + { + return $this->startApiCall('CreateTensorboardTimeSeries', $request, $callOptions)->wait(); + } + + /** + * Deletes a Tensorboard. + * + * The async variant is {@see TensorboardServiceClient::deleteTensorboardAsync()} . + * + * @example samples/V1/TensorboardServiceClient/delete_tensorboard.php + * + * @param DeleteTensorboardRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTensorboard(DeleteTensorboardRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteTensorboard', $request, $callOptions)->wait(); + } + + /** + * Deletes a TensorboardExperiment. + * + * The async variant is + * {@see TensorboardServiceClient::deleteTensorboardExperimentAsync()} . + * + * @example samples/V1/TensorboardServiceClient/delete_tensorboard_experiment.php + * + * @param DeleteTensorboardExperimentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTensorboardExperiment(DeleteTensorboardExperimentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteTensorboardExperiment', $request, $callOptions)->wait(); + } + + /** + * Deletes a TensorboardRun. + * + * The async variant is + * {@see TensorboardServiceClient::deleteTensorboardRunAsync()} . + * + * @example samples/V1/TensorboardServiceClient/delete_tensorboard_run.php + * + * @param DeleteTensorboardRunRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTensorboardRun(DeleteTensorboardRunRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteTensorboardRun', $request, $callOptions)->wait(); + } + + /** + * Deletes a TensorboardTimeSeries. + * + * The async variant is + * {@see TensorboardServiceClient::deleteTensorboardTimeSeriesAsync()} . + * + * @example samples/V1/TensorboardServiceClient/delete_tensorboard_time_series.php + * + * @param DeleteTensorboardTimeSeriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTensorboardTimeSeries(DeleteTensorboardTimeSeriesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteTensorboardTimeSeries', $request, $callOptions)->wait(); + } + + /** + * Exports a TensorboardTimeSeries' data. Data is returned in paginated + * responses. + * + * The async variant is + * {@see TensorboardServiceClient::exportTensorboardTimeSeriesDataAsync()} . + * + * @example samples/V1/TensorboardServiceClient/export_tensorboard_time_series_data.php + * + * @param ExportTensorboardTimeSeriesDataRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportTensorboardTimeSeriesData(ExportTensorboardTimeSeriesDataRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ExportTensorboardTimeSeriesData', $request, $callOptions); + } + + /** + * Gets a Tensorboard. + * + * The async variant is {@see TensorboardServiceClient::getTensorboardAsync()} . + * + * @example samples/V1/TensorboardServiceClient/get_tensorboard.php + * + * @param GetTensorboardRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Tensorboard + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTensorboard(GetTensorboardRequest $request, array $callOptions = []): Tensorboard + { + return $this->startApiCall('GetTensorboard', $request, $callOptions)->wait(); + } + + /** + * Gets a TensorboardExperiment. + * + * The async variant is + * {@see TensorboardServiceClient::getTensorboardExperimentAsync()} . + * + * @example samples/V1/TensorboardServiceClient/get_tensorboard_experiment.php + * + * @param GetTensorboardExperimentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TensorboardExperiment + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTensorboardExperiment(GetTensorboardExperimentRequest $request, array $callOptions = []): TensorboardExperiment + { + return $this->startApiCall('GetTensorboardExperiment', $request, $callOptions)->wait(); + } + + /** + * Gets a TensorboardRun. + * + * The async variant is {@see TensorboardServiceClient::getTensorboardRunAsync()} . + * + * @example samples/V1/TensorboardServiceClient/get_tensorboard_run.php + * + * @param GetTensorboardRunRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TensorboardRun + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTensorboardRun(GetTensorboardRunRequest $request, array $callOptions = []): TensorboardRun + { + return $this->startApiCall('GetTensorboardRun', $request, $callOptions)->wait(); + } + + /** + * Gets a TensorboardTimeSeries. + * + * The async variant is + * {@see TensorboardServiceClient::getTensorboardTimeSeriesAsync()} . + * + * @example samples/V1/TensorboardServiceClient/get_tensorboard_time_series.php + * + * @param GetTensorboardTimeSeriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TensorboardTimeSeries + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTensorboardTimeSeries(GetTensorboardTimeSeriesRequest $request, array $callOptions = []): TensorboardTimeSeries + { + return $this->startApiCall('GetTensorboardTimeSeries', $request, $callOptions)->wait(); + } + + /** + * Lists TensorboardExperiments in a Location. + * + * The async variant is + * {@see TensorboardServiceClient::listTensorboardExperimentsAsync()} . + * + * @example samples/V1/TensorboardServiceClient/list_tensorboard_experiments.php + * + * @param ListTensorboardExperimentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTensorboardExperiments(ListTensorboardExperimentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTensorboardExperiments', $request, $callOptions); + } + + /** + * Lists TensorboardRuns in a Location. + * + * The async variant is {@see TensorboardServiceClient::listTensorboardRunsAsync()} + * . + * + * @example samples/V1/TensorboardServiceClient/list_tensorboard_runs.php + * + * @param ListTensorboardRunsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTensorboardRuns(ListTensorboardRunsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTensorboardRuns', $request, $callOptions); + } + + /** + * Lists TensorboardTimeSeries in a Location. + * + * The async variant is + * {@see TensorboardServiceClient::listTensorboardTimeSeriesAsync()} . + * + * @example samples/V1/TensorboardServiceClient/list_tensorboard_time_series.php + * + * @param ListTensorboardTimeSeriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTensorboardTimeSeries(ListTensorboardTimeSeriesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTensorboardTimeSeries', $request, $callOptions); + } + + /** + * Lists Tensorboards in a Location. + * + * The async variant is {@see TensorboardServiceClient::listTensorboardsAsync()} . + * + * @example samples/V1/TensorboardServiceClient/list_tensorboards.php + * + * @param ListTensorboardsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTensorboards(ListTensorboardsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTensorboards', $request, $callOptions); + } + + /** + * Gets bytes of TensorboardBlobs. + * This is to allow reading blob data stored in consumer project's Cloud + * Storage bucket without users having to obtain Cloud Storage access + * permission. + * + * @example samples/V1/TensorboardServiceClient/read_tensorboard_blob_data.php + * + * @param ReadTensorboardBlobDataRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return ServerStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function readTensorboardBlobData(ReadTensorboardBlobDataRequest $request, array $callOptions = []): ServerStream + { + return $this->startApiCall('ReadTensorboardBlobData', $request, $callOptions); + } + + /** + * Returns the storage size for a given TensorBoard instance. + * + * The async variant is {@see TensorboardServiceClient::readTensorboardSizeAsync()} + * . + * + * @example samples/V1/TensorboardServiceClient/read_tensorboard_size.php + * + * @param ReadTensorboardSizeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ReadTensorboardSizeResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function readTensorboardSize(ReadTensorboardSizeRequest $request, array $callOptions = []): ReadTensorboardSizeResponse + { + return $this->startApiCall('ReadTensorboardSize', $request, $callOptions)->wait(); + } + + /** + * Reads a TensorboardTimeSeries' data. By default, if the number of data + * points stored is less than 1000, all data is returned. Otherwise, 1000 + * data points is randomly selected from this time series and returned. + * This value can be changed by changing max_data_points, which can't be + * greater than 10k. + * + * The async variant is + * {@see TensorboardServiceClient::readTensorboardTimeSeriesDataAsync()} . + * + * @example samples/V1/TensorboardServiceClient/read_tensorboard_time_series_data.php + * + * @param ReadTensorboardTimeSeriesDataRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ReadTensorboardTimeSeriesDataResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function readTensorboardTimeSeriesData(ReadTensorboardTimeSeriesDataRequest $request, array $callOptions = []): ReadTensorboardTimeSeriesDataResponse + { + return $this->startApiCall('ReadTensorboardTimeSeriesData', $request, $callOptions)->wait(); + } + + /** + * Returns a list of monthly active users for a given TensorBoard instance. + * + * The async variant is + * {@see TensorboardServiceClient::readTensorboardUsageAsync()} . + * + * @example samples/V1/TensorboardServiceClient/read_tensorboard_usage.php + * + * @param ReadTensorboardUsageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ReadTensorboardUsageResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function readTensorboardUsage(ReadTensorboardUsageRequest $request, array $callOptions = []): ReadTensorboardUsageResponse + { + return $this->startApiCall('ReadTensorboardUsage', $request, $callOptions)->wait(); + } + + /** + * Updates a Tensorboard. + * + * The async variant is {@see TensorboardServiceClient::updateTensorboardAsync()} . + * + * @example samples/V1/TensorboardServiceClient/update_tensorboard.php + * + * @param UpdateTensorboardRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTensorboard(UpdateTensorboardRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateTensorboard', $request, $callOptions)->wait(); + } + + /** + * Updates a TensorboardExperiment. + * + * The async variant is + * {@see TensorboardServiceClient::updateTensorboardExperimentAsync()} . + * + * @example samples/V1/TensorboardServiceClient/update_tensorboard_experiment.php + * + * @param UpdateTensorboardExperimentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TensorboardExperiment + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTensorboardExperiment(UpdateTensorboardExperimentRequest $request, array $callOptions = []): TensorboardExperiment + { + return $this->startApiCall('UpdateTensorboardExperiment', $request, $callOptions)->wait(); + } + + /** + * Updates a TensorboardRun. + * + * The async variant is + * {@see TensorboardServiceClient::updateTensorboardRunAsync()} . + * + * @example samples/V1/TensorboardServiceClient/update_tensorboard_run.php + * + * @param UpdateTensorboardRunRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TensorboardRun + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTensorboardRun(UpdateTensorboardRunRequest $request, array $callOptions = []): TensorboardRun + { + return $this->startApiCall('UpdateTensorboardRun', $request, $callOptions)->wait(); + } + + /** + * Updates a TensorboardTimeSeries. + * + * The async variant is + * {@see TensorboardServiceClient::updateTensorboardTimeSeriesAsync()} . + * + * @example samples/V1/TensorboardServiceClient/update_tensorboard_time_series.php + * + * @param UpdateTensorboardTimeSeriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TensorboardTimeSeries + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTensorboardTimeSeries(UpdateTensorboardTimeSeriesRequest $request, array $callOptions = []): TensorboardTimeSeries + { + return $this->startApiCall('UpdateTensorboardTimeSeries', $request, $callOptions)->wait(); + } + + /** + * Write time series data points of multiple TensorboardTimeSeries in multiple + * TensorboardRun's. If any data fail to be ingested, an error is returned. + * + * The async variant is + * {@see TensorboardServiceClient::writeTensorboardExperimentDataAsync()} . + * + * @example samples/V1/TensorboardServiceClient/write_tensorboard_experiment_data.php + * + * @param WriteTensorboardExperimentDataRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 WriteTensorboardExperimentDataResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function writeTensorboardExperimentData(WriteTensorboardExperimentDataRequest $request, array $callOptions = []): WriteTensorboardExperimentDataResponse + { + return $this->startApiCall('WriteTensorboardExperimentData', $request, $callOptions)->wait(); + } + + /** + * Write time series data points into multiple TensorboardTimeSeries under + * a TensorboardRun. If any data fail to be ingested, an error is returned. + * + * The async variant is + * {@see TensorboardServiceClient::writeTensorboardRunDataAsync()} . + * + * @example samples/V1/TensorboardServiceClient/write_tensorboard_run_data.php + * + * @param WriteTensorboardRunDataRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 WriteTensorboardRunDataResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function writeTensorboardRunData(WriteTensorboardRunDataRequest $request, array $callOptions = []): WriteTensorboardRunDataResponse + { + return $this->startApiCall('WriteTensorboardRunData', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see TensorboardServiceClient::getLocationAsync()} . + * + * @example samples/V1/TensorboardServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see TensorboardServiceClient::listLocationsAsync()} . + * + * @example samples/V1/TensorboardServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see TensorboardServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/TensorboardServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see TensorboardServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/TensorboardServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see TensorboardServiceClient::testIamPermissionsAsync()} + * . + * + * @example samples/V1/TensorboardServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/AiPlatform/src/V1/Client/VizierServiceClient.php b/AiPlatform/src/V1/Client/VizierServiceClient.php index 3e7bb9429738..3a45acfe644e 100644 --- a/AiPlatform/src/V1/Client/VizierServiceClient.php +++ b/AiPlatform/src/V1/Client/VizierServiceClient.php @@ -24,17 +24,875 @@ namespace Google\Cloud\AIPlatform\V1\Client; -use Google\Cloud\AIPlatform\V1\Client\BaseClient\VizierServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AIPlatform\V1\AddTrialMeasurementRequest; +use Google\Cloud\AIPlatform\V1\CheckTrialEarlyStoppingStateRequest; +use Google\Cloud\AIPlatform\V1\CheckTrialEarlyStoppingStateResponse; +use Google\Cloud\AIPlatform\V1\CompleteTrialRequest; +use Google\Cloud\AIPlatform\V1\CreateStudyRequest; +use Google\Cloud\AIPlatform\V1\CreateTrialRequest; +use Google\Cloud\AIPlatform\V1\DeleteStudyRequest; +use Google\Cloud\AIPlatform\V1\DeleteTrialRequest; +use Google\Cloud\AIPlatform\V1\GetStudyRequest; +use Google\Cloud\AIPlatform\V1\GetTrialRequest; +use Google\Cloud\AIPlatform\V1\ListOptimalTrialsRequest; +use Google\Cloud\AIPlatform\V1\ListOptimalTrialsResponse; +use Google\Cloud\AIPlatform\V1\ListStudiesRequest; +use Google\Cloud\AIPlatform\V1\ListTrialsRequest; +use Google\Cloud\AIPlatform\V1\LookupStudyRequest; +use Google\Cloud\AIPlatform\V1\StopTrialRequest; +use Google\Cloud\AIPlatform\V1\Study; +use Google\Cloud\AIPlatform\V1\SuggestTrialsRequest; +use Google\Cloud\AIPlatform\V1\SuggestTrialsResponse; +use Google\Cloud\AIPlatform\V1\Trial; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Vertex AI Vizier API. * - * This class is currently experimental and may be subject to changes. + * Vertex AI Vizier is a service to solve blackbox optimization problems, + * such as tuning machine learning hyperparameters and searching over deep + * learning architectures. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AIPlatform\V1\VizierServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface addTrialMeasurementAsync(AddTrialMeasurementRequest $request, array $optionalArgs = []) + * @method PromiseInterface checkTrialEarlyStoppingStateAsync(CheckTrialEarlyStoppingStateRequest $request, array $optionalArgs = []) + * @method PromiseInterface completeTrialAsync(CompleteTrialRequest $request, array $optionalArgs = []) + * @method PromiseInterface createStudyAsync(CreateStudyRequest $request, array $optionalArgs = []) + * @method PromiseInterface createTrialAsync(CreateTrialRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteStudyAsync(DeleteStudyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTrialAsync(DeleteTrialRequest $request, array $optionalArgs = []) + * @method PromiseInterface getStudyAsync(GetStudyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTrialAsync(GetTrialRequest $request, array $optionalArgs = []) + * @method PromiseInterface listOptimalTrialsAsync(ListOptimalTrialsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listStudiesAsync(ListStudiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTrialsAsync(ListTrialsRequest $request, array $optionalArgs = []) + * @method PromiseInterface lookupStudyAsync(LookupStudyRequest $request, array $optionalArgs = []) + * @method PromiseInterface stopTrialAsync(StopTrialRequest $request, array $optionalArgs = []) + * @method PromiseInterface suggestTrialsAsync(SuggestTrialsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class VizierServiceClient extends VizierServiceBaseClient +final class VizierServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see VizierServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.aiplatform.v1.VizierService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'aiplatform.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/vizier_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/vizier_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/vizier_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/vizier_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a custom_job + * resource. + * + * @param string $project + * @param string $location + * @param string $customJob + * + * @return string The formatted custom_job resource. + */ + public static function customJobName(string $project, string $location, string $customJob): string + { + return self::getPathTemplate('customJob')->render([ + 'project' => $project, + 'location' => $location, + 'custom_job' => $customJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a study + * resource. + * + * @param string $project + * @param string $location + * @param string $study + * + * @return string The formatted study resource. + */ + public static function studyName(string $project, string $location, string $study): string + { + return self::getPathTemplate('study')->render([ + 'project' => $project, + 'location' => $location, + 'study' => $study, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a trial + * resource. + * + * @param string $project + * @param string $location + * @param string $study + * @param string $trial + * + * @return string The formatted trial resource. + */ + public static function trialName(string $project, string $location, string $study, string $trial): string + { + return self::getPathTemplate('trial')->render([ + 'project' => $project, + 'location' => $location, + 'study' => $study, + 'trial' => $trial, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - customJob: projects/{project}/locations/{location}/customJobs/{custom_job} + * - location: projects/{project}/locations/{location} + * - study: projects/{project}/locations/{location}/studies/{study} + * - trial: projects/{project}/locations/{location}/studies/{study}/trials/{trial} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'aiplatform.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Adds a measurement of the objective metrics to a Trial. This measurement + * is assumed to have been taken before the Trial is complete. + * + * The async variant is {@see VizierServiceClient::addTrialMeasurementAsync()} . + * + * @example samples/V1/VizierServiceClient/add_trial_measurement.php + * + * @param AddTrialMeasurementRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Trial + * + * @throws ApiException Thrown if the API call fails. + */ + public function addTrialMeasurement(AddTrialMeasurementRequest $request, array $callOptions = []): Trial + { + return $this->startApiCall('AddTrialMeasurement', $request, $callOptions)->wait(); + } + + /** + * Checks whether a Trial should stop or not. Returns a + * long-running operation. When the operation is successful, + * it will contain a + * [CheckTrialEarlyStoppingStateResponse][google.cloud.aiplatform.v1.CheckTrialEarlyStoppingStateResponse]. + * + * The async variant is + * {@see VizierServiceClient::checkTrialEarlyStoppingStateAsync()} . + * + * @example samples/V1/VizierServiceClient/check_trial_early_stopping_state.php + * + * @param CheckTrialEarlyStoppingStateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function checkTrialEarlyStoppingState(CheckTrialEarlyStoppingStateRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CheckTrialEarlyStoppingState', $request, $callOptions)->wait(); + } + + /** + * Marks a Trial as complete. + * + * The async variant is {@see VizierServiceClient::completeTrialAsync()} . + * + * @example samples/V1/VizierServiceClient/complete_trial.php + * + * @param CompleteTrialRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Trial + * + * @throws ApiException Thrown if the API call fails. + */ + public function completeTrial(CompleteTrialRequest $request, array $callOptions = []): Trial + { + return $this->startApiCall('CompleteTrial', $request, $callOptions)->wait(); + } + + /** + * Creates a Study. A resource name will be generated after creation of the + * Study. + * + * The async variant is {@see VizierServiceClient::createStudyAsync()} . + * + * @example samples/V1/VizierServiceClient/create_study.php + * + * @param CreateStudyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Study + * + * @throws ApiException Thrown if the API call fails. + */ + public function createStudy(CreateStudyRequest $request, array $callOptions = []): Study + { + return $this->startApiCall('CreateStudy', $request, $callOptions)->wait(); + } + + /** + * Adds a user provided Trial to a Study. + * + * The async variant is {@see VizierServiceClient::createTrialAsync()} . + * + * @example samples/V1/VizierServiceClient/create_trial.php + * + * @param CreateTrialRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Trial + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTrial(CreateTrialRequest $request, array $callOptions = []): Trial + { + return $this->startApiCall('CreateTrial', $request, $callOptions)->wait(); + } + + /** + * Deletes a Study. + * + * The async variant is {@see VizierServiceClient::deleteStudyAsync()} . + * + * @example samples/V1/VizierServiceClient/delete_study.php + * + * @param DeleteStudyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteStudy(DeleteStudyRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteStudy', $request, $callOptions)->wait(); + } + + /** + * Deletes a Trial. + * + * The async variant is {@see VizierServiceClient::deleteTrialAsync()} . + * + * @example samples/V1/VizierServiceClient/delete_trial.php + * + * @param DeleteTrialRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTrial(DeleteTrialRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteTrial', $request, $callOptions)->wait(); + } + + /** + * Gets a Study by name. + * + * The async variant is {@see VizierServiceClient::getStudyAsync()} . + * + * @example samples/V1/VizierServiceClient/get_study.php + * + * @param GetStudyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Study + * + * @throws ApiException Thrown if the API call fails. + */ + public function getStudy(GetStudyRequest $request, array $callOptions = []): Study + { + return $this->startApiCall('GetStudy', $request, $callOptions)->wait(); + } + + /** + * Gets a Trial. + * + * The async variant is {@see VizierServiceClient::getTrialAsync()} . + * + * @example samples/V1/VizierServiceClient/get_trial.php + * + * @param GetTrialRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Trial + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTrial(GetTrialRequest $request, array $callOptions = []): Trial + { + return $this->startApiCall('GetTrial', $request, $callOptions)->wait(); + } + + /** + * Lists the pareto-optimal Trials for multi-objective Study or the + * optimal Trials for single-objective Study. The definition of + * pareto-optimal can be checked in wiki page. + * https://en.wikipedia.org/wiki/Pareto_efficiency + * + * The async variant is {@see VizierServiceClient::listOptimalTrialsAsync()} . + * + * @example samples/V1/VizierServiceClient/list_optimal_trials.php + * + * @param ListOptimalTrialsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ListOptimalTrialsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listOptimalTrials(ListOptimalTrialsRequest $request, array $callOptions = []): ListOptimalTrialsResponse + { + return $this->startApiCall('ListOptimalTrials', $request, $callOptions)->wait(); + } + + /** + * Lists all the studies in a region for an associated project. + * + * The async variant is {@see VizierServiceClient::listStudiesAsync()} . + * + * @example samples/V1/VizierServiceClient/list_studies.php + * + * @param ListStudiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listStudies(ListStudiesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListStudies', $request, $callOptions); + } + + /** + * Lists the Trials associated with a Study. + * + * The async variant is {@see VizierServiceClient::listTrialsAsync()} . + * + * @example samples/V1/VizierServiceClient/list_trials.php + * + * @param ListTrialsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTrials(ListTrialsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTrials', $request, $callOptions); + } + + /** + * Looks a study up using the user-defined display_name field instead of the + * fully qualified resource name. + * + * The async variant is {@see VizierServiceClient::lookupStudyAsync()} . + * + * @example samples/V1/VizierServiceClient/lookup_study.php + * + * @param LookupStudyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Study + * + * @throws ApiException Thrown if the API call fails. + */ + public function lookupStudy(LookupStudyRequest $request, array $callOptions = []): Study + { + return $this->startApiCall('LookupStudy', $request, $callOptions)->wait(); + } + + /** + * Stops a Trial. + * + * The async variant is {@see VizierServiceClient::stopTrialAsync()} . + * + * @example samples/V1/VizierServiceClient/stop_trial.php + * + * @param StopTrialRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Trial + * + * @throws ApiException Thrown if the API call fails. + */ + public function stopTrial(StopTrialRequest $request, array $callOptions = []): Trial + { + return $this->startApiCall('StopTrial', $request, $callOptions)->wait(); + } + + /** + * Adds one or more Trials to a Study, with parameter values + * suggested by Vertex AI Vizier. Returns a long-running + * operation associated with the generation of Trial suggestions. + * When this long-running operation succeeds, it will contain + * a + * [SuggestTrialsResponse][google.cloud.aiplatform.v1.SuggestTrialsResponse]. + * + * The async variant is {@see VizierServiceClient::suggestTrialsAsync()} . + * + * @example samples/V1/VizierServiceClient/suggest_trials.php + * + * @param SuggestTrialsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function suggestTrials(SuggestTrialsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SuggestTrials', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see VizierServiceClient::getLocationAsync()} . + * + * @example samples/V1/VizierServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see VizierServiceClient::listLocationsAsync()} . + * + * @example samples/V1/VizierServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see VizierServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/VizierServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see VizierServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/VizierServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see VizierServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/VizierServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/AiPlatform/src/V1/CreateDatasetVersionRequest.php b/AiPlatform/src/V1/CreateDatasetVersionRequest.php new file mode 100644 index 000000000000..a8cdb399abc5 --- /dev/null +++ b/AiPlatform/src/V1/CreateDatasetVersionRequest.php @@ -0,0 +1,148 @@ +google.cloud.aiplatform.v1.CreateDatasetVersionRequest + */ +class CreateDatasetVersionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the Dataset resource. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}` + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * Required. The version to be created. The same CMEK policies with the + * original Dataset will be applied the dataset version. So here we don't need + * to specify the EncryptionSpecType here. + * + * Generated from protobuf field .google.cloud.aiplatform.v1.DatasetVersion dataset_version = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $dataset_version = null; + + /** + * @param string $parent Required. The name of the Dataset resource. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}` + * Please see {@see DatasetServiceClient::datasetName()} for help formatting this field. + * @param \Google\Cloud\AIPlatform\V1\DatasetVersion $datasetVersion Required. The version to be created. The same CMEK policies with the + * original Dataset will be applied the dataset version. So here we don't need + * to specify the EncryptionSpecType here. + * + * @return \Google\Cloud\AIPlatform\V1\CreateDatasetVersionRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\AIPlatform\V1\DatasetVersion $datasetVersion): self + { + return (new self()) + ->setParent($parent) + ->setDatasetVersion($datasetVersion); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The name of the Dataset resource. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}` + * @type \Google\Cloud\AIPlatform\V1\DatasetVersion $dataset_version + * Required. The version to be created. The same CMEK policies with the + * original Dataset will be applied the dataset version. So here we don't need + * to specify the EncryptionSpecType here. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Aiplatform\V1\DatasetService::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the Dataset resource. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}` + * + * 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 name of the Dataset resource. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}` + * + * 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. The version to be created. The same CMEK policies with the + * original Dataset will be applied the dataset version. So here we don't need + * to specify the EncryptionSpecType here. + * + * Generated from protobuf field .google.cloud.aiplatform.v1.DatasetVersion dataset_version = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\AIPlatform\V1\DatasetVersion|null + */ + public function getDatasetVersion() + { + return $this->dataset_version; + } + + public function hasDatasetVersion() + { + return isset($this->dataset_version); + } + + public function clearDatasetVersion() + { + unset($this->dataset_version); + } + + /** + * Required. The version to be created. The same CMEK policies with the + * original Dataset will be applied the dataset version. So here we don't need + * to specify the EncryptionSpecType here. + * + * Generated from protobuf field .google.cloud.aiplatform.v1.DatasetVersion dataset_version = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\AIPlatform\V1\DatasetVersion $var + * @return $this + */ + public function setDatasetVersion($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\AIPlatform\V1\DatasetVersion::class); + $this->dataset_version = $var; + + return $this; + } + +} + diff --git a/AiPlatform/src/V1/CreatePipelineJobRequest.php b/AiPlatform/src/V1/CreatePipelineJobRequest.php index afe5081dbec3..a200921e44d6 100644 --- a/AiPlatform/src/V1/CreatePipelineJobRequest.php +++ b/AiPlatform/src/V1/CreatePipelineJobRequest.php @@ -34,7 +34,7 @@ class CreatePipelineJobRequest extends \Google\Protobuf\Internal\Message * the PipelineJob name. If not provided, an ID will be automatically * generated. * This value should be less than 128 characters, and valid characters - * are /[a-z][0-9]-/. + * are `/[a-z][0-9]-/`. * * Generated from protobuf field string pipeline_job_id = 3; */ @@ -50,7 +50,7 @@ class CreatePipelineJobRequest extends \Google\Protobuf\Internal\Message * generated. * * This value should be less than 128 characters, and valid characters - * are /[a-z][0-9]-/. + * are `/[a-z][0-9]-/`. * * @return \Google\Cloud\AIPlatform\V1\CreatePipelineJobRequest * @@ -80,7 +80,7 @@ public static function build(string $parent, \Google\Cloud\AIPlatform\V1\Pipelin * the PipelineJob name. If not provided, an ID will be automatically * generated. * This value should be less than 128 characters, and valid characters - * are /[a-z][0-9]-/. + * are `/[a-z][0-9]-/`. * } */ public function __construct($data = NULL) { @@ -157,7 +157,7 @@ public function setPipelineJob($var) * the PipelineJob name. If not provided, an ID will be automatically * generated. * This value should be less than 128 characters, and valid characters - * are /[a-z][0-9]-/. + * are `/[a-z][0-9]-/`. * * Generated from protobuf field string pipeline_job_id = 3; * @return string @@ -172,7 +172,7 @@ public function getPipelineJobId() * the PipelineJob name. If not provided, an ID will be automatically * generated. * This value should be less than 128 characters, and valid characters - * are /[a-z][0-9]-/. + * are `/[a-z][0-9]-/`. * * Generated from protobuf field string pipeline_job_id = 3; * @param string $var diff --git a/AiPlatform/src/V1/CreateTensorboardExperimentRequest.php b/AiPlatform/src/V1/CreateTensorboardExperimentRequest.php index e97c246ce2ac..8ffe522a768b 100644 --- a/AiPlatform/src/V1/CreateTensorboardExperimentRequest.php +++ b/AiPlatform/src/V1/CreateTensorboardExperimentRequest.php @@ -34,7 +34,7 @@ class CreateTensorboardExperimentRequest extends \Google\Protobuf\Internal\Messa * Required. The ID to use for the Tensorboard experiment, which becomes the * final component of the Tensorboard experiment's resource name. * This value should be 1-128 characters, and valid characters - * are /[a-z][0-9]-/. + * are `/[a-z][0-9]-/`. * * Generated from protobuf field string tensorboard_experiment_id = 3 [(.google.api.field_behavior) = REQUIRED]; */ @@ -50,7 +50,7 @@ class CreateTensorboardExperimentRequest extends \Google\Protobuf\Internal\Messa * final component of the Tensorboard experiment's resource name. * * This value should be 1-128 characters, and valid characters - * are /[a-z][0-9]-/. + * are `/[a-z][0-9]-/`. * * @return \Google\Cloud\AIPlatform\V1\CreateTensorboardExperimentRequest * @@ -80,7 +80,7 @@ public static function build(string $parent, \Google\Cloud\AIPlatform\V1\Tensorb * Required. The ID to use for the Tensorboard experiment, which becomes the * final component of the Tensorboard experiment's resource name. * This value should be 1-128 characters, and valid characters - * are /[a-z][0-9]-/. + * are `/[a-z][0-9]-/`. * } */ public function __construct($data = NULL) { @@ -158,7 +158,7 @@ public function setTensorboardExperiment($var) * Required. The ID to use for the Tensorboard experiment, which becomes the * final component of the Tensorboard experiment's resource name. * This value should be 1-128 characters, and valid characters - * are /[a-z][0-9]-/. + * are `/[a-z][0-9]-/`. * * Generated from protobuf field string tensorboard_experiment_id = 3 [(.google.api.field_behavior) = REQUIRED]; * @return string @@ -172,7 +172,7 @@ public function getTensorboardExperimentId() * Required. The ID to use for the Tensorboard experiment, which becomes the * final component of the Tensorboard experiment's resource name. * This value should be 1-128 characters, and valid characters - * are /[a-z][0-9]-/. + * are `/[a-z][0-9]-/`. * * Generated from protobuf field string tensorboard_experiment_id = 3 [(.google.api.field_behavior) = REQUIRED]; * @param string $var diff --git a/AiPlatform/src/V1/CreateTensorboardRunRequest.php b/AiPlatform/src/V1/CreateTensorboardRunRequest.php index 35faeb207748..f8e8e906fed0 100644 --- a/AiPlatform/src/V1/CreateTensorboardRunRequest.php +++ b/AiPlatform/src/V1/CreateTensorboardRunRequest.php @@ -34,7 +34,7 @@ class CreateTensorboardRunRequest extends \Google\Protobuf\Internal\Message * Required. The ID to use for the Tensorboard run, which becomes the final * component of the Tensorboard run's resource name. * This value should be 1-128 characters, and valid characters - * are /[a-z][0-9]-/. + * are `/[a-z][0-9]-/`. * * Generated from protobuf field string tensorboard_run_id = 3 [(.google.api.field_behavior) = REQUIRED]; */ @@ -50,7 +50,7 @@ class CreateTensorboardRunRequest extends \Google\Protobuf\Internal\Message * component of the Tensorboard run's resource name. * * This value should be 1-128 characters, and valid characters - * are /[a-z][0-9]-/. + * are `/[a-z][0-9]-/`. * * @return \Google\Cloud\AIPlatform\V1\CreateTensorboardRunRequest * @@ -80,7 +80,7 @@ public static function build(string $parent, \Google\Cloud\AIPlatform\V1\Tensorb * Required. The ID to use for the Tensorboard run, which becomes the final * component of the Tensorboard run's resource name. * This value should be 1-128 characters, and valid characters - * are /[a-z][0-9]-/. + * are `/[a-z][0-9]-/`. * } */ public function __construct($data = NULL) { @@ -158,7 +158,7 @@ public function setTensorboardRun($var) * Required. The ID to use for the Tensorboard run, which becomes the final * component of the Tensorboard run's resource name. * This value should be 1-128 characters, and valid characters - * are /[a-z][0-9]-/. + * are `/[a-z][0-9]-/`. * * Generated from protobuf field string tensorboard_run_id = 3 [(.google.api.field_behavior) = REQUIRED]; * @return string @@ -172,7 +172,7 @@ public function getTensorboardRunId() * Required. The ID to use for the Tensorboard run, which becomes the final * component of the Tensorboard run's resource name. * This value should be 1-128 characters, and valid characters - * are /[a-z][0-9]-/. + * are `/[a-z][0-9]-/`. * * Generated from protobuf field string tensorboard_run_id = 3 [(.google.api.field_behavior) = REQUIRED]; * @param string $var diff --git a/AiPlatform/src/V1/DatasetVersion.php b/AiPlatform/src/V1/DatasetVersion.php new file mode 100644 index 000000000000..d44ace0c8532 --- /dev/null +++ b/AiPlatform/src/V1/DatasetVersion.php @@ -0,0 +1,227 @@ +google.cloud.aiplatform.v1.DatasetVersion + */ +class DatasetVersion extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. The resource name of the DatasetVersion. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $name = ''; + /** + * Output only. Timestamp when this DatasetVersion was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $create_time = null; + /** + * Output only. Timestamp when this DatasetVersion was last updated. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $update_time = null; + /** + * Used to perform consistent read-modify-write updates. If not set, a blind + * "overwrite" update happens. + * + * Generated from protobuf field string etag = 3; + */ + private $etag = ''; + /** + * Output only. Name of the associated BigQuery dataset. + * + * Generated from protobuf field string big_query_dataset_name = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $big_query_dataset_name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Output only. The resource name of the DatasetVersion. + * @type \Google\Protobuf\Timestamp $create_time + * Output only. Timestamp when this DatasetVersion was created. + * @type \Google\Protobuf\Timestamp $update_time + * Output only. Timestamp when this DatasetVersion was last updated. + * @type string $etag + * Used to perform consistent read-modify-write updates. If not set, a blind + * "overwrite" update happens. + * @type string $big_query_dataset_name + * Output only. Name of the associated BigQuery dataset. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Aiplatform\V1\DatasetVersion::initOnce(); + parent::__construct($data); + } + + /** + * Output only. The resource name of the DatasetVersion. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Output only. The resource name of the DatasetVersion. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Output only. Timestamp when this DatasetVersion was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 2 [(.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. Timestamp when this DatasetVersion was created. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 2 [(.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. Timestamp when this DatasetVersion was last updated. + * + * 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. Timestamp when this DatasetVersion was last updated. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 6 [(.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; + } + + /** + * Used to perform consistent read-modify-write updates. If not set, a blind + * "overwrite" update happens. + * + * Generated from protobuf field string etag = 3; + * @return string + */ + public function getEtag() + { + return $this->etag; + } + + /** + * Used to perform consistent read-modify-write updates. If not set, a blind + * "overwrite" update happens. + * + * Generated from protobuf field string etag = 3; + * @param string $var + * @return $this + */ + public function setEtag($var) + { + GPBUtil::checkString($var, True); + $this->etag = $var; + + return $this; + } + + /** + * Output only. Name of the associated BigQuery dataset. + * + * Generated from protobuf field string big_query_dataset_name = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getBigQueryDatasetName() + { + return $this->big_query_dataset_name; + } + + /** + * Output only. Name of the associated BigQuery dataset. + * + * Generated from protobuf field string big_query_dataset_name = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setBigQueryDatasetName($var) + { + GPBUtil::checkString($var, True); + $this->big_query_dataset_name = $var; + + return $this; + } + +} + diff --git a/AiPlatform/src/V1/DeleteDatasetVersionRequest.php b/AiPlatform/src/V1/DeleteDatasetVersionRequest.php new file mode 100644 index 000000000000..3e5c365e96a9 --- /dev/null +++ b/AiPlatform/src/V1/DeleteDatasetVersionRequest.php @@ -0,0 +1,92 @@ +google.cloud.aiplatform.v1.DeleteDatasetVersionRequest + */ +class DeleteDatasetVersionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The resource name of the Dataset version to delete. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}` + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * @param string $name Required. The resource name of the Dataset version to delete. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}` + * Please see {@see DatasetServiceClient::datasetVersionName()} for help formatting this field. + * + * @return \Google\Cloud\AIPlatform\V1\DeleteDatasetVersionRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The resource name of the Dataset version to delete. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}` + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Aiplatform\V1\DatasetService::initOnce(); + parent::__construct($data); + } + + /** + * Required. The resource name of the Dataset version to delete. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}` + * + * 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 Dataset version to delete. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}` + * + * 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/AiPlatform/src/V1/DeployedIndex.php b/AiPlatform/src/V1/DeployedIndex.php index 7999a14bd328..592d05c46cca 100644 --- a/AiPlatform/src/V1/DeployedIndex.php +++ b/AiPlatform/src/V1/DeployedIndex.php @@ -128,7 +128,9 @@ class DeployedIndex extends \Google\Protobuf\Internal\Message * network. * The value should be the name of the address * (https://cloud.google.com/compute/docs/reference/rest/v1/addresses) - * Example: 'vertex-ai-ip-range'. + * Example: ['vertex-ai-ip-range']. + * For more information about subnets and network IP ranges, please see + * https://cloud.google.com/vpc/docs/subnets#manually_created_subnet_ip_ranges. * * Generated from protobuf field repeated string reserved_ip_ranges = 10 [(.google.api.field_behavior) = OPTIONAL]; */ @@ -228,7 +230,9 @@ class DeployedIndex extends \Google\Protobuf\Internal\Message * network. * The value should be the name of the address * (https://cloud.google.com/compute/docs/reference/rest/v1/addresses) - * Example: 'vertex-ai-ip-range'. + * Example: ['vertex-ai-ip-range']. + * For more information about subnets and network IP ranges, please see + * https://cloud.google.com/vpc/docs/subnets#manually_created_subnet_ip_ranges. * @type string $deployment_group * Optional. The deployment group can be no longer than 64 characters (eg: * 'test', 'prod'). If not set, we will use the 'default' deployment group. @@ -665,7 +669,9 @@ public function setDeployedIndexAuthConfig($var) * network. * The value should be the name of the address * (https://cloud.google.com/compute/docs/reference/rest/v1/addresses) - * Example: 'vertex-ai-ip-range'. + * Example: ['vertex-ai-ip-range']. + * For more information about subnets and network IP ranges, please see + * https://cloud.google.com/vpc/docs/subnets#manually_created_subnet_ip_ranges. * * Generated from protobuf field repeated string reserved_ip_ranges = 10 [(.google.api.field_behavior) = OPTIONAL]; * @return \Google\Protobuf\Internal\RepeatedField @@ -683,7 +689,9 @@ public function getReservedIpRanges() * network. * The value should be the name of the address * (https://cloud.google.com/compute/docs/reference/rest/v1/addresses) - * Example: 'vertex-ai-ip-range'. + * Example: ['vertex-ai-ip-range']. + * For more information about subnets and network IP ranges, please see + * https://cloud.google.com/vpc/docs/subnets#manually_created_subnet_ip_ranges. * * Generated from protobuf field repeated string reserved_ip_ranges = 10 [(.google.api.field_behavior) = OPTIONAL]; * @param array|\Google\Protobuf\Internal\RepeatedField $var diff --git a/AiPlatform/src/V1/DeployedModel.php b/AiPlatform/src/V1/DeployedModel.php index be829718be6b..fbb09fa94406 100644 --- a/AiPlatform/src/V1/DeployedModel.php +++ b/AiPlatform/src/V1/DeployedModel.php @@ -18,7 +18,7 @@ class DeployedModel extends \Google\Protobuf\Internal\Message /** * Immutable. The ID of the DeployedModel. If not provided upon deployment, * Vertex AI will generate a value for this ID. - * This value should be 1-10 characters, and valid characters are /[0-9]/. + * This value should be 1-10 characters, and valid characters are `/[0-9]/`. * * Generated from protobuf field string id = 1 [(.google.api.field_behavior) = IMMUTABLE]; */ @@ -137,7 +137,7 @@ class DeployedModel extends \Google\Protobuf\Internal\Message * @type string $id * Immutable. The ID of the DeployedModel. If not provided upon deployment, * Vertex AI will generate a value for this ID. - * This value should be 1-10 characters, and valid characters are /[0-9]/. + * This value should be 1-10 characters, and valid characters are `/[0-9]/`. * @type string $model * Required. The resource name of the Model that this is the deployment of. * Note that the Model may be in a different location than the DeployedModel's @@ -275,7 +275,7 @@ public function setAutomaticResources($var) /** * Immutable. The ID of the DeployedModel. If not provided upon deployment, * Vertex AI will generate a value for this ID. - * This value should be 1-10 characters, and valid characters are /[0-9]/. + * This value should be 1-10 characters, and valid characters are `/[0-9]/`. * * Generated from protobuf field string id = 1 [(.google.api.field_behavior) = IMMUTABLE]; * @return string @@ -288,7 +288,7 @@ public function getId() /** * Immutable. The ID of the DeployedModel. If not provided upon deployment, * Vertex AI will generate a value for this ID. - * This value should be 1-10 characters, and valid characters are /[0-9]/. + * This value should be 1-10 characters, and valid characters are `/[0-9]/`. * * Generated from protobuf field string id = 1 [(.google.api.field_behavior) = IMMUTABLE]; * @param string $var diff --git a/AiPlatform/src/V1/Gapic/DatasetServiceGapicClient.php b/AiPlatform/src/V1/Gapic/DatasetServiceGapicClient.php index 9742af8d8dfd..2bbf21c3e702 100644 --- a/AiPlatform/src/V1/Gapic/DatasetServiceGapicClient.php +++ b/AiPlatform/src/V1/Gapic/DatasetServiceGapicClient.php @@ -38,23 +38,30 @@ use Google\Auth\FetchAuthTokenInterface; use Google\Cloud\AIPlatform\V1\AnnotationSpec; use Google\Cloud\AIPlatform\V1\CreateDatasetRequest; +use Google\Cloud\AIPlatform\V1\CreateDatasetVersionRequest; use Google\Cloud\AIPlatform\V1\Dataset; +use Google\Cloud\AIPlatform\V1\DatasetVersion; use Google\Cloud\AIPlatform\V1\DeleteDatasetRequest; +use Google\Cloud\AIPlatform\V1\DeleteDatasetVersionRequest; use Google\Cloud\AIPlatform\V1\DeleteSavedQueryRequest; use Google\Cloud\AIPlatform\V1\ExportDataConfig; use Google\Cloud\AIPlatform\V1\ExportDataRequest; use Google\Cloud\AIPlatform\V1\GetAnnotationSpecRequest; use Google\Cloud\AIPlatform\V1\GetDatasetRequest; +use Google\Cloud\AIPlatform\V1\GetDatasetVersionRequest; use Google\Cloud\AIPlatform\V1\ImportDataConfig; use Google\Cloud\AIPlatform\V1\ImportDataRequest; use Google\Cloud\AIPlatform\V1\ListAnnotationsRequest; use Google\Cloud\AIPlatform\V1\ListAnnotationsResponse; use Google\Cloud\AIPlatform\V1\ListDataItemsRequest; use Google\Cloud\AIPlatform\V1\ListDataItemsResponse; +use Google\Cloud\AIPlatform\V1\ListDatasetVersionsRequest; +use Google\Cloud\AIPlatform\V1\ListDatasetVersionsResponse; use Google\Cloud\AIPlatform\V1\ListDatasetsRequest; use Google\Cloud\AIPlatform\V1\ListDatasetsResponse; use Google\Cloud\AIPlatform\V1\ListSavedQueriesRequest; use Google\Cloud\AIPlatform\V1\ListSavedQueriesResponse; +use Google\Cloud\AIPlatform\V1\RestoreDatasetVersionRequest; use Google\Cloud\AIPlatform\V1\SearchDataItemsRequest; use Google\Cloud\AIPlatform\V1\SearchDataItemsRequest\OrderByAnnotation; use Google\Cloud\AIPlatform\V1\SearchDataItemsResponse; @@ -149,6 +156,8 @@ class DatasetServiceGapicClient private static $datasetNameTemplate; + private static $datasetVersionNameTemplate; + private static $locationNameTemplate; private static $savedQueryNameTemplate; @@ -215,6 +224,17 @@ private static function getDatasetNameTemplate() return self::$datasetNameTemplate; } + private static function getDatasetVersionNameTemplate() + { + if (self::$datasetVersionNameTemplate == null) { + self::$datasetVersionNameTemplate = new PathTemplate( + 'projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}' + ); + } + + return self::$datasetVersionNameTemplate; + } + private static function getLocationNameTemplate() { if (self::$locationNameTemplate == null) { @@ -244,6 +264,7 @@ private static function getPathTemplateMap() 'annotationSpec' => self::getAnnotationSpecNameTemplate(), 'dataItem' => self::getDataItemNameTemplate(), 'dataset' => self::getDatasetNameTemplate(), + 'datasetVersion' => self::getDatasetVersionNameTemplate(), 'location' => self::getLocationNameTemplate(), 'savedQuery' => self::getSavedQueryNameTemplate(), ]; @@ -321,6 +342,31 @@ public static function datasetName($project, $location, $dataset) ]); } + /** + * Formats a string containing the fully-qualified path to represent a + * dataset_version resource. + * + * @param string $project + * @param string $location + * @param string $dataset + * @param string $datasetVersion + * + * @return string The formatted dataset_version resource. + */ + public static function datasetVersionName( + $project, + $location, + $dataset, + $datasetVersion + ) { + return self::getDatasetVersionNameTemplate()->render([ + 'project' => $project, + 'location' => $location, + 'dataset' => $dataset, + 'dataset_version' => $datasetVersion, + ]); + } + /** * Formats a string containing the fully-qualified path to represent a location * resource. @@ -370,6 +416,7 @@ public static function savedQueryName( * - annotationSpec: projects/{project}/locations/{location}/datasets/{dataset}/annotationSpecs/{annotation_spec} * - dataItem: projects/{project}/locations/{location}/datasets/{dataset}/dataItems/{data_item} * - dataset: projects/{project}/locations/{location}/datasets/{dataset} + * - datasetVersion: projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version} * - location: projects/{project}/locations/{location} * - savedQuery: projects/{project}/locations/{location}/datasets/{dataset}/savedQueries/{saved_query} * @@ -585,6 +632,89 @@ public function createDataset($parent, $dataset, array $optionalArgs = []) )->wait(); } + /** + * Create a version from a Dataset. + * + * Sample code: + * ``` + * $datasetServiceClient = new DatasetServiceClient(); + * try { + * $formattedParent = $datasetServiceClient->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + * $datasetVersion = new DatasetVersion(); + * $operationResponse = $datasetServiceClient->createDatasetVersion($formattedParent, $datasetVersion); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $datasetServiceClient->createDatasetVersion($formattedParent, $datasetVersion); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $datasetServiceClient->resumeOperation($operationName, 'createDatasetVersion'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $datasetServiceClient->close(); + * } + * ``` + * + * @param string $parent Required. The name of the Dataset resource. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}` + * @param DatasetVersion $datasetVersion Required. The version to be created. The same CMEK policies with the + * original Dataset will be applied the dataset version. So here we don't need + * to specify the EncryptionSpecType here. + * @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\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function createDatasetVersion( + $parent, + $datasetVersion, + array $optionalArgs = [] + ) { + $request = new CreateDatasetVersionRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $request->setDatasetVersion($datasetVersion); + $requestParamHeaders['parent'] = $parent; + $requestParams = new RequestParamsHeaderDescriptor( + $requestParamHeaders + ); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + return $this->startOperationsCall( + 'CreateDatasetVersion', + $optionalArgs, + $request, + $this->getOperationsClient() + )->wait(); + } + /** * Deletes a Dataset. * @@ -658,6 +788,79 @@ public function deleteDataset($name, array $optionalArgs = []) )->wait(); } + /** + * Deletes a Dataset version. + * + * Sample code: + * ``` + * $datasetServiceClient = new DatasetServiceClient(); + * try { + * $formattedName = $datasetServiceClient->datasetVersionName('[PROJECT]', '[LOCATION]', '[DATASET]', '[DATASET_VERSION]'); + * $operationResponse = $datasetServiceClient->deleteDatasetVersion($formattedName); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * // operation succeeded and returns no value + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $datasetServiceClient->deleteDatasetVersion($formattedName); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $datasetServiceClient->resumeOperation($operationName, 'deleteDatasetVersion'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * // operation succeeded and returns no value + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $datasetServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The resource name of the Dataset version to delete. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}` + * @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\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function deleteDatasetVersion($name, array $optionalArgs = []) + { + $request = new DeleteDatasetVersionRequest(); + $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->startOperationsCall( + 'DeleteDatasetVersion', + $optionalArgs, + $request, + $this->getOperationsClient() + )->wait(); + } + /** * Deletes a SavedQuery. * @@ -919,6 +1122,62 @@ public function getDataset($name, array $optionalArgs = []) )->wait(); } + /** + * Gets a Dataset version. + * + * Sample code: + * ``` + * $datasetServiceClient = new DatasetServiceClient(); + * try { + * $formattedName = $datasetServiceClient->datasetVersionName('[PROJECT]', '[LOCATION]', '[DATASET]', '[DATASET_VERSION]'); + * $response = $datasetServiceClient->getDatasetVersion($formattedName); + * } finally { + * $datasetServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The resource name of the Dataset version to delete. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}` + * @param array $optionalArgs { + * Optional. + * + * @type FieldMask $readMask + * Mask specifying which fields to read. + * @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\AIPlatform\V1\DatasetVersion + * + * @throws ApiException if the remote call fails + */ + public function getDatasetVersion($name, array $optionalArgs = []) + { + $request = new GetDatasetVersionRequest(); + $requestParamHeaders = []; + $request->setName($name); + $requestParamHeaders['name'] = $name; + if (isset($optionalArgs['readMask'])) { + $request->setReadMask($optionalArgs['readMask']); + } + + $requestParams = new RequestParamsHeaderDescriptor( + $requestParamHeaders + ); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + return $this->startCall( + 'GetDatasetVersion', + DatasetVersion::class, + $optionalArgs, + $request + )->wait(); + } + /** * Imports data into a Dataset. * @@ -1194,6 +1453,104 @@ public function listDataItems($parent, array $optionalArgs = []) ); } + /** + * Lists DatasetVersions in a Dataset. + * + * Sample code: + * ``` + * $datasetServiceClient = new DatasetServiceClient(); + * try { + * $formattedParent = $datasetServiceClient->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + * // Iterate over pages of elements + * $pagedResponse = $datasetServiceClient->listDatasetVersions($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $datasetServiceClient->listDatasetVersions($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $datasetServiceClient->close(); + * } + * ``` + * + * @param string $parent Required. The resource name of the Dataset to list DatasetVersions from. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}` + * @param array $optionalArgs { + * Optional. + * + * @type string $filter + * Optional. The standard list filter. + * @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 FieldMask $readMask + * Optional. Mask specifying which fields to read. + * @type string $orderBy + * Optional. A comma-separated list of fields to order by, sorted in ascending + * order. Use "desc" after a field name for descending. + * @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 + */ + public function listDatasetVersions($parent, array $optionalArgs = []) + { + $request = new ListDatasetVersionsRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); + } + + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + if (isset($optionalArgs['readMask'])) { + $request->setReadMask($optionalArgs['readMask']); + } + + if (isset($optionalArgs['orderBy'])) { + $request->setOrderBy($optionalArgs['orderBy']); + } + + $requestParams = new RequestParamsHeaderDescriptor( + $requestParamHeaders + ); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + return $this->getPagedListResponse( + 'ListDatasetVersions', + $optionalArgs, + ListDatasetVersionsResponse::class, + $request + ); + } + /** * Lists Datasets in a Location. * @@ -1407,6 +1764,81 @@ public function listSavedQueries($parent, array $optionalArgs = []) ); } + /** + * Restores a dataset version. + * + * Sample code: + * ``` + * $datasetServiceClient = new DatasetServiceClient(); + * try { + * $formattedName = $datasetServiceClient->datasetVersionName('[PROJECT]', '[LOCATION]', '[DATASET]', '[DATASET_VERSION]'); + * $operationResponse = $datasetServiceClient->restoreDatasetVersion($formattedName); + * $operationResponse->pollUntilComplete(); + * if ($operationResponse->operationSucceeded()) { + * $result = $operationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $operationResponse->getError(); + * // handleError($error) + * } + * // Alternatively: + * // start the operation, keep the operation name, and resume later + * $operationResponse = $datasetServiceClient->restoreDatasetVersion($formattedName); + * $operationName = $operationResponse->getName(); + * // ... do other work + * $newOperationResponse = $datasetServiceClient->resumeOperation($operationName, 'restoreDatasetVersion'); + * while (!$newOperationResponse->isDone()) { + * // ... do other work + * $newOperationResponse->reload(); + * } + * if ($newOperationResponse->operationSucceeded()) { + * $result = $newOperationResponse->getResult(); + * // doSomethingWith($result) + * } else { + * $error = $newOperationResponse->getError(); + * // handleError($error) + * } + * } finally { + * $datasetServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the DatasetVersion resource. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}` + * @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\ApiCore\OperationResponse + * + * @throws ApiException if the remote call fails + */ + public function restoreDatasetVersion($name, array $optionalArgs = []) + { + $request = new RestoreDatasetVersionRequest(); + $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->startOperationsCall( + 'RestoreDatasetVersion', + $optionalArgs, + $request, + $this->getOperationsClient() + )->wait(); + } + /** * Searches DataItems in a Dataset. * diff --git a/AiPlatform/src/V1/Gapic/JobServiceGapicClient.php b/AiPlatform/src/V1/Gapic/JobServiceGapicClient.php index e3a372032354..3b9b92c677f5 100644 --- a/AiPlatform/src/V1/Gapic/JobServiceGapicClient.php +++ b/AiPlatform/src/V1/Gapic/JobServiceGapicClient.php @@ -174,6 +174,8 @@ class JobServiceGapicClient private static $networkNameTemplate; + private static $notificationChannelNameTemplate; + private static $projectLocationEndpointNameTemplate; private static $projectLocationPublisherModelNameTemplate; @@ -354,6 +356,17 @@ private static function getNetworkNameTemplate() return self::$networkNameTemplate; } + private static function getNotificationChannelNameTemplate() + { + if (self::$notificationChannelNameTemplate == null) { + self::$notificationChannelNameTemplate = new PathTemplate( + 'projects/{project}/notificationChannels/{notification_channel}' + ); + } + + return self::$notificationChannelNameTemplate; + } + private static function getProjectLocationEndpointNameTemplate() { if (self::$projectLocationEndpointNameTemplate == null) { @@ -415,6 +428,7 @@ private static function getPathTemplateMap() 'nasJob' => self::getNasJobNameTemplate(), 'nasTrialDetail' => self::getNasTrialDetailNameTemplate(), 'network' => self::getNetworkNameTemplate(), + 'notificationChannel' => self::getNotificationChannelNameTemplate(), 'projectLocationEndpoint' => self::getProjectLocationEndpointNameTemplate(), 'projectLocationPublisherModel' => self::getProjectLocationPublisherModelNameTemplate(), 'tensorboard' => self::getTensorboardNameTemplate(), @@ -692,6 +706,25 @@ public static function networkName($project, $network) ]); } + /** + * Formats a string containing the fully-qualified path to represent a + * notification_channel resource. + * + * @param string $project + * @param string $notificationChannel + * + * @return string The formatted notification_channel resource. + */ + public static function notificationChannelName( + $project, + $notificationChannel + ) { + return self::getNotificationChannelNameTemplate()->render([ + 'project' => $project, + 'notification_channel' => $notificationChannel, + ]); + } + /** * Formats a string containing the fully-qualified path to represent a * project_location_endpoint resource. @@ -796,6 +829,7 @@ public static function trialName($project, $location, $study, $trial) * - nasJob: projects/{project}/locations/{location}/nasJobs/{nas_job} * - nasTrialDetail: projects/{project}/locations/{location}/nasJobs/{nas_job}/nasTrialDetails/{nas_trial_detail} * - network: projects/{project}/global/networks/{network} + * - notificationChannel: projects/{project}/notificationChannels/{notification_channel} * - projectLocationEndpoint: projects/{project}/locations/{location}/endpoints/{endpoint} * - projectLocationPublisherModel: projects/{project}/locations/{location}/publishers/{publisher}/models/{model} * - tensorboard: projects/{project}/locations/{location}/tensorboards/{tensorboard} diff --git a/AiPlatform/src/V1/Gapic/PipelineServiceGapicClient.php b/AiPlatform/src/V1/Gapic/PipelineServiceGapicClient.php index 4e90817f46c2..f138172089ae 100644 --- a/AiPlatform/src/V1/Gapic/PipelineServiceGapicClient.php +++ b/AiPlatform/src/V1/Gapic/PipelineServiceGapicClient.php @@ -911,7 +911,7 @@ public function cancelTrainingPipeline($name, array $optionalArgs = []) * generated. * * This value should be less than 128 characters, and valid characters - * are /[a-z][0-9]-/. + * are `/[a-z][0-9]-/`. * @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 diff --git a/AiPlatform/src/V1/Gapic/TensorboardServiceGapicClient.php b/AiPlatform/src/V1/Gapic/TensorboardServiceGapicClient.php index b4f9b6c519d7..4bf8b2d16185 100644 --- a/AiPlatform/src/V1/Gapic/TensorboardServiceGapicClient.php +++ b/AiPlatform/src/V1/Gapic/TensorboardServiceGapicClient.php @@ -811,7 +811,7 @@ public function createTensorboard( * final component of the Tensorboard experiment's resource name. * * This value should be 1-128 characters, and valid characters - * are /[a-z][0-9]-/. + * are `/[a-z][0-9]-/`. * @param array $optionalArgs { * Optional. * @@ -881,7 +881,7 @@ public function createTensorboardExperiment( * component of the Tensorboard run's resource name. * * This value should be 1-128 characters, and valid characters - * are /[a-z][0-9]-/. + * are `/[a-z][0-9]-/`. * @param array $optionalArgs { * Optional. * diff --git a/AiPlatform/src/V1/GetDatasetVersionRequest.php b/AiPlatform/src/V1/GetDatasetVersionRequest.php new file mode 100644 index 000000000000..1a0682831fb8 --- /dev/null +++ b/AiPlatform/src/V1/GetDatasetVersionRequest.php @@ -0,0 +1,136 @@ +google.cloud.aiplatform.v1.GetDatasetVersionRequest + */ +class GetDatasetVersionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The resource name of the Dataset version to delete. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}` + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + /** + * Mask specifying which fields to read. + * + * Generated from protobuf field .google.protobuf.FieldMask read_mask = 2; + */ + private $read_mask = null; + + /** + * @param string $name Required. The resource name of the Dataset version to delete. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}` + * Please see {@see DatasetServiceClient::datasetVersionName()} for help formatting this field. + * + * @return \Google\Cloud\AIPlatform\V1\GetDatasetVersionRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The resource name of the Dataset version to delete. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}` + * @type \Google\Protobuf\FieldMask $read_mask + * Mask specifying which fields to read. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Aiplatform\V1\DatasetService::initOnce(); + parent::__construct($data); + } + + /** + * Required. The resource name of the Dataset version to delete. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}` + * + * 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 Dataset version to delete. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}` + * + * 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; + } + + /** + * Mask specifying which fields to read. + * + * Generated from protobuf field .google.protobuf.FieldMask read_mask = 2; + * @return \Google\Protobuf\FieldMask|null + */ + public function getReadMask() + { + return $this->read_mask; + } + + public function hasReadMask() + { + return isset($this->read_mask); + } + + public function clearReadMask() + { + unset($this->read_mask); + } + + /** + * Mask specifying which fields to read. + * + * Generated from protobuf field .google.protobuf.FieldMask read_mask = 2; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setReadMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->read_mask = $var; + + return $this; + } + +} + diff --git a/AiPlatform/src/V1/Index/IndexUpdateMethod.php b/AiPlatform/src/V1/Index/IndexUpdateMethod.php index 86b751e727c8..f0f42043a2d1 100644 --- a/AiPlatform/src/V1/Index/IndexUpdateMethod.php +++ b/AiPlatform/src/V1/Index/IndexUpdateMethod.php @@ -21,7 +21,7 @@ class IndexUpdateMethod const INDEX_UPDATE_METHOD_UNSPECIFIED = 0; /** * BatchUpdate: user can call UpdateIndex with files on Cloud Storage of - * datapoints to update. + * Datapoints to update. * * Generated from protobuf enum BATCH_UPDATE = 1; */ diff --git a/AiPlatform/src/V1/IndexDatapoint.php b/AiPlatform/src/V1/IndexDatapoint.php index 0beb37dabdac..0068a76cdae9 100644 --- a/AiPlatform/src/V1/IndexDatapoint.php +++ b/AiPlatform/src/V1/IndexDatapoint.php @@ -31,7 +31,7 @@ class IndexDatapoint extends \Google\Protobuf\Internal\Message /** * Optional. List of Restrict of the datapoint, used to perform "restricted * searches" where boolean rule are used to filter the subset of the database - * eligible for matching. See: + * eligible for matching. This uses categorical tokens. See: * https://cloud.google.com/vertex-ai/docs/matching-engine/filtering * * Generated from protobuf field repeated .google.cloud.aiplatform.v1.IndexDatapoint.Restriction restricts = 4 [(.google.api.field_behavior) = OPTIONAL]; @@ -59,7 +59,7 @@ class IndexDatapoint extends \Google\Protobuf\Internal\Message * @type array<\Google\Cloud\AIPlatform\V1\IndexDatapoint\Restriction>|\Google\Protobuf\Internal\RepeatedField $restricts * Optional. List of Restrict of the datapoint, used to perform "restricted * searches" where boolean rule are used to filter the subset of the database - * eligible for matching. See: + * eligible for matching. This uses categorical tokens. See: * https://cloud.google.com/vertex-ai/docs/matching-engine/filtering * @type \Google\Cloud\AIPlatform\V1\IndexDatapoint\CrowdingTag $crowding_tag * Optional. CrowdingTag of the datapoint, the number of neighbors to return @@ -128,7 +128,7 @@ public function setFeatureVector($var) /** * Optional. List of Restrict of the datapoint, used to perform "restricted * searches" where boolean rule are used to filter the subset of the database - * eligible for matching. See: + * eligible for matching. This uses categorical tokens. See: * https://cloud.google.com/vertex-ai/docs/matching-engine/filtering * * Generated from protobuf field repeated .google.cloud.aiplatform.v1.IndexDatapoint.Restriction restricts = 4 [(.google.api.field_behavior) = OPTIONAL]; @@ -142,7 +142,7 @@ public function getRestricts() /** * Optional. List of Restrict of the datapoint, used to perform "restricted * searches" where boolean rule are used to filter the subset of the database - * eligible for matching. See: + * eligible for matching. This uses categorical tokens. See: * https://cloud.google.com/vertex-ai/docs/matching-engine/filtering * * Generated from protobuf field repeated .google.cloud.aiplatform.v1.IndexDatapoint.Restriction restricts = 4 [(.google.api.field_behavior) = OPTIONAL]; diff --git a/AiPlatform/src/V1/IndexDatapoint/Restriction.php b/AiPlatform/src/V1/IndexDatapoint/Restriction.php index ca1fb203a0e9..72effa875d21 100644 --- a/AiPlatform/src/V1/IndexDatapoint/Restriction.php +++ b/AiPlatform/src/V1/IndexDatapoint/Restriction.php @@ -17,19 +17,19 @@ class Restriction extends \Google\Protobuf\Internal\Message { /** - * The namespace of this restriction. eg: color. + * The namespace of this restriction. e.g.: color. * * Generated from protobuf field string namespace = 1; */ private $namespace = ''; /** - * The attributes to allow in this namespace. eg: 'red' + * The attributes to allow in this namespace. e.g.: 'red' * * Generated from protobuf field repeated string allow_list = 2; */ private $allow_list; /** - * The attributes to deny in this namespace. eg: 'blue' + * The attributes to deny in this namespace. e.g.: 'blue' * * Generated from protobuf field repeated string deny_list = 3; */ @@ -42,11 +42,11 @@ class Restriction extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $namespace - * The namespace of this restriction. eg: color. + * The namespace of this restriction. e.g.: color. * @type array|\Google\Protobuf\Internal\RepeatedField $allow_list - * The attributes to allow in this namespace. eg: 'red' + * The attributes to allow in this namespace. e.g.: 'red' * @type array|\Google\Protobuf\Internal\RepeatedField $deny_list - * The attributes to deny in this namespace. eg: 'blue' + * The attributes to deny in this namespace. e.g.: 'blue' * } */ public function __construct($data = NULL) { @@ -55,7 +55,7 @@ public function __construct($data = NULL) { } /** - * The namespace of this restriction. eg: color. + * The namespace of this restriction. e.g.: color. * * Generated from protobuf field string namespace = 1; * @return string @@ -66,7 +66,7 @@ public function getNamespace() } /** - * The namespace of this restriction. eg: color. + * The namespace of this restriction. e.g.: color. * * Generated from protobuf field string namespace = 1; * @param string $var @@ -81,7 +81,7 @@ public function setNamespace($var) } /** - * The attributes to allow in this namespace. eg: 'red' + * The attributes to allow in this namespace. e.g.: 'red' * * Generated from protobuf field repeated string allow_list = 2; * @return \Google\Protobuf\Internal\RepeatedField @@ -92,7 +92,7 @@ public function getAllowList() } /** - * The attributes to allow in this namespace. eg: 'red' + * The attributes to allow in this namespace. e.g.: 'red' * * Generated from protobuf field repeated string allow_list = 2; * @param array|\Google\Protobuf\Internal\RepeatedField $var @@ -107,7 +107,7 @@ public function setAllowList($var) } /** - * The attributes to deny in this namespace. eg: 'blue' + * The attributes to deny in this namespace. e.g.: 'blue' * * Generated from protobuf field repeated string deny_list = 3; * @return \Google\Protobuf\Internal\RepeatedField @@ -118,7 +118,7 @@ public function getDenyList() } /** - * The attributes to deny in this namespace. eg: 'blue' + * The attributes to deny in this namespace. e.g.: 'blue' * * Generated from protobuf field repeated string deny_list = 3; * @param array|\Google\Protobuf\Internal\RepeatedField $var diff --git a/AiPlatform/src/V1/ListDatasetVersionsRequest.php b/AiPlatform/src/V1/ListDatasetVersionsRequest.php new file mode 100644 index 000000000000..57a7f519d8cd --- /dev/null +++ b/AiPlatform/src/V1/ListDatasetVersionsRequest.php @@ -0,0 +1,276 @@ +google.cloud.aiplatform.v1.ListDatasetVersionsRequest + */ +class ListDatasetVersionsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The resource name of the Dataset to list DatasetVersions from. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}` + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * Optional. The standard list filter. + * + * Generated from protobuf field string filter = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $filter = ''; + /** + * Optional. The standard list page size. + * + * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_size = 0; + /** + * Optional. The standard list page token. + * + * Generated from protobuf field string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_token = ''; + /** + * Optional. Mask specifying which fields to read. + * + * Generated from protobuf field .google.protobuf.FieldMask read_mask = 5 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $read_mask = null; + /** + * Optional. A comma-separated list of fields to order by, sorted in ascending + * order. Use "desc" after a field name for descending. + * + * Generated from protobuf field string order_by = 6 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $order_by = ''; + + /** + * @param string $parent Required. The resource name of the Dataset to list DatasetVersions from. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}` + * Please see {@see DatasetServiceClient::datasetName()} for help formatting this field. + * + * @return \Google\Cloud\AIPlatform\V1\ListDatasetVersionsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The resource name of the Dataset to list DatasetVersions from. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}` + * @type string $filter + * Optional. The standard list filter. + * @type int $page_size + * Optional. The standard list page size. + * @type string $page_token + * Optional. The standard list page token. + * @type \Google\Protobuf\FieldMask $read_mask + * Optional. Mask specifying which fields to read. + * @type string $order_by + * Optional. A comma-separated list of fields to order by, sorted in ascending + * order. Use "desc" after a field name for descending. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Aiplatform\V1\DatasetService::initOnce(); + parent::__construct($data); + } + + /** + * Required. The resource name of the Dataset to list DatasetVersions from. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}` + * + * 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 name of the Dataset to list DatasetVersions from. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}` + * + * 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. The standard list filter. + * + * Generated from protobuf field string filter = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * Optional. The standard list filter. + * + * 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 standard list page size. + * + * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Optional. The standard list page size. + * + * 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; + } + + /** + * Optional. The standard list page token. + * + * Generated from protobuf field string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * Optional. The standard list page token. + * + * Generated from protobuf field string page_token = 4 [(.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. Mask specifying which fields to read. + * + * Generated from protobuf field .google.protobuf.FieldMask read_mask = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\FieldMask|null + */ + public function getReadMask() + { + return $this->read_mask; + } + + public function hasReadMask() + { + return isset($this->read_mask); + } + + public function clearReadMask() + { + unset($this->read_mask); + } + + /** + * Optional. Mask specifying which fields to read. + * + * Generated from protobuf field .google.protobuf.FieldMask read_mask = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setReadMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->read_mask = $var; + + return $this; + } + + /** + * Optional. A comma-separated list of fields to order by, sorted in ascending + * order. Use "desc" after a field name for descending. + * + * Generated from protobuf field string order_by = 6 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getOrderBy() + { + return $this->order_by; + } + + /** + * Optional. A comma-separated list of fields to order by, sorted in ascending + * order. Use "desc" after a field name for descending. + * + * Generated from protobuf field string order_by = 6 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setOrderBy($var) + { + GPBUtil::checkString($var, True); + $this->order_by = $var; + + return $this; + } + +} + diff --git a/AiPlatform/src/V1/ListDatasetVersionsResponse.php b/AiPlatform/src/V1/ListDatasetVersionsResponse.php new file mode 100644 index 000000000000..86eadf42f22c --- /dev/null +++ b/AiPlatform/src/V1/ListDatasetVersionsResponse.php @@ -0,0 +1,102 @@ +google.cloud.aiplatform.v1.ListDatasetVersionsResponse + */ +class ListDatasetVersionsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * A list of DatasetVersions that matches the specified filter in the request. + * + * Generated from protobuf field repeated .google.cloud.aiplatform.v1.DatasetVersion dataset_versions = 1; + */ + private $dataset_versions; + /** + * The standard List next-page token. + * + * 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 array<\Google\Cloud\AIPlatform\V1\DatasetVersion>|\Google\Protobuf\Internal\RepeatedField $dataset_versions + * A list of DatasetVersions that matches the specified filter in the request. + * @type string $next_page_token + * The standard List next-page token. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Aiplatform\V1\DatasetService::initOnce(); + parent::__construct($data); + } + + /** + * A list of DatasetVersions that matches the specified filter in the request. + * + * Generated from protobuf field repeated .google.cloud.aiplatform.v1.DatasetVersion dataset_versions = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getDatasetVersions() + { + return $this->dataset_versions; + } + + /** + * A list of DatasetVersions that matches the specified filter in the request. + * + * Generated from protobuf field repeated .google.cloud.aiplatform.v1.DatasetVersion dataset_versions = 1; + * @param array<\Google\Cloud\AIPlatform\V1\DatasetVersion>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setDatasetVersions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\AIPlatform\V1\DatasetVersion::class); + $this->dataset_versions = $arr; + + return $this; + } + + /** + * The standard List next-page token. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * The standard List next-page token. + * + * 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/AiPlatform/src/V1/ModelMonitoringAlertConfig.php b/AiPlatform/src/V1/ModelMonitoringAlertConfig.php index 5584339113aa..6570cd8c26bc 100644 --- a/AiPlatform/src/V1/ModelMonitoringAlertConfig.php +++ b/AiPlatform/src/V1/ModelMonitoringAlertConfig.php @@ -23,6 +23,14 @@ class ModelMonitoringAlertConfig extends \Google\Protobuf\Internal\Message * Generated from protobuf field bool enable_logging = 2; */ private $enable_logging = false; + /** + * Resource names of the NotificationChannels to send alert. + * Must be of the format + * `projects//notificationChannels/` + * + * Generated from protobuf field repeated string notification_channels = 3 [(.google.api.resource_reference) = { + */ + private $notification_channels; protected $alert; /** @@ -39,6 +47,10 @@ class ModelMonitoringAlertConfig extends \Google\Protobuf\Internal\Message * [google.cloud.aiplatform.logging.ModelMonitoringAnomaliesLogEntry][]. * This can be further sinked to Pub/Sub or any other services supported * by Cloud Logging. + * @type array|\Google\Protobuf\Internal\RepeatedField $notification_channels + * Resource names of the NotificationChannels to send alert. + * Must be of the format + * `projects//notificationChannels/` * } */ public function __construct($data = NULL) { @@ -111,6 +123,36 @@ public function setEnableLogging($var) return $this; } + /** + * Resource names of the NotificationChannels to send alert. + * Must be of the format + * `projects//notificationChannels/` + * + * Generated from protobuf field repeated string notification_channels = 3 [(.google.api.resource_reference) = { + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getNotificationChannels() + { + return $this->notification_channels; + } + + /** + * Resource names of the NotificationChannels to send alert. + * Must be of the format + * `projects//notificationChannels/` + * + * Generated from protobuf field repeated string notification_channels = 3 [(.google.api.resource_reference) = { + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setNotificationChannels($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->notification_channels = $arr; + + return $this; + } + /** * @return string */ diff --git a/AiPlatform/src/V1/PersistentDiskSpec.php b/AiPlatform/src/V1/PersistentDiskSpec.php new file mode 100644 index 000000000000..0487c4cfeaae --- /dev/null +++ b/AiPlatform/src/V1/PersistentDiskSpec.php @@ -0,0 +1,118 @@ +google.cloud.aiplatform.v1.PersistentDiskSpec + */ +class PersistentDiskSpec extends \Google\Protobuf\Internal\Message +{ + /** + * Type of the disk (default is "pd-standard"). + * Valid values: "pd-ssd" (Persistent Disk Solid State Drive) + * "pd-standard" (Persistent Disk Hard Disk Drive) + * "pd-balanced" (Balanced Persistent Disk) + * "pd-extreme" (Extreme Persistent Disk) + * + * Generated from protobuf field string disk_type = 1; + */ + private $disk_type = ''; + /** + * Size in GB of the disk (default is 100GB). + * + * Generated from protobuf field int64 disk_size_gb = 2; + */ + private $disk_size_gb = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $disk_type + * Type of the disk (default is "pd-standard"). + * Valid values: "pd-ssd" (Persistent Disk Solid State Drive) + * "pd-standard" (Persistent Disk Hard Disk Drive) + * "pd-balanced" (Balanced Persistent Disk) + * "pd-extreme" (Extreme Persistent Disk) + * @type int|string $disk_size_gb + * Size in GB of the disk (default is 100GB). + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Aiplatform\V1\MachineResources::initOnce(); + parent::__construct($data); + } + + /** + * Type of the disk (default is "pd-standard"). + * Valid values: "pd-ssd" (Persistent Disk Solid State Drive) + * "pd-standard" (Persistent Disk Hard Disk Drive) + * "pd-balanced" (Balanced Persistent Disk) + * "pd-extreme" (Extreme Persistent Disk) + * + * Generated from protobuf field string disk_type = 1; + * @return string + */ + public function getDiskType() + { + return $this->disk_type; + } + + /** + * Type of the disk (default is "pd-standard"). + * Valid values: "pd-ssd" (Persistent Disk Solid State Drive) + * "pd-standard" (Persistent Disk Hard Disk Drive) + * "pd-balanced" (Balanced Persistent Disk) + * "pd-extreme" (Extreme Persistent Disk) + * + * Generated from protobuf field string disk_type = 1; + * @param string $var + * @return $this + */ + public function setDiskType($var) + { + GPBUtil::checkString($var, True); + $this->disk_type = $var; + + return $this; + } + + /** + * Size in GB of the disk (default is 100GB). + * + * Generated from protobuf field int64 disk_size_gb = 2; + * @return int|string + */ + public function getDiskSizeGb() + { + return $this->disk_size_gb; + } + + /** + * Size in GB of the disk (default is 100GB). + * + * Generated from protobuf field int64 disk_size_gb = 2; + * @param int|string $var + * @return $this + */ + public function setDiskSizeGb($var) + { + GPBUtil::checkInt64($var); + $this->disk_size_gb = $var; + + return $this; + } + +} + diff --git a/AiPlatform/src/V1/PipelineJob.php b/AiPlatform/src/V1/PipelineJob.php index 80bc38193d1f..5ac537601c05 100644 --- a/AiPlatform/src/V1/PipelineJob.php +++ b/AiPlatform/src/V1/PipelineJob.php @@ -147,7 +147,9 @@ class PipelineJob extends \Google\Protobuf\Internal\Message /** * A template uri from where the * [PipelineJob.pipeline_spec][google.cloud.aiplatform.v1.PipelineJob.pipeline_spec], - * if empty, will be downloaded. + * if empty, will be downloaded. Currently, only uri from Vertex Template + * Registry & Gallery is supported. Reference to + * https://cloud.google.com/vertex-ai/docs/pipelines/create-pipeline-template. * * Generated from protobuf field string template_uri = 19; */ @@ -242,7 +244,9 @@ class PipelineJob extends \Google\Protobuf\Internal\Message * @type string $template_uri * A template uri from where the * [PipelineJob.pipeline_spec][google.cloud.aiplatform.v1.PipelineJob.pipeline_spec], - * if empty, will be downloaded. + * if empty, will be downloaded. Currently, only uri from Vertex Template + * Registry & Gallery is supported. Reference to + * https://cloud.google.com/vertex-ai/docs/pipelines/create-pipeline-template. * @type \Google\Cloud\AIPlatform\V1\PipelineTemplateMetadata $template_metadata * Output only. Pipeline template metadata. Will fill up fields if * [PipelineJob.template_uri][google.cloud.aiplatform.v1.PipelineJob.template_uri] @@ -832,7 +836,9 @@ public function setReservedIpRanges($var) /** * A template uri from where the * [PipelineJob.pipeline_spec][google.cloud.aiplatform.v1.PipelineJob.pipeline_spec], - * if empty, will be downloaded. + * if empty, will be downloaded. Currently, only uri from Vertex Template + * Registry & Gallery is supported. Reference to + * https://cloud.google.com/vertex-ai/docs/pipelines/create-pipeline-template. * * Generated from protobuf field string template_uri = 19; * @return string @@ -845,7 +851,9 @@ public function getTemplateUri() /** * A template uri from where the * [PipelineJob.pipeline_spec][google.cloud.aiplatform.v1.PipelineJob.pipeline_spec], - * if empty, will be downloaded. + * if empty, will be downloaded. Currently, only uri from Vertex Template + * Registry & Gallery is supported. Reference to + * https://cloud.google.com/vertex-ai/docs/pipelines/create-pipeline-template. * * Generated from protobuf field string template_uri = 19; * @param string $var diff --git a/AiPlatform/src/V1/RestoreDatasetVersionRequest.php b/AiPlatform/src/V1/RestoreDatasetVersionRequest.php new file mode 100644 index 000000000000..9b2afc54d556 --- /dev/null +++ b/AiPlatform/src/V1/RestoreDatasetVersionRequest.php @@ -0,0 +1,92 @@ +google.cloud.aiplatform.v1.RestoreDatasetVersionRequest + */ +class RestoreDatasetVersionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the DatasetVersion resource. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}` + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * @param string $name Required. The name of the DatasetVersion resource. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}` + * Please see {@see DatasetServiceClient::datasetVersionName()} for help formatting this field. + * + * @return \Google\Cloud\AIPlatform\V1\RestoreDatasetVersionRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The name of the DatasetVersion resource. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}` + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Aiplatform\V1\DatasetService::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the DatasetVersion resource. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}` + * + * 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 name of the DatasetVersion resource. + * Format: + * `projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}` + * + * 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/AiPlatform/src/V1/gapic_metadata.json b/AiPlatform/src/V1/gapic_metadata.json index 872da2011603..8020268afa26 100644 --- a/AiPlatform/src/V1/gapic_metadata.json +++ b/AiPlatform/src/V1/gapic_metadata.json @@ -15,11 +15,21 @@ "createDataset" ] }, + "CreateDatasetVersion": { + "methods": [ + "createDatasetVersion" + ] + }, "DeleteDataset": { "methods": [ "deleteDataset" ] }, + "DeleteDatasetVersion": { + "methods": [ + "deleteDatasetVersion" + ] + }, "DeleteSavedQuery": { "methods": [ "deleteSavedQuery" @@ -40,6 +50,11 @@ "getDataset" ] }, + "GetDatasetVersion": { + "methods": [ + "getDatasetVersion" + ] + }, "ImportData": { "methods": [ "importData" @@ -55,6 +70,11 @@ "listDataItems" ] }, + "ListDatasetVersions": { + "methods": [ + "listDatasetVersions" + ] + }, "ListDatasets": { "methods": [ "listDatasets" @@ -65,6 +85,11 @@ "listSavedQueries" ] }, + "RestoreDatasetVersion": { + "methods": [ + "restoreDatasetVersion" + ] + }, "SearchDataItems": { "methods": [ "searchDataItems" diff --git a/AiPlatform/src/V1/resources/dataset_service_client_config.json b/AiPlatform/src/V1/resources/dataset_service_client_config.json index 5d5fa64395ae..f2eef2cb9580 100644 --- a/AiPlatform/src/V1/resources/dataset_service_client_config.json +++ b/AiPlatform/src/V1/resources/dataset_service_client_config.json @@ -21,11 +21,21 @@ "retry_codes_name": "no_retry_codes", "retry_params_name": "no_retry_params" }, + "CreateDatasetVersion": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "DeleteDataset": { "timeout_millis": 60000, "retry_codes_name": "no_retry_codes", "retry_params_name": "no_retry_params" }, + "DeleteDatasetVersion": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "DeleteSavedQuery": { "timeout_millis": 60000, "retry_codes_name": "no_retry_codes", @@ -46,6 +56,11 @@ "retry_codes_name": "no_retry_codes", "retry_params_name": "no_retry_params" }, + "GetDatasetVersion": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "ImportData": { "timeout_millis": 60000, "retry_codes_name": "no_retry_codes", @@ -61,6 +76,11 @@ "retry_codes_name": "no_retry_codes", "retry_params_name": "no_retry_params" }, + "ListDatasetVersions": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "ListDatasets": { "timeout_millis": 60000, "retry_codes_name": "no_retry_codes", @@ -71,6 +91,11 @@ "retry_codes_name": "no_retry_codes", "retry_params_name": "no_retry_params" }, + "RestoreDatasetVersion": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "SearchDataItems": { "timeout_millis": 60000, "retry_codes_name": "no_retry_codes", diff --git a/AiPlatform/src/V1/resources/dataset_service_descriptor_config.php b/AiPlatform/src/V1/resources/dataset_service_descriptor_config.php index d46c67019e55..d3a2854f250b 100644 --- a/AiPlatform/src/V1/resources/dataset_service_descriptor_config.php +++ b/AiPlatform/src/V1/resources/dataset_service_descriptor_config.php @@ -22,6 +22,25 @@ ], ], ], + 'CreateDatasetVersion' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\AIPlatform\V1\DatasetVersion', + 'metadataReturnType' => '\Google\Cloud\AIPlatform\V1\CreateDatasetVersionOperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], 'DeleteDataset' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Protobuf\GPBEmpty', @@ -41,6 +60,25 @@ ], ], ], + 'DeleteDatasetVersion' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Protobuf\GPBEmpty', + 'metadataReturnType' => '\Google\Cloud\AIPlatform\V1\DeleteOperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'DeleteSavedQuery' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Protobuf\GPBEmpty', @@ -98,6 +136,25 @@ ], ], ], + 'RestoreDatasetVersion' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\AIPlatform\V1\DatasetVersion', + 'metadataReturnType' => '\Google\Cloud\AIPlatform\V1\RestoreDatasetVersionOperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'GetAnnotationSpec' => [ 'callType' => \Google\ApiCore\Call::UNARY_CALL, 'responseType' => 'Google\Cloud\AIPlatform\V1\AnnotationSpec', @@ -122,6 +179,18 @@ ], ], ], + 'GetDatasetVersion' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\AIPlatform\V1\DatasetVersion', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'ListAnnotations' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', @@ -162,6 +231,26 @@ ], ], ], + 'ListDatasetVersions' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getDatasetVersions', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\AIPlatform\V1\ListDatasetVersionsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], 'ListDatasets' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', @@ -312,6 +401,7 @@ 'annotationSpec' => 'projects/{project}/locations/{location}/datasets/{dataset}/annotationSpecs/{annotation_spec}', 'dataItem' => 'projects/{project}/locations/{location}/datasets/{dataset}/dataItems/{data_item}', 'dataset' => 'projects/{project}/locations/{location}/datasets/{dataset}', + 'datasetVersion' => 'projects/{project}/locations/{location}/datasets/{dataset}/datasetVersions/{dataset_version}', 'location' => 'projects/{project}/locations/{location}', 'savedQuery' => 'projects/{project}/locations/{location}/datasets/{dataset}/savedQueries/{saved_query}', ], diff --git a/AiPlatform/src/V1/resources/dataset_service_rest_client_config.php b/AiPlatform/src/V1/resources/dataset_service_rest_client_config.php index 67389139158b..38ea4623fb5e 100644 --- a/AiPlatform/src/V1/resources/dataset_service_rest_client_config.php +++ b/AiPlatform/src/V1/resources/dataset_service_rest_client_config.php @@ -15,6 +15,18 @@ ], ], ], + 'CreateDatasetVersion' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{parent=projects/*/locations/*/datasets/*}/datasetVersions', + 'body' => 'dataset_version', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], 'DeleteDataset' => [ 'method' => 'delete', 'uriTemplate' => '/v1/{name=projects/*/locations/*/datasets/*}', @@ -26,6 +38,17 @@ ], ], ], + 'DeleteDatasetVersion' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/datasets/*/datasetVersions/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], 'DeleteSavedQuery' => [ 'method' => 'delete', 'uriTemplate' => '/v1/{name=projects/*/locations/*/datasets/*/savedQueries/*}', @@ -71,6 +94,17 @@ ], ], ], + 'GetDatasetVersion' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/datasets/*/datasetVersions/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], 'ImportData' => [ 'method' => 'post', 'uriTemplate' => '/v1/{name=projects/*/locations/*/datasets/*}:import', @@ -105,6 +139,17 @@ ], ], ], + 'ListDatasetVersions' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*/locations/*/datasets/*}/datasetVersions', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], 'ListDatasets' => [ 'method' => 'get', 'uriTemplate' => '/v1/{parent=projects/*/locations/*}/datasets', @@ -127,6 +172,17 @@ ], ], ], + 'RestoreDatasetVersion' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/datasets/*/datasetVersions/*}:restore', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], 'SearchDataItems' => [ 'method' => 'get', 'uriTemplate' => '/v1/{dataset=projects/*/locations/*/datasets/*}:searchDataItems', @@ -200,6 +256,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:getIamPolicy', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:getIamPolicy', @@ -239,6 +299,11 @@ 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy', 'body' => '*', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:setIamPolicy', + 'body' => '*', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:setIamPolicy', @@ -281,6 +346,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:testIamPermissions', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:testIamPermissions', diff --git a/AiPlatform/src/V1/resources/endpoint_service_rest_client_config.php b/AiPlatform/src/V1/resources/endpoint_service_rest_client_config.php index f3221b39582b..d7ea0a7d9425 100644 --- a/AiPlatform/src/V1/resources/endpoint_service_rest_client_config.php +++ b/AiPlatform/src/V1/resources/endpoint_service_rest_client_config.php @@ -146,6 +146,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:getIamPolicy', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:getIamPolicy', @@ -185,6 +189,11 @@ 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy', 'body' => '*', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:setIamPolicy', + 'body' => '*', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:setIamPolicy', @@ -227,6 +236,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:testIamPermissions', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:testIamPermissions', diff --git a/AiPlatform/src/V1/resources/featurestore_online_serving_service_rest_client_config.php b/AiPlatform/src/V1/resources/featurestore_online_serving_service_rest_client_config.php index 1ef752c25468..7b4914d95dee 100644 --- a/AiPlatform/src/V1/resources/featurestore_online_serving_service_rest_client_config.php +++ b/AiPlatform/src/V1/resources/featurestore_online_serving_service_rest_client_config.php @@ -85,6 +85,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:getIamPolicy', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:getIamPolicy', @@ -124,6 +128,11 @@ 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy', 'body' => '*', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:setIamPolicy', + 'body' => '*', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:setIamPolicy', @@ -166,6 +175,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:testIamPermissions', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:testIamPermissions', diff --git a/AiPlatform/src/V1/resources/featurestore_service_rest_client_config.php b/AiPlatform/src/V1/resources/featurestore_service_rest_client_config.php index 00d39e5b3e89..4c1caad95e72 100644 --- a/AiPlatform/src/V1/resources/featurestore_service_rest_client_config.php +++ b/AiPlatform/src/V1/resources/featurestore_service_rest_client_config.php @@ -303,6 +303,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:getIamPolicy', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:getIamPolicy', @@ -342,6 +346,11 @@ 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy', 'body' => '*', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:setIamPolicy', + 'body' => '*', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:setIamPolicy', @@ -384,6 +393,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:testIamPermissions', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:testIamPermissions', diff --git a/AiPlatform/src/V1/resources/index_endpoint_service_rest_client_config.php b/AiPlatform/src/V1/resources/index_endpoint_service_rest_client_config.php index bc547ff581c6..c87d8c950456 100644 --- a/AiPlatform/src/V1/resources/index_endpoint_service_rest_client_config.php +++ b/AiPlatform/src/V1/resources/index_endpoint_service_rest_client_config.php @@ -146,6 +146,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:getIamPolicy', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:getIamPolicy', @@ -185,6 +189,11 @@ 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy', 'body' => '*', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:setIamPolicy', + 'body' => '*', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:setIamPolicy', @@ -227,6 +236,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:testIamPermissions', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:testIamPermissions', diff --git a/AiPlatform/src/V1/resources/index_service_rest_client_config.php b/AiPlatform/src/V1/resources/index_service_rest_client_config.php index 11923f6690c5..e4f5ba8e4030 100644 --- a/AiPlatform/src/V1/resources/index_service_rest_client_config.php +++ b/AiPlatform/src/V1/resources/index_service_rest_client_config.php @@ -131,6 +131,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:getIamPolicy', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:getIamPolicy', @@ -170,6 +174,11 @@ 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy', 'body' => '*', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:setIamPolicy', + 'body' => '*', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:setIamPolicy', @@ -212,6 +221,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:testIamPermissions', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:testIamPermissions', diff --git a/AiPlatform/src/V1/resources/job_service_descriptor_config.php b/AiPlatform/src/V1/resources/job_service_descriptor_config.php index 6fe00220ecb4..70bd84ce450b 100644 --- a/AiPlatform/src/V1/resources/job_service_descriptor_config.php +++ b/AiPlatform/src/V1/resources/job_service_descriptor_config.php @@ -624,6 +624,7 @@ 'nasJob' => 'projects/{project}/locations/{location}/nasJobs/{nas_job}', 'nasTrialDetail' => 'projects/{project}/locations/{location}/nasJobs/{nas_job}/nasTrialDetails/{nas_trial_detail}', 'network' => 'projects/{project}/global/networks/{network}', + 'notificationChannel' => 'projects/{project}/notificationChannels/{notification_channel}', 'projectLocationEndpoint' => 'projects/{project}/locations/{location}/endpoints/{endpoint}', 'projectLocationPublisherModel' => 'projects/{project}/locations/{location}/publishers/{publisher}/models/{model}', 'tensorboard' => 'projects/{project}/locations/{location}/tensorboards/{tensorboard}', diff --git a/AiPlatform/src/V1/resources/job_service_rest_client_config.php b/AiPlatform/src/V1/resources/job_service_rest_client_config.php index 66e14217426e..32433ec713f6 100644 --- a/AiPlatform/src/V1/resources/job_service_rest_client_config.php +++ b/AiPlatform/src/V1/resources/job_service_rest_client_config.php @@ -453,6 +453,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:getIamPolicy', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:getIamPolicy', @@ -492,6 +496,11 @@ 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy', 'body' => '*', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:setIamPolicy', + 'body' => '*', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:setIamPolicy', @@ -534,6 +543,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:testIamPermissions', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:testIamPermissions', diff --git a/AiPlatform/src/V1/resources/match_service_rest_client_config.php b/AiPlatform/src/V1/resources/match_service_rest_client_config.php index c4b8b0d4ce6c..826d4d9edd4e 100644 --- a/AiPlatform/src/V1/resources/match_service_rest_client_config.php +++ b/AiPlatform/src/V1/resources/match_service_rest_client_config.php @@ -73,6 +73,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:getIamPolicy', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:getIamPolicy', @@ -112,6 +116,11 @@ 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy', 'body' => '*', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:setIamPolicy', + 'body' => '*', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:setIamPolicy', @@ -154,6 +163,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:testIamPermissions', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:testIamPermissions', diff --git a/AiPlatform/src/V1/resources/metadata_service_rest_client_config.php b/AiPlatform/src/V1/resources/metadata_service_rest_client_config.php index e98856611ede..08282a70c520 100644 --- a/AiPlatform/src/V1/resources/metadata_service_rest_client_config.php +++ b/AiPlatform/src/V1/resources/metadata_service_rest_client_config.php @@ -419,6 +419,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:getIamPolicy', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:getIamPolicy', @@ -458,6 +462,11 @@ 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy', 'body' => '*', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:setIamPolicy', + 'body' => '*', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:setIamPolicy', @@ -500,6 +509,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:testIamPermissions', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:testIamPermissions', diff --git a/AiPlatform/src/V1/resources/migration_service_rest_client_config.php b/AiPlatform/src/V1/resources/migration_service_rest_client_config.php index d2ec0de71bf8..692a410b773b 100644 --- a/AiPlatform/src/V1/resources/migration_service_rest_client_config.php +++ b/AiPlatform/src/V1/resources/migration_service_rest_client_config.php @@ -73,6 +73,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:getIamPolicy', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:getIamPolicy', @@ -112,6 +116,11 @@ 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy', 'body' => '*', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:setIamPolicy', + 'body' => '*', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:setIamPolicy', @@ -154,6 +163,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:testIamPermissions', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:testIamPermissions', diff --git a/AiPlatform/src/V1/resources/model_garden_service_rest_client_config.php b/AiPlatform/src/V1/resources/model_garden_service_rest_client_config.php index c29d4164a9ae..668e00d7d3be 100644 --- a/AiPlatform/src/V1/resources/model_garden_service_rest_client_config.php +++ b/AiPlatform/src/V1/resources/model_garden_service_rest_client_config.php @@ -60,6 +60,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:getIamPolicy', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:getIamPolicy', @@ -99,6 +103,11 @@ 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy', 'body' => '*', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:setIamPolicy', + 'body' => '*', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:setIamPolicy', @@ -141,6 +150,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:testIamPermissions', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:testIamPermissions', diff --git a/AiPlatform/src/V1/resources/model_service_rest_client_config.php b/AiPlatform/src/V1/resources/model_service_rest_client_config.php index b8ab77779e83..36b6a80453f7 100644 --- a/AiPlatform/src/V1/resources/model_service_rest_client_config.php +++ b/AiPlatform/src/V1/resources/model_service_rest_client_config.php @@ -260,6 +260,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:getIamPolicy', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:getIamPolicy', @@ -299,6 +303,11 @@ 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy', 'body' => '*', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:setIamPolicy', + 'body' => '*', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:setIamPolicy', @@ -341,6 +350,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:testIamPermissions', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:testIamPermissions', diff --git a/AiPlatform/src/V1/resources/pipeline_service_rest_client_config.php b/AiPlatform/src/V1/resources/pipeline_service_rest_client_config.php index b46e255cb989..16bd34b90de0 100644 --- a/AiPlatform/src/V1/resources/pipeline_service_rest_client_config.php +++ b/AiPlatform/src/V1/resources/pipeline_service_rest_client_config.php @@ -163,6 +163,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:getIamPolicy', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:getIamPolicy', @@ -202,6 +206,11 @@ 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy', 'body' => '*', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:setIamPolicy', + 'body' => '*', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:setIamPolicy', @@ -244,6 +253,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:testIamPermissions', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:testIamPermissions', diff --git a/AiPlatform/src/V1/resources/prediction_service_rest_client_config.php b/AiPlatform/src/V1/resources/prediction_service_rest_client_config.php index 6b7e288a0406..3efd81af503d 100644 --- a/AiPlatform/src/V1/resources/prediction_service_rest_client_config.php +++ b/AiPlatform/src/V1/resources/prediction_service_rest_client_config.php @@ -118,6 +118,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:getIamPolicy', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:getIamPolicy', @@ -157,6 +161,11 @@ 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy', 'body' => '*', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:setIamPolicy', + 'body' => '*', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:setIamPolicy', @@ -199,6 +208,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:testIamPermissions', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:testIamPermissions', diff --git a/AiPlatform/src/V1/resources/schedule_service_rest_client_config.php b/AiPlatform/src/V1/resources/schedule_service_rest_client_config.php index 4efabf54dec8..7e062f1abdf8 100644 --- a/AiPlatform/src/V1/resources/schedule_service_rest_client_config.php +++ b/AiPlatform/src/V1/resources/schedule_service_rest_client_config.php @@ -134,6 +134,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:getIamPolicy', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:getIamPolicy', @@ -173,6 +177,11 @@ 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy', 'body' => '*', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:setIamPolicy', + 'body' => '*', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:setIamPolicy', @@ -215,6 +224,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:testIamPermissions', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:testIamPermissions', diff --git a/AiPlatform/src/V1/resources/specialist_pool_service_rest_client_config.php b/AiPlatform/src/V1/resources/specialist_pool_service_rest_client_config.php index 3cee9f87a82d..c1a5c0e54208 100644 --- a/AiPlatform/src/V1/resources/specialist_pool_service_rest_client_config.php +++ b/AiPlatform/src/V1/resources/specialist_pool_service_rest_client_config.php @@ -110,6 +110,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:getIamPolicy', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:getIamPolicy', @@ -149,6 +153,11 @@ 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy', 'body' => '*', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:setIamPolicy', + 'body' => '*', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:setIamPolicy', @@ -191,6 +200,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:testIamPermissions', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:testIamPermissions', diff --git a/AiPlatform/src/V1/resources/tensorboard_service_rest_client_config.php b/AiPlatform/src/V1/resources/tensorboard_service_rest_client_config.php index 486db4379a85..85296eb5c0ce 100644 --- a/AiPlatform/src/V1/resources/tensorboard_service_rest_client_config.php +++ b/AiPlatform/src/V1/resources/tensorboard_service_rest_client_config.php @@ -414,6 +414,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:getIamPolicy', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:getIamPolicy', @@ -453,6 +457,11 @@ 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy', 'body' => '*', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:setIamPolicy', + 'body' => '*', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:setIamPolicy', @@ -495,6 +504,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:testIamPermissions', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:testIamPermissions', diff --git a/AiPlatform/src/V1/resources/vizier_service_rest_client_config.php b/AiPlatform/src/V1/resources/vizier_service_rest_client_config.php index 2f197a14a9ef..b994ea053dad 100644 --- a/AiPlatform/src/V1/resources/vizier_service_rest_client_config.php +++ b/AiPlatform/src/V1/resources/vizier_service_rest_client_config.php @@ -223,6 +223,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:getIamPolicy', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:getIamPolicy', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:getIamPolicy', @@ -262,6 +266,11 @@ 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:setIamPolicy', 'body' => '*', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:setIamPolicy', + 'body' => '*', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:setIamPolicy', @@ -304,6 +313,10 @@ 'method' => 'post', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/featurestores/*/entityTypes/*}:testIamPermissions', ], + [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/notebookRuntimeTemplates/*}:testIamPermissions', + ], [ 'method' => 'post', 'uriTemplate' => '/ui/{resource=projects/*/locations/*/featurestores/*}:testIamPermissions', diff --git a/AiPlatform/tests/Unit/V1/Client/DatasetServiceClientTest.php b/AiPlatform/tests/Unit/V1/Client/DatasetServiceClientTest.php index e877450a5790..ae8c569884b2 100644 --- a/AiPlatform/tests/Unit/V1/Client/DatasetServiceClientTest.php +++ b/AiPlatform/tests/Unit/V1/Client/DatasetServiceClientTest.php @@ -31,26 +31,33 @@ use Google\Cloud\AIPlatform\V1\AnnotationSpec; use Google\Cloud\AIPlatform\V1\Client\DatasetServiceClient; use Google\Cloud\AIPlatform\V1\CreateDatasetRequest; +use Google\Cloud\AIPlatform\V1\CreateDatasetVersionRequest; use Google\Cloud\AIPlatform\V1\DataItem; use Google\Cloud\AIPlatform\V1\DataItemView; use Google\Cloud\AIPlatform\V1\Dataset; +use Google\Cloud\AIPlatform\V1\DatasetVersion; use Google\Cloud\AIPlatform\V1\DeleteDatasetRequest; +use Google\Cloud\AIPlatform\V1\DeleteDatasetVersionRequest; use Google\Cloud\AIPlatform\V1\DeleteSavedQueryRequest; use Google\Cloud\AIPlatform\V1\ExportDataConfig; use Google\Cloud\AIPlatform\V1\ExportDataRequest; use Google\Cloud\AIPlatform\V1\ExportDataResponse; use Google\Cloud\AIPlatform\V1\GetAnnotationSpecRequest; use Google\Cloud\AIPlatform\V1\GetDatasetRequest; +use Google\Cloud\AIPlatform\V1\GetDatasetVersionRequest; use Google\Cloud\AIPlatform\V1\ImportDataRequest; use Google\Cloud\AIPlatform\V1\ImportDataResponse; use Google\Cloud\AIPlatform\V1\ListAnnotationsRequest; use Google\Cloud\AIPlatform\V1\ListAnnotationsResponse; use Google\Cloud\AIPlatform\V1\ListDataItemsRequest; use Google\Cloud\AIPlatform\V1\ListDataItemsResponse; +use Google\Cloud\AIPlatform\V1\ListDatasetVersionsRequest; +use Google\Cloud\AIPlatform\V1\ListDatasetVersionsResponse; use Google\Cloud\AIPlatform\V1\ListDatasetsRequest; use Google\Cloud\AIPlatform\V1\ListDatasetsResponse; use Google\Cloud\AIPlatform\V1\ListSavedQueriesRequest; use Google\Cloud\AIPlatform\V1\ListSavedQueriesResponse; +use Google\Cloud\AIPlatform\V1\RestoreDatasetVersionRequest; use Google\Cloud\AIPlatform\V1\SavedQuery; use Google\Cloud\AIPlatform\V1\SearchDataItemsRequest; use Google\Cloud\AIPlatform\V1\SearchDataItemsResponse; @@ -254,6 +261,139 @@ public function createDatasetExceptionTest() $this->assertTrue($operationsTransport->isExhausted()); } + /** @test */ + public function createDatasetVersionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createDatasetVersionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $etag = 'etag3123477'; + $bigQueryDatasetName = 'bigQueryDatasetName-1230960216'; + $expectedResponse = new DatasetVersion(); + $expectedResponse->setName($name); + $expectedResponse->setEtag($etag); + $expectedResponse->setBigQueryDatasetName($bigQueryDatasetName); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createDatasetVersionTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + $datasetVersion = new DatasetVersion(); + $request = (new CreateDatasetVersionRequest()) + ->setParent($formattedParent) + ->setDatasetVersion($datasetVersion); + $response = $gapicClient->createDatasetVersion($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.aiplatform.v1.DatasetService/CreateDatasetVersion', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getDatasetVersion(); + $this->assertProtobufEquals($datasetVersion, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createDatasetVersionTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createDatasetVersionExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createDatasetVersionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + $datasetVersion = new DatasetVersion(); + $request = (new CreateDatasetVersionRequest()) + ->setParent($formattedParent) + ->setDatasetVersion($datasetVersion); + $response = $gapicClient->createDatasetVersion($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createDatasetVersionTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + /** @test */ public function deleteDatasetTest() { @@ -375,6 +515,127 @@ public function deleteDatasetExceptionTest() $this->assertTrue($operationsTransport->isExhausted()); } + /** @test */ + public function deleteDatasetVersionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/deleteDatasetVersionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $expectedResponse = new GPBEmpty(); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/deleteDatasetVersionTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedName = $gapicClient->datasetVersionName('[PROJECT]', '[LOCATION]', '[DATASET]', '[DATASET_VERSION]'); + $request = (new DeleteDatasetVersionRequest()) + ->setName($formattedName); + $response = $gapicClient->deleteDatasetVersion($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.aiplatform.v1.DatasetService/DeleteDatasetVersion', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/deleteDatasetVersionTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function deleteDatasetVersionExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/deleteDatasetVersionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->datasetVersionName('[PROJECT]', '[LOCATION]', '[DATASET]', '[DATASET_VERSION]'); + $request = (new DeleteDatasetVersionRequest()) + ->setName($formattedName); + $response = $gapicClient->deleteDatasetVersion($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/deleteDatasetVersionTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + /** @test */ public function deleteSavedQueryTest() { @@ -767,6 +1028,74 @@ public function getDatasetExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function getDatasetVersionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $etag = 'etag3123477'; + $bigQueryDatasetName = 'bigQueryDatasetName-1230960216'; + $expectedResponse = new DatasetVersion(); + $expectedResponse->setName($name2); + $expectedResponse->setEtag($etag); + $expectedResponse->setBigQueryDatasetName($bigQueryDatasetName); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->datasetVersionName('[PROJECT]', '[LOCATION]', '[DATASET]', '[DATASET_VERSION]'); + $request = (new GetDatasetVersionRequest()) + ->setName($formattedName); + $response = $gapicClient->getDatasetVersion($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.aiplatform.v1.DatasetService/GetDatasetVersion', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getDatasetVersionExceptionTest() + { + $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 + $formattedName = $gapicClient->datasetVersionName('[PROJECT]', '[LOCATION]', '[DATASET]', '[DATASET_VERSION]'); + $request = (new GetDatasetVersionRequest()) + ->setName($formattedName); + try { + $gapicClient->getDatasetVersion($request); + // 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 importDataTest() { @@ -1038,6 +1367,78 @@ public function listDataItemsExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function listDatasetVersionsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $datasetVersionsElement = new DatasetVersion(); + $datasetVersions = [ + $datasetVersionsElement, + ]; + $expectedResponse = new ListDatasetVersionsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setDatasetVersions($datasetVersions); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + $request = (new ListDatasetVersionsRequest()) + ->setParent($formattedParent); + $response = $gapicClient->listDatasetVersions($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getDatasetVersions()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.aiplatform.v1.DatasetService/ListDatasetVersions', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listDatasetVersionsExceptionTest() + { + $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 + $formattedParent = $gapicClient->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + $request = (new ListDatasetVersionsRequest()) + ->setParent($formattedParent); + try { + $gapicClient->listDatasetVersions($request); + // 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 listDatasetsTest() { @@ -1182,6 +1583,133 @@ public function listSavedQueriesExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function restoreDatasetVersionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/restoreDatasetVersionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name2 = 'name2-1052831874'; + $etag = 'etag3123477'; + $bigQueryDatasetName = 'bigQueryDatasetName-1230960216'; + $expectedResponse = new DatasetVersion(); + $expectedResponse->setName($name2); + $expectedResponse->setEtag($etag); + $expectedResponse->setBigQueryDatasetName($bigQueryDatasetName); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/restoreDatasetVersionTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedName = $gapicClient->datasetVersionName('[PROJECT]', '[LOCATION]', '[DATASET]', '[DATASET_VERSION]'); + $request = (new RestoreDatasetVersionRequest()) + ->setName($formattedName); + $response = $gapicClient->restoreDatasetVersion($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.aiplatform.v1.DatasetService/RestoreDatasetVersion', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/restoreDatasetVersionTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function restoreDatasetVersionExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/restoreDatasetVersionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->datasetVersionName('[PROJECT]', '[LOCATION]', '[DATASET]', '[DATASET_VERSION]'); + $request = (new RestoreDatasetVersionRequest()) + ->setName($formattedName); + $response = $gapicClient->restoreDatasetVersion($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/restoreDatasetVersionTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + /** @test */ public function searchDataItemsTest() { diff --git a/AiPlatform/tests/Unit/V1/DatasetServiceClientTest.php b/AiPlatform/tests/Unit/V1/DatasetServiceClientTest.php index 36f862c03c44..1b165968f0b6 100644 --- a/AiPlatform/tests/Unit/V1/DatasetServiceClientTest.php +++ b/AiPlatform/tests/Unit/V1/DatasetServiceClientTest.php @@ -33,11 +33,13 @@ use Google\Cloud\AIPlatform\V1\DataItemView; use Google\Cloud\AIPlatform\V1\Dataset; use Google\Cloud\AIPlatform\V1\DatasetServiceClient; +use Google\Cloud\AIPlatform\V1\DatasetVersion; use Google\Cloud\AIPlatform\V1\ExportDataConfig; use Google\Cloud\AIPlatform\V1\ExportDataResponse; use Google\Cloud\AIPlatform\V1\ImportDataResponse; use Google\Cloud\AIPlatform\V1\ListAnnotationsResponse; use Google\Cloud\AIPlatform\V1\ListDataItemsResponse; +use Google\Cloud\AIPlatform\V1\ListDatasetVersionsResponse; use Google\Cloud\AIPlatform\V1\ListDatasetsResponse; use Google\Cloud\AIPlatform\V1\ListSavedQueriesResponse; use Google\Cloud\AIPlatform\V1\SavedQuery; @@ -230,6 +232,133 @@ public function createDatasetExceptionTest() $this->assertTrue($operationsTransport->isExhausted()); } + /** @test */ + public function createDatasetVersionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createDatasetVersionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $etag = 'etag3123477'; + $bigQueryDatasetName = 'bigQueryDatasetName-1230960216'; + $expectedResponse = new DatasetVersion(); + $expectedResponse->setName($name); + $expectedResponse->setEtag($etag); + $expectedResponse->setBigQueryDatasetName($bigQueryDatasetName); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createDatasetVersionTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + $datasetVersion = new DatasetVersion(); + $response = $gapicClient->createDatasetVersion($formattedParent, $datasetVersion); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.aiplatform.v1.DatasetService/CreateDatasetVersion', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getDatasetVersion(); + $this->assertProtobufEquals($datasetVersion, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createDatasetVersionTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createDatasetVersionExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createDatasetVersionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + $datasetVersion = new DatasetVersion(); + $response = $gapicClient->createDatasetVersion($formattedParent, $datasetVersion); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createDatasetVersionTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + /** @test */ public function deleteDatasetTest() { @@ -347,6 +476,123 @@ public function deleteDatasetExceptionTest() $this->assertTrue($operationsTransport->isExhausted()); } + /** @test */ + public function deleteDatasetVersionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/deleteDatasetVersionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $expectedResponse = new GPBEmpty(); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/deleteDatasetVersionTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedName = $gapicClient->datasetVersionName('[PROJECT]', '[LOCATION]', '[DATASET]', '[DATASET_VERSION]'); + $response = $gapicClient->deleteDatasetVersion($formattedName); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.aiplatform.v1.DatasetService/DeleteDatasetVersion', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/deleteDatasetVersionTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function deleteDatasetVersionExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/deleteDatasetVersionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->datasetVersionName('[PROJECT]', '[LOCATION]', '[DATASET]', '[DATASET_VERSION]'); + $response = $gapicClient->deleteDatasetVersion($formattedName); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/deleteDatasetVersionTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + /** @test */ public function deleteSavedQueryTest() { @@ -721,6 +967,70 @@ public function getDatasetExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function getDatasetVersionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $etag = 'etag3123477'; + $bigQueryDatasetName = 'bigQueryDatasetName-1230960216'; + $expectedResponse = new DatasetVersion(); + $expectedResponse->setName($name2); + $expectedResponse->setEtag($etag); + $expectedResponse->setBigQueryDatasetName($bigQueryDatasetName); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->datasetVersionName('[PROJECT]', '[LOCATION]', '[DATASET]', '[DATASET_VERSION]'); + $response = $gapicClient->getDatasetVersion($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.aiplatform.v1.DatasetService/GetDatasetVersion', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getDatasetVersionExceptionTest() + { + $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 + $formattedName = $gapicClient->datasetVersionName('[PROJECT]', '[LOCATION]', '[DATASET]', '[DATASET_VERSION]'); + try { + $gapicClient->getDatasetVersion($formattedName); + // 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 importDataTest() { @@ -978,6 +1288,74 @@ public function listDataItemsExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function listDatasetVersionsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $datasetVersionsElement = new DatasetVersion(); + $datasetVersions = [ + $datasetVersionsElement, + ]; + $expectedResponse = new ListDatasetVersionsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setDatasetVersions($datasetVersions); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + $response = $gapicClient->listDatasetVersions($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getDatasetVersions()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.aiplatform.v1.DatasetService/ListDatasetVersions', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listDatasetVersionsExceptionTest() + { + $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 + $formattedParent = $gapicClient->datasetName('[PROJECT]', '[LOCATION]', '[DATASET]'); + try { + $gapicClient->listDatasetVersions($formattedParent); + // 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 listDatasetsTest() { @@ -1114,6 +1492,129 @@ public function listSavedQueriesExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function restoreDatasetVersionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/restoreDatasetVersionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name2 = 'name2-1052831874'; + $etag = 'etag3123477'; + $bigQueryDatasetName = 'bigQueryDatasetName-1230960216'; + $expectedResponse = new DatasetVersion(); + $expectedResponse->setName($name2); + $expectedResponse->setEtag($etag); + $expectedResponse->setBigQueryDatasetName($bigQueryDatasetName); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/restoreDatasetVersionTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedName = $gapicClient->datasetVersionName('[PROJECT]', '[LOCATION]', '[DATASET]', '[DATASET_VERSION]'); + $response = $gapicClient->restoreDatasetVersion($formattedName); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.aiplatform.v1.DatasetService/RestoreDatasetVersion', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/restoreDatasetVersionTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function restoreDatasetVersionExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/restoreDatasetVersionTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $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); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->datasetVersionName('[PROJECT]', '[LOCATION]', '[DATASET]', '[DATASET_VERSION]'); + $response = $gapicClient->restoreDatasetVersion($formattedName); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/restoreDatasetVersionTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() 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 stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + /** @test */ public function searchDataItemsTest() { diff --git a/AlloyDb/composer.json b/AlloyDb/composer.json index 4ffbd12ec471..c47f31cb6293 100644 --- a/AlloyDb/composer.json +++ b/AlloyDb/composer.json @@ -18,7 +18,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/AlloyDb/src/V1/Client/AlloyDBAdminClient.php b/AlloyDb/src/V1/Client/AlloyDBAdminClient.php index c51843392de7..39579c9fe5e4 100644 --- a/AlloyDb/src/V1/Client/AlloyDBAdminClient.php +++ b/AlloyDb/src/V1/Client/AlloyDBAdminClient.php @@ -24,17 +24,1299 @@ namespace Google\Cloud\AlloyDb\V1\Client; -use Google\Cloud\AlloyDb\V1\Client\BaseClient\AlloyDBAdminBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AlloyDb\V1\Backup; +use Google\Cloud\AlloyDb\V1\BatchCreateInstancesRequest; +use Google\Cloud\AlloyDb\V1\Cluster; +use Google\Cloud\AlloyDb\V1\ConnectionInfo; +use Google\Cloud\AlloyDb\V1\CreateBackupRequest; +use Google\Cloud\AlloyDb\V1\CreateClusterRequest; +use Google\Cloud\AlloyDb\V1\CreateInstanceRequest; +use Google\Cloud\AlloyDb\V1\CreateSecondaryClusterRequest; +use Google\Cloud\AlloyDb\V1\CreateSecondaryInstanceRequest; +use Google\Cloud\AlloyDb\V1\CreateUserRequest; +use Google\Cloud\AlloyDb\V1\DeleteBackupRequest; +use Google\Cloud\AlloyDb\V1\DeleteClusterRequest; +use Google\Cloud\AlloyDb\V1\DeleteInstanceRequest; +use Google\Cloud\AlloyDb\V1\DeleteUserRequest; +use Google\Cloud\AlloyDb\V1\FailoverInstanceRequest; +use Google\Cloud\AlloyDb\V1\GenerateClientCertificateRequest; +use Google\Cloud\AlloyDb\V1\GenerateClientCertificateResponse; +use Google\Cloud\AlloyDb\V1\GetBackupRequest; +use Google\Cloud\AlloyDb\V1\GetClusterRequest; +use Google\Cloud\AlloyDb\V1\GetConnectionInfoRequest; +use Google\Cloud\AlloyDb\V1\GetInstanceRequest; +use Google\Cloud\AlloyDb\V1\GetUserRequest; +use Google\Cloud\AlloyDb\V1\InjectFaultRequest; +use Google\Cloud\AlloyDb\V1\Instance; +use Google\Cloud\AlloyDb\V1\ListBackupsRequest; +use Google\Cloud\AlloyDb\V1\ListClustersRequest; +use Google\Cloud\AlloyDb\V1\ListInstancesRequest; +use Google\Cloud\AlloyDb\V1\ListSupportedDatabaseFlagsRequest; +use Google\Cloud\AlloyDb\V1\ListUsersRequest; +use Google\Cloud\AlloyDb\V1\PromoteClusterRequest; +use Google\Cloud\AlloyDb\V1\RestartInstanceRequest; +use Google\Cloud\AlloyDb\V1\RestoreClusterRequest; +use Google\Cloud\AlloyDb\V1\UpdateBackupRequest; +use Google\Cloud\AlloyDb\V1\UpdateClusterRequest; +use Google\Cloud\AlloyDb\V1\UpdateInstanceRequest; +use Google\Cloud\AlloyDb\V1\UpdateUserRequest; +use Google\Cloud\AlloyDb\V1\User; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service describing handlers for resources * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AlloyDb\V1\AlloyDBAdminClient} for the stable implementation * * @experimental + * + * @method PromiseInterface batchCreateInstancesAsync(BatchCreateInstancesRequest $request, array $optionalArgs = []) + * @method PromiseInterface createBackupAsync(CreateBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface createClusterAsync(CreateClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface createInstanceAsync(CreateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSecondaryClusterAsync(CreateSecondaryClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSecondaryInstanceAsync(CreateSecondaryInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface createUserAsync(CreateUserRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteBackupAsync(DeleteBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteClusterAsync(DeleteClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteInstanceAsync(DeleteInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteUserAsync(DeleteUserRequest $request, array $optionalArgs = []) + * @method PromiseInterface failoverInstanceAsync(FailoverInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface generateClientCertificateAsync(GenerateClientCertificateRequest $request, array $optionalArgs = []) + * @method PromiseInterface getBackupAsync(GetBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface getClusterAsync(GetClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface getConnectionInfoAsync(GetConnectionInfoRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInstanceAsync(GetInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getUserAsync(GetUserRequest $request, array $optionalArgs = []) + * @method PromiseInterface injectFaultAsync(InjectFaultRequest $request, array $optionalArgs = []) + * @method PromiseInterface listBackupsAsync(ListBackupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listClustersAsync(ListClustersRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInstancesAsync(ListInstancesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSupportedDatabaseFlagsAsync(ListSupportedDatabaseFlagsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listUsersAsync(ListUsersRequest $request, array $optionalArgs = []) + * @method PromiseInterface promoteClusterAsync(PromoteClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface restartInstanceAsync(RestartInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface restoreClusterAsync(RestoreClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateBackupAsync(UpdateBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateClusterAsync(UpdateClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateInstanceAsync(UpdateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateUserAsync(UpdateUserRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class AlloyDBAdminClient extends AlloyDBAdminBaseClient +final class AlloyDBAdminClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AlloyDBAdminBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.alloydb.v1.AlloyDBAdmin'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'alloydb.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/alloy_db_admin_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/alloy_db_admin_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/alloy_db_admin_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/alloy_db_admin_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a backup + * resource. + * + * @param string $project + * @param string $location + * @param string $backup + * + * @return string The formatted backup resource. + */ + public static function backupName(string $project, string $location, string $backup): string + { + return self::getPathTemplate('backup')->render([ + 'project' => $project, + 'location' => $location, + 'backup' => $backup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a cluster + * resource. + * + * @param string $project + * @param string $location + * @param string $cluster + * + * @return string The formatted cluster resource. + */ + public static function clusterName(string $project, string $location, string $cluster): string + { + return self::getPathTemplate('cluster')->render([ + 'project' => $project, + 'location' => $location, + 'cluster' => $cluster, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * crypto_key_version resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * @param string $cryptoKeyVersion + * + * @return string The formatted crypto_key_version resource. + */ + public static function cryptoKeyVersionName(string $project, string $location, string $keyRing, string $cryptoKey, string $cryptoKeyVersion): string + { + return self::getPathTemplate('cryptoKeyVersion')->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'crypto_key' => $cryptoKey, + 'crypto_key_version' => $cryptoKeyVersion, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a instance + * resource. + * + * @param string $project + * @param string $location + * @param string $cluster + * @param string $instance + * + * @return string The formatted instance resource. + */ + public static function instanceName(string $project, string $location, string $cluster, string $instance): string + { + return self::getPathTemplate('instance')->render([ + 'project' => $project, + 'location' => $location, + 'cluster' => $cluster, + 'instance' => $instance, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a network + * resource. + * + * @param string $project + * @param string $network + * + * @return string The formatted network resource. + */ + public static function networkName(string $project, string $network): string + { + return self::getPathTemplate('network')->render([ + 'project' => $project, + 'network' => $network, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a user + * resource. + * + * @param string $project + * @param string $location + * @param string $cluster + * @param string $user + * + * @return string The formatted user resource. + */ + public static function userName(string $project, string $location, string $cluster, string $user): string + { + return self::getPathTemplate('user')->render([ + 'project' => $project, + 'location' => $location, + 'cluster' => $cluster, + 'user' => $user, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - backup: projects/{project}/locations/{location}/backups/{backup} + * - cluster: projects/{project}/locations/{location}/clusters/{cluster} + * - cryptoKeyVersion: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version} + * - instance: projects/{project}/locations/{location}/clusters/{cluster}/instances/{instance} + * - location: projects/{project}/locations/{location} + * - network: projects/{project}/global/networks/{network} + * - user: projects/{project}/locations/{location}/clusters/{cluster}/users/{user} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'alloydb.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates new instances under the given project, location and cluster. + * There can be only one primary instance in a cluster. If the primary + * instance exists in the cluster as well as this request, then API will + * throw an error. + * The primary instance should exist before any read pool instance is + * created. If the primary instance is a part of the request payload, then + * the API will take care of creating instances in the correct order. + * This method is here to support Google-internal use cases, and is not meant + * for external customers to consume. Please do not start relying on it; its + * behavior is subject to change without notice. + * + * The async variant is {@see AlloyDBAdminClient::batchCreateInstancesAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/batch_create_instances.php + * + * @param BatchCreateInstancesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchCreateInstances(BatchCreateInstancesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchCreateInstances', $request, $callOptions)->wait(); + } + + /** + * Creates a new Backup in a given project and location. + * + * The async variant is {@see AlloyDBAdminClient::createBackupAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/create_backup.php + * + * @param CreateBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createBackup(CreateBackupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateBackup', $request, $callOptions)->wait(); + } + + /** + * Creates a new Cluster in a given project and location. + * + * The async variant is {@see AlloyDBAdminClient::createClusterAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/create_cluster.php + * + * @param CreateClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCluster(CreateClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateCluster', $request, $callOptions)->wait(); + } + + /** + * Creates a new Instance in a given project and location. + * + * The async variant is {@see AlloyDBAdminClient::createInstanceAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/create_instance.php + * + * @param CreateInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createInstance(CreateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateInstance', $request, $callOptions)->wait(); + } + + /** + * Creates a cluster of type SECONDARY in the given location using + * the primary cluster as the source. + * + * The async variant is {@see AlloyDBAdminClient::createSecondaryClusterAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/create_secondary_cluster.php + * + * @param CreateSecondaryClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSecondaryCluster(CreateSecondaryClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateSecondaryCluster', $request, $callOptions)->wait(); + } + + /** + * Creates a new SECONDARY Instance in a given project and location. + * + * The async variant is {@see AlloyDBAdminClient::createSecondaryInstanceAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/create_secondary_instance.php + * + * @param CreateSecondaryInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSecondaryInstance(CreateSecondaryInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateSecondaryInstance', $request, $callOptions)->wait(); + } + + /** + * Creates a new User in a given project, location, and cluster. + * + * The async variant is {@see AlloyDBAdminClient::createUserAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/create_user.php + * + * @param CreateUserRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 User + * + * @throws ApiException Thrown if the API call fails. + */ + public function createUser(CreateUserRequest $request, array $callOptions = []): User + { + return $this->startApiCall('CreateUser', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Backup. + * + * The async variant is {@see AlloyDBAdminClient::deleteBackupAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/delete_backup.php + * + * @param DeleteBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteBackup(DeleteBackupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteBackup', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Cluster. + * + * The async variant is {@see AlloyDBAdminClient::deleteClusterAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/delete_cluster.php + * + * @param DeleteClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteCluster(DeleteClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteCluster', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Instance. + * + * The async variant is {@see AlloyDBAdminClient::deleteInstanceAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/delete_instance.php + * + * @param DeleteInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); + } + + /** + * Deletes a single User. + * + * The async variant is {@see AlloyDBAdminClient::deleteUserAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/delete_user.php + * + * @param DeleteUserRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteUser(DeleteUserRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteUser', $request, $callOptions)->wait(); + } + + /** + * Forces a Failover for a highly available instance. + * Failover promotes the HA standby instance as the new primary. + * Imperative only. + * + * The async variant is {@see AlloyDBAdminClient::failoverInstanceAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/failover_instance.php + * + * @param FailoverInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function failoverInstance(FailoverInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('FailoverInstance', $request, $callOptions)->wait(); + } + + /** + * Generate a client certificate signed by a Cluster CA. + * The sole purpose of this endpoint is to support AlloyDB connectors and the + * Auth Proxy client. The endpoint's behavior is subject to change without + * notice, so do not rely on its behavior remaining constant. Future changes + * will not break AlloyDB connectors or the Auth Proxy client. + * + * The async variant is {@see AlloyDBAdminClient::generateClientCertificateAsync()} + * . + * + * @example samples/V1/AlloyDBAdminClient/generate_client_certificate.php + * + * @param GenerateClientCertificateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GenerateClientCertificateResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function generateClientCertificate(GenerateClientCertificateRequest $request, array $callOptions = []): GenerateClientCertificateResponse + { + return $this->startApiCall('GenerateClientCertificate', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Backup. + * + * The async variant is {@see AlloyDBAdminClient::getBackupAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/get_backup.php + * + * @param GetBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Backup + * + * @throws ApiException Thrown if the API call fails. + */ + public function getBackup(GetBackupRequest $request, array $callOptions = []): Backup + { + return $this->startApiCall('GetBackup', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Cluster. + * + * The async variant is {@see AlloyDBAdminClient::getClusterAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/get_cluster.php + * + * @param GetClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Cluster + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCluster(GetClusterRequest $request, array $callOptions = []): Cluster + { + return $this->startApiCall('GetCluster', $request, $callOptions)->wait(); + } + + /** + * Get instance metadata used for a connection. + * + * The async variant is {@see AlloyDBAdminClient::getConnectionInfoAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/get_connection_info.php + * + * @param GetConnectionInfoRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ConnectionInfo + * + * @throws ApiException Thrown if the API call fails. + */ + public function getConnectionInfo(GetConnectionInfoRequest $request, array $callOptions = []): ConnectionInfo + { + return $this->startApiCall('GetConnectionInfo', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Instance. + * + * The async variant is {@see AlloyDBAdminClient::getInstanceAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/get_instance.php + * + * @param GetInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Instance + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance + { + return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single User. + * + * The async variant is {@see AlloyDBAdminClient::getUserAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/get_user.php + * + * @param GetUserRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 User + * + * @throws ApiException Thrown if the API call fails. + */ + public function getUser(GetUserRequest $request, array $callOptions = []): User + { + return $this->startApiCall('GetUser', $request, $callOptions)->wait(); + } + + /** + * Injects fault in an instance. + * Imperative only. + * + * The async variant is {@see AlloyDBAdminClient::injectFaultAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/inject_fault.php + * + * @param InjectFaultRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function injectFault(InjectFaultRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('InjectFault', $request, $callOptions)->wait(); + } + + /** + * Lists Backups in a given project and location. + * + * The async variant is {@see AlloyDBAdminClient::listBackupsAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/list_backups.php + * + * @param ListBackupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listBackups(ListBackupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListBackups', $request, $callOptions); + } + + /** + * Lists Clusters in a given project and location. + * + * The async variant is {@see AlloyDBAdminClient::listClustersAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/list_clusters.php + * + * @param ListClustersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listClusters(ListClustersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListClusters', $request, $callOptions); + } + + /** + * Lists Instances in a given project and location. + * + * The async variant is {@see AlloyDBAdminClient::listInstancesAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/list_instances.php + * + * @param ListInstancesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInstances(ListInstancesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInstances', $request, $callOptions); + } + + /** + * Lists SupportedDatabaseFlags for a given project and location. + * + * The async variant is + * {@see AlloyDBAdminClient::listSupportedDatabaseFlagsAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/list_supported_database_flags.php + * + * @param ListSupportedDatabaseFlagsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSupportedDatabaseFlags(ListSupportedDatabaseFlagsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSupportedDatabaseFlags', $request, $callOptions); + } + + /** + * Lists Users in a given project and location. + * + * The async variant is {@see AlloyDBAdminClient::listUsersAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/list_users.php + * + * @param ListUsersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listUsers(ListUsersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListUsers', $request, $callOptions); + } + + /** + * Promotes a SECONDARY cluster. This turns down replication + * from the PRIMARY cluster and promotes a secondary cluster + * into its own standalone cluster. + * Imperative only. + * + * The async variant is {@see AlloyDBAdminClient::promoteClusterAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/promote_cluster.php + * + * @param PromoteClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function promoteCluster(PromoteClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('PromoteCluster', $request, $callOptions)->wait(); + } + + /** + * Restart an Instance in a cluster. + * Imperative only. + * + * The async variant is {@see AlloyDBAdminClient::restartInstanceAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/restart_instance.php + * + * @param RestartInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function restartInstance(RestartInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RestartInstance', $request, $callOptions)->wait(); + } + + /** + * Creates a new Cluster in a given project and location, with a volume + * restored from the provided source, either a backup ID or a point-in-time + * and a source cluster. + * + * The async variant is {@see AlloyDBAdminClient::restoreClusterAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/restore_cluster.php + * + * @param RestoreClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function restoreCluster(RestoreClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RestoreCluster', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single Backup. + * + * The async variant is {@see AlloyDBAdminClient::updateBackupAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/update_backup.php + * + * @param UpdateBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateBackup(UpdateBackupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateBackup', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single Cluster. + * + * The async variant is {@see AlloyDBAdminClient::updateClusterAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/update_cluster.php + * + * @param UpdateClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCluster(UpdateClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateCluster', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single Instance. + * + * The async variant is {@see AlloyDBAdminClient::updateInstanceAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/update_instance.php + * + * @param UpdateInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateInstance(UpdateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateInstance', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single User. + * + * The async variant is {@see AlloyDBAdminClient::updateUserAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/update_user.php + * + * @param UpdateUserRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 User + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateUser(UpdateUserRequest $request, array $callOptions = []): User + { + return $this->startApiCall('UpdateUser', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see AlloyDBAdminClient::getLocationAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see AlloyDBAdminClient::listLocationsAsync()} . + * + * @example samples/V1/AlloyDBAdminClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/AlloyDb/src/V1/Client/BaseClient/AlloyDBAdminBaseClient.php b/AlloyDb/src/V1/Client/BaseClient/AlloyDBAdminBaseClient.php deleted file mode 100644 index 776d32b8d7e3..000000000000 --- a/AlloyDb/src/V1/Client/BaseClient/AlloyDBAdminBaseClient.php +++ /dev/null @@ -1,1322 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/alloy_db_admin_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/alloy_db_admin_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/alloy_db_admin_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/alloy_db_admin_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a backup - * resource. - * - * @param string $project - * @param string $location - * @param string $backup - * - * @return string The formatted backup resource. - */ - public static function backupName(string $project, string $location, string $backup): string - { - return self::getPathTemplate('backup')->render([ - 'project' => $project, - 'location' => $location, - 'backup' => $backup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a cluster - * resource. - * - * @param string $project - * @param string $location - * @param string $cluster - * - * @return string The formatted cluster resource. - */ - public static function clusterName(string $project, string $location, string $cluster): string - { - return self::getPathTemplate('cluster')->render([ - 'project' => $project, - 'location' => $location, - 'cluster' => $cluster, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * crypto_key_version resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * @param string $cryptoKey - * @param string $cryptoKeyVersion - * - * @return string The formatted crypto_key_version resource. - */ - public static function cryptoKeyVersionName(string $project, string $location, string $keyRing, string $cryptoKey, string $cryptoKeyVersion): string - { - return self::getPathTemplate('cryptoKeyVersion')->render([ - 'project' => $project, - 'location' => $location, - 'key_ring' => $keyRing, - 'crypto_key' => $cryptoKey, - 'crypto_key_version' => $cryptoKeyVersion, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a instance - * resource. - * - * @param string $project - * @param string $location - * @param string $cluster - * @param string $instance - * - * @return string The formatted instance resource. - */ - public static function instanceName(string $project, string $location, string $cluster, string $instance): string - { - return self::getPathTemplate('instance')->render([ - 'project' => $project, - 'location' => $location, - 'cluster' => $cluster, - 'instance' => $instance, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a network - * resource. - * - * @param string $project - * @param string $network - * - * @return string The formatted network resource. - */ - public static function networkName(string $project, string $network): string - { - return self::getPathTemplate('network')->render([ - 'project' => $project, - 'network' => $network, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a user - * resource. - * - * @param string $project - * @param string $location - * @param string $cluster - * @param string $user - * - * @return string The formatted user resource. - */ - public static function userName(string $project, string $location, string $cluster, string $user): string - { - return self::getPathTemplate('user')->render([ - 'project' => $project, - 'location' => $location, - 'cluster' => $cluster, - 'user' => $user, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - backup: projects/{project}/locations/{location}/backups/{backup} - * - cluster: projects/{project}/locations/{location}/clusters/{cluster} - * - cryptoKeyVersion: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version} - * - instance: projects/{project}/locations/{location}/clusters/{cluster}/instances/{instance} - * - location: projects/{project}/locations/{location} - * - network: projects/{project}/global/networks/{network} - * - user: projects/{project}/locations/{location}/clusters/{cluster}/users/{user} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'alloydb.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates new instances under the given project, location and cluster. - * There can be only one primary instance in a cluster. If the primary - * instance exists in the cluster as well as this request, then API will - * throw an error. - * The primary instance should exist before any read pool instance is - * created. If the primary instance is a part of the request payload, then - * the API will take care of creating instances in the correct order. - * This method is here to support Google-internal use cases, and is not meant - * for external customers to consume. Please do not start relying on it; its - * behavior is subject to change without notice. - * - * The async variant is {@see self::batchCreateInstancesAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/batch_create_instances.php - * - * @param BatchCreateInstancesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchCreateInstances(BatchCreateInstancesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BatchCreateInstances', $request, $callOptions)->wait(); - } - - /** - * Creates a new Backup in a given project and location. - * - * The async variant is {@see self::createBackupAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/create_backup.php - * - * @param CreateBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createBackup(CreateBackupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateBackup', $request, $callOptions)->wait(); - } - - /** - * Creates a new Cluster in a given project and location. - * - * The async variant is {@see self::createClusterAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/create_cluster.php - * - * @param CreateClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCluster(CreateClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateCluster', $request, $callOptions)->wait(); - } - - /** - * Creates a new Instance in a given project and location. - * - * The async variant is {@see self::createInstanceAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/create_instance.php - * - * @param CreateInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createInstance(CreateInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateInstance', $request, $callOptions)->wait(); - } - - /** - * Creates a cluster of type SECONDARY in the given location using - * the primary cluster as the source. - * - * The async variant is {@see self::createSecondaryClusterAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/create_secondary_cluster.php - * - * @param CreateSecondaryClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSecondaryCluster(CreateSecondaryClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateSecondaryCluster', $request, $callOptions)->wait(); - } - - /** - * Creates a new SECONDARY Instance in a given project and location. - * - * The async variant is {@see self::createSecondaryInstanceAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/create_secondary_instance.php - * - * @param CreateSecondaryInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSecondaryInstance(CreateSecondaryInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateSecondaryInstance', $request, $callOptions)->wait(); - } - - /** - * Creates a new User in a given project, location, and cluster. - * - * The async variant is {@see self::createUserAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/create_user.php - * - * @param CreateUserRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 User - * - * @throws ApiException Thrown if the API call fails. - */ - public function createUser(CreateUserRequest $request, array $callOptions = []): User - { - return $this->startApiCall('CreateUser', $request, $callOptions)->wait(); - } - - /** - * Deletes a single Backup. - * - * The async variant is {@see self::deleteBackupAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/delete_backup.php - * - * @param DeleteBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteBackup(DeleteBackupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteBackup', $request, $callOptions)->wait(); - } - - /** - * Deletes a single Cluster. - * - * The async variant is {@see self::deleteClusterAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/delete_cluster.php - * - * @param DeleteClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteCluster(DeleteClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteCluster', $request, $callOptions)->wait(); - } - - /** - * Deletes a single Instance. - * - * The async variant is {@see self::deleteInstanceAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/delete_instance.php - * - * @param DeleteInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); - } - - /** - * Deletes a single User. - * - * The async variant is {@see self::deleteUserAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/delete_user.php - * - * @param DeleteUserRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteUser(DeleteUserRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteUser', $request, $callOptions)->wait(); - } - - /** - * Forces a Failover for a highly available instance. - * Failover promotes the HA standby instance as the new primary. - * Imperative only. - * - * The async variant is {@see self::failoverInstanceAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/failover_instance.php - * - * @param FailoverInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function failoverInstance(FailoverInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('FailoverInstance', $request, $callOptions)->wait(); - } - - /** - * Generate a client certificate signed by a Cluster CA. - * The sole purpose of this endpoint is to support AlloyDB connectors and the - * Auth Proxy client. The endpoint's behavior is subject to change without - * notice, so do not rely on its behavior remaining constant. Future changes - * will not break AlloyDB connectors or the Auth Proxy client. - * - * The async variant is {@see self::generateClientCertificateAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/generate_client_certificate.php - * - * @param GenerateClientCertificateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GenerateClientCertificateResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function generateClientCertificate(GenerateClientCertificateRequest $request, array $callOptions = []): GenerateClientCertificateResponse - { - return $this->startApiCall('GenerateClientCertificate', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single Backup. - * - * The async variant is {@see self::getBackupAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/get_backup.php - * - * @param GetBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Backup - * - * @throws ApiException Thrown if the API call fails. - */ - public function getBackup(GetBackupRequest $request, array $callOptions = []): Backup - { - return $this->startApiCall('GetBackup', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single Cluster. - * - * The async variant is {@see self::getClusterAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/get_cluster.php - * - * @param GetClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Cluster - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCluster(GetClusterRequest $request, array $callOptions = []): Cluster - { - return $this->startApiCall('GetCluster', $request, $callOptions)->wait(); - } - - /** - * Get instance metadata used for a connection. - * - * The async variant is {@see self::getConnectionInfoAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/get_connection_info.php - * - * @param GetConnectionInfoRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ConnectionInfo - * - * @throws ApiException Thrown if the API call fails. - */ - public function getConnectionInfo(GetConnectionInfoRequest $request, array $callOptions = []): ConnectionInfo - { - return $this->startApiCall('GetConnectionInfo', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single Instance. - * - * The async variant is {@see self::getInstanceAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/get_instance.php - * - * @param GetInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Instance - * - * @throws ApiException Thrown if the API call fails. - */ - public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance - { - return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single User. - * - * The async variant is {@see self::getUserAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/get_user.php - * - * @param GetUserRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 User - * - * @throws ApiException Thrown if the API call fails. - */ - public function getUser(GetUserRequest $request, array $callOptions = []): User - { - return $this->startApiCall('GetUser', $request, $callOptions)->wait(); - } - - /** - * Injects fault in an instance. - * Imperative only. - * - * The async variant is {@see self::injectFaultAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/inject_fault.php - * - * @param InjectFaultRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function injectFault(InjectFaultRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('InjectFault', $request, $callOptions)->wait(); - } - - /** - * Lists Backups in a given project and location. - * - * The async variant is {@see self::listBackupsAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/list_backups.php - * - * @param ListBackupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listBackups(ListBackupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListBackups', $request, $callOptions); - } - - /** - * Lists Clusters in a given project and location. - * - * The async variant is {@see self::listClustersAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/list_clusters.php - * - * @param ListClustersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listClusters(ListClustersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListClusters', $request, $callOptions); - } - - /** - * Lists Instances in a given project and location. - * - * The async variant is {@see self::listInstancesAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/list_instances.php - * - * @param ListInstancesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listInstances(ListInstancesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListInstances', $request, $callOptions); - } - - /** - * Lists SupportedDatabaseFlags for a given project and location. - * - * The async variant is {@see self::listSupportedDatabaseFlagsAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/list_supported_database_flags.php - * - * @param ListSupportedDatabaseFlagsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSupportedDatabaseFlags(ListSupportedDatabaseFlagsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSupportedDatabaseFlags', $request, $callOptions); - } - - /** - * Lists Users in a given project and location. - * - * The async variant is {@see self::listUsersAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/list_users.php - * - * @param ListUsersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listUsers(ListUsersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListUsers', $request, $callOptions); - } - - /** - * Promotes a SECONDARY cluster. This turns down replication - * from the PRIMARY cluster and promotes a secondary cluster - * into its own standalone cluster. - * Imperative only. - * - * The async variant is {@see self::promoteClusterAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/promote_cluster.php - * - * @param PromoteClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function promoteCluster(PromoteClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('PromoteCluster', $request, $callOptions)->wait(); - } - - /** - * Restart an Instance in a cluster. - * Imperative only. - * - * The async variant is {@see self::restartInstanceAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/restart_instance.php - * - * @param RestartInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function restartInstance(RestartInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RestartInstance', $request, $callOptions)->wait(); - } - - /** - * Creates a new Cluster in a given project and location, with a volume - * restored from the provided source, either a backup ID or a point-in-time - * and a source cluster. - * - * The async variant is {@see self::restoreClusterAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/restore_cluster.php - * - * @param RestoreClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function restoreCluster(RestoreClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RestoreCluster', $request, $callOptions)->wait(); - } - - /** - * Updates the parameters of a single Backup. - * - * The async variant is {@see self::updateBackupAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/update_backup.php - * - * @param UpdateBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateBackup(UpdateBackupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateBackup', $request, $callOptions)->wait(); - } - - /** - * Updates the parameters of a single Cluster. - * - * The async variant is {@see self::updateClusterAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/update_cluster.php - * - * @param UpdateClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCluster(UpdateClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateCluster', $request, $callOptions)->wait(); - } - - /** - * Updates the parameters of a single Instance. - * - * The async variant is {@see self::updateInstanceAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/update_instance.php - * - * @param UpdateInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateInstance(UpdateInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateInstance', $request, $callOptions)->wait(); - } - - /** - * Updates the parameters of a single User. - * - * The async variant is {@see self::updateUserAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/update_user.php - * - * @param UpdateUserRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 User - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateUser(UpdateUserRequest $request, array $callOptions = []): User - { - return $this->startApiCall('UpdateUser', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/AlloyDBAdminClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/AnalyticsAdmin/composer.json b/AnalyticsAdmin/composer.json index 28b30851440a..28c5a1e69fc5 100644 --- a/AnalyticsAdmin/composer.json +++ b/AnalyticsAdmin/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/AnalyticsAdmin/src/V1beta/Client/AnalyticsAdminServiceClient.php b/AnalyticsAdmin/src/V1beta/Client/AnalyticsAdminServiceClient.php index d88cada9574d..9a1667d7d27b 100644 --- a/AnalyticsAdmin/src/V1beta/Client/AnalyticsAdminServiceClient.php +++ b/AnalyticsAdmin/src/V1beta/Client/AnalyticsAdminServiceClient.php @@ -26,17 +26,1944 @@ namespace Google\Analytics\Admin\V1beta\Client; -use Google\Analytics\Admin\V1beta\Client\BaseClient\AnalyticsAdminServiceBaseClient; +use Google\Analytics\Admin\V1beta\Account; +use Google\Analytics\Admin\V1beta\AcknowledgeUserDataCollectionRequest; +use Google\Analytics\Admin\V1beta\AcknowledgeUserDataCollectionResponse; +use Google\Analytics\Admin\V1beta\ArchiveCustomDimensionRequest; +use Google\Analytics\Admin\V1beta\ArchiveCustomMetricRequest; +use Google\Analytics\Admin\V1beta\ConversionEvent; +use Google\Analytics\Admin\V1beta\CreateConversionEventRequest; +use Google\Analytics\Admin\V1beta\CreateCustomDimensionRequest; +use Google\Analytics\Admin\V1beta\CreateCustomMetricRequest; +use Google\Analytics\Admin\V1beta\CreateDataStreamRequest; +use Google\Analytics\Admin\V1beta\CreateFirebaseLinkRequest; +use Google\Analytics\Admin\V1beta\CreateGoogleAdsLinkRequest; +use Google\Analytics\Admin\V1beta\CreateMeasurementProtocolSecretRequest; +use Google\Analytics\Admin\V1beta\CreatePropertyRequest; +use Google\Analytics\Admin\V1beta\CustomDimension; +use Google\Analytics\Admin\V1beta\CustomMetric; +use Google\Analytics\Admin\V1beta\DataRetentionSettings; +use Google\Analytics\Admin\V1beta\DataSharingSettings; +use Google\Analytics\Admin\V1beta\DataStream; +use Google\Analytics\Admin\V1beta\DeleteAccountRequest; +use Google\Analytics\Admin\V1beta\DeleteConversionEventRequest; +use Google\Analytics\Admin\V1beta\DeleteDataStreamRequest; +use Google\Analytics\Admin\V1beta\DeleteFirebaseLinkRequest; +use Google\Analytics\Admin\V1beta\DeleteGoogleAdsLinkRequest; +use Google\Analytics\Admin\V1beta\DeleteMeasurementProtocolSecretRequest; +use Google\Analytics\Admin\V1beta\DeletePropertyRequest; +use Google\Analytics\Admin\V1beta\FirebaseLink; +use Google\Analytics\Admin\V1beta\GetAccountRequest; +use Google\Analytics\Admin\V1beta\GetConversionEventRequest; +use Google\Analytics\Admin\V1beta\GetCustomDimensionRequest; +use Google\Analytics\Admin\V1beta\GetCustomMetricRequest; +use Google\Analytics\Admin\V1beta\GetDataRetentionSettingsRequest; +use Google\Analytics\Admin\V1beta\GetDataSharingSettingsRequest; +use Google\Analytics\Admin\V1beta\GetDataStreamRequest; +use Google\Analytics\Admin\V1beta\GetMeasurementProtocolSecretRequest; +use Google\Analytics\Admin\V1beta\GetPropertyRequest; +use Google\Analytics\Admin\V1beta\GoogleAdsLink; +use Google\Analytics\Admin\V1beta\ListAccountSummariesRequest; +use Google\Analytics\Admin\V1beta\ListAccountsRequest; +use Google\Analytics\Admin\V1beta\ListConversionEventsRequest; +use Google\Analytics\Admin\V1beta\ListCustomDimensionsRequest; +use Google\Analytics\Admin\V1beta\ListCustomMetricsRequest; +use Google\Analytics\Admin\V1beta\ListDataStreamsRequest; +use Google\Analytics\Admin\V1beta\ListFirebaseLinksRequest; +use Google\Analytics\Admin\V1beta\ListGoogleAdsLinksRequest; +use Google\Analytics\Admin\V1beta\ListMeasurementProtocolSecretsRequest; +use Google\Analytics\Admin\V1beta\ListPropertiesRequest; +use Google\Analytics\Admin\V1beta\MeasurementProtocolSecret; +use Google\Analytics\Admin\V1beta\Property; +use Google\Analytics\Admin\V1beta\ProvisionAccountTicketRequest; +use Google\Analytics\Admin\V1beta\ProvisionAccountTicketResponse; +use Google\Analytics\Admin\V1beta\RunAccessReportRequest; +use Google\Analytics\Admin\V1beta\RunAccessReportResponse; +use Google\Analytics\Admin\V1beta\SearchChangeHistoryEventsRequest; +use Google\Analytics\Admin\V1beta\UpdateAccountRequest; +use Google\Analytics\Admin\V1beta\UpdateConversionEventRequest; +use Google\Analytics\Admin\V1beta\UpdateCustomDimensionRequest; +use Google\Analytics\Admin\V1beta\UpdateCustomMetricRequest; +use Google\Analytics\Admin\V1beta\UpdateDataRetentionSettingsRequest; +use Google\Analytics\Admin\V1beta\UpdateDataStreamRequest; +use Google\Analytics\Admin\V1beta\UpdateGoogleAdsLinkRequest; +use Google\Analytics\Admin\V1beta\UpdateMeasurementProtocolSecretRequest; +use Google\Analytics\Admin\V1beta\UpdatePropertyRequest; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service Interface for the Analytics Admin API (GA4). + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface acknowledgeUserDataCollectionAsync(AcknowledgeUserDataCollectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface archiveCustomDimensionAsync(ArchiveCustomDimensionRequest $request, array $optionalArgs = []) + * @method PromiseInterface archiveCustomMetricAsync(ArchiveCustomMetricRequest $request, array $optionalArgs = []) + * @method PromiseInterface createConversionEventAsync(CreateConversionEventRequest $request, array $optionalArgs = []) + * @method PromiseInterface createCustomDimensionAsync(CreateCustomDimensionRequest $request, array $optionalArgs = []) + * @method PromiseInterface createCustomMetricAsync(CreateCustomMetricRequest $request, array $optionalArgs = []) + * @method PromiseInterface createDataStreamAsync(CreateDataStreamRequest $request, array $optionalArgs = []) + * @method PromiseInterface createFirebaseLinkAsync(CreateFirebaseLinkRequest $request, array $optionalArgs = []) + * @method PromiseInterface createGoogleAdsLinkAsync(CreateGoogleAdsLinkRequest $request, array $optionalArgs = []) + * @method PromiseInterface createMeasurementProtocolSecretAsync(CreateMeasurementProtocolSecretRequest $request, array $optionalArgs = []) + * @method PromiseInterface createPropertyAsync(CreatePropertyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAccountAsync(DeleteAccountRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteConversionEventAsync(DeleteConversionEventRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDataStreamAsync(DeleteDataStreamRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteFirebaseLinkAsync(DeleteFirebaseLinkRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteGoogleAdsLinkAsync(DeleteGoogleAdsLinkRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteMeasurementProtocolSecretAsync(DeleteMeasurementProtocolSecretRequest $request, array $optionalArgs = []) + * @method PromiseInterface deletePropertyAsync(DeletePropertyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAccountAsync(GetAccountRequest $request, array $optionalArgs = []) + * @method PromiseInterface getConversionEventAsync(GetConversionEventRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCustomDimensionAsync(GetCustomDimensionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCustomMetricAsync(GetCustomMetricRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDataRetentionSettingsAsync(GetDataRetentionSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDataSharingSettingsAsync(GetDataSharingSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDataStreamAsync(GetDataStreamRequest $request, array $optionalArgs = []) + * @method PromiseInterface getMeasurementProtocolSecretAsync(GetMeasurementProtocolSecretRequest $request, array $optionalArgs = []) + * @method PromiseInterface getPropertyAsync(GetPropertyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAccountSummariesAsync(ListAccountSummariesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAccountsAsync(ListAccountsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listConversionEventsAsync(ListConversionEventsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCustomDimensionsAsync(ListCustomDimensionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCustomMetricsAsync(ListCustomMetricsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDataStreamsAsync(ListDataStreamsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listFirebaseLinksAsync(ListFirebaseLinksRequest $request, array $optionalArgs = []) + * @method PromiseInterface listGoogleAdsLinksAsync(ListGoogleAdsLinksRequest $request, array $optionalArgs = []) + * @method PromiseInterface listMeasurementProtocolSecretsAsync(ListMeasurementProtocolSecretsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPropertiesAsync(ListPropertiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface provisionAccountTicketAsync(ProvisionAccountTicketRequest $request, array $optionalArgs = []) + * @method PromiseInterface runAccessReportAsync(RunAccessReportRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchChangeHistoryEventsAsync(SearchChangeHistoryEventsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAccountAsync(UpdateAccountRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateConversionEventAsync(UpdateConversionEventRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCustomDimensionAsync(UpdateCustomDimensionRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCustomMetricAsync(UpdateCustomMetricRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDataRetentionSettingsAsync(UpdateDataRetentionSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDataStreamAsync(UpdateDataStreamRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateGoogleAdsLinkAsync(UpdateGoogleAdsLinkRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateMeasurementProtocolSecretAsync(UpdateMeasurementProtocolSecretRequest $request, array $optionalArgs = []) + * @method PromiseInterface updatePropertyAsync(UpdatePropertyRequest $request, array $optionalArgs = []) */ -final class AnalyticsAdminServiceClient extends AnalyticsAdminServiceBaseClient +final class AnalyticsAdminServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AnalyticsAdminServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.analytics.admin.v1beta.AnalyticsAdminService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'analyticsadmin.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/analytics.edit', + 'https://www.googleapis.com/auth/analytics.readonly', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/analytics_admin_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/analytics_admin_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/analytics_admin_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/analytics_admin_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a account + * resource. + * + * @param string $account + * + * @return string The formatted account resource. + * + * @experimental + */ + public static function accountName(string $account): string + { + return self::getPathTemplate('account')->render([ + 'account' => $account, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * conversion_event resource. + * + * @param string $property + * @param string $conversionEvent + * + * @return string The formatted conversion_event resource. + * + * @experimental + */ + public static function conversionEventName(string $property, string $conversionEvent): string + { + return self::getPathTemplate('conversionEvent')->render([ + 'property' => $property, + 'conversion_event' => $conversionEvent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * custom_dimension resource. + * + * @param string $property + * @param string $customDimension + * + * @return string The formatted custom_dimension resource. + * + * @experimental + */ + public static function customDimensionName(string $property, string $customDimension): string + { + return self::getPathTemplate('customDimension')->render([ + 'property' => $property, + 'custom_dimension' => $customDimension, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * custom_metric resource. + * + * @param string $property + * @param string $customMetric + * + * @return string The formatted custom_metric resource. + * + * @experimental + */ + public static function customMetricName(string $property, string $customMetric): string + { + return self::getPathTemplate('customMetric')->render([ + 'property' => $property, + 'custom_metric' => $customMetric, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * data_retention_settings resource. + * + * @param string $property + * + * @return string The formatted data_retention_settings resource. + * + * @experimental + */ + public static function dataRetentionSettingsName(string $property): string + { + return self::getPathTemplate('dataRetentionSettings')->render([ + 'property' => $property, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * data_sharing_settings resource. + * + * @param string $account + * + * @return string The formatted data_sharing_settings resource. + * + * @experimental + */ + public static function dataSharingSettingsName(string $account): string + { + return self::getPathTemplate('dataSharingSettings')->render([ + 'account' => $account, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a data_stream + * resource. + * + * @param string $property + * @param string $dataStream + * + * @return string The formatted data_stream resource. + * + * @experimental + */ + public static function dataStreamName(string $property, string $dataStream): string + { + return self::getPathTemplate('dataStream')->render([ + 'property' => $property, + 'data_stream' => $dataStream, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * firebase_link resource. + * + * @param string $property + * @param string $firebaseLink + * + * @return string The formatted firebase_link resource. + * + * @experimental + */ + public static function firebaseLinkName(string $property, string $firebaseLink): string + { + return self::getPathTemplate('firebaseLink')->render([ + 'property' => $property, + 'firebase_link' => $firebaseLink, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * google_ads_link resource. + * + * @param string $property + * @param string $googleAdsLink + * + * @return string The formatted google_ads_link resource. + * + * @experimental + */ + public static function googleAdsLinkName(string $property, string $googleAdsLink): string + { + return self::getPathTemplate('googleAdsLink')->render([ + 'property' => $property, + 'google_ads_link' => $googleAdsLink, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * measurement_protocol_secret resource. + * + * @param string $property + * @param string $dataStream + * @param string $measurementProtocolSecret + * + * @return string The formatted measurement_protocol_secret resource. + * + * @experimental + */ + public static function measurementProtocolSecretName(string $property, string $dataStream, string $measurementProtocolSecret): string + { + return self::getPathTemplate('measurementProtocolSecret')->render([ + 'property' => $property, + 'data_stream' => $dataStream, + 'measurement_protocol_secret' => $measurementProtocolSecret, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a property + * resource. + * + * @param string $property + * + * @return string The formatted property resource. + * + * @experimental + */ + public static function propertyName(string $property): string + { + return self::getPathTemplate('property')->render([ + 'property' => $property, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - account: accounts/{account} + * - conversionEvent: properties/{property}/conversionEvents/{conversion_event} + * - customDimension: properties/{property}/customDimensions/{custom_dimension} + * - customMetric: properties/{property}/customMetrics/{custom_metric} + * - dataRetentionSettings: properties/{property}/dataRetentionSettings + * - dataSharingSettings: accounts/{account}/dataSharingSettings + * - dataStream: properties/{property}/dataStreams/{data_stream} + * - firebaseLink: properties/{property}/firebaseLinks/{firebase_link} + * - googleAdsLink: properties/{property}/googleAdsLinks/{google_ads_link} + * - measurementProtocolSecret: properties/{property}/dataStreams/{data_stream}/measurementProtocolSecrets/{measurement_protocol_secret} + * - property: properties/{property} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'analyticsadmin.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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Acknowledges the terms of user data collection for the specified property. + * + * This acknowledgement must be completed (either in the Google Analytics UI + * or through this API) before MeasurementProtocolSecret resources may be + * created. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::acknowledgeUserDataCollectionAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/acknowledge_user_data_collection.php + * + * @param AcknowledgeUserDataCollectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AcknowledgeUserDataCollectionResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function acknowledgeUserDataCollection(AcknowledgeUserDataCollectionRequest $request, array $callOptions = []): AcknowledgeUserDataCollectionResponse + { + return $this->startApiCall('AcknowledgeUserDataCollection', $request, $callOptions)->wait(); + } + + /** + * Archives a CustomDimension on a property. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::archiveCustomDimensionAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/archive_custom_dimension.php + * + * @param ArchiveCustomDimensionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function archiveCustomDimension(ArchiveCustomDimensionRequest $request, array $callOptions = []): void + { + $this->startApiCall('ArchiveCustomDimension', $request, $callOptions)->wait(); + } + + /** + * Archives a CustomMetric on a property. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::archiveCustomMetricAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/archive_custom_metric.php + * + * @param ArchiveCustomMetricRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function archiveCustomMetric(ArchiveCustomMetricRequest $request, array $callOptions = []): void + { + $this->startApiCall('ArchiveCustomMetric', $request, $callOptions)->wait(); + } + + /** + * Creates a conversion event with the specified attributes. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::createConversionEventAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/create_conversion_event.php + * + * @param CreateConversionEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ConversionEvent + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createConversionEvent(CreateConversionEventRequest $request, array $callOptions = []): ConversionEvent + { + return $this->startApiCall('CreateConversionEvent', $request, $callOptions)->wait(); + } + + /** + * Creates a CustomDimension. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::createCustomDimensionAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/create_custom_dimension.php + * + * @param CreateCustomDimensionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CustomDimension + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createCustomDimension(CreateCustomDimensionRequest $request, array $callOptions = []): CustomDimension + { + return $this->startApiCall('CreateCustomDimension', $request, $callOptions)->wait(); + } + + /** + * Creates a CustomMetric. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::createCustomMetricAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/create_custom_metric.php + * + * @param CreateCustomMetricRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CustomMetric + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createCustomMetric(CreateCustomMetricRequest $request, array $callOptions = []): CustomMetric + { + return $this->startApiCall('CreateCustomMetric', $request, $callOptions)->wait(); + } + + /** + * Creates a DataStream. + * + * The async variant is {@see AnalyticsAdminServiceClient::createDataStreamAsync()} + * . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/create_data_stream.php + * + * @param CreateDataStreamRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataStream + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createDataStream(CreateDataStreamRequest $request, array $callOptions = []): DataStream + { + return $this->startApiCall('CreateDataStream', $request, $callOptions)->wait(); + } + + /** + * Creates a FirebaseLink. + * + * Properties can have at most one FirebaseLink. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::createFirebaseLinkAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/create_firebase_link.php + * + * @param CreateFirebaseLinkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FirebaseLink + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createFirebaseLink(CreateFirebaseLinkRequest $request, array $callOptions = []): FirebaseLink + { + return $this->startApiCall('CreateFirebaseLink', $request, $callOptions)->wait(); + } + + /** + * Creates a GoogleAdsLink. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::createGoogleAdsLinkAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/create_google_ads_link.php + * + * @param CreateGoogleAdsLinkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GoogleAdsLink + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createGoogleAdsLink(CreateGoogleAdsLinkRequest $request, array $callOptions = []): GoogleAdsLink + { + return $this->startApiCall('CreateGoogleAdsLink', $request, $callOptions)->wait(); + } + + /** + * Creates a measurement protocol secret. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::createMeasurementProtocolSecretAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/create_measurement_protocol_secret.php + * + * @param CreateMeasurementProtocolSecretRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MeasurementProtocolSecret + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createMeasurementProtocolSecret(CreateMeasurementProtocolSecretRequest $request, array $callOptions = []): MeasurementProtocolSecret + { + return $this->startApiCall('CreateMeasurementProtocolSecret', $request, $callOptions)->wait(); + } + + /** + * Creates an "GA4" property with the specified location and attributes. + * + * The async variant is {@see AnalyticsAdminServiceClient::createPropertyAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/create_property.php + * + * @param CreatePropertyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Property + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createProperty(CreatePropertyRequest $request, array $callOptions = []): Property + { + return $this->startApiCall('CreateProperty', $request, $callOptions)->wait(); + } + + /** + * Marks target Account as soft-deleted (ie: "trashed") and returns it. + * + * This API does not have a method to restore soft-deleted accounts. + * However, they can be restored using the Trash Can UI. + * + * If the accounts are not restored before the expiration time, the account + * and all child resources (eg: Properties, GoogleAdsLinks, Streams, + * UserLinks) will be permanently purged. + * https://support.google.com/analytics/answer/6154772 + * + * Returns an error if the target is not found. + * + * The async variant is {@see AnalyticsAdminServiceClient::deleteAccountAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/delete_account.php + * + * @param DeleteAccountRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteAccount(DeleteAccountRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteAccount', $request, $callOptions)->wait(); + } + + /** + * Deletes a conversion event in a property. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::deleteConversionEventAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/delete_conversion_event.php + * + * @param DeleteConversionEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteConversionEvent(DeleteConversionEventRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteConversionEvent', $request, $callOptions)->wait(); + } + + /** + * Deletes a DataStream on a property. + * + * The async variant is {@see AnalyticsAdminServiceClient::deleteDataStreamAsync()} + * . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/delete_data_stream.php + * + * @param DeleteDataStreamRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteDataStream(DeleteDataStreamRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteDataStream', $request, $callOptions)->wait(); + } + + /** + * Deletes a FirebaseLink on a property + * + * The async variant is + * {@see AnalyticsAdminServiceClient::deleteFirebaseLinkAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/delete_firebase_link.php + * + * @param DeleteFirebaseLinkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteFirebaseLink(DeleteFirebaseLinkRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteFirebaseLink', $request, $callOptions)->wait(); + } + + /** + * Deletes a GoogleAdsLink on a property + * + * The async variant is + * {@see AnalyticsAdminServiceClient::deleteGoogleAdsLinkAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/delete_google_ads_link.php + * + * @param DeleteGoogleAdsLinkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteGoogleAdsLink(DeleteGoogleAdsLinkRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteGoogleAdsLink', $request, $callOptions)->wait(); + } + + /** + * Deletes target MeasurementProtocolSecret. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::deleteMeasurementProtocolSecretAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/delete_measurement_protocol_secret.php + * + * @param DeleteMeasurementProtocolSecretRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteMeasurementProtocolSecret(DeleteMeasurementProtocolSecretRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteMeasurementProtocolSecret', $request, $callOptions)->wait(); + } + + /** + * Marks target Property as soft-deleted (ie: "trashed") and returns it. + * + * This API does not have a method to restore soft-deleted properties. + * However, they can be restored using the Trash Can UI. + * + * If the properties are not restored before the expiration time, the Property + * and all child resources (eg: GoogleAdsLinks, Streams, UserLinks) + * will be permanently purged. + * https://support.google.com/analytics/answer/6154772 + * + * Returns an error if the target is not found, or is not a GA4 Property. + * + * The async variant is {@see AnalyticsAdminServiceClient::deletePropertyAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/delete_property.php + * + * @param DeletePropertyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Property + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteProperty(DeletePropertyRequest $request, array $callOptions = []): Property + { + return $this->startApiCall('DeleteProperty', $request, $callOptions)->wait(); + } + + /** + * Lookup for a single Account. + * + * The async variant is {@see AnalyticsAdminServiceClient::getAccountAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/get_account.php + * + * @param GetAccountRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Account + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getAccount(GetAccountRequest $request, array $callOptions = []): Account + { + return $this->startApiCall('GetAccount', $request, $callOptions)->wait(); + } + + /** + * Retrieve a single conversion event. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::getConversionEventAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/get_conversion_event.php + * + * @param GetConversionEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ConversionEvent + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getConversionEvent(GetConversionEventRequest $request, array $callOptions = []): ConversionEvent + { + return $this->startApiCall('GetConversionEvent', $request, $callOptions)->wait(); + } + + /** + * Lookup for a single CustomDimension. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::getCustomDimensionAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/get_custom_dimension.php + * + * @param GetCustomDimensionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CustomDimension + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getCustomDimension(GetCustomDimensionRequest $request, array $callOptions = []): CustomDimension + { + return $this->startApiCall('GetCustomDimension', $request, $callOptions)->wait(); + } + + /** + * Lookup for a single CustomMetric. + * + * The async variant is {@see AnalyticsAdminServiceClient::getCustomMetricAsync()} + * . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/get_custom_metric.php + * + * @param GetCustomMetricRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CustomMetric + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getCustomMetric(GetCustomMetricRequest $request, array $callOptions = []): CustomMetric + { + return $this->startApiCall('GetCustomMetric', $request, $callOptions)->wait(); + } + + /** + * Returns the singleton data retention settings for this property. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::getDataRetentionSettingsAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/get_data_retention_settings.php + * + * @param GetDataRetentionSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataRetentionSettings + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getDataRetentionSettings(GetDataRetentionSettingsRequest $request, array $callOptions = []): DataRetentionSettings + { + return $this->startApiCall('GetDataRetentionSettings', $request, $callOptions)->wait(); + } + + /** + * Get data sharing settings on an account. + * Data sharing settings are singletons. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::getDataSharingSettingsAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/get_data_sharing_settings.php + * + * @param GetDataSharingSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataSharingSettings + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getDataSharingSettings(GetDataSharingSettingsRequest $request, array $callOptions = []): DataSharingSettings + { + return $this->startApiCall('GetDataSharingSettings', $request, $callOptions)->wait(); + } + + /** + * Lookup for a single DataStream. + * + * The async variant is {@see AnalyticsAdminServiceClient::getDataStreamAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/get_data_stream.php + * + * @param GetDataStreamRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataStream + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getDataStream(GetDataStreamRequest $request, array $callOptions = []): DataStream + { + return $this->startApiCall('GetDataStream', $request, $callOptions)->wait(); + } + + /** + * Lookup for a single "GA4" MeasurementProtocolSecret. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::getMeasurementProtocolSecretAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/get_measurement_protocol_secret.php + * + * @param GetMeasurementProtocolSecretRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MeasurementProtocolSecret + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getMeasurementProtocolSecret(GetMeasurementProtocolSecretRequest $request, array $callOptions = []): MeasurementProtocolSecret + { + return $this->startApiCall('GetMeasurementProtocolSecret', $request, $callOptions)->wait(); + } + + /** + * Lookup for a single "GA4" Property. + * + * The async variant is {@see AnalyticsAdminServiceClient::getPropertyAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/get_property.php + * + * @param GetPropertyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Property + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getProperty(GetPropertyRequest $request, array $callOptions = []): Property + { + return $this->startApiCall('GetProperty', $request, $callOptions)->wait(); + } + + /** + * Returns summaries of all accounts accessible by the caller. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::listAccountSummariesAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/list_account_summaries.php + * + * @param ListAccountSummariesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listAccountSummaries(ListAccountSummariesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAccountSummaries', $request, $callOptions); + } + + /** + * Returns all accounts accessible by the caller. + * + * Note that these accounts might not currently have GA4 properties. + * Soft-deleted (ie: "trashed") accounts are excluded by default. + * Returns an empty list if no relevant accounts are found. + * + * The async variant is {@see AnalyticsAdminServiceClient::listAccountsAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/list_accounts.php + * + * @param ListAccountsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listAccounts(ListAccountsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAccounts', $request, $callOptions); + } + + /** + * Returns a list of conversion events in the specified parent property. + * + * Returns an empty list if no conversion events are found. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::listConversionEventsAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/list_conversion_events.php + * + * @param ListConversionEventsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listConversionEvents(ListConversionEventsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListConversionEvents', $request, $callOptions); + } + + /** + * Lists CustomDimensions on a property. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::listCustomDimensionsAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/list_custom_dimensions.php + * + * @param ListCustomDimensionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listCustomDimensions(ListCustomDimensionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCustomDimensions', $request, $callOptions); + } + + /** + * Lists CustomMetrics on a property. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::listCustomMetricsAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/list_custom_metrics.php + * + * @param ListCustomMetricsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listCustomMetrics(ListCustomMetricsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCustomMetrics', $request, $callOptions); + } + + /** + * Lists DataStreams on a property. + * + * The async variant is {@see AnalyticsAdminServiceClient::listDataStreamsAsync()} + * . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/list_data_streams.php + * + * @param ListDataStreamsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listDataStreams(ListDataStreamsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDataStreams', $request, $callOptions); + } + + /** + * Lists FirebaseLinks on a property. + * Properties can have at most one FirebaseLink. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::listFirebaseLinksAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/list_firebase_links.php + * + * @param ListFirebaseLinksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listFirebaseLinks(ListFirebaseLinksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListFirebaseLinks', $request, $callOptions); + } + + /** + * Lists GoogleAdsLinks on a property. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::listGoogleAdsLinksAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/list_google_ads_links.php + * + * @param ListGoogleAdsLinksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listGoogleAdsLinks(ListGoogleAdsLinksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListGoogleAdsLinks', $request, $callOptions); + } + + /** + * Returns child MeasurementProtocolSecrets under the specified parent + * Property. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::listMeasurementProtocolSecretsAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/list_measurement_protocol_secrets.php + * + * @param ListMeasurementProtocolSecretsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listMeasurementProtocolSecrets(ListMeasurementProtocolSecretsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListMeasurementProtocolSecrets', $request, $callOptions); + } + + /** + * Returns child Properties under the specified parent Account. + * + * Only "GA4" properties will be returned. + * Properties will be excluded if the caller does not have access. + * Soft-deleted (ie: "trashed") properties are excluded by default. + * Returns an empty list if no relevant properties are found. + * + * The async variant is {@see AnalyticsAdminServiceClient::listPropertiesAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/list_properties.php + * + * @param ListPropertiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listProperties(ListPropertiesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListProperties', $request, $callOptions); + } + + /** + * Requests a ticket for creating an account. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::provisionAccountTicketAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/provision_account_ticket.php + * + * @param ProvisionAccountTicketRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ProvisionAccountTicketResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function provisionAccountTicket(ProvisionAccountTicketRequest $request, array $callOptions = []): ProvisionAccountTicketResponse + { + return $this->startApiCall('ProvisionAccountTicket', $request, $callOptions)->wait(); + } + + /** + * Returns a customized report of data access records. The report provides + * records of each time a user reads Google Analytics reporting data. Access + * records are retained for up to 2 years. + * + * Data Access Reports can be requested for a property. The property must be + * in Google Analytics 360. This method is only available to Administrators. + * + * These data access records include GA4 UI Reporting, GA4 UI Explorations, + * GA4 Data API, and other products like Firebase & Admob that can retrieve + * data from Google Analytics through a linkage. These records don't include + * property configuration changes like adding a stream or changing a + * property's time zone. For configuration change history, see + * [searchChangeHistoryEvents](https://developers.google.com/analytics/devguides/config/admin/v1/rest/v1alpha/accounts/searchChangeHistoryEvents). + * + * The async variant is {@see AnalyticsAdminServiceClient::runAccessReportAsync()} + * . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/run_access_report.php + * + * @param RunAccessReportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RunAccessReportResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function runAccessReport(RunAccessReportRequest $request, array $callOptions = []): RunAccessReportResponse + { + return $this->startApiCall('RunAccessReport', $request, $callOptions)->wait(); + } + + /** + * Searches through all changes to an account or its children given the + * specified set of filters. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::searchChangeHistoryEventsAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/search_change_history_events.php + * + * @param SearchChangeHistoryEventsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function searchChangeHistoryEvents(SearchChangeHistoryEventsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchChangeHistoryEvents', $request, $callOptions); + } + + /** + * Updates an account. + * + * The async variant is {@see AnalyticsAdminServiceClient::updateAccountAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/update_account.php + * + * @param UpdateAccountRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Account + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function updateAccount(UpdateAccountRequest $request, array $callOptions = []): Account + { + return $this->startApiCall('UpdateAccount', $request, $callOptions)->wait(); + } + + /** + * Updates a conversion event with the specified attributes. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::updateConversionEventAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/update_conversion_event.php + * + * @param UpdateConversionEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ConversionEvent + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function updateConversionEvent(UpdateConversionEventRequest $request, array $callOptions = []): ConversionEvent + { + return $this->startApiCall('UpdateConversionEvent', $request, $callOptions)->wait(); + } + + /** + * Updates a CustomDimension on a property. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::updateCustomDimensionAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/update_custom_dimension.php + * + * @param UpdateCustomDimensionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CustomDimension + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function updateCustomDimension(UpdateCustomDimensionRequest $request, array $callOptions = []): CustomDimension + { + return $this->startApiCall('UpdateCustomDimension', $request, $callOptions)->wait(); + } + + /** + * Updates a CustomMetric on a property. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::updateCustomMetricAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/update_custom_metric.php + * + * @param UpdateCustomMetricRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CustomMetric + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function updateCustomMetric(UpdateCustomMetricRequest $request, array $callOptions = []): CustomMetric + { + return $this->startApiCall('UpdateCustomMetric', $request, $callOptions)->wait(); + } + + /** + * Updates the singleton data retention settings for this property. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::updateDataRetentionSettingsAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/update_data_retention_settings.php + * + * @param UpdateDataRetentionSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataRetentionSettings + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function updateDataRetentionSettings(UpdateDataRetentionSettingsRequest $request, array $callOptions = []): DataRetentionSettings + { + return $this->startApiCall('UpdateDataRetentionSettings', $request, $callOptions)->wait(); + } + + /** + * Updates a DataStream on a property. + * + * The async variant is {@see AnalyticsAdminServiceClient::updateDataStreamAsync()} + * . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/update_data_stream.php + * + * @param UpdateDataStreamRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataStream + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function updateDataStream(UpdateDataStreamRequest $request, array $callOptions = []): DataStream + { + return $this->startApiCall('UpdateDataStream', $request, $callOptions)->wait(); + } + + /** + * Updates a GoogleAdsLink on a property + * + * The async variant is + * {@see AnalyticsAdminServiceClient::updateGoogleAdsLinkAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/update_google_ads_link.php + * + * @param UpdateGoogleAdsLinkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GoogleAdsLink + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function updateGoogleAdsLink(UpdateGoogleAdsLinkRequest $request, array $callOptions = []): GoogleAdsLink + { + return $this->startApiCall('UpdateGoogleAdsLink', $request, $callOptions)->wait(); + } + + /** + * Updates a measurement protocol secret. + * + * The async variant is + * {@see AnalyticsAdminServiceClient::updateMeasurementProtocolSecretAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/update_measurement_protocol_secret.php + * + * @param UpdateMeasurementProtocolSecretRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MeasurementProtocolSecret + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function updateMeasurementProtocolSecret(UpdateMeasurementProtocolSecretRequest $request, array $callOptions = []): MeasurementProtocolSecret + { + return $this->startApiCall('UpdateMeasurementProtocolSecret', $request, $callOptions)->wait(); + } + + /** + * Updates a property. + * + * The async variant is {@see AnalyticsAdminServiceClient::updatePropertyAsync()} . + * + * @example samples/V1beta/AnalyticsAdminServiceClient/update_property.php + * + * @param UpdatePropertyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Property + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function updateProperty(UpdatePropertyRequest $request, array $callOptions = []): Property + { + return $this->startApiCall('UpdateProperty', $request, $callOptions)->wait(); + } } diff --git a/AnalyticsAdmin/src/V1beta/Client/BaseClient/AnalyticsAdminServiceBaseClient.php b/AnalyticsAdmin/src/V1beta/Client/BaseClient/AnalyticsAdminServiceBaseClient.php deleted file mode 100644 index b3fe720e7f77..000000000000 --- a/AnalyticsAdmin/src/V1beta/Client/BaseClient/AnalyticsAdminServiceBaseClient.php +++ /dev/null @@ -1,1932 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/analytics_admin_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/analytics_admin_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/analytics_admin_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/analytics_admin_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a account - * resource. - * - * @param string $account - * - * @return string The formatted account resource. - * - * @experimental - */ - public static function accountName(string $account): string - { - return self::getPathTemplate('account')->render([ - 'account' => $account, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * conversion_event resource. - * - * @param string $property - * @param string $conversionEvent - * - * @return string The formatted conversion_event resource. - * - * @experimental - */ - public static function conversionEventName(string $property, string $conversionEvent): string - { - return self::getPathTemplate('conversionEvent')->render([ - 'property' => $property, - 'conversion_event' => $conversionEvent, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * custom_dimension resource. - * - * @param string $property - * @param string $customDimension - * - * @return string The formatted custom_dimension resource. - * - * @experimental - */ - public static function customDimensionName(string $property, string $customDimension): string - { - return self::getPathTemplate('customDimension')->render([ - 'property' => $property, - 'custom_dimension' => $customDimension, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * custom_metric resource. - * - * @param string $property - * @param string $customMetric - * - * @return string The formatted custom_metric resource. - * - * @experimental - */ - public static function customMetricName(string $property, string $customMetric): string - { - return self::getPathTemplate('customMetric')->render([ - 'property' => $property, - 'custom_metric' => $customMetric, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * data_retention_settings resource. - * - * @param string $property - * - * @return string The formatted data_retention_settings resource. - * - * @experimental - */ - public static function dataRetentionSettingsName(string $property): string - { - return self::getPathTemplate('dataRetentionSettings')->render([ - 'property' => $property, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * data_sharing_settings resource. - * - * @param string $account - * - * @return string The formatted data_sharing_settings resource. - * - * @experimental - */ - public static function dataSharingSettingsName(string $account): string - { - return self::getPathTemplate('dataSharingSettings')->render([ - 'account' => $account, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a data_stream - * resource. - * - * @param string $property - * @param string $dataStream - * - * @return string The formatted data_stream resource. - * - * @experimental - */ - public static function dataStreamName(string $property, string $dataStream): string - { - return self::getPathTemplate('dataStream')->render([ - 'property' => $property, - 'data_stream' => $dataStream, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * firebase_link resource. - * - * @param string $property - * @param string $firebaseLink - * - * @return string The formatted firebase_link resource. - * - * @experimental - */ - public static function firebaseLinkName(string $property, string $firebaseLink): string - { - return self::getPathTemplate('firebaseLink')->render([ - 'property' => $property, - 'firebase_link' => $firebaseLink, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * google_ads_link resource. - * - * @param string $property - * @param string $googleAdsLink - * - * @return string The formatted google_ads_link resource. - * - * @experimental - */ - public static function googleAdsLinkName(string $property, string $googleAdsLink): string - { - return self::getPathTemplate('googleAdsLink')->render([ - 'property' => $property, - 'google_ads_link' => $googleAdsLink, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * measurement_protocol_secret resource. - * - * @param string $property - * @param string $dataStream - * @param string $measurementProtocolSecret - * - * @return string The formatted measurement_protocol_secret resource. - * - * @experimental - */ - public static function measurementProtocolSecretName(string $property, string $dataStream, string $measurementProtocolSecret): string - { - return self::getPathTemplate('measurementProtocolSecret')->render([ - 'property' => $property, - 'data_stream' => $dataStream, - 'measurement_protocol_secret' => $measurementProtocolSecret, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a property - * resource. - * - * @param string $property - * - * @return string The formatted property resource. - * - * @experimental - */ - public static function propertyName(string $property): string - { - return self::getPathTemplate('property')->render([ - 'property' => $property, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - account: accounts/{account} - * - conversionEvent: properties/{property}/conversionEvents/{conversion_event} - * - customDimension: properties/{property}/customDimensions/{custom_dimension} - * - customMetric: properties/{property}/customMetrics/{custom_metric} - * - dataRetentionSettings: properties/{property}/dataRetentionSettings - * - dataSharingSettings: accounts/{account}/dataSharingSettings - * - dataStream: properties/{property}/dataStreams/{data_stream} - * - firebaseLink: properties/{property}/firebaseLinks/{firebase_link} - * - googleAdsLink: properties/{property}/googleAdsLinks/{google_ads_link} - * - measurementProtocolSecret: properties/{property}/dataStreams/{data_stream}/measurementProtocolSecrets/{measurement_protocol_secret} - * - property: properties/{property} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'analyticsadmin.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); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Acknowledges the terms of user data collection for the specified property. - * - * This acknowledgement must be completed (either in the Google Analytics UI - * or through this API) before MeasurementProtocolSecret resources may be - * created. - * - * The async variant is {@see self::acknowledgeUserDataCollectionAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/acknowledge_user_data_collection.php - * - * @param AcknowledgeUserDataCollectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AcknowledgeUserDataCollectionResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function acknowledgeUserDataCollection(AcknowledgeUserDataCollectionRequest $request, array $callOptions = []): AcknowledgeUserDataCollectionResponse - { - return $this->startApiCall('AcknowledgeUserDataCollection', $request, $callOptions)->wait(); - } - - /** - * Archives a CustomDimension on a property. - * - * The async variant is {@see self::archiveCustomDimensionAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/archive_custom_dimension.php - * - * @param ArchiveCustomDimensionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function archiveCustomDimension(ArchiveCustomDimensionRequest $request, array $callOptions = []): void - { - $this->startApiCall('ArchiveCustomDimension', $request, $callOptions)->wait(); - } - - /** - * Archives a CustomMetric on a property. - * - * The async variant is {@see self::archiveCustomMetricAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/archive_custom_metric.php - * - * @param ArchiveCustomMetricRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function archiveCustomMetric(ArchiveCustomMetricRequest $request, array $callOptions = []): void - { - $this->startApiCall('ArchiveCustomMetric', $request, $callOptions)->wait(); - } - - /** - * Creates a conversion event with the specified attributes. - * - * The async variant is {@see self::createConversionEventAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/create_conversion_event.php - * - * @param CreateConversionEventRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ConversionEvent - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createConversionEvent(CreateConversionEventRequest $request, array $callOptions = []): ConversionEvent - { - return $this->startApiCall('CreateConversionEvent', $request, $callOptions)->wait(); - } - - /** - * Creates a CustomDimension. - * - * The async variant is {@see self::createCustomDimensionAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/create_custom_dimension.php - * - * @param CreateCustomDimensionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CustomDimension - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createCustomDimension(CreateCustomDimensionRequest $request, array $callOptions = []): CustomDimension - { - return $this->startApiCall('CreateCustomDimension', $request, $callOptions)->wait(); - } - - /** - * Creates a CustomMetric. - * - * The async variant is {@see self::createCustomMetricAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/create_custom_metric.php - * - * @param CreateCustomMetricRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CustomMetric - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createCustomMetric(CreateCustomMetricRequest $request, array $callOptions = []): CustomMetric - { - return $this->startApiCall('CreateCustomMetric', $request, $callOptions)->wait(); - } - - /** - * Creates a DataStream. - * - * The async variant is {@see self::createDataStreamAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/create_data_stream.php - * - * @param CreateDataStreamRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataStream - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createDataStream(CreateDataStreamRequest $request, array $callOptions = []): DataStream - { - return $this->startApiCall('CreateDataStream', $request, $callOptions)->wait(); - } - - /** - * Creates a FirebaseLink. - * - * Properties can have at most one FirebaseLink. - * - * The async variant is {@see self::createFirebaseLinkAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/create_firebase_link.php - * - * @param CreateFirebaseLinkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FirebaseLink - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createFirebaseLink(CreateFirebaseLinkRequest $request, array $callOptions = []): FirebaseLink - { - return $this->startApiCall('CreateFirebaseLink', $request, $callOptions)->wait(); - } - - /** - * Creates a GoogleAdsLink. - * - * The async variant is {@see self::createGoogleAdsLinkAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/create_google_ads_link.php - * - * @param CreateGoogleAdsLinkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GoogleAdsLink - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createGoogleAdsLink(CreateGoogleAdsLinkRequest $request, array $callOptions = []): GoogleAdsLink - { - return $this->startApiCall('CreateGoogleAdsLink', $request, $callOptions)->wait(); - } - - /** - * Creates a measurement protocol secret. - * - * The async variant is {@see self::createMeasurementProtocolSecretAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/create_measurement_protocol_secret.php - * - * @param CreateMeasurementProtocolSecretRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MeasurementProtocolSecret - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createMeasurementProtocolSecret(CreateMeasurementProtocolSecretRequest $request, array $callOptions = []): MeasurementProtocolSecret - { - return $this->startApiCall('CreateMeasurementProtocolSecret', $request, $callOptions)->wait(); - } - - /** - * Creates an "GA4" property with the specified location and attributes. - * - * The async variant is {@see self::createPropertyAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/create_property.php - * - * @param CreatePropertyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Property - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createProperty(CreatePropertyRequest $request, array $callOptions = []): Property - { - return $this->startApiCall('CreateProperty', $request, $callOptions)->wait(); - } - - /** - * Marks target Account as soft-deleted (ie: "trashed") and returns it. - * - * This API does not have a method to restore soft-deleted accounts. - * However, they can be restored using the Trash Can UI. - * - * If the accounts are not restored before the expiration time, the account - * and all child resources (eg: Properties, GoogleAdsLinks, Streams, - * UserLinks) will be permanently purged. - * https://support.google.com/analytics/answer/6154772 - * - * Returns an error if the target is not found. - * - * The async variant is {@see self::deleteAccountAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/delete_account.php - * - * @param DeleteAccountRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteAccount(DeleteAccountRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteAccount', $request, $callOptions)->wait(); - } - - /** - * Deletes a conversion event in a property. - * - * The async variant is {@see self::deleteConversionEventAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/delete_conversion_event.php - * - * @param DeleteConversionEventRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteConversionEvent(DeleteConversionEventRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteConversionEvent', $request, $callOptions)->wait(); - } - - /** - * Deletes a DataStream on a property. - * - * The async variant is {@see self::deleteDataStreamAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/delete_data_stream.php - * - * @param DeleteDataStreamRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteDataStream(DeleteDataStreamRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteDataStream', $request, $callOptions)->wait(); - } - - /** - * Deletes a FirebaseLink on a property - * - * The async variant is {@see self::deleteFirebaseLinkAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/delete_firebase_link.php - * - * @param DeleteFirebaseLinkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteFirebaseLink(DeleteFirebaseLinkRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteFirebaseLink', $request, $callOptions)->wait(); - } - - /** - * Deletes a GoogleAdsLink on a property - * - * The async variant is {@see self::deleteGoogleAdsLinkAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/delete_google_ads_link.php - * - * @param DeleteGoogleAdsLinkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteGoogleAdsLink(DeleteGoogleAdsLinkRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteGoogleAdsLink', $request, $callOptions)->wait(); - } - - /** - * Deletes target MeasurementProtocolSecret. - * - * The async variant is {@see self::deleteMeasurementProtocolSecretAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/delete_measurement_protocol_secret.php - * - * @param DeleteMeasurementProtocolSecretRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteMeasurementProtocolSecret(DeleteMeasurementProtocolSecretRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteMeasurementProtocolSecret', $request, $callOptions)->wait(); - } - - /** - * Marks target Property as soft-deleted (ie: "trashed") and returns it. - * - * This API does not have a method to restore soft-deleted properties. - * However, they can be restored using the Trash Can UI. - * - * If the properties are not restored before the expiration time, the Property - * and all child resources (eg: GoogleAdsLinks, Streams, UserLinks) - * will be permanently purged. - * https://support.google.com/analytics/answer/6154772 - * - * Returns an error if the target is not found, or is not a GA4 Property. - * - * The async variant is {@see self::deletePropertyAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/delete_property.php - * - * @param DeletePropertyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Property - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteProperty(DeletePropertyRequest $request, array $callOptions = []): Property - { - return $this->startApiCall('DeleteProperty', $request, $callOptions)->wait(); - } - - /** - * Lookup for a single Account. - * - * The async variant is {@see self::getAccountAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/get_account.php - * - * @param GetAccountRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Account - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getAccount(GetAccountRequest $request, array $callOptions = []): Account - { - return $this->startApiCall('GetAccount', $request, $callOptions)->wait(); - } - - /** - * Retrieve a single conversion event. - * - * The async variant is {@see self::getConversionEventAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/get_conversion_event.php - * - * @param GetConversionEventRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ConversionEvent - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getConversionEvent(GetConversionEventRequest $request, array $callOptions = []): ConversionEvent - { - return $this->startApiCall('GetConversionEvent', $request, $callOptions)->wait(); - } - - /** - * Lookup for a single CustomDimension. - * - * The async variant is {@see self::getCustomDimensionAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/get_custom_dimension.php - * - * @param GetCustomDimensionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CustomDimension - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getCustomDimension(GetCustomDimensionRequest $request, array $callOptions = []): CustomDimension - { - return $this->startApiCall('GetCustomDimension', $request, $callOptions)->wait(); - } - - /** - * Lookup for a single CustomMetric. - * - * The async variant is {@see self::getCustomMetricAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/get_custom_metric.php - * - * @param GetCustomMetricRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CustomMetric - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getCustomMetric(GetCustomMetricRequest $request, array $callOptions = []): CustomMetric - { - return $this->startApiCall('GetCustomMetric', $request, $callOptions)->wait(); - } - - /** - * Returns the singleton data retention settings for this property. - * - * The async variant is {@see self::getDataRetentionSettingsAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/get_data_retention_settings.php - * - * @param GetDataRetentionSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataRetentionSettings - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getDataRetentionSettings(GetDataRetentionSettingsRequest $request, array $callOptions = []): DataRetentionSettings - { - return $this->startApiCall('GetDataRetentionSettings', $request, $callOptions)->wait(); - } - - /** - * Get data sharing settings on an account. - * Data sharing settings are singletons. - * - * The async variant is {@see self::getDataSharingSettingsAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/get_data_sharing_settings.php - * - * @param GetDataSharingSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataSharingSettings - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getDataSharingSettings(GetDataSharingSettingsRequest $request, array $callOptions = []): DataSharingSettings - { - return $this->startApiCall('GetDataSharingSettings', $request, $callOptions)->wait(); - } - - /** - * Lookup for a single DataStream. - * - * The async variant is {@see self::getDataStreamAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/get_data_stream.php - * - * @param GetDataStreamRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataStream - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getDataStream(GetDataStreamRequest $request, array $callOptions = []): DataStream - { - return $this->startApiCall('GetDataStream', $request, $callOptions)->wait(); - } - - /** - * Lookup for a single "GA4" MeasurementProtocolSecret. - * - * The async variant is {@see self::getMeasurementProtocolSecretAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/get_measurement_protocol_secret.php - * - * @param GetMeasurementProtocolSecretRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MeasurementProtocolSecret - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getMeasurementProtocolSecret(GetMeasurementProtocolSecretRequest $request, array $callOptions = []): MeasurementProtocolSecret - { - return $this->startApiCall('GetMeasurementProtocolSecret', $request, $callOptions)->wait(); - } - - /** - * Lookup for a single "GA4" Property. - * - * The async variant is {@see self::getPropertyAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/get_property.php - * - * @param GetPropertyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Property - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getProperty(GetPropertyRequest $request, array $callOptions = []): Property - { - return $this->startApiCall('GetProperty', $request, $callOptions)->wait(); - } - - /** - * Returns summaries of all accounts accessible by the caller. - * - * The async variant is {@see self::listAccountSummariesAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/list_account_summaries.php - * - * @param ListAccountSummariesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listAccountSummaries(ListAccountSummariesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAccountSummaries', $request, $callOptions); - } - - /** - * Returns all accounts accessible by the caller. - * - * Note that these accounts might not currently have GA4 properties. - * Soft-deleted (ie: "trashed") accounts are excluded by default. - * Returns an empty list if no relevant accounts are found. - * - * The async variant is {@see self::listAccountsAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/list_accounts.php - * - * @param ListAccountsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listAccounts(ListAccountsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAccounts', $request, $callOptions); - } - - /** - * Returns a list of conversion events in the specified parent property. - * - * Returns an empty list if no conversion events are found. - * - * The async variant is {@see self::listConversionEventsAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/list_conversion_events.php - * - * @param ListConversionEventsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listConversionEvents(ListConversionEventsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListConversionEvents', $request, $callOptions); - } - - /** - * Lists CustomDimensions on a property. - * - * The async variant is {@see self::listCustomDimensionsAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/list_custom_dimensions.php - * - * @param ListCustomDimensionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listCustomDimensions(ListCustomDimensionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCustomDimensions', $request, $callOptions); - } - - /** - * Lists CustomMetrics on a property. - * - * The async variant is {@see self::listCustomMetricsAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/list_custom_metrics.php - * - * @param ListCustomMetricsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listCustomMetrics(ListCustomMetricsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCustomMetrics', $request, $callOptions); - } - - /** - * Lists DataStreams on a property. - * - * The async variant is {@see self::listDataStreamsAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/list_data_streams.php - * - * @param ListDataStreamsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listDataStreams(ListDataStreamsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDataStreams', $request, $callOptions); - } - - /** - * Lists FirebaseLinks on a property. - * Properties can have at most one FirebaseLink. - * - * The async variant is {@see self::listFirebaseLinksAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/list_firebase_links.php - * - * @param ListFirebaseLinksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listFirebaseLinks(ListFirebaseLinksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListFirebaseLinks', $request, $callOptions); - } - - /** - * Lists GoogleAdsLinks on a property. - * - * The async variant is {@see self::listGoogleAdsLinksAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/list_google_ads_links.php - * - * @param ListGoogleAdsLinksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listGoogleAdsLinks(ListGoogleAdsLinksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListGoogleAdsLinks', $request, $callOptions); - } - - /** - * Returns child MeasurementProtocolSecrets under the specified parent - * Property. - * - * The async variant is {@see self::listMeasurementProtocolSecretsAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/list_measurement_protocol_secrets.php - * - * @param ListMeasurementProtocolSecretsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listMeasurementProtocolSecrets(ListMeasurementProtocolSecretsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListMeasurementProtocolSecrets', $request, $callOptions); - } - - /** - * Returns child Properties under the specified parent Account. - * - * Only "GA4" properties will be returned. - * Properties will be excluded if the caller does not have access. - * Soft-deleted (ie: "trashed") properties are excluded by default. - * Returns an empty list if no relevant properties are found. - * - * The async variant is {@see self::listPropertiesAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/list_properties.php - * - * @param ListPropertiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listProperties(ListPropertiesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListProperties', $request, $callOptions); - } - - /** - * Requests a ticket for creating an account. - * - * The async variant is {@see self::provisionAccountTicketAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/provision_account_ticket.php - * - * @param ProvisionAccountTicketRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ProvisionAccountTicketResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function provisionAccountTicket(ProvisionAccountTicketRequest $request, array $callOptions = []): ProvisionAccountTicketResponse - { - return $this->startApiCall('ProvisionAccountTicket', $request, $callOptions)->wait(); - } - - /** - * Returns a customized report of data access records. The report provides - * records of each time a user reads Google Analytics reporting data. Access - * records are retained for up to 2 years. - * - * Data Access Reports can be requested for a property. The property must be - * in Google Analytics 360. This method is only available to Administrators. - * - * These data access records include GA4 UI Reporting, GA4 UI Explorations, - * GA4 Data API, and other products like Firebase & Admob that can retrieve - * data from Google Analytics through a linkage. These records don't include - * property configuration changes like adding a stream or changing a - * property's time zone. For configuration change history, see - * [searchChangeHistoryEvents](https://developers.google.com/analytics/devguides/config/admin/v1/rest/v1alpha/accounts/searchChangeHistoryEvents). - * - * The async variant is {@see self::runAccessReportAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/run_access_report.php - * - * @param RunAccessReportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RunAccessReportResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function runAccessReport(RunAccessReportRequest $request, array $callOptions = []): RunAccessReportResponse - { - return $this->startApiCall('RunAccessReport', $request, $callOptions)->wait(); - } - - /** - * Searches through all changes to an account or its children given the - * specified set of filters. - * - * The async variant is {@see self::searchChangeHistoryEventsAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/search_change_history_events.php - * - * @param SearchChangeHistoryEventsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function searchChangeHistoryEvents(SearchChangeHistoryEventsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchChangeHistoryEvents', $request, $callOptions); - } - - /** - * Updates an account. - * - * The async variant is {@see self::updateAccountAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/update_account.php - * - * @param UpdateAccountRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Account - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function updateAccount(UpdateAccountRequest $request, array $callOptions = []): Account - { - return $this->startApiCall('UpdateAccount', $request, $callOptions)->wait(); - } - - /** - * Updates a conversion event with the specified attributes. - * - * The async variant is {@see self::updateConversionEventAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/update_conversion_event.php - * - * @param UpdateConversionEventRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ConversionEvent - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function updateConversionEvent(UpdateConversionEventRequest $request, array $callOptions = []): ConversionEvent - { - return $this->startApiCall('UpdateConversionEvent', $request, $callOptions)->wait(); - } - - /** - * Updates a CustomDimension on a property. - * - * The async variant is {@see self::updateCustomDimensionAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/update_custom_dimension.php - * - * @param UpdateCustomDimensionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CustomDimension - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function updateCustomDimension(UpdateCustomDimensionRequest $request, array $callOptions = []): CustomDimension - { - return $this->startApiCall('UpdateCustomDimension', $request, $callOptions)->wait(); - } - - /** - * Updates a CustomMetric on a property. - * - * The async variant is {@see self::updateCustomMetricAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/update_custom_metric.php - * - * @param UpdateCustomMetricRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CustomMetric - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function updateCustomMetric(UpdateCustomMetricRequest $request, array $callOptions = []): CustomMetric - { - return $this->startApiCall('UpdateCustomMetric', $request, $callOptions)->wait(); - } - - /** - * Updates the singleton data retention settings for this property. - * - * The async variant is {@see self::updateDataRetentionSettingsAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/update_data_retention_settings.php - * - * @param UpdateDataRetentionSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataRetentionSettings - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function updateDataRetentionSettings(UpdateDataRetentionSettingsRequest $request, array $callOptions = []): DataRetentionSettings - { - return $this->startApiCall('UpdateDataRetentionSettings', $request, $callOptions)->wait(); - } - - /** - * Updates a DataStream on a property. - * - * The async variant is {@see self::updateDataStreamAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/update_data_stream.php - * - * @param UpdateDataStreamRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataStream - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function updateDataStream(UpdateDataStreamRequest $request, array $callOptions = []): DataStream - { - return $this->startApiCall('UpdateDataStream', $request, $callOptions)->wait(); - } - - /** - * Updates a GoogleAdsLink on a property - * - * The async variant is {@see self::updateGoogleAdsLinkAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/update_google_ads_link.php - * - * @param UpdateGoogleAdsLinkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GoogleAdsLink - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function updateGoogleAdsLink(UpdateGoogleAdsLinkRequest $request, array $callOptions = []): GoogleAdsLink - { - return $this->startApiCall('UpdateGoogleAdsLink', $request, $callOptions)->wait(); - } - - /** - * Updates a measurement protocol secret. - * - * The async variant is {@see self::updateMeasurementProtocolSecretAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/update_measurement_protocol_secret.php - * - * @param UpdateMeasurementProtocolSecretRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MeasurementProtocolSecret - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function updateMeasurementProtocolSecret(UpdateMeasurementProtocolSecretRequest $request, array $callOptions = []): MeasurementProtocolSecret - { - return $this->startApiCall('UpdateMeasurementProtocolSecret', $request, $callOptions)->wait(); - } - - /** - * Updates a property. - * - * The async variant is {@see self::updatePropertyAsync()} . - * - * @example samples/V1beta/AnalyticsAdminServiceClient/update_property.php - * - * @param UpdatePropertyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Property - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function updateProperty(UpdatePropertyRequest $request, array $callOptions = []): Property - { - return $this->startApiCall('UpdateProperty', $request, $callOptions)->wait(); - } -} diff --git a/AnalyticsData/composer.json b/AnalyticsData/composer.json index 3969dbb1d402..3c7dc6e180be 100644 --- a/AnalyticsData/composer.json +++ b/AnalyticsData/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/AnalyticsData/src/V1beta/Client/BaseClient/BetaAnalyticsDataBaseClient.php b/AnalyticsData/src/V1beta/Client/BaseClient/BetaAnalyticsDataBaseClient.php deleted file mode 100644 index 0fef39bd6498..000000000000 --- a/AnalyticsData/src/V1beta/Client/BaseClient/BetaAnalyticsDataBaseClient.php +++ /dev/null @@ -1,475 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/beta_analytics_data_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/beta_analytics_data_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/beta_analytics_data_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/beta_analytics_data_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a metadata - * resource. - * - * @param string $property - * - * @return string The formatted metadata resource. - * - * @experimental - */ - public static function metadataName(string $property): string - { - return self::getPathTemplate('metadata')->render([ - 'property' => $property, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - metadata: properties/{property}/metadata - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'analyticsdata.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); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Returns multiple pivot reports in a batch. All reports must be for the same - * GA4 Property. - * - * The async variant is {@see self::batchRunPivotReportsAsync()} . - * - * @example samples/V1beta/BetaAnalyticsDataClient/batch_run_pivot_reports.php - * - * @param BatchRunPivotReportsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BatchRunPivotReportsResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function batchRunPivotReports(BatchRunPivotReportsRequest $request, array $callOptions = []): BatchRunPivotReportsResponse - { - return $this->startApiCall('BatchRunPivotReports', $request, $callOptions)->wait(); - } - - /** - * Returns multiple reports in a batch. All reports must be for the same - * GA4 Property. - * - * The async variant is {@see self::batchRunReportsAsync()} . - * - * @example samples/V1beta/BetaAnalyticsDataClient/batch_run_reports.php - * - * @param BatchRunReportsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BatchRunReportsResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function batchRunReports(BatchRunReportsRequest $request, array $callOptions = []): BatchRunReportsResponse - { - return $this->startApiCall('BatchRunReports', $request, $callOptions)->wait(); - } - - /** - * This compatibility method lists dimensions and metrics that can be added to - * a report request and maintain compatibility. This method fails if the - * request's dimensions and metrics are incompatible. - * - * In Google Analytics, reports fail if they request incompatible dimensions - * and/or metrics; in that case, you will need to remove dimensions and/or - * metrics from the incompatible report until the report is compatible. - * - * The Realtime and Core reports have different compatibility rules. This - * method checks compatibility for Core reports. - * - * The async variant is {@see self::checkCompatibilityAsync()} . - * - * @example samples/V1beta/BetaAnalyticsDataClient/check_compatibility.php - * - * @param CheckCompatibilityRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CheckCompatibilityResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function checkCompatibility(CheckCompatibilityRequest $request, array $callOptions = []): CheckCompatibilityResponse - { - return $this->startApiCall('CheckCompatibility', $request, $callOptions)->wait(); - } - - /** - * Returns metadata for dimensions and metrics available in reporting methods. - * Used to explore the dimensions and metrics. In this method, a Google - * Analytics GA4 Property Identifier is specified in the request, and - * the metadata response includes Custom dimensions and metrics as well as - * Universal metadata. - * - * For example if a custom metric with parameter name `levels_unlocked` is - * registered to a property, the Metadata response will contain - * `customEvent:levels_unlocked`. Universal metadata are dimensions and - * metrics applicable to any property such as `country` and `totalUsers`. - * - * The async variant is {@see self::getMetadataAsync()} . - * - * @example samples/V1beta/BetaAnalyticsDataClient/get_metadata.php - * - * @param GetMetadataRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Metadata - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getMetadata(GetMetadataRequest $request, array $callOptions = []): Metadata - { - return $this->startApiCall('GetMetadata', $request, $callOptions)->wait(); - } - - /** - * Returns a customized pivot report of your Google Analytics event data. - * Pivot reports are more advanced and expressive formats than regular - * reports. In a pivot report, dimensions are only visible if they are - * included in a pivot. Multiple pivots can be specified to further dissect - * your data. - * - * The async variant is {@see self::runPivotReportAsync()} . - * - * @example samples/V1beta/BetaAnalyticsDataClient/run_pivot_report.php - * - * @param RunPivotReportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RunPivotReportResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function runPivotReport(RunPivotReportRequest $request, array $callOptions = []): RunPivotReportResponse - { - return $this->startApiCall('RunPivotReport', $request, $callOptions)->wait(); - } - - /** - * Returns a customized report of realtime event data for your property. - * Events appear in realtime reports seconds after they have been sent to - * the Google Analytics. Realtime reports show events and usage data for the - * periods of time ranging from the present moment to 30 minutes ago (up to - * 60 minutes for Google Analytics 360 properties). - * - * For a guide to constructing realtime requests & understanding responses, - * see [Creating a Realtime - * Report](https://developers.google.com/analytics/devguides/reporting/data/v1/realtime-basics). - * - * The async variant is {@see self::runRealtimeReportAsync()} . - * - * @example samples/V1beta/BetaAnalyticsDataClient/run_realtime_report.php - * - * @param RunRealtimeReportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RunRealtimeReportResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function runRealtimeReport(RunRealtimeReportRequest $request, array $callOptions = []): RunRealtimeReportResponse - { - return $this->startApiCall('RunRealtimeReport', $request, $callOptions)->wait(); - } - - /** - * Returns a customized report of your Google Analytics event data. Reports - * contain statistics derived from data collected by the Google Analytics - * tracking code. The data returned from the API is as a table with columns - * for the requested dimensions and metrics. Metrics are individual - * measurements of user activity on your property, such as active users or - * event count. Dimensions break down metrics across some common criteria, - * such as country or event name. - * - * For a guide to constructing requests & understanding responses, see - * [Creating a - * Report](https://developers.google.com/analytics/devguides/reporting/data/v1/basics). - * - * The async variant is {@see self::runReportAsync()} . - * - * @example samples/V1beta/BetaAnalyticsDataClient/run_report.php - * - * @param RunReportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RunReportResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function runReport(RunReportRequest $request, array $callOptions = []): RunReportResponse - { - return $this->startApiCall('RunReport', $request, $callOptions)->wait(); - } -} diff --git a/AnalyticsData/src/V1beta/Client/BetaAnalyticsDataClient.php b/AnalyticsData/src/V1beta/Client/BetaAnalyticsDataClient.php index 164c0808c938..0c1dd9dd59ac 100644 --- a/AnalyticsData/src/V1beta/Client/BetaAnalyticsDataClient.php +++ b/AnalyticsData/src/V1beta/Client/BetaAnalyticsDataClient.php @@ -26,17 +26,449 @@ namespace Google\Analytics\Data\V1beta\Client; -use Google\Analytics\Data\V1beta\Client\BaseClient\BetaAnalyticsDataBaseClient; +use Google\Analytics\Data\V1beta\BatchRunPivotReportsRequest; +use Google\Analytics\Data\V1beta\BatchRunPivotReportsResponse; +use Google\Analytics\Data\V1beta\BatchRunReportsRequest; +use Google\Analytics\Data\V1beta\BatchRunReportsResponse; +use Google\Analytics\Data\V1beta\CheckCompatibilityRequest; +use Google\Analytics\Data\V1beta\CheckCompatibilityResponse; +use Google\Analytics\Data\V1beta\GetMetadataRequest; +use Google\Analytics\Data\V1beta\Metadata; +use Google\Analytics\Data\V1beta\Metric; +use Google\Analytics\Data\V1beta\Pivot; +use Google\Analytics\Data\V1beta\RunPivotReportRequest; +use Google\Analytics\Data\V1beta\RunPivotReportResponse; +use Google\Analytics\Data\V1beta\RunRealtimeReportRequest; +use Google\Analytics\Data\V1beta\RunRealtimeReportResponse; +use Google\Analytics\Data\V1beta\RunReportRequest; +use Google\Analytics\Data\V1beta\RunReportResponse; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Google Analytics reporting data service. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface batchRunPivotReportsAsync(BatchRunPivotReportsRequest $request, array $optionalArgs = []) + * @method PromiseInterface batchRunReportsAsync(BatchRunReportsRequest $request, array $optionalArgs = []) + * @method PromiseInterface checkCompatibilityAsync(CheckCompatibilityRequest $request, array $optionalArgs = []) + * @method PromiseInterface getMetadataAsync(GetMetadataRequest $request, array $optionalArgs = []) + * @method PromiseInterface runPivotReportAsync(RunPivotReportRequest $request, array $optionalArgs = []) + * @method PromiseInterface runRealtimeReportAsync(RunRealtimeReportRequest $request, array $optionalArgs = []) + * @method PromiseInterface runReportAsync(RunReportRequest $request, array $optionalArgs = []) */ -final class BetaAnalyticsDataClient extends BetaAnalyticsDataBaseClient +final class BetaAnalyticsDataClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see BetaAnalyticsDataBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.analytics.data.v1beta.BetaAnalyticsData'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'analyticsdata.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/analytics', + 'https://www.googleapis.com/auth/analytics.readonly', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/beta_analytics_data_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/beta_analytics_data_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/beta_analytics_data_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/beta_analytics_data_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a metadata + * resource. + * + * @param string $property + * + * @return string The formatted metadata resource. + * + * @experimental + */ + public static function metadataName(string $property): string + { + return self::getPathTemplate('metadata')->render([ + 'property' => $property, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - metadata: properties/{property}/metadata + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'analyticsdata.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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Returns multiple pivot reports in a batch. All reports must be for the same + * GA4 Property. + * + * The async variant is {@see BetaAnalyticsDataClient::batchRunPivotReportsAsync()} + * . + * + * @example samples/V1beta/BetaAnalyticsDataClient/batch_run_pivot_reports.php + * + * @param BatchRunPivotReportsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BatchRunPivotReportsResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function batchRunPivotReports(BatchRunPivotReportsRequest $request, array $callOptions = []): BatchRunPivotReportsResponse + { + return $this->startApiCall('BatchRunPivotReports', $request, $callOptions)->wait(); + } + + /** + * Returns multiple reports in a batch. All reports must be for the same + * GA4 Property. + * + * The async variant is {@see BetaAnalyticsDataClient::batchRunReportsAsync()} . + * + * @example samples/V1beta/BetaAnalyticsDataClient/batch_run_reports.php + * + * @param BatchRunReportsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BatchRunReportsResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function batchRunReports(BatchRunReportsRequest $request, array $callOptions = []): BatchRunReportsResponse + { + return $this->startApiCall('BatchRunReports', $request, $callOptions)->wait(); + } + + /** + * This compatibility method lists dimensions and metrics that can be added to + * a report request and maintain compatibility. This method fails if the + * request's dimensions and metrics are incompatible. + * + * In Google Analytics, reports fail if they request incompatible dimensions + * and/or metrics; in that case, you will need to remove dimensions and/or + * metrics from the incompatible report until the report is compatible. + * + * The Realtime and Core reports have different compatibility rules. This + * method checks compatibility for Core reports. + * + * The async variant is {@see BetaAnalyticsDataClient::checkCompatibilityAsync()} . + * + * @example samples/V1beta/BetaAnalyticsDataClient/check_compatibility.php + * + * @param CheckCompatibilityRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CheckCompatibilityResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function checkCompatibility(CheckCompatibilityRequest $request, array $callOptions = []): CheckCompatibilityResponse + { + return $this->startApiCall('CheckCompatibility', $request, $callOptions)->wait(); + } + + /** + * Returns metadata for dimensions and metrics available in reporting methods. + * Used to explore the dimensions and metrics. In this method, a Google + * Analytics GA4 Property Identifier is specified in the request, and + * the metadata response includes Custom dimensions and metrics as well as + * Universal metadata. + * + * For example if a custom metric with parameter name `levels_unlocked` is + * registered to a property, the Metadata response will contain + * `customEvent:levels_unlocked`. Universal metadata are dimensions and + * metrics applicable to any property such as `country` and `totalUsers`. + * + * The async variant is {@see BetaAnalyticsDataClient::getMetadataAsync()} . + * + * @example samples/V1beta/BetaAnalyticsDataClient/get_metadata.php + * + * @param GetMetadataRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Metadata + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getMetadata(GetMetadataRequest $request, array $callOptions = []): Metadata + { + return $this->startApiCall('GetMetadata', $request, $callOptions)->wait(); + } + + /** + * Returns a customized pivot report of your Google Analytics event data. + * Pivot reports are more advanced and expressive formats than regular + * reports. In a pivot report, dimensions are only visible if they are + * included in a pivot. Multiple pivots can be specified to further dissect + * your data. + * + * The async variant is {@see BetaAnalyticsDataClient::runPivotReportAsync()} . + * + * @example samples/V1beta/BetaAnalyticsDataClient/run_pivot_report.php + * + * @param RunPivotReportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RunPivotReportResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function runPivotReport(RunPivotReportRequest $request, array $callOptions = []): RunPivotReportResponse + { + return $this->startApiCall('RunPivotReport', $request, $callOptions)->wait(); + } + + /** + * Returns a customized report of realtime event data for your property. + * Events appear in realtime reports seconds after they have been sent to + * the Google Analytics. Realtime reports show events and usage data for the + * periods of time ranging from the present moment to 30 minutes ago (up to + * 60 minutes for Google Analytics 360 properties). + * + * For a guide to constructing realtime requests & understanding responses, + * see [Creating a Realtime + * Report](https://developers.google.com/analytics/devguides/reporting/data/v1/realtime-basics). + * + * The async variant is {@see BetaAnalyticsDataClient::runRealtimeReportAsync()} . + * + * @example samples/V1beta/BetaAnalyticsDataClient/run_realtime_report.php + * + * @param RunRealtimeReportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RunRealtimeReportResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function runRealtimeReport(RunRealtimeReportRequest $request, array $callOptions = []): RunRealtimeReportResponse + { + return $this->startApiCall('RunRealtimeReport', $request, $callOptions)->wait(); + } + + /** + * Returns a customized report of your Google Analytics event data. Reports + * contain statistics derived from data collected by the Google Analytics + * tracking code. The data returned from the API is as a table with columns + * for the requested dimensions and metrics. Metrics are individual + * measurements of user activity on your property, such as active users or + * event count. Dimensions break down metrics across some common criteria, + * such as country or event name. + * + * For a guide to constructing requests & understanding responses, see + * [Creating a + * Report](https://developers.google.com/analytics/devguides/reporting/data/v1/basics). + * + * The async variant is {@see BetaAnalyticsDataClient::runReportAsync()} . + * + * @example samples/V1beta/BetaAnalyticsDataClient/run_report.php + * + * @param RunReportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RunReportResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function runReport(RunReportRequest $request, array $callOptions = []): RunReportResponse + { + return $this->startApiCall('RunReport', $request, $callOptions)->wait(); + } } diff --git a/ApiGateway/composer.json b/ApiGateway/composer.json index 874643e1adf7..c5aaf071152f 100644 --- a/ApiGateway/composer.json +++ b/ApiGateway/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/ApiGateway/src/V1/Client/ApiGatewayServiceClient.php b/ApiGateway/src/V1/Client/ApiGatewayServiceClient.php index 2afe792bbe19..3d8066d8fccf 100644 --- a/ApiGateway/src/V1/Client/ApiGatewayServiceClient.php +++ b/ApiGateway/src/V1/Client/ApiGatewayServiceClient.php @@ -24,17 +24,723 @@ namespace Google\Cloud\ApiGateway\V1\Client; -use Google\Cloud\ApiGateway\V1\Client\BaseClient\ApiGatewayServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\ApiGateway\V1\Api; +use Google\Cloud\ApiGateway\V1\ApiConfig; +use Google\Cloud\ApiGateway\V1\CreateApiConfigRequest; +use Google\Cloud\ApiGateway\V1\CreateApiRequest; +use Google\Cloud\ApiGateway\V1\CreateGatewayRequest; +use Google\Cloud\ApiGateway\V1\DeleteApiConfigRequest; +use Google\Cloud\ApiGateway\V1\DeleteApiRequest; +use Google\Cloud\ApiGateway\V1\DeleteGatewayRequest; +use Google\Cloud\ApiGateway\V1\Gateway; +use Google\Cloud\ApiGateway\V1\GetApiConfigRequest; +use Google\Cloud\ApiGateway\V1\GetApiRequest; +use Google\Cloud\ApiGateway\V1\GetGatewayRequest; +use Google\Cloud\ApiGateway\V1\ListApiConfigsRequest; +use Google\Cloud\ApiGateway\V1\ListApisRequest; +use Google\Cloud\ApiGateway\V1\ListGatewaysRequest; +use Google\Cloud\ApiGateway\V1\UpdateApiConfigRequest; +use Google\Cloud\ApiGateway\V1\UpdateApiRequest; +use Google\Cloud\ApiGateway\V1\UpdateGatewayRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The API Gateway Service is the interface for managing API Gateways. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ApiGateway\V1\ApiGatewayServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createApiAsync(CreateApiRequest $request, array $optionalArgs = []) + * @method PromiseInterface createApiConfigAsync(CreateApiConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface createGatewayAsync(CreateGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteApiAsync(DeleteApiRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteApiConfigAsync(DeleteApiConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteGatewayAsync(DeleteGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface getApiAsync(GetApiRequest $request, array $optionalArgs = []) + * @method PromiseInterface getApiConfigAsync(GetApiConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getGatewayAsync(GetGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface listApiConfigsAsync(ListApiConfigsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listApisAsync(ListApisRequest $request, array $optionalArgs = []) + * @method PromiseInterface listGatewaysAsync(ListGatewaysRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateApiAsync(UpdateApiRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateApiConfigAsync(UpdateApiConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateGatewayAsync(UpdateGatewayRequest $request, array $optionalArgs = []) */ -final class ApiGatewayServiceClient extends ApiGatewayServiceBaseClient +final class ApiGatewayServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ApiGatewayServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.apigateway.v1.ApiGatewayService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'apigateway.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/api_gateway_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/api_gateway_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/api_gateway_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/api_gateway_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a api + * resource. + * + * @param string $project + * @param string $api + * + * @return string The formatted api resource. + */ + public static function apiName(string $project, string $api): string + { + return self::getPathTemplate('api')->render([ + 'project' => $project, + 'api' => $api, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a api_config + * resource. + * + * @param string $project + * @param string $api + * @param string $apiConfig + * + * @return string The formatted api_config resource. + */ + public static function apiConfigName(string $project, string $api, string $apiConfig): string + { + return self::getPathTemplate('apiConfig')->render([ + 'project' => $project, + 'api' => $api, + 'api_config' => $apiConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a gateway + * resource. + * + * @param string $project + * @param string $location + * @param string $gateway + * + * @return string The formatted gateway resource. + */ + public static function gatewayName(string $project, string $location, string $gateway): string + { + return self::getPathTemplate('gateway')->render([ + 'project' => $project, + 'location' => $location, + 'gateway' => $gateway, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * managed_service resource. + * + * @param string $service + * + * @return string The formatted managed_service resource. + */ + public static function managedServiceName(string $service): string + { + return self::getPathTemplate('managedService')->render([ + 'service' => $service, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a service + * resource. + * + * @param string $service + * @param string $config + * + * @return string The formatted service resource. + */ + public static function serviceName(string $service, string $config): string + { + return self::getPathTemplate('service')->render([ + 'service' => $service, + 'config' => $config, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * service_account resource. + * + * @param string $project + * @param string $serviceAccount + * + * @return string The formatted service_account resource. + */ + public static function serviceAccountName(string $project, string $serviceAccount): string + { + return self::getPathTemplate('serviceAccount')->render([ + 'project' => $project, + 'service_account' => $serviceAccount, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - api: projects/{project}/locations/global/apis/{api} + * - apiConfig: projects/{project}/locations/global/apis/{api}/configs/{api_config} + * - gateway: projects/{project}/locations/{location}/gateways/{gateway} + * - location: projects/{project}/locations/{location} + * - managedService: services/{service} + * - service: services/{service}/configs/{config} + * - serviceAccount: projects/{project}/serviceAccounts/{service_account} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'apigateway.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new Api in a given project and location. + * + * The async variant is {@see ApiGatewayServiceClient::createApiAsync()} . + * + * @param CreateApiRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createApi(CreateApiRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateApi', $request, $callOptions)->wait(); + } + + /** + * Creates a new ApiConfig in a given project and location. + * + * The async variant is {@see ApiGatewayServiceClient::createApiConfigAsync()} . + * + * @param CreateApiConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createApiConfig(CreateApiConfigRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateApiConfig', $request, $callOptions)->wait(); + } + + /** + * Creates a new Gateway in a given project and location. + * + * The async variant is {@see ApiGatewayServiceClient::createGatewayAsync()} . + * + * @param CreateGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createGateway(CreateGatewayRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateGateway', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Api. + * + * The async variant is {@see ApiGatewayServiceClient::deleteApiAsync()} . + * + * @param DeleteApiRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteApi(DeleteApiRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteApi', $request, $callOptions)->wait(); + } + + /** + * Deletes a single ApiConfig. + * + * The async variant is {@see ApiGatewayServiceClient::deleteApiConfigAsync()} . + * + * @param DeleteApiConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteApiConfig(DeleteApiConfigRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteApiConfig', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Gateway. + * + * The async variant is {@see ApiGatewayServiceClient::deleteGatewayAsync()} . + * + * @param DeleteGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteGateway(DeleteGatewayRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteGateway', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Api. + * + * The async variant is {@see ApiGatewayServiceClient::getApiAsync()} . + * + * @param GetApiRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Api + * + * @throws ApiException Thrown if the API call fails. + */ + public function getApi(GetApiRequest $request, array $callOptions = []): Api + { + return $this->startApiCall('GetApi', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single ApiConfig. + * + * The async variant is {@see ApiGatewayServiceClient::getApiConfigAsync()} . + * + * @param GetApiConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ApiConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getApiConfig(GetApiConfigRequest $request, array $callOptions = []): ApiConfig + { + return $this->startApiCall('GetApiConfig', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Gateway. + * + * The async variant is {@see ApiGatewayServiceClient::getGatewayAsync()} . + * + * @param GetGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Gateway + * + * @throws ApiException Thrown if the API call fails. + */ + public function getGateway(GetGatewayRequest $request, array $callOptions = []): Gateway + { + return $this->startApiCall('GetGateway', $request, $callOptions)->wait(); + } + + /** + * Lists ApiConfigs in a given project and location. + * + * The async variant is {@see ApiGatewayServiceClient::listApiConfigsAsync()} . + * + * @param ListApiConfigsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listApiConfigs(ListApiConfigsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListApiConfigs', $request, $callOptions); + } + + /** + * Lists Apis in a given project and location. + * + * The async variant is {@see ApiGatewayServiceClient::listApisAsync()} . + * + * @param ListApisRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listApis(ListApisRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListApis', $request, $callOptions); + } + + /** + * Lists Gateways in a given project and location. + * + * The async variant is {@see ApiGatewayServiceClient::listGatewaysAsync()} . + * + * @param ListGatewaysRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listGateways(ListGatewaysRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListGateways', $request, $callOptions); + } + + /** + * Updates the parameters of a single Api. + * + * The async variant is {@see ApiGatewayServiceClient::updateApiAsync()} . + * + * @param UpdateApiRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateApi(UpdateApiRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateApi', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single ApiConfig. + * + * The async variant is {@see ApiGatewayServiceClient::updateApiConfigAsync()} . + * + * @param UpdateApiConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateApiConfig(UpdateApiConfigRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateApiConfig', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single Gateway. + * + * The async variant is {@see ApiGatewayServiceClient::updateGatewayAsync()} . + * + * @param UpdateGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateGateway(UpdateGatewayRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateGateway', $request, $callOptions)->wait(); + } } diff --git a/ApiGateway/src/V1/Client/BaseClient/ApiGatewayServiceBaseClient.php b/ApiGateway/src/V1/Client/BaseClient/ApiGatewayServiceBaseClient.php deleted file mode 100644 index 4b18ee9091e3..000000000000 --- a/ApiGateway/src/V1/Client/BaseClient/ApiGatewayServiceBaseClient.php +++ /dev/null @@ -1,748 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/api_gateway_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/api_gateway_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/api_gateway_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/api_gateway_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a api - * resource. - * - * @param string $project - * @param string $api - * - * @return string The formatted api resource. - */ - public static function apiName(string $project, string $api): string - { - return self::getPathTemplate('api')->render([ - 'project' => $project, - 'api' => $api, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a api_config - * resource. - * - * @param string $project - * @param string $api - * @param string $apiConfig - * - * @return string The formatted api_config resource. - */ - public static function apiConfigName(string $project, string $api, string $apiConfig): string - { - return self::getPathTemplate('apiConfig')->render([ - 'project' => $project, - 'api' => $api, - 'api_config' => $apiConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a gateway - * resource. - * - * @param string $project - * @param string $location - * @param string $gateway - * - * @return string The formatted gateway resource. - */ - public static function gatewayName(string $project, string $location, string $gateway): string - { - return self::getPathTemplate('gateway')->render([ - 'project' => $project, - 'location' => $location, - 'gateway' => $gateway, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * managed_service resource. - * - * @param string $service - * - * @return string The formatted managed_service resource. - */ - public static function managedServiceName(string $service): string - { - return self::getPathTemplate('managedService')->render([ - 'service' => $service, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a service - * resource. - * - * @param string $service - * @param string $config - * - * @return string The formatted service resource. - */ - public static function serviceName(string $service, string $config): string - { - return self::getPathTemplate('service')->render([ - 'service' => $service, - 'config' => $config, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * service_account resource. - * - * @param string $project - * @param string $serviceAccount - * - * @return string The formatted service_account resource. - */ - public static function serviceAccountName(string $project, string $serviceAccount): string - { - return self::getPathTemplate('serviceAccount')->render([ - 'project' => $project, - 'service_account' => $serviceAccount, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - api: projects/{project}/locations/global/apis/{api} - * - apiConfig: projects/{project}/locations/global/apis/{api}/configs/{api_config} - * - gateway: projects/{project}/locations/{location}/gateways/{gateway} - * - location: projects/{project}/locations/{location} - * - managedService: services/{service} - * - service: services/{service}/configs/{config} - * - serviceAccount: projects/{project}/serviceAccounts/{service_account} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'apigateway.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new Api in a given project and location. - * - * The async variant is {@see self::createApiAsync()} . - * - * @param CreateApiRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createApi(CreateApiRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateApi', $request, $callOptions)->wait(); - } - - /** - * Creates a new ApiConfig in a given project and location. - * - * The async variant is {@see self::createApiConfigAsync()} . - * - * @param CreateApiConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createApiConfig(CreateApiConfigRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateApiConfig', $request, $callOptions)->wait(); - } - - /** - * Creates a new Gateway in a given project and location. - * - * The async variant is {@see self::createGatewayAsync()} . - * - * @param CreateGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createGateway(CreateGatewayRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateGateway', $request, $callOptions)->wait(); - } - - /** - * Deletes a single Api. - * - * The async variant is {@see self::deleteApiAsync()} . - * - * @param DeleteApiRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteApi(DeleteApiRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteApi', $request, $callOptions)->wait(); - } - - /** - * Deletes a single ApiConfig. - * - * The async variant is {@see self::deleteApiConfigAsync()} . - * - * @param DeleteApiConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteApiConfig(DeleteApiConfigRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteApiConfig', $request, $callOptions)->wait(); - } - - /** - * Deletes a single Gateway. - * - * The async variant is {@see self::deleteGatewayAsync()} . - * - * @param DeleteGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteGateway(DeleteGatewayRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteGateway', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single Api. - * - * The async variant is {@see self::getApiAsync()} . - * - * @param GetApiRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Api - * - * @throws ApiException Thrown if the API call fails. - */ - public function getApi(GetApiRequest $request, array $callOptions = []): Api - { - return $this->startApiCall('GetApi', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single ApiConfig. - * - * The async variant is {@see self::getApiConfigAsync()} . - * - * @param GetApiConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ApiConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getApiConfig(GetApiConfigRequest $request, array $callOptions = []): ApiConfig - { - return $this->startApiCall('GetApiConfig', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single Gateway. - * - * The async variant is {@see self::getGatewayAsync()} . - * - * @param GetGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Gateway - * - * @throws ApiException Thrown if the API call fails. - */ - public function getGateway(GetGatewayRequest $request, array $callOptions = []): Gateway - { - return $this->startApiCall('GetGateway', $request, $callOptions)->wait(); - } - - /** - * Lists ApiConfigs in a given project and location. - * - * The async variant is {@see self::listApiConfigsAsync()} . - * - * @param ListApiConfigsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listApiConfigs(ListApiConfigsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListApiConfigs', $request, $callOptions); - } - - /** - * Lists Apis in a given project and location. - * - * The async variant is {@see self::listApisAsync()} . - * - * @param ListApisRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listApis(ListApisRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListApis', $request, $callOptions); - } - - /** - * Lists Gateways in a given project and location. - * - * The async variant is {@see self::listGatewaysAsync()} . - * - * @param ListGatewaysRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listGateways(ListGatewaysRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListGateways', $request, $callOptions); - } - - /** - * Updates the parameters of a single Api. - * - * The async variant is {@see self::updateApiAsync()} . - * - * @param UpdateApiRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateApi(UpdateApiRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateApi', $request, $callOptions)->wait(); - } - - /** - * Updates the parameters of a single ApiConfig. - * - * The async variant is {@see self::updateApiConfigAsync()} . - * - * @param UpdateApiConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateApiConfig(UpdateApiConfigRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateApiConfig', $request, $callOptions)->wait(); - } - - /** - * Updates the parameters of a single Gateway. - * - * The async variant is {@see self::updateGatewayAsync()} . - * - * @param UpdateGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateGateway(UpdateGatewayRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateGateway', $request, $callOptions)->wait(); - } -} diff --git a/ApiKeys/composer.json b/ApiKeys/composer.json index c06e1c68c275..adbdb9fa9379 100644 --- a/ApiKeys/composer.json +++ b/ApiKeys/composer.json @@ -19,7 +19,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/ApiKeys/src/V2/Client/ApiKeysClient.php b/ApiKeys/src/V2/Client/ApiKeysClient.php index e5c96b4fdf93..d5c479db7cbf 100644 --- a/ApiKeys/src/V2/Client/ApiKeysClient.php +++ b/ApiKeys/src/V2/Client/ApiKeysClient.php @@ -24,17 +24,496 @@ namespace Google\Cloud\ApiKeys\V2\Client; -use Google\Cloud\ApiKeys\V2\Client\BaseClient\ApiKeysBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\ApiKeys\V2\CreateKeyRequest; +use Google\Cloud\ApiKeys\V2\DeleteKeyRequest; +use Google\Cloud\ApiKeys\V2\GetKeyRequest; +use Google\Cloud\ApiKeys\V2\GetKeyStringRequest; +use Google\Cloud\ApiKeys\V2\GetKeyStringResponse; +use Google\Cloud\ApiKeys\V2\Key; +use Google\Cloud\ApiKeys\V2\ListKeysRequest; +use Google\Cloud\ApiKeys\V2\LookupKeyRequest; +use Google\Cloud\ApiKeys\V2\LookupKeyResponse; +use Google\Cloud\ApiKeys\V2\UndeleteKeyRequest; +use Google\Cloud\ApiKeys\V2\UpdateKeyRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Manages the API keys associated with projects. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ApiKeys\V2\ApiKeysClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createKeyAsync(CreateKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteKeyAsync(DeleteKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getKeyAsync(GetKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getKeyStringAsync(GetKeyStringRequest $request, array $optionalArgs = []) + * @method PromiseInterface listKeysAsync(ListKeysRequest $request, array $optionalArgs = []) + * @method PromiseInterface lookupKeyAsync(LookupKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface undeleteKeyAsync(UndeleteKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateKeyAsync(UpdateKeyRequest $request, array $optionalArgs = []) */ -final class ApiKeysClient extends ApiKeysBaseClient +final class ApiKeysClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ApiKeysBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.api.apikeys.v2.ApiKeys'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'apikeys.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/api_keys_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/api_keys_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/api_keys_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/api_keys_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a key + * resource. + * + * @param string $project + * @param string $location + * @param string $key + * + * @return string The formatted key resource. + */ + public static function keyName(string $project, string $location, string $key): string + { + return self::getPathTemplate('key')->render([ + 'project' => $project, + 'location' => $location, + 'key' => $key, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - key: projects/{project}/locations/{location}/keys/{key} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'apikeys.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new API key. + * + * NOTE: Key is a global resource; hence the only supported value for + * location is `global`. + * + * The async variant is {@see ApiKeysClient::createKeyAsync()} . + * + * @example samples/V2/ApiKeysClient/create_key.php + * + * @param CreateKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createKey(CreateKeyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateKey', $request, $callOptions)->wait(); + } + + /** + * Deletes an API key. Deleted key can be retrieved within 30 days of + * deletion. Afterward, key will be purged from the project. + * + * NOTE: Key is a global resource; hence the only supported value for + * location is `global`. + * + * The async variant is {@see ApiKeysClient::deleteKeyAsync()} . + * + * @example samples/V2/ApiKeysClient/delete_key.php + * + * @param DeleteKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteKey(DeleteKeyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteKey', $request, $callOptions)->wait(); + } + + /** + * Gets the metadata for an API key. The key string of the API key + * isn't included in the response. + * + * NOTE: Key is a global resource; hence the only supported value for + * location is `global`. + * + * The async variant is {@see ApiKeysClient::getKeyAsync()} . + * + * @example samples/V2/ApiKeysClient/get_key.php + * + * @param GetKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Key + * + * @throws ApiException Thrown if the API call fails. + */ + public function getKey(GetKeyRequest $request, array $callOptions = []): Key + { + return $this->startApiCall('GetKey', $request, $callOptions)->wait(); + } + + /** + * Get the key string for an API key. + * + * NOTE: Key is a global resource; hence the only supported value for + * location is `global`. + * + * The async variant is {@see ApiKeysClient::getKeyStringAsync()} . + * + * @example samples/V2/ApiKeysClient/get_key_string.php + * + * @param GetKeyStringRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GetKeyStringResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function getKeyString(GetKeyStringRequest $request, array $callOptions = []): GetKeyStringResponse + { + return $this->startApiCall('GetKeyString', $request, $callOptions)->wait(); + } + + /** + * Lists the API keys owned by a project. The key string of the API key + * isn't included in the response. + * + * NOTE: Key is a global resource; hence the only supported value for + * location is `global`. + * + * The async variant is {@see ApiKeysClient::listKeysAsync()} . + * + * @example samples/V2/ApiKeysClient/list_keys.php + * + * @param ListKeysRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listKeys(ListKeysRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListKeys', $request, $callOptions); + } + + /** + * Find the parent project and resource name of the API + * key that matches the key string in the request. If the API key has been + * purged, resource name will not be set. + * The service account must have the `apikeys.keys.lookup` permission + * on the parent project. + * + * The async variant is {@see ApiKeysClient::lookupKeyAsync()} . + * + * @example samples/V2/ApiKeysClient/lookup_key.php + * + * @param LookupKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LookupKeyResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function lookupKey(LookupKeyRequest $request, array $callOptions = []): LookupKeyResponse + { + return $this->startApiCall('LookupKey', $request, $callOptions)->wait(); + } + + /** + * Undeletes an API key which was deleted within 30 days. + * + * NOTE: Key is a global resource; hence the only supported value for + * location is `global`. + * + * The async variant is {@see ApiKeysClient::undeleteKeyAsync()} . + * + * @example samples/V2/ApiKeysClient/undelete_key.php + * + * @param UndeleteKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function undeleteKey(UndeleteKeyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UndeleteKey', $request, $callOptions)->wait(); + } + + /** + * Patches the modifiable fields of an API key. + * The key string of the API key isn't included in the response. + * + * NOTE: Key is a global resource; hence the only supported value for + * location is `global`. + * + * The async variant is {@see ApiKeysClient::updateKeyAsync()} . + * + * @example samples/V2/ApiKeysClient/update_key.php + * + * @param UpdateKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateKey(UpdateKeyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateKey', $request, $callOptions)->wait(); + } } diff --git a/ApiKeys/src/V2/Client/BaseClient/ApiKeysBaseClient.php b/ApiKeys/src/V2/Client/BaseClient/ApiKeysBaseClient.php deleted file mode 100644 index 531d6a8b5d68..000000000000 --- a/ApiKeys/src/V2/Client/BaseClient/ApiKeysBaseClient.php +++ /dev/null @@ -1,521 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/api_keys_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/api_keys_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/api_keys_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/api_keys_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a key - * resource. - * - * @param string $project - * @param string $location - * @param string $key - * - * @return string The formatted key resource. - */ - public static function keyName(string $project, string $location, string $key): string - { - return self::getPathTemplate('key')->render([ - 'project' => $project, - 'location' => $location, - 'key' => $key, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - key: projects/{project}/locations/{location}/keys/{key} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'apikeys.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new API key. - * - * NOTE: Key is a global resource; hence the only supported value for - * location is `global`. - * - * The async variant is {@see self::createKeyAsync()} . - * - * @example samples/V2/ApiKeysClient/create_key.php - * - * @param CreateKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createKey(CreateKeyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateKey', $request, $callOptions)->wait(); - } - - /** - * Deletes an API key. Deleted key can be retrieved within 30 days of - * deletion. Afterward, key will be purged from the project. - * - * NOTE: Key is a global resource; hence the only supported value for - * location is `global`. - * - * The async variant is {@see self::deleteKeyAsync()} . - * - * @example samples/V2/ApiKeysClient/delete_key.php - * - * @param DeleteKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteKey(DeleteKeyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteKey', $request, $callOptions)->wait(); - } - - /** - * Gets the metadata for an API key. The key string of the API key - * isn't included in the response. - * - * NOTE: Key is a global resource; hence the only supported value for - * location is `global`. - * - * The async variant is {@see self::getKeyAsync()} . - * - * @example samples/V2/ApiKeysClient/get_key.php - * - * @param GetKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Key - * - * @throws ApiException Thrown if the API call fails. - */ - public function getKey(GetKeyRequest $request, array $callOptions = []): Key - { - return $this->startApiCall('GetKey', $request, $callOptions)->wait(); - } - - /** - * Get the key string for an API key. - * - * NOTE: Key is a global resource; hence the only supported value for - * location is `global`. - * - * The async variant is {@see self::getKeyStringAsync()} . - * - * @example samples/V2/ApiKeysClient/get_key_string.php - * - * @param GetKeyStringRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GetKeyStringResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function getKeyString(GetKeyStringRequest $request, array $callOptions = []): GetKeyStringResponse - { - return $this->startApiCall('GetKeyString', $request, $callOptions)->wait(); - } - - /** - * Lists the API keys owned by a project. The key string of the API key - * isn't included in the response. - * - * NOTE: Key is a global resource; hence the only supported value for - * location is `global`. - * - * The async variant is {@see self::listKeysAsync()} . - * - * @example samples/V2/ApiKeysClient/list_keys.php - * - * @param ListKeysRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listKeys(ListKeysRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListKeys', $request, $callOptions); - } - - /** - * Find the parent project and resource name of the API - * key that matches the key string in the request. If the API key has been - * purged, resource name will not be set. - * The service account must have the `apikeys.keys.lookup` permission - * on the parent project. - * - * The async variant is {@see self::lookupKeyAsync()} . - * - * @example samples/V2/ApiKeysClient/lookup_key.php - * - * @param LookupKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LookupKeyResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function lookupKey(LookupKeyRequest $request, array $callOptions = []): LookupKeyResponse - { - return $this->startApiCall('LookupKey', $request, $callOptions)->wait(); - } - - /** - * Undeletes an API key which was deleted within 30 days. - * - * NOTE: Key is a global resource; hence the only supported value for - * location is `global`. - * - * The async variant is {@see self::undeleteKeyAsync()} . - * - * @example samples/V2/ApiKeysClient/undelete_key.php - * - * @param UndeleteKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function undeleteKey(UndeleteKeyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UndeleteKey', $request, $callOptions)->wait(); - } - - /** - * Patches the modifiable fields of an API key. - * The key string of the API key isn't included in the response. - * - * NOTE: Key is a global resource; hence the only supported value for - * location is `global`. - * - * The async variant is {@see self::updateKeyAsync()} . - * - * @example samples/V2/ApiKeysClient/update_key.php - * - * @param UpdateKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateKey(UpdateKeyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateKey', $request, $callOptions)->wait(); - } -} diff --git a/ApigeeConnect/composer.json b/ApigeeConnect/composer.json index eed87b02ff82..3c2804d07514 100644 --- a/ApigeeConnect/composer.json +++ b/ApigeeConnect/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/ApigeeConnect/src/V1/Client/BaseClient/ConnectionServiceBaseClient.php b/ApigeeConnect/src/V1/Client/BaseClient/ConnectionServiceBaseClient.php deleted file mode 100644 index 68f72c0ab0c9..000000000000 --- a/ApigeeConnect/src/V1/Client/BaseClient/ConnectionServiceBaseClient.php +++ /dev/null @@ -1,237 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/connection_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/connection_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/connection_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/connection_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a endpoint - * resource. - * - * @param string $project - * @param string $endpoint - * - * @return string The formatted endpoint resource. - */ - public static function endpointName(string $project, string $endpoint): string - { - return self::getPathTemplate('endpoint')->render([ - 'project' => $project, - 'endpoint' => $endpoint, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - endpoint: projects/{project}/endpoints/{endpoint} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'apigeeconnect.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Lists connections that are currently active for the given Apigee Connect - * endpoint. - * - * The async variant is {@see self::listConnectionsAsync()} . - * - * @param ListConnectionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listConnections(ListConnectionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListConnections', $request, $callOptions); - } -} diff --git a/ApigeeConnect/src/V1/Client/BaseClient/TetherBaseClient.php b/ApigeeConnect/src/V1/Client/BaseClient/TetherBaseClient.php deleted file mode 100644 index d30c41e12bb7..000000000000 --- a/ApigeeConnect/src/V1/Client/BaseClient/TetherBaseClient.php +++ /dev/null @@ -1,174 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/tether_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/tether_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/tether_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/tether_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'apigeeconnect.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** - * Egress streams egress requests and responses. Logically, this is not - * actually a streaming request, but uses streaming as a mechanism to flip - * the client-server relationship of gRPC so that the server can act as a - * client. - * The listener, the RPC server, accepts connections from the dialer, - * the RPC client. - * The listener streams http requests and the dialer streams http responses. - * - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return BidiStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function egress(array $callOptions = []): BidiStream - { - return $this->startApiCall('Egress', null, $callOptions); - } -} diff --git a/ApigeeConnect/src/V1/Client/ConnectionServiceClient.php b/ApigeeConnect/src/V1/Client/ConnectionServiceClient.php index 9bcd0f6e9125..ced8834cef50 100644 --- a/ApigeeConnect/src/V1/Client/ConnectionServiceClient.php +++ b/ApigeeConnect/src/V1/Client/ConnectionServiceClient.php @@ -24,17 +24,212 @@ namespace Google\Cloud\ApigeeConnect\V1\Client; -use Google\Cloud\ApigeeConnect\V1\Client\BaseClient\ConnectionServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\ApigeeConnect\V1\ListConnectionsRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service Interface for the Apigee Connect connection management APIs. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ApigeeConnect\V1\ConnectionServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface listConnectionsAsync(ListConnectionsRequest $request, array $optionalArgs = []) */ -final class ConnectionServiceClient extends ConnectionServiceBaseClient +final class ConnectionServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ConnectionServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.apigeeconnect.v1.ConnectionService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'apigeeconnect.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/connection_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/connection_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/connection_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/connection_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a endpoint + * resource. + * + * @param string $project + * @param string $endpoint + * + * @return string The formatted endpoint resource. + */ + public static function endpointName(string $project, string $endpoint): string + { + return self::getPathTemplate('endpoint')->render([ + 'project' => $project, + 'endpoint' => $endpoint, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - endpoint: projects/{project}/endpoints/{endpoint} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'apigeeconnect.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Lists connections that are currently active for the given Apigee Connect + * endpoint. + * + * The async variant is {@see ConnectionServiceClient::listConnectionsAsync()} . + * + * @param ListConnectionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listConnections(ListConnectionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListConnections', $request, $callOptions); + } } diff --git a/ApigeeConnect/src/V1/Client/TetherClient.php b/ApigeeConnect/src/V1/Client/TetherClient.php index 242ae8dc2ffd..9eccfc693756 100644 --- a/ApigeeConnect/src/V1/Client/TetherClient.php +++ b/ApigeeConnect/src/V1/Client/TetherClient.php @@ -24,17 +24,149 @@ namespace Google\Cloud\ApigeeConnect\V1\Client; -use Google\Cloud\ApigeeConnect\V1\Client\BaseClient\TetherBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\BidiStream; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; /** - * {@inheritdoc} + * Service Description: Tether provides a way for the control plane to send HTTP API requests to + * services in data planes that runs in a remote datacenter without + * requiring customers to open firewalls on their runtime plane. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ApigeeConnect\V1\TetherClient} for the stable implementation * * @experimental */ -final class TetherClient extends TetherBaseClient +final class TetherClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TetherBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.apigeeconnect.v1.Tether'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'apigeeconnect.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/tether_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/tether_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/tether_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/tether_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'apigeeconnect.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** + * Egress streams egress requests and responses. Logically, this is not + * actually a streaming request, but uses streaming as a mechanism to flip + * the client-server relationship of gRPC so that the server can act as a + * client. + * The listener, the RPC server, accepts connections from the dialer, + * the RPC client. + * The listener streams http requests and the dialer streams http responses. + * + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return BidiStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function egress(array $callOptions = []): BidiStream + { + return $this->startApiCall('Egress', null, $callOptions); + } } diff --git a/ApigeeRegistry/composer.json b/ApigeeRegistry/composer.json index f6d60a818a4e..d7a11599bd3d 100644 --- a/ApigeeRegistry/composer.json +++ b/ApigeeRegistry/composer.json @@ -19,7 +19,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/ApigeeRegistry/src/V1/Client/BaseClient/ProvisioningBaseClient.php b/ApigeeRegistry/src/V1/Client/BaseClient/ProvisioningBaseClient.php deleted file mode 100644 index ff95e273b4f4..000000000000 --- a/ApigeeRegistry/src/V1/Client/BaseClient/ProvisioningBaseClient.php +++ /dev/null @@ -1,505 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/provisioning_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/provisioning_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/provisioning_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/provisioning_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a instance - * resource. - * - * @param string $project - * @param string $location - * @param string $instance - * - * @return string The formatted instance resource. - */ - public static function instanceName(string $project, string $location, string $instance): string - { - return self::getPathTemplate('instance')->render([ - 'project' => $project, - 'location' => $location, - 'instance' => $instance, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - instance: projects/{project}/locations/{location}/instances/{instance} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'apigeeregistry.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Provisions instance resources for the Registry. - * - * The async variant is {@see self::createInstanceAsync()} . - * - * @example samples/V1/ProvisioningClient/create_instance.php - * - * @param CreateInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createInstance(CreateInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateInstance', $request, $callOptions)->wait(); - } - - /** - * Deletes the Registry instance. - * - * The async variant is {@see self::deleteInstanceAsync()} . - * - * @example samples/V1/ProvisioningClient/delete_instance.php - * - * @param DeleteInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single Instance. - * - * The async variant is {@see self::getInstanceAsync()} . - * - * @example samples/V1/ProvisioningClient/get_instance.php - * - * @param GetInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Instance - * - * @throws ApiException Thrown if the API call fails. - */ - public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance - { - return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/ProvisioningClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/ProvisioningClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/ProvisioningClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/ProvisioningClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/ProvisioningClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/ApigeeRegistry/src/V1/Client/BaseClient/RegistryBaseClient.php b/ApigeeRegistry/src/V1/Client/BaseClient/RegistryBaseClient.php deleted file mode 100644 index b563068c8d85..000000000000 --- a/ApigeeRegistry/src/V1/Client/BaseClient/RegistryBaseClient.php +++ /dev/null @@ -1,1578 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/registry_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/registry_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/registry_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/registry_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a api - * resource. - * - * @param string $project - * @param string $location - * @param string $api - * - * @return string The formatted api resource. - */ - public static function apiName(string $project, string $location, string $api): string - { - return self::getPathTemplate('api')->render([ - 'project' => $project, - 'location' => $location, - 'api' => $api, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * api_deployment resource. - * - * @param string $project - * @param string $location - * @param string $api - * @param string $deployment - * - * @return string The formatted api_deployment resource. - */ - public static function apiDeploymentName(string $project, string $location, string $api, string $deployment): string - { - return self::getPathTemplate('apiDeployment')->render([ - 'project' => $project, - 'location' => $location, - 'api' => $api, - 'deployment' => $deployment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a api_spec - * resource. - * - * @param string $project - * @param string $location - * @param string $api - * @param string $version - * @param string $spec - * - * @return string The formatted api_spec resource. - */ - public static function apiSpecName(string $project, string $location, string $api, string $version, string $spec): string - { - return self::getPathTemplate('apiSpec')->render([ - 'project' => $project, - 'location' => $location, - 'api' => $api, - 'version' => $version, - 'spec' => $spec, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a api_version - * resource. - * - * @param string $project - * @param string $location - * @param string $api - * @param string $version - * - * @return string The formatted api_version resource. - */ - public static function apiVersionName(string $project, string $location, string $api, string $version): string - { - return self::getPathTemplate('apiVersion')->render([ - 'project' => $project, - 'location' => $location, - 'api' => $api, - 'version' => $version, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a artifact - * resource. - * - * @param string $project - * @param string $location - * @param string $artifact - * - * @return string The formatted artifact resource. - */ - public static function artifactName(string $project, string $location, string $artifact): string - { - return self::getPathTemplate('artifact')->render([ - 'project' => $project, - 'location' => $location, - 'artifact' => $artifact, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_api_artifact resource. - * - * @param string $project - * @param string $location - * @param string $api - * @param string $artifact - * - * @return string The formatted project_location_api_artifact resource. - */ - public static function projectLocationApiArtifactName(string $project, string $location, string $api, string $artifact): string - { - return self::getPathTemplate('projectLocationApiArtifact')->render([ - 'project' => $project, - 'location' => $location, - 'api' => $api, - 'artifact' => $artifact, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_api_deployment_artifact resource. - * - * @param string $project - * @param string $location - * @param string $api - * @param string $deployment - * @param string $artifact - * - * @return string The formatted project_location_api_deployment_artifact resource. - */ - public static function projectLocationApiDeploymentArtifactName(string $project, string $location, string $api, string $deployment, string $artifact): string - { - return self::getPathTemplate('projectLocationApiDeploymentArtifact')->render([ - 'project' => $project, - 'location' => $location, - 'api' => $api, - 'deployment' => $deployment, - 'artifact' => $artifact, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_api_version_artifact resource. - * - * @param string $project - * @param string $location - * @param string $api - * @param string $version - * @param string $artifact - * - * @return string The formatted project_location_api_version_artifact resource. - */ - public static function projectLocationApiVersionArtifactName(string $project, string $location, string $api, string $version, string $artifact): string - { - return self::getPathTemplate('projectLocationApiVersionArtifact')->render([ - 'project' => $project, - 'location' => $location, - 'api' => $api, - 'version' => $version, - 'artifact' => $artifact, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_api_version_spec_artifact resource. - * - * @param string $project - * @param string $location - * @param string $api - * @param string $version - * @param string $spec - * @param string $artifact - * - * @return string The formatted project_location_api_version_spec_artifact resource. - */ - public static function projectLocationApiVersionSpecArtifactName(string $project, string $location, string $api, string $version, string $spec, string $artifact): string - { - return self::getPathTemplate('projectLocationApiVersionSpecArtifact')->render([ - 'project' => $project, - 'location' => $location, - 'api' => $api, - 'version' => $version, - 'spec' => $spec, - 'artifact' => $artifact, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_artifact resource. - * - * @param string $project - * @param string $location - * @param string $artifact - * - * @return string The formatted project_location_artifact resource. - */ - public static function projectLocationArtifactName(string $project, string $location, string $artifact): string - { - return self::getPathTemplate('projectLocationArtifact')->render([ - 'project' => $project, - 'location' => $location, - 'artifact' => $artifact, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - api: projects/{project}/locations/{location}/apis/{api} - * - apiDeployment: projects/{project}/locations/{location}/apis/{api}/deployments/{deployment} - * - apiSpec: projects/{project}/locations/{location}/apis/{api}/versions/{version}/specs/{spec} - * - apiVersion: projects/{project}/locations/{location}/apis/{api}/versions/{version} - * - artifact: projects/{project}/locations/{location}/artifacts/{artifact} - * - location: projects/{project}/locations/{location} - * - projectLocationApiArtifact: projects/{project}/locations/{location}/apis/{api}/artifacts/{artifact} - * - projectLocationApiDeploymentArtifact: projects/{project}/locations/{location}/apis/{api}/deployments/{deployment}/artifacts/{artifact} - * - projectLocationApiVersionArtifact: projects/{project}/locations/{location}/apis/{api}/versions/{version}/artifacts/{artifact} - * - projectLocationApiVersionSpecArtifact: projects/{project}/locations/{location}/apis/{api}/versions/{version}/specs/{spec}/artifacts/{artifact} - * - projectLocationArtifact: projects/{project}/locations/{location}/artifacts/{artifact} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'apigeeregistry.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a specified API. - * - * The async variant is {@see self::createApiAsync()} . - * - * @example samples/V1/RegistryClient/create_api.php - * - * @param CreateApiRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Api - * - * @throws ApiException Thrown if the API call fails. - */ - public function createApi(CreateApiRequest $request, array $callOptions = []): Api - { - return $this->startApiCall('CreateApi', $request, $callOptions)->wait(); - } - - /** - * Creates a specified deployment. - * - * The async variant is {@see self::createApiDeploymentAsync()} . - * - * @example samples/V1/RegistryClient/create_api_deployment.php - * - * @param CreateApiDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ApiDeployment - * - * @throws ApiException Thrown if the API call fails. - */ - public function createApiDeployment(CreateApiDeploymentRequest $request, array $callOptions = []): ApiDeployment - { - return $this->startApiCall('CreateApiDeployment', $request, $callOptions)->wait(); - } - - /** - * Creates a specified spec. - * - * The async variant is {@see self::createApiSpecAsync()} . - * - * @example samples/V1/RegistryClient/create_api_spec.php - * - * @param CreateApiSpecRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ApiSpec - * - * @throws ApiException Thrown if the API call fails. - */ - public function createApiSpec(CreateApiSpecRequest $request, array $callOptions = []): ApiSpec - { - return $this->startApiCall('CreateApiSpec', $request, $callOptions)->wait(); - } - - /** - * Creates a specified version. - * - * The async variant is {@see self::createApiVersionAsync()} . - * - * @example samples/V1/RegistryClient/create_api_version.php - * - * @param CreateApiVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ApiVersion - * - * @throws ApiException Thrown if the API call fails. - */ - public function createApiVersion(CreateApiVersionRequest $request, array $callOptions = []): ApiVersion - { - return $this->startApiCall('CreateApiVersion', $request, $callOptions)->wait(); - } - - /** - * Creates a specified artifact. - * - * The async variant is {@see self::createArtifactAsync()} . - * - * @example samples/V1/RegistryClient/create_artifact.php - * - * @param CreateArtifactRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Artifact - * - * @throws ApiException Thrown if the API call fails. - */ - public function createArtifact(CreateArtifactRequest $request, array $callOptions = []): Artifact - { - return $this->startApiCall('CreateArtifact', $request, $callOptions)->wait(); - } - - /** - * Removes a specified API and all of the resources that it - * owns. - * - * The async variant is {@see self::deleteApiAsync()} . - * - * @example samples/V1/RegistryClient/delete_api.php - * - * @param DeleteApiRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteApi(DeleteApiRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteApi', $request, $callOptions)->wait(); - } - - /** - * Removes a specified deployment, all revisions, and all - * child resources (e.g., artifacts). - * - * The async variant is {@see self::deleteApiDeploymentAsync()} . - * - * @example samples/V1/RegistryClient/delete_api_deployment.php - * - * @param DeleteApiDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteApiDeployment(DeleteApiDeploymentRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteApiDeployment', $request, $callOptions)->wait(); - } - - /** - * Deletes a revision of a deployment. - * - * The async variant is {@see self::deleteApiDeploymentRevisionAsync()} . - * - * @example samples/V1/RegistryClient/delete_api_deployment_revision.php - * - * @param DeleteApiDeploymentRevisionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ApiDeployment - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteApiDeploymentRevision(DeleteApiDeploymentRevisionRequest $request, array $callOptions = []): ApiDeployment - { - return $this->startApiCall('DeleteApiDeploymentRevision', $request, $callOptions)->wait(); - } - - /** - * Removes a specified spec, all revisions, and all child - * resources (e.g., artifacts). - * - * The async variant is {@see self::deleteApiSpecAsync()} . - * - * @example samples/V1/RegistryClient/delete_api_spec.php - * - * @param DeleteApiSpecRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteApiSpec(DeleteApiSpecRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteApiSpec', $request, $callOptions)->wait(); - } - - /** - * Deletes a revision of a spec. - * - * The async variant is {@see self::deleteApiSpecRevisionAsync()} . - * - * @example samples/V1/RegistryClient/delete_api_spec_revision.php - * - * @param DeleteApiSpecRevisionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ApiSpec - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteApiSpecRevision(DeleteApiSpecRevisionRequest $request, array $callOptions = []): ApiSpec - { - return $this->startApiCall('DeleteApiSpecRevision', $request, $callOptions)->wait(); - } - - /** - * Removes a specified version and all of the resources that - * it owns. - * - * The async variant is {@see self::deleteApiVersionAsync()} . - * - * @example samples/V1/RegistryClient/delete_api_version.php - * - * @param DeleteApiVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteApiVersion(DeleteApiVersionRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteApiVersion', $request, $callOptions)->wait(); - } - - /** - * Removes a specified artifact. - * - * The async variant is {@see self::deleteArtifactAsync()} . - * - * @example samples/V1/RegistryClient/delete_artifact.php - * - * @param DeleteArtifactRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteArtifact(DeleteArtifactRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteArtifact', $request, $callOptions)->wait(); - } - - /** - * Returns a specified API. - * - * The async variant is {@see self::getApiAsync()} . - * - * @example samples/V1/RegistryClient/get_api.php - * - * @param GetApiRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Api - * - * @throws ApiException Thrown if the API call fails. - */ - public function getApi(GetApiRequest $request, array $callOptions = []): Api - { - return $this->startApiCall('GetApi', $request, $callOptions)->wait(); - } - - /** - * Returns a specified deployment. - * - * The async variant is {@see self::getApiDeploymentAsync()} . - * - * @example samples/V1/RegistryClient/get_api_deployment.php - * - * @param GetApiDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ApiDeployment - * - * @throws ApiException Thrown if the API call fails. - */ - public function getApiDeployment(GetApiDeploymentRequest $request, array $callOptions = []): ApiDeployment - { - return $this->startApiCall('GetApiDeployment', $request, $callOptions)->wait(); - } - - /** - * Returns a specified spec. - * - * The async variant is {@see self::getApiSpecAsync()} . - * - * @example samples/V1/RegistryClient/get_api_spec.php - * - * @param GetApiSpecRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ApiSpec - * - * @throws ApiException Thrown if the API call fails. - */ - public function getApiSpec(GetApiSpecRequest $request, array $callOptions = []): ApiSpec - { - return $this->startApiCall('GetApiSpec', $request, $callOptions)->wait(); - } - - /** - * Returns the contents of a specified spec. - * If specs are stored with GZip compression, the default behavior - * is to return the spec uncompressed (the mime_type response field - * indicates the exact format returned). - * - * The async variant is {@see self::getApiSpecContentsAsync()} . - * - * @example samples/V1/RegistryClient/get_api_spec_contents.php - * - * @param GetApiSpecContentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 HttpBody - * - * @throws ApiException Thrown if the API call fails. - */ - public function getApiSpecContents(GetApiSpecContentsRequest $request, array $callOptions = []): HttpBody - { - return $this->startApiCall('GetApiSpecContents', $request, $callOptions)->wait(); - } - - /** - * Returns a specified version. - * - * The async variant is {@see self::getApiVersionAsync()} . - * - * @example samples/V1/RegistryClient/get_api_version.php - * - * @param GetApiVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ApiVersion - * - * @throws ApiException Thrown if the API call fails. - */ - public function getApiVersion(GetApiVersionRequest $request, array $callOptions = []): ApiVersion - { - return $this->startApiCall('GetApiVersion', $request, $callOptions)->wait(); - } - - /** - * Returns a specified artifact. - * - * The async variant is {@see self::getArtifactAsync()} . - * - * @example samples/V1/RegistryClient/get_artifact.php - * - * @param GetArtifactRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Artifact - * - * @throws ApiException Thrown if the API call fails. - */ - public function getArtifact(GetArtifactRequest $request, array $callOptions = []): Artifact - { - return $this->startApiCall('GetArtifact', $request, $callOptions)->wait(); - } - - /** - * Returns the contents of a specified artifact. - * If artifacts are stored with GZip compression, the default behavior - * is to return the artifact uncompressed (the mime_type response field - * indicates the exact format returned). - * - * The async variant is {@see self::getArtifactContentsAsync()} . - * - * @example samples/V1/RegistryClient/get_artifact_contents.php - * - * @param GetArtifactContentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 HttpBody - * - * @throws ApiException Thrown if the API call fails. - */ - public function getArtifactContents(GetArtifactContentsRequest $request, array $callOptions = []): HttpBody - { - return $this->startApiCall('GetArtifactContents', $request, $callOptions)->wait(); - } - - /** - * Lists all revisions of a deployment. - * Revisions are returned in descending order of revision creation time. - * - * The async variant is {@see self::listApiDeploymentRevisionsAsync()} . - * - * @example samples/V1/RegistryClient/list_api_deployment_revisions.php - * - * @param ListApiDeploymentRevisionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listApiDeploymentRevisions(ListApiDeploymentRevisionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListApiDeploymentRevisions', $request, $callOptions); - } - - /** - * Returns matching deployments. - * - * The async variant is {@see self::listApiDeploymentsAsync()} . - * - * @example samples/V1/RegistryClient/list_api_deployments.php - * - * @param ListApiDeploymentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listApiDeployments(ListApiDeploymentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListApiDeployments', $request, $callOptions); - } - - /** - * Lists all revisions of a spec. - * Revisions are returned in descending order of revision creation time. - * - * The async variant is {@see self::listApiSpecRevisionsAsync()} . - * - * @example samples/V1/RegistryClient/list_api_spec_revisions.php - * - * @param ListApiSpecRevisionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listApiSpecRevisions(ListApiSpecRevisionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListApiSpecRevisions', $request, $callOptions); - } - - /** - * Returns matching specs. - * - * The async variant is {@see self::listApiSpecsAsync()} . - * - * @example samples/V1/RegistryClient/list_api_specs.php - * - * @param ListApiSpecsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listApiSpecs(ListApiSpecsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListApiSpecs', $request, $callOptions); - } - - /** - * Returns matching versions. - * - * The async variant is {@see self::listApiVersionsAsync()} . - * - * @example samples/V1/RegistryClient/list_api_versions.php - * - * @param ListApiVersionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listApiVersions(ListApiVersionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListApiVersions', $request, $callOptions); - } - - /** - * Returns matching APIs. - * - * The async variant is {@see self::listApisAsync()} . - * - * @example samples/V1/RegistryClient/list_apis.php - * - * @param ListApisRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listApis(ListApisRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListApis', $request, $callOptions); - } - - /** - * Returns matching artifacts. - * - * The async variant is {@see self::listArtifactsAsync()} . - * - * @example samples/V1/RegistryClient/list_artifacts.php - * - * @param ListArtifactsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listArtifacts(ListArtifactsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListArtifacts', $request, $callOptions); - } - - /** - * Used to replace a specified artifact. - * - * The async variant is {@see self::replaceArtifactAsync()} . - * - * @example samples/V1/RegistryClient/replace_artifact.php - * - * @param ReplaceArtifactRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Artifact - * - * @throws ApiException Thrown if the API call fails. - */ - public function replaceArtifact(ReplaceArtifactRequest $request, array $callOptions = []): Artifact - { - return $this->startApiCall('ReplaceArtifact', $request, $callOptions)->wait(); - } - - /** - * Sets the current revision to a specified prior - * revision. Note that this creates a new revision with a new revision ID. - * - * The async variant is {@see self::rollbackApiDeploymentAsync()} . - * - * @example samples/V1/RegistryClient/rollback_api_deployment.php - * - * @param RollbackApiDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ApiDeployment - * - * @throws ApiException Thrown if the API call fails. - */ - public function rollbackApiDeployment(RollbackApiDeploymentRequest $request, array $callOptions = []): ApiDeployment - { - return $this->startApiCall('RollbackApiDeployment', $request, $callOptions)->wait(); - } - - /** - * Sets the current revision to a specified prior revision. - * Note that this creates a new revision with a new revision ID. - * - * The async variant is {@see self::rollbackApiSpecAsync()} . - * - * @example samples/V1/RegistryClient/rollback_api_spec.php - * - * @param RollbackApiSpecRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ApiSpec - * - * @throws ApiException Thrown if the API call fails. - */ - public function rollbackApiSpec(RollbackApiSpecRequest $request, array $callOptions = []): ApiSpec - { - return $this->startApiCall('RollbackApiSpec', $request, $callOptions)->wait(); - } - - /** - * Adds a tag to a specified revision of a - * deployment. - * - * The async variant is {@see self::tagApiDeploymentRevisionAsync()} . - * - * @example samples/V1/RegistryClient/tag_api_deployment_revision.php - * - * @param TagApiDeploymentRevisionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ApiDeployment - * - * @throws ApiException Thrown if the API call fails. - */ - public function tagApiDeploymentRevision(TagApiDeploymentRevisionRequest $request, array $callOptions = []): ApiDeployment - { - return $this->startApiCall('TagApiDeploymentRevision', $request, $callOptions)->wait(); - } - - /** - * Adds a tag to a specified revision of a spec. - * - * The async variant is {@see self::tagApiSpecRevisionAsync()} . - * - * @example samples/V1/RegistryClient/tag_api_spec_revision.php - * - * @param TagApiSpecRevisionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ApiSpec - * - * @throws ApiException Thrown if the API call fails. - */ - public function tagApiSpecRevision(TagApiSpecRevisionRequest $request, array $callOptions = []): ApiSpec - { - return $this->startApiCall('TagApiSpecRevision', $request, $callOptions)->wait(); - } - - /** - * Used to modify a specified API. - * - * The async variant is {@see self::updateApiAsync()} . - * - * @example samples/V1/RegistryClient/update_api.php - * - * @param UpdateApiRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Api - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateApi(UpdateApiRequest $request, array $callOptions = []): Api - { - return $this->startApiCall('UpdateApi', $request, $callOptions)->wait(); - } - - /** - * Used to modify a specified deployment. - * - * The async variant is {@see self::updateApiDeploymentAsync()} . - * - * @example samples/V1/RegistryClient/update_api_deployment.php - * - * @param UpdateApiDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ApiDeployment - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateApiDeployment(UpdateApiDeploymentRequest $request, array $callOptions = []): ApiDeployment - { - return $this->startApiCall('UpdateApiDeployment', $request, $callOptions)->wait(); - } - - /** - * Used to modify a specified spec. - * - * The async variant is {@see self::updateApiSpecAsync()} . - * - * @example samples/V1/RegistryClient/update_api_spec.php - * - * @param UpdateApiSpecRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ApiSpec - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateApiSpec(UpdateApiSpecRequest $request, array $callOptions = []): ApiSpec - { - return $this->startApiCall('UpdateApiSpec', $request, $callOptions)->wait(); - } - - /** - * Used to modify a specified version. - * - * The async variant is {@see self::updateApiVersionAsync()} . - * - * @example samples/V1/RegistryClient/update_api_version.php - * - * @param UpdateApiVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ApiVersion - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateApiVersion(UpdateApiVersionRequest $request, array $callOptions = []): ApiVersion - { - return $this->startApiCall('UpdateApiVersion', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/RegistryClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/RegistryClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/RegistryClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/RegistryClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/RegistryClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/ApigeeRegistry/src/V1/Client/ProvisioningClient.php b/ApigeeRegistry/src/V1/Client/ProvisioningClient.php index 55602827834e..0febac612bb2 100644 --- a/ApigeeRegistry/src/V1/Client/ProvisioningClient.php +++ b/ApigeeRegistry/src/V1/Client/ProvisioningClient.php @@ -24,17 +24,480 @@ namespace Google\Cloud\ApigeeRegistry\V1\Client; -use Google\Cloud\ApigeeRegistry\V1\Client\BaseClient\ProvisioningBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\ApigeeRegistry\V1\CreateInstanceRequest; +use Google\Cloud\ApigeeRegistry\V1\DeleteInstanceRequest; +use Google\Cloud\ApigeeRegistry\V1\GetInstanceRequest; +use Google\Cloud\ApigeeRegistry\V1\Instance; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The service that is used for managing the data plane provisioning of the + * Registry. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ApigeeRegistry\V1\ProvisioningClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createInstanceAsync(CreateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteInstanceAsync(DeleteInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInstanceAsync(GetInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class ProvisioningClient extends ProvisioningBaseClient +final class ProvisioningClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ProvisioningBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.apigeeregistry.v1.Provisioning'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'apigeeregistry.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/provisioning_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/provisioning_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/provisioning_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/provisioning_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a instance + * resource. + * + * @param string $project + * @param string $location + * @param string $instance + * + * @return string The formatted instance resource. + */ + public static function instanceName(string $project, string $location, string $instance): string + { + return self::getPathTemplate('instance')->render([ + 'project' => $project, + 'location' => $location, + 'instance' => $instance, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - instance: projects/{project}/locations/{location}/instances/{instance} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'apigeeregistry.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Provisions instance resources for the Registry. + * + * The async variant is {@see ProvisioningClient::createInstanceAsync()} . + * + * @example samples/V1/ProvisioningClient/create_instance.php + * + * @param CreateInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createInstance(CreateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateInstance', $request, $callOptions)->wait(); + } + + /** + * Deletes the Registry instance. + * + * The async variant is {@see ProvisioningClient::deleteInstanceAsync()} . + * + * @example samples/V1/ProvisioningClient/delete_instance.php + * + * @param DeleteInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Instance. + * + * The async variant is {@see ProvisioningClient::getInstanceAsync()} . + * + * @example samples/V1/ProvisioningClient/get_instance.php + * + * @param GetInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Instance + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance + { + return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see ProvisioningClient::getLocationAsync()} . + * + * @example samples/V1/ProvisioningClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see ProvisioningClient::listLocationsAsync()} . + * + * @example samples/V1/ProvisioningClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see ProvisioningClient::getIamPolicyAsync()} . + * + * @example samples/V1/ProvisioningClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see ProvisioningClient::setIamPolicyAsync()} . + * + * @example samples/V1/ProvisioningClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see ProvisioningClient::testIamPermissionsAsync()} . + * + * @example samples/V1/ProvisioningClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/ApigeeRegistry/src/V1/Client/RegistryClient.php b/ApigeeRegistry/src/V1/Client/RegistryClient.php index 1fd8f4f11832..9ca05cc86792 100644 --- a/ApigeeRegistry/src/V1/Client/RegistryClient.php +++ b/ApigeeRegistry/src/V1/Client/RegistryClient.php @@ -24,17 +24,1553 @@ namespace Google\Cloud\ApigeeRegistry\V1\Client; -use Google\Cloud\ApigeeRegistry\V1\Client\BaseClient\RegistryBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Api\HttpBody; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\ApigeeRegistry\V1\Api; +use Google\Cloud\ApigeeRegistry\V1\ApiDeployment; +use Google\Cloud\ApigeeRegistry\V1\ApiSpec; +use Google\Cloud\ApigeeRegistry\V1\ApiVersion; +use Google\Cloud\ApigeeRegistry\V1\Artifact; +use Google\Cloud\ApigeeRegistry\V1\CreateApiDeploymentRequest; +use Google\Cloud\ApigeeRegistry\V1\CreateApiRequest; +use Google\Cloud\ApigeeRegistry\V1\CreateApiSpecRequest; +use Google\Cloud\ApigeeRegistry\V1\CreateApiVersionRequest; +use Google\Cloud\ApigeeRegistry\V1\CreateArtifactRequest; +use Google\Cloud\ApigeeRegistry\V1\DeleteApiDeploymentRequest; +use Google\Cloud\ApigeeRegistry\V1\DeleteApiDeploymentRevisionRequest; +use Google\Cloud\ApigeeRegistry\V1\DeleteApiRequest; +use Google\Cloud\ApigeeRegistry\V1\DeleteApiSpecRequest; +use Google\Cloud\ApigeeRegistry\V1\DeleteApiSpecRevisionRequest; +use Google\Cloud\ApigeeRegistry\V1\DeleteApiVersionRequest; +use Google\Cloud\ApigeeRegistry\V1\DeleteArtifactRequest; +use Google\Cloud\ApigeeRegistry\V1\GetApiDeploymentRequest; +use Google\Cloud\ApigeeRegistry\V1\GetApiRequest; +use Google\Cloud\ApigeeRegistry\V1\GetApiSpecContentsRequest; +use Google\Cloud\ApigeeRegistry\V1\GetApiSpecRequest; +use Google\Cloud\ApigeeRegistry\V1\GetApiVersionRequest; +use Google\Cloud\ApigeeRegistry\V1\GetArtifactContentsRequest; +use Google\Cloud\ApigeeRegistry\V1\GetArtifactRequest; +use Google\Cloud\ApigeeRegistry\V1\ListApiDeploymentRevisionsRequest; +use Google\Cloud\ApigeeRegistry\V1\ListApiDeploymentsRequest; +use Google\Cloud\ApigeeRegistry\V1\ListApiSpecRevisionsRequest; +use Google\Cloud\ApigeeRegistry\V1\ListApiSpecsRequest; +use Google\Cloud\ApigeeRegistry\V1\ListApiVersionsRequest; +use Google\Cloud\ApigeeRegistry\V1\ListApisRequest; +use Google\Cloud\ApigeeRegistry\V1\ListArtifactsRequest; +use Google\Cloud\ApigeeRegistry\V1\ReplaceArtifactRequest; +use Google\Cloud\ApigeeRegistry\V1\RollbackApiDeploymentRequest; +use Google\Cloud\ApigeeRegistry\V1\RollbackApiSpecRequest; +use Google\Cloud\ApigeeRegistry\V1\TagApiDeploymentRevisionRequest; +use Google\Cloud\ApigeeRegistry\V1\TagApiSpecRevisionRequest; +use Google\Cloud\ApigeeRegistry\V1\UpdateApiDeploymentRequest; +use Google\Cloud\ApigeeRegistry\V1\UpdateApiRequest; +use Google\Cloud\ApigeeRegistry\V1\UpdateApiSpecRequest; +use Google\Cloud\ApigeeRegistry\V1\UpdateApiVersionRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Registry service allows teams to manage descriptions of APIs. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ApigeeRegistry\V1\RegistryClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createApiAsync(CreateApiRequest $request, array $optionalArgs = []) + * @method PromiseInterface createApiDeploymentAsync(CreateApiDeploymentRequest $request, array $optionalArgs = []) + * @method PromiseInterface createApiSpecAsync(CreateApiSpecRequest $request, array $optionalArgs = []) + * @method PromiseInterface createApiVersionAsync(CreateApiVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface createArtifactAsync(CreateArtifactRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteApiAsync(DeleteApiRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteApiDeploymentAsync(DeleteApiDeploymentRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteApiDeploymentRevisionAsync(DeleteApiDeploymentRevisionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteApiSpecAsync(DeleteApiSpecRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteApiSpecRevisionAsync(DeleteApiSpecRevisionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteApiVersionAsync(DeleteApiVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteArtifactAsync(DeleteArtifactRequest $request, array $optionalArgs = []) + * @method PromiseInterface getApiAsync(GetApiRequest $request, array $optionalArgs = []) + * @method PromiseInterface getApiDeploymentAsync(GetApiDeploymentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getApiSpecAsync(GetApiSpecRequest $request, array $optionalArgs = []) + * @method PromiseInterface getApiSpecContentsAsync(GetApiSpecContentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getApiVersionAsync(GetApiVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getArtifactAsync(GetArtifactRequest $request, array $optionalArgs = []) + * @method PromiseInterface getArtifactContentsAsync(GetArtifactContentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listApiDeploymentRevisionsAsync(ListApiDeploymentRevisionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listApiDeploymentsAsync(ListApiDeploymentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listApiSpecRevisionsAsync(ListApiSpecRevisionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listApiSpecsAsync(ListApiSpecsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listApiVersionsAsync(ListApiVersionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listApisAsync(ListApisRequest $request, array $optionalArgs = []) + * @method PromiseInterface listArtifactsAsync(ListArtifactsRequest $request, array $optionalArgs = []) + * @method PromiseInterface replaceArtifactAsync(ReplaceArtifactRequest $request, array $optionalArgs = []) + * @method PromiseInterface rollbackApiDeploymentAsync(RollbackApiDeploymentRequest $request, array $optionalArgs = []) + * @method PromiseInterface rollbackApiSpecAsync(RollbackApiSpecRequest $request, array $optionalArgs = []) + * @method PromiseInterface tagApiDeploymentRevisionAsync(TagApiDeploymentRevisionRequest $request, array $optionalArgs = []) + * @method PromiseInterface tagApiSpecRevisionAsync(TagApiSpecRevisionRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateApiAsync(UpdateApiRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateApiDeploymentAsync(UpdateApiDeploymentRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateApiSpecAsync(UpdateApiSpecRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateApiVersionAsync(UpdateApiVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class RegistryClient extends RegistryBaseClient +final class RegistryClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegistryBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.apigeeregistry.v1.Registry'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'apigeeregistry.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/registry_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/registry_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/registry_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/registry_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a api + * resource. + * + * @param string $project + * @param string $location + * @param string $api + * + * @return string The formatted api resource. + */ + public static function apiName(string $project, string $location, string $api): string + { + return self::getPathTemplate('api')->render([ + 'project' => $project, + 'location' => $location, + 'api' => $api, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * api_deployment resource. + * + * @param string $project + * @param string $location + * @param string $api + * @param string $deployment + * + * @return string The formatted api_deployment resource. + */ + public static function apiDeploymentName(string $project, string $location, string $api, string $deployment): string + { + return self::getPathTemplate('apiDeployment')->render([ + 'project' => $project, + 'location' => $location, + 'api' => $api, + 'deployment' => $deployment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a api_spec + * resource. + * + * @param string $project + * @param string $location + * @param string $api + * @param string $version + * @param string $spec + * + * @return string The formatted api_spec resource. + */ + public static function apiSpecName(string $project, string $location, string $api, string $version, string $spec): string + { + return self::getPathTemplate('apiSpec')->render([ + 'project' => $project, + 'location' => $location, + 'api' => $api, + 'version' => $version, + 'spec' => $spec, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a api_version + * resource. + * + * @param string $project + * @param string $location + * @param string $api + * @param string $version + * + * @return string The formatted api_version resource. + */ + public static function apiVersionName(string $project, string $location, string $api, string $version): string + { + return self::getPathTemplate('apiVersion')->render([ + 'project' => $project, + 'location' => $location, + 'api' => $api, + 'version' => $version, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a artifact + * resource. + * + * @param string $project + * @param string $location + * @param string $artifact + * + * @return string The formatted artifact resource. + */ + public static function artifactName(string $project, string $location, string $artifact): string + { + return self::getPathTemplate('artifact')->render([ + 'project' => $project, + 'location' => $location, + 'artifact' => $artifact, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_api_artifact resource. + * + * @param string $project + * @param string $location + * @param string $api + * @param string $artifact + * + * @return string The formatted project_location_api_artifact resource. + */ + public static function projectLocationApiArtifactName(string $project, string $location, string $api, string $artifact): string + { + return self::getPathTemplate('projectLocationApiArtifact')->render([ + 'project' => $project, + 'location' => $location, + 'api' => $api, + 'artifact' => $artifact, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_api_deployment_artifact resource. + * + * @param string $project + * @param string $location + * @param string $api + * @param string $deployment + * @param string $artifact + * + * @return string The formatted project_location_api_deployment_artifact resource. + */ + public static function projectLocationApiDeploymentArtifactName(string $project, string $location, string $api, string $deployment, string $artifact): string + { + return self::getPathTemplate('projectLocationApiDeploymentArtifact')->render([ + 'project' => $project, + 'location' => $location, + 'api' => $api, + 'deployment' => $deployment, + 'artifact' => $artifact, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_api_version_artifact resource. + * + * @param string $project + * @param string $location + * @param string $api + * @param string $version + * @param string $artifact + * + * @return string The formatted project_location_api_version_artifact resource. + */ + public static function projectLocationApiVersionArtifactName(string $project, string $location, string $api, string $version, string $artifact): string + { + return self::getPathTemplate('projectLocationApiVersionArtifact')->render([ + 'project' => $project, + 'location' => $location, + 'api' => $api, + 'version' => $version, + 'artifact' => $artifact, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_api_version_spec_artifact resource. + * + * @param string $project + * @param string $location + * @param string $api + * @param string $version + * @param string $spec + * @param string $artifact + * + * @return string The formatted project_location_api_version_spec_artifact resource. + */ + public static function projectLocationApiVersionSpecArtifactName(string $project, string $location, string $api, string $version, string $spec, string $artifact): string + { + return self::getPathTemplate('projectLocationApiVersionSpecArtifact')->render([ + 'project' => $project, + 'location' => $location, + 'api' => $api, + 'version' => $version, + 'spec' => $spec, + 'artifact' => $artifact, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_artifact resource. + * + * @param string $project + * @param string $location + * @param string $artifact + * + * @return string The formatted project_location_artifact resource. + */ + public static function projectLocationArtifactName(string $project, string $location, string $artifact): string + { + return self::getPathTemplate('projectLocationArtifact')->render([ + 'project' => $project, + 'location' => $location, + 'artifact' => $artifact, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - api: projects/{project}/locations/{location}/apis/{api} + * - apiDeployment: projects/{project}/locations/{location}/apis/{api}/deployments/{deployment} + * - apiSpec: projects/{project}/locations/{location}/apis/{api}/versions/{version}/specs/{spec} + * - apiVersion: projects/{project}/locations/{location}/apis/{api}/versions/{version} + * - artifact: projects/{project}/locations/{location}/artifacts/{artifact} + * - location: projects/{project}/locations/{location} + * - projectLocationApiArtifact: projects/{project}/locations/{location}/apis/{api}/artifacts/{artifact} + * - projectLocationApiDeploymentArtifact: projects/{project}/locations/{location}/apis/{api}/deployments/{deployment}/artifacts/{artifact} + * - projectLocationApiVersionArtifact: projects/{project}/locations/{location}/apis/{api}/versions/{version}/artifacts/{artifact} + * - projectLocationApiVersionSpecArtifact: projects/{project}/locations/{location}/apis/{api}/versions/{version}/specs/{spec}/artifacts/{artifact} + * - projectLocationArtifact: projects/{project}/locations/{location}/artifacts/{artifact} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'apigeeregistry.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a specified API. + * + * The async variant is {@see RegistryClient::createApiAsync()} . + * + * @example samples/V1/RegistryClient/create_api.php + * + * @param CreateApiRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Api + * + * @throws ApiException Thrown if the API call fails. + */ + public function createApi(CreateApiRequest $request, array $callOptions = []): Api + { + return $this->startApiCall('CreateApi', $request, $callOptions)->wait(); + } + + /** + * Creates a specified deployment. + * + * The async variant is {@see RegistryClient::createApiDeploymentAsync()} . + * + * @example samples/V1/RegistryClient/create_api_deployment.php + * + * @param CreateApiDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ApiDeployment + * + * @throws ApiException Thrown if the API call fails. + */ + public function createApiDeployment(CreateApiDeploymentRequest $request, array $callOptions = []): ApiDeployment + { + return $this->startApiCall('CreateApiDeployment', $request, $callOptions)->wait(); + } + + /** + * Creates a specified spec. + * + * The async variant is {@see RegistryClient::createApiSpecAsync()} . + * + * @example samples/V1/RegistryClient/create_api_spec.php + * + * @param CreateApiSpecRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ApiSpec + * + * @throws ApiException Thrown if the API call fails. + */ + public function createApiSpec(CreateApiSpecRequest $request, array $callOptions = []): ApiSpec + { + return $this->startApiCall('CreateApiSpec', $request, $callOptions)->wait(); + } + + /** + * Creates a specified version. + * + * The async variant is {@see RegistryClient::createApiVersionAsync()} . + * + * @example samples/V1/RegistryClient/create_api_version.php + * + * @param CreateApiVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ApiVersion + * + * @throws ApiException Thrown if the API call fails. + */ + public function createApiVersion(CreateApiVersionRequest $request, array $callOptions = []): ApiVersion + { + return $this->startApiCall('CreateApiVersion', $request, $callOptions)->wait(); + } + + /** + * Creates a specified artifact. + * + * The async variant is {@see RegistryClient::createArtifactAsync()} . + * + * @example samples/V1/RegistryClient/create_artifact.php + * + * @param CreateArtifactRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Artifact + * + * @throws ApiException Thrown if the API call fails. + */ + public function createArtifact(CreateArtifactRequest $request, array $callOptions = []): Artifact + { + return $this->startApiCall('CreateArtifact', $request, $callOptions)->wait(); + } + + /** + * Removes a specified API and all of the resources that it + * owns. + * + * The async variant is {@see RegistryClient::deleteApiAsync()} . + * + * @example samples/V1/RegistryClient/delete_api.php + * + * @param DeleteApiRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteApi(DeleteApiRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteApi', $request, $callOptions)->wait(); + } + + /** + * Removes a specified deployment, all revisions, and all + * child resources (e.g., artifacts). + * + * The async variant is {@see RegistryClient::deleteApiDeploymentAsync()} . + * + * @example samples/V1/RegistryClient/delete_api_deployment.php + * + * @param DeleteApiDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteApiDeployment(DeleteApiDeploymentRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteApiDeployment', $request, $callOptions)->wait(); + } + + /** + * Deletes a revision of a deployment. + * + * The async variant is {@see RegistryClient::deleteApiDeploymentRevisionAsync()} . + * + * @example samples/V1/RegistryClient/delete_api_deployment_revision.php + * + * @param DeleteApiDeploymentRevisionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ApiDeployment + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteApiDeploymentRevision(DeleteApiDeploymentRevisionRequest $request, array $callOptions = []): ApiDeployment + { + return $this->startApiCall('DeleteApiDeploymentRevision', $request, $callOptions)->wait(); + } + + /** + * Removes a specified spec, all revisions, and all child + * resources (e.g., artifacts). + * + * The async variant is {@see RegistryClient::deleteApiSpecAsync()} . + * + * @example samples/V1/RegistryClient/delete_api_spec.php + * + * @param DeleteApiSpecRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteApiSpec(DeleteApiSpecRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteApiSpec', $request, $callOptions)->wait(); + } + + /** + * Deletes a revision of a spec. + * + * The async variant is {@see RegistryClient::deleteApiSpecRevisionAsync()} . + * + * @example samples/V1/RegistryClient/delete_api_spec_revision.php + * + * @param DeleteApiSpecRevisionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ApiSpec + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteApiSpecRevision(DeleteApiSpecRevisionRequest $request, array $callOptions = []): ApiSpec + { + return $this->startApiCall('DeleteApiSpecRevision', $request, $callOptions)->wait(); + } + + /** + * Removes a specified version and all of the resources that + * it owns. + * + * The async variant is {@see RegistryClient::deleteApiVersionAsync()} . + * + * @example samples/V1/RegistryClient/delete_api_version.php + * + * @param DeleteApiVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteApiVersion(DeleteApiVersionRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteApiVersion', $request, $callOptions)->wait(); + } + + /** + * Removes a specified artifact. + * + * The async variant is {@see RegistryClient::deleteArtifactAsync()} . + * + * @example samples/V1/RegistryClient/delete_artifact.php + * + * @param DeleteArtifactRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteArtifact(DeleteArtifactRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteArtifact', $request, $callOptions)->wait(); + } + + /** + * Returns a specified API. + * + * The async variant is {@see RegistryClient::getApiAsync()} . + * + * @example samples/V1/RegistryClient/get_api.php + * + * @param GetApiRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Api + * + * @throws ApiException Thrown if the API call fails. + */ + public function getApi(GetApiRequest $request, array $callOptions = []): Api + { + return $this->startApiCall('GetApi', $request, $callOptions)->wait(); + } + + /** + * Returns a specified deployment. + * + * The async variant is {@see RegistryClient::getApiDeploymentAsync()} . + * + * @example samples/V1/RegistryClient/get_api_deployment.php + * + * @param GetApiDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ApiDeployment + * + * @throws ApiException Thrown if the API call fails. + */ + public function getApiDeployment(GetApiDeploymentRequest $request, array $callOptions = []): ApiDeployment + { + return $this->startApiCall('GetApiDeployment', $request, $callOptions)->wait(); + } + + /** + * Returns a specified spec. + * + * The async variant is {@see RegistryClient::getApiSpecAsync()} . + * + * @example samples/V1/RegistryClient/get_api_spec.php + * + * @param GetApiSpecRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ApiSpec + * + * @throws ApiException Thrown if the API call fails. + */ + public function getApiSpec(GetApiSpecRequest $request, array $callOptions = []): ApiSpec + { + return $this->startApiCall('GetApiSpec', $request, $callOptions)->wait(); + } + + /** + * Returns the contents of a specified spec. + * If specs are stored with GZip compression, the default behavior + * is to return the spec uncompressed (the mime_type response field + * indicates the exact format returned). + * + * The async variant is {@see RegistryClient::getApiSpecContentsAsync()} . + * + * @example samples/V1/RegistryClient/get_api_spec_contents.php + * + * @param GetApiSpecContentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 HttpBody + * + * @throws ApiException Thrown if the API call fails. + */ + public function getApiSpecContents(GetApiSpecContentsRequest $request, array $callOptions = []): HttpBody + { + return $this->startApiCall('GetApiSpecContents', $request, $callOptions)->wait(); + } + + /** + * Returns a specified version. + * + * The async variant is {@see RegistryClient::getApiVersionAsync()} . + * + * @example samples/V1/RegistryClient/get_api_version.php + * + * @param GetApiVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ApiVersion + * + * @throws ApiException Thrown if the API call fails. + */ + public function getApiVersion(GetApiVersionRequest $request, array $callOptions = []): ApiVersion + { + return $this->startApiCall('GetApiVersion', $request, $callOptions)->wait(); + } + + /** + * Returns a specified artifact. + * + * The async variant is {@see RegistryClient::getArtifactAsync()} . + * + * @example samples/V1/RegistryClient/get_artifact.php + * + * @param GetArtifactRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Artifact + * + * @throws ApiException Thrown if the API call fails. + */ + public function getArtifact(GetArtifactRequest $request, array $callOptions = []): Artifact + { + return $this->startApiCall('GetArtifact', $request, $callOptions)->wait(); + } + + /** + * Returns the contents of a specified artifact. + * If artifacts are stored with GZip compression, the default behavior + * is to return the artifact uncompressed (the mime_type response field + * indicates the exact format returned). + * + * The async variant is {@see RegistryClient::getArtifactContentsAsync()} . + * + * @example samples/V1/RegistryClient/get_artifact_contents.php + * + * @param GetArtifactContentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 HttpBody + * + * @throws ApiException Thrown if the API call fails. + */ + public function getArtifactContents(GetArtifactContentsRequest $request, array $callOptions = []): HttpBody + { + return $this->startApiCall('GetArtifactContents', $request, $callOptions)->wait(); + } + + /** + * Lists all revisions of a deployment. + * Revisions are returned in descending order of revision creation time. + * + * The async variant is {@see RegistryClient::listApiDeploymentRevisionsAsync()} . + * + * @example samples/V1/RegistryClient/list_api_deployment_revisions.php + * + * @param ListApiDeploymentRevisionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listApiDeploymentRevisions(ListApiDeploymentRevisionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListApiDeploymentRevisions', $request, $callOptions); + } + + /** + * Returns matching deployments. + * + * The async variant is {@see RegistryClient::listApiDeploymentsAsync()} . + * + * @example samples/V1/RegistryClient/list_api_deployments.php + * + * @param ListApiDeploymentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listApiDeployments(ListApiDeploymentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListApiDeployments', $request, $callOptions); + } + + /** + * Lists all revisions of a spec. + * Revisions are returned in descending order of revision creation time. + * + * The async variant is {@see RegistryClient::listApiSpecRevisionsAsync()} . + * + * @example samples/V1/RegistryClient/list_api_spec_revisions.php + * + * @param ListApiSpecRevisionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listApiSpecRevisions(ListApiSpecRevisionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListApiSpecRevisions', $request, $callOptions); + } + + /** + * Returns matching specs. + * + * The async variant is {@see RegistryClient::listApiSpecsAsync()} . + * + * @example samples/V1/RegistryClient/list_api_specs.php + * + * @param ListApiSpecsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listApiSpecs(ListApiSpecsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListApiSpecs', $request, $callOptions); + } + + /** + * Returns matching versions. + * + * The async variant is {@see RegistryClient::listApiVersionsAsync()} . + * + * @example samples/V1/RegistryClient/list_api_versions.php + * + * @param ListApiVersionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listApiVersions(ListApiVersionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListApiVersions', $request, $callOptions); + } + + /** + * Returns matching APIs. + * + * The async variant is {@see RegistryClient::listApisAsync()} . + * + * @example samples/V1/RegistryClient/list_apis.php + * + * @param ListApisRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listApis(ListApisRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListApis', $request, $callOptions); + } + + /** + * Returns matching artifacts. + * + * The async variant is {@see RegistryClient::listArtifactsAsync()} . + * + * @example samples/V1/RegistryClient/list_artifacts.php + * + * @param ListArtifactsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listArtifacts(ListArtifactsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListArtifacts', $request, $callOptions); + } + + /** + * Used to replace a specified artifact. + * + * The async variant is {@see RegistryClient::replaceArtifactAsync()} . + * + * @example samples/V1/RegistryClient/replace_artifact.php + * + * @param ReplaceArtifactRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Artifact + * + * @throws ApiException Thrown if the API call fails. + */ + public function replaceArtifact(ReplaceArtifactRequest $request, array $callOptions = []): Artifact + { + return $this->startApiCall('ReplaceArtifact', $request, $callOptions)->wait(); + } + + /** + * Sets the current revision to a specified prior + * revision. Note that this creates a new revision with a new revision ID. + * + * The async variant is {@see RegistryClient::rollbackApiDeploymentAsync()} . + * + * @example samples/V1/RegistryClient/rollback_api_deployment.php + * + * @param RollbackApiDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ApiDeployment + * + * @throws ApiException Thrown if the API call fails. + */ + public function rollbackApiDeployment(RollbackApiDeploymentRequest $request, array $callOptions = []): ApiDeployment + { + return $this->startApiCall('RollbackApiDeployment', $request, $callOptions)->wait(); + } + + /** + * Sets the current revision to a specified prior revision. + * Note that this creates a new revision with a new revision ID. + * + * The async variant is {@see RegistryClient::rollbackApiSpecAsync()} . + * + * @example samples/V1/RegistryClient/rollback_api_spec.php + * + * @param RollbackApiSpecRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ApiSpec + * + * @throws ApiException Thrown if the API call fails. + */ + public function rollbackApiSpec(RollbackApiSpecRequest $request, array $callOptions = []): ApiSpec + { + return $this->startApiCall('RollbackApiSpec', $request, $callOptions)->wait(); + } + + /** + * Adds a tag to a specified revision of a + * deployment. + * + * The async variant is {@see RegistryClient::tagApiDeploymentRevisionAsync()} . + * + * @example samples/V1/RegistryClient/tag_api_deployment_revision.php + * + * @param TagApiDeploymentRevisionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ApiDeployment + * + * @throws ApiException Thrown if the API call fails. + */ + public function tagApiDeploymentRevision(TagApiDeploymentRevisionRequest $request, array $callOptions = []): ApiDeployment + { + return $this->startApiCall('TagApiDeploymentRevision', $request, $callOptions)->wait(); + } + + /** + * Adds a tag to a specified revision of a spec. + * + * The async variant is {@see RegistryClient::tagApiSpecRevisionAsync()} . + * + * @example samples/V1/RegistryClient/tag_api_spec_revision.php + * + * @param TagApiSpecRevisionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ApiSpec + * + * @throws ApiException Thrown if the API call fails. + */ + public function tagApiSpecRevision(TagApiSpecRevisionRequest $request, array $callOptions = []): ApiSpec + { + return $this->startApiCall('TagApiSpecRevision', $request, $callOptions)->wait(); + } + + /** + * Used to modify a specified API. + * + * The async variant is {@see RegistryClient::updateApiAsync()} . + * + * @example samples/V1/RegistryClient/update_api.php + * + * @param UpdateApiRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Api + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateApi(UpdateApiRequest $request, array $callOptions = []): Api + { + return $this->startApiCall('UpdateApi', $request, $callOptions)->wait(); + } + + /** + * Used to modify a specified deployment. + * + * The async variant is {@see RegistryClient::updateApiDeploymentAsync()} . + * + * @example samples/V1/RegistryClient/update_api_deployment.php + * + * @param UpdateApiDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ApiDeployment + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateApiDeployment(UpdateApiDeploymentRequest $request, array $callOptions = []): ApiDeployment + { + return $this->startApiCall('UpdateApiDeployment', $request, $callOptions)->wait(); + } + + /** + * Used to modify a specified spec. + * + * The async variant is {@see RegistryClient::updateApiSpecAsync()} . + * + * @example samples/V1/RegistryClient/update_api_spec.php + * + * @param UpdateApiSpecRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ApiSpec + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateApiSpec(UpdateApiSpecRequest $request, array $callOptions = []): ApiSpec + { + return $this->startApiCall('UpdateApiSpec', $request, $callOptions)->wait(); + } + + /** + * Used to modify a specified version. + * + * The async variant is {@see RegistryClient::updateApiVersionAsync()} . + * + * @example samples/V1/RegistryClient/update_api_version.php + * + * @param UpdateApiVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ApiVersion + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateApiVersion(UpdateApiVersionRequest $request, array $callOptions = []): ApiVersion + { + return $this->startApiCall('UpdateApiVersion', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see RegistryClient::getLocationAsync()} . + * + * @example samples/V1/RegistryClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see RegistryClient::listLocationsAsync()} . + * + * @example samples/V1/RegistryClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see RegistryClient::getIamPolicyAsync()} . + * + * @example samples/V1/RegistryClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see RegistryClient::setIamPolicyAsync()} . + * + * @example samples/V1/RegistryClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see RegistryClient::testIamPermissionsAsync()} . + * + * @example samples/V1/RegistryClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/AppEngineAdmin/composer.json b/AppEngineAdmin/composer.json index 4e79b9d67829..424782238c0b 100644 --- a/AppEngineAdmin/composer.json +++ b/AppEngineAdmin/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/AppEngineAdmin/src/V1/Client/ApplicationsClient.php b/AppEngineAdmin/src/V1/Client/ApplicationsClient.php index a7308a8df5aa..3aed5d3ce460 100644 --- a/AppEngineAdmin/src/V1/Client/ApplicationsClient.php +++ b/AppEngineAdmin/src/V1/Client/ApplicationsClient.php @@ -24,17 +24,297 @@ namespace Google\Cloud\AppEngine\V1\Client; -use Google\Cloud\AppEngine\V1\Client\BaseClient\ApplicationsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AppEngine\V1\Application; +use Google\Cloud\AppEngine\V1\CreateApplicationRequest; +use Google\Cloud\AppEngine\V1\GetApplicationRequest; +use Google\Cloud\AppEngine\V1\RepairApplicationRequest; +use Google\Cloud\AppEngine\V1\UpdateApplicationRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Manages App Engine applications. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AppEngine\V1\ApplicationsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createApplicationAsync(CreateApplicationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getApplicationAsync(GetApplicationRequest $request, array $optionalArgs = []) + * @method PromiseInterface repairApplicationAsync(RepairApplicationRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateApplicationAsync(UpdateApplicationRequest $request, array $optionalArgs = []) */ -final class ApplicationsClient extends ApplicationsBaseClient +final class ApplicationsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ApplicationsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.appengine.v1.Applications'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'appengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/appengine.admin', + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/applications_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/applications_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/applications_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/applications_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'appengine.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates an App Engine application for a Google Cloud Platform project. + * Required fields: + * + * * `id` - The ID of the target Cloud Platform project. + * * *location* - The [region](https://cloud.google.com/appengine/docs/locations) where you want the App Engine application located. + * + * For more information about App Engine applications, see [Managing Projects, Applications, and Billing](https://cloud.google.com/appengine/docs/standard/python/console/). + * + * The async variant is {@see ApplicationsClient::createApplicationAsync()} . + * + * @param CreateApplicationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createApplication(CreateApplicationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateApplication', $request, $callOptions)->wait(); + } + + /** + * Gets information about an application. + * + * The async variant is {@see ApplicationsClient::getApplicationAsync()} . + * + * @param GetApplicationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Application + * + * @throws ApiException Thrown if the API call fails. + */ + public function getApplication(GetApplicationRequest $request, array $callOptions = []): Application + { + return $this->startApiCall('GetApplication', $request, $callOptions)->wait(); + } + + /** + * Recreates the required App Engine features for the specified App Engine + * application, for example a Cloud Storage bucket or App Engine service + * account. + * Use this method if you receive an error message about a missing feature, + * for example, *Error retrieving the App Engine service account*. + * If you have deleted your App Engine service account, this will + * not be able to recreate it. Instead, you should attempt to use the + * IAM undelete API if possible at https://cloud.google.com/iam/reference/rest/v1/projects.serviceAccounts/undelete?apix_params=%7B"name"%3A"projects%2F-%2FserviceAccounts%2Funique_id"%2C"resource"%3A%7B%7D%7D . + * If the deletion was recent, the numeric ID can be found in the Cloud + * Console Activity Log. + * + * The async variant is {@see ApplicationsClient::repairApplicationAsync()} . + * + * @param RepairApplicationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function repairApplication(RepairApplicationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RepairApplication', $request, $callOptions)->wait(); + } + + /** + * Updates the specified Application resource. + * You can update the following fields: + * + * * `auth_domain` - Google authentication domain for controlling user access to the application. + * * `default_cookie_expiration` - Cookie expiration policy for the application. + * * `iap` - Identity-Aware Proxy properties for the application. + * + * The async variant is {@see ApplicationsClient::updateApplicationAsync()} . + * + * @param UpdateApplicationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateApplication(UpdateApplicationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateApplication', $request, $callOptions)->wait(); + } } diff --git a/AppEngineAdmin/src/V1/Client/AuthorizedCertificatesClient.php b/AppEngineAdmin/src/V1/Client/AuthorizedCertificatesClient.php index 18a4aa86160c..b8135e0cbd83 100644 --- a/AppEngineAdmin/src/V1/Client/AuthorizedCertificatesClient.php +++ b/AppEngineAdmin/src/V1/Client/AuthorizedCertificatesClient.php @@ -24,17 +24,278 @@ namespace Google\Cloud\AppEngine\V1\Client; -use Google\Cloud\AppEngine\V1\Client\BaseClient\AuthorizedCertificatesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AppEngine\V1\AuthorizedCertificate; +use Google\Cloud\AppEngine\V1\CreateAuthorizedCertificateRequest; +use Google\Cloud\AppEngine\V1\DeleteAuthorizedCertificateRequest; +use Google\Cloud\AppEngine\V1\GetAuthorizedCertificateRequest; +use Google\Cloud\AppEngine\V1\ListAuthorizedCertificatesRequest; +use Google\Cloud\AppEngine\V1\UpdateAuthorizedCertificateRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Manages SSL certificates a user is authorized to administer. A user can + * administer any SSL certificates applicable to their authorized domains. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AppEngine\V1\AuthorizedCertificatesClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createAuthorizedCertificateAsync(CreateAuthorizedCertificateRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAuthorizedCertificateAsync(DeleteAuthorizedCertificateRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAuthorizedCertificateAsync(GetAuthorizedCertificateRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAuthorizedCertificatesAsync(ListAuthorizedCertificatesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAuthorizedCertificateAsync(UpdateAuthorizedCertificateRequest $request, array $optionalArgs = []) */ -final class AuthorizedCertificatesClient extends AuthorizedCertificatesBaseClient +final class AuthorizedCertificatesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AuthorizedCertificatesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.appengine.v1.AuthorizedCertificates'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'appengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/appengine.admin', + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/authorized_certificates_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/authorized_certificates_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/authorized_certificates_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/authorized_certificates_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'appengine.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Uploads the specified SSL certificate. + * + * The async variant is + * {@see AuthorizedCertificatesClient::createAuthorizedCertificateAsync()} . + * + * @param CreateAuthorizedCertificateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AuthorizedCertificate + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAuthorizedCertificate(CreateAuthorizedCertificateRequest $request, array $callOptions = []): AuthorizedCertificate + { + return $this->startApiCall('CreateAuthorizedCertificate', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified SSL certificate. + * + * The async variant is + * {@see AuthorizedCertificatesClient::deleteAuthorizedCertificateAsync()} . + * + * @param DeleteAuthorizedCertificateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAuthorizedCertificate(DeleteAuthorizedCertificateRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteAuthorizedCertificate', $request, $callOptions)->wait(); + } + + /** + * Gets the specified SSL certificate. + * + * The async variant is + * {@see AuthorizedCertificatesClient::getAuthorizedCertificateAsync()} . + * + * @param GetAuthorizedCertificateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AuthorizedCertificate + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAuthorizedCertificate(GetAuthorizedCertificateRequest $request, array $callOptions = []): AuthorizedCertificate + { + return $this->startApiCall('GetAuthorizedCertificate', $request, $callOptions)->wait(); + } + + /** + * Lists all SSL certificates the user is authorized to administer. + * + * The async variant is + * {@see AuthorizedCertificatesClient::listAuthorizedCertificatesAsync()} . + * + * @param ListAuthorizedCertificatesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAuthorizedCertificates(ListAuthorizedCertificatesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAuthorizedCertificates', $request, $callOptions); + } + + /** + * Updates the specified SSL certificate. To renew a certificate and maintain + * its existing domain mappings, update `certificate_data` with a new + * certificate. The new certificate must be applicable to the same domains as + * the original certificate. The certificate `display_name` may also be + * updated. + * + * The async variant is + * {@see AuthorizedCertificatesClient::updateAuthorizedCertificateAsync()} . + * + * @param UpdateAuthorizedCertificateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AuthorizedCertificate + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAuthorizedCertificate(UpdateAuthorizedCertificateRequest $request, array $callOptions = []): AuthorizedCertificate + { + return $this->startApiCall('UpdateAuthorizedCertificate', $request, $callOptions)->wait(); + } } diff --git a/AppEngineAdmin/src/V1/Client/AuthorizedDomainsClient.php b/AppEngineAdmin/src/V1/Client/AuthorizedDomainsClient.php index 205be407dfc0..06599bef754e 100644 --- a/AppEngineAdmin/src/V1/Client/AuthorizedDomainsClient.php +++ b/AppEngineAdmin/src/V1/Client/AuthorizedDomainsClient.php @@ -24,17 +24,168 @@ namespace Google\Cloud\AppEngine\V1\Client; -use Google\Cloud\AppEngine\V1\Client\BaseClient\AuthorizedDomainsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AppEngine\V1\ListAuthorizedDomainsRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Manages domains a user is authorized to administer. To authorize use of a + * domain, verify ownership via + * [Webmaster Central](https://www.google.com/webmasters/verification/home). * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AppEngine\V1\AuthorizedDomainsClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface listAuthorizedDomainsAsync(ListAuthorizedDomainsRequest $request, array $optionalArgs = []) */ -final class AuthorizedDomainsClient extends AuthorizedDomainsBaseClient +final class AuthorizedDomainsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AuthorizedDomainsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.appengine.v1.AuthorizedDomains'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'appengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/appengine.admin', + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/authorized_domains_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/authorized_domains_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/authorized_domains_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/authorized_domains_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'appengine.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Lists all domains the user is authorized to administer. + * + * The async variant is + * {@see AuthorizedDomainsClient::listAuthorizedDomainsAsync()} . + * + * @param ListAuthorizedDomainsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAuthorizedDomains(ListAuthorizedDomainsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAuthorizedDomains', $request, $callOptions); + } } diff --git a/AppEngineAdmin/src/V1/Client/BaseClient/ApplicationsBaseClient.php b/AppEngineAdmin/src/V1/Client/BaseClient/ApplicationsBaseClient.php deleted file mode 100644 index 23cb66aae20b..000000000000 --- a/AppEngineAdmin/src/V1/Client/BaseClient/ApplicationsBaseClient.php +++ /dev/null @@ -1,322 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/applications_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/applications_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/applications_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/applications_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'appengine.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates an App Engine application for a Google Cloud Platform project. - * Required fields: - * - * * `id` - The ID of the target Cloud Platform project. - * * *location* - The [region](https://cloud.google.com/appengine/docs/locations) where you want the App Engine application located. - * - * For more information about App Engine applications, see [Managing Projects, Applications, and Billing](https://cloud.google.com/appengine/docs/standard/python/console/). - * - * The async variant is {@see self::createApplicationAsync()} . - * - * @param CreateApplicationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createApplication(CreateApplicationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateApplication', $request, $callOptions)->wait(); - } - - /** - * Gets information about an application. - * - * The async variant is {@see self::getApplicationAsync()} . - * - * @param GetApplicationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Application - * - * @throws ApiException Thrown if the API call fails. - */ - public function getApplication(GetApplicationRequest $request, array $callOptions = []): Application - { - return $this->startApiCall('GetApplication', $request, $callOptions)->wait(); - } - - /** - * Recreates the required App Engine features for the specified App Engine - * application, for example a Cloud Storage bucket or App Engine service - * account. - * Use this method if you receive an error message about a missing feature, - * for example, *Error retrieving the App Engine service account*. - * If you have deleted your App Engine service account, this will - * not be able to recreate it. Instead, you should attempt to use the - * IAM undelete API if possible at https://cloud.google.com/iam/reference/rest/v1/projects.serviceAccounts/undelete?apix_params=%7B"name"%3A"projects%2F-%2FserviceAccounts%2Funique_id"%2C"resource"%3A%7B%7D%7D . - * If the deletion was recent, the numeric ID can be found in the Cloud - * Console Activity Log. - * - * The async variant is {@see self::repairApplicationAsync()} . - * - * @param RepairApplicationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function repairApplication(RepairApplicationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RepairApplication', $request, $callOptions)->wait(); - } - - /** - * Updates the specified Application resource. - * You can update the following fields: - * - * * `auth_domain` - Google authentication domain for controlling user access to the application. - * * `default_cookie_expiration` - Cookie expiration policy for the application. - * * `iap` - Identity-Aware Proxy properties for the application. - * - * The async variant is {@see self::updateApplicationAsync()} . - * - * @param UpdateApplicationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateApplication(UpdateApplicationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateApplication', $request, $callOptions)->wait(); - } -} diff --git a/AppEngineAdmin/src/V1/Client/BaseClient/AuthorizedCertificatesBaseClient.php b/AppEngineAdmin/src/V1/Client/BaseClient/AuthorizedCertificatesBaseClient.php deleted file mode 100644 index a3651e5a3237..000000000000 --- a/AppEngineAdmin/src/V1/Client/BaseClient/AuthorizedCertificatesBaseClient.php +++ /dev/null @@ -1,298 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/authorized_certificates_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/authorized_certificates_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/authorized_certificates_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/authorized_certificates_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'appengine.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Uploads the specified SSL certificate. - * - * The async variant is {@see self::createAuthorizedCertificateAsync()} . - * - * @param CreateAuthorizedCertificateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AuthorizedCertificate - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAuthorizedCertificate(CreateAuthorizedCertificateRequest $request, array $callOptions = []): AuthorizedCertificate - { - return $this->startApiCall('CreateAuthorizedCertificate', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified SSL certificate. - * - * The async variant is {@see self::deleteAuthorizedCertificateAsync()} . - * - * @param DeleteAuthorizedCertificateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAuthorizedCertificate(DeleteAuthorizedCertificateRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteAuthorizedCertificate', $request, $callOptions)->wait(); - } - - /** - * Gets the specified SSL certificate. - * - * The async variant is {@see self::getAuthorizedCertificateAsync()} . - * - * @param GetAuthorizedCertificateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AuthorizedCertificate - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAuthorizedCertificate(GetAuthorizedCertificateRequest $request, array $callOptions = []): AuthorizedCertificate - { - return $this->startApiCall('GetAuthorizedCertificate', $request, $callOptions)->wait(); - } - - /** - * Lists all SSL certificates the user is authorized to administer. - * - * The async variant is {@see self::listAuthorizedCertificatesAsync()} . - * - * @param ListAuthorizedCertificatesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAuthorizedCertificates(ListAuthorizedCertificatesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAuthorizedCertificates', $request, $callOptions); - } - - /** - * Updates the specified SSL certificate. To renew a certificate and maintain - * its existing domain mappings, update `certificate_data` with a new - * certificate. The new certificate must be applicable to the same domains as - * the original certificate. The certificate `display_name` may also be - * updated. - * - * The async variant is {@see self::updateAuthorizedCertificateAsync()} . - * - * @param UpdateAuthorizedCertificateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AuthorizedCertificate - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAuthorizedCertificate(UpdateAuthorizedCertificateRequest $request, array $callOptions = []): AuthorizedCertificate - { - return $this->startApiCall('UpdateAuthorizedCertificate', $request, $callOptions)->wait(); - } -} diff --git a/AppEngineAdmin/src/V1/Client/BaseClient/AuthorizedDomainsBaseClient.php b/AppEngineAdmin/src/V1/Client/BaseClient/AuthorizedDomainsBaseClient.php deleted file mode 100644 index 83aba4f0b3c5..000000000000 --- a/AppEngineAdmin/src/V1/Client/BaseClient/AuthorizedDomainsBaseClient.php +++ /dev/null @@ -1,192 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/authorized_domains_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/authorized_domains_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/authorized_domains_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/authorized_domains_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'appengine.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Lists all domains the user is authorized to administer. - * - * The async variant is {@see self::listAuthorizedDomainsAsync()} . - * - * @param ListAuthorizedDomainsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAuthorizedDomains(ListAuthorizedDomainsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAuthorizedDomains', $request, $callOptions); - } -} diff --git a/AppEngineAdmin/src/V1/Client/BaseClient/DomainMappingsBaseClient.php b/AppEngineAdmin/src/V1/Client/BaseClient/DomainMappingsBaseClient.php deleted file mode 100644 index 2eaa26685ebd..000000000000 --- a/AppEngineAdmin/src/V1/Client/BaseClient/DomainMappingsBaseClient.php +++ /dev/null @@ -1,336 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/domain_mappings_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/domain_mappings_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/domain_mappings_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/domain_mappings_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'appengine.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Maps a domain to an application. A user must be authorized to administer a - * domain in order to map it to an application. For a list of available - * authorized domains, see [`AuthorizedDomains.ListAuthorizedDomains`](). - * - * The async variant is {@see self::createDomainMappingAsync()} . - * - * @param CreateDomainMappingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDomainMapping(CreateDomainMappingRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateDomainMapping', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified domain mapping. A user must be authorized to - * administer the associated domain in order to delete a `DomainMapping` - * resource. - * - * The async variant is {@see self::deleteDomainMappingAsync()} . - * - * @param DeleteDomainMappingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDomainMapping(DeleteDomainMappingRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteDomainMapping', $request, $callOptions)->wait(); - } - - /** - * Gets the specified domain mapping. - * - * The async variant is {@see self::getDomainMappingAsync()} . - * - * @param GetDomainMappingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DomainMapping - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDomainMapping(GetDomainMappingRequest $request, array $callOptions = []): DomainMapping - { - return $this->startApiCall('GetDomainMapping', $request, $callOptions)->wait(); - } - - /** - * Lists the domain mappings on an application. - * - * The async variant is {@see self::listDomainMappingsAsync()} . - * - * @param ListDomainMappingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDomainMappings(ListDomainMappingsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDomainMappings', $request, $callOptions); - } - - /** - * Updates the specified domain mapping. To map an SSL certificate to a - * domain mapping, update `certificate_id` to point to an `AuthorizedCertificate` - * resource. A user must be authorized to administer the associated domain - * in order to update a `DomainMapping` resource. - * - * The async variant is {@see self::updateDomainMappingAsync()} . - * - * @param UpdateDomainMappingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDomainMapping(UpdateDomainMappingRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateDomainMapping', $request, $callOptions)->wait(); - } -} diff --git a/AppEngineAdmin/src/V1/Client/BaseClient/FirewallBaseClient.php b/AppEngineAdmin/src/V1/Client/BaseClient/FirewallBaseClient.php deleted file mode 100644 index 21481b475889..000000000000 --- a/AppEngineAdmin/src/V1/Client/BaseClient/FirewallBaseClient.php +++ /dev/null @@ -1,332 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/firewall_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/firewall_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/firewall_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/firewall_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'appengine.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Replaces the entire firewall ruleset in one bulk operation. This overrides - * and replaces the rules of an existing firewall with the new rules. - * - * If the final rule does not match traffic with the '*' wildcard IP range, - * then an "allow all" rule is explicitly added to the end of the list. - * - * The async variant is {@see self::batchUpdateIngressRulesAsync()} . - * - * @param BatchUpdateIngressRulesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BatchUpdateIngressRulesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchUpdateIngressRules(BatchUpdateIngressRulesRequest $request, array $callOptions = []): BatchUpdateIngressRulesResponse - { - return $this->startApiCall('BatchUpdateIngressRules', $request, $callOptions)->wait(); - } - - /** - * Creates a firewall rule for the application. - * - * The async variant is {@see self::createIngressRuleAsync()} . - * - * @param CreateIngressRuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FirewallRule - * - * @throws ApiException Thrown if the API call fails. - */ - public function createIngressRule(CreateIngressRuleRequest $request, array $callOptions = []): FirewallRule - { - return $this->startApiCall('CreateIngressRule', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified firewall rule. - * - * The async variant is {@see self::deleteIngressRuleAsync()} . - * - * @param DeleteIngressRuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteIngressRule(DeleteIngressRuleRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteIngressRule', $request, $callOptions)->wait(); - } - - /** - * Gets the specified firewall rule. - * - * The async variant is {@see self::getIngressRuleAsync()} . - * - * @param GetIngressRuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FirewallRule - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIngressRule(GetIngressRuleRequest $request, array $callOptions = []): FirewallRule - { - return $this->startApiCall('GetIngressRule', $request, $callOptions)->wait(); - } - - /** - * Lists the firewall rules of an application. - * - * The async variant is {@see self::listIngressRulesAsync()} . - * - * @param ListIngressRulesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listIngressRules(ListIngressRulesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListIngressRules', $request, $callOptions); - } - - /** - * Updates the specified firewall rule. - * - * The async variant is {@see self::updateIngressRuleAsync()} . - * - * @param UpdateIngressRuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FirewallRule - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateIngressRule(UpdateIngressRuleRequest $request, array $callOptions = []): FirewallRule - { - return $this->startApiCall('UpdateIngressRule', $request, $callOptions)->wait(); - } -} diff --git a/AppEngineAdmin/src/V1/Client/BaseClient/InstancesBaseClient.php b/AppEngineAdmin/src/V1/Client/BaseClient/InstancesBaseClient.php deleted file mode 100644 index b3b783bb4724..000000000000 --- a/AppEngineAdmin/src/V1/Client/BaseClient/InstancesBaseClient.php +++ /dev/null @@ -1,324 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/instances_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/instances_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/instances_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/instances_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'appengine.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Enables debugging on a VM instance. This allows you to use the SSH - * command to connect to the virtual machine where the instance lives. - * While in "debug mode", the instance continues to serve live traffic. - * You should delete the instance when you are done debugging and then - * allow the system to take over and determine if another instance - * should be started. - * - * Only applicable for instances in App Engine flexible environment. - * - * The async variant is {@see self::debugInstanceAsync()} . - * - * @param DebugInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function debugInstance(DebugInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DebugInstance', $request, $callOptions)->wait(); - } - - /** - * Stops a running instance. - * - * The instance might be automatically recreated based on the scaling settings - * of the version. For more information, see "How Instances are Managed" - * ([standard environment](https://cloud.google.com/appengine/docs/standard/python/how-instances-are-managed) | - * [flexible environment](https://cloud.google.com/appengine/docs/flexible/python/how-instances-are-managed)). - * - * To ensure that instances are not re-created and avoid getting billed, you - * can stop all instances within the target version by changing the serving - * status of the version to `STOPPED` with the - * [`apps.services.versions.patch`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions/patch) - * method. - * - * The async variant is {@see self::deleteInstanceAsync()} . - * - * @param DeleteInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); - } - - /** - * Gets instance information. - * - * The async variant is {@see self::getInstanceAsync()} . - * - * @param GetInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Instance - * - * @throws ApiException Thrown if the API call fails. - */ - public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance - { - return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); - } - - /** - * Lists the instances of a version. - * - * Tip: To aggregate details about instances over time, see the - * [Stackdriver Monitoring API](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list). - * - * The async variant is {@see self::listInstancesAsync()} . - * - * @param ListInstancesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listInstances(ListInstancesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListInstances', $request, $callOptions); - } -} diff --git a/AppEngineAdmin/src/V1/Client/BaseClient/ServicesBaseClient.php b/AppEngineAdmin/src/V1/Client/BaseClient/ServicesBaseClient.php deleted file mode 100644 index 269a214b0868..000000000000 --- a/AppEngineAdmin/src/V1/Client/BaseClient/ServicesBaseClient.php +++ /dev/null @@ -1,303 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/services_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/services_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/services_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/services_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'appengine.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified service and all enclosed versions. - * - * The async variant is {@see self::deleteServiceAsync()} . - * - * @param DeleteServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteService(DeleteServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteService', $request, $callOptions)->wait(); - } - - /** - * Gets the current configuration of the specified service. - * - * The async variant is {@see self::getServiceAsync()} . - * - * @param GetServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Service - * - * @throws ApiException Thrown if the API call fails. - */ - public function getService(GetServiceRequest $request, array $callOptions = []): Service - { - return $this->startApiCall('GetService', $request, $callOptions)->wait(); - } - - /** - * Lists all the services in the application. - * - * The async variant is {@see self::listServicesAsync()} . - * - * @param ListServicesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listServices(ListServicesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListServices', $request, $callOptions); - } - - /** - * Updates the configuration of the specified service. - * - * The async variant is {@see self::updateServiceAsync()} . - * - * @param UpdateServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateService(UpdateServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateService', $request, $callOptions)->wait(); - } -} diff --git a/AppEngineAdmin/src/V1/Client/BaseClient/VersionsBaseClient.php b/AppEngineAdmin/src/V1/Client/BaseClient/VersionsBaseClient.php deleted file mode 100644 index 5785807e05db..000000000000 --- a/AppEngineAdmin/src/V1/Client/BaseClient/VersionsBaseClient.php +++ /dev/null @@ -1,366 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/versions_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/versions_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/versions_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/versions_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'appengine.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deploys code and resource files to a new version. - * - * The async variant is {@see self::createVersionAsync()} . - * - * @param CreateVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createVersion(CreateVersionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateVersion', $request, $callOptions)->wait(); - } - - /** - * Deletes an existing Version resource. - * - * The async variant is {@see self::deleteVersionAsync()} . - * - * @param DeleteVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteVersion(DeleteVersionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteVersion', $request, $callOptions)->wait(); - } - - /** - * Gets the specified Version resource. - * By default, only a `BASIC_VIEW` will be returned. - * Specify the `FULL_VIEW` parameter to get the full resource. - * - * The async variant is {@see self::getVersionAsync()} . - * - * @param GetVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Version - * - * @throws ApiException Thrown if the API call fails. - */ - public function getVersion(GetVersionRequest $request, array $callOptions = []): Version - { - return $this->startApiCall('GetVersion', $request, $callOptions)->wait(); - } - - /** - * Lists the versions of a service. - * - * The async variant is {@see self::listVersionsAsync()} . - * - * @param ListVersionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listVersions(ListVersionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListVersions', $request, $callOptions); - } - - /** - * Updates the specified Version resource. - * You can specify the following fields depending on the App Engine - * environment and type of scaling that the version resource uses: - * - * **Standard environment** - * - * * [`instance_class`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.instance_class) - * - * *automatic scaling* in the standard environment: - * - * * [`automatic_scaling.min_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) - * * [`automatic_scaling.max_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) - * * [`automaticScaling.standard_scheduler_settings.max_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) - * * [`automaticScaling.standard_scheduler_settings.min_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) - * * [`automaticScaling.standard_scheduler_settings.target_cpu_utilization`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) - * * [`automaticScaling.standard_scheduler_settings.target_throughput_utilization`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) - * - * *basic scaling* or *manual scaling* in the standard environment: - * - * * [`serving_status`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.serving_status) - * * [`manual_scaling.instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#manualscaling) - * - * **Flexible environment** - * - * * [`serving_status`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.serving_status) - * - * *automatic scaling* in the flexible environment: - * - * * [`automatic_scaling.min_total_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) - * * [`automatic_scaling.max_total_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) - * * [`automatic_scaling.cool_down_period_sec`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) - * * [`automatic_scaling.cpu_utilization.target_utilization`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) - * - * *manual scaling* in the flexible environment: - * - * * [`manual_scaling.instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#manualscaling) - * - * The async variant is {@see self::updateVersionAsync()} . - * - * @param UpdateVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateVersion(UpdateVersionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateVersion', $request, $callOptions)->wait(); - } -} diff --git a/AppEngineAdmin/src/V1/Client/DomainMappingsClient.php b/AppEngineAdmin/src/V1/Client/DomainMappingsClient.php index d071e142207c..a23a7eb78383 100644 --- a/AppEngineAdmin/src/V1/Client/DomainMappingsClient.php +++ b/AppEngineAdmin/src/V1/Client/DomainMappingsClient.php @@ -24,17 +24,311 @@ namespace Google\Cloud\AppEngine\V1\Client; -use Google\Cloud\AppEngine\V1\Client\BaseClient\DomainMappingsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AppEngine\V1\CreateDomainMappingRequest; +use Google\Cloud\AppEngine\V1\DeleteDomainMappingRequest; +use Google\Cloud\AppEngine\V1\DomainMapping; +use Google\Cloud\AppEngine\V1\GetDomainMappingRequest; +use Google\Cloud\AppEngine\V1\ListDomainMappingsRequest; +use Google\Cloud\AppEngine\V1\UpdateDomainMappingRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Manages domains serving an application. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AppEngine\V1\DomainMappingsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createDomainMappingAsync(CreateDomainMappingRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDomainMappingAsync(DeleteDomainMappingRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDomainMappingAsync(GetDomainMappingRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDomainMappingsAsync(ListDomainMappingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDomainMappingAsync(UpdateDomainMappingRequest $request, array $optionalArgs = []) */ -final class DomainMappingsClient extends DomainMappingsBaseClient +final class DomainMappingsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DomainMappingsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.appengine.v1.DomainMappings'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'appengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/appengine.admin', + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/domain_mappings_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/domain_mappings_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/domain_mappings_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/domain_mappings_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'appengine.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Maps a domain to an application. A user must be authorized to administer a + * domain in order to map it to an application. For a list of available + * authorized domains, see [`AuthorizedDomains.ListAuthorizedDomains`](). + * + * The async variant is {@see DomainMappingsClient::createDomainMappingAsync()} . + * + * @param CreateDomainMappingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDomainMapping(CreateDomainMappingRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateDomainMapping', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified domain mapping. A user must be authorized to + * administer the associated domain in order to delete a `DomainMapping` + * resource. + * + * The async variant is {@see DomainMappingsClient::deleteDomainMappingAsync()} . + * + * @param DeleteDomainMappingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDomainMapping(DeleteDomainMappingRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteDomainMapping', $request, $callOptions)->wait(); + } + + /** + * Gets the specified domain mapping. + * + * The async variant is {@see DomainMappingsClient::getDomainMappingAsync()} . + * + * @param GetDomainMappingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DomainMapping + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDomainMapping(GetDomainMappingRequest $request, array $callOptions = []): DomainMapping + { + return $this->startApiCall('GetDomainMapping', $request, $callOptions)->wait(); + } + + /** + * Lists the domain mappings on an application. + * + * The async variant is {@see DomainMappingsClient::listDomainMappingsAsync()} . + * + * @param ListDomainMappingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDomainMappings(ListDomainMappingsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDomainMappings', $request, $callOptions); + } + + /** + * Updates the specified domain mapping. To map an SSL certificate to a + * domain mapping, update `certificate_id` to point to an `AuthorizedCertificate` + * resource. A user must be authorized to administer the associated domain + * in order to update a `DomainMapping` resource. + * + * The async variant is {@see DomainMappingsClient::updateDomainMappingAsync()} . + * + * @param UpdateDomainMappingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDomainMapping(UpdateDomainMappingRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateDomainMapping', $request, $callOptions)->wait(); + } } diff --git a/AppEngineAdmin/src/V1/Client/FirewallClient.php b/AppEngineAdmin/src/V1/Client/FirewallClient.php index 9a5225f2da1c..72786053134c 100644 --- a/AppEngineAdmin/src/V1/Client/FirewallClient.php +++ b/AppEngineAdmin/src/V1/Client/FirewallClient.php @@ -24,17 +24,307 @@ namespace Google\Cloud\AppEngine\V1\Client; -use Google\Cloud\AppEngine\V1\Client\BaseClient\FirewallBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AppEngine\V1\BatchUpdateIngressRulesRequest; +use Google\Cloud\AppEngine\V1\BatchUpdateIngressRulesResponse; +use Google\Cloud\AppEngine\V1\CreateIngressRuleRequest; +use Google\Cloud\AppEngine\V1\DeleteIngressRuleRequest; +use Google\Cloud\AppEngine\V1\FirewallRule; +use Google\Cloud\AppEngine\V1\GetIngressRuleRequest; +use Google\Cloud\AppEngine\V1\ListIngressRulesRequest; +use Google\Cloud\AppEngine\V1\UpdateIngressRuleRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Firewall resources are used to define a collection of access control rules + * for an Application. Each rule is defined with a position which specifies + * the rule's order in the sequence of rules, an IP range to be matched against + * requests, and an action to take upon matching requests. * - * This class is currently experimental and may be subject to changes. + * Every request is evaluated against the Firewall rules in priority order. + * Processesing stops at the first rule which matches the request's IP address. + * A final rule always specifies an action that applies to all remaining + * IP addresses. The default final rule for a newly-created application will be + * set to "allow" if not otherwise specified by the user. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AppEngine\V1\FirewallClient} for the stable implementation * * @experimental + * + * @method PromiseInterface batchUpdateIngressRulesAsync(BatchUpdateIngressRulesRequest $request, array $optionalArgs = []) + * @method PromiseInterface createIngressRuleAsync(CreateIngressRuleRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteIngressRuleAsync(DeleteIngressRuleRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIngressRuleAsync(GetIngressRuleRequest $request, array $optionalArgs = []) + * @method PromiseInterface listIngressRulesAsync(ListIngressRulesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateIngressRuleAsync(UpdateIngressRuleRequest $request, array $optionalArgs = []) */ -final class FirewallClient extends FirewallBaseClient +final class FirewallClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see FirewallBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.appengine.v1.Firewall'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'appengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/appengine.admin', + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/firewall_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/firewall_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/firewall_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/firewall_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'appengine.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Replaces the entire firewall ruleset in one bulk operation. This overrides + * and replaces the rules of an existing firewall with the new rules. + * + * If the final rule does not match traffic with the '*' wildcard IP range, + * then an "allow all" rule is explicitly added to the end of the list. + * + * The async variant is {@see FirewallClient::batchUpdateIngressRulesAsync()} . + * + * @param BatchUpdateIngressRulesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BatchUpdateIngressRulesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchUpdateIngressRules(BatchUpdateIngressRulesRequest $request, array $callOptions = []): BatchUpdateIngressRulesResponse + { + return $this->startApiCall('BatchUpdateIngressRules', $request, $callOptions)->wait(); + } + + /** + * Creates a firewall rule for the application. + * + * The async variant is {@see FirewallClient::createIngressRuleAsync()} . + * + * @param CreateIngressRuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FirewallRule + * + * @throws ApiException Thrown if the API call fails. + */ + public function createIngressRule(CreateIngressRuleRequest $request, array $callOptions = []): FirewallRule + { + return $this->startApiCall('CreateIngressRule', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified firewall rule. + * + * The async variant is {@see FirewallClient::deleteIngressRuleAsync()} . + * + * @param DeleteIngressRuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteIngressRule(DeleteIngressRuleRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteIngressRule', $request, $callOptions)->wait(); + } + + /** + * Gets the specified firewall rule. + * + * The async variant is {@see FirewallClient::getIngressRuleAsync()} . + * + * @param GetIngressRuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FirewallRule + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIngressRule(GetIngressRuleRequest $request, array $callOptions = []): FirewallRule + { + return $this->startApiCall('GetIngressRule', $request, $callOptions)->wait(); + } + + /** + * Lists the firewall rules of an application. + * + * The async variant is {@see FirewallClient::listIngressRulesAsync()} . + * + * @param ListIngressRulesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listIngressRules(ListIngressRulesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListIngressRules', $request, $callOptions); + } + + /** + * Updates the specified firewall rule. + * + * The async variant is {@see FirewallClient::updateIngressRuleAsync()} . + * + * @param UpdateIngressRuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FirewallRule + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateIngressRule(UpdateIngressRuleRequest $request, array $callOptions = []): FirewallRule + { + return $this->startApiCall('UpdateIngressRule', $request, $callOptions)->wait(); + } } diff --git a/AppEngineAdmin/src/V1/Client/InstancesClient.php b/AppEngineAdmin/src/V1/Client/InstancesClient.php index cfa45999cafe..7b2c123925db 100644 --- a/AppEngineAdmin/src/V1/Client/InstancesClient.php +++ b/AppEngineAdmin/src/V1/Client/InstancesClient.php @@ -24,17 +24,299 @@ namespace Google\Cloud\AppEngine\V1\Client; -use Google\Cloud\AppEngine\V1\Client\BaseClient\InstancesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AppEngine\V1\DebugInstanceRequest; +use Google\Cloud\AppEngine\V1\DeleteInstanceRequest; +use Google\Cloud\AppEngine\V1\GetInstanceRequest; +use Google\Cloud\AppEngine\V1\Instance; +use Google\Cloud\AppEngine\V1\ListInstancesRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Manages instances of a version. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AppEngine\V1\InstancesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface debugInstanceAsync(DebugInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteInstanceAsync(DeleteInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInstanceAsync(GetInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInstancesAsync(ListInstancesRequest $request, array $optionalArgs = []) */ -final class InstancesClient extends InstancesBaseClient +final class InstancesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see InstancesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.appengine.v1.Instances'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'appengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/appengine.admin', + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/instances_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/instances_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/instances_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/instances_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'appengine.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Enables debugging on a VM instance. This allows you to use the SSH + * command to connect to the virtual machine where the instance lives. + * While in "debug mode", the instance continues to serve live traffic. + * You should delete the instance when you are done debugging and then + * allow the system to take over and determine if another instance + * should be started. + * + * Only applicable for instances in App Engine flexible environment. + * + * The async variant is {@see InstancesClient::debugInstanceAsync()} . + * + * @param DebugInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function debugInstance(DebugInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DebugInstance', $request, $callOptions)->wait(); + } + + /** + * Stops a running instance. + * + * The instance might be automatically recreated based on the scaling settings + * of the version. For more information, see "How Instances are Managed" + * ([standard environment](https://cloud.google.com/appengine/docs/standard/python/how-instances-are-managed) | + * [flexible environment](https://cloud.google.com/appengine/docs/flexible/python/how-instances-are-managed)). + * + * To ensure that instances are not re-created and avoid getting billed, you + * can stop all instances within the target version by changing the serving + * status of the version to `STOPPED` with the + * [`apps.services.versions.patch`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions/patch) + * method. + * + * The async variant is {@see InstancesClient::deleteInstanceAsync()} . + * + * @param DeleteInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); + } + + /** + * Gets instance information. + * + * The async variant is {@see InstancesClient::getInstanceAsync()} . + * + * @param GetInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Instance + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance + { + return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); + } + + /** + * Lists the instances of a version. + * + * Tip: To aggregate details about instances over time, see the + * [Stackdriver Monitoring API](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list). + * + * The async variant is {@see InstancesClient::listInstancesAsync()} . + * + * @param ListInstancesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInstances(ListInstancesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInstances', $request, $callOptions); + } } diff --git a/AppEngineAdmin/src/V1/Client/ServicesClient.php b/AppEngineAdmin/src/V1/Client/ServicesClient.php index 9cdf99a1b634..2790f0c67bfb 100644 --- a/AppEngineAdmin/src/V1/Client/ServicesClient.php +++ b/AppEngineAdmin/src/V1/Client/ServicesClient.php @@ -24,17 +24,278 @@ namespace Google\Cloud\AppEngine\V1\Client; -use Google\Cloud\AppEngine\V1\Client\BaseClient\ServicesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AppEngine\V1\DeleteServiceRequest; +use Google\Cloud\AppEngine\V1\GetServiceRequest; +use Google\Cloud\AppEngine\V1\ListServicesRequest; +use Google\Cloud\AppEngine\V1\Service; +use Google\Cloud\AppEngine\V1\UpdateServiceRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Manages services of an application. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AppEngine\V1\ServicesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface deleteServiceAsync(DeleteServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getServiceAsync(GetServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface listServicesAsync(ListServicesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateServiceAsync(UpdateServiceRequest $request, array $optionalArgs = []) */ -final class ServicesClient extends ServicesBaseClient +final class ServicesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ServicesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.appengine.v1.Services'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'appengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/appengine.admin', + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/services_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/services_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/services_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/services_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'appengine.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified service and all enclosed versions. + * + * The async variant is {@see ServicesClient::deleteServiceAsync()} . + * + * @param DeleteServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteService(DeleteServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteService', $request, $callOptions)->wait(); + } + + /** + * Gets the current configuration of the specified service. + * + * The async variant is {@see ServicesClient::getServiceAsync()} . + * + * @param GetServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Service + * + * @throws ApiException Thrown if the API call fails. + */ + public function getService(GetServiceRequest $request, array $callOptions = []): Service + { + return $this->startApiCall('GetService', $request, $callOptions)->wait(); + } + + /** + * Lists all the services in the application. + * + * The async variant is {@see ServicesClient::listServicesAsync()} . + * + * @param ListServicesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listServices(ListServicesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListServices', $request, $callOptions); + } + + /** + * Updates the configuration of the specified service. + * + * The async variant is {@see ServicesClient::updateServiceAsync()} . + * + * @param UpdateServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateService(UpdateServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateService', $request, $callOptions)->wait(); + } } diff --git a/AppEngineAdmin/src/V1/Client/VersionsClient.php b/AppEngineAdmin/src/V1/Client/VersionsClient.php index 42a99d8c7211..5107b5424025 100644 --- a/AppEngineAdmin/src/V1/Client/VersionsClient.php +++ b/AppEngineAdmin/src/V1/Client/VersionsClient.php @@ -24,17 +24,341 @@ namespace Google\Cloud\AppEngine\V1\Client; -use Google\Cloud\AppEngine\V1\Client\BaseClient\VersionsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AppEngine\V1\CreateVersionRequest; +use Google\Cloud\AppEngine\V1\DeleteVersionRequest; +use Google\Cloud\AppEngine\V1\GetVersionRequest; +use Google\Cloud\AppEngine\V1\ListVersionsRequest; +use Google\Cloud\AppEngine\V1\UpdateVersionRequest; +use Google\Cloud\AppEngine\V1\Version; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Manages versions of a service. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AppEngine\V1\VersionsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createVersionAsync(CreateVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteVersionAsync(DeleteVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getVersionAsync(GetVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface listVersionsAsync(ListVersionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateVersionAsync(UpdateVersionRequest $request, array $optionalArgs = []) */ -final class VersionsClient extends VersionsBaseClient +final class VersionsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see VersionsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.appengine.v1.Versions'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'appengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/appengine.admin', + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/versions_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/versions_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/versions_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/versions_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'appengine.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deploys code and resource files to a new version. + * + * The async variant is {@see VersionsClient::createVersionAsync()} . + * + * @param CreateVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createVersion(CreateVersionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateVersion', $request, $callOptions)->wait(); + } + + /** + * Deletes an existing Version resource. + * + * The async variant is {@see VersionsClient::deleteVersionAsync()} . + * + * @param DeleteVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteVersion(DeleteVersionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteVersion', $request, $callOptions)->wait(); + } + + /** + * Gets the specified Version resource. + * By default, only a `BASIC_VIEW` will be returned. + * Specify the `FULL_VIEW` parameter to get the full resource. + * + * The async variant is {@see VersionsClient::getVersionAsync()} . + * + * @param GetVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Version + * + * @throws ApiException Thrown if the API call fails. + */ + public function getVersion(GetVersionRequest $request, array $callOptions = []): Version + { + return $this->startApiCall('GetVersion', $request, $callOptions)->wait(); + } + + /** + * Lists the versions of a service. + * + * The async variant is {@see VersionsClient::listVersionsAsync()} . + * + * @param ListVersionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listVersions(ListVersionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListVersions', $request, $callOptions); + } + + /** + * Updates the specified Version resource. + * You can specify the following fields depending on the App Engine + * environment and type of scaling that the version resource uses: + * + * **Standard environment** + * + * * [`instance_class`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.instance_class) + * + * *automatic scaling* in the standard environment: + * + * * [`automatic_scaling.min_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) + * * [`automatic_scaling.max_idle_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) + * * [`automaticScaling.standard_scheduler_settings.max_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) + * * [`automaticScaling.standard_scheduler_settings.min_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) + * * [`automaticScaling.standard_scheduler_settings.target_cpu_utilization`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) + * * [`automaticScaling.standard_scheduler_settings.target_throughput_utilization`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#StandardSchedulerSettings) + * + * *basic scaling* or *manual scaling* in the standard environment: + * + * * [`serving_status`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.serving_status) + * * [`manual_scaling.instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#manualscaling) + * + * **Flexible environment** + * + * * [`serving_status`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.serving_status) + * + * *automatic scaling* in the flexible environment: + * + * * [`automatic_scaling.min_total_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) + * * [`automatic_scaling.max_total_instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) + * * [`automatic_scaling.cool_down_period_sec`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) + * * [`automatic_scaling.cpu_utilization.target_utilization`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version.FIELDS.automatic_scaling) + * + * *manual scaling* in the flexible environment: + * + * * [`manual_scaling.instances`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#manualscaling) + * + * The async variant is {@see VersionsClient::updateVersionAsync()} . + * + * @param UpdateVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateVersion(UpdateVersionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateVersion', $request, $callOptions)->wait(); + } } diff --git a/ArtifactRegistry/composer.json b/ArtifactRegistry/composer.json index 5cf3d5ac1369..9b870125d28b 100644 --- a/ArtifactRegistry/composer.json +++ b/ArtifactRegistry/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/ArtifactRegistry/src/V1/Client/ArtifactRegistryClient.php b/ArtifactRegistry/src/V1/Client/ArtifactRegistryClient.php index ec8ed1d88097..eb8fbabb168c 100644 --- a/ArtifactRegistry/src/V1/Client/ArtifactRegistryClient.php +++ b/ArtifactRegistry/src/V1/Client/ArtifactRegistryClient.php @@ -24,17 +24,1501 @@ namespace Google\Cloud\ArtifactRegistry\V1\Client; -use Google\Cloud\ArtifactRegistry\V1\Client\BaseClient\ArtifactRegistryBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\ArtifactRegistry\V1\CreateRepositoryRequest; +use Google\Cloud\ArtifactRegistry\V1\CreateTagRequest; +use Google\Cloud\ArtifactRegistry\V1\DeletePackageRequest; +use Google\Cloud\ArtifactRegistry\V1\DeleteRepositoryRequest; +use Google\Cloud\ArtifactRegistry\V1\DeleteTagRequest; +use Google\Cloud\ArtifactRegistry\V1\DeleteVersionRequest; +use Google\Cloud\ArtifactRegistry\V1\DockerImage; +use Google\Cloud\ArtifactRegistry\V1\File; +use Google\Cloud\ArtifactRegistry\V1\GetDockerImageRequest; +use Google\Cloud\ArtifactRegistry\V1\GetFileRequest; +use Google\Cloud\ArtifactRegistry\V1\GetMavenArtifactRequest; +use Google\Cloud\ArtifactRegistry\V1\GetNpmPackageRequest; +use Google\Cloud\ArtifactRegistry\V1\GetPackageRequest; +use Google\Cloud\ArtifactRegistry\V1\GetProjectSettingsRequest; +use Google\Cloud\ArtifactRegistry\V1\GetPythonPackageRequest; +use Google\Cloud\ArtifactRegistry\V1\GetRepositoryRequest; +use Google\Cloud\ArtifactRegistry\V1\GetTagRequest; +use Google\Cloud\ArtifactRegistry\V1\GetVPCSCConfigRequest; +use Google\Cloud\ArtifactRegistry\V1\GetVersionRequest; +use Google\Cloud\ArtifactRegistry\V1\ImportAptArtifactsRequest; +use Google\Cloud\ArtifactRegistry\V1\ImportYumArtifactsRequest; +use Google\Cloud\ArtifactRegistry\V1\ListDockerImagesRequest; +use Google\Cloud\ArtifactRegistry\V1\ListFilesRequest; +use Google\Cloud\ArtifactRegistry\V1\ListMavenArtifactsRequest; +use Google\Cloud\ArtifactRegistry\V1\ListNpmPackagesRequest; +use Google\Cloud\ArtifactRegistry\V1\ListPackagesRequest; +use Google\Cloud\ArtifactRegistry\V1\ListPythonPackagesRequest; +use Google\Cloud\ArtifactRegistry\V1\ListRepositoriesRequest; +use Google\Cloud\ArtifactRegistry\V1\ListTagsRequest; +use Google\Cloud\ArtifactRegistry\V1\ListVersionsRequest; +use Google\Cloud\ArtifactRegistry\V1\MavenArtifact; +use Google\Cloud\ArtifactRegistry\V1\NpmPackage; +use Google\Cloud\ArtifactRegistry\V1\Package; +use Google\Cloud\ArtifactRegistry\V1\ProjectSettings; +use Google\Cloud\ArtifactRegistry\V1\PythonPackage; +use Google\Cloud\ArtifactRegistry\V1\Repository; +use Google\Cloud\ArtifactRegistry\V1\Tag; +use Google\Cloud\ArtifactRegistry\V1\UpdateProjectSettingsRequest; +use Google\Cloud\ArtifactRegistry\V1\UpdateRepositoryRequest; +use Google\Cloud\ArtifactRegistry\V1\UpdateTagRequest; +use Google\Cloud\ArtifactRegistry\V1\UpdateVPCSCConfigRequest; +use Google\Cloud\ArtifactRegistry\V1\VPCSCConfig; +use Google\Cloud\ArtifactRegistry\V1\Version; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Artifact Registry API service. + * + * Artifact Registry is an artifact management system for storing artifacts + * from different package management systems. + * + * The resources managed by this API are: + * + * * Repositories, which group packages and their data. + * * Packages, which group versions and their tags. + * * Versions, which are specific forms of a package. + * * Tags, which represent alternative names for versions. + * * Files, which contain content and are optionally associated with a Package + * or Version. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createRepositoryAsync(CreateRepositoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface createTagAsync(CreateTagRequest $request, array $optionalArgs = []) + * @method PromiseInterface deletePackageAsync(DeletePackageRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteRepositoryAsync(DeleteRepositoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTagAsync(DeleteTagRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteVersionAsync(DeleteVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDockerImageAsync(GetDockerImageRequest $request, array $optionalArgs = []) + * @method PromiseInterface getFileAsync(GetFileRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getMavenArtifactAsync(GetMavenArtifactRequest $request, array $optionalArgs = []) + * @method PromiseInterface getNpmPackageAsync(GetNpmPackageRequest $request, array $optionalArgs = []) + * @method PromiseInterface getPackageAsync(GetPackageRequest $request, array $optionalArgs = []) + * @method PromiseInterface getProjectSettingsAsync(GetProjectSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getPythonPackageAsync(GetPythonPackageRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRepositoryAsync(GetRepositoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTagAsync(GetTagRequest $request, array $optionalArgs = []) + * @method PromiseInterface getVPCSCConfigAsync(GetVPCSCConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getVersionAsync(GetVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface importAptArtifactsAsync(ImportAptArtifactsRequest $request, array $optionalArgs = []) + * @method PromiseInterface importYumArtifactsAsync(ImportYumArtifactsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDockerImagesAsync(ListDockerImagesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listFilesAsync(ListFilesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listMavenArtifactsAsync(ListMavenArtifactsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listNpmPackagesAsync(ListNpmPackagesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPackagesAsync(ListPackagesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPythonPackagesAsync(ListPythonPackagesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listRepositoriesAsync(ListRepositoriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTagsAsync(ListTagsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listVersionsAsync(ListVersionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateProjectSettingsAsync(UpdateProjectSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateRepositoryAsync(UpdateRepositoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateTagAsync(UpdateTagRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateVPCSCConfigAsync(UpdateVPCSCConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class ArtifactRegistryClient extends ArtifactRegistryBaseClient +final class ArtifactRegistryClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ArtifactRegistryBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.devtools.artifactregistry.v1.ArtifactRegistry'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'artifactregistry.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/artifact_registry_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/artifact_registry_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/artifact_registry_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/artifact_registry_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a docker_image + * resource. + * + * @param string $project + * @param string $location + * @param string $repository + * @param string $dockerImage + * + * @return string The formatted docker_image resource. + */ + public static function dockerImageName(string $project, string $location, string $repository, string $dockerImage): string + { + return self::getPathTemplate('dockerImage')->render([ + 'project' => $project, + 'location' => $location, + 'repository' => $repository, + 'docker_image' => $dockerImage, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a file + * resource. + * + * @param string $project + * @param string $location + * @param string $repository + * @param string $file + * + * @return string The formatted file resource. + */ + public static function fileName(string $project, string $location, string $repository, string $file): string + { + return self::getPathTemplate('file')->render([ + 'project' => $project, + 'location' => $location, + 'repository' => $repository, + 'file' => $file, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * maven_artifact resource. + * + * @param string $project + * @param string $location + * @param string $repository + * @param string $mavenArtifact + * + * @return string The formatted maven_artifact resource. + */ + public static function mavenArtifactName(string $project, string $location, string $repository, string $mavenArtifact): string + { + return self::getPathTemplate('mavenArtifact')->render([ + 'project' => $project, + 'location' => $location, + 'repository' => $repository, + 'maven_artifact' => $mavenArtifact, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a npm_package + * resource. + * + * @param string $project + * @param string $location + * @param string $repository + * @param string $npmPackage + * + * @return string The formatted npm_package resource. + */ + public static function npmPackageName(string $project, string $location, string $repository, string $npmPackage): string + { + return self::getPathTemplate('npmPackage')->render([ + 'project' => $project, + 'location' => $location, + 'repository' => $repository, + 'npm_package' => $npmPackage, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a package + * resource. + * + * @param string $project + * @param string $location + * @param string $repository + * @param string $package + * + * @return string The formatted package resource. + */ + public static function packageName(string $project, string $location, string $repository, string $package): string + { + return self::getPathTemplate('package')->render([ + 'project' => $project, + 'location' => $location, + 'repository' => $repository, + 'package' => $package, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_settings resource. + * + * @param string $project + * + * @return string The formatted project_settings resource. + */ + public static function projectSettingsName(string $project): string + { + return self::getPathTemplate('projectSettings')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * python_package resource. + * + * @param string $project + * @param string $location + * @param string $repository + * @param string $pythonPackage + * + * @return string The formatted python_package resource. + */ + public static function pythonPackageName(string $project, string $location, string $repository, string $pythonPackage): string + { + return self::getPathTemplate('pythonPackage')->render([ + 'project' => $project, + 'location' => $location, + 'repository' => $repository, + 'python_package' => $pythonPackage, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a repository + * resource. + * + * @param string $project + * @param string $location + * @param string $repository + * + * @return string The formatted repository resource. + */ + public static function repositoryName(string $project, string $location, string $repository): string + { + return self::getPathTemplate('repository')->render([ + 'project' => $project, + 'location' => $location, + 'repository' => $repository, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a tag + * resource. + * + * @param string $project + * @param string $location + * @param string $repository + * @param string $package + * @param string $tag + * + * @return string The formatted tag resource. + */ + public static function tagName(string $project, string $location, string $repository, string $package, string $tag): string + { + return self::getPathTemplate('tag')->render([ + 'project' => $project, + 'location' => $location, + 'repository' => $repository, + 'package' => $package, + 'tag' => $tag, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a vpcsc_config + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted vpcsc_config resource. + */ + public static function vpcscConfigName(string $project, string $location): string + { + return self::getPathTemplate('vpcscConfig')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - dockerImage: projects/{project}/locations/{location}/repositories/{repository}/dockerImages/{docker_image} + * - file: projects/{project}/locations/{location}/repositories/{repository}/files/{file} + * - location: projects/{project}/locations/{location} + * - mavenArtifact: projects/{project}/locations/{location}/repositories/{repository}/mavenArtifacts/{maven_artifact} + * - npmPackage: projects/{project}/locations/{location}/repositories/{repository}/npmPackages/{npm_package} + * - package: projects/{project}/locations/{location}/repositories/{repository}/packages/{package} + * - projectSettings: projects/{project}/projectSettings + * - pythonPackage: projects/{project}/locations/{location}/repositories/{repository}/pythonPackages/{python_package} + * - repository: projects/{project}/locations/{location}/repositories/{repository} + * - tag: projects/{project}/locations/{location}/repositories/{repository}/packages/{package}/tags/{tag} + * - vpcscConfig: projects/{project}/locations/{location}/vpcscConfig + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'artifactregistry.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a repository. The returned Operation will finish once the + * repository has been created. Its response will be the created Repository. + * + * The async variant is {@see ArtifactRegistryClient::createRepositoryAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/create_repository.php + * + * @param CreateRepositoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createRepository(CreateRepositoryRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateRepository', $request, $callOptions)->wait(); + } + + /** + * Creates a tag. + * + * The async variant is {@see ArtifactRegistryClient::createTagAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/create_tag.php + * + * @param CreateTagRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Tag + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTag(CreateTagRequest $request, array $callOptions = []): Tag + { + return $this->startApiCall('CreateTag', $request, $callOptions)->wait(); + } + + /** + * Deletes a package and all of its versions and tags. The returned operation + * will complete once the package has been deleted. + * + * The async variant is {@see ArtifactRegistryClient::deletePackageAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/delete_package.php + * + * @param DeletePackageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deletePackage(DeletePackageRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeletePackage', $request, $callOptions)->wait(); + } + + /** + * Deletes a repository and all of its contents. The returned Operation will + * finish once the repository has been deleted. It will not have any Operation + * metadata and will return a google.protobuf.Empty response. + * + * The async variant is {@see ArtifactRegistryClient::deleteRepositoryAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/delete_repository.php + * + * @param DeleteRepositoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteRepository(DeleteRepositoryRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteRepository', $request, $callOptions)->wait(); + } + + /** + * Deletes a tag. + * + * The async variant is {@see ArtifactRegistryClient::deleteTagAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/delete_tag.php + * + * @param DeleteTagRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTag(DeleteTagRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteTag', $request, $callOptions)->wait(); + } + + /** + * Deletes a version and all of its content. The returned operation will + * complete once the version has been deleted. + * + * The async variant is {@see ArtifactRegistryClient::deleteVersionAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/delete_version.php + * + * @param DeleteVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteVersion(DeleteVersionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteVersion', $request, $callOptions)->wait(); + } + + /** + * Gets a docker image. + * + * The async variant is {@see ArtifactRegistryClient::getDockerImageAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/get_docker_image.php + * + * @param GetDockerImageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DockerImage + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDockerImage(GetDockerImageRequest $request, array $callOptions = []): DockerImage + { + return $this->startApiCall('GetDockerImage', $request, $callOptions)->wait(); + } + + /** + * Gets a file. + * + * The async variant is {@see ArtifactRegistryClient::getFileAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/get_file.php + * + * @param GetFileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 File + * + * @throws ApiException Thrown if the API call fails. + */ + public function getFile(GetFileRequest $request, array $callOptions = []): File + { + return $this->startApiCall('GetFile', $request, $callOptions)->wait(); + } + + /** + * Gets the IAM policy for a given resource. + * + * The async variant is {@see ArtifactRegistryClient::getIamPolicyAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets a maven artifact. + * + * The async variant is {@see ArtifactRegistryClient::getMavenArtifactAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/get_maven_artifact.php + * + * @param GetMavenArtifactRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MavenArtifact + * + * @throws ApiException Thrown if the API call fails. + */ + public function getMavenArtifact(GetMavenArtifactRequest $request, array $callOptions = []): MavenArtifact + { + return $this->startApiCall('GetMavenArtifact', $request, $callOptions)->wait(); + } + + /** + * Gets a npm package. + * + * The async variant is {@see ArtifactRegistryClient::getNpmPackageAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/get_npm_package.php + * + * @param GetNpmPackageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NpmPackage + * + * @throws ApiException Thrown if the API call fails. + */ + public function getNpmPackage(GetNpmPackageRequest $request, array $callOptions = []): NpmPackage + { + return $this->startApiCall('GetNpmPackage', $request, $callOptions)->wait(); + } + + /** + * Gets a package. + * + * The async variant is {@see ArtifactRegistryClient::getPackageAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/get_package.php + * + * @param GetPackageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Package + * + * @throws ApiException Thrown if the API call fails. + */ + public function getPackage(GetPackageRequest $request, array $callOptions = []): Package + { + return $this->startApiCall('GetPackage', $request, $callOptions)->wait(); + } + + /** + * Retrieves the Settings for the Project. + * + * The async variant is {@see ArtifactRegistryClient::getProjectSettingsAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/get_project_settings.php + * + * @param GetProjectSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ProjectSettings + * + * @throws ApiException Thrown if the API call fails. + */ + public function getProjectSettings(GetProjectSettingsRequest $request, array $callOptions = []): ProjectSettings + { + return $this->startApiCall('GetProjectSettings', $request, $callOptions)->wait(); + } + + /** + * Gets a python package. + * + * The async variant is {@see ArtifactRegistryClient::getPythonPackageAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/get_python_package.php + * + * @param GetPythonPackageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PythonPackage + * + * @throws ApiException Thrown if the API call fails. + */ + public function getPythonPackage(GetPythonPackageRequest $request, array $callOptions = []): PythonPackage + { + return $this->startApiCall('GetPythonPackage', $request, $callOptions)->wait(); + } + + /** + * Gets a repository. + * + * The async variant is {@see ArtifactRegistryClient::getRepositoryAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/get_repository.php + * + * @param GetRepositoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Repository + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRepository(GetRepositoryRequest $request, array $callOptions = []): Repository + { + return $this->startApiCall('GetRepository', $request, $callOptions)->wait(); + } + + /** + * Gets a tag. + * + * The async variant is {@see ArtifactRegistryClient::getTagAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/get_tag.php + * + * @param GetTagRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Tag + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTag(GetTagRequest $request, array $callOptions = []): Tag + { + return $this->startApiCall('GetTag', $request, $callOptions)->wait(); + } + + /** + * Retrieves the VPCSC Config for the Project. + * + * The async variant is {@see ArtifactRegistryClient::getVPCSCConfigAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/get_vpcsc_config.php + * + * @param GetVPCSCConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 VPCSCConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getVPCSCConfig(GetVPCSCConfigRequest $request, array $callOptions = []): VPCSCConfig + { + return $this->startApiCall('GetVPCSCConfig', $request, $callOptions)->wait(); + } + + /** + * Gets a version + * + * The async variant is {@see ArtifactRegistryClient::getVersionAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/get_version.php + * + * @param GetVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Version + * + * @throws ApiException Thrown if the API call fails. + */ + public function getVersion(GetVersionRequest $request, array $callOptions = []): Version + { + return $this->startApiCall('GetVersion', $request, $callOptions)->wait(); + } + + /** + * Imports Apt artifacts. The returned Operation will complete once the + * resources are imported. Package, Version, and File resources are created + * based on the imported artifacts. Imported artifacts that conflict with + * existing resources are ignored. + * + * The async variant is {@see ArtifactRegistryClient::importAptArtifactsAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/import_apt_artifacts.php + * + * @param ImportAptArtifactsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importAptArtifacts(ImportAptArtifactsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportAptArtifacts', $request, $callOptions)->wait(); + } + + /** + * Imports Yum (RPM) artifacts. The returned Operation will complete once the + * resources are imported. Package, Version, and File resources are created + * based on the imported artifacts. Imported artifacts that conflict with + * existing resources are ignored. + * + * The async variant is {@see ArtifactRegistryClient::importYumArtifactsAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/import_yum_artifacts.php + * + * @param ImportYumArtifactsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importYumArtifacts(ImportYumArtifactsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportYumArtifacts', $request, $callOptions)->wait(); + } + + /** + * Lists docker images. + * + * The async variant is {@see ArtifactRegistryClient::listDockerImagesAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/list_docker_images.php + * + * @param ListDockerImagesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDockerImages(ListDockerImagesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDockerImages', $request, $callOptions); + } + + /** + * Lists files. + * + * The async variant is {@see ArtifactRegistryClient::listFilesAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/list_files.php + * + * @param ListFilesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listFiles(ListFilesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListFiles', $request, $callOptions); + } + + /** + * Lists maven artifacts. + * + * The async variant is {@see ArtifactRegistryClient::listMavenArtifactsAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/list_maven_artifacts.php + * + * @param ListMavenArtifactsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listMavenArtifacts(ListMavenArtifactsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListMavenArtifacts', $request, $callOptions); + } + + /** + * Lists npm packages. + * + * The async variant is {@see ArtifactRegistryClient::listNpmPackagesAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/list_npm_packages.php + * + * @param ListNpmPackagesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listNpmPackages(ListNpmPackagesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListNpmPackages', $request, $callOptions); + } + + /** + * Lists packages. + * + * The async variant is {@see ArtifactRegistryClient::listPackagesAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/list_packages.php + * + * @param ListPackagesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPackages(ListPackagesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPackages', $request, $callOptions); + } + + /** + * Lists python packages. + * + * The async variant is {@see ArtifactRegistryClient::listPythonPackagesAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/list_python_packages.php + * + * @param ListPythonPackagesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPythonPackages(ListPythonPackagesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPythonPackages', $request, $callOptions); + } + + /** + * Lists repositories. + * + * The async variant is {@see ArtifactRegistryClient::listRepositoriesAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/list_repositories.php + * + * @param ListRepositoriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listRepositories(ListRepositoriesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListRepositories', $request, $callOptions); + } + + /** + * Lists tags. + * + * The async variant is {@see ArtifactRegistryClient::listTagsAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/list_tags.php + * + * @param ListTagsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTags(ListTagsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTags', $request, $callOptions); + } + + /** + * Lists versions. + * + * The async variant is {@see ArtifactRegistryClient::listVersionsAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/list_versions.php + * + * @param ListVersionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listVersions(ListVersionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListVersions', $request, $callOptions); + } + + /** + * Updates the IAM policy for a given resource. + * + * The async variant is {@see ArtifactRegistryClient::setIamPolicyAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Tests if the caller has a list of permissions on a resource. + * + * The async variant is {@see ArtifactRegistryClient::testIamPermissionsAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates the Settings for the Project. + * + * The async variant is {@see ArtifactRegistryClient::updateProjectSettingsAsync()} + * . + * + * @example samples/V1/ArtifactRegistryClient/update_project_settings.php + * + * @param UpdateProjectSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ProjectSettings + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateProjectSettings(UpdateProjectSettingsRequest $request, array $callOptions = []): ProjectSettings + { + return $this->startApiCall('UpdateProjectSettings', $request, $callOptions)->wait(); + } + + /** + * Updates a repository. + * + * The async variant is {@see ArtifactRegistryClient::updateRepositoryAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/update_repository.php + * + * @param UpdateRepositoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Repository + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateRepository(UpdateRepositoryRequest $request, array $callOptions = []): Repository + { + return $this->startApiCall('UpdateRepository', $request, $callOptions)->wait(); + } + + /** + * Updates a tag. + * + * The async variant is {@see ArtifactRegistryClient::updateTagAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/update_tag.php + * + * @param UpdateTagRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Tag + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTag(UpdateTagRequest $request, array $callOptions = []): Tag + { + return $this->startApiCall('UpdateTag', $request, $callOptions)->wait(); + } + + /** + * Updates the VPCSC Config for the Project. + * + * The async variant is {@see ArtifactRegistryClient::updateVPCSCConfigAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/update_vpcsc_config.php + * + * @param UpdateVPCSCConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 VPCSCConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateVPCSCConfig(UpdateVPCSCConfigRequest $request, array $callOptions = []): VPCSCConfig + { + return $this->startApiCall('UpdateVPCSCConfig', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see ArtifactRegistryClient::getLocationAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see ArtifactRegistryClient::listLocationsAsync()} . + * + * @example samples/V1/ArtifactRegistryClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/ArtifactRegistry/src/V1/Client/BaseClient/ArtifactRegistryBaseClient.php b/ArtifactRegistry/src/V1/Client/BaseClient/ArtifactRegistryBaseClient.php deleted file mode 100644 index 1f0e55f85f77..000000000000 --- a/ArtifactRegistry/src/V1/Client/BaseClient/ArtifactRegistryBaseClient.php +++ /dev/null @@ -1,1525 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/artifact_registry_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/artifact_registry_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/artifact_registry_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/artifact_registry_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a docker_image - * resource. - * - * @param string $project - * @param string $location - * @param string $repository - * @param string $dockerImage - * - * @return string The formatted docker_image resource. - */ - public static function dockerImageName(string $project, string $location, string $repository, string $dockerImage): string - { - return self::getPathTemplate('dockerImage')->render([ - 'project' => $project, - 'location' => $location, - 'repository' => $repository, - 'docker_image' => $dockerImage, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a file - * resource. - * - * @param string $project - * @param string $location - * @param string $repository - * @param string $file - * - * @return string The formatted file resource. - */ - public static function fileName(string $project, string $location, string $repository, string $file): string - { - return self::getPathTemplate('file')->render([ - 'project' => $project, - 'location' => $location, - 'repository' => $repository, - 'file' => $file, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * maven_artifact resource. - * - * @param string $project - * @param string $location - * @param string $repository - * @param string $mavenArtifact - * - * @return string The formatted maven_artifact resource. - */ - public static function mavenArtifactName(string $project, string $location, string $repository, string $mavenArtifact): string - { - return self::getPathTemplate('mavenArtifact')->render([ - 'project' => $project, - 'location' => $location, - 'repository' => $repository, - 'maven_artifact' => $mavenArtifact, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a npm_package - * resource. - * - * @param string $project - * @param string $location - * @param string $repository - * @param string $npmPackage - * - * @return string The formatted npm_package resource. - */ - public static function npmPackageName(string $project, string $location, string $repository, string $npmPackage): string - { - return self::getPathTemplate('npmPackage')->render([ - 'project' => $project, - 'location' => $location, - 'repository' => $repository, - 'npm_package' => $npmPackage, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a package - * resource. - * - * @param string $project - * @param string $location - * @param string $repository - * @param string $package - * - * @return string The formatted package resource. - */ - public static function packageName(string $project, string $location, string $repository, string $package): string - { - return self::getPathTemplate('package')->render([ - 'project' => $project, - 'location' => $location, - 'repository' => $repository, - 'package' => $package, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_settings resource. - * - * @param string $project - * - * @return string The formatted project_settings resource. - */ - public static function projectSettingsName(string $project): string - { - return self::getPathTemplate('projectSettings')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * python_package resource. - * - * @param string $project - * @param string $location - * @param string $repository - * @param string $pythonPackage - * - * @return string The formatted python_package resource. - */ - public static function pythonPackageName(string $project, string $location, string $repository, string $pythonPackage): string - { - return self::getPathTemplate('pythonPackage')->render([ - 'project' => $project, - 'location' => $location, - 'repository' => $repository, - 'python_package' => $pythonPackage, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a repository - * resource. - * - * @param string $project - * @param string $location - * @param string $repository - * - * @return string The formatted repository resource. - */ - public static function repositoryName(string $project, string $location, string $repository): string - { - return self::getPathTemplate('repository')->render([ - 'project' => $project, - 'location' => $location, - 'repository' => $repository, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a tag - * resource. - * - * @param string $project - * @param string $location - * @param string $repository - * @param string $package - * @param string $tag - * - * @return string The formatted tag resource. - */ - public static function tagName(string $project, string $location, string $repository, string $package, string $tag): string - { - return self::getPathTemplate('tag')->render([ - 'project' => $project, - 'location' => $location, - 'repository' => $repository, - 'package' => $package, - 'tag' => $tag, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a vpcsc_config - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted vpcsc_config resource. - */ - public static function vpcscConfigName(string $project, string $location): string - { - return self::getPathTemplate('vpcscConfig')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - dockerImage: projects/{project}/locations/{location}/repositories/{repository}/dockerImages/{docker_image} - * - file: projects/{project}/locations/{location}/repositories/{repository}/files/{file} - * - location: projects/{project}/locations/{location} - * - mavenArtifact: projects/{project}/locations/{location}/repositories/{repository}/mavenArtifacts/{maven_artifact} - * - npmPackage: projects/{project}/locations/{location}/repositories/{repository}/npmPackages/{npm_package} - * - package: projects/{project}/locations/{location}/repositories/{repository}/packages/{package} - * - projectSettings: projects/{project}/projectSettings - * - pythonPackage: projects/{project}/locations/{location}/repositories/{repository}/pythonPackages/{python_package} - * - repository: projects/{project}/locations/{location}/repositories/{repository} - * - tag: projects/{project}/locations/{location}/repositories/{repository}/packages/{package}/tags/{tag} - * - vpcscConfig: projects/{project}/locations/{location}/vpcscConfig - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'artifactregistry.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a repository. The returned Operation will finish once the - * repository has been created. Its response will be the created Repository. - * - * The async variant is {@see self::createRepositoryAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/create_repository.php - * - * @param CreateRepositoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createRepository(CreateRepositoryRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateRepository', $request, $callOptions)->wait(); - } - - /** - * Creates a tag. - * - * The async variant is {@see self::createTagAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/create_tag.php - * - * @param CreateTagRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Tag - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTag(CreateTagRequest $request, array $callOptions = []): Tag - { - return $this->startApiCall('CreateTag', $request, $callOptions)->wait(); - } - - /** - * Deletes a package and all of its versions and tags. The returned operation - * will complete once the package has been deleted. - * - * The async variant is {@see self::deletePackageAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/delete_package.php - * - * @param DeletePackageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deletePackage(DeletePackageRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeletePackage', $request, $callOptions)->wait(); - } - - /** - * Deletes a repository and all of its contents. The returned Operation will - * finish once the repository has been deleted. It will not have any Operation - * metadata and will return a google.protobuf.Empty response. - * - * The async variant is {@see self::deleteRepositoryAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/delete_repository.php - * - * @param DeleteRepositoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteRepository(DeleteRepositoryRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteRepository', $request, $callOptions)->wait(); - } - - /** - * Deletes a tag. - * - * The async variant is {@see self::deleteTagAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/delete_tag.php - * - * @param DeleteTagRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTag(DeleteTagRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteTag', $request, $callOptions)->wait(); - } - - /** - * Deletes a version and all of its content. The returned operation will - * complete once the version has been deleted. - * - * The async variant is {@see self::deleteVersionAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/delete_version.php - * - * @param DeleteVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteVersion(DeleteVersionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteVersion', $request, $callOptions)->wait(); - } - - /** - * Gets a docker image. - * - * The async variant is {@see self::getDockerImageAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/get_docker_image.php - * - * @param GetDockerImageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DockerImage - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDockerImage(GetDockerImageRequest $request, array $callOptions = []): DockerImage - { - return $this->startApiCall('GetDockerImage', $request, $callOptions)->wait(); - } - - /** - * Gets a file. - * - * The async variant is {@see self::getFileAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/get_file.php - * - * @param GetFileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 File - * - * @throws ApiException Thrown if the API call fails. - */ - public function getFile(GetFileRequest $request, array $callOptions = []): File - { - return $this->startApiCall('GetFile', $request, $callOptions)->wait(); - } - - /** - * Gets the IAM policy for a given resource. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets a maven artifact. - * - * The async variant is {@see self::getMavenArtifactAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/get_maven_artifact.php - * - * @param GetMavenArtifactRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MavenArtifact - * - * @throws ApiException Thrown if the API call fails. - */ - public function getMavenArtifact(GetMavenArtifactRequest $request, array $callOptions = []): MavenArtifact - { - return $this->startApiCall('GetMavenArtifact', $request, $callOptions)->wait(); - } - - /** - * Gets a npm package. - * - * The async variant is {@see self::getNpmPackageAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/get_npm_package.php - * - * @param GetNpmPackageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NpmPackage - * - * @throws ApiException Thrown if the API call fails. - */ - public function getNpmPackage(GetNpmPackageRequest $request, array $callOptions = []): NpmPackage - { - return $this->startApiCall('GetNpmPackage', $request, $callOptions)->wait(); - } - - /** - * Gets a package. - * - * The async variant is {@see self::getPackageAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/get_package.php - * - * @param GetPackageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Package - * - * @throws ApiException Thrown if the API call fails. - */ - public function getPackage(GetPackageRequest $request, array $callOptions = []): Package - { - return $this->startApiCall('GetPackage', $request, $callOptions)->wait(); - } - - /** - * Retrieves the Settings for the Project. - * - * The async variant is {@see self::getProjectSettingsAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/get_project_settings.php - * - * @param GetProjectSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ProjectSettings - * - * @throws ApiException Thrown if the API call fails. - */ - public function getProjectSettings(GetProjectSettingsRequest $request, array $callOptions = []): ProjectSettings - { - return $this->startApiCall('GetProjectSettings', $request, $callOptions)->wait(); - } - - /** - * Gets a python package. - * - * The async variant is {@see self::getPythonPackageAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/get_python_package.php - * - * @param GetPythonPackageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PythonPackage - * - * @throws ApiException Thrown if the API call fails. - */ - public function getPythonPackage(GetPythonPackageRequest $request, array $callOptions = []): PythonPackage - { - return $this->startApiCall('GetPythonPackage', $request, $callOptions)->wait(); - } - - /** - * Gets a repository. - * - * The async variant is {@see self::getRepositoryAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/get_repository.php - * - * @param GetRepositoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Repository - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRepository(GetRepositoryRequest $request, array $callOptions = []): Repository - { - return $this->startApiCall('GetRepository', $request, $callOptions)->wait(); - } - - /** - * Gets a tag. - * - * The async variant is {@see self::getTagAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/get_tag.php - * - * @param GetTagRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Tag - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTag(GetTagRequest $request, array $callOptions = []): Tag - { - return $this->startApiCall('GetTag', $request, $callOptions)->wait(); - } - - /** - * Retrieves the VPCSC Config for the Project. - * - * The async variant is {@see self::getVPCSCConfigAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/get_vpcsc_config.php - * - * @param GetVPCSCConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 VPCSCConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getVPCSCConfig(GetVPCSCConfigRequest $request, array $callOptions = []): VPCSCConfig - { - return $this->startApiCall('GetVPCSCConfig', $request, $callOptions)->wait(); - } - - /** - * Gets a version - * - * The async variant is {@see self::getVersionAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/get_version.php - * - * @param GetVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Version - * - * @throws ApiException Thrown if the API call fails. - */ - public function getVersion(GetVersionRequest $request, array $callOptions = []): Version - { - return $this->startApiCall('GetVersion', $request, $callOptions)->wait(); - } - - /** - * Imports Apt artifacts. The returned Operation will complete once the - * resources are imported. Package, Version, and File resources are created - * based on the imported artifacts. Imported artifacts that conflict with - * existing resources are ignored. - * - * The async variant is {@see self::importAptArtifactsAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/import_apt_artifacts.php - * - * @param ImportAptArtifactsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function importAptArtifacts(ImportAptArtifactsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ImportAptArtifacts', $request, $callOptions)->wait(); - } - - /** - * Imports Yum (RPM) artifacts. The returned Operation will complete once the - * resources are imported. Package, Version, and File resources are created - * based on the imported artifacts. Imported artifacts that conflict with - * existing resources are ignored. - * - * The async variant is {@see self::importYumArtifactsAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/import_yum_artifacts.php - * - * @param ImportYumArtifactsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function importYumArtifacts(ImportYumArtifactsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ImportYumArtifacts', $request, $callOptions)->wait(); - } - - /** - * Lists docker images. - * - * The async variant is {@see self::listDockerImagesAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/list_docker_images.php - * - * @param ListDockerImagesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDockerImages(ListDockerImagesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDockerImages', $request, $callOptions); - } - - /** - * Lists files. - * - * The async variant is {@see self::listFilesAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/list_files.php - * - * @param ListFilesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listFiles(ListFilesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListFiles', $request, $callOptions); - } - - /** - * Lists maven artifacts. - * - * The async variant is {@see self::listMavenArtifactsAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/list_maven_artifacts.php - * - * @param ListMavenArtifactsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listMavenArtifacts(ListMavenArtifactsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListMavenArtifacts', $request, $callOptions); - } - - /** - * Lists npm packages. - * - * The async variant is {@see self::listNpmPackagesAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/list_npm_packages.php - * - * @param ListNpmPackagesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listNpmPackages(ListNpmPackagesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListNpmPackages', $request, $callOptions); - } - - /** - * Lists packages. - * - * The async variant is {@see self::listPackagesAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/list_packages.php - * - * @param ListPackagesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPackages(ListPackagesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPackages', $request, $callOptions); - } - - /** - * Lists python packages. - * - * The async variant is {@see self::listPythonPackagesAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/list_python_packages.php - * - * @param ListPythonPackagesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPythonPackages(ListPythonPackagesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPythonPackages', $request, $callOptions); - } - - /** - * Lists repositories. - * - * The async variant is {@see self::listRepositoriesAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/list_repositories.php - * - * @param ListRepositoriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listRepositories(ListRepositoriesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListRepositories', $request, $callOptions); - } - - /** - * Lists tags. - * - * The async variant is {@see self::listTagsAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/list_tags.php - * - * @param ListTagsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTags(ListTagsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTags', $request, $callOptions); - } - - /** - * Lists versions. - * - * The async variant is {@see self::listVersionsAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/list_versions.php - * - * @param ListVersionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listVersions(ListVersionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListVersions', $request, $callOptions); - } - - /** - * Updates the IAM policy for a given resource. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Tests if the caller has a list of permissions on a resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Updates the Settings for the Project. - * - * The async variant is {@see self::updateProjectSettingsAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/update_project_settings.php - * - * @param UpdateProjectSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ProjectSettings - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateProjectSettings(UpdateProjectSettingsRequest $request, array $callOptions = []): ProjectSettings - { - return $this->startApiCall('UpdateProjectSettings', $request, $callOptions)->wait(); - } - - /** - * Updates a repository. - * - * The async variant is {@see self::updateRepositoryAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/update_repository.php - * - * @param UpdateRepositoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Repository - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateRepository(UpdateRepositoryRequest $request, array $callOptions = []): Repository - { - return $this->startApiCall('UpdateRepository', $request, $callOptions)->wait(); - } - - /** - * Updates a tag. - * - * The async variant is {@see self::updateTagAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/update_tag.php - * - * @param UpdateTagRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Tag - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateTag(UpdateTagRequest $request, array $callOptions = []): Tag - { - return $this->startApiCall('UpdateTag', $request, $callOptions)->wait(); - } - - /** - * Updates the VPCSC Config for the Project. - * - * The async variant is {@see self::updateVPCSCConfigAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/update_vpcsc_config.php - * - * @param UpdateVPCSCConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 VPCSCConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateVPCSCConfig(UpdateVPCSCConfigRequest $request, array $callOptions = []): VPCSCConfig - { - return $this->startApiCall('UpdateVPCSCConfig', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/ArtifactRegistryClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Asset/composer.json b/Asset/composer.json index 6cb5aecb836b..04ec46ef0cf5 100644 --- a/Asset/composer.json +++ b/Asset/composer.json @@ -26,13 +26,13 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1", + "google/gax": "^1.24.0", "google/access-context-manager": "^0.4", "google/cloud-osconfig": "^1.0" }, "require-dev": { "phpunit/phpunit": "^9.0", - "google/cloud-core": "^1.39" + "google/cloud-core": "^1.52.7" }, "suggest": { "ext-grpc": "Enables use of gRPC, a universal high-performance RPC framework created by Google.", diff --git a/Asset/src/V1/Client/AssetServiceClient.php b/Asset/src/V1/Client/AssetServiceClient.php index 33f0dee91d9f..c853aba9cdf2 100644 --- a/Asset/src/V1/Client/AssetServiceClient.php +++ b/Asset/src/V1/Client/AssetServiceClient.php @@ -24,17 +24,1067 @@ namespace Google\Cloud\Asset\V1\Client; -use Google\Cloud\Asset\V1\Client\BaseClient\AssetServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Asset\V1\AnalyzeIamPolicyLongrunningRequest; +use Google\Cloud\Asset\V1\AnalyzeIamPolicyRequest; +use Google\Cloud\Asset\V1\AnalyzeIamPolicyResponse; +use Google\Cloud\Asset\V1\AnalyzeMoveRequest; +use Google\Cloud\Asset\V1\AnalyzeMoveResponse; +use Google\Cloud\Asset\V1\AnalyzeOrgPoliciesRequest; +use Google\Cloud\Asset\V1\AnalyzeOrgPolicyGovernedAssetsRequest; +use Google\Cloud\Asset\V1\AnalyzeOrgPolicyGovernedContainersRequest; +use Google\Cloud\Asset\V1\BatchGetAssetsHistoryRequest; +use Google\Cloud\Asset\V1\BatchGetAssetsHistoryResponse; +use Google\Cloud\Asset\V1\BatchGetEffectiveIamPoliciesRequest; +use Google\Cloud\Asset\V1\BatchGetEffectiveIamPoliciesResponse; +use Google\Cloud\Asset\V1\CreateFeedRequest; +use Google\Cloud\Asset\V1\CreateSavedQueryRequest; +use Google\Cloud\Asset\V1\DeleteFeedRequest; +use Google\Cloud\Asset\V1\DeleteSavedQueryRequest; +use Google\Cloud\Asset\V1\ExportAssetsRequest; +use Google\Cloud\Asset\V1\Feed; +use Google\Cloud\Asset\V1\GetFeedRequest; +use Google\Cloud\Asset\V1\GetSavedQueryRequest; +use Google\Cloud\Asset\V1\ListAssetsRequest; +use Google\Cloud\Asset\V1\ListFeedsRequest; +use Google\Cloud\Asset\V1\ListFeedsResponse; +use Google\Cloud\Asset\V1\ListSavedQueriesRequest; +use Google\Cloud\Asset\V1\QueryAssetsRequest; +use Google\Cloud\Asset\V1\QueryAssetsResponse; +use Google\Cloud\Asset\V1\SavedQuery; +use Google\Cloud\Asset\V1\SearchAllIamPoliciesRequest; +use Google\Cloud\Asset\V1\SearchAllResourcesRequest; +use Google\Cloud\Asset\V1\UpdateFeedRequest; +use Google\Cloud\Asset\V1\UpdateSavedQueryRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Asset service definition. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Asset\V1\AssetServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface analyzeIamPolicyAsync(AnalyzeIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface analyzeIamPolicyLongrunningAsync(AnalyzeIamPolicyLongrunningRequest $request, array $optionalArgs = []) + * @method PromiseInterface analyzeMoveAsync(AnalyzeMoveRequest $request, array $optionalArgs = []) + * @method PromiseInterface analyzeOrgPoliciesAsync(AnalyzeOrgPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface analyzeOrgPolicyGovernedAssetsAsync(AnalyzeOrgPolicyGovernedAssetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface analyzeOrgPolicyGovernedContainersAsync(AnalyzeOrgPolicyGovernedContainersRequest $request, array $optionalArgs = []) + * @method PromiseInterface batchGetAssetsHistoryAsync(BatchGetAssetsHistoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface batchGetEffectiveIamPoliciesAsync(BatchGetEffectiveIamPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface createFeedAsync(CreateFeedRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSavedQueryAsync(CreateSavedQueryRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteFeedAsync(DeleteFeedRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSavedQueryAsync(DeleteSavedQueryRequest $request, array $optionalArgs = []) + * @method PromiseInterface exportAssetsAsync(ExportAssetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getFeedAsync(GetFeedRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSavedQueryAsync(GetSavedQueryRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAssetsAsync(ListAssetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listFeedsAsync(ListFeedsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSavedQueriesAsync(ListSavedQueriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface queryAssetsAsync(QueryAssetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchAllIamPoliciesAsync(SearchAllIamPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchAllResourcesAsync(SearchAllResourcesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateFeedAsync(UpdateFeedRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSavedQueryAsync(UpdateSavedQueryRequest $request, array $optionalArgs = []) */ -final class AssetServiceClient extends AssetServiceBaseClient +final class AssetServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AssetServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.asset.v1.AssetService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudasset.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/asset_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/asset_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/asset_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/asset_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a feed + * resource. + * + * @param string $project + * @param string $feed + * + * @return string The formatted feed resource. + */ + public static function feedName(string $project, string $feed): string + { + return self::getPathTemplate('feed')->render([ + 'project' => $project, + 'feed' => $feed, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a folder + * resource. + * + * @param string $folder + * + * @return string The formatted folder resource. + */ + public static function folderName(string $folder): string + { + return self::getPathTemplate('folder')->render([ + 'folder' => $folder, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a folder_feed + * resource. + * + * @param string $folder + * @param string $feed + * + * @return string The formatted folder_feed resource. + */ + public static function folderFeedName(string $folder, string $feed): string + { + return self::getPathTemplate('folderFeed')->render([ + 'folder' => $folder, + 'feed' => $feed, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_saved_query resource. + * + * @param string $folder + * @param string $savedQuery + * + * @return string The formatted folder_saved_query resource. + */ + public static function folderSavedQueryName(string $folder, string $savedQuery): string + { + return self::getPathTemplate('folderSavedQuery')->render([ + 'folder' => $folder, + 'saved_query' => $savedQuery, + ]); + } + + /** + * 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(string $organization): string + { + return self::getPathTemplate('organization')->render([ + 'organization' => $organization, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_feed resource. + * + * @param string $organization + * @param string $feed + * + * @return string The formatted organization_feed resource. + */ + public static function organizationFeedName(string $organization, string $feed): string + { + return self::getPathTemplate('organizationFeed')->render([ + 'organization' => $organization, + 'feed' => $feed, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_saved_query resource. + * + * @param string $organization + * @param string $savedQuery + * + * @return string The formatted organization_saved_query resource. + */ + public static function organizationSavedQueryName(string $organization, string $savedQuery): string + { + return self::getPathTemplate('organizationSavedQuery')->render([ + 'organization' => $organization, + 'saved_query' => $savedQuery, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a project_feed + * resource. + * + * @param string $project + * @param string $feed + * + * @return string The formatted project_feed resource. + */ + public static function projectFeedName(string $project, string $feed): string + { + return self::getPathTemplate('projectFeed')->render([ + 'project' => $project, + 'feed' => $feed, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_saved_query resource. + * + * @param string $project + * @param string $savedQuery + * + * @return string The formatted project_saved_query resource. + */ + public static function projectSavedQueryName(string $project, string $savedQuery): string + { + return self::getPathTemplate('projectSavedQuery')->render([ + 'project' => $project, + 'saved_query' => $savedQuery, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a saved_query + * resource. + * + * @param string $project + * @param string $savedQuery + * + * @return string The formatted saved_query resource. + */ + public static function savedQueryName(string $project, string $savedQuery): string + { + return self::getPathTemplate('savedQuery')->render([ + 'project' => $project, + 'saved_query' => $savedQuery, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - feed: projects/{project}/feeds/{feed} + * - folder: folders/{folder} + * - folderFeed: folders/{folder}/feeds/{feed} + * - folderSavedQuery: folders/{folder}/savedQueries/{saved_query} + * - organization: organizations/{organization} + * - organizationFeed: organizations/{organization}/feeds/{feed} + * - organizationSavedQuery: organizations/{organization}/savedQueries/{saved_query} + * - project: projects/{project} + * - projectFeed: projects/{project}/feeds/{feed} + * - projectSavedQuery: projects/{project}/savedQueries/{saved_query} + * - savedQuery: projects/{project}/savedQueries/{saved_query} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudasset.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Analyzes IAM policies to answer which identities have what accesses on + * which resources. + * + * The async variant is {@see AssetServiceClient::analyzeIamPolicyAsync()} . + * + * @param AnalyzeIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AnalyzeIamPolicyResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function analyzeIamPolicy(AnalyzeIamPolicyRequest $request, array $callOptions = []): AnalyzeIamPolicyResponse + { + return $this->startApiCall('AnalyzeIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Analyzes IAM policies asynchronously to answer which identities have what + * accesses on which resources, and writes the analysis results to a Google + * Cloud Storage or a BigQuery destination. For Cloud Storage destination, the + * output format is the JSON format that represents a + * [AnalyzeIamPolicyResponse][google.cloud.asset.v1.AnalyzeIamPolicyResponse]. + * This method implements the + * [google.longrunning.Operation][google.longrunning.Operation], which allows + * you to track the operation status. We recommend intervals of at least 2 + * seconds with exponential backoff retry to poll the operation result. The + * metadata contains the metadata for the long-running operation. + * + * The async variant is + * {@see AssetServiceClient::analyzeIamPolicyLongrunningAsync()} . + * + * @param AnalyzeIamPolicyLongrunningRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function analyzeIamPolicyLongrunning(AnalyzeIamPolicyLongrunningRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AnalyzeIamPolicyLongrunning', $request, $callOptions)->wait(); + } + + /** + * Analyze moving a resource to a specified destination without kicking off + * the actual move. The analysis is best effort depending on the user's + * permissions of viewing different hierarchical policies and configurations. + * The policies and configuration are subject to change before the actual + * resource migration takes place. + * + * The async variant is {@see AssetServiceClient::analyzeMoveAsync()} . + * + * @param AnalyzeMoveRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AnalyzeMoveResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function analyzeMove(AnalyzeMoveRequest $request, array $callOptions = []): AnalyzeMoveResponse + { + return $this->startApiCall('AnalyzeMove', $request, $callOptions)->wait(); + } + + /** + * Analyzes organization policies under a scope. + * + * The async variant is {@see AssetServiceClient::analyzeOrgPoliciesAsync()} . + * + * @param AnalyzeOrgPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function analyzeOrgPolicies(AnalyzeOrgPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AnalyzeOrgPolicies', $request, $callOptions); + } + + /** + * Analyzes organization policies governed assets (Google Cloud resources or + * policies) under a scope. This RPC supports custom constraints and the + * following 10 canned constraints: + * + * * storage.uniformBucketLevelAccess + * * iam.disableServiceAccountKeyCreation + * * iam.allowedPolicyMemberDomains + * * compute.vmExternalIpAccess + * * appengine.enforceServiceAccountActAsCheck + * * gcp.resourceLocations + * * compute.trustedImageProjects + * * compute.skipDefaultNetworkCreation + * * compute.requireOsLogin + * * compute.disableNestedVirtualization + * + * This RPC only returns either resources of types supported by [searchable + * asset + * types](https://cloud.google.com/asset-inventory/docs/supported-asset-types#searchable_asset_types), + * or IAM policies. + * + * The async variant is + * {@see AssetServiceClient::analyzeOrgPolicyGovernedAssetsAsync()} . + * + * @param AnalyzeOrgPolicyGovernedAssetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function analyzeOrgPolicyGovernedAssets(AnalyzeOrgPolicyGovernedAssetsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AnalyzeOrgPolicyGovernedAssets', $request, $callOptions); + } + + /** + * Analyzes organization policies governed containers (projects, folders or + * organization) under a scope. + * + * The async variant is + * {@see AssetServiceClient::analyzeOrgPolicyGovernedContainersAsync()} . + * + * @param AnalyzeOrgPolicyGovernedContainersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function analyzeOrgPolicyGovernedContainers(AnalyzeOrgPolicyGovernedContainersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AnalyzeOrgPolicyGovernedContainers', $request, $callOptions); + } + + /** + * Batch gets the update history of assets that overlap a time window. + * For IAM_POLICY content, this API outputs history when the asset and its + * attached IAM POLICY both exist. This can create gaps in the output history. + * Otherwise, this API outputs history with asset in both non-delete or + * deleted status. + * If a specified asset does not exist, this API returns an INVALID_ARGUMENT + * error. + * + * The async variant is {@see AssetServiceClient::batchGetAssetsHistoryAsync()} . + * + * @param BatchGetAssetsHistoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BatchGetAssetsHistoryResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchGetAssetsHistory(BatchGetAssetsHistoryRequest $request, array $callOptions = []): BatchGetAssetsHistoryResponse + { + return $this->startApiCall('BatchGetAssetsHistory', $request, $callOptions)->wait(); + } + + /** + * Gets effective IAM policies for a batch of resources. + * + * The async variant is + * {@see AssetServiceClient::batchGetEffectiveIamPoliciesAsync()} . + * + * @param BatchGetEffectiveIamPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BatchGetEffectiveIamPoliciesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchGetEffectiveIamPolicies(BatchGetEffectiveIamPoliciesRequest $request, array $callOptions = []): BatchGetEffectiveIamPoliciesResponse + { + return $this->startApiCall('BatchGetEffectiveIamPolicies', $request, $callOptions)->wait(); + } + + /** + * Creates a feed in a parent project/folder/organization to listen to its + * asset updates. + * + * The async variant is {@see AssetServiceClient::createFeedAsync()} . + * + * @param CreateFeedRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Feed + * + * @throws ApiException Thrown if the API call fails. + */ + public function createFeed(CreateFeedRequest $request, array $callOptions = []): Feed + { + return $this->startApiCall('CreateFeed', $request, $callOptions)->wait(); + } + + /** + * Creates a saved query in a parent project/folder/organization. + * + * The async variant is {@see AssetServiceClient::createSavedQueryAsync()} . + * + * @param CreateSavedQueryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SavedQuery + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSavedQuery(CreateSavedQueryRequest $request, array $callOptions = []): SavedQuery + { + return $this->startApiCall('CreateSavedQuery', $request, $callOptions)->wait(); + } + + /** + * Deletes an asset feed. + * + * The async variant is {@see AssetServiceClient::deleteFeedAsync()} . + * + * @param DeleteFeedRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteFeed(DeleteFeedRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteFeed', $request, $callOptions)->wait(); + } + + /** + * Deletes a saved query. + * + * The async variant is {@see AssetServiceClient::deleteSavedQueryAsync()} . + * + * @param DeleteSavedQueryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSavedQuery(DeleteSavedQueryRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteSavedQuery', $request, $callOptions)->wait(); + } + + /** + * Exports assets with time and resource types to a given Cloud Storage + * location/BigQuery table. For Cloud Storage location destinations, the + * output format is newline-delimited JSON. Each line represents a + * [google.cloud.asset.v1.Asset][google.cloud.asset.v1.Asset] in the JSON + * format; for BigQuery table destinations, the output table stores the fields + * in asset Protobuf as columns. This API implements the + * [google.longrunning.Operation][google.longrunning.Operation] API, which + * allows you to keep track of the export. We recommend intervals of at least + * 2 seconds with exponential retry to poll the export operation result. For + * regular-size resource parent, the export operation usually finishes within + * 5 minutes. + * + * The async variant is {@see AssetServiceClient::exportAssetsAsync()} . + * + * @param ExportAssetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportAssets(ExportAssetsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ExportAssets', $request, $callOptions)->wait(); + } + + /** + * Gets details about an asset feed. + * + * The async variant is {@see AssetServiceClient::getFeedAsync()} . + * + * @param GetFeedRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Feed + * + * @throws ApiException Thrown if the API call fails. + */ + public function getFeed(GetFeedRequest $request, array $callOptions = []): Feed + { + return $this->startApiCall('GetFeed', $request, $callOptions)->wait(); + } + + /** + * Gets details about a saved query. + * + * The async variant is {@see AssetServiceClient::getSavedQueryAsync()} . + * + * @param GetSavedQueryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SavedQuery + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSavedQuery(GetSavedQueryRequest $request, array $callOptions = []): SavedQuery + { + return $this->startApiCall('GetSavedQuery', $request, $callOptions)->wait(); + } + + /** + * Lists assets with time and resource types and returns paged results in + * response. + * + * The async variant is {@see AssetServiceClient::listAssetsAsync()} . + * + * @param ListAssetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAssets(ListAssetsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAssets', $request, $callOptions); + } + + /** + * Lists all asset feeds in a parent project/folder/organization. + * + * The async variant is {@see AssetServiceClient::listFeedsAsync()} . + * + * @param ListFeedsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ListFeedsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listFeeds(ListFeedsRequest $request, array $callOptions = []): ListFeedsResponse + { + return $this->startApiCall('ListFeeds', $request, $callOptions)->wait(); + } + + /** + * Lists all saved queries in a parent project/folder/organization. + * + * The async variant is {@see AssetServiceClient::listSavedQueriesAsync()} . + * + * @param ListSavedQueriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSavedQueries(ListSavedQueriesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSavedQueries', $request, $callOptions); + } + + /** + * Issue a job that queries assets using a SQL statement compatible with + * [BigQuery SQL](https://cloud.google.com/bigquery/docs/introduction-sql). + * + * If the query execution finishes within timeout and there's no pagination, + * the full query results will be returned in the `QueryAssetsResponse`. + * + * Otherwise, full query results can be obtained by issuing extra requests + * with the `job_reference` from the a previous `QueryAssets` call. + * + * Note, the query result has approximately 10 GB limitation enforced by + * [BigQuery](https://cloud.google.com/bigquery/docs/best-practices-performance-output). + * Queries return larger results will result in errors. + * + * The async variant is {@see AssetServiceClient::queryAssetsAsync()} . + * + * @param QueryAssetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 QueryAssetsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function queryAssets(QueryAssetsRequest $request, array $callOptions = []): QueryAssetsResponse + { + return $this->startApiCall('QueryAssets', $request, $callOptions)->wait(); + } + + /** + * Searches all IAM policies within the specified scope, such as a project, + * folder, or organization. The caller must be granted the + * `cloudasset.assets.searchAllIamPolicies` permission on the desired scope, + * otherwise the request will be rejected. + * + * The async variant is {@see AssetServiceClient::searchAllIamPoliciesAsync()} . + * + * @param SearchAllIamPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchAllIamPolicies(SearchAllIamPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchAllIamPolicies', $request, $callOptions); + } + + /** + * Searches all Google Cloud resources within the specified scope, such as a + * project, folder, or organization. The caller must be granted the + * `cloudasset.assets.searchAllResources` permission on the desired scope, + * otherwise the request will be rejected. + * + * The async variant is {@see AssetServiceClient::searchAllResourcesAsync()} . + * + * @param SearchAllResourcesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchAllResources(SearchAllResourcesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchAllResources', $request, $callOptions); + } + + /** + * Updates an asset feed configuration. + * + * The async variant is {@see AssetServiceClient::updateFeedAsync()} . + * + * @param UpdateFeedRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Feed + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateFeed(UpdateFeedRequest $request, array $callOptions = []): Feed + { + return $this->startApiCall('UpdateFeed', $request, $callOptions)->wait(); + } + + /** + * Updates a saved query. + * + * The async variant is {@see AssetServiceClient::updateSavedQueryAsync()} . + * + * @param UpdateSavedQueryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SavedQuery + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSavedQuery(UpdateSavedQueryRequest $request, array $callOptions = []): SavedQuery + { + return $this->startApiCall('UpdateSavedQuery', $request, $callOptions)->wait(); + } } diff --git a/Asset/src/V1/Client/BaseClient/AssetServiceBaseClient.php b/Asset/src/V1/Client/BaseClient/AssetServiceBaseClient.php deleted file mode 100644 index 87a77beb4d41..000000000000 --- a/Asset/src/V1/Client/BaseClient/AssetServiceBaseClient.php +++ /dev/null @@ -1,1088 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/asset_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/asset_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/asset_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/asset_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a feed - * resource. - * - * @param string $project - * @param string $feed - * - * @return string The formatted feed resource. - */ - public static function feedName(string $project, string $feed): string - { - return self::getPathTemplate('feed')->render([ - 'project' => $project, - 'feed' => $feed, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a folder - * resource. - * - * @param string $folder - * - * @return string The formatted folder resource. - */ - public static function folderName(string $folder): string - { - return self::getPathTemplate('folder')->render([ - 'folder' => $folder, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a folder_feed - * resource. - * - * @param string $folder - * @param string $feed - * - * @return string The formatted folder_feed resource. - */ - public static function folderFeedName(string $folder, string $feed): string - { - return self::getPathTemplate('folderFeed')->render([ - 'folder' => $folder, - 'feed' => $feed, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_saved_query resource. - * - * @param string $folder - * @param string $savedQuery - * - * @return string The formatted folder_saved_query resource. - */ - public static function folderSavedQueryName(string $folder, string $savedQuery): string - { - return self::getPathTemplate('folderSavedQuery')->render([ - 'folder' => $folder, - 'saved_query' => $savedQuery, - ]); - } - - /** - * 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(string $organization): string - { - return self::getPathTemplate('organization')->render([ - 'organization' => $organization, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_feed resource. - * - * @param string $organization - * @param string $feed - * - * @return string The formatted organization_feed resource. - */ - public static function organizationFeedName(string $organization, string $feed): string - { - return self::getPathTemplate('organizationFeed')->render([ - 'organization' => $organization, - 'feed' => $feed, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_saved_query resource. - * - * @param string $organization - * @param string $savedQuery - * - * @return string The formatted organization_saved_query resource. - */ - public static function organizationSavedQueryName(string $organization, string $savedQuery): string - { - return self::getPathTemplate('organizationSavedQuery')->render([ - 'organization' => $organization, - 'saved_query' => $savedQuery, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a project_feed - * resource. - * - * @param string $project - * @param string $feed - * - * @return string The formatted project_feed resource. - */ - public static function projectFeedName(string $project, string $feed): string - { - return self::getPathTemplate('projectFeed')->render([ - 'project' => $project, - 'feed' => $feed, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_saved_query resource. - * - * @param string $project - * @param string $savedQuery - * - * @return string The formatted project_saved_query resource. - */ - public static function projectSavedQueryName(string $project, string $savedQuery): string - { - return self::getPathTemplate('projectSavedQuery')->render([ - 'project' => $project, - 'saved_query' => $savedQuery, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a saved_query - * resource. - * - * @param string $project - * @param string $savedQuery - * - * @return string The formatted saved_query resource. - */ - public static function savedQueryName(string $project, string $savedQuery): string - { - return self::getPathTemplate('savedQuery')->render([ - 'project' => $project, - 'saved_query' => $savedQuery, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - feed: projects/{project}/feeds/{feed} - * - folder: folders/{folder} - * - folderFeed: folders/{folder}/feeds/{feed} - * - folderSavedQuery: folders/{folder}/savedQueries/{saved_query} - * - organization: organizations/{organization} - * - organizationFeed: organizations/{organization}/feeds/{feed} - * - organizationSavedQuery: organizations/{organization}/savedQueries/{saved_query} - * - project: projects/{project} - * - projectFeed: projects/{project}/feeds/{feed} - * - projectSavedQuery: projects/{project}/savedQueries/{saved_query} - * - savedQuery: projects/{project}/savedQueries/{saved_query} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudasset.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Analyzes IAM policies to answer which identities have what accesses on - * which resources. - * - * The async variant is {@see self::analyzeIamPolicyAsync()} . - * - * @param AnalyzeIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AnalyzeIamPolicyResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function analyzeIamPolicy(AnalyzeIamPolicyRequest $request, array $callOptions = []): AnalyzeIamPolicyResponse - { - return $this->startApiCall('AnalyzeIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Analyzes IAM policies asynchronously to answer which identities have what - * accesses on which resources, and writes the analysis results to a Google - * Cloud Storage or a BigQuery destination. For Cloud Storage destination, the - * output format is the JSON format that represents a - * [AnalyzeIamPolicyResponse][google.cloud.asset.v1.AnalyzeIamPolicyResponse]. - * This method implements the - * [google.longrunning.Operation][google.longrunning.Operation], which allows - * you to track the operation status. We recommend intervals of at least 2 - * seconds with exponential backoff retry to poll the operation result. The - * metadata contains the metadata for the long-running operation. - * - * The async variant is {@see self::analyzeIamPolicyLongrunningAsync()} . - * - * @param AnalyzeIamPolicyLongrunningRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function analyzeIamPolicyLongrunning(AnalyzeIamPolicyLongrunningRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AnalyzeIamPolicyLongrunning', $request, $callOptions)->wait(); - } - - /** - * Analyze moving a resource to a specified destination without kicking off - * the actual move. The analysis is best effort depending on the user's - * permissions of viewing different hierarchical policies and configurations. - * The policies and configuration are subject to change before the actual - * resource migration takes place. - * - * The async variant is {@see self::analyzeMoveAsync()} . - * - * @param AnalyzeMoveRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AnalyzeMoveResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function analyzeMove(AnalyzeMoveRequest $request, array $callOptions = []): AnalyzeMoveResponse - { - return $this->startApiCall('AnalyzeMove', $request, $callOptions)->wait(); - } - - /** - * Analyzes organization policies under a scope. - * - * The async variant is {@see self::analyzeOrgPoliciesAsync()} . - * - * @param AnalyzeOrgPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function analyzeOrgPolicies(AnalyzeOrgPoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AnalyzeOrgPolicies', $request, $callOptions); - } - - /** - * Analyzes organization policies governed assets (Google Cloud resources or - * policies) under a scope. This RPC supports custom constraints and the - * following 10 canned constraints: - * - * * storage.uniformBucketLevelAccess - * * iam.disableServiceAccountKeyCreation - * * iam.allowedPolicyMemberDomains - * * compute.vmExternalIpAccess - * * appengine.enforceServiceAccountActAsCheck - * * gcp.resourceLocations - * * compute.trustedImageProjects - * * compute.skipDefaultNetworkCreation - * * compute.requireOsLogin - * * compute.disableNestedVirtualization - * - * This RPC only returns either resources of types supported by [searchable - * asset - * types](https://cloud.google.com/asset-inventory/docs/supported-asset-types#searchable_asset_types), - * or IAM policies. - * - * The async variant is {@see self::analyzeOrgPolicyGovernedAssetsAsync()} . - * - * @param AnalyzeOrgPolicyGovernedAssetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function analyzeOrgPolicyGovernedAssets(AnalyzeOrgPolicyGovernedAssetsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AnalyzeOrgPolicyGovernedAssets', $request, $callOptions); - } - - /** - * Analyzes organization policies governed containers (projects, folders or - * organization) under a scope. - * - * The async variant is {@see self::analyzeOrgPolicyGovernedContainersAsync()} . - * - * @param AnalyzeOrgPolicyGovernedContainersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function analyzeOrgPolicyGovernedContainers(AnalyzeOrgPolicyGovernedContainersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AnalyzeOrgPolicyGovernedContainers', $request, $callOptions); - } - - /** - * Batch gets the update history of assets that overlap a time window. - * For IAM_POLICY content, this API outputs history when the asset and its - * attached IAM POLICY both exist. This can create gaps in the output history. - * Otherwise, this API outputs history with asset in both non-delete or - * deleted status. - * If a specified asset does not exist, this API returns an INVALID_ARGUMENT - * error. - * - * The async variant is {@see self::batchGetAssetsHistoryAsync()} . - * - * @param BatchGetAssetsHistoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BatchGetAssetsHistoryResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchGetAssetsHistory(BatchGetAssetsHistoryRequest $request, array $callOptions = []): BatchGetAssetsHistoryResponse - { - return $this->startApiCall('BatchGetAssetsHistory', $request, $callOptions)->wait(); - } - - /** - * Gets effective IAM policies for a batch of resources. - * - * The async variant is {@see self::batchGetEffectiveIamPoliciesAsync()} . - * - * @param BatchGetEffectiveIamPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BatchGetEffectiveIamPoliciesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchGetEffectiveIamPolicies(BatchGetEffectiveIamPoliciesRequest $request, array $callOptions = []): BatchGetEffectiveIamPoliciesResponse - { - return $this->startApiCall('BatchGetEffectiveIamPolicies', $request, $callOptions)->wait(); - } - - /** - * Creates a feed in a parent project/folder/organization to listen to its - * asset updates. - * - * The async variant is {@see self::createFeedAsync()} . - * - * @param CreateFeedRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Feed - * - * @throws ApiException Thrown if the API call fails. - */ - public function createFeed(CreateFeedRequest $request, array $callOptions = []): Feed - { - return $this->startApiCall('CreateFeed', $request, $callOptions)->wait(); - } - - /** - * Creates a saved query in a parent project/folder/organization. - * - * The async variant is {@see self::createSavedQueryAsync()} . - * - * @param CreateSavedQueryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SavedQuery - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSavedQuery(CreateSavedQueryRequest $request, array $callOptions = []): SavedQuery - { - return $this->startApiCall('CreateSavedQuery', $request, $callOptions)->wait(); - } - - /** - * Deletes an asset feed. - * - * The async variant is {@see self::deleteFeedAsync()} . - * - * @param DeleteFeedRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteFeed(DeleteFeedRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteFeed', $request, $callOptions)->wait(); - } - - /** - * Deletes a saved query. - * - * The async variant is {@see self::deleteSavedQueryAsync()} . - * - * @param DeleteSavedQueryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSavedQuery(DeleteSavedQueryRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteSavedQuery', $request, $callOptions)->wait(); - } - - /** - * Exports assets with time and resource types to a given Cloud Storage - * location/BigQuery table. For Cloud Storage location destinations, the - * output format is newline-delimited JSON. Each line represents a - * [google.cloud.asset.v1.Asset][google.cloud.asset.v1.Asset] in the JSON - * format; for BigQuery table destinations, the output table stores the fields - * in asset Protobuf as columns. This API implements the - * [google.longrunning.Operation][google.longrunning.Operation] API, which - * allows you to keep track of the export. We recommend intervals of at least - * 2 seconds with exponential retry to poll the export operation result. For - * regular-size resource parent, the export operation usually finishes within - * 5 minutes. - * - * The async variant is {@see self::exportAssetsAsync()} . - * - * @param ExportAssetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function exportAssets(ExportAssetsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ExportAssets', $request, $callOptions)->wait(); - } - - /** - * Gets details about an asset feed. - * - * The async variant is {@see self::getFeedAsync()} . - * - * @param GetFeedRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Feed - * - * @throws ApiException Thrown if the API call fails. - */ - public function getFeed(GetFeedRequest $request, array $callOptions = []): Feed - { - return $this->startApiCall('GetFeed', $request, $callOptions)->wait(); - } - - /** - * Gets details about a saved query. - * - * The async variant is {@see self::getSavedQueryAsync()} . - * - * @param GetSavedQueryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SavedQuery - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSavedQuery(GetSavedQueryRequest $request, array $callOptions = []): SavedQuery - { - return $this->startApiCall('GetSavedQuery', $request, $callOptions)->wait(); - } - - /** - * Lists assets with time and resource types and returns paged results in - * response. - * - * The async variant is {@see self::listAssetsAsync()} . - * - * @param ListAssetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAssets(ListAssetsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAssets', $request, $callOptions); - } - - /** - * Lists all asset feeds in a parent project/folder/organization. - * - * The async variant is {@see self::listFeedsAsync()} . - * - * @param ListFeedsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ListFeedsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listFeeds(ListFeedsRequest $request, array $callOptions = []): ListFeedsResponse - { - return $this->startApiCall('ListFeeds', $request, $callOptions)->wait(); - } - - /** - * Lists all saved queries in a parent project/folder/organization. - * - * The async variant is {@see self::listSavedQueriesAsync()} . - * - * @param ListSavedQueriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSavedQueries(ListSavedQueriesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSavedQueries', $request, $callOptions); - } - - /** - * Issue a job that queries assets using a SQL statement compatible with - * [BigQuery SQL](https://cloud.google.com/bigquery/docs/introduction-sql). - * - * If the query execution finishes within timeout and there's no pagination, - * the full query results will be returned in the `QueryAssetsResponse`. - * - * Otherwise, full query results can be obtained by issuing extra requests - * with the `job_reference` from the a previous `QueryAssets` call. - * - * Note, the query result has approximately 10 GB limitation enforced by - * [BigQuery](https://cloud.google.com/bigquery/docs/best-practices-performance-output). - * Queries return larger results will result in errors. - * - * The async variant is {@see self::queryAssetsAsync()} . - * - * @param QueryAssetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 QueryAssetsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function queryAssets(QueryAssetsRequest $request, array $callOptions = []): QueryAssetsResponse - { - return $this->startApiCall('QueryAssets', $request, $callOptions)->wait(); - } - - /** - * Searches all IAM policies within the specified scope, such as a project, - * folder, or organization. The caller must be granted the - * `cloudasset.assets.searchAllIamPolicies` permission on the desired scope, - * otherwise the request will be rejected. - * - * The async variant is {@see self::searchAllIamPoliciesAsync()} . - * - * @param SearchAllIamPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchAllIamPolicies(SearchAllIamPoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchAllIamPolicies', $request, $callOptions); - } - - /** - * Searches all Google Cloud resources within the specified scope, such as a - * project, folder, or organization. The caller must be granted the - * `cloudasset.assets.searchAllResources` permission on the desired scope, - * otherwise the request will be rejected. - * - * The async variant is {@see self::searchAllResourcesAsync()} . - * - * @param SearchAllResourcesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchAllResources(SearchAllResourcesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchAllResources', $request, $callOptions); - } - - /** - * Updates an asset feed configuration. - * - * The async variant is {@see self::updateFeedAsync()} . - * - * @param UpdateFeedRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Feed - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateFeed(UpdateFeedRequest $request, array $callOptions = []): Feed - { - return $this->startApiCall('UpdateFeed', $request, $callOptions)->wait(); - } - - /** - * Updates a saved query. - * - * The async variant is {@see self::updateSavedQueryAsync()} . - * - * @param UpdateSavedQueryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SavedQuery - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSavedQuery(UpdateSavedQueryRequest $request, array $callOptions = []): SavedQuery - { - return $this->startApiCall('UpdateSavedQuery', $request, $callOptions)->wait(); - } -} diff --git a/AssuredWorkloads/composer.json b/AssuredWorkloads/composer.json index 3cdcae670f73..feb5d7a9b99d 100644 --- a/AssuredWorkloads/composer.json +++ b/AssuredWorkloads/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/AssuredWorkloads/src/V1/Client/AssuredWorkloadsServiceClient.php b/AssuredWorkloads/src/V1/Client/AssuredWorkloadsServiceClient.php index e415f0241490..64bd55515f5b 100644 --- a/AssuredWorkloads/src/V1/Client/AssuredWorkloadsServiceClient.php +++ b/AssuredWorkloads/src/V1/Client/AssuredWorkloadsServiceClient.php @@ -24,17 +24,538 @@ namespace Google\Cloud\AssuredWorkloads\V1\Client; -use Google\Cloud\AssuredWorkloads\V1\Client\BaseClient\AssuredWorkloadsServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AssuredWorkloads\V1\AcknowledgeViolationRequest; +use Google\Cloud\AssuredWorkloads\V1\AcknowledgeViolationResponse; +use Google\Cloud\AssuredWorkloads\V1\CreateWorkloadRequest; +use Google\Cloud\AssuredWorkloads\V1\DeleteWorkloadRequest; +use Google\Cloud\AssuredWorkloads\V1\GetViolationRequest; +use Google\Cloud\AssuredWorkloads\V1\GetWorkloadRequest; +use Google\Cloud\AssuredWorkloads\V1\ListViolationsRequest; +use Google\Cloud\AssuredWorkloads\V1\ListWorkloadsRequest; +use Google\Cloud\AssuredWorkloads\V1\RestrictAllowedResourcesRequest; +use Google\Cloud\AssuredWorkloads\V1\RestrictAllowedResourcesResponse; +use Google\Cloud\AssuredWorkloads\V1\UpdateWorkloadRequest; +use Google\Cloud\AssuredWorkloads\V1\Violation; +use Google\Cloud\AssuredWorkloads\V1\Workload; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service to manage AssuredWorkloads. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface acknowledgeViolationAsync(AcknowledgeViolationRequest $request, array $optionalArgs = []) + * @method PromiseInterface createWorkloadAsync(CreateWorkloadRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteWorkloadAsync(DeleteWorkloadRequest $request, array $optionalArgs = []) + * @method PromiseInterface getViolationAsync(GetViolationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getWorkloadAsync(GetWorkloadRequest $request, array $optionalArgs = []) + * @method PromiseInterface listViolationsAsync(ListViolationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listWorkloadsAsync(ListWorkloadsRequest $request, array $optionalArgs = []) + * @method PromiseInterface restrictAllowedResourcesAsync(RestrictAllowedResourcesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateWorkloadAsync(UpdateWorkloadRequest $request, array $optionalArgs = []) */ -final class AssuredWorkloadsServiceClient extends AssuredWorkloadsServiceBaseClient +final class AssuredWorkloadsServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AssuredWorkloadsServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.assuredworkloads.v1.AssuredWorkloadsService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'assuredworkloads.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/assured_workloads_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/assured_workloads_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/assured_workloads_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/assured_workloads_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $organization + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $organization, string $location): string + { + return self::getPathTemplate('location')->render([ + 'organization' => $organization, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a violation + * resource. + * + * @param string $organization + * @param string $location + * @param string $workload + * @param string $violation + * + * @return string The formatted violation resource. + */ + public static function violationName(string $organization, string $location, string $workload, string $violation): string + { + return self::getPathTemplate('violation')->render([ + 'organization' => $organization, + 'location' => $location, + 'workload' => $workload, + 'violation' => $violation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a workload + * resource. + * + * @param string $organization + * @param string $location + * @param string $workload + * + * @return string The formatted workload resource. + */ + public static function workloadName(string $organization, string $location, string $workload): string + { + return self::getPathTemplate('workload')->render([ + 'organization' => $organization, + 'location' => $location, + 'workload' => $workload, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - location: organizations/{organization}/locations/{location} + * - violation: organizations/{organization}/locations/{location}/workloads/{workload}/violations/{violation} + * - workload: organizations/{organization}/locations/{location}/workloads/{workload} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'assuredworkloads.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Acknowledges an existing violation. By acknowledging a violation, users + * acknowledge the existence of a compliance violation in their workload and + * decide to ignore it due to a valid business justification. Acknowledgement + * is a permanent operation and it cannot be reverted. + * + * The async variant is + * {@see AssuredWorkloadsServiceClient::acknowledgeViolationAsync()} . + * + * @example samples/V1/AssuredWorkloadsServiceClient/acknowledge_violation.php + * + * @param AcknowledgeViolationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AcknowledgeViolationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function acknowledgeViolation(AcknowledgeViolationRequest $request, array $callOptions = []): AcknowledgeViolationResponse + { + return $this->startApiCall('AcknowledgeViolation', $request, $callOptions)->wait(); + } + + /** + * Creates Assured Workload. + * + * The async variant is {@see AssuredWorkloadsServiceClient::createWorkloadAsync()} + * . + * + * @example samples/V1/AssuredWorkloadsServiceClient/create_workload.php + * + * @param CreateWorkloadRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createWorkload(CreateWorkloadRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateWorkload', $request, $callOptions)->wait(); + } + + /** + * Deletes the workload. Make sure that workload's direct children are already + * in a deleted state, otherwise the request will fail with a + * FAILED_PRECONDITION error. + * + * The async variant is {@see AssuredWorkloadsServiceClient::deleteWorkloadAsync()} + * . + * + * @example samples/V1/AssuredWorkloadsServiceClient/delete_workload.php + * + * @param DeleteWorkloadRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteWorkload(DeleteWorkloadRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteWorkload', $request, $callOptions)->wait(); + } + + /** + * Retrieves Assured Workload Violation based on ID. + * + * The async variant is {@see AssuredWorkloadsServiceClient::getViolationAsync()} . + * + * @example samples/V1/AssuredWorkloadsServiceClient/get_violation.php + * + * @param GetViolationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Violation + * + * @throws ApiException Thrown if the API call fails. + */ + public function getViolation(GetViolationRequest $request, array $callOptions = []): Violation + { + return $this->startApiCall('GetViolation', $request, $callOptions)->wait(); + } + + /** + * Gets Assured Workload associated with a CRM Node + * + * The async variant is {@see AssuredWorkloadsServiceClient::getWorkloadAsync()} . + * + * @example samples/V1/AssuredWorkloadsServiceClient/get_workload.php + * + * @param GetWorkloadRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Workload + * + * @throws ApiException Thrown if the API call fails. + */ + public function getWorkload(GetWorkloadRequest $request, array $callOptions = []): Workload + { + return $this->startApiCall('GetWorkload', $request, $callOptions)->wait(); + } + + /** + * Lists the Violations in the AssuredWorkload Environment. + * Callers may also choose to read across multiple Workloads as per + * [AIP-159](https://google.aip.dev/159) by using '-' (the hyphen or dash + * character) as a wildcard character instead of workload-id in the parent. + * Format `organizations/{org_id}/locations/{location}/workloads/-` + * + * The async variant is {@see AssuredWorkloadsServiceClient::listViolationsAsync()} + * . + * + * @example samples/V1/AssuredWorkloadsServiceClient/list_violations.php + * + * @param ListViolationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listViolations(ListViolationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListViolations', $request, $callOptions); + } + + /** + * Lists Assured Workloads under a CRM Node. + * + * The async variant is {@see AssuredWorkloadsServiceClient::listWorkloadsAsync()} + * . + * + * @example samples/V1/AssuredWorkloadsServiceClient/list_workloads.php + * + * @param ListWorkloadsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listWorkloads(ListWorkloadsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListWorkloads', $request, $callOptions); + } + + /** + * Restrict the list of resources allowed in the Workload environment. + * The current list of allowed products can be found at + * https://cloud.google.com/assured-workloads/docs/supported-products + * In addition to assuredworkloads.workload.update permission, the user should + * also have orgpolicy.policy.set permission on the folder resource + * to use this functionality. + * + * The async variant is + * {@see AssuredWorkloadsServiceClient::restrictAllowedResourcesAsync()} . + * + * @example samples/V1/AssuredWorkloadsServiceClient/restrict_allowed_resources.php + * + * @param RestrictAllowedResourcesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RestrictAllowedResourcesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function restrictAllowedResources(RestrictAllowedResourcesRequest $request, array $callOptions = []): RestrictAllowedResourcesResponse + { + return $this->startApiCall('RestrictAllowedResources', $request, $callOptions)->wait(); + } + + /** + * Updates an existing workload. + * Currently allows updating of workload display_name and labels. + * For force updates don't set etag field in the Workload. + * Only one update operation per workload can be in progress. + * + * The async variant is {@see AssuredWorkloadsServiceClient::updateWorkloadAsync()} + * . + * + * @example samples/V1/AssuredWorkloadsServiceClient/update_workload.php + * + * @param UpdateWorkloadRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Workload + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateWorkload(UpdateWorkloadRequest $request, array $callOptions = []): Workload + { + return $this->startApiCall('UpdateWorkload', $request, $callOptions)->wait(); + } } diff --git a/AssuredWorkloads/src/V1/Client/BaseClient/AssuredWorkloadsServiceBaseClient.php b/AssuredWorkloads/src/V1/Client/BaseClient/AssuredWorkloadsServiceBaseClient.php deleted file mode 100644 index 6b4ecc5f1d0e..000000000000 --- a/AssuredWorkloads/src/V1/Client/BaseClient/AssuredWorkloadsServiceBaseClient.php +++ /dev/null @@ -1,556 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/assured_workloads_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/assured_workloads_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/assured_workloads_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/assured_workloads_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $organization - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $organization, string $location): string - { - return self::getPathTemplate('location')->render([ - 'organization' => $organization, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a violation - * resource. - * - * @param string $organization - * @param string $location - * @param string $workload - * @param string $violation - * - * @return string The formatted violation resource. - */ - public static function violationName(string $organization, string $location, string $workload, string $violation): string - { - return self::getPathTemplate('violation')->render([ - 'organization' => $organization, - 'location' => $location, - 'workload' => $workload, - 'violation' => $violation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a workload - * resource. - * - * @param string $organization - * @param string $location - * @param string $workload - * - * @return string The formatted workload resource. - */ - public static function workloadName(string $organization, string $location, string $workload): string - { - return self::getPathTemplate('workload')->render([ - 'organization' => $organization, - 'location' => $location, - 'workload' => $workload, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - location: organizations/{organization}/locations/{location} - * - violation: organizations/{organization}/locations/{location}/workloads/{workload}/violations/{violation} - * - workload: organizations/{organization}/locations/{location}/workloads/{workload} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'assuredworkloads.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Acknowledges an existing violation. By acknowledging a violation, users - * acknowledge the existence of a compliance violation in their workload and - * decide to ignore it due to a valid business justification. Acknowledgement - * is a permanent operation and it cannot be reverted. - * - * The async variant is {@see self::acknowledgeViolationAsync()} . - * - * @example samples/V1/AssuredWorkloadsServiceClient/acknowledge_violation.php - * - * @param AcknowledgeViolationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AcknowledgeViolationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function acknowledgeViolation(AcknowledgeViolationRequest $request, array $callOptions = []): AcknowledgeViolationResponse - { - return $this->startApiCall('AcknowledgeViolation', $request, $callOptions)->wait(); - } - - /** - * Creates Assured Workload. - * - * The async variant is {@see self::createWorkloadAsync()} . - * - * @example samples/V1/AssuredWorkloadsServiceClient/create_workload.php - * - * @param CreateWorkloadRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createWorkload(CreateWorkloadRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateWorkload', $request, $callOptions)->wait(); - } - - /** - * Deletes the workload. Make sure that workload's direct children are already - * in a deleted state, otherwise the request will fail with a - * FAILED_PRECONDITION error. - * - * The async variant is {@see self::deleteWorkloadAsync()} . - * - * @example samples/V1/AssuredWorkloadsServiceClient/delete_workload.php - * - * @param DeleteWorkloadRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteWorkload(DeleteWorkloadRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteWorkload', $request, $callOptions)->wait(); - } - - /** - * Retrieves Assured Workload Violation based on ID. - * - * The async variant is {@see self::getViolationAsync()} . - * - * @example samples/V1/AssuredWorkloadsServiceClient/get_violation.php - * - * @param GetViolationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Violation - * - * @throws ApiException Thrown if the API call fails. - */ - public function getViolation(GetViolationRequest $request, array $callOptions = []): Violation - { - return $this->startApiCall('GetViolation', $request, $callOptions)->wait(); - } - - /** - * Gets Assured Workload associated with a CRM Node - * - * The async variant is {@see self::getWorkloadAsync()} . - * - * @example samples/V1/AssuredWorkloadsServiceClient/get_workload.php - * - * @param GetWorkloadRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Workload - * - * @throws ApiException Thrown if the API call fails. - */ - public function getWorkload(GetWorkloadRequest $request, array $callOptions = []): Workload - { - return $this->startApiCall('GetWorkload', $request, $callOptions)->wait(); - } - - /** - * Lists the Violations in the AssuredWorkload Environment. - * Callers may also choose to read across multiple Workloads as per - * [AIP-159](https://google.aip.dev/159) by using '-' (the hyphen or dash - * character) as a wildcard character instead of workload-id in the parent. - * Format `organizations/{org_id}/locations/{location}/workloads/-` - * - * The async variant is {@see self::listViolationsAsync()} . - * - * @example samples/V1/AssuredWorkloadsServiceClient/list_violations.php - * - * @param ListViolationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listViolations(ListViolationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListViolations', $request, $callOptions); - } - - /** - * Lists Assured Workloads under a CRM Node. - * - * The async variant is {@see self::listWorkloadsAsync()} . - * - * @example samples/V1/AssuredWorkloadsServiceClient/list_workloads.php - * - * @param ListWorkloadsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listWorkloads(ListWorkloadsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListWorkloads', $request, $callOptions); - } - - /** - * Restrict the list of resources allowed in the Workload environment. - * The current list of allowed products can be found at - * https://cloud.google.com/assured-workloads/docs/supported-products - * In addition to assuredworkloads.workload.update permission, the user should - * also have orgpolicy.policy.set permission on the folder resource - * to use this functionality. - * - * The async variant is {@see self::restrictAllowedResourcesAsync()} . - * - * @example samples/V1/AssuredWorkloadsServiceClient/restrict_allowed_resources.php - * - * @param RestrictAllowedResourcesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RestrictAllowedResourcesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function restrictAllowedResources(RestrictAllowedResourcesRequest $request, array $callOptions = []): RestrictAllowedResourcesResponse - { - return $this->startApiCall('RestrictAllowedResources', $request, $callOptions)->wait(); - } - - /** - * Updates an existing workload. - * Currently allows updating of workload display_name and labels. - * For force updates don't set etag field in the Workload. - * Only one update operation per workload can be in progress. - * - * The async variant is {@see self::updateWorkloadAsync()} . - * - * @example samples/V1/AssuredWorkloadsServiceClient/update_workload.php - * - * @param UpdateWorkloadRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Workload - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateWorkload(UpdateWorkloadRequest $request, array $callOptions = []): Workload - { - return $this->startApiCall('UpdateWorkload', $request, $callOptions)->wait(); - } -} diff --git a/AutoMl/composer.json b/AutoMl/composer.json index 3424726ae922..473fbf9cde2f 100644 --- a/AutoMl/composer.json +++ b/AutoMl/composer.json @@ -24,11 +24,11 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", - "google/cloud-core": "^1.39" + "google/cloud-core": "^1.52.7" }, "suggest": { "ext-grpc": "Enables use of gRPC, a universal high-performance RPC framework created by Google.", diff --git a/AutoMl/src/V1/Client/AutoMlClient.php b/AutoMl/src/V1/Client/AutoMlClient.php index df5bf16b5c62..97efb458a668 100644 --- a/AutoMl/src/V1/Client/AutoMlClient.php +++ b/AutoMl/src/V1/Client/AutoMlClient.php @@ -24,17 +24,832 @@ namespace Google\Cloud\AutoMl\V1\Client; -use Google\Cloud\AutoMl\V1\Client\BaseClient\AutoMlBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AutoMl\V1\AnnotationSpec; +use Google\Cloud\AutoMl\V1\CreateDatasetRequest; +use Google\Cloud\AutoMl\V1\CreateModelRequest; +use Google\Cloud\AutoMl\V1\Dataset; +use Google\Cloud\AutoMl\V1\DeleteDatasetRequest; +use Google\Cloud\AutoMl\V1\DeleteModelRequest; +use Google\Cloud\AutoMl\V1\DeployModelRequest; +use Google\Cloud\AutoMl\V1\ExportDataRequest; +use Google\Cloud\AutoMl\V1\ExportModelRequest; +use Google\Cloud\AutoMl\V1\GetAnnotationSpecRequest; +use Google\Cloud\AutoMl\V1\GetDatasetRequest; +use Google\Cloud\AutoMl\V1\GetModelEvaluationRequest; +use Google\Cloud\AutoMl\V1\GetModelRequest; +use Google\Cloud\AutoMl\V1\ImportDataRequest; +use Google\Cloud\AutoMl\V1\ListDatasetsRequest; +use Google\Cloud\AutoMl\V1\ListModelEvaluationsRequest; +use Google\Cloud\AutoMl\V1\ListModelsRequest; +use Google\Cloud\AutoMl\V1\Model; +use Google\Cloud\AutoMl\V1\ModelEvaluation; +use Google\Cloud\AutoMl\V1\UndeployModelRequest; +use Google\Cloud\AutoMl\V1\UpdateDatasetRequest; +use Google\Cloud\AutoMl\V1\UpdateModelRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: AutoML Server API. * - * This class is currently experimental and may be subject to changes. + * The resource names are assigned by the server. + * The server never reuses names that it has created after the resources with + * those names are deleted. + * + * An ID of a resource is the last element of the item's resource name. For + * `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}`, then + * the id for the item is `{dataset_id}`. + * + * Currently the only supported `location_id` is "us-central1". + * + * On any input that is documented to expect a string parameter in + * snake_case or dash-case, either of those cases is accepted. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AutoMl\V1\AutoMlClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createDatasetAsync(CreateDatasetRequest $request, array $optionalArgs = []) + * @method PromiseInterface createModelAsync(CreateModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDatasetAsync(DeleteDatasetRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteModelAsync(DeleteModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface deployModelAsync(DeployModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface exportDataAsync(ExportDataRequest $request, array $optionalArgs = []) + * @method PromiseInterface exportModelAsync(ExportModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAnnotationSpecAsync(GetAnnotationSpecRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDatasetAsync(GetDatasetRequest $request, array $optionalArgs = []) + * @method PromiseInterface getModelAsync(GetModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface getModelEvaluationAsync(GetModelEvaluationRequest $request, array $optionalArgs = []) + * @method PromiseInterface importDataAsync(ImportDataRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDatasetsAsync(ListDatasetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listModelEvaluationsAsync(ListModelEvaluationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listModelsAsync(ListModelsRequest $request, array $optionalArgs = []) + * @method PromiseInterface undeployModelAsync(UndeployModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDatasetAsync(UpdateDatasetRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateModelAsync(UpdateModelRequest $request, array $optionalArgs = []) */ -final class AutoMlClient extends AutoMlBaseClient +final class AutoMlClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AutoMlBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.automl.v1.AutoMl'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'automl.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/auto_ml_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/auto_ml_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/auto_ml_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/auto_ml_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * annotation_spec resource. + * + * @param string $project + * @param string $location + * @param string $dataset + * @param string $annotationSpec + * + * @return string The formatted annotation_spec resource. + */ + public static function annotationSpecName(string $project, string $location, string $dataset, string $annotationSpec): string + { + return self::getPathTemplate('annotationSpec')->render([ + 'project' => $project, + 'location' => $location, + 'dataset' => $dataset, + 'annotation_spec' => $annotationSpec, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a dataset + * resource. + * + * @param string $project + * @param string $location + * @param string $dataset + * + * @return string The formatted dataset resource. + */ + public static function datasetName(string $project, string $location, string $dataset): string + { + return self::getPathTemplate('dataset')->render([ + 'project' => $project, + 'location' => $location, + 'dataset' => $dataset, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a model + * resource. + * + * @param string $project + * @param string $location + * @param string $model + * + * @return string The formatted model resource. + */ + public static function modelName(string $project, string $location, string $model): string + { + return self::getPathTemplate('model')->render([ + 'project' => $project, + 'location' => $location, + 'model' => $model, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * model_evaluation resource. + * + * @param string $project + * @param string $location + * @param string $model + * @param string $modelEvaluation + * + * @return string The formatted model_evaluation resource. + */ + public static function modelEvaluationName(string $project, string $location, string $model, string $modelEvaluation): string + { + return self::getPathTemplate('modelEvaluation')->render([ + 'project' => $project, + 'location' => $location, + 'model' => $model, + 'model_evaluation' => $modelEvaluation, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - annotationSpec: projects/{project}/locations/{location}/datasets/{dataset}/annotationSpecs/{annotation_spec} + * - dataset: projects/{project}/locations/{location}/datasets/{dataset} + * - location: projects/{project}/locations/{location} + * - model: projects/{project}/locations/{location}/models/{model} + * - modelEvaluation: projects/{project}/locations/{location}/models/{model}/modelEvaluations/{model_evaluation} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'automl.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a dataset. + * + * The async variant is {@see AutoMlClient::createDatasetAsync()} . + * + * @param CreateDatasetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDataset(CreateDatasetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateDataset', $request, $callOptions)->wait(); + } + + /** + * Creates a model. + * Returns a Model in the [response][google.longrunning.Operation.response] + * field when it completes. + * When you create a model, several model evaluations are created for it: + * a global evaluation, and one evaluation for each annotation spec. + * + * The async variant is {@see AutoMlClient::createModelAsync()} . + * + * @param CreateModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createModel(CreateModelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateModel', $request, $callOptions)->wait(); + } + + /** + * Deletes a dataset and all of its contents. + * Returns empty response in the + * [response][google.longrunning.Operation.response] field when it completes, + * and `delete_details` in the + * [metadata][google.longrunning.Operation.metadata] field. + * + * The async variant is {@see AutoMlClient::deleteDatasetAsync()} . + * + * @param DeleteDatasetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDataset(DeleteDatasetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteDataset', $request, $callOptions)->wait(); + } + + /** + * Deletes a model. + * Returns `google.protobuf.Empty` in the + * [response][google.longrunning.Operation.response] field when it completes, + * and `delete_details` in the + * [metadata][google.longrunning.Operation.metadata] field. + * + * The async variant is {@see AutoMlClient::deleteModelAsync()} . + * + * @param DeleteModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteModel(DeleteModelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteModel', $request, $callOptions)->wait(); + } + + /** + * Deploys a model. If a model is already deployed, deploying it with the + * same parameters has no effect. Deploying with different parametrs + * (as e.g. changing + * [node_number][google.cloud.automl.v1p1beta.ImageObjectDetectionModelDeploymentMetadata.node_number]) + * will reset the deployment state without pausing the model's availability. + * + * Only applicable for Text Classification, Image Object Detection , Tables, and Image Segmentation; all other domains manage + * deployment automatically. + * + * Returns an empty response in the + * [response][google.longrunning.Operation.response] field when it completes. + * + * The async variant is {@see AutoMlClient::deployModelAsync()} . + * + * @param DeployModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deployModel(DeployModelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeployModel', $request, $callOptions)->wait(); + } + + /** + * Exports dataset's data to the provided output location. + * Returns an empty response in the + * [response][google.longrunning.Operation.response] field when it completes. + * + * The async variant is {@see AutoMlClient::exportDataAsync()} . + * + * @param ExportDataRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportData(ExportDataRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ExportData', $request, $callOptions)->wait(); + } + + /** + * Exports a trained, "export-able", model to a user specified Google Cloud + * Storage location. A model is considered export-able if and only if it has + * an export format defined for it in + * [ModelExportOutputConfig][google.cloud.automl.v1.ModelExportOutputConfig]. + * + * Returns an empty response in the + * [response][google.longrunning.Operation.response] field when it completes. + * + * The async variant is {@see AutoMlClient::exportModelAsync()} . + * + * @param ExportModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportModel(ExportModelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ExportModel', $request, $callOptions)->wait(); + } + + /** + * Gets an annotation spec. + * + * The async variant is {@see AutoMlClient::getAnnotationSpecAsync()} . + * + * @param GetAnnotationSpecRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AnnotationSpec + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAnnotationSpec(GetAnnotationSpecRequest $request, array $callOptions = []): AnnotationSpec + { + return $this->startApiCall('GetAnnotationSpec', $request, $callOptions)->wait(); + } + + /** + * Gets a dataset. + * + * The async variant is {@see AutoMlClient::getDatasetAsync()} . + * + * @param GetDatasetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Dataset + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDataset(GetDatasetRequest $request, array $callOptions = []): Dataset + { + return $this->startApiCall('GetDataset', $request, $callOptions)->wait(); + } + + /** + * Gets a model. + * + * The async variant is {@see AutoMlClient::getModelAsync()} . + * + * @param GetModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Model + * + * @throws ApiException Thrown if the API call fails. + */ + public function getModel(GetModelRequest $request, array $callOptions = []): Model + { + return $this->startApiCall('GetModel', $request, $callOptions)->wait(); + } + + /** + * Gets a model evaluation. + * + * The async variant is {@see AutoMlClient::getModelEvaluationAsync()} . + * + * @param GetModelEvaluationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ModelEvaluation + * + * @throws ApiException Thrown if the API call fails. + */ + public function getModelEvaluation(GetModelEvaluationRequest $request, array $callOptions = []): ModelEvaluation + { + return $this->startApiCall('GetModelEvaluation', $request, $callOptions)->wait(); + } + + /** + * Imports data into a dataset. + * For Tables this method can only be called on an empty Dataset. + * + * For Tables: + * * A + * [schema_inference_version][google.cloud.automl.v1.InputConfig.params] + * parameter must be explicitly set. + * Returns an empty response in the + * [response][google.longrunning.Operation.response] field when it completes. + * + * The async variant is {@see AutoMlClient::importDataAsync()} . + * + * @param ImportDataRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importData(ImportDataRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportData', $request, $callOptions)->wait(); + } + + /** + * Lists datasets in a project. + * + * The async variant is {@see AutoMlClient::listDatasetsAsync()} . + * + * @param ListDatasetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDatasets(ListDatasetsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDatasets', $request, $callOptions); + } + + /** + * Lists model evaluations. + * + * The async variant is {@see AutoMlClient::listModelEvaluationsAsync()} . + * + * @param ListModelEvaluationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listModelEvaluations(ListModelEvaluationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListModelEvaluations', $request, $callOptions); + } + + /** + * Lists models. + * + * The async variant is {@see AutoMlClient::listModelsAsync()} . + * + * @param ListModelsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listModels(ListModelsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListModels', $request, $callOptions); + } + + /** + * Undeploys a model. If the model is not deployed this method has no effect. + * + * Only applicable for Text Classification, Image Object Detection and Tables; + * all other domains manage deployment automatically. + * + * Returns an empty response in the + * [response][google.longrunning.Operation.response] field when it completes. + * + * The async variant is {@see AutoMlClient::undeployModelAsync()} . + * + * @param UndeployModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function undeployModel(UndeployModelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UndeployModel', $request, $callOptions)->wait(); + } + + /** + * Updates a dataset. + * + * The async variant is {@see AutoMlClient::updateDatasetAsync()} . + * + * @param UpdateDatasetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Dataset + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDataset(UpdateDatasetRequest $request, array $callOptions = []): Dataset + { + return $this->startApiCall('UpdateDataset', $request, $callOptions)->wait(); + } + + /** + * Updates a model. + * + * The async variant is {@see AutoMlClient::updateModelAsync()} . + * + * @param UpdateModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Model + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateModel(UpdateModelRequest $request, array $callOptions = []): Model + { + return $this->startApiCall('UpdateModel', $request, $callOptions)->wait(); + } } diff --git a/AutoMl/src/V1/Client/BaseClient/AutoMlBaseClient.php b/AutoMl/src/V1/Client/BaseClient/AutoMlBaseClient.php deleted file mode 100644 index 0deaa5d1cabc..000000000000 --- a/AutoMl/src/V1/Client/BaseClient/AutoMlBaseClient.php +++ /dev/null @@ -1,857 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/auto_ml_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/auto_ml_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/auto_ml_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/auto_ml_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * annotation_spec resource. - * - * @param string $project - * @param string $location - * @param string $dataset - * @param string $annotationSpec - * - * @return string The formatted annotation_spec resource. - */ - public static function annotationSpecName(string $project, string $location, string $dataset, string $annotationSpec): string - { - return self::getPathTemplate('annotationSpec')->render([ - 'project' => $project, - 'location' => $location, - 'dataset' => $dataset, - 'annotation_spec' => $annotationSpec, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a dataset - * resource. - * - * @param string $project - * @param string $location - * @param string $dataset - * - * @return string The formatted dataset resource. - */ - public static function datasetName(string $project, string $location, string $dataset): string - { - return self::getPathTemplate('dataset')->render([ - 'project' => $project, - 'location' => $location, - 'dataset' => $dataset, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a model - * resource. - * - * @param string $project - * @param string $location - * @param string $model - * - * @return string The formatted model resource. - */ - public static function modelName(string $project, string $location, string $model): string - { - return self::getPathTemplate('model')->render([ - 'project' => $project, - 'location' => $location, - 'model' => $model, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * model_evaluation resource. - * - * @param string $project - * @param string $location - * @param string $model - * @param string $modelEvaluation - * - * @return string The formatted model_evaluation resource. - */ - public static function modelEvaluationName(string $project, string $location, string $model, string $modelEvaluation): string - { - return self::getPathTemplate('modelEvaluation')->render([ - 'project' => $project, - 'location' => $location, - 'model' => $model, - 'model_evaluation' => $modelEvaluation, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - annotationSpec: projects/{project}/locations/{location}/datasets/{dataset}/annotationSpecs/{annotation_spec} - * - dataset: projects/{project}/locations/{location}/datasets/{dataset} - * - location: projects/{project}/locations/{location} - * - model: projects/{project}/locations/{location}/models/{model} - * - modelEvaluation: projects/{project}/locations/{location}/models/{model}/modelEvaluations/{model_evaluation} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'automl.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a dataset. - * - * The async variant is {@see self::createDatasetAsync()} . - * - * @param CreateDatasetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDataset(CreateDatasetRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateDataset', $request, $callOptions)->wait(); - } - - /** - * Creates a model. - * Returns a Model in the [response][google.longrunning.Operation.response] - * field when it completes. - * When you create a model, several model evaluations are created for it: - * a global evaluation, and one evaluation for each annotation spec. - * - * The async variant is {@see self::createModelAsync()} . - * - * @param CreateModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createModel(CreateModelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateModel', $request, $callOptions)->wait(); - } - - /** - * Deletes a dataset and all of its contents. - * Returns empty response in the - * [response][google.longrunning.Operation.response] field when it completes, - * and `delete_details` in the - * [metadata][google.longrunning.Operation.metadata] field. - * - * The async variant is {@see self::deleteDatasetAsync()} . - * - * @param DeleteDatasetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDataset(DeleteDatasetRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteDataset', $request, $callOptions)->wait(); - } - - /** - * Deletes a model. - * Returns `google.protobuf.Empty` in the - * [response][google.longrunning.Operation.response] field when it completes, - * and `delete_details` in the - * [metadata][google.longrunning.Operation.metadata] field. - * - * The async variant is {@see self::deleteModelAsync()} . - * - * @param DeleteModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteModel(DeleteModelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteModel', $request, $callOptions)->wait(); - } - - /** - * Deploys a model. If a model is already deployed, deploying it with the - * same parameters has no effect. Deploying with different parametrs - * (as e.g. changing - * [node_number][google.cloud.automl.v1p1beta.ImageObjectDetectionModelDeploymentMetadata.node_number]) - * will reset the deployment state without pausing the model's availability. - * - * Only applicable for Text Classification, Image Object Detection , Tables, and Image Segmentation; all other domains manage - * deployment automatically. - * - * Returns an empty response in the - * [response][google.longrunning.Operation.response] field when it completes. - * - * The async variant is {@see self::deployModelAsync()} . - * - * @param DeployModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deployModel(DeployModelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeployModel', $request, $callOptions)->wait(); - } - - /** - * Exports dataset's data to the provided output location. - * Returns an empty response in the - * [response][google.longrunning.Operation.response] field when it completes. - * - * The async variant is {@see self::exportDataAsync()} . - * - * @param ExportDataRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function exportData(ExportDataRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ExportData', $request, $callOptions)->wait(); - } - - /** - * Exports a trained, "export-able", model to a user specified Google Cloud - * Storage location. A model is considered export-able if and only if it has - * an export format defined for it in - * [ModelExportOutputConfig][google.cloud.automl.v1.ModelExportOutputConfig]. - * - * Returns an empty response in the - * [response][google.longrunning.Operation.response] field when it completes. - * - * The async variant is {@see self::exportModelAsync()} . - * - * @param ExportModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function exportModel(ExportModelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ExportModel', $request, $callOptions)->wait(); - } - - /** - * Gets an annotation spec. - * - * The async variant is {@see self::getAnnotationSpecAsync()} . - * - * @param GetAnnotationSpecRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AnnotationSpec - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAnnotationSpec(GetAnnotationSpecRequest $request, array $callOptions = []): AnnotationSpec - { - return $this->startApiCall('GetAnnotationSpec', $request, $callOptions)->wait(); - } - - /** - * Gets a dataset. - * - * The async variant is {@see self::getDatasetAsync()} . - * - * @param GetDatasetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Dataset - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDataset(GetDatasetRequest $request, array $callOptions = []): Dataset - { - return $this->startApiCall('GetDataset', $request, $callOptions)->wait(); - } - - /** - * Gets a model. - * - * The async variant is {@see self::getModelAsync()} . - * - * @param GetModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Model - * - * @throws ApiException Thrown if the API call fails. - */ - public function getModel(GetModelRequest $request, array $callOptions = []): Model - { - return $this->startApiCall('GetModel', $request, $callOptions)->wait(); - } - - /** - * Gets a model evaluation. - * - * The async variant is {@see self::getModelEvaluationAsync()} . - * - * @param GetModelEvaluationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ModelEvaluation - * - * @throws ApiException Thrown if the API call fails. - */ - public function getModelEvaluation(GetModelEvaluationRequest $request, array $callOptions = []): ModelEvaluation - { - return $this->startApiCall('GetModelEvaluation', $request, $callOptions)->wait(); - } - - /** - * Imports data into a dataset. - * For Tables this method can only be called on an empty Dataset. - * - * For Tables: - * * A - * [schema_inference_version][google.cloud.automl.v1.InputConfig.params] - * parameter must be explicitly set. - * Returns an empty response in the - * [response][google.longrunning.Operation.response] field when it completes. - * - * The async variant is {@see self::importDataAsync()} . - * - * @param ImportDataRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function importData(ImportDataRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ImportData', $request, $callOptions)->wait(); - } - - /** - * Lists datasets in a project. - * - * The async variant is {@see self::listDatasetsAsync()} . - * - * @param ListDatasetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDatasets(ListDatasetsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDatasets', $request, $callOptions); - } - - /** - * Lists model evaluations. - * - * The async variant is {@see self::listModelEvaluationsAsync()} . - * - * @param ListModelEvaluationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listModelEvaluations(ListModelEvaluationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListModelEvaluations', $request, $callOptions); - } - - /** - * Lists models. - * - * The async variant is {@see self::listModelsAsync()} . - * - * @param ListModelsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listModels(ListModelsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListModels', $request, $callOptions); - } - - /** - * Undeploys a model. If the model is not deployed this method has no effect. - * - * Only applicable for Text Classification, Image Object Detection and Tables; - * all other domains manage deployment automatically. - * - * Returns an empty response in the - * [response][google.longrunning.Operation.response] field when it completes. - * - * The async variant is {@see self::undeployModelAsync()} . - * - * @param UndeployModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function undeployModel(UndeployModelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UndeployModel', $request, $callOptions)->wait(); - } - - /** - * Updates a dataset. - * - * The async variant is {@see self::updateDatasetAsync()} . - * - * @param UpdateDatasetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Dataset - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDataset(UpdateDatasetRequest $request, array $callOptions = []): Dataset - { - return $this->startApiCall('UpdateDataset', $request, $callOptions)->wait(); - } - - /** - * Updates a model. - * - * The async variant is {@see self::updateModelAsync()} . - * - * @param UpdateModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Model - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateModel(UpdateModelRequest $request, array $callOptions = []): Model - { - return $this->startApiCall('UpdateModel', $request, $callOptions)->wait(); - } -} diff --git a/AutoMl/src/V1/Client/BaseClient/PredictionServiceBaseClient.php b/AutoMl/src/V1/Client/BaseClient/PredictionServiceBaseClient.php deleted file mode 100644 index 7ed04fca0cfd..000000000000 --- a/AutoMl/src/V1/Client/BaseClient/PredictionServiceBaseClient.php +++ /dev/null @@ -1,351 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/prediction_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/prediction_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/prediction_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/prediction_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a model - * resource. - * - * @param string $project - * @param string $location - * @param string $model - * - * @return string The formatted model resource. - */ - public static function modelName(string $project, string $location, string $model): string - { - return self::getPathTemplate('model')->render([ - 'project' => $project, - 'location' => $location, - 'model' => $model, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - model: projects/{project}/locations/{location}/models/{model} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'automl.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Perform a batch prediction. Unlike the online [Predict][google.cloud.automl.v1.PredictionService.Predict], batch - * prediction result won't be immediately available in the response. Instead, - * a long running operation object is returned. User can poll the operation - * result via [GetOperation][google.longrunning.Operations.GetOperation] - * method. Once the operation is done, [BatchPredictResult][google.cloud.automl.v1.BatchPredictResult] is returned in - * the [response][google.longrunning.Operation.response] field. - * Available for following ML scenarios: - * - * * AutoML Vision Classification - * * AutoML Vision Object Detection - * * AutoML Video Intelligence Classification - * * AutoML Video Intelligence Object Tracking * AutoML Natural Language Classification - * * AutoML Natural Language Entity Extraction - * * AutoML Natural Language Sentiment Analysis - * * AutoML Tables - * - * The async variant is {@see self::batchPredictAsync()} . - * - * @param BatchPredictRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchPredict(BatchPredictRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BatchPredict', $request, $callOptions)->wait(); - } - - /** - * Perform an online prediction. The prediction result is directly - * returned in the response. - * Available for following ML scenarios, and their expected request payloads: - * - * AutoML Vision Classification - * - * * An image in .JPEG, .GIF or .PNG format, image_bytes up to 30MB. - * - * AutoML Vision Object Detection - * - * * An image in .JPEG, .GIF or .PNG format, image_bytes up to 30MB. - * - * AutoML Natural Language Classification - * - * * A TextSnippet up to 60,000 characters, UTF-8 encoded or a document in - * .PDF, .TIF or .TIFF format with size upto 2MB. - * - * AutoML Natural Language Entity Extraction - * - * * A TextSnippet up to 10,000 characters, UTF-8 NFC encoded or a document - * in .PDF, .TIF or .TIFF format with size upto 20MB. - * - * AutoML Natural Language Sentiment Analysis - * - * * A TextSnippet up to 60,000 characters, UTF-8 encoded or a document in - * .PDF, .TIF or .TIFF format with size upto 2MB. - * - * AutoML Translation - * - * * A TextSnippet up to 25,000 characters, UTF-8 encoded. - * - * AutoML Tables - * - * * A row with column values matching - * the columns of the model, up to 5MB. Not available for FORECASTING - * `prediction_type`. - * - * The async variant is {@see self::predictAsync()} . - * - * @param PredictRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PredictResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function predict(PredictRequest $request, array $callOptions = []): PredictResponse - { - return $this->startApiCall('Predict', $request, $callOptions)->wait(); - } -} diff --git a/AutoMl/src/V1/Client/PredictionServiceClient.php b/AutoMl/src/V1/Client/PredictionServiceClient.php index d92ea0efc478..2cf4fdaea479 100644 --- a/AutoMl/src/V1/Client/PredictionServiceClient.php +++ b/AutoMl/src/V1/Client/PredictionServiceClient.php @@ -24,17 +24,326 @@ namespace Google\Cloud\AutoMl\V1\Client; -use Google\Cloud\AutoMl\V1\Client\BaseClient\PredictionServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\AutoMl\V1\BatchPredictRequest; +use Google\Cloud\AutoMl\V1\BatchPredictResult; +use Google\Cloud\AutoMl\V1\PredictRequest; +use Google\Cloud\AutoMl\V1\PredictResponse; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: AutoML Prediction API. * - * This class is currently experimental and may be subject to changes. + * On any input that is documented to expect a string parameter in + * snake_case or dash-case, either of those cases is accepted. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\AutoMl\V1\PredictionServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface batchPredictAsync(BatchPredictRequest $request, array $optionalArgs = []) + * @method PromiseInterface predictAsync(PredictRequest $request, array $optionalArgs = []) */ -final class PredictionServiceClient extends PredictionServiceBaseClient +final class PredictionServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see PredictionServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.automl.v1.PredictionService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'automl.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/prediction_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/prediction_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/prediction_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/prediction_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a model + * resource. + * + * @param string $project + * @param string $location + * @param string $model + * + * @return string The formatted model resource. + */ + public static function modelName(string $project, string $location, string $model): string + { + return self::getPathTemplate('model')->render([ + 'project' => $project, + 'location' => $location, + 'model' => $model, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - model: projects/{project}/locations/{location}/models/{model} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'automl.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Perform a batch prediction. Unlike the online [Predict][google.cloud.automl.v1.PredictionService.Predict], batch + * prediction result won't be immediately available in the response. Instead, + * a long running operation object is returned. User can poll the operation + * result via [GetOperation][google.longrunning.Operations.GetOperation] + * method. Once the operation is done, [BatchPredictResult][google.cloud.automl.v1.BatchPredictResult] is returned in + * the [response][google.longrunning.Operation.response] field. + * Available for following ML scenarios: + * + * * AutoML Vision Classification + * * AutoML Vision Object Detection + * * AutoML Video Intelligence Classification + * * AutoML Video Intelligence Object Tracking * AutoML Natural Language Classification + * * AutoML Natural Language Entity Extraction + * * AutoML Natural Language Sentiment Analysis + * * AutoML Tables + * + * The async variant is {@see PredictionServiceClient::batchPredictAsync()} . + * + * @param BatchPredictRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchPredict(BatchPredictRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchPredict', $request, $callOptions)->wait(); + } + + /** + * Perform an online prediction. The prediction result is directly + * returned in the response. + * Available for following ML scenarios, and their expected request payloads: + * + * AutoML Vision Classification + * + * * An image in .JPEG, .GIF or .PNG format, image_bytes up to 30MB. + * + * AutoML Vision Object Detection + * + * * An image in .JPEG, .GIF or .PNG format, image_bytes up to 30MB. + * + * AutoML Natural Language Classification + * + * * A TextSnippet up to 60,000 characters, UTF-8 encoded or a document in + * .PDF, .TIF or .TIFF format with size upto 2MB. + * + * AutoML Natural Language Entity Extraction + * + * * A TextSnippet up to 10,000 characters, UTF-8 NFC encoded or a document + * in .PDF, .TIF or .TIFF format with size upto 20MB. + * + * AutoML Natural Language Sentiment Analysis + * + * * A TextSnippet up to 60,000 characters, UTF-8 encoded or a document in + * .PDF, .TIF or .TIFF format with size upto 2MB. + * + * AutoML Translation + * + * * A TextSnippet up to 25,000 characters, UTF-8 encoded. + * + * AutoML Tables + * + * * A row with column values matching + * the columns of the model, up to 5MB. Not available for FORECASTING + * `prediction_type`. + * + * The async variant is {@see PredictionServiceClient::predictAsync()} . + * + * @param PredictRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PredictResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function predict(PredictRequest $request, array $callOptions = []): PredictResponse + { + return $this->startApiCall('Predict', $request, $callOptions)->wait(); + } } diff --git a/BareMetalSolution/composer.json b/BareMetalSolution/composer.json index 5170b98cd997..30958d10bc0a 100644 --- a/BareMetalSolution/composer.json +++ b/BareMetalSolution/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/BareMetalSolution/src/V2/Client/BareMetalSolutionClient.php b/BareMetalSolution/src/V2/Client/BareMetalSolutionClient.php index 7e5ecbfe0137..e65576fe2aed 100644 --- a/BareMetalSolution/src/V2/Client/BareMetalSolutionClient.php +++ b/BareMetalSolution/src/V2/Client/BareMetalSolutionClient.php @@ -24,17 +24,1813 @@ namespace Google\Cloud\BareMetalSolution\V2\Client; -use Google\Cloud\BareMetalSolution\V2\Client\BaseClient\BareMetalSolutionBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\BareMetalSolution\V2\CreateNfsShareRequest; +use Google\Cloud\BareMetalSolution\V2\CreateProvisioningConfigRequest; +use Google\Cloud\BareMetalSolution\V2\CreateSSHKeyRequest; +use Google\Cloud\BareMetalSolution\V2\CreateVolumeSnapshotRequest; +use Google\Cloud\BareMetalSolution\V2\DeleteNfsShareRequest; +use Google\Cloud\BareMetalSolution\V2\DeleteSSHKeyRequest; +use Google\Cloud\BareMetalSolution\V2\DeleteVolumeSnapshotRequest; +use Google\Cloud\BareMetalSolution\V2\DetachLunRequest; +use Google\Cloud\BareMetalSolution\V2\DisableInteractiveSerialConsoleRequest; +use Google\Cloud\BareMetalSolution\V2\EnableInteractiveSerialConsoleRequest; +use Google\Cloud\BareMetalSolution\V2\EvictLunRequest; +use Google\Cloud\BareMetalSolution\V2\EvictVolumeRequest; +use Google\Cloud\BareMetalSolution\V2\GetInstanceRequest; +use Google\Cloud\BareMetalSolution\V2\GetLunRequest; +use Google\Cloud\BareMetalSolution\V2\GetNetworkRequest; +use Google\Cloud\BareMetalSolution\V2\GetNfsShareRequest; +use Google\Cloud\BareMetalSolution\V2\GetProvisioningConfigRequest; +use Google\Cloud\BareMetalSolution\V2\GetVolumeRequest; +use Google\Cloud\BareMetalSolution\V2\GetVolumeSnapshotRequest; +use Google\Cloud\BareMetalSolution\V2\Instance; +use Google\Cloud\BareMetalSolution\V2\ListInstancesRequest; +use Google\Cloud\BareMetalSolution\V2\ListLunsRequest; +use Google\Cloud\BareMetalSolution\V2\ListNetworkUsageRequest; +use Google\Cloud\BareMetalSolution\V2\ListNetworkUsageResponse; +use Google\Cloud\BareMetalSolution\V2\ListNetworksRequest; +use Google\Cloud\BareMetalSolution\V2\ListNfsSharesRequest; +use Google\Cloud\BareMetalSolution\V2\ListOSImagesRequest; +use Google\Cloud\BareMetalSolution\V2\ListProvisioningQuotasRequest; +use Google\Cloud\BareMetalSolution\V2\ListSSHKeysRequest; +use Google\Cloud\BareMetalSolution\V2\ListVolumeSnapshotsRequest; +use Google\Cloud\BareMetalSolution\V2\ListVolumesRequest; +use Google\Cloud\BareMetalSolution\V2\Lun; +use Google\Cloud\BareMetalSolution\V2\Network; +use Google\Cloud\BareMetalSolution\V2\NfsShare; +use Google\Cloud\BareMetalSolution\V2\ProvisioningConfig; +use Google\Cloud\BareMetalSolution\V2\RenameInstanceRequest; +use Google\Cloud\BareMetalSolution\V2\RenameNetworkRequest; +use Google\Cloud\BareMetalSolution\V2\RenameNfsShareRequest; +use Google\Cloud\BareMetalSolution\V2\RenameVolumeRequest; +use Google\Cloud\BareMetalSolution\V2\ResetInstanceRequest; +use Google\Cloud\BareMetalSolution\V2\ResizeVolumeRequest; +use Google\Cloud\BareMetalSolution\V2\RestoreVolumeSnapshotRequest; +use Google\Cloud\BareMetalSolution\V2\SSHKey; +use Google\Cloud\BareMetalSolution\V2\StartInstanceRequest; +use Google\Cloud\BareMetalSolution\V2\StopInstanceRequest; +use Google\Cloud\BareMetalSolution\V2\SubmitProvisioningConfigRequest; +use Google\Cloud\BareMetalSolution\V2\SubmitProvisioningConfigResponse; +use Google\Cloud\BareMetalSolution\V2\UpdateInstanceRequest; +use Google\Cloud\BareMetalSolution\V2\UpdateNetworkRequest; +use Google\Cloud\BareMetalSolution\V2\UpdateNfsShareRequest; +use Google\Cloud\BareMetalSolution\V2\UpdateProvisioningConfigRequest; +use Google\Cloud\BareMetalSolution\V2\UpdateVolumeRequest; +use Google\Cloud\BareMetalSolution\V2\Volume; +use Google\Cloud\BareMetalSolution\V2\VolumeSnapshot; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Performs management operations on Bare Metal Solution servers. * - * This class is currently experimental and may be subject to changes. + * The `baremetalsolution.googleapis.com` service provides management + * capabilities for Bare Metal Solution servers. To access the API methods, you + * must assign Bare Metal Solution IAM roles containing the desired permissions + * to your staff in your Google Cloud project. You must also enable the Bare + * Metal Solution API. Once enabled, the methods act + * upon specific servers in your Bare Metal Solution environment. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\BareMetalSolution\V2\BareMetalSolutionClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createNfsShareAsync(CreateNfsShareRequest $request, array $optionalArgs = []) + * @method PromiseInterface createProvisioningConfigAsync(CreateProvisioningConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSSHKeyAsync(CreateSSHKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface createVolumeSnapshotAsync(CreateVolumeSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteNfsShareAsync(DeleteNfsShareRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSSHKeyAsync(DeleteSSHKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteVolumeSnapshotAsync(DeleteVolumeSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface detachLunAsync(DetachLunRequest $request, array $optionalArgs = []) + * @method PromiseInterface disableInteractiveSerialConsoleAsync(DisableInteractiveSerialConsoleRequest $request, array $optionalArgs = []) + * @method PromiseInterface enableInteractiveSerialConsoleAsync(EnableInteractiveSerialConsoleRequest $request, array $optionalArgs = []) + * @method PromiseInterface evictLunAsync(EvictLunRequest $request, array $optionalArgs = []) + * @method PromiseInterface evictVolumeAsync(EvictVolumeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInstanceAsync(GetInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLunAsync(GetLunRequest $request, array $optionalArgs = []) + * @method PromiseInterface getNetworkAsync(GetNetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface getNfsShareAsync(GetNfsShareRequest $request, array $optionalArgs = []) + * @method PromiseInterface getProvisioningConfigAsync(GetProvisioningConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getVolumeAsync(GetVolumeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getVolumeSnapshotAsync(GetVolumeSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInstancesAsync(ListInstancesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLunsAsync(ListLunsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listNetworkUsageAsync(ListNetworkUsageRequest $request, array $optionalArgs = []) + * @method PromiseInterface listNetworksAsync(ListNetworksRequest $request, array $optionalArgs = []) + * @method PromiseInterface listNfsSharesAsync(ListNfsSharesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listOSImagesAsync(ListOSImagesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listProvisioningQuotasAsync(ListProvisioningQuotasRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSSHKeysAsync(ListSSHKeysRequest $request, array $optionalArgs = []) + * @method PromiseInterface listVolumeSnapshotsAsync(ListVolumeSnapshotsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listVolumesAsync(ListVolumesRequest $request, array $optionalArgs = []) + * @method PromiseInterface renameInstanceAsync(RenameInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface renameNetworkAsync(RenameNetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface renameNfsShareAsync(RenameNfsShareRequest $request, array $optionalArgs = []) + * @method PromiseInterface renameVolumeAsync(RenameVolumeRequest $request, array $optionalArgs = []) + * @method PromiseInterface resetInstanceAsync(ResetInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface resizeVolumeAsync(ResizeVolumeRequest $request, array $optionalArgs = []) + * @method PromiseInterface restoreVolumeSnapshotAsync(RestoreVolumeSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface startInstanceAsync(StartInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface stopInstanceAsync(StopInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface submitProvisioningConfigAsync(SubmitProvisioningConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateInstanceAsync(UpdateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateNetworkAsync(UpdateNetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateNfsShareAsync(UpdateNfsShareRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateProvisioningConfigAsync(UpdateProvisioningConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateVolumeAsync(UpdateVolumeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class BareMetalSolutionClient extends BareMetalSolutionBaseClient +final class BareMetalSolutionClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see BareMetalSolutionBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.baremetalsolution.v2.BareMetalSolution'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'baremetalsolution.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/bare_metal_solution_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/bare_metal_solution_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/bare_metal_solution_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/bare_metal_solution_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a instance + * resource. + * + * @param string $project + * @param string $location + * @param string $instance + * + * @return string The formatted instance resource. + */ + public static function instanceName(string $project, string $location, string $instance): string + { + return self::getPathTemplate('instance')->render([ + 'project' => $project, + 'location' => $location, + 'instance' => $instance, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * instance_config resource. + * + * @param string $project + * @param string $location + * @param string $instanceConfig + * + * @return string The formatted instance_config resource. + */ + public static function instanceConfigName(string $project, string $location, string $instanceConfig): string + { + return self::getPathTemplate('instanceConfig')->render([ + 'project' => $project, + 'location' => $location, + 'instance_config' => $instanceConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * interconnect_attachment resource. + * + * @param string $project + * @param string $region + * @param string $interconnectAttachment + * + * @return string The formatted interconnect_attachment resource. + */ + public static function interconnectAttachmentName(string $project, string $region, string $interconnectAttachment): string + { + return self::getPathTemplate('interconnectAttachment')->render([ + 'project' => $project, + 'region' => $region, + 'interconnect_attachment' => $interconnectAttachment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a lun + * resource. + * + * @param string $project + * @param string $location + * @param string $volume + * @param string $lun + * + * @return string The formatted lun resource. + */ + public static function lunName(string $project, string $location, string $volume, string $lun): string + { + return self::getPathTemplate('lun')->render([ + 'project' => $project, + 'location' => $location, + 'volume' => $volume, + 'lun' => $lun, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a nfs_share + * resource. + * + * @param string $project + * @param string $location + * @param string $nfsShare + * + * @return string The formatted nfs_share resource. + */ + public static function nFSShareName(string $project, string $location, string $nfsShare): string + { + return self::getPathTemplate('nFSShare')->render([ + 'project' => $project, + 'location' => $location, + 'nfs_share' => $nfsShare, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a network + * resource. + * + * @param string $project + * @param string $location + * @param string $network + * + * @return string The formatted network resource. + */ + public static function networkName(string $project, string $location, string $network): string + { + return self::getPathTemplate('network')->render([ + 'project' => $project, + 'location' => $location, + 'network' => $network, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * network_config resource. + * + * @param string $project + * @param string $location + * @param string $networkConfig + * + * @return string The formatted network_config resource. + */ + public static function networkConfigName(string $project, string $location, string $networkConfig): string + { + return self::getPathTemplate('networkConfig')->render([ + 'project' => $project, + 'location' => $location, + 'network_config' => $networkConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * provisioning_config resource. + * + * @param string $project + * @param string $location + * @param string $provisioningConfig + * + * @return string The formatted provisioning_config resource. + */ + public static function provisioningConfigName(string $project, string $location, string $provisioningConfig): string + { + return self::getPathTemplate('provisioningConfig')->render([ + 'project' => $project, + 'location' => $location, + 'provisioning_config' => $provisioningConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * server_network_template resource. + * + * @param string $project + * @param string $location + * @param string $serverNetworkTemplate + * + * @return string The formatted server_network_template resource. + */ + public static function serverNetworkTemplateName(string $project, string $location, string $serverNetworkTemplate): string + { + return self::getPathTemplate('serverNetworkTemplate')->render([ + 'project' => $project, + 'location' => $location, + 'server_network_template' => $serverNetworkTemplate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a ssh_key + * resource. + * + * @param string $project + * @param string $location + * @param string $sshKey + * + * @return string The formatted ssh_key resource. + */ + public static function sshKeyName(string $project, string $location, string $sshKey): string + { + return self::getPathTemplate('sshKey')->render([ + 'project' => $project, + 'location' => $location, + 'ssh_key' => $sshKey, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a volume + * resource. + * + * @param string $project + * @param string $location + * @param string $volume + * + * @return string The formatted volume resource. + */ + public static function volumeName(string $project, string $location, string $volume): string + { + return self::getPathTemplate('volume')->render([ + 'project' => $project, + 'location' => $location, + 'volume' => $volume, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * volume_config resource. + * + * @param string $project + * @param string $location + * @param string $volumeConfig + * + * @return string The formatted volume_config resource. + */ + public static function volumeConfigName(string $project, string $location, string $volumeConfig): string + { + return self::getPathTemplate('volumeConfig')->render([ + 'project' => $project, + 'location' => $location, + 'volume_config' => $volumeConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * volume_snapshot resource. + * + * @param string $project + * @param string $location + * @param string $volume + * @param string $snapshot + * + * @return string The formatted volume_snapshot resource. + */ + public static function volumeSnapshotName(string $project, string $location, string $volume, string $snapshot): string + { + return self::getPathTemplate('volumeSnapshot')->render([ + 'project' => $project, + 'location' => $location, + 'volume' => $volume, + 'snapshot' => $snapshot, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - instance: projects/{project}/locations/{location}/instances/{instance} + * - instanceConfig: projects/{project}/locations/{location}/instanceConfigs/{instance_config} + * - interconnectAttachment: projects/{project}/regions/{region}/interconnectAttachments/{interconnect_attachment} + * - location: projects/{project}/locations/{location} + * - lun: projects/{project}/locations/{location}/volumes/{volume}/luns/{lun} + * - nFSShare: projects/{project}/locations/{location}/nfsShares/{nfs_share} + * - network: projects/{project}/locations/{location}/networks/{network} + * - networkConfig: projects/{project}/locations/{location}/networkConfigs/{network_config} + * - provisioningConfig: projects/{project}/locations/{location}/provisioningConfigs/{provisioning_config} + * - serverNetworkTemplate: projects/{project}/locations/{location}/serverNetworkTemplate/{server_network_template} + * - sshKey: projects/{project}/locations/{location}/sshKeys/{ssh_key} + * - volume: projects/{project}/locations/{location}/volumes/{volume} + * - volumeConfig: projects/{project}/locations/{location}/volumeConfigs/{volume_config} + * - volumeSnapshot: projects/{project}/locations/{location}/volumes/{volume}/snapshots/{snapshot} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'baremetalsolution.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Create an NFS share. + * + * The async variant is {@see BareMetalSolutionClient::createNfsShareAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/create_nfs_share.php + * + * @param CreateNfsShareRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createNfsShare(CreateNfsShareRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateNfsShare', $request, $callOptions)->wait(); + } + + /** + * Create new ProvisioningConfig. + * + * The async variant is + * {@see BareMetalSolutionClient::createProvisioningConfigAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/create_provisioning_config.php + * + * @param CreateProvisioningConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ProvisioningConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function createProvisioningConfig(CreateProvisioningConfigRequest $request, array $callOptions = []): ProvisioningConfig + { + return $this->startApiCall('CreateProvisioningConfig', $request, $callOptions)->wait(); + } + + /** + * Register a public SSH key in the specified project for use with the + * interactive serial console feature. + * + * The async variant is {@see BareMetalSolutionClient::createSSHKeyAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/create_ssh_key.php + * + * @param CreateSSHKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SSHKey + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSSHKey(CreateSSHKeyRequest $request, array $callOptions = []): SSHKey + { + return $this->startApiCall('CreateSSHKey', $request, $callOptions)->wait(); + } + + /** + * Takes a snapshot of a boot volume. + * Returns INVALID_ARGUMENT if called for a non-boot volume. + * + * The async variant is {@see BareMetalSolutionClient::createVolumeSnapshotAsync()} + * . + * + * @example samples/V2/BareMetalSolutionClient/create_volume_snapshot.php + * + * @param CreateVolumeSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 VolumeSnapshot + * + * @throws ApiException Thrown if the API call fails. + */ + public function createVolumeSnapshot(CreateVolumeSnapshotRequest $request, array $callOptions = []): VolumeSnapshot + { + return $this->startApiCall('CreateVolumeSnapshot', $request, $callOptions)->wait(); + } + + /** + * Delete an NFS share. The underlying volume is automatically deleted. + * + * The async variant is {@see BareMetalSolutionClient::deleteNfsShareAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/delete_nfs_share.php + * + * @param DeleteNfsShareRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteNfsShare(DeleteNfsShareRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteNfsShare', $request, $callOptions)->wait(); + } + + /** + * Deletes a public SSH key registered in the specified project. + * + * The async variant is {@see BareMetalSolutionClient::deleteSSHKeyAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/delete_ssh_key.php + * + * @param DeleteSSHKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSSHKey(DeleteSSHKeyRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteSSHKey', $request, $callOptions)->wait(); + } + + /** + * Deletes a volume snapshot. + * Returns INVALID_ARGUMENT if called for a non-boot volume. + * + * The async variant is {@see BareMetalSolutionClient::deleteVolumeSnapshotAsync()} + * . + * + * @example samples/V2/BareMetalSolutionClient/delete_volume_snapshot.php + * + * @param DeleteVolumeSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteVolumeSnapshot(DeleteVolumeSnapshotRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteVolumeSnapshot', $request, $callOptions)->wait(); + } + + /** + * Detach LUN from Instance. + * + * The async variant is {@see BareMetalSolutionClient::detachLunAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/detach_lun.php + * + * @param DetachLunRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function detachLun(DetachLunRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DetachLun', $request, $callOptions)->wait(); + } + + /** + * Disable the interactive serial console feature on an instance. + * + * The async variant is + * {@see BareMetalSolutionClient::disableInteractiveSerialConsoleAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/disable_interactive_serial_console.php + * + * @param DisableInteractiveSerialConsoleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function disableInteractiveSerialConsole(DisableInteractiveSerialConsoleRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DisableInteractiveSerialConsole', $request, $callOptions)->wait(); + } + + /** + * Enable the interactive serial console feature on an instance. + * + * The async variant is + * {@see BareMetalSolutionClient::enableInteractiveSerialConsoleAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/enable_interactive_serial_console.php + * + * @param EnableInteractiveSerialConsoleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function enableInteractiveSerialConsole(EnableInteractiveSerialConsoleRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('EnableInteractiveSerialConsole', $request, $callOptions)->wait(); + } + + /** + * Skips lun's cooloff and deletes it now. + * Lun must be in cooloff state. + * + * The async variant is {@see BareMetalSolutionClient::evictLunAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/evict_lun.php + * + * @param EvictLunRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function evictLun(EvictLunRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('EvictLun', $request, $callOptions)->wait(); + } + + /** + * Skips volume's cooloff and deletes it now. + * Volume must be in cooloff state. + * + * The async variant is {@see BareMetalSolutionClient::evictVolumeAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/evict_volume.php + * + * @param EvictVolumeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function evictVolume(EvictVolumeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('EvictVolume', $request, $callOptions)->wait(); + } + + /** + * Get details about a single server. + * + * The async variant is {@see BareMetalSolutionClient::getInstanceAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/get_instance.php + * + * @param GetInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Instance + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance + { + return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); + } + + /** + * Get details of a single storage logical unit number(LUN). + * + * The async variant is {@see BareMetalSolutionClient::getLunAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/get_lun.php + * + * @param GetLunRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Lun + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLun(GetLunRequest $request, array $callOptions = []): Lun + { + return $this->startApiCall('GetLun', $request, $callOptions)->wait(); + } + + /** + * Get details of a single network. + * + * The async variant is {@see BareMetalSolutionClient::getNetworkAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/get_network.php + * + * @param GetNetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Network + * + * @throws ApiException Thrown if the API call fails. + */ + public function getNetwork(GetNetworkRequest $request, array $callOptions = []): Network + { + return $this->startApiCall('GetNetwork', $request, $callOptions)->wait(); + } + + /** + * Get details of a single NFS share. + * + * The async variant is {@see BareMetalSolutionClient::getNfsShareAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/get_nfs_share.php + * + * @param GetNfsShareRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NfsShare + * + * @throws ApiException Thrown if the API call fails. + */ + public function getNfsShare(GetNfsShareRequest $request, array $callOptions = []): NfsShare + { + return $this->startApiCall('GetNfsShare', $request, $callOptions)->wait(); + } + + /** + * Get ProvisioningConfig by name. + * + * The async variant is + * {@see BareMetalSolutionClient::getProvisioningConfigAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/get_provisioning_config.php + * + * @param GetProvisioningConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ProvisioningConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getProvisioningConfig(GetProvisioningConfigRequest $request, array $callOptions = []): ProvisioningConfig + { + return $this->startApiCall('GetProvisioningConfig', $request, $callOptions)->wait(); + } + + /** + * Get details of a single storage volume. + * + * The async variant is {@see BareMetalSolutionClient::getVolumeAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/get_volume.php + * + * @param GetVolumeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Volume + * + * @throws ApiException Thrown if the API call fails. + */ + public function getVolume(GetVolumeRequest $request, array $callOptions = []): Volume + { + return $this->startApiCall('GetVolume', $request, $callOptions)->wait(); + } + + /** + * Returns the specified snapshot resource. + * Returns INVALID_ARGUMENT if called for a non-boot volume. + * + * The async variant is {@see BareMetalSolutionClient::getVolumeSnapshotAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/get_volume_snapshot.php + * + * @param GetVolumeSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 VolumeSnapshot + * + * @throws ApiException Thrown if the API call fails. + */ + public function getVolumeSnapshot(GetVolumeSnapshotRequest $request, array $callOptions = []): VolumeSnapshot + { + return $this->startApiCall('GetVolumeSnapshot', $request, $callOptions)->wait(); + } + + /** + * List servers in a given project and location. + * + * The async variant is {@see BareMetalSolutionClient::listInstancesAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/list_instances.php + * + * @param ListInstancesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInstances(ListInstancesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInstances', $request, $callOptions); + } + + /** + * List storage volume luns for given storage volume. + * + * The async variant is {@see BareMetalSolutionClient::listLunsAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/list_luns.php + * + * @param ListLunsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLuns(ListLunsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLuns', $request, $callOptions); + } + + /** + * List all Networks (and used IPs for each Network) in the vendor account + * associated with the specified project. + * + * The async variant is {@see BareMetalSolutionClient::listNetworkUsageAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/list_network_usage.php + * + * @param ListNetworkUsageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ListNetworkUsageResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listNetworkUsage(ListNetworkUsageRequest $request, array $callOptions = []): ListNetworkUsageResponse + { + return $this->startApiCall('ListNetworkUsage', $request, $callOptions)->wait(); + } + + /** + * List network in a given project and location. + * + * The async variant is {@see BareMetalSolutionClient::listNetworksAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/list_networks.php + * + * @param ListNetworksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listNetworks(ListNetworksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListNetworks', $request, $callOptions); + } + + /** + * List NFS shares. + * + * The async variant is {@see BareMetalSolutionClient::listNfsSharesAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/list_nfs_shares.php + * + * @param ListNfsSharesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listNfsShares(ListNfsSharesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListNfsShares', $request, $callOptions); + } + + /** + * Retrieves the list of OS images which are currently approved. + * + * The async variant is {@see BareMetalSolutionClient::listOSImagesAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/list_os_images.php + * + * @param ListOSImagesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listOSImages(ListOSImagesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListOSImages', $request, $callOptions); + } + + /** + * List the budget details to provision resources on a given project. + * + * The async variant is + * {@see BareMetalSolutionClient::listProvisioningQuotasAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/list_provisioning_quotas.php + * + * @param ListProvisioningQuotasRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listProvisioningQuotas(ListProvisioningQuotasRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListProvisioningQuotas', $request, $callOptions); + } + + /** + * Lists the public SSH keys registered for the specified project. + * These SSH keys are used only for the interactive serial console feature. + * + * The async variant is {@see BareMetalSolutionClient::listSSHKeysAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/list_ssh_keys.php + * + * @param ListSSHKeysRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSSHKeys(ListSSHKeysRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSSHKeys', $request, $callOptions); + } + + /** + * Retrieves the list of snapshots for the specified volume. + * Returns a response with an empty list of snapshots if called + * for a non-boot volume. + * + * The async variant is {@see BareMetalSolutionClient::listVolumeSnapshotsAsync()} + * . + * + * @example samples/V2/BareMetalSolutionClient/list_volume_snapshots.php + * + * @param ListVolumeSnapshotsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listVolumeSnapshots(ListVolumeSnapshotsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListVolumeSnapshots', $request, $callOptions); + } + + /** + * List storage volumes in a given project and location. + * + * The async variant is {@see BareMetalSolutionClient::listVolumesAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/list_volumes.php + * + * @param ListVolumesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listVolumes(ListVolumesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListVolumes', $request, $callOptions); + } + + /** + * RenameInstance sets a new name for an instance. + * Use with caution, previous names become immediately invalidated. + * + * The async variant is {@see BareMetalSolutionClient::renameInstanceAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/rename_instance.php + * + * @param RenameInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Instance + * + * @throws ApiException Thrown if the API call fails. + */ + public function renameInstance(RenameInstanceRequest $request, array $callOptions = []): Instance + { + return $this->startApiCall('RenameInstance', $request, $callOptions)->wait(); + } + + /** + * RenameNetwork sets a new name for a network. + * Use with caution, previous names become immediately invalidated. + * + * The async variant is {@see BareMetalSolutionClient::renameNetworkAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/rename_network.php + * + * @param RenameNetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Network + * + * @throws ApiException Thrown if the API call fails. + */ + public function renameNetwork(RenameNetworkRequest $request, array $callOptions = []): Network + { + return $this->startApiCall('RenameNetwork', $request, $callOptions)->wait(); + } + + /** + * RenameNfsShare sets a new name for an nfsshare. + * Use with caution, previous names become immediately invalidated. + * + * The async variant is {@see BareMetalSolutionClient::renameNfsShareAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/rename_nfs_share.php + * + * @param RenameNfsShareRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NfsShare + * + * @throws ApiException Thrown if the API call fails. + */ + public function renameNfsShare(RenameNfsShareRequest $request, array $callOptions = []): NfsShare + { + return $this->startApiCall('RenameNfsShare', $request, $callOptions)->wait(); + } + + /** + * RenameVolume sets a new name for a volume. + * Use with caution, previous names become immediately invalidated. + * + * The async variant is {@see BareMetalSolutionClient::renameVolumeAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/rename_volume.php + * + * @param RenameVolumeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Volume + * + * @throws ApiException Thrown if the API call fails. + */ + public function renameVolume(RenameVolumeRequest $request, array $callOptions = []): Volume + { + return $this->startApiCall('RenameVolume', $request, $callOptions)->wait(); + } + + /** + * Perform an ungraceful, hard reset on a server. Equivalent to shutting the + * power off and then turning it back on. + * + * The async variant is {@see BareMetalSolutionClient::resetInstanceAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/reset_instance.php + * + * @param ResetInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function resetInstance(ResetInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ResetInstance', $request, $callOptions)->wait(); + } + + /** + * Emergency Volume resize. + * + * The async variant is {@see BareMetalSolutionClient::resizeVolumeAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/resize_volume.php + * + * @param ResizeVolumeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function resizeVolume(ResizeVolumeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ResizeVolume', $request, $callOptions)->wait(); + } + + /** + * Uses the specified snapshot to restore its parent volume. + * Returns INVALID_ARGUMENT if called for a non-boot volume. + * + * The async variant is + * {@see BareMetalSolutionClient::restoreVolumeSnapshotAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/restore_volume_snapshot.php + * + * @param RestoreVolumeSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function restoreVolumeSnapshot(RestoreVolumeSnapshotRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RestoreVolumeSnapshot', $request, $callOptions)->wait(); + } + + /** + * Starts a server that was shutdown. + * + * The async variant is {@see BareMetalSolutionClient::startInstanceAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/start_instance.php + * + * @param StartInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function startInstance(StartInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StartInstance', $request, $callOptions)->wait(); + } + + /** + * Stop a running server. + * + * The async variant is {@see BareMetalSolutionClient::stopInstanceAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/stop_instance.php + * + * @param StopInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function stopInstance(StopInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StopInstance', $request, $callOptions)->wait(); + } + + /** + * Submit a provisiong configuration for a given project. + * + * The async variant is + * {@see BareMetalSolutionClient::submitProvisioningConfigAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/submit_provisioning_config.php + * + * @param SubmitProvisioningConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SubmitProvisioningConfigResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function submitProvisioningConfig(SubmitProvisioningConfigRequest $request, array $callOptions = []): SubmitProvisioningConfigResponse + { + return $this->startApiCall('SubmitProvisioningConfig', $request, $callOptions)->wait(); + } + + /** + * Update details of a single server. + * + * The async variant is {@see BareMetalSolutionClient::updateInstanceAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/update_instance.php + * + * @param UpdateInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateInstance(UpdateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateInstance', $request, $callOptions)->wait(); + } + + /** + * Update details of a single network. + * + * The async variant is {@see BareMetalSolutionClient::updateNetworkAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/update_network.php + * + * @param UpdateNetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateNetwork(UpdateNetworkRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateNetwork', $request, $callOptions)->wait(); + } + + /** + * Update details of a single NFS share. + * + * The async variant is {@see BareMetalSolutionClient::updateNfsShareAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/update_nfs_share.php + * + * @param UpdateNfsShareRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateNfsShare(UpdateNfsShareRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateNfsShare', $request, $callOptions)->wait(); + } + + /** + * Update existing ProvisioningConfig. + * + * The async variant is + * {@see BareMetalSolutionClient::updateProvisioningConfigAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/update_provisioning_config.php + * + * @param UpdateProvisioningConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ProvisioningConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateProvisioningConfig(UpdateProvisioningConfigRequest $request, array $callOptions = []): ProvisioningConfig + { + return $this->startApiCall('UpdateProvisioningConfig', $request, $callOptions)->wait(); + } + + /** + * Update details of a single storage volume. + * + * The async variant is {@see BareMetalSolutionClient::updateVolumeAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/update_volume.php + * + * @param UpdateVolumeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateVolume(UpdateVolumeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateVolume', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see BareMetalSolutionClient::getLocationAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see BareMetalSolutionClient::listLocationsAsync()} . + * + * @example samples/V2/BareMetalSolutionClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/BareMetalSolution/src/V2/Client/BaseClient/BareMetalSolutionBaseClient.php b/BareMetalSolution/src/V2/Client/BaseClient/BareMetalSolutionBaseClient.php deleted file mode 100644 index 01eb4563d5e5..000000000000 --- a/BareMetalSolution/src/V2/Client/BaseClient/BareMetalSolutionBaseClient.php +++ /dev/null @@ -1,1827 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/bare_metal_solution_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/bare_metal_solution_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/bare_metal_solution_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/bare_metal_solution_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a instance - * resource. - * - * @param string $project - * @param string $location - * @param string $instance - * - * @return string The formatted instance resource. - */ - public static function instanceName(string $project, string $location, string $instance): string - { - return self::getPathTemplate('instance')->render([ - 'project' => $project, - 'location' => $location, - 'instance' => $instance, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * instance_config resource. - * - * @param string $project - * @param string $location - * @param string $instanceConfig - * - * @return string The formatted instance_config resource. - */ - public static function instanceConfigName(string $project, string $location, string $instanceConfig): string - { - return self::getPathTemplate('instanceConfig')->render([ - 'project' => $project, - 'location' => $location, - 'instance_config' => $instanceConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * interconnect_attachment resource. - * - * @param string $project - * @param string $region - * @param string $interconnectAttachment - * - * @return string The formatted interconnect_attachment resource. - */ - public static function interconnectAttachmentName(string $project, string $region, string $interconnectAttachment): string - { - return self::getPathTemplate('interconnectAttachment')->render([ - 'project' => $project, - 'region' => $region, - 'interconnect_attachment' => $interconnectAttachment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a lun - * resource. - * - * @param string $project - * @param string $location - * @param string $volume - * @param string $lun - * - * @return string The formatted lun resource. - */ - public static function lunName(string $project, string $location, string $volume, string $lun): string - { - return self::getPathTemplate('lun')->render([ - 'project' => $project, - 'location' => $location, - 'volume' => $volume, - 'lun' => $lun, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a nfs_share - * resource. - * - * @param string $project - * @param string $location - * @param string $nfsShare - * - * @return string The formatted nfs_share resource. - */ - public static function nFSShareName(string $project, string $location, string $nfsShare): string - { - return self::getPathTemplate('nFSShare')->render([ - 'project' => $project, - 'location' => $location, - 'nfs_share' => $nfsShare, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a network - * resource. - * - * @param string $project - * @param string $location - * @param string $network - * - * @return string The formatted network resource. - */ - public static function networkName(string $project, string $location, string $network): string - { - return self::getPathTemplate('network')->render([ - 'project' => $project, - 'location' => $location, - 'network' => $network, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * network_config resource. - * - * @param string $project - * @param string $location - * @param string $networkConfig - * - * @return string The formatted network_config resource. - */ - public static function networkConfigName(string $project, string $location, string $networkConfig): string - { - return self::getPathTemplate('networkConfig')->render([ - 'project' => $project, - 'location' => $location, - 'network_config' => $networkConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * provisioning_config resource. - * - * @param string $project - * @param string $location - * @param string $provisioningConfig - * - * @return string The formatted provisioning_config resource. - */ - public static function provisioningConfigName(string $project, string $location, string $provisioningConfig): string - { - return self::getPathTemplate('provisioningConfig')->render([ - 'project' => $project, - 'location' => $location, - 'provisioning_config' => $provisioningConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * server_network_template resource. - * - * @param string $project - * @param string $location - * @param string $serverNetworkTemplate - * - * @return string The formatted server_network_template resource. - */ - public static function serverNetworkTemplateName(string $project, string $location, string $serverNetworkTemplate): string - { - return self::getPathTemplate('serverNetworkTemplate')->render([ - 'project' => $project, - 'location' => $location, - 'server_network_template' => $serverNetworkTemplate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a ssh_key - * resource. - * - * @param string $project - * @param string $location - * @param string $sshKey - * - * @return string The formatted ssh_key resource. - */ - public static function sshKeyName(string $project, string $location, string $sshKey): string - { - return self::getPathTemplate('sshKey')->render([ - 'project' => $project, - 'location' => $location, - 'ssh_key' => $sshKey, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a volume - * resource. - * - * @param string $project - * @param string $location - * @param string $volume - * - * @return string The formatted volume resource. - */ - public static function volumeName(string $project, string $location, string $volume): string - { - return self::getPathTemplate('volume')->render([ - 'project' => $project, - 'location' => $location, - 'volume' => $volume, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * volume_config resource. - * - * @param string $project - * @param string $location - * @param string $volumeConfig - * - * @return string The formatted volume_config resource. - */ - public static function volumeConfigName(string $project, string $location, string $volumeConfig): string - { - return self::getPathTemplate('volumeConfig')->render([ - 'project' => $project, - 'location' => $location, - 'volume_config' => $volumeConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * volume_snapshot resource. - * - * @param string $project - * @param string $location - * @param string $volume - * @param string $snapshot - * - * @return string The formatted volume_snapshot resource. - */ - public static function volumeSnapshotName(string $project, string $location, string $volume, string $snapshot): string - { - return self::getPathTemplate('volumeSnapshot')->render([ - 'project' => $project, - 'location' => $location, - 'volume' => $volume, - 'snapshot' => $snapshot, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - instance: projects/{project}/locations/{location}/instances/{instance} - * - instanceConfig: projects/{project}/locations/{location}/instanceConfigs/{instance_config} - * - interconnectAttachment: projects/{project}/regions/{region}/interconnectAttachments/{interconnect_attachment} - * - location: projects/{project}/locations/{location} - * - lun: projects/{project}/locations/{location}/volumes/{volume}/luns/{lun} - * - nFSShare: projects/{project}/locations/{location}/nfsShares/{nfs_share} - * - network: projects/{project}/locations/{location}/networks/{network} - * - networkConfig: projects/{project}/locations/{location}/networkConfigs/{network_config} - * - provisioningConfig: projects/{project}/locations/{location}/provisioningConfigs/{provisioning_config} - * - serverNetworkTemplate: projects/{project}/locations/{location}/serverNetworkTemplate/{server_network_template} - * - sshKey: projects/{project}/locations/{location}/sshKeys/{ssh_key} - * - volume: projects/{project}/locations/{location}/volumes/{volume} - * - volumeConfig: projects/{project}/locations/{location}/volumeConfigs/{volume_config} - * - volumeSnapshot: projects/{project}/locations/{location}/volumes/{volume}/snapshots/{snapshot} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'baremetalsolution.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Create an NFS share. - * - * The async variant is {@see self::createNfsShareAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/create_nfs_share.php - * - * @param CreateNfsShareRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createNfsShare(CreateNfsShareRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateNfsShare', $request, $callOptions)->wait(); - } - - /** - * Create new ProvisioningConfig. - * - * The async variant is {@see self::createProvisioningConfigAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/create_provisioning_config.php - * - * @param CreateProvisioningConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ProvisioningConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function createProvisioningConfig(CreateProvisioningConfigRequest $request, array $callOptions = []): ProvisioningConfig - { - return $this->startApiCall('CreateProvisioningConfig', $request, $callOptions)->wait(); - } - - /** - * Register a public SSH key in the specified project for use with the - * interactive serial console feature. - * - * The async variant is {@see self::createSSHKeyAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/create_ssh_key.php - * - * @param CreateSSHKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SSHKey - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSSHKey(CreateSSHKeyRequest $request, array $callOptions = []): SSHKey - { - return $this->startApiCall('CreateSSHKey', $request, $callOptions)->wait(); - } - - /** - * Takes a snapshot of a boot volume. - * Returns INVALID_ARGUMENT if called for a non-boot volume. - * - * The async variant is {@see self::createVolumeSnapshotAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/create_volume_snapshot.php - * - * @param CreateVolumeSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 VolumeSnapshot - * - * @throws ApiException Thrown if the API call fails. - */ - public function createVolumeSnapshot(CreateVolumeSnapshotRequest $request, array $callOptions = []): VolumeSnapshot - { - return $this->startApiCall('CreateVolumeSnapshot', $request, $callOptions)->wait(); - } - - /** - * Delete an NFS share. The underlying volume is automatically deleted. - * - * The async variant is {@see self::deleteNfsShareAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/delete_nfs_share.php - * - * @param DeleteNfsShareRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteNfsShare(DeleteNfsShareRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteNfsShare', $request, $callOptions)->wait(); - } - - /** - * Deletes a public SSH key registered in the specified project. - * - * The async variant is {@see self::deleteSSHKeyAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/delete_ssh_key.php - * - * @param DeleteSSHKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSSHKey(DeleteSSHKeyRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteSSHKey', $request, $callOptions)->wait(); - } - - /** - * Deletes a volume snapshot. - * Returns INVALID_ARGUMENT if called for a non-boot volume. - * - * The async variant is {@see self::deleteVolumeSnapshotAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/delete_volume_snapshot.php - * - * @param DeleteVolumeSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteVolumeSnapshot(DeleteVolumeSnapshotRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteVolumeSnapshot', $request, $callOptions)->wait(); - } - - /** - * Detach LUN from Instance. - * - * The async variant is {@see self::detachLunAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/detach_lun.php - * - * @param DetachLunRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function detachLun(DetachLunRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DetachLun', $request, $callOptions)->wait(); - } - - /** - * Disable the interactive serial console feature on an instance. - * - * The async variant is {@see self::disableInteractiveSerialConsoleAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/disable_interactive_serial_console.php - * - * @param DisableInteractiveSerialConsoleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function disableInteractiveSerialConsole(DisableInteractiveSerialConsoleRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DisableInteractiveSerialConsole', $request, $callOptions)->wait(); - } - - /** - * Enable the interactive serial console feature on an instance. - * - * The async variant is {@see self::enableInteractiveSerialConsoleAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/enable_interactive_serial_console.php - * - * @param EnableInteractiveSerialConsoleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function enableInteractiveSerialConsole(EnableInteractiveSerialConsoleRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('EnableInteractiveSerialConsole', $request, $callOptions)->wait(); - } - - /** - * Skips lun's cooloff and deletes it now. - * Lun must be in cooloff state. - * - * The async variant is {@see self::evictLunAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/evict_lun.php - * - * @param EvictLunRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function evictLun(EvictLunRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('EvictLun', $request, $callOptions)->wait(); - } - - /** - * Skips volume's cooloff and deletes it now. - * Volume must be in cooloff state. - * - * The async variant is {@see self::evictVolumeAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/evict_volume.php - * - * @param EvictVolumeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function evictVolume(EvictVolumeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('EvictVolume', $request, $callOptions)->wait(); - } - - /** - * Get details about a single server. - * - * The async variant is {@see self::getInstanceAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/get_instance.php - * - * @param GetInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Instance - * - * @throws ApiException Thrown if the API call fails. - */ - public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance - { - return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); - } - - /** - * Get details of a single storage logical unit number(LUN). - * - * The async variant is {@see self::getLunAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/get_lun.php - * - * @param GetLunRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Lun - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLun(GetLunRequest $request, array $callOptions = []): Lun - { - return $this->startApiCall('GetLun', $request, $callOptions)->wait(); - } - - /** - * Get details of a single network. - * - * The async variant is {@see self::getNetworkAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/get_network.php - * - * @param GetNetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Network - * - * @throws ApiException Thrown if the API call fails. - */ - public function getNetwork(GetNetworkRequest $request, array $callOptions = []): Network - { - return $this->startApiCall('GetNetwork', $request, $callOptions)->wait(); - } - - /** - * Get details of a single NFS share. - * - * The async variant is {@see self::getNfsShareAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/get_nfs_share.php - * - * @param GetNfsShareRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NfsShare - * - * @throws ApiException Thrown if the API call fails. - */ - public function getNfsShare(GetNfsShareRequest $request, array $callOptions = []): NfsShare - { - return $this->startApiCall('GetNfsShare', $request, $callOptions)->wait(); - } - - /** - * Get ProvisioningConfig by name. - * - * The async variant is {@see self::getProvisioningConfigAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/get_provisioning_config.php - * - * @param GetProvisioningConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ProvisioningConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getProvisioningConfig(GetProvisioningConfigRequest $request, array $callOptions = []): ProvisioningConfig - { - return $this->startApiCall('GetProvisioningConfig', $request, $callOptions)->wait(); - } - - /** - * Get details of a single storage volume. - * - * The async variant is {@see self::getVolumeAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/get_volume.php - * - * @param GetVolumeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Volume - * - * @throws ApiException Thrown if the API call fails. - */ - public function getVolume(GetVolumeRequest $request, array $callOptions = []): Volume - { - return $this->startApiCall('GetVolume', $request, $callOptions)->wait(); - } - - /** - * Returns the specified snapshot resource. - * Returns INVALID_ARGUMENT if called for a non-boot volume. - * - * The async variant is {@see self::getVolumeSnapshotAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/get_volume_snapshot.php - * - * @param GetVolumeSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 VolumeSnapshot - * - * @throws ApiException Thrown if the API call fails. - */ - public function getVolumeSnapshot(GetVolumeSnapshotRequest $request, array $callOptions = []): VolumeSnapshot - { - return $this->startApiCall('GetVolumeSnapshot', $request, $callOptions)->wait(); - } - - /** - * List servers in a given project and location. - * - * The async variant is {@see self::listInstancesAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/list_instances.php - * - * @param ListInstancesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listInstances(ListInstancesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListInstances', $request, $callOptions); - } - - /** - * List storage volume luns for given storage volume. - * - * The async variant is {@see self::listLunsAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/list_luns.php - * - * @param ListLunsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLuns(ListLunsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLuns', $request, $callOptions); - } - - /** - * List all Networks (and used IPs for each Network) in the vendor account - * associated with the specified project. - * - * The async variant is {@see self::listNetworkUsageAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/list_network_usage.php - * - * @param ListNetworkUsageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ListNetworkUsageResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listNetworkUsage(ListNetworkUsageRequest $request, array $callOptions = []): ListNetworkUsageResponse - { - return $this->startApiCall('ListNetworkUsage', $request, $callOptions)->wait(); - } - - /** - * List network in a given project and location. - * - * The async variant is {@see self::listNetworksAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/list_networks.php - * - * @param ListNetworksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listNetworks(ListNetworksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListNetworks', $request, $callOptions); - } - - /** - * List NFS shares. - * - * The async variant is {@see self::listNfsSharesAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/list_nfs_shares.php - * - * @param ListNfsSharesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listNfsShares(ListNfsSharesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListNfsShares', $request, $callOptions); - } - - /** - * Retrieves the list of OS images which are currently approved. - * - * The async variant is {@see self::listOSImagesAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/list_os_images.php - * - * @param ListOSImagesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listOSImages(ListOSImagesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListOSImages', $request, $callOptions); - } - - /** - * List the budget details to provision resources on a given project. - * - * The async variant is {@see self::listProvisioningQuotasAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/list_provisioning_quotas.php - * - * @param ListProvisioningQuotasRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listProvisioningQuotas(ListProvisioningQuotasRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListProvisioningQuotas', $request, $callOptions); - } - - /** - * Lists the public SSH keys registered for the specified project. - * These SSH keys are used only for the interactive serial console feature. - * - * The async variant is {@see self::listSSHKeysAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/list_ssh_keys.php - * - * @param ListSSHKeysRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSSHKeys(ListSSHKeysRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSSHKeys', $request, $callOptions); - } - - /** - * Retrieves the list of snapshots for the specified volume. - * Returns a response with an empty list of snapshots if called - * for a non-boot volume. - * - * The async variant is {@see self::listVolumeSnapshotsAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/list_volume_snapshots.php - * - * @param ListVolumeSnapshotsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listVolumeSnapshots(ListVolumeSnapshotsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListVolumeSnapshots', $request, $callOptions); - } - - /** - * List storage volumes in a given project and location. - * - * The async variant is {@see self::listVolumesAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/list_volumes.php - * - * @param ListVolumesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listVolumes(ListVolumesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListVolumes', $request, $callOptions); - } - - /** - * RenameInstance sets a new name for an instance. - * Use with caution, previous names become immediately invalidated. - * - * The async variant is {@see self::renameInstanceAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/rename_instance.php - * - * @param RenameInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Instance - * - * @throws ApiException Thrown if the API call fails. - */ - public function renameInstance(RenameInstanceRequest $request, array $callOptions = []): Instance - { - return $this->startApiCall('RenameInstance', $request, $callOptions)->wait(); - } - - /** - * RenameNetwork sets a new name for a network. - * Use with caution, previous names become immediately invalidated. - * - * The async variant is {@see self::renameNetworkAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/rename_network.php - * - * @param RenameNetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Network - * - * @throws ApiException Thrown if the API call fails. - */ - public function renameNetwork(RenameNetworkRequest $request, array $callOptions = []): Network - { - return $this->startApiCall('RenameNetwork', $request, $callOptions)->wait(); - } - - /** - * RenameNfsShare sets a new name for an nfsshare. - * Use with caution, previous names become immediately invalidated. - * - * The async variant is {@see self::renameNfsShareAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/rename_nfs_share.php - * - * @param RenameNfsShareRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NfsShare - * - * @throws ApiException Thrown if the API call fails. - */ - public function renameNfsShare(RenameNfsShareRequest $request, array $callOptions = []): NfsShare - { - return $this->startApiCall('RenameNfsShare', $request, $callOptions)->wait(); - } - - /** - * RenameVolume sets a new name for a volume. - * Use with caution, previous names become immediately invalidated. - * - * The async variant is {@see self::renameVolumeAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/rename_volume.php - * - * @param RenameVolumeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Volume - * - * @throws ApiException Thrown if the API call fails. - */ - public function renameVolume(RenameVolumeRequest $request, array $callOptions = []): Volume - { - return $this->startApiCall('RenameVolume', $request, $callOptions)->wait(); - } - - /** - * Perform an ungraceful, hard reset on a server. Equivalent to shutting the - * power off and then turning it back on. - * - * The async variant is {@see self::resetInstanceAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/reset_instance.php - * - * @param ResetInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function resetInstance(ResetInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ResetInstance', $request, $callOptions)->wait(); - } - - /** - * Emergency Volume resize. - * - * The async variant is {@see self::resizeVolumeAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/resize_volume.php - * - * @param ResizeVolumeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function resizeVolume(ResizeVolumeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ResizeVolume', $request, $callOptions)->wait(); - } - - /** - * Uses the specified snapshot to restore its parent volume. - * Returns INVALID_ARGUMENT if called for a non-boot volume. - * - * The async variant is {@see self::restoreVolumeSnapshotAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/restore_volume_snapshot.php - * - * @param RestoreVolumeSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function restoreVolumeSnapshot(RestoreVolumeSnapshotRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RestoreVolumeSnapshot', $request, $callOptions)->wait(); - } - - /** - * Starts a server that was shutdown. - * - * The async variant is {@see self::startInstanceAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/start_instance.php - * - * @param StartInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function startInstance(StartInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StartInstance', $request, $callOptions)->wait(); - } - - /** - * Stop a running server. - * - * The async variant is {@see self::stopInstanceAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/stop_instance.php - * - * @param StopInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function stopInstance(StopInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StopInstance', $request, $callOptions)->wait(); - } - - /** - * Submit a provisiong configuration for a given project. - * - * The async variant is {@see self::submitProvisioningConfigAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/submit_provisioning_config.php - * - * @param SubmitProvisioningConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SubmitProvisioningConfigResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function submitProvisioningConfig(SubmitProvisioningConfigRequest $request, array $callOptions = []): SubmitProvisioningConfigResponse - { - return $this->startApiCall('SubmitProvisioningConfig', $request, $callOptions)->wait(); - } - - /** - * Update details of a single server. - * - * The async variant is {@see self::updateInstanceAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/update_instance.php - * - * @param UpdateInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateInstance(UpdateInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateInstance', $request, $callOptions)->wait(); - } - - /** - * Update details of a single network. - * - * The async variant is {@see self::updateNetworkAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/update_network.php - * - * @param UpdateNetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateNetwork(UpdateNetworkRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateNetwork', $request, $callOptions)->wait(); - } - - /** - * Update details of a single NFS share. - * - * The async variant is {@see self::updateNfsShareAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/update_nfs_share.php - * - * @param UpdateNfsShareRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateNfsShare(UpdateNfsShareRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateNfsShare', $request, $callOptions)->wait(); - } - - /** - * Update existing ProvisioningConfig. - * - * The async variant is {@see self::updateProvisioningConfigAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/update_provisioning_config.php - * - * @param UpdateProvisioningConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ProvisioningConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateProvisioningConfig(UpdateProvisioningConfigRequest $request, array $callOptions = []): ProvisioningConfig - { - return $this->startApiCall('UpdateProvisioningConfig', $request, $callOptions)->wait(); - } - - /** - * Update details of a single storage volume. - * - * The async variant is {@see self::updateVolumeAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/update_volume.php - * - * @param UpdateVolumeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateVolume(UpdateVolumeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateVolume', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V2/BareMetalSolutionClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Batch/VERSION b/Batch/VERSION index 1a96df19c09a..ac454c6a1fc3 100644 --- a/Batch/VERSION +++ b/Batch/VERSION @@ -1 +1 @@ -0.11.3 +0.12.0 diff --git a/Batch/composer.json b/Batch/composer.json index 8247b3440232..705292767507 100644 --- a/Batch/composer.json +++ b/Batch/composer.json @@ -19,7 +19,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Batch/metadata/V1/Job.php b/Batch/metadata/V1/Job.php index 56edd85735af..f6e70f734992 100644 Binary files a/Batch/metadata/V1/Job.php and b/Batch/metadata/V1/Job.php differ diff --git a/Batch/src/V1/AllocationPolicy/Disk.php b/Batch/src/V1/AllocationPolicy/Disk.php index 234836d3f8b7..96887690f7d2 100644 --- a/Batch/src/V1/AllocationPolicy/Disk.php +++ b/Batch/src/V1/AllocationPolicy/Disk.php @@ -80,6 +80,7 @@ class Disk extends \Google\Protobuf\Internal\Message * * `batch-centos`: use Batch CentOS images. * * `batch-cos`: use Batch Container-Optimized images. * * `batch-hpc-centos`: use Batch HPC CentOS images. + * * `batch-hpc-rocky`: use Batch HPC Rocky Linux images. * @type string $snapshot * Name of a snapshot used as the data source. * Snapshot is not supported as boot disk now. @@ -132,6 +133,7 @@ public function __construct($data = NULL) { * * `batch-centos`: use Batch CentOS images. * * `batch-cos`: use Batch Container-Optimized images. * * `batch-hpc-centos`: use Batch HPC CentOS images. + * * `batch-hpc-rocky`: use Batch HPC Rocky Linux images. * * Generated from protobuf field string image = 4; * @return string @@ -159,6 +161,7 @@ public function hasImage() * * `batch-centos`: use Batch CentOS images. * * `batch-cos`: use Batch Container-Optimized images. * * `batch-hpc-centos`: use Batch HPC CentOS images. + * * `batch-hpc-rocky`: use Batch HPC Rocky Linux images. * * Generated from protobuf field string image = 4; * @param string $var diff --git a/Batch/src/V1/AllocationPolicy/InstancePolicy.php b/Batch/src/V1/AllocationPolicy/InstancePolicy.php index 0f81c44b2c1b..7209e470f22e 100644 --- a/Batch/src/V1/AllocationPolicy/InstancePolicy.php +++ b/Batch/src/V1/AllocationPolicy/InstancePolicy.php @@ -60,6 +60,13 @@ class InstancePolicy extends \Google\Protobuf\Internal\Message * Generated from protobuf field repeated .google.cloud.batch.v1.AllocationPolicy.AttachedDisk disks = 6; */ private $disks; + /** + * Optional. If specified, VMs will consume only the specified reservation. + * If not specified (default), VMs will consume any applicable reservation. + * + * Generated from protobuf field string reservation = 7 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $reservation = ''; /** * Constructor. @@ -87,6 +94,9 @@ class InstancePolicy extends \Google\Protobuf\Internal\Message * A non-boot disk is a disk that can be of a device with a * file system or a raw storage drive that is not ready for data * storage and accessing. + * @type string $reservation + * Optional. If specified, VMs will consume only the specified reservation. + * If not specified (default), VMs will consume any applicable reservation. * } */ public function __construct($data = NULL) { @@ -276,6 +286,34 @@ public function setDisks($var) return $this; } + /** + * Optional. If specified, VMs will consume only the specified reservation. + * If not specified (default), VMs will consume any applicable reservation. + * + * Generated from protobuf field string reservation = 7 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getReservation() + { + return $this->reservation; + } + + /** + * Optional. If specified, VMs will consume only the specified reservation. + * If not specified (default), VMs will consume any applicable reservation. + * + * Generated from protobuf field string reservation = 7 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setReservation($var) + { + GPBUtil::checkString($var, True); + $this->reservation = $var; + + return $this; + } + } diff --git a/Batch/src/V1/Client/BaseClient/BatchServiceBaseClient.php b/Batch/src/V1/Client/BaseClient/BatchServiceBaseClient.php deleted file mode 100644 index 4716e03c28b7..000000000000 --- a/Batch/src/V1/Client/BaseClient/BatchServiceBaseClient.php +++ /dev/null @@ -1,539 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/batch_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/batch_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/batch_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/batch_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a job - * resource. - * - * @param string $project - * @param string $location - * @param string $job - * - * @return string The formatted job resource. - */ - public static function jobName(string $project, string $location, string $job): string - { - return self::getPathTemplate('job')->render([ - 'project' => $project, - 'location' => $location, - 'job' => $job, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a task - * resource. - * - * @param string $project - * @param string $location - * @param string $job - * @param string $taskGroup - * @param string $task - * - * @return string The formatted task resource. - */ - public static function taskName(string $project, string $location, string $job, string $taskGroup, string $task): string - { - return self::getPathTemplate('task')->render([ - 'project' => $project, - 'location' => $location, - 'job' => $job, - 'task_group' => $taskGroup, - 'task' => $task, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a task_group - * resource. - * - * @param string $project - * @param string $location - * @param string $job - * @param string $taskGroup - * - * @return string The formatted task_group resource. - */ - public static function taskGroupName(string $project, string $location, string $job, string $taskGroup): string - { - return self::getPathTemplate('taskGroup')->render([ - 'project' => $project, - 'location' => $location, - 'job' => $job, - 'task_group' => $taskGroup, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - job: projects/{project}/locations/{location}/jobs/{job} - * - location: projects/{project}/locations/{location} - * - task: projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}/tasks/{task} - * - taskGroup: projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_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. - */ - public static function parseName(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'batch.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Create a Job. - * - * The async variant is {@see self::createJobAsync()} . - * - * @example samples/V1/BatchServiceClient/create_job.php - * - * @param CreateJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - */ - public function createJob(CreateJobRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('CreateJob', $request, $callOptions)->wait(); - } - - /** - * Delete a Job. - * - * The async variant is {@see self::deleteJobAsync()} . - * - * @example samples/V1/BatchServiceClient/delete_job.php - * - * @param DeleteJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteJob(DeleteJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteJob', $request, $callOptions)->wait(); - } - - /** - * Get a Job specified by its resource name. - * - * The async variant is {@see self::getJobAsync()} . - * - * @example samples/V1/BatchServiceClient/get_job.php - * - * @param GetJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - */ - public function getJob(GetJobRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('GetJob', $request, $callOptions)->wait(); - } - - /** - * Return a single Task. - * - * The async variant is {@see self::getTaskAsync()} . - * - * @example samples/V1/BatchServiceClient/get_task.php - * - * @param GetTaskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Task - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTask(GetTaskRequest $request, array $callOptions = []): Task - { - return $this->startApiCall('GetTask', $request, $callOptions)->wait(); - } - - /** - * List all Jobs for a project within a region. - * - * The async variant is {@see self::listJobsAsync()} . - * - * @example samples/V1/BatchServiceClient/list_jobs.php - * - * @param ListJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listJobs(ListJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListJobs', $request, $callOptions); - } - - /** - * List Tasks associated with a job. - * - * The async variant is {@see self::listTasksAsync()} . - * - * @example samples/V1/BatchServiceClient/list_tasks.php - * - * @param ListTasksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTasks(ListTasksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTasks', $request, $callOptions); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/BatchServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/BatchServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Batch/src/V1/Client/BatchServiceClient.php b/Batch/src/V1/Client/BatchServiceClient.php index 5fb6c3bd3c1e..f985c68eb08d 100644 --- a/Batch/src/V1/Client/BatchServiceClient.php +++ b/Batch/src/V1/Client/BatchServiceClient.php @@ -24,17 +24,514 @@ namespace Google\Cloud\Batch\V1\Client; -use Google\Cloud\Batch\V1\Client\BaseClient\BatchServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Batch\V1\CreateJobRequest; +use Google\Cloud\Batch\V1\DeleteJobRequest; +use Google\Cloud\Batch\V1\GetJobRequest; +use Google\Cloud\Batch\V1\GetTaskRequest; +use Google\Cloud\Batch\V1\Job; +use Google\Cloud\Batch\V1\ListJobsRequest; +use Google\Cloud\Batch\V1\ListTasksRequest; +use Google\Cloud\Batch\V1\Task; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Google Batch Service. + * The service manages user submitted batch jobs and allocates Google Compute + * Engine VM instances to run the jobs. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Batch\V1\BatchServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createJobAsync(CreateJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteJobAsync(DeleteJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getJobAsync(GetJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTaskAsync(GetTaskRequest $request, array $optionalArgs = []) + * @method PromiseInterface listJobsAsync(ListJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTasksAsync(ListTasksRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class BatchServiceClient extends BatchServiceBaseClient +final class BatchServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see BatchServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.batch.v1.BatchService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'batch.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/batch_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/batch_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/batch_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/batch_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a job + * resource. + * + * @param string $project + * @param string $location + * @param string $job + * + * @return string The formatted job resource. + */ + public static function jobName(string $project, string $location, string $job): string + { + return self::getPathTemplate('job')->render([ + 'project' => $project, + 'location' => $location, + 'job' => $job, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a task + * resource. + * + * @param string $project + * @param string $location + * @param string $job + * @param string $taskGroup + * @param string $task + * + * @return string The formatted task resource. + */ + public static function taskName(string $project, string $location, string $job, string $taskGroup, string $task): string + { + return self::getPathTemplate('task')->render([ + 'project' => $project, + 'location' => $location, + 'job' => $job, + 'task_group' => $taskGroup, + 'task' => $task, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a task_group + * resource. + * + * @param string $project + * @param string $location + * @param string $job + * @param string $taskGroup + * + * @return string The formatted task_group resource. + */ + public static function taskGroupName(string $project, string $location, string $job, string $taskGroup): string + { + return self::getPathTemplate('taskGroup')->render([ + 'project' => $project, + 'location' => $location, + 'job' => $job, + 'task_group' => $taskGroup, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - job: projects/{project}/locations/{location}/jobs/{job} + * - location: projects/{project}/locations/{location} + * - task: projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}/tasks/{task} + * - taskGroup: projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_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. + */ + public static function parseName(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'batch.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Create a Job. + * + * The async variant is {@see BatchServiceClient::createJobAsync()} . + * + * @example samples/V1/BatchServiceClient/create_job.php + * + * @param CreateJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + */ + public function createJob(CreateJobRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('CreateJob', $request, $callOptions)->wait(); + } + + /** + * Delete a Job. + * + * The async variant is {@see BatchServiceClient::deleteJobAsync()} . + * + * @example samples/V1/BatchServiceClient/delete_job.php + * + * @param DeleteJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteJob(DeleteJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteJob', $request, $callOptions)->wait(); + } + + /** + * Get a Job specified by its resource name. + * + * The async variant is {@see BatchServiceClient::getJobAsync()} . + * + * @example samples/V1/BatchServiceClient/get_job.php + * + * @param GetJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + */ + public function getJob(GetJobRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('GetJob', $request, $callOptions)->wait(); + } + + /** + * Return a single Task. + * + * The async variant is {@see BatchServiceClient::getTaskAsync()} . + * + * @example samples/V1/BatchServiceClient/get_task.php + * + * @param GetTaskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Task + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTask(GetTaskRequest $request, array $callOptions = []): Task + { + return $this->startApiCall('GetTask', $request, $callOptions)->wait(); + } + + /** + * List all Jobs for a project within a region. + * + * The async variant is {@see BatchServiceClient::listJobsAsync()} . + * + * @example samples/V1/BatchServiceClient/list_jobs.php + * + * @param ListJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listJobs(ListJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListJobs', $request, $callOptions); + } + + /** + * List Tasks associated with a job. + * + * The async variant is {@see BatchServiceClient::listTasksAsync()} . + * + * @example samples/V1/BatchServiceClient/list_tasks.php + * + * @param ListTasksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTasks(ListTasksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTasks', $request, $callOptions); + } + + /** + * Gets information about a location. + * + * The async variant is {@see BatchServiceClient::getLocationAsync()} . + * + * @example samples/V1/BatchServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see BatchServiceClient::listLocationsAsync()} . + * + * @example samples/V1/BatchServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Batch/src/V1/Runnable/Container.php b/Batch/src/V1/Runnable/Container.php index 599febc147c4..536f1e02ce8c 100644 --- a/Batch/src/V1/Runnable/Container.php +++ b/Batch/src/V1/Runnable/Container.php @@ -39,6 +39,13 @@ class Container extends \Google\Protobuf\Internal\Message * Volumes to mount (bind mount) from the host machine files or directories * into the container, formatted to match docker run's --volume option, * e.g. /foo:/bar, or /foo:/bar:ro + * If the `TaskSpec.Volumes` field is specified but this field is not, Batch + * will mount each volume from the host machine to the container with the + * same mount path by default. In this case, the default mount option for + * containers will be read-only (ro) for existing persistent disks and + * read-write (rw) for other volume types, regardless of the original mount + * options specified in `TaskSpec.Volumes`. If you need different mount + * settings, you can explicitly configure them in this field. * * Generated from protobuf field repeated string volumes = 7; */ @@ -94,6 +101,13 @@ class Container extends \Google\Protobuf\Internal\Message * Volumes to mount (bind mount) from the host machine files or directories * into the container, formatted to match docker run's --volume option, * e.g. /foo:/bar, or /foo:/bar:ro + * If the `TaskSpec.Volumes` field is specified but this field is not, Batch + * will mount each volume from the host machine to the container with the + * same mount path by default. In this case, the default mount option for + * containers will be read-only (ro) for existing persistent disks and + * read-write (rw) for other volume types, regardless of the original mount + * options specified in `TaskSpec.Volumes`. If you need different mount + * settings, you can explicitly configure them in this field. * @type string $options * Arbitrary additional options to include in the "docker run" command when * running this container, e.g. "--network host". @@ -203,6 +217,13 @@ public function setEntrypoint($var) * Volumes to mount (bind mount) from the host machine files or directories * into the container, formatted to match docker run's --volume option, * e.g. /foo:/bar, or /foo:/bar:ro + * If the `TaskSpec.Volumes` field is specified but this field is not, Batch + * will mount each volume from the host machine to the container with the + * same mount path by default. In this case, the default mount option for + * containers will be read-only (ro) for existing persistent disks and + * read-write (rw) for other volume types, regardless of the original mount + * options specified in `TaskSpec.Volumes`. If you need different mount + * settings, you can explicitly configure them in this field. * * Generated from protobuf field repeated string volumes = 7; * @return \Google\Protobuf\Internal\RepeatedField @@ -216,6 +237,13 @@ public function getVolumes() * Volumes to mount (bind mount) from the host machine files or directories * into the container, formatted to match docker run's --volume option, * e.g. /foo:/bar, or /foo:/bar:ro + * If the `TaskSpec.Volumes` field is specified but this field is not, Batch + * will mount each volume from the host machine to the container with the + * same mount path by default. In this case, the default mount option for + * containers will be read-only (ro) for existing persistent disks and + * read-write (rw) for other volume types, regardless of the original mount + * options specified in `TaskSpec.Volumes`. If you need different mount + * settings, you can explicitly configure them in this field. * * Generated from protobuf field repeated string volumes = 7; * @param array|\Google\Protobuf\Internal\RepeatedField $var diff --git a/BeyondCorpAppConnections/composer.json b/BeyondCorpAppConnections/composer.json index a56b6beef81f..fd47fedc90c8 100644 --- a/BeyondCorpAppConnections/composer.json +++ b/BeyondCorpAppConnections/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/BeyondCorpAppConnections/src/V1/Client/AppConnectionsServiceClient.php b/BeyondCorpAppConnections/src/V1/Client/AppConnectionsServiceClient.php index b42b2bf42386..def0a9c813b5 100644 --- a/BeyondCorpAppConnections/src/V1/Client/AppConnectionsServiceClient.php +++ b/BeyondCorpAppConnections/src/V1/Client/AppConnectionsServiceClient.php @@ -24,17 +24,625 @@ namespace Google\Cloud\BeyondCorp\AppConnections\V1\Client; -use Google\Cloud\BeyondCorp\AppConnections\V1\Client\BaseClient\AppConnectionsServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\BeyondCorp\AppConnections\V1\AppConnection; +use Google\Cloud\BeyondCorp\AppConnections\V1\CreateAppConnectionRequest; +use Google\Cloud\BeyondCorp\AppConnections\V1\DeleteAppConnectionRequest; +use Google\Cloud\BeyondCorp\AppConnections\V1\GetAppConnectionRequest; +use Google\Cloud\BeyondCorp\AppConnections\V1\ListAppConnectionsRequest; +use Google\Cloud\BeyondCorp\AppConnections\V1\ResolveAppConnectionsRequest; +use Google\Cloud\BeyondCorp\AppConnections\V1\UpdateAppConnectionRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: API Overview: * - * This class is currently experimental and may be subject to changes. + * The `beyondcorp.googleapis.com` service implements the Google Cloud + * BeyondCorp API. + * + * Data Model: + * + * The AppConnectionsService exposes the following resources: + * + * * AppConnections, named as follows: + * `projects/{project_id}/locations/{location_id}/appConnections/{app_connection_id}`. + * + * The AppConnectionsService service provides methods to manage + * (create/read/update/delete) BeyondCorp AppConnections. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\BeyondCorp\AppConnections\V1\AppConnectionsServiceClient} for the + * stable implementation * * @experimental + * + * @method PromiseInterface createAppConnectionAsync(CreateAppConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAppConnectionAsync(DeleteAppConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAppConnectionAsync(GetAppConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAppConnectionsAsync(ListAppConnectionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface resolveAppConnectionsAsync(ResolveAppConnectionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAppConnectionAsync(UpdateAppConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class AppConnectionsServiceClient extends AppConnectionsServiceBaseClient +final class AppConnectionsServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AppConnectionsServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.beyondcorp.appconnections.v1.AppConnectionsService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'beyondcorp.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/app_connections_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/app_connections_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/app_connections_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/app_connections_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * app_connection resource. + * + * @param string $project + * @param string $location + * @param string $appConnection + * + * @return string The formatted app_connection resource. + */ + public static function appConnectionName(string $project, string $location, string $appConnection): string + { + return self::getPathTemplate('appConnection')->render([ + 'project' => $project, + 'location' => $location, + 'app_connection' => $appConnection, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * app_connector resource. + * + * @param string $project + * @param string $location + * @param string $appConnector + * + * @return string The formatted app_connector resource. + */ + public static function appConnectorName(string $project, string $location, string $appConnector): string + { + return self::getPathTemplate('appConnector')->render([ + 'project' => $project, + 'location' => $location, + 'app_connector' => $appConnector, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a app_gateway + * resource. + * + * @param string $project + * @param string $location + * @param string $appGateway + * + * @return string The formatted app_gateway resource. + */ + public static function appGatewayName(string $project, string $location, string $appGateway): string + { + return self::getPathTemplate('appGateway')->render([ + 'project' => $project, + 'location' => $location, + 'app_gateway' => $appGateway, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - appConnection: projects/{project}/locations/{location}/appConnections/{app_connection} + * - appConnector: projects/{project}/locations/{location}/appConnectors/{app_connector} + * - appGateway: projects/{project}/locations/{location}/appGateways/{app_gateway} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'beyondcorp.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new AppConnection in a given project and location. + * + * The async variant is + * {@see AppConnectionsServiceClient::createAppConnectionAsync()} . + * + * @example samples/V1/AppConnectionsServiceClient/create_app_connection.php + * + * @param CreateAppConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAppConnection(CreateAppConnectionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateAppConnection', $request, $callOptions)->wait(); + } + + /** + * Deletes a single AppConnection. + * + * The async variant is + * {@see AppConnectionsServiceClient::deleteAppConnectionAsync()} . + * + * @example samples/V1/AppConnectionsServiceClient/delete_app_connection.php + * + * @param DeleteAppConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAppConnection(DeleteAppConnectionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteAppConnection', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single AppConnection. + * + * The async variant is {@see AppConnectionsServiceClient::getAppConnectionAsync()} + * . + * + * @example samples/V1/AppConnectionsServiceClient/get_app_connection.php + * + * @param GetAppConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AppConnection + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAppConnection(GetAppConnectionRequest $request, array $callOptions = []): AppConnection + { + return $this->startApiCall('GetAppConnection', $request, $callOptions)->wait(); + } + + /** + * Lists AppConnections in a given project and location. + * + * The async variant is + * {@see AppConnectionsServiceClient::listAppConnectionsAsync()} . + * + * @example samples/V1/AppConnectionsServiceClient/list_app_connections.php + * + * @param ListAppConnectionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAppConnections(ListAppConnectionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAppConnections', $request, $callOptions); + } + + /** + * Resolves AppConnections details for a given AppConnector. + * An internal method called by a connector to find AppConnections to connect + * to. + * + * The async variant is + * {@see AppConnectionsServiceClient::resolveAppConnectionsAsync()} . + * + * @example samples/V1/AppConnectionsServiceClient/resolve_app_connections.php + * + * @param ResolveAppConnectionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function resolveAppConnections(ResolveAppConnectionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ResolveAppConnections', $request, $callOptions); + } + + /** + * Updates the parameters of a single AppConnection. + * + * The async variant is + * {@see AppConnectionsServiceClient::updateAppConnectionAsync()} . + * + * @example samples/V1/AppConnectionsServiceClient/update_app_connection.php + * + * @param UpdateAppConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAppConnection(UpdateAppConnectionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateAppConnection', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see AppConnectionsServiceClient::getLocationAsync()} . + * + * @example samples/V1/AppConnectionsServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see AppConnectionsServiceClient::listLocationsAsync()} . + * + * @example samples/V1/AppConnectionsServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see AppConnectionsServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/AppConnectionsServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see AppConnectionsServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/AppConnectionsServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is + * {@see AppConnectionsServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/AppConnectionsServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/BeyondCorpAppConnections/src/V1/Client/BaseClient/AppConnectionsServiceBaseClient.php b/BeyondCorpAppConnections/src/V1/Client/BaseClient/AppConnectionsServiceBaseClient.php deleted file mode 100644 index 59ad42978dd8..000000000000 --- a/BeyondCorpAppConnections/src/V1/Client/BaseClient/AppConnectionsServiceBaseClient.php +++ /dev/null @@ -1,643 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/app_connections_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/app_connections_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/app_connections_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/app_connections_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * app_connection resource. - * - * @param string $project - * @param string $location - * @param string $appConnection - * - * @return string The formatted app_connection resource. - */ - public static function appConnectionName(string $project, string $location, string $appConnection): string - { - return self::getPathTemplate('appConnection')->render([ - 'project' => $project, - 'location' => $location, - 'app_connection' => $appConnection, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * app_connector resource. - * - * @param string $project - * @param string $location - * @param string $appConnector - * - * @return string The formatted app_connector resource. - */ - public static function appConnectorName(string $project, string $location, string $appConnector): string - { - return self::getPathTemplate('appConnector')->render([ - 'project' => $project, - 'location' => $location, - 'app_connector' => $appConnector, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a app_gateway - * resource. - * - * @param string $project - * @param string $location - * @param string $appGateway - * - * @return string The formatted app_gateway resource. - */ - public static function appGatewayName(string $project, string $location, string $appGateway): string - { - return self::getPathTemplate('appGateway')->render([ - 'project' => $project, - 'location' => $location, - 'app_gateway' => $appGateway, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - appConnection: projects/{project}/locations/{location}/appConnections/{app_connection} - * - appConnector: projects/{project}/locations/{location}/appConnectors/{app_connector} - * - appGateway: projects/{project}/locations/{location}/appGateways/{app_gateway} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'beyondcorp.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new AppConnection in a given project and location. - * - * The async variant is {@see self::createAppConnectionAsync()} . - * - * @example samples/V1/AppConnectionsServiceClient/create_app_connection.php - * - * @param CreateAppConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAppConnection(CreateAppConnectionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateAppConnection', $request, $callOptions)->wait(); - } - - /** - * Deletes a single AppConnection. - * - * The async variant is {@see self::deleteAppConnectionAsync()} . - * - * @example samples/V1/AppConnectionsServiceClient/delete_app_connection.php - * - * @param DeleteAppConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAppConnection(DeleteAppConnectionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteAppConnection', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single AppConnection. - * - * The async variant is {@see self::getAppConnectionAsync()} . - * - * @example samples/V1/AppConnectionsServiceClient/get_app_connection.php - * - * @param GetAppConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AppConnection - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAppConnection(GetAppConnectionRequest $request, array $callOptions = []): AppConnection - { - return $this->startApiCall('GetAppConnection', $request, $callOptions)->wait(); - } - - /** - * Lists AppConnections in a given project and location. - * - * The async variant is {@see self::listAppConnectionsAsync()} . - * - * @example samples/V1/AppConnectionsServiceClient/list_app_connections.php - * - * @param ListAppConnectionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAppConnections(ListAppConnectionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAppConnections', $request, $callOptions); - } - - /** - * Resolves AppConnections details for a given AppConnector. - * An internal method called by a connector to find AppConnections to connect - * to. - * - * The async variant is {@see self::resolveAppConnectionsAsync()} . - * - * @example samples/V1/AppConnectionsServiceClient/resolve_app_connections.php - * - * @param ResolveAppConnectionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function resolveAppConnections(ResolveAppConnectionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ResolveAppConnections', $request, $callOptions); - } - - /** - * Updates the parameters of a single AppConnection. - * - * The async variant is {@see self::updateAppConnectionAsync()} . - * - * @example samples/V1/AppConnectionsServiceClient/update_app_connection.php - * - * @param UpdateAppConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAppConnection(UpdateAppConnectionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateAppConnection', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/AppConnectionsServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/AppConnectionsServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/AppConnectionsServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/AppConnectionsServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/AppConnectionsServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/BeyondCorpAppConnectors/composer.json b/BeyondCorpAppConnectors/composer.json index 493cb7f2c6b7..ca7ab73e3843 100644 --- a/BeyondCorpAppConnectors/composer.json +++ b/BeyondCorpAppConnectors/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/BeyondCorpAppConnectors/src/V1/Client/AppConnectorsServiceClient.php b/BeyondCorpAppConnectors/src/V1/Client/AppConnectorsServiceClient.php index 055ed7433fc2..d954037eb4e3 100644 --- a/BeyondCorpAppConnectors/src/V1/Client/AppConnectorsServiceClient.php +++ b/BeyondCorpAppConnectors/src/V1/Client/AppConnectorsServiceClient.php @@ -24,17 +24,581 @@ namespace Google\Cloud\BeyondCorp\AppConnectors\V1\Client; -use Google\Cloud\BeyondCorp\AppConnectors\V1\Client\BaseClient\AppConnectorsServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\BeyondCorp\AppConnectors\V1\AppConnector; +use Google\Cloud\BeyondCorp\AppConnectors\V1\CreateAppConnectorRequest; +use Google\Cloud\BeyondCorp\AppConnectors\V1\DeleteAppConnectorRequest; +use Google\Cloud\BeyondCorp\AppConnectors\V1\GetAppConnectorRequest; +use Google\Cloud\BeyondCorp\AppConnectors\V1\ListAppConnectorsRequest; +use Google\Cloud\BeyondCorp\AppConnectors\V1\ReportStatusRequest; +use Google\Cloud\BeyondCorp\AppConnectors\V1\UpdateAppConnectorRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: API Overview: * - * This class is currently experimental and may be subject to changes. + * The `beyondcorp.googleapis.com` service implements the Google Cloud + * BeyondCorp API. + * + * Data Model: + * + * The AppConnectorsService exposes the following resource: + * + * * AppConnectors, named as follows: + * `projects/{project_id}/locations/{location_id}/appConnectors/{app_connector_id}`. + * + * The AppConnectorsService provides methods to manage + * (create/read/update/delete) BeyondCorp AppConnectors. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\BeyondCorp\AppConnectors\V1\AppConnectorsServiceClient} for the + * stable implementation * * @experimental + * + * @method PromiseInterface createAppConnectorAsync(CreateAppConnectorRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAppConnectorAsync(DeleteAppConnectorRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAppConnectorAsync(GetAppConnectorRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAppConnectorsAsync(ListAppConnectorsRequest $request, array $optionalArgs = []) + * @method PromiseInterface reportStatusAsync(ReportStatusRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAppConnectorAsync(UpdateAppConnectorRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class AppConnectorsServiceClient extends AppConnectorsServiceBaseClient +final class AppConnectorsServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AppConnectorsServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'beyondcorp.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/app_connectors_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/app_connectors_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/app_connectors_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/app_connectors_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * app_connector resource. + * + * @param string $project + * @param string $location + * @param string $appConnector + * + * @return string The formatted app_connector resource. + */ + public static function appConnectorName(string $project, string $location, string $appConnector): string + { + return self::getPathTemplate('appConnector')->render([ + 'project' => $project, + 'location' => $location, + 'app_connector' => $appConnector, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - appConnector: projects/{project}/locations/{location}/appConnectors/{app_connector} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'beyondcorp.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new AppConnector in a given project and location. + * + * The async variant is + * {@see AppConnectorsServiceClient::createAppConnectorAsync()} . + * + * @example samples/V1/AppConnectorsServiceClient/create_app_connector.php + * + * @param CreateAppConnectorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAppConnector(CreateAppConnectorRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateAppConnector', $request, $callOptions)->wait(); + } + + /** + * Deletes a single AppConnector. + * + * The async variant is + * {@see AppConnectorsServiceClient::deleteAppConnectorAsync()} . + * + * @example samples/V1/AppConnectorsServiceClient/delete_app_connector.php + * + * @param DeleteAppConnectorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAppConnector(DeleteAppConnectorRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteAppConnector', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single AppConnector. + * + * The async variant is {@see AppConnectorsServiceClient::getAppConnectorAsync()} . + * + * @example samples/V1/AppConnectorsServiceClient/get_app_connector.php + * + * @param GetAppConnectorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AppConnector + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAppConnector(GetAppConnectorRequest $request, array $callOptions = []): AppConnector + { + return $this->startApiCall('GetAppConnector', $request, $callOptions)->wait(); + } + + /** + * Lists AppConnectors in a given project and location. + * + * The async variant is {@see AppConnectorsServiceClient::listAppConnectorsAsync()} + * . + * + * @example samples/V1/AppConnectorsServiceClient/list_app_connectors.php + * + * @param ListAppConnectorsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAppConnectors(ListAppConnectorsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAppConnectors', $request, $callOptions); + } + + /** + * Report status for a given connector. + * + * The async variant is {@see AppConnectorsServiceClient::reportStatusAsync()} . + * + * @example samples/V1/AppConnectorsServiceClient/report_status.php + * + * @param ReportStatusRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function reportStatus(ReportStatusRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ReportStatus', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single AppConnector. + * + * The async variant is + * {@see AppConnectorsServiceClient::updateAppConnectorAsync()} . + * + * @example samples/V1/AppConnectorsServiceClient/update_app_connector.php + * + * @param UpdateAppConnectorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAppConnector(UpdateAppConnectorRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateAppConnector', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see AppConnectorsServiceClient::getLocationAsync()} . + * + * @example samples/V1/AppConnectorsServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see AppConnectorsServiceClient::listLocationsAsync()} . + * + * @example samples/V1/AppConnectorsServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see AppConnectorsServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/AppConnectorsServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see AppConnectorsServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/AppConnectorsServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is + * {@see AppConnectorsServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/AppConnectorsServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/BeyondCorpAppConnectors/src/V1/Client/BaseClient/AppConnectorsServiceBaseClient.php b/BeyondCorpAppConnectors/src/V1/Client/BaseClient/AppConnectorsServiceBaseClient.php deleted file mode 100644 index 4ec1b37819af..000000000000 --- a/BeyondCorpAppConnectors/src/V1/Client/BaseClient/AppConnectorsServiceBaseClient.php +++ /dev/null @@ -1,601 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/app_connectors_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/app_connectors_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/app_connectors_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/app_connectors_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * app_connector resource. - * - * @param string $project - * @param string $location - * @param string $appConnector - * - * @return string The formatted app_connector resource. - */ - public static function appConnectorName(string $project, string $location, string $appConnector): string - { - return self::getPathTemplate('appConnector')->render([ - 'project' => $project, - 'location' => $location, - 'app_connector' => $appConnector, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - appConnector: projects/{project}/locations/{location}/appConnectors/{app_connector} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'beyondcorp.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new AppConnector in a given project and location. - * - * The async variant is {@see self::createAppConnectorAsync()} . - * - * @example samples/V1/AppConnectorsServiceClient/create_app_connector.php - * - * @param CreateAppConnectorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAppConnector(CreateAppConnectorRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateAppConnector', $request, $callOptions)->wait(); - } - - /** - * Deletes a single AppConnector. - * - * The async variant is {@see self::deleteAppConnectorAsync()} . - * - * @example samples/V1/AppConnectorsServiceClient/delete_app_connector.php - * - * @param DeleteAppConnectorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAppConnector(DeleteAppConnectorRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteAppConnector', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single AppConnector. - * - * The async variant is {@see self::getAppConnectorAsync()} . - * - * @example samples/V1/AppConnectorsServiceClient/get_app_connector.php - * - * @param GetAppConnectorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AppConnector - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAppConnector(GetAppConnectorRequest $request, array $callOptions = []): AppConnector - { - return $this->startApiCall('GetAppConnector', $request, $callOptions)->wait(); - } - - /** - * Lists AppConnectors in a given project and location. - * - * The async variant is {@see self::listAppConnectorsAsync()} . - * - * @example samples/V1/AppConnectorsServiceClient/list_app_connectors.php - * - * @param ListAppConnectorsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAppConnectors(ListAppConnectorsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAppConnectors', $request, $callOptions); - } - - /** - * Report status for a given connector. - * - * The async variant is {@see self::reportStatusAsync()} . - * - * @example samples/V1/AppConnectorsServiceClient/report_status.php - * - * @param ReportStatusRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function reportStatus(ReportStatusRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ReportStatus', $request, $callOptions)->wait(); - } - - /** - * Updates the parameters of a single AppConnector. - * - * The async variant is {@see self::updateAppConnectorAsync()} . - * - * @example samples/V1/AppConnectorsServiceClient/update_app_connector.php - * - * @param UpdateAppConnectorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAppConnector(UpdateAppConnectorRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateAppConnector', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/AppConnectorsServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/AppConnectorsServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/AppConnectorsServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/AppConnectorsServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/AppConnectorsServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/BeyondCorpAppGateways/composer.json b/BeyondCorpAppGateways/composer.json index 45b25037573b..d24ce7d4f8f1 100644 --- a/BeyondCorpAppGateways/composer.json +++ b/BeyondCorpAppGateways/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/BeyondCorpAppGateways/src/V1/Client/AppGatewaysServiceClient.php b/BeyondCorpAppGateways/src/V1/Client/AppGatewaysServiceClient.php index fa2c2ae0a784..3f89b626d94e 100644 --- a/BeyondCorpAppGateways/src/V1/Client/AppGatewaysServiceClient.php +++ b/BeyondCorpAppGateways/src/V1/Client/AppGatewaysServiceClient.php @@ -24,17 +24,521 @@ namespace Google\Cloud\BeyondCorp\AppGateways\V1\Client; -use Google\Cloud\BeyondCorp\AppGateways\V1\Client\BaseClient\AppGatewaysServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\BeyondCorp\AppGateways\V1\AppGateway; +use Google\Cloud\BeyondCorp\AppGateways\V1\CreateAppGatewayRequest; +use Google\Cloud\BeyondCorp\AppGateways\V1\DeleteAppGatewayRequest; +use Google\Cloud\BeyondCorp\AppGateways\V1\GetAppGatewayRequest; +use Google\Cloud\BeyondCorp\AppGateways\V1\ListAppGatewaysRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: API Overview: * - * This class is currently experimental and may be subject to changes. + * The `beyondcorp.googleapis.com` service implements the Google Cloud + * BeyondCorp API. + * + * Data Model: + * + * The AppGatewaysService exposes the following resources: + * + * * AppGateways, named as follows: + * `projects/{project_id}/locations/{location_id}/appGateways/{app_gateway_id}`. + * + * The AppGatewaysService service provides methods to manage + * (create/read/update/delete) BeyondCorp AppGateways. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\BeyondCorp\AppGateways\V1\AppGatewaysServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createAppGatewayAsync(CreateAppGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAppGatewayAsync(DeleteAppGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAppGatewayAsync(GetAppGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAppGatewaysAsync(ListAppGatewaysRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class AppGatewaysServiceClient extends AppGatewaysServiceBaseClient +final class AppGatewaysServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AppGatewaysServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.beyondcorp.appgateways.v1.AppGatewaysService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'beyondcorp.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/app_gateways_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/app_gateways_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/app_gateways_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/app_gateways_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a app_gateway + * resource. + * + * @param string $project + * @param string $location + * @param string $appGateway + * + * @return string The formatted app_gateway resource. + */ + public static function appGatewayName(string $project, string $location, string $appGateway): string + { + return self::getPathTemplate('appGateway')->render([ + 'project' => $project, + 'location' => $location, + 'app_gateway' => $appGateway, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - appGateway: projects/{project}/locations/{location}/appGateways/{app_gateway} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'beyondcorp.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new AppGateway in a given project and location. + * + * The async variant is {@see AppGatewaysServiceClient::createAppGatewayAsync()} . + * + * @example samples/V1/AppGatewaysServiceClient/create_app_gateway.php + * + * @param CreateAppGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAppGateway(CreateAppGatewayRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateAppGateway', $request, $callOptions)->wait(); + } + + /** + * Deletes a single AppGateway. + * + * The async variant is {@see AppGatewaysServiceClient::deleteAppGatewayAsync()} . + * + * @example samples/V1/AppGatewaysServiceClient/delete_app_gateway.php + * + * @param DeleteAppGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAppGateway(DeleteAppGatewayRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteAppGateway', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single AppGateway. + * + * The async variant is {@see AppGatewaysServiceClient::getAppGatewayAsync()} . + * + * @example samples/V1/AppGatewaysServiceClient/get_app_gateway.php + * + * @param GetAppGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AppGateway + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAppGateway(GetAppGatewayRequest $request, array $callOptions = []): AppGateway + { + return $this->startApiCall('GetAppGateway', $request, $callOptions)->wait(); + } + + /** + * Lists AppGateways in a given project and location. + * + * The async variant is {@see AppGatewaysServiceClient::listAppGatewaysAsync()} . + * + * @example samples/V1/AppGatewaysServiceClient/list_app_gateways.php + * + * @param ListAppGatewaysRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAppGateways(ListAppGatewaysRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAppGateways', $request, $callOptions); + } + + /** + * Gets information about a location. + * + * The async variant is {@see AppGatewaysServiceClient::getLocationAsync()} . + * + * @example samples/V1/AppGatewaysServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see AppGatewaysServiceClient::listLocationsAsync()} . + * + * @example samples/V1/AppGatewaysServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see AppGatewaysServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/AppGatewaysServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see AppGatewaysServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/AppGatewaysServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see AppGatewaysServiceClient::testIamPermissionsAsync()} + * . + * + * @example samples/V1/AppGatewaysServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/BeyondCorpAppGateways/src/V1/Client/BaseClient/AppGatewaysServiceBaseClient.php b/BeyondCorpAppGateways/src/V1/Client/BaseClient/AppGatewaysServiceBaseClient.php deleted file mode 100644 index fc27cf9cada4..000000000000 --- a/BeyondCorpAppGateways/src/V1/Client/BaseClient/AppGatewaysServiceBaseClient.php +++ /dev/null @@ -1,545 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/app_gateways_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/app_gateways_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/app_gateways_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/app_gateways_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a app_gateway - * resource. - * - * @param string $project - * @param string $location - * @param string $appGateway - * - * @return string The formatted app_gateway resource. - */ - public static function appGatewayName(string $project, string $location, string $appGateway): string - { - return self::getPathTemplate('appGateway')->render([ - 'project' => $project, - 'location' => $location, - 'app_gateway' => $appGateway, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - appGateway: projects/{project}/locations/{location}/appGateways/{app_gateway} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'beyondcorp.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new AppGateway in a given project and location. - * - * The async variant is {@see self::createAppGatewayAsync()} . - * - * @example samples/V1/AppGatewaysServiceClient/create_app_gateway.php - * - * @param CreateAppGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAppGateway(CreateAppGatewayRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateAppGateway', $request, $callOptions)->wait(); - } - - /** - * Deletes a single AppGateway. - * - * The async variant is {@see self::deleteAppGatewayAsync()} . - * - * @example samples/V1/AppGatewaysServiceClient/delete_app_gateway.php - * - * @param DeleteAppGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAppGateway(DeleteAppGatewayRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteAppGateway', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single AppGateway. - * - * The async variant is {@see self::getAppGatewayAsync()} . - * - * @example samples/V1/AppGatewaysServiceClient/get_app_gateway.php - * - * @param GetAppGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AppGateway - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAppGateway(GetAppGatewayRequest $request, array $callOptions = []): AppGateway - { - return $this->startApiCall('GetAppGateway', $request, $callOptions)->wait(); - } - - /** - * Lists AppGateways in a given project and location. - * - * The async variant is {@see self::listAppGatewaysAsync()} . - * - * @example samples/V1/AppGatewaysServiceClient/list_app_gateways.php - * - * @param ListAppGatewaysRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAppGateways(ListAppGatewaysRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAppGateways', $request, $callOptions); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/AppGatewaysServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/AppGatewaysServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/AppGatewaysServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/AppGatewaysServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/AppGatewaysServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/BeyondCorpClientConnectorServices/composer.json b/BeyondCorpClientConnectorServices/composer.json index e293fa0db041..964ca9e45841 100644 --- a/BeyondCorpClientConnectorServices/composer.json +++ b/BeyondCorpClientConnectorServices/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/BeyondCorpClientConnectorServices/src/V1/Client/BaseClient/ClientConnectorServicesServiceBaseClient.php b/BeyondCorpClientConnectorServices/src/V1/Client/BaseClient/ClientConnectorServicesServiceBaseClient.php deleted file mode 100644 index 54f112a918be..000000000000 --- a/BeyondCorpClientConnectorServices/src/V1/Client/BaseClient/ClientConnectorServicesServiceBaseClient.php +++ /dev/null @@ -1,570 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/client_connector_services_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/client_connector_services_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/client_connector_services_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/client_connector_services_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * client_connector_service resource. - * - * @param string $project - * @param string $location - * @param string $clientConnectorService - * - * @return string The formatted client_connector_service resource. - */ - public static function clientConnectorServiceName(string $project, string $location, string $clientConnectorService): string - { - return self::getPathTemplate('clientConnectorService')->render([ - 'project' => $project, - 'location' => $location, - 'client_connector_service' => $clientConnectorService, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - clientConnectorService: projects/{project}/locations/{location}/clientConnectorServices/{client_connector_service} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'beyondcorp.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new ClientConnectorService in a given project and location. - * - * The async variant is {@see self::createClientConnectorServiceAsync()} . - * - * @example samples/V1/ClientConnectorServicesServiceClient/create_client_connector_service.php - * - * @param CreateClientConnectorServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createClientConnectorService(CreateClientConnectorServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateClientConnectorService', $request, $callOptions)->wait(); - } - - /** - * Deletes a single ClientConnectorService. - * - * The async variant is {@see self::deleteClientConnectorServiceAsync()} . - * - * @example samples/V1/ClientConnectorServicesServiceClient/delete_client_connector_service.php - * - * @param DeleteClientConnectorServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteClientConnectorService(DeleteClientConnectorServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteClientConnectorService', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single ClientConnectorService. - * - * The async variant is {@see self::getClientConnectorServiceAsync()} . - * - * @example samples/V1/ClientConnectorServicesServiceClient/get_client_connector_service.php - * - * @param GetClientConnectorServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ClientConnectorService - * - * @throws ApiException Thrown if the API call fails. - */ - public function getClientConnectorService(GetClientConnectorServiceRequest $request, array $callOptions = []): ClientConnectorService - { - return $this->startApiCall('GetClientConnectorService', $request, $callOptions)->wait(); - } - - /** - * Lists ClientConnectorServices in a given project and location. - * - * The async variant is {@see self::listClientConnectorServicesAsync()} . - * - * @example samples/V1/ClientConnectorServicesServiceClient/list_client_connector_services.php - * - * @param ListClientConnectorServicesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listClientConnectorServices(ListClientConnectorServicesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListClientConnectorServices', $request, $callOptions); - } - - /** - * Updates the parameters of a single ClientConnectorService. - * - * The async variant is {@see self::updateClientConnectorServiceAsync()} . - * - * @example samples/V1/ClientConnectorServicesServiceClient/update_client_connector_service.php - * - * @param UpdateClientConnectorServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateClientConnectorService(UpdateClientConnectorServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateClientConnectorService', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/ClientConnectorServicesServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/ClientConnectorServicesServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/ClientConnectorServicesServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/ClientConnectorServicesServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/ClientConnectorServicesServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/BeyondCorpClientConnectorServices/src/V1/Client/ClientConnectorServicesServiceClient.php b/BeyondCorpClientConnectorServices/src/V1/Client/ClientConnectorServicesServiceClient.php index 4bcc0e46ce3d..e1d5d3bd7b7c 100644 --- a/BeyondCorpClientConnectorServices/src/V1/Client/ClientConnectorServicesServiceClient.php +++ b/BeyondCorpClientConnectorServices/src/V1/Client/ClientConnectorServicesServiceClient.php @@ -24,17 +24,559 @@ namespace Google\Cloud\BeyondCorp\ClientConnectorServices\V1\Client; -use Google\Cloud\BeyondCorp\ClientConnectorServices\V1\Client\BaseClient\ClientConnectorServicesServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\BeyondCorp\ClientConnectorServices\V1\ClientConnectorService; +use Google\Cloud\BeyondCorp\ClientConnectorServices\V1\CreateClientConnectorServiceRequest; +use Google\Cloud\BeyondCorp\ClientConnectorServices\V1\DeleteClientConnectorServiceRequest; +use Google\Cloud\BeyondCorp\ClientConnectorServices\V1\GetClientConnectorServiceRequest; +use Google\Cloud\BeyondCorp\ClientConnectorServices\V1\ListClientConnectorServicesRequest; +use Google\Cloud\BeyondCorp\ClientConnectorServices\V1\UpdateClientConnectorServiceRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: API Overview: * - * This class is currently experimental and may be subject to changes. + * The `beyondcorp.googleapis.com` service implements the Google Cloud + * BeyondCorp API. + * + * Data Model: + * + * The ClientConnectorServicesService exposes the following resources: + * + * * Client Connector Services, named as follows: + * `projects/{project_id}/locations/{location_id}/client_connector_services/{client_connector_service_id}`. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\BeyondCorp\ClientConnectorServices\V1\ClientConnectorServicesServiceClient} + * for the stable implementation * * @experimental + * + * @method PromiseInterface createClientConnectorServiceAsync(CreateClientConnectorServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteClientConnectorServiceAsync(DeleteClientConnectorServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getClientConnectorServiceAsync(GetClientConnectorServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface listClientConnectorServicesAsync(ListClientConnectorServicesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateClientConnectorServiceAsync(UpdateClientConnectorServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class ClientConnectorServicesServiceClient extends ClientConnectorServicesServiceBaseClient +final class ClientConnectorServicesServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ClientConnectorServicesServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'beyondcorp.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/client_connector_services_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/client_connector_services_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/client_connector_services_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/client_connector_services_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * client_connector_service resource. + * + * @param string $project + * @param string $location + * @param string $clientConnectorService + * + * @return string The formatted client_connector_service resource. + */ + public static function clientConnectorServiceName(string $project, string $location, string $clientConnectorService): string + { + return self::getPathTemplate('clientConnectorService')->render([ + 'project' => $project, + 'location' => $location, + 'client_connector_service' => $clientConnectorService, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - clientConnectorService: projects/{project}/locations/{location}/clientConnectorServices/{client_connector_service} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'beyondcorp.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new ClientConnectorService in a given project and location. + * + * The async variant is + * {@see ClientConnectorServicesServiceClient::createClientConnectorServiceAsync()} + * . + * + * @example samples/V1/ClientConnectorServicesServiceClient/create_client_connector_service.php + * + * @param CreateClientConnectorServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createClientConnectorService(CreateClientConnectorServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateClientConnectorService', $request, $callOptions)->wait(); + } + + /** + * Deletes a single ClientConnectorService. + * + * The async variant is + * {@see ClientConnectorServicesServiceClient::deleteClientConnectorServiceAsync()} + * . + * + * @example samples/V1/ClientConnectorServicesServiceClient/delete_client_connector_service.php + * + * @param DeleteClientConnectorServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteClientConnectorService(DeleteClientConnectorServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteClientConnectorService', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single ClientConnectorService. + * + * The async variant is + * {@see ClientConnectorServicesServiceClient::getClientConnectorServiceAsync()} . + * + * @example samples/V1/ClientConnectorServicesServiceClient/get_client_connector_service.php + * + * @param GetClientConnectorServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ClientConnectorService + * + * @throws ApiException Thrown if the API call fails. + */ + public function getClientConnectorService(GetClientConnectorServiceRequest $request, array $callOptions = []): ClientConnectorService + { + return $this->startApiCall('GetClientConnectorService', $request, $callOptions)->wait(); + } + + /** + * Lists ClientConnectorServices in a given project and location. + * + * The async variant is + * {@see ClientConnectorServicesServiceClient::listClientConnectorServicesAsync()} + * . + * + * @example samples/V1/ClientConnectorServicesServiceClient/list_client_connector_services.php + * + * @param ListClientConnectorServicesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listClientConnectorServices(ListClientConnectorServicesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListClientConnectorServices', $request, $callOptions); + } + + /** + * Updates the parameters of a single ClientConnectorService. + * + * The async variant is + * {@see ClientConnectorServicesServiceClient::updateClientConnectorServiceAsync()} + * . + * + * @example samples/V1/ClientConnectorServicesServiceClient/update_client_connector_service.php + * + * @param UpdateClientConnectorServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateClientConnectorService(UpdateClientConnectorServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateClientConnectorService', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is + * {@see ClientConnectorServicesServiceClient::getLocationAsync()} . + * + * @example samples/V1/ClientConnectorServicesServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is + * {@see ClientConnectorServicesServiceClient::listLocationsAsync()} . + * + * @example samples/V1/ClientConnectorServicesServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is + * {@see ClientConnectorServicesServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/ClientConnectorServicesServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is + * {@see ClientConnectorServicesServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/ClientConnectorServicesServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is + * {@see ClientConnectorServicesServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/ClientConnectorServicesServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/BeyondCorpClientGateways/composer.json b/BeyondCorpClientGateways/composer.json index 96a1d7b50c09..dbc3c9f1c69b 100644 --- a/BeyondCorpClientGateways/composer.json +++ b/BeyondCorpClientGateways/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/BeyondCorpClientGateways/src/V1/Client/BaseClient/ClientGatewaysServiceBaseClient.php b/BeyondCorpClientGateways/src/V1/Client/BaseClient/ClientGatewaysServiceBaseClient.php deleted file mode 100644 index afef50d9527d..000000000000 --- a/BeyondCorpClientGateways/src/V1/Client/BaseClient/ClientGatewaysServiceBaseClient.php +++ /dev/null @@ -1,542 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/client_gateways_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/client_gateways_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/client_gateways_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/client_gateways_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * client_gateway resource. - * - * @param string $project - * @param string $location - * @param string $clientGateway - * - * @return string The formatted client_gateway resource. - */ - public static function clientGatewayName(string $project, string $location, string $clientGateway): string - { - return self::getPathTemplate('clientGateway')->render([ - 'project' => $project, - 'location' => $location, - 'client_gateway' => $clientGateway, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - clientGateway: projects/{project}/locations/{location}/clientGateways/{client_gateway} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'beyondcorp.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new ClientGateway in a given project and location. - * - * The async variant is {@see self::createClientGatewayAsync()} . - * - * @example samples/V1/ClientGatewaysServiceClient/create_client_gateway.php - * - * @param CreateClientGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createClientGateway(CreateClientGatewayRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateClientGateway', $request, $callOptions)->wait(); - } - - /** - * Deletes a single ClientGateway. - * - * The async variant is {@see self::deleteClientGatewayAsync()} . - * - * @example samples/V1/ClientGatewaysServiceClient/delete_client_gateway.php - * - * @param DeleteClientGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteClientGateway(DeleteClientGatewayRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteClientGateway', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single ClientGateway. - * - * The async variant is {@see self::getClientGatewayAsync()} . - * - * @example samples/V1/ClientGatewaysServiceClient/get_client_gateway.php - * - * @param GetClientGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ClientGateway - * - * @throws ApiException Thrown if the API call fails. - */ - public function getClientGateway(GetClientGatewayRequest $request, array $callOptions = []): ClientGateway - { - return $this->startApiCall('GetClientGateway', $request, $callOptions)->wait(); - } - - /** - * Lists ClientGateways in a given project and location. - * - * The async variant is {@see self::listClientGatewaysAsync()} . - * - * @example samples/V1/ClientGatewaysServiceClient/list_client_gateways.php - * - * @param ListClientGatewaysRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listClientGateways(ListClientGatewaysRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListClientGateways', $request, $callOptions); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/ClientGatewaysServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/ClientGatewaysServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/ClientGatewaysServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/ClientGatewaysServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/ClientGatewaysServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/BeyondCorpClientGateways/src/V1/Client/ClientGatewaysServiceClient.php b/BeyondCorpClientGateways/src/V1/Client/ClientGatewaysServiceClient.php index 68d0596349ac..4d0420375960 100644 --- a/BeyondCorpClientGateways/src/V1/Client/ClientGatewaysServiceClient.php +++ b/BeyondCorpClientGateways/src/V1/Client/ClientGatewaysServiceClient.php @@ -24,17 +24,522 @@ namespace Google\Cloud\BeyondCorp\ClientGateways\V1\Client; -use Google\Cloud\BeyondCorp\ClientGateways\V1\Client\BaseClient\ClientGatewaysServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\BeyondCorp\ClientGateways\V1\ClientGateway; +use Google\Cloud\BeyondCorp\ClientGateways\V1\CreateClientGatewayRequest; +use Google\Cloud\BeyondCorp\ClientGateways\V1\DeleteClientGatewayRequest; +use Google\Cloud\BeyondCorp\ClientGateways\V1\GetClientGatewayRequest; +use Google\Cloud\BeyondCorp\ClientGateways\V1\ListClientGatewaysRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: API Overview: * - * This class is currently experimental and may be subject to changes. + * The `beyondcorp.googleapis.com` service implements the Google Cloud + * BeyondCorp API. + * + * Data Model: + * + * The ClientGatewaysService exposes the following resources: + * + * * Client Gateways, named as follows: + * `projects/{project_id}/locations/{location_id}/clientGateways/{client_gateway_id}`. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\BeyondCorp\ClientGateways\V1\ClientGatewaysServiceClient} for the + * stable implementation * * @experimental + * + * @method PromiseInterface createClientGatewayAsync(CreateClientGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteClientGatewayAsync(DeleteClientGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface getClientGatewayAsync(GetClientGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface listClientGatewaysAsync(ListClientGatewaysRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class ClientGatewaysServiceClient extends ClientGatewaysServiceBaseClient +final class ClientGatewaysServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ClientGatewaysServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'beyondcorp.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/client_gateways_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/client_gateways_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/client_gateways_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/client_gateways_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * client_gateway resource. + * + * @param string $project + * @param string $location + * @param string $clientGateway + * + * @return string The formatted client_gateway resource. + */ + public static function clientGatewayName(string $project, string $location, string $clientGateway): string + { + return self::getPathTemplate('clientGateway')->render([ + 'project' => $project, + 'location' => $location, + 'client_gateway' => $clientGateway, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - clientGateway: projects/{project}/locations/{location}/clientGateways/{client_gateway} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'beyondcorp.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new ClientGateway in a given project and location. + * + * The async variant is + * {@see ClientGatewaysServiceClient::createClientGatewayAsync()} . + * + * @example samples/V1/ClientGatewaysServiceClient/create_client_gateway.php + * + * @param CreateClientGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createClientGateway(CreateClientGatewayRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateClientGateway', $request, $callOptions)->wait(); + } + + /** + * Deletes a single ClientGateway. + * + * The async variant is + * {@see ClientGatewaysServiceClient::deleteClientGatewayAsync()} . + * + * @example samples/V1/ClientGatewaysServiceClient/delete_client_gateway.php + * + * @param DeleteClientGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteClientGateway(DeleteClientGatewayRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteClientGateway', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single ClientGateway. + * + * The async variant is {@see ClientGatewaysServiceClient::getClientGatewayAsync()} + * . + * + * @example samples/V1/ClientGatewaysServiceClient/get_client_gateway.php + * + * @param GetClientGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ClientGateway + * + * @throws ApiException Thrown if the API call fails. + */ + public function getClientGateway(GetClientGatewayRequest $request, array $callOptions = []): ClientGateway + { + return $this->startApiCall('GetClientGateway', $request, $callOptions)->wait(); + } + + /** + * Lists ClientGateways in a given project and location. + * + * The async variant is + * {@see ClientGatewaysServiceClient::listClientGatewaysAsync()} . + * + * @example samples/V1/ClientGatewaysServiceClient/list_client_gateways.php + * + * @param ListClientGatewaysRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listClientGateways(ListClientGatewaysRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListClientGateways', $request, $callOptions); + } + + /** + * Gets information about a location. + * + * The async variant is {@see ClientGatewaysServiceClient::getLocationAsync()} . + * + * @example samples/V1/ClientGatewaysServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see ClientGatewaysServiceClient::listLocationsAsync()} . + * + * @example samples/V1/ClientGatewaysServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see ClientGatewaysServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/ClientGatewaysServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see ClientGatewaysServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/ClientGatewaysServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is + * {@see ClientGatewaysServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/ClientGatewaysServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/BigQuery/composer.json b/BigQuery/composer.json index e36e8a0929c9..6e654b2040f7 100644 --- a/BigQuery/composer.json +++ b/BigQuery/composer.json @@ -5,7 +5,7 @@ "minimum-stability": "stable", "require": { "php": ">=7.4", - "google/cloud-core": "^1.43", + "google/cloud-core": "^1.52.7", "ramsey/uuid": "^3.0|^4.0" }, "require-dev": { diff --git a/BigQueryAnalyticsHub/composer.json b/BigQueryAnalyticsHub/composer.json index f45925927257..79717596d14b 100644 --- a/BigQueryAnalyticsHub/composer.json +++ b/BigQueryAnalyticsHub/composer.json @@ -19,7 +19,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/BigQueryAnalyticsHub/src/V1/Client/AnalyticsHubServiceClient.php b/BigQueryAnalyticsHub/src/V1/Client/AnalyticsHubServiceClient.php index 9177b15e52e3..6527af9082f5 100644 --- a/BigQueryAnalyticsHub/src/V1/Client/AnalyticsHubServiceClient.php +++ b/BigQueryAnalyticsHub/src/V1/Client/AnalyticsHubServiceClient.php @@ -24,17 +24,946 @@ namespace Google\Cloud\BigQuery\AnalyticsHub\V1\Client; -use Google\Cloud\BigQuery\AnalyticsHub\V1\Client\BaseClient\AnalyticsHubServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\BigQuery\AnalyticsHub\V1\CreateDataExchangeRequest; +use Google\Cloud\BigQuery\AnalyticsHub\V1\CreateListingRequest; +use Google\Cloud\BigQuery\AnalyticsHub\V1\DataExchange; +use Google\Cloud\BigQuery\AnalyticsHub\V1\DeleteDataExchangeRequest; +use Google\Cloud\BigQuery\AnalyticsHub\V1\DeleteListingRequest; +use Google\Cloud\BigQuery\AnalyticsHub\V1\DeleteSubscriptionRequest; +use Google\Cloud\BigQuery\AnalyticsHub\V1\GetDataExchangeRequest; +use Google\Cloud\BigQuery\AnalyticsHub\V1\GetListingRequest; +use Google\Cloud\BigQuery\AnalyticsHub\V1\GetSubscriptionRequest; +use Google\Cloud\BigQuery\AnalyticsHub\V1\ListDataExchangesRequest; +use Google\Cloud\BigQuery\AnalyticsHub\V1\ListListingsRequest; +use Google\Cloud\BigQuery\AnalyticsHub\V1\ListOrgDataExchangesRequest; +use Google\Cloud\BigQuery\AnalyticsHub\V1\ListSharedResourceSubscriptionsRequest; +use Google\Cloud\BigQuery\AnalyticsHub\V1\ListSubscriptionsRequest; +use Google\Cloud\BigQuery\AnalyticsHub\V1\Listing; +use Google\Cloud\BigQuery\AnalyticsHub\V1\RefreshSubscriptionRequest; +use Google\Cloud\BigQuery\AnalyticsHub\V1\RevokeSubscriptionRequest; +use Google\Cloud\BigQuery\AnalyticsHub\V1\RevokeSubscriptionResponse; +use Google\Cloud\BigQuery\AnalyticsHub\V1\SubscribeDataExchangeRequest; +use Google\Cloud\BigQuery\AnalyticsHub\V1\SubscribeListingRequest; +use Google\Cloud\BigQuery\AnalyticsHub\V1\SubscribeListingResponse; +use Google\Cloud\BigQuery\AnalyticsHub\V1\Subscription; +use Google\Cloud\BigQuery\AnalyticsHub\V1\UpdateDataExchangeRequest; +use Google\Cloud\BigQuery\AnalyticsHub\V1\UpdateListingRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The `AnalyticsHubService` API facilitates data sharing within and across + * organizations. It allows data providers to publish listings that reference + * shared datasets. With Analytics Hub, users can discover and search for + * listings that they have access to. Subscribers can view and subscribe to + * listings. When you subscribe to a listing, Analytics Hub creates a linked + * dataset in your project. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\BigQuery\AnalyticsHub\V1\AnalyticsHubServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createDataExchangeAsync(CreateDataExchangeRequest $request, array $optionalArgs = []) + * @method PromiseInterface createListingAsync(CreateListingRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDataExchangeAsync(DeleteDataExchangeRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteListingAsync(DeleteListingRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSubscriptionAsync(DeleteSubscriptionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDataExchangeAsync(GetDataExchangeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getListingAsync(GetListingRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSubscriptionAsync(GetSubscriptionRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDataExchangesAsync(ListDataExchangesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listListingsAsync(ListListingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listOrgDataExchangesAsync(ListOrgDataExchangesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSharedResourceSubscriptionsAsync(ListSharedResourceSubscriptionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSubscriptionsAsync(ListSubscriptionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface refreshSubscriptionAsync(RefreshSubscriptionRequest $request, array $optionalArgs = []) + * @method PromiseInterface revokeSubscriptionAsync(RevokeSubscriptionRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface subscribeDataExchangeAsync(SubscribeDataExchangeRequest $request, array $optionalArgs = []) + * @method PromiseInterface subscribeListingAsync(SubscribeListingRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDataExchangeAsync(UpdateDataExchangeRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateListingAsync(UpdateListingRequest $request, array $optionalArgs = []) */ -final class AnalyticsHubServiceClient extends AnalyticsHubServiceBaseClient +final class AnalyticsHubServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AnalyticsHubServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.bigquery.analyticshub.v1.AnalyticsHubService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'analyticshub.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/bigquery', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/analytics_hub_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/analytics_hub_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/analytics_hub_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/analytics_hub_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * data_exchange resource. + * + * @param string $project + * @param string $location + * @param string $dataExchange + * + * @return string The formatted data_exchange resource. + */ + public static function dataExchangeName(string $project, string $location, string $dataExchange): string + { + return self::getPathTemplate('dataExchange')->render([ + 'project' => $project, + 'location' => $location, + 'data_exchange' => $dataExchange, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a dataset + * resource. + * + * @param string $project + * @param string $dataset + * + * @return string The formatted dataset resource. + */ + public static function datasetName(string $project, string $dataset): string + { + return self::getPathTemplate('dataset')->render([ + 'project' => $project, + 'dataset' => $dataset, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a listing + * resource. + * + * @param string $project + * @param string $location + * @param string $dataExchange + * @param string $listing + * + * @return string The formatted listing resource. + */ + public static function listingName(string $project, string $location, string $dataExchange, string $listing): string + { + return self::getPathTemplate('listing')->render([ + 'project' => $project, + 'location' => $location, + 'data_exchange' => $dataExchange, + 'listing' => $listing, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a subscription + * resource. + * + * @param string $project + * @param string $location + * @param string $subscription + * + * @return string The formatted subscription resource. + */ + public static function subscriptionName(string $project, string $location, string $subscription): string + { + return self::getPathTemplate('subscription')->render([ + 'project' => $project, + 'location' => $location, + 'subscription' => $subscription, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - dataExchange: projects/{project}/locations/{location}/dataExchanges/{data_exchange} + * - dataset: projects/{project}/datasets/{dataset} + * - listing: projects/{project}/locations/{location}/dataExchanges/{data_exchange}/listings/{listing} + * - location: projects/{project}/locations/{location} + * - subscription: projects/{project}/locations/{location}/subscriptions/{subscription} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'analyticshub.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new data exchange. + * + * The async variant is {@see AnalyticsHubServiceClient::createDataExchangeAsync()} + * . + * + * @example samples/V1/AnalyticsHubServiceClient/create_data_exchange.php + * + * @param CreateDataExchangeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataExchange + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDataExchange(CreateDataExchangeRequest $request, array $callOptions = []): DataExchange + { + return $this->startApiCall('CreateDataExchange', $request, $callOptions)->wait(); + } + + /** + * Creates a new listing. + * + * The async variant is {@see AnalyticsHubServiceClient::createListingAsync()} . + * + * @example samples/V1/AnalyticsHubServiceClient/create_listing.php + * + * @param CreateListingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Listing + * + * @throws ApiException Thrown if the API call fails. + */ + public function createListing(CreateListingRequest $request, array $callOptions = []): Listing + { + return $this->startApiCall('CreateListing', $request, $callOptions)->wait(); + } + + /** + * Deletes an existing data exchange. + * + * The async variant is {@see AnalyticsHubServiceClient::deleteDataExchangeAsync()} + * . + * + * @example samples/V1/AnalyticsHubServiceClient/delete_data_exchange.php + * + * @param DeleteDataExchangeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDataExchange(DeleteDataExchangeRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteDataExchange', $request, $callOptions)->wait(); + } + + /** + * Deletes a listing. + * + * The async variant is {@see AnalyticsHubServiceClient::deleteListingAsync()} . + * + * @example samples/V1/AnalyticsHubServiceClient/delete_listing.php + * + * @param DeleteListingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteListing(DeleteListingRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteListing', $request, $callOptions)->wait(); + } + + /** + * Deletes a subscription. + * + * The async variant is {@see AnalyticsHubServiceClient::deleteSubscriptionAsync()} + * . + * + * @example samples/V1/AnalyticsHubServiceClient/delete_subscription.php + * + * @param DeleteSubscriptionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSubscription(DeleteSubscriptionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteSubscription', $request, $callOptions)->wait(); + } + + /** + * Gets the details of a data exchange. + * + * The async variant is {@see AnalyticsHubServiceClient::getDataExchangeAsync()} . + * + * @example samples/V1/AnalyticsHubServiceClient/get_data_exchange.php + * + * @param GetDataExchangeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataExchange + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDataExchange(GetDataExchangeRequest $request, array $callOptions = []): DataExchange + { + return $this->startApiCall('GetDataExchange', $request, $callOptions)->wait(); + } + + /** + * Gets the IAM policy. + * + * The async variant is {@see AnalyticsHubServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/AnalyticsHubServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets the details of a listing. + * + * The async variant is {@see AnalyticsHubServiceClient::getListingAsync()} . + * + * @example samples/V1/AnalyticsHubServiceClient/get_listing.php + * + * @param GetListingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Listing + * + * @throws ApiException Thrown if the API call fails. + */ + public function getListing(GetListingRequest $request, array $callOptions = []): Listing + { + return $this->startApiCall('GetListing', $request, $callOptions)->wait(); + } + + /** + * Gets the details of a Subscription. + * + * The async variant is {@see AnalyticsHubServiceClient::getSubscriptionAsync()} . + * + * @example samples/V1/AnalyticsHubServiceClient/get_subscription.php + * + * @param GetSubscriptionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Subscription + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSubscription(GetSubscriptionRequest $request, array $callOptions = []): Subscription + { + return $this->startApiCall('GetSubscription', $request, $callOptions)->wait(); + } + + /** + * Lists all data exchanges in a given project and location. + * + * The async variant is {@see AnalyticsHubServiceClient::listDataExchangesAsync()} + * . + * + * @example samples/V1/AnalyticsHubServiceClient/list_data_exchanges.php + * + * @param ListDataExchangesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDataExchanges(ListDataExchangesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDataExchanges', $request, $callOptions); + } + + /** + * Lists all listings in a given project and location. + * + * The async variant is {@see AnalyticsHubServiceClient::listListingsAsync()} . + * + * @example samples/V1/AnalyticsHubServiceClient/list_listings.php + * + * @param ListListingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listListings(ListListingsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListListings', $request, $callOptions); + } + + /** + * Lists all data exchanges from projects in a given organization and + * location. + * + * The async variant is + * {@see AnalyticsHubServiceClient::listOrgDataExchangesAsync()} . + * + * @example samples/V1/AnalyticsHubServiceClient/list_org_data_exchanges.php + * + * @param ListOrgDataExchangesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listOrgDataExchanges(ListOrgDataExchangesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListOrgDataExchanges', $request, $callOptions); + } + + /** + * Lists all subscriptions on a given Data Exchange or Listing. + * + * The async variant is + * {@see AnalyticsHubServiceClient::listSharedResourceSubscriptionsAsync()} . + * + * @example samples/V1/AnalyticsHubServiceClient/list_shared_resource_subscriptions.php + * + * @param ListSharedResourceSubscriptionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSharedResourceSubscriptions(ListSharedResourceSubscriptionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSharedResourceSubscriptions', $request, $callOptions); + } + + /** + * Lists all subscriptions in a given project and location. + * + * The async variant is {@see AnalyticsHubServiceClient::listSubscriptionsAsync()} + * . + * + * @example samples/V1/AnalyticsHubServiceClient/list_subscriptions.php + * + * @param ListSubscriptionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSubscriptions(ListSubscriptionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSubscriptions', $request, $callOptions); + } + + /** + * Refreshes a Subscription to a Data Exchange. A Data Exchange can become + * stale when a publisher adds or removes data. This is a long-running + * operation as it may create many linked datasets. + * + * The async variant is + * {@see AnalyticsHubServiceClient::refreshSubscriptionAsync()} . + * + * @example samples/V1/AnalyticsHubServiceClient/refresh_subscription.php + * + * @param RefreshSubscriptionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function refreshSubscription(RefreshSubscriptionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RefreshSubscription', $request, $callOptions)->wait(); + } + + /** + * Revokes a given subscription. + * + * The async variant is {@see AnalyticsHubServiceClient::revokeSubscriptionAsync()} + * . + * + * @example samples/V1/AnalyticsHubServiceClient/revoke_subscription.php + * + * @param RevokeSubscriptionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RevokeSubscriptionResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function revokeSubscription(RevokeSubscriptionRequest $request, array $callOptions = []): RevokeSubscriptionResponse + { + return $this->startApiCall('RevokeSubscription', $request, $callOptions)->wait(); + } + + /** + * Sets the IAM policy. + * + * The async variant is {@see AnalyticsHubServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/AnalyticsHubServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Creates a Subscription to a Data Exchange. This is a long-running operation + * as it will create one or more linked datasets. + * + * The async variant is + * {@see AnalyticsHubServiceClient::subscribeDataExchangeAsync()} . + * + * @example samples/V1/AnalyticsHubServiceClient/subscribe_data_exchange.php + * + * @param SubscribeDataExchangeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function subscribeDataExchange(SubscribeDataExchangeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SubscribeDataExchange', $request, $callOptions)->wait(); + } + + /** + * Subscribes to a listing. + * + * Currently, with Analytics Hub, you can create listings that + * reference only BigQuery datasets. + * Upon subscription to a listing for a BigQuery dataset, Analytics Hub + * creates a linked dataset in the subscriber's project. + * + * The async variant is {@see AnalyticsHubServiceClient::subscribeListingAsync()} . + * + * @example samples/V1/AnalyticsHubServiceClient/subscribe_listing.php + * + * @param SubscribeListingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SubscribeListingResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function subscribeListing(SubscribeListingRequest $request, array $callOptions = []): SubscribeListingResponse + { + return $this->startApiCall('SubscribeListing', $request, $callOptions)->wait(); + } + + /** + * Returns the permissions that a caller has. + * + * The async variant is {@see AnalyticsHubServiceClient::testIamPermissionsAsync()} + * . + * + * @example samples/V1/AnalyticsHubServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates an existing data exchange. + * + * The async variant is {@see AnalyticsHubServiceClient::updateDataExchangeAsync()} + * . + * + * @example samples/V1/AnalyticsHubServiceClient/update_data_exchange.php + * + * @param UpdateDataExchangeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataExchange + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDataExchange(UpdateDataExchangeRequest $request, array $callOptions = []): DataExchange + { + return $this->startApiCall('UpdateDataExchange', $request, $callOptions)->wait(); + } + + /** + * Updates an existing listing. + * + * The async variant is {@see AnalyticsHubServiceClient::updateListingAsync()} . + * + * @example samples/V1/AnalyticsHubServiceClient/update_listing.php + * + * @param UpdateListingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Listing + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateListing(UpdateListingRequest $request, array $callOptions = []): Listing + { + return $this->startApiCall('UpdateListing', $request, $callOptions)->wait(); + } } diff --git a/BigQueryAnalyticsHub/src/V1/Client/BaseClient/AnalyticsHubServiceBaseClient.php b/BigQueryAnalyticsHub/src/V1/Client/BaseClient/AnalyticsHubServiceBaseClient.php deleted file mode 100644 index 05a446e56024..000000000000 --- a/BigQueryAnalyticsHub/src/V1/Client/BaseClient/AnalyticsHubServiceBaseClient.php +++ /dev/null @@ -1,959 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/analytics_hub_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/analytics_hub_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/analytics_hub_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/analytics_hub_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * data_exchange resource. - * - * @param string $project - * @param string $location - * @param string $dataExchange - * - * @return string The formatted data_exchange resource. - */ - public static function dataExchangeName(string $project, string $location, string $dataExchange): string - { - return self::getPathTemplate('dataExchange')->render([ - 'project' => $project, - 'location' => $location, - 'data_exchange' => $dataExchange, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a dataset - * resource. - * - * @param string $project - * @param string $dataset - * - * @return string The formatted dataset resource. - */ - public static function datasetName(string $project, string $dataset): string - { - return self::getPathTemplate('dataset')->render([ - 'project' => $project, - 'dataset' => $dataset, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a listing - * resource. - * - * @param string $project - * @param string $location - * @param string $dataExchange - * @param string $listing - * - * @return string The formatted listing resource. - */ - public static function listingName(string $project, string $location, string $dataExchange, string $listing): string - { - return self::getPathTemplate('listing')->render([ - 'project' => $project, - 'location' => $location, - 'data_exchange' => $dataExchange, - 'listing' => $listing, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a subscription - * resource. - * - * @param string $project - * @param string $location - * @param string $subscription - * - * @return string The formatted subscription resource. - */ - public static function subscriptionName(string $project, string $location, string $subscription): string - { - return self::getPathTemplate('subscription')->render([ - 'project' => $project, - 'location' => $location, - 'subscription' => $subscription, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - dataExchange: projects/{project}/locations/{location}/dataExchanges/{data_exchange} - * - dataset: projects/{project}/datasets/{dataset} - * - listing: projects/{project}/locations/{location}/dataExchanges/{data_exchange}/listings/{listing} - * - location: projects/{project}/locations/{location} - * - subscription: projects/{project}/locations/{location}/subscriptions/{subscription} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'analyticshub.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new data exchange. - * - * The async variant is {@see self::createDataExchangeAsync()} . - * - * @example samples/V1/AnalyticsHubServiceClient/create_data_exchange.php - * - * @param CreateDataExchangeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataExchange - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDataExchange(CreateDataExchangeRequest $request, array $callOptions = []): DataExchange - { - return $this->startApiCall('CreateDataExchange', $request, $callOptions)->wait(); - } - - /** - * Creates a new listing. - * - * The async variant is {@see self::createListingAsync()} . - * - * @example samples/V1/AnalyticsHubServiceClient/create_listing.php - * - * @param CreateListingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Listing - * - * @throws ApiException Thrown if the API call fails. - */ - public function createListing(CreateListingRequest $request, array $callOptions = []): Listing - { - return $this->startApiCall('CreateListing', $request, $callOptions)->wait(); - } - - /** - * Deletes an existing data exchange. - * - * The async variant is {@see self::deleteDataExchangeAsync()} . - * - * @example samples/V1/AnalyticsHubServiceClient/delete_data_exchange.php - * - * @param DeleteDataExchangeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDataExchange(DeleteDataExchangeRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteDataExchange', $request, $callOptions)->wait(); - } - - /** - * Deletes a listing. - * - * The async variant is {@see self::deleteListingAsync()} . - * - * @example samples/V1/AnalyticsHubServiceClient/delete_listing.php - * - * @param DeleteListingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteListing(DeleteListingRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteListing', $request, $callOptions)->wait(); - } - - /** - * Deletes a subscription. - * - * The async variant is {@see self::deleteSubscriptionAsync()} . - * - * @example samples/V1/AnalyticsHubServiceClient/delete_subscription.php - * - * @param DeleteSubscriptionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSubscription(DeleteSubscriptionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteSubscription', $request, $callOptions)->wait(); - } - - /** - * Gets the details of a data exchange. - * - * The async variant is {@see self::getDataExchangeAsync()} . - * - * @example samples/V1/AnalyticsHubServiceClient/get_data_exchange.php - * - * @param GetDataExchangeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataExchange - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDataExchange(GetDataExchangeRequest $request, array $callOptions = []): DataExchange - { - return $this->startApiCall('GetDataExchange', $request, $callOptions)->wait(); - } - - /** - * Gets the IAM policy. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/AnalyticsHubServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets the details of a listing. - * - * The async variant is {@see self::getListingAsync()} . - * - * @example samples/V1/AnalyticsHubServiceClient/get_listing.php - * - * @param GetListingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Listing - * - * @throws ApiException Thrown if the API call fails. - */ - public function getListing(GetListingRequest $request, array $callOptions = []): Listing - { - return $this->startApiCall('GetListing', $request, $callOptions)->wait(); - } - - /** - * Gets the details of a Subscription. - * - * The async variant is {@see self::getSubscriptionAsync()} . - * - * @example samples/V1/AnalyticsHubServiceClient/get_subscription.php - * - * @param GetSubscriptionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Subscription - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSubscription(GetSubscriptionRequest $request, array $callOptions = []): Subscription - { - return $this->startApiCall('GetSubscription', $request, $callOptions)->wait(); - } - - /** - * Lists all data exchanges in a given project and location. - * - * The async variant is {@see self::listDataExchangesAsync()} . - * - * @example samples/V1/AnalyticsHubServiceClient/list_data_exchanges.php - * - * @param ListDataExchangesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDataExchanges(ListDataExchangesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDataExchanges', $request, $callOptions); - } - - /** - * Lists all listings in a given project and location. - * - * The async variant is {@see self::listListingsAsync()} . - * - * @example samples/V1/AnalyticsHubServiceClient/list_listings.php - * - * @param ListListingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listListings(ListListingsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListListings', $request, $callOptions); - } - - /** - * Lists all data exchanges from projects in a given organization and - * location. - * - * The async variant is {@see self::listOrgDataExchangesAsync()} . - * - * @example samples/V1/AnalyticsHubServiceClient/list_org_data_exchanges.php - * - * @param ListOrgDataExchangesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listOrgDataExchanges(ListOrgDataExchangesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListOrgDataExchanges', $request, $callOptions); - } - - /** - * Lists all subscriptions on a given Data Exchange or Listing. - * - * The async variant is {@see self::listSharedResourceSubscriptionsAsync()} . - * - * @example samples/V1/AnalyticsHubServiceClient/list_shared_resource_subscriptions.php - * - * @param ListSharedResourceSubscriptionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSharedResourceSubscriptions(ListSharedResourceSubscriptionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSharedResourceSubscriptions', $request, $callOptions); - } - - /** - * Lists all subscriptions in a given project and location. - * - * The async variant is {@see self::listSubscriptionsAsync()} . - * - * @example samples/V1/AnalyticsHubServiceClient/list_subscriptions.php - * - * @param ListSubscriptionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSubscriptions(ListSubscriptionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSubscriptions', $request, $callOptions); - } - - /** - * Refreshes a Subscription to a Data Exchange. A Data Exchange can become - * stale when a publisher adds or removes data. This is a long-running - * operation as it may create many linked datasets. - * - * The async variant is {@see self::refreshSubscriptionAsync()} . - * - * @example samples/V1/AnalyticsHubServiceClient/refresh_subscription.php - * - * @param RefreshSubscriptionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function refreshSubscription(RefreshSubscriptionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RefreshSubscription', $request, $callOptions)->wait(); - } - - /** - * Revokes a given subscription. - * - * The async variant is {@see self::revokeSubscriptionAsync()} . - * - * @example samples/V1/AnalyticsHubServiceClient/revoke_subscription.php - * - * @param RevokeSubscriptionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RevokeSubscriptionResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function revokeSubscription(RevokeSubscriptionRequest $request, array $callOptions = []): RevokeSubscriptionResponse - { - return $this->startApiCall('RevokeSubscription', $request, $callOptions)->wait(); - } - - /** - * Sets the IAM policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/AnalyticsHubServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Creates a Subscription to a Data Exchange. This is a long-running operation - * as it will create one or more linked datasets. - * - * The async variant is {@see self::subscribeDataExchangeAsync()} . - * - * @example samples/V1/AnalyticsHubServiceClient/subscribe_data_exchange.php - * - * @param SubscribeDataExchangeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function subscribeDataExchange(SubscribeDataExchangeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SubscribeDataExchange', $request, $callOptions)->wait(); - } - - /** - * Subscribes to a listing. - * - * Currently, with Analytics Hub, you can create listings that - * reference only BigQuery datasets. - * Upon subscription to a listing for a BigQuery dataset, Analytics Hub - * creates a linked dataset in the subscriber's project. - * - * The async variant is {@see self::subscribeListingAsync()} . - * - * @example samples/V1/AnalyticsHubServiceClient/subscribe_listing.php - * - * @param SubscribeListingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SubscribeListingResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function subscribeListing(SubscribeListingRequest $request, array $callOptions = []): SubscribeListingResponse - { - return $this->startApiCall('SubscribeListing', $request, $callOptions)->wait(); - } - - /** - * Returns the permissions that a caller has. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/AnalyticsHubServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Updates an existing data exchange. - * - * The async variant is {@see self::updateDataExchangeAsync()} . - * - * @example samples/V1/AnalyticsHubServiceClient/update_data_exchange.php - * - * @param UpdateDataExchangeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataExchange - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDataExchange(UpdateDataExchangeRequest $request, array $callOptions = []): DataExchange - { - return $this->startApiCall('UpdateDataExchange', $request, $callOptions)->wait(); - } - - /** - * Updates an existing listing. - * - * The async variant is {@see self::updateListingAsync()} . - * - * @example samples/V1/AnalyticsHubServiceClient/update_listing.php - * - * @param UpdateListingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Listing - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateListing(UpdateListingRequest $request, array $callOptions = []): Listing - { - return $this->startApiCall('UpdateListing', $request, $callOptions)->wait(); - } -} diff --git a/BigQueryConnection/composer.json b/BigQueryConnection/composer.json index 16cbeb17fc31..e3494de4f6f0 100644 --- a/BigQueryConnection/composer.json +++ b/BigQueryConnection/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/BigQueryConnection/src/V1/Client/BaseClient/ConnectionServiceBaseClient.php b/BigQueryConnection/src/V1/Client/BaseClient/ConnectionServiceBaseClient.php deleted file mode 100644 index 60b911676340..000000000000 --- a/BigQueryConnection/src/V1/Client/BaseClient/ConnectionServiceBaseClient.php +++ /dev/null @@ -1,492 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/connection_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/connection_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/connection_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/connection_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a cluster - * resource. - * - * @param string $project - * @param string $region - * @param string $cluster - * - * @return string The formatted cluster resource. - */ - public static function clusterName(string $project, string $region, string $cluster): string - { - return self::getPathTemplate('cluster')->render([ - 'project' => $project, - 'region' => $region, - 'cluster' => $cluster, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a connection - * resource. - * - * @param string $project - * @param string $location - * @param string $connection - * - * @return string The formatted connection resource. - */ - public static function connectionName(string $project, string $location, string $connection): string - { - return self::getPathTemplate('connection')->render([ - 'project' => $project, - 'location' => $location, - 'connection' => $connection, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a service - * resource. - * - * @param string $project - * @param string $location - * @param string $service - * - * @return string The formatted service resource. - */ - public static function serviceName(string $project, string $location, string $service): string - { - return self::getPathTemplate('service')->render([ - 'project' => $project, - 'location' => $location, - 'service' => $service, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - cluster: projects/{project}/regions/{region}/clusters/{cluster} - * - connection: projects/{project}/locations/{location}/connections/{connection} - * - location: projects/{project}/locations/{location} - * - service: projects/{project}/locations/{location}/services/{service} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'bigqueryconnection.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new connection. - * - * The async variant is {@see self::createConnectionAsync()} . - * - * @param CreateConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Connection - * - * @throws ApiException Thrown if the API call fails. - */ - public function createConnection(CreateConnectionRequest $request, array $callOptions = []): Connection - { - return $this->startApiCall('CreateConnection', $request, $callOptions)->wait(); - } - - /** - * Deletes connection and associated credential. - * - * The async variant is {@see self::deleteConnectionAsync()} . - * - * @param DeleteConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteConnection(DeleteConnectionRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteConnection', $request, $callOptions)->wait(); - } - - /** - * Returns specified connection. - * - * The async variant is {@see self::getConnectionAsync()} . - * - * @param GetConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Connection - * - * @throws ApiException Thrown if the API call fails. - */ - public function getConnection(GetConnectionRequest $request, array $callOptions = []): Connection - { - return $this->startApiCall('GetConnection', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. - * Returns an empty policy if the resource exists and does not have a policy - * set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns a list of connections in the given project. - * - * The async variant is {@see self::listConnectionsAsync()} . - * - * @param ListConnectionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listConnections(ListConnectionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListConnections', $request, $callOptions); - } - - /** - * Sets the access control policy on the specified resource. Replaces any - * existing policy. - * - * Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. - * If the resource does not exist, this will return an empty set of - * permissions, not a `NOT_FOUND` error. - * - * Note: This operation is designed to be used for building permission-aware - * UIs and command-line tools, not for authorization checking. This operation - * may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Updates the specified connection. For security reasons, also resets - * credential if connection properties are in the update field mask. - * - * The async variant is {@see self::updateConnectionAsync()} . - * - * @param UpdateConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Connection - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateConnection(UpdateConnectionRequest $request, array $callOptions = []): Connection - { - return $this->startApiCall('UpdateConnection', $request, $callOptions)->wait(); - } -} diff --git a/BigQueryConnection/src/V1/Client/ConnectionServiceClient.php b/BigQueryConnection/src/V1/Client/ConnectionServiceClient.php index 421e9eaf8556..767c121c522c 100644 --- a/BigQueryConnection/src/V1/Client/ConnectionServiceClient.php +++ b/BigQueryConnection/src/V1/Client/ConnectionServiceClient.php @@ -24,17 +24,467 @@ namespace Google\Cloud\BigQuery\Connection\V1\Client; -use Google\Cloud\BigQuery\Connection\V1\Client\BaseClient\ConnectionServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\BigQuery\Connection\V1\Connection; +use Google\Cloud\BigQuery\Connection\V1\CreateConnectionRequest; +use Google\Cloud\BigQuery\Connection\V1\DeleteConnectionRequest; +use Google\Cloud\BigQuery\Connection\V1\GetConnectionRequest; +use Google\Cloud\BigQuery\Connection\V1\ListConnectionsRequest; +use Google\Cloud\BigQuery\Connection\V1\UpdateConnectionRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Manages external data source connections and credentials. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\BigQuery\Connection\V1\ConnectionServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createConnectionAsync(CreateConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteConnectionAsync(DeleteConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getConnectionAsync(GetConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listConnectionsAsync(ListConnectionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateConnectionAsync(UpdateConnectionRequest $request, array $optionalArgs = []) */ -final class ConnectionServiceClient extends ConnectionServiceBaseClient +final class ConnectionServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ConnectionServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.bigquery.connection.v1.ConnectionService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'bigqueryconnection.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/bigquery', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/connection_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/connection_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/connection_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/connection_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a cluster + * resource. + * + * @param string $project + * @param string $region + * @param string $cluster + * + * @return string The formatted cluster resource. + */ + public static function clusterName(string $project, string $region, string $cluster): string + { + return self::getPathTemplate('cluster')->render([ + 'project' => $project, + 'region' => $region, + 'cluster' => $cluster, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a connection + * resource. + * + * @param string $project + * @param string $location + * @param string $connection + * + * @return string The formatted connection resource. + */ + public static function connectionName(string $project, string $location, string $connection): string + { + return self::getPathTemplate('connection')->render([ + 'project' => $project, + 'location' => $location, + 'connection' => $connection, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a service + * resource. + * + * @param string $project + * @param string $location + * @param string $service + * + * @return string The formatted service resource. + */ + public static function serviceName(string $project, string $location, string $service): string + { + return self::getPathTemplate('service')->render([ + 'project' => $project, + 'location' => $location, + 'service' => $service, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - cluster: projects/{project}/regions/{region}/clusters/{cluster} + * - connection: projects/{project}/locations/{location}/connections/{connection} + * - location: projects/{project}/locations/{location} + * - service: projects/{project}/locations/{location}/services/{service} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'bigqueryconnection.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new connection. + * + * The async variant is {@see ConnectionServiceClient::createConnectionAsync()} . + * + * @param CreateConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Connection + * + * @throws ApiException Thrown if the API call fails. + */ + public function createConnection(CreateConnectionRequest $request, array $callOptions = []): Connection + { + return $this->startApiCall('CreateConnection', $request, $callOptions)->wait(); + } + + /** + * Deletes connection and associated credential. + * + * The async variant is {@see ConnectionServiceClient::deleteConnectionAsync()} . + * + * @param DeleteConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteConnection(DeleteConnectionRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteConnection', $request, $callOptions)->wait(); + } + + /** + * Returns specified connection. + * + * The async variant is {@see ConnectionServiceClient::getConnectionAsync()} . + * + * @param GetConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Connection + * + * @throws ApiException Thrown if the API call fails. + */ + public function getConnection(GetConnectionRequest $request, array $callOptions = []): Connection + { + return $this->startApiCall('GetConnection', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. + * Returns an empty policy if the resource exists and does not have a policy + * set. + * + * The async variant is {@see ConnectionServiceClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns a list of connections in the given project. + * + * The async variant is {@see ConnectionServiceClient::listConnectionsAsync()} . + * + * @param ListConnectionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listConnections(ListConnectionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListConnections', $request, $callOptions); + } + + /** + * Sets the access control policy on the specified resource. Replaces any + * existing policy. + * + * Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + * + * The async variant is {@see ConnectionServiceClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. + * If the resource does not exist, this will return an empty set of + * permissions, not a `NOT_FOUND` error. + * + * Note: This operation is designed to be used for building permission-aware + * UIs and command-line tools, not for authorization checking. This operation + * may "fail open" without warning. + * + * The async variant is {@see ConnectionServiceClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates the specified connection. For security reasons, also resets + * credential if connection properties are in the update field mask. + * + * The async variant is {@see ConnectionServiceClient::updateConnectionAsync()} . + * + * @param UpdateConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Connection + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateConnection(UpdateConnectionRequest $request, array $callOptions = []): Connection + { + return $this->startApiCall('UpdateConnection', $request, $callOptions)->wait(); + } } diff --git a/BigQueryDataExchange/composer.json b/BigQueryDataExchange/composer.json index 07204c3136de..430d9ee26bc8 100644 --- a/BigQueryDataExchange/composer.json +++ b/BigQueryDataExchange/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/BigQueryDataExchange/src/V1beta1/Client/AnalyticsHubServiceClient.php b/BigQueryDataExchange/src/V1beta1/Client/AnalyticsHubServiceClient.php index c083caaae50b..1f667069dd04 100644 --- a/BigQueryDataExchange/src/V1beta1/Client/AnalyticsHubServiceClient.php +++ b/BigQueryDataExchange/src/V1beta1/Client/AnalyticsHubServiceClient.php @@ -26,17 +26,785 @@ namespace Google\Cloud\BigQuery\DataExchange\V1beta1\Client; -use Google\Cloud\BigQuery\DataExchange\V1beta1\Client\BaseClient\AnalyticsHubServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\BigQuery\DataExchange\V1beta1\CreateDataExchangeRequest; +use Google\Cloud\BigQuery\DataExchange\V1beta1\CreateListingRequest; +use Google\Cloud\BigQuery\DataExchange\V1beta1\DataExchange; +use Google\Cloud\BigQuery\DataExchange\V1beta1\DeleteDataExchangeRequest; +use Google\Cloud\BigQuery\DataExchange\V1beta1\DeleteListingRequest; +use Google\Cloud\BigQuery\DataExchange\V1beta1\GetDataExchangeRequest; +use Google\Cloud\BigQuery\DataExchange\V1beta1\GetListingRequest; +use Google\Cloud\BigQuery\DataExchange\V1beta1\ListDataExchangesRequest; +use Google\Cloud\BigQuery\DataExchange\V1beta1\ListListingsRequest; +use Google\Cloud\BigQuery\DataExchange\V1beta1\ListOrgDataExchangesRequest; +use Google\Cloud\BigQuery\DataExchange\V1beta1\Listing; +use Google\Cloud\BigQuery\DataExchange\V1beta1\SubscribeListingRequest; +use Google\Cloud\BigQuery\DataExchange\V1beta1\SubscribeListingResponse; +use Google\Cloud\BigQuery\DataExchange\V1beta1\UpdateDataExchangeRequest; +use Google\Cloud\BigQuery\DataExchange\V1beta1\UpdateListingRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The `AnalyticsHubService` API facilitates data sharing within and across + * organizations. It allows data providers to publish listings that reference + * shared datasets. With Analytics Hub, users can discover and search for + * listings that they have access to. Subscribers can view and subscribe to + * listings. When you subscribe to a listing, Analytics Hub creates a linked + * dataset in your project. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createDataExchangeAsync(CreateDataExchangeRequest $request, array $optionalArgs = []) + * @method PromiseInterface createListingAsync(CreateListingRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDataExchangeAsync(DeleteDataExchangeRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteListingAsync(DeleteListingRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDataExchangeAsync(GetDataExchangeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getListingAsync(GetListingRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDataExchangesAsync(ListDataExchangesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listListingsAsync(ListListingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listOrgDataExchangesAsync(ListOrgDataExchangesRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface subscribeListingAsync(SubscribeListingRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDataExchangeAsync(UpdateDataExchangeRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateListingAsync(UpdateListingRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class AnalyticsHubServiceClient extends AnalyticsHubServiceBaseClient +final class AnalyticsHubServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AnalyticsHubServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'analyticshub.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/bigquery', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/analytics_hub_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/analytics_hub_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/analytics_hub_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/analytics_hub_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * data_exchange resource. + * + * @param string $project + * @param string $location + * @param string $dataExchange + * + * @return string The formatted data_exchange resource. + * + * @experimental + */ + public static function dataExchangeName(string $project, string $location, string $dataExchange): string + { + return self::getPathTemplate('dataExchange')->render([ + 'project' => $project, + 'location' => $location, + 'data_exchange' => $dataExchange, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a dataset + * resource. + * + * @param string $project + * @param string $dataset + * + * @return string The formatted dataset resource. + * + * @experimental + */ + public static function datasetName(string $project, string $dataset): string + { + return self::getPathTemplate('dataset')->render([ + 'project' => $project, + 'dataset' => $dataset, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a listing + * resource. + * + * @param string $project + * @param string $location + * @param string $dataExchange + * @param string $listing + * + * @return string The formatted listing resource. + * + * @experimental + */ + public static function listingName(string $project, string $location, string $dataExchange, string $listing): string + { + return self::getPathTemplate('listing')->render([ + 'project' => $project, + 'location' => $location, + 'data_exchange' => $dataExchange, + 'listing' => $listing, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + * + * @experimental + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - dataExchange: projects/{project}/locations/{location}/dataExchanges/{data_exchange} + * - dataset: projects/{project}/datasets/{dataset} + * - listing: projects/{project}/locations/{location}/dataExchanges/{data_exchange}/listings/{listing} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'analyticshub.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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new data exchange. + * + * The async variant is {@see AnalyticsHubServiceClient::createDataExchangeAsync()} + * . + * + * @example samples/V1beta1/AnalyticsHubServiceClient/create_data_exchange.php + * + * @param CreateDataExchangeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataExchange + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createDataExchange(CreateDataExchangeRequest $request, array $callOptions = []): DataExchange + { + return $this->startApiCall('CreateDataExchange', $request, $callOptions)->wait(); + } + + /** + * Creates a new listing. + * + * The async variant is {@see AnalyticsHubServiceClient::createListingAsync()} . + * + * @example samples/V1beta1/AnalyticsHubServiceClient/create_listing.php + * + * @param CreateListingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Listing + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createListing(CreateListingRequest $request, array $callOptions = []): Listing + { + return $this->startApiCall('CreateListing', $request, $callOptions)->wait(); + } + + /** + * Deletes an existing data exchange. + * + * The async variant is {@see AnalyticsHubServiceClient::deleteDataExchangeAsync()} + * . + * + * @example samples/V1beta1/AnalyticsHubServiceClient/delete_data_exchange.php + * + * @param DeleteDataExchangeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteDataExchange(DeleteDataExchangeRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteDataExchange', $request, $callOptions)->wait(); + } + + /** + * Deletes a listing. + * + * The async variant is {@see AnalyticsHubServiceClient::deleteListingAsync()} . + * + * @example samples/V1beta1/AnalyticsHubServiceClient/delete_listing.php + * + * @param DeleteListingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteListing(DeleteListingRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteListing', $request, $callOptions)->wait(); + } + + /** + * Gets the details of a data exchange. + * + * The async variant is {@see AnalyticsHubServiceClient::getDataExchangeAsync()} . + * + * @example samples/V1beta1/AnalyticsHubServiceClient/get_data_exchange.php + * + * @param GetDataExchangeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataExchange + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getDataExchange(GetDataExchangeRequest $request, array $callOptions = []): DataExchange + { + return $this->startApiCall('GetDataExchange', $request, $callOptions)->wait(); + } + + /** + * Gets the IAM policy. + * + * The async variant is {@see AnalyticsHubServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1beta1/AnalyticsHubServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets the details of a listing. + * + * The async variant is {@see AnalyticsHubServiceClient::getListingAsync()} . + * + * @example samples/V1beta1/AnalyticsHubServiceClient/get_listing.php + * + * @param GetListingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Listing + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getListing(GetListingRequest $request, array $callOptions = []): Listing + { + return $this->startApiCall('GetListing', $request, $callOptions)->wait(); + } + + /** + * Lists all data exchanges in a given project and location. + * + * The async variant is {@see AnalyticsHubServiceClient::listDataExchangesAsync()} + * . + * + * @example samples/V1beta1/AnalyticsHubServiceClient/list_data_exchanges.php + * + * @param ListDataExchangesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listDataExchanges(ListDataExchangesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDataExchanges', $request, $callOptions); + } + + /** + * Lists all listings in a given project and location. + * + * The async variant is {@see AnalyticsHubServiceClient::listListingsAsync()} . + * + * @example samples/V1beta1/AnalyticsHubServiceClient/list_listings.php + * + * @param ListListingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listListings(ListListingsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListListings', $request, $callOptions); + } + + /** + * Lists all data exchanges from projects in a given organization and + * location. + * + * The async variant is + * {@see AnalyticsHubServiceClient::listOrgDataExchangesAsync()} . + * + * @example samples/V1beta1/AnalyticsHubServiceClient/list_org_data_exchanges.php + * + * @param ListOrgDataExchangesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listOrgDataExchanges(ListOrgDataExchangesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListOrgDataExchanges', $request, $callOptions); + } + + /** + * Sets the IAM policy. + * + * The async variant is {@see AnalyticsHubServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1beta1/AnalyticsHubServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Subscribes to a listing. + * + * Currently, with Analytics Hub, you can create listings that + * reference only BigQuery datasets. + * Upon subscription to a listing for a BigQuery dataset, Analytics Hub + * creates a linked dataset in the subscriber's project. + * + * The async variant is {@see AnalyticsHubServiceClient::subscribeListingAsync()} . + * + * @example samples/V1beta1/AnalyticsHubServiceClient/subscribe_listing.php + * + * @param SubscribeListingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SubscribeListingResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function subscribeListing(SubscribeListingRequest $request, array $callOptions = []): SubscribeListingResponse + { + return $this->startApiCall('SubscribeListing', $request, $callOptions)->wait(); + } + + /** + * Returns the permissions that a caller has. + * + * The async variant is {@see AnalyticsHubServiceClient::testIamPermissionsAsync()} + * . + * + * @example samples/V1beta1/AnalyticsHubServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates an existing data exchange. + * + * The async variant is {@see AnalyticsHubServiceClient::updateDataExchangeAsync()} + * . + * + * @example samples/V1beta1/AnalyticsHubServiceClient/update_data_exchange.php + * + * @param UpdateDataExchangeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataExchange + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function updateDataExchange(UpdateDataExchangeRequest $request, array $callOptions = []): DataExchange + { + return $this->startApiCall('UpdateDataExchange', $request, $callOptions)->wait(); + } + + /** + * Updates an existing listing. + * + * The async variant is {@see AnalyticsHubServiceClient::updateListingAsync()} . + * + * @example samples/V1beta1/AnalyticsHubServiceClient/update_listing.php + * + * @param UpdateListingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Listing + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function updateListing(UpdateListingRequest $request, array $callOptions = []): Listing + { + return $this->startApiCall('UpdateListing', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see AnalyticsHubServiceClient::getLocationAsync()} . + * + * @example samples/V1beta1/AnalyticsHubServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see AnalyticsHubServiceClient::listLocationsAsync()} . + * + * @example samples/V1beta1/AnalyticsHubServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/BigQueryDataExchange/src/V1beta1/Client/BaseClient/AnalyticsHubServiceBaseClient.php b/BigQueryDataExchange/src/V1beta1/Client/BaseClient/AnalyticsHubServiceBaseClient.php deleted file mode 100644 index 5e3b3d05b18d..000000000000 --- a/BigQueryDataExchange/src/V1beta1/Client/BaseClient/AnalyticsHubServiceBaseClient.php +++ /dev/null @@ -1,806 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/analytics_hub_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/analytics_hub_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/analytics_hub_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/analytics_hub_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * data_exchange resource. - * - * @param string $project - * @param string $location - * @param string $dataExchange - * - * @return string The formatted data_exchange resource. - * - * @experimental - */ - public static function dataExchangeName(string $project, string $location, string $dataExchange): string - { - return self::getPathTemplate('dataExchange')->render([ - 'project' => $project, - 'location' => $location, - 'data_exchange' => $dataExchange, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a dataset - * resource. - * - * @param string $project - * @param string $dataset - * - * @return string The formatted dataset resource. - * - * @experimental - */ - public static function datasetName(string $project, string $dataset): string - { - return self::getPathTemplate('dataset')->render([ - 'project' => $project, - 'dataset' => $dataset, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a listing - * resource. - * - * @param string $project - * @param string $location - * @param string $dataExchange - * @param string $listing - * - * @return string The formatted listing resource. - * - * @experimental - */ - public static function listingName(string $project, string $location, string $dataExchange, string $listing): string - { - return self::getPathTemplate('listing')->render([ - 'project' => $project, - 'location' => $location, - 'data_exchange' => $dataExchange, - 'listing' => $listing, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - * - * @experimental - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - dataExchange: projects/{project}/locations/{location}/dataExchanges/{data_exchange} - * - dataset: projects/{project}/datasets/{dataset} - * - listing: projects/{project}/locations/{location}/dataExchanges/{data_exchange}/listings/{listing} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'analyticshub.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); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new data exchange. - * - * The async variant is {@see self::createDataExchangeAsync()} . - * - * @example samples/V1beta1/AnalyticsHubServiceClient/create_data_exchange.php - * - * @param CreateDataExchangeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataExchange - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createDataExchange(CreateDataExchangeRequest $request, array $callOptions = []): DataExchange - { - return $this->startApiCall('CreateDataExchange', $request, $callOptions)->wait(); - } - - /** - * Creates a new listing. - * - * The async variant is {@see self::createListingAsync()} . - * - * @example samples/V1beta1/AnalyticsHubServiceClient/create_listing.php - * - * @param CreateListingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Listing - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createListing(CreateListingRequest $request, array $callOptions = []): Listing - { - return $this->startApiCall('CreateListing', $request, $callOptions)->wait(); - } - - /** - * Deletes an existing data exchange. - * - * The async variant is {@see self::deleteDataExchangeAsync()} . - * - * @example samples/V1beta1/AnalyticsHubServiceClient/delete_data_exchange.php - * - * @param DeleteDataExchangeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteDataExchange(DeleteDataExchangeRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteDataExchange', $request, $callOptions)->wait(); - } - - /** - * Deletes a listing. - * - * The async variant is {@see self::deleteListingAsync()} . - * - * @example samples/V1beta1/AnalyticsHubServiceClient/delete_listing.php - * - * @param DeleteListingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteListing(DeleteListingRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteListing', $request, $callOptions)->wait(); - } - - /** - * Gets the details of a data exchange. - * - * The async variant is {@see self::getDataExchangeAsync()} . - * - * @example samples/V1beta1/AnalyticsHubServiceClient/get_data_exchange.php - * - * @param GetDataExchangeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataExchange - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getDataExchange(GetDataExchangeRequest $request, array $callOptions = []): DataExchange - { - return $this->startApiCall('GetDataExchange', $request, $callOptions)->wait(); - } - - /** - * Gets the IAM policy. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1beta1/AnalyticsHubServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets the details of a listing. - * - * The async variant is {@see self::getListingAsync()} . - * - * @example samples/V1beta1/AnalyticsHubServiceClient/get_listing.php - * - * @param GetListingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Listing - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getListing(GetListingRequest $request, array $callOptions = []): Listing - { - return $this->startApiCall('GetListing', $request, $callOptions)->wait(); - } - - /** - * Lists all data exchanges in a given project and location. - * - * The async variant is {@see self::listDataExchangesAsync()} . - * - * @example samples/V1beta1/AnalyticsHubServiceClient/list_data_exchanges.php - * - * @param ListDataExchangesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listDataExchanges(ListDataExchangesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDataExchanges', $request, $callOptions); - } - - /** - * Lists all listings in a given project and location. - * - * The async variant is {@see self::listListingsAsync()} . - * - * @example samples/V1beta1/AnalyticsHubServiceClient/list_listings.php - * - * @param ListListingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listListings(ListListingsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListListings', $request, $callOptions); - } - - /** - * Lists all data exchanges from projects in a given organization and - * location. - * - * The async variant is {@see self::listOrgDataExchangesAsync()} . - * - * @example samples/V1beta1/AnalyticsHubServiceClient/list_org_data_exchanges.php - * - * @param ListOrgDataExchangesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listOrgDataExchanges(ListOrgDataExchangesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListOrgDataExchanges', $request, $callOptions); - } - - /** - * Sets the IAM policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1beta1/AnalyticsHubServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Subscribes to a listing. - * - * Currently, with Analytics Hub, you can create listings that - * reference only BigQuery datasets. - * Upon subscription to a listing for a BigQuery dataset, Analytics Hub - * creates a linked dataset in the subscriber's project. - * - * The async variant is {@see self::subscribeListingAsync()} . - * - * @example samples/V1beta1/AnalyticsHubServiceClient/subscribe_listing.php - * - * @param SubscribeListingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SubscribeListingResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function subscribeListing(SubscribeListingRequest $request, array $callOptions = []): SubscribeListingResponse - { - return $this->startApiCall('SubscribeListing', $request, $callOptions)->wait(); - } - - /** - * Returns the permissions that a caller has. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1beta1/AnalyticsHubServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Updates an existing data exchange. - * - * The async variant is {@see self::updateDataExchangeAsync()} . - * - * @example samples/V1beta1/AnalyticsHubServiceClient/update_data_exchange.php - * - * @param UpdateDataExchangeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataExchange - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function updateDataExchange(UpdateDataExchangeRequest $request, array $callOptions = []): DataExchange - { - return $this->startApiCall('UpdateDataExchange', $request, $callOptions)->wait(); - } - - /** - * Updates an existing listing. - * - * The async variant is {@see self::updateListingAsync()} . - * - * @example samples/V1beta1/AnalyticsHubServiceClient/update_listing.php - * - * @param UpdateListingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Listing - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function updateListing(UpdateListingRequest $request, array $callOptions = []): Listing - { - return $this->startApiCall('UpdateListing', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1beta1/AnalyticsHubServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1beta1/AnalyticsHubServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/BigQueryDataPolicies/composer.json b/BigQueryDataPolicies/composer.json index abf12a9d26ca..b0dce8d8744d 100644 --- a/BigQueryDataPolicies/composer.json +++ b/BigQueryDataPolicies/composer.json @@ -19,7 +19,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/BigQueryDataPolicies/src/V1/Client/BaseClient/DataPolicyServiceBaseClient.php b/BigQueryDataPolicies/src/V1/Client/BaseClient/DataPolicyServiceBaseClient.php deleted file mode 100644 index 4aebb9f785ab..000000000000 --- a/BigQueryDataPolicies/src/V1/Client/BaseClient/DataPolicyServiceBaseClient.php +++ /dev/null @@ -1,486 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/data_policy_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/data_policy_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/data_policy_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/data_policy_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a data_policy - * resource. - * - * @param string $project - * @param string $location - * @param string $dataPolicy - * - * @return string The formatted data_policy resource. - */ - public static function dataPolicyName(string $project, string $location, string $dataPolicy): string - { - return self::getPathTemplate('dataPolicy')->render([ - 'project' => $project, - 'location' => $location, - 'data_policy' => $dataPolicy, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - dataPolicy: projects/{project}/locations/{location}/dataPolicies/{data_policy} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'bigquerydatapolicy.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new data policy under a project with the given `dataPolicyId` - * (used as the display name), policy tag, and data policy type. - * - * The async variant is {@see self::createDataPolicyAsync()} . - * - * @example samples/V1/DataPolicyServiceClient/create_data_policy.php - * - * @param CreateDataPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataPolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDataPolicy(CreateDataPolicyRequest $request, array $callOptions = []): DataPolicy - { - return $this->startApiCall('CreateDataPolicy', $request, $callOptions)->wait(); - } - - /** - * Deletes the data policy specified by its resource name. - * - * The async variant is {@see self::deleteDataPolicyAsync()} . - * - * @example samples/V1/DataPolicyServiceClient/delete_data_policy.php - * - * @param DeleteDataPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDataPolicy(DeleteDataPolicyRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteDataPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets the data policy specified by its resource name. - * - * The async variant is {@see self::getDataPolicyAsync()} . - * - * @example samples/V1/DataPolicyServiceClient/get_data_policy.php - * - * @param GetDataPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataPolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDataPolicy(GetDataPolicyRequest $request, array $callOptions = []): DataPolicy - { - return $this->startApiCall('GetDataPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets the IAM policy for the specified data policy. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/DataPolicyServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * List all of the data policies in the specified parent project. - * - * The async variant is {@see self::listDataPoliciesAsync()} . - * - * @example samples/V1/DataPolicyServiceClient/list_data_policies.php - * - * @param ListDataPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDataPolicies(ListDataPoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDataPolicies', $request, $callOptions); - } - - /** - * Renames the id (display name) of the specified data policy. - * - * The async variant is {@see self::renameDataPolicyAsync()} . - * - * @example samples/V1/DataPolicyServiceClient/rename_data_policy.php - * - * @param RenameDataPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataPolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function renameDataPolicy(RenameDataPolicyRequest $request, array $callOptions = []): DataPolicy - { - return $this->startApiCall('RenameDataPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the IAM policy for the specified data policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/DataPolicyServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns the caller's permission on the specified data policy resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/DataPolicyServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Updates the metadata for an existing data policy. The target data policy - * can be specified by the resource name. - * - * The async variant is {@see self::updateDataPolicyAsync()} . - * - * @example samples/V1/DataPolicyServiceClient/update_data_policy.php - * - * @param UpdateDataPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataPolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDataPolicy(UpdateDataPolicyRequest $request, array $callOptions = []): DataPolicy - { - return $this->startApiCall('UpdateDataPolicy', $request, $callOptions)->wait(); - } -} diff --git a/BigQueryDataPolicies/src/V1/Client/DataPolicyServiceClient.php b/BigQueryDataPolicies/src/V1/Client/DataPolicyServiceClient.php index 33623d714fe4..f60182adf4ae 100644 --- a/BigQueryDataPolicies/src/V1/Client/DataPolicyServiceClient.php +++ b/BigQueryDataPolicies/src/V1/Client/DataPolicyServiceClient.php @@ -24,17 +24,461 @@ namespace Google\Cloud\BigQuery\DataPolicies\V1\Client; -use Google\Cloud\BigQuery\DataPolicies\V1\Client\BaseClient\DataPolicyServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\BigQuery\DataPolicies\V1\CreateDataPolicyRequest; +use Google\Cloud\BigQuery\DataPolicies\V1\DataPolicy; +use Google\Cloud\BigQuery\DataPolicies\V1\DeleteDataPolicyRequest; +use Google\Cloud\BigQuery\DataPolicies\V1\GetDataPolicyRequest; +use Google\Cloud\BigQuery\DataPolicies\V1\ListDataPoliciesRequest; +use Google\Cloud\BigQuery\DataPolicies\V1\RenameDataPolicyRequest; +use Google\Cloud\BigQuery\DataPolicies\V1\UpdateDataPolicyRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Data Policy Service provides APIs for managing the label-policy bindings. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\BigQuery\DataPolicies\V1\DataPolicyServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createDataPolicyAsync(CreateDataPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDataPolicyAsync(DeleteDataPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDataPolicyAsync(GetDataPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDataPoliciesAsync(ListDataPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface renameDataPolicyAsync(RenameDataPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDataPolicyAsync(UpdateDataPolicyRequest $request, array $optionalArgs = []) */ -final class DataPolicyServiceClient extends DataPolicyServiceBaseClient +final class DataPolicyServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DataPolicyServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.bigquery.datapolicies.v1.DataPolicyService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'bigquerydatapolicy.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/bigquery', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/data_policy_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/data_policy_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/data_policy_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/data_policy_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a data_policy + * resource. + * + * @param string $project + * @param string $location + * @param string $dataPolicy + * + * @return string The formatted data_policy resource. + */ + public static function dataPolicyName(string $project, string $location, string $dataPolicy): string + { + return self::getPathTemplate('dataPolicy')->render([ + 'project' => $project, + 'location' => $location, + 'data_policy' => $dataPolicy, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - dataPolicy: projects/{project}/locations/{location}/dataPolicies/{data_policy} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'bigquerydatapolicy.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new data policy under a project with the given `dataPolicyId` + * (used as the display name), policy tag, and data policy type. + * + * The async variant is {@see DataPolicyServiceClient::createDataPolicyAsync()} . + * + * @example samples/V1/DataPolicyServiceClient/create_data_policy.php + * + * @param CreateDataPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDataPolicy(CreateDataPolicyRequest $request, array $callOptions = []): DataPolicy + { + return $this->startApiCall('CreateDataPolicy', $request, $callOptions)->wait(); + } + + /** + * Deletes the data policy specified by its resource name. + * + * The async variant is {@see DataPolicyServiceClient::deleteDataPolicyAsync()} . + * + * @example samples/V1/DataPolicyServiceClient/delete_data_policy.php + * + * @param DeleteDataPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDataPolicy(DeleteDataPolicyRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteDataPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets the data policy specified by its resource name. + * + * The async variant is {@see DataPolicyServiceClient::getDataPolicyAsync()} . + * + * @example samples/V1/DataPolicyServiceClient/get_data_policy.php + * + * @param GetDataPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDataPolicy(GetDataPolicyRequest $request, array $callOptions = []): DataPolicy + { + return $this->startApiCall('GetDataPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets the IAM policy for the specified data policy. + * + * The async variant is {@see DataPolicyServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/DataPolicyServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * List all of the data policies in the specified parent project. + * + * The async variant is {@see DataPolicyServiceClient::listDataPoliciesAsync()} . + * + * @example samples/V1/DataPolicyServiceClient/list_data_policies.php + * + * @param ListDataPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDataPolicies(ListDataPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDataPolicies', $request, $callOptions); + } + + /** + * Renames the id (display name) of the specified data policy. + * + * The async variant is {@see DataPolicyServiceClient::renameDataPolicyAsync()} . + * + * @example samples/V1/DataPolicyServiceClient/rename_data_policy.php + * + * @param RenameDataPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function renameDataPolicy(RenameDataPolicyRequest $request, array $callOptions = []): DataPolicy + { + return $this->startApiCall('RenameDataPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the IAM policy for the specified data policy. + * + * The async variant is {@see DataPolicyServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/DataPolicyServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns the caller's permission on the specified data policy resource. + * + * The async variant is {@see DataPolicyServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/DataPolicyServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates the metadata for an existing data policy. The target data policy + * can be specified by the resource name. + * + * The async variant is {@see DataPolicyServiceClient::updateDataPolicyAsync()} . + * + * @example samples/V1/DataPolicyServiceClient/update_data_policy.php + * + * @param UpdateDataPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDataPolicy(UpdateDataPolicyRequest $request, array $callOptions = []): DataPolicy + { + return $this->startApiCall('UpdateDataPolicy', $request, $callOptions)->wait(); + } } diff --git a/BigQueryDataTransfer/composer.json b/BigQueryDataTransfer/composer.json index c139831fe650..4093bb146669 100644 --- a/BigQueryDataTransfer/composer.json +++ b/BigQueryDataTransfer/composer.json @@ -19,11 +19,11 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", - "google/cloud-core": "^1.39" + "google/cloud-core": "^1.52.7" }, "suggest": { "ext-protobuf": "Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions." diff --git a/BigQueryDataTransfer/src/V1/Client/BaseClient/DataTransferServiceBaseClient.php b/BigQueryDataTransfer/src/V1/Client/BaseClient/DataTransferServiceBaseClient.php deleted file mode 100644 index fde6a2393ed1..000000000000 --- a/BigQueryDataTransfer/src/V1/Client/BaseClient/DataTransferServiceBaseClient.php +++ /dev/null @@ -1,863 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/data_transfer_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/data_transfer_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/data_transfer_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/data_transfer_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a data_source - * resource. - * - * @param string $project - * @param string $dataSource - * - * @return string The formatted data_source resource. - */ - public static function dataSourceName(string $project, string $dataSource): string - { - return self::getPathTemplate('dataSource')->render([ - 'project' => $project, - 'data_source' => $dataSource, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_data_source resource. - * - * @param string $project - * @param string $dataSource - * - * @return string The formatted project_data_source resource. - */ - public static function projectDataSourceName(string $project, string $dataSource): string - { - return self::getPathTemplate('projectDataSource')->render([ - 'project' => $project, - 'data_source' => $dataSource, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_source resource. - * - * @param string $project - * @param string $location - * @param string $dataSource - * - * @return string The formatted project_location_data_source resource. - */ - public static function projectLocationDataSourceName(string $project, string $location, string $dataSource): string - { - return self::getPathTemplate('projectLocationDataSource')->render([ - 'project' => $project, - 'location' => $location, - 'data_source' => $dataSource, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_transfer_config resource. - * - * @param string $project - * @param string $location - * @param string $transferConfig - * - * @return string The formatted project_location_transfer_config resource. - */ - public static function projectLocationTransferConfigName(string $project, string $location, string $transferConfig): string - { - return self::getPathTemplate('projectLocationTransferConfig')->render([ - 'project' => $project, - 'location' => $location, - 'transfer_config' => $transferConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_transfer_config_run resource. - * - * @param string $project - * @param string $location - * @param string $transferConfig - * @param string $run - * - * @return string The formatted project_location_transfer_config_run resource. - */ - public static function projectLocationTransferConfigRunName(string $project, string $location, string $transferConfig, string $run): string - { - return self::getPathTemplate('projectLocationTransferConfigRun')->render([ - 'project' => $project, - 'location' => $location, - 'transfer_config' => $transferConfig, - 'run' => $run, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_transfer_config resource. - * - * @param string $project - * @param string $transferConfig - * - * @return string The formatted project_transfer_config resource. - */ - public static function projectTransferConfigName(string $project, string $transferConfig): string - { - return self::getPathTemplate('projectTransferConfig')->render([ - 'project' => $project, - 'transfer_config' => $transferConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_transfer_config_run resource. - * - * @param string $project - * @param string $transferConfig - * @param string $run - * - * @return string The formatted project_transfer_config_run resource. - */ - public static function projectTransferConfigRunName(string $project, string $transferConfig, string $run): string - { - return self::getPathTemplate('projectTransferConfigRun')->render([ - 'project' => $project, - 'transfer_config' => $transferConfig, - 'run' => $run, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a run - * resource. - * - * @param string $project - * @param string $transferConfig - * @param string $run - * - * @return string The formatted run resource. - */ - public static function runName(string $project, string $transferConfig, string $run): string - { - return self::getPathTemplate('run')->render([ - 'project' => $project, - 'transfer_config' => $transferConfig, - 'run' => $run, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * transfer_config resource. - * - * @param string $project - * @param string $transferConfig - * - * @return string The formatted transfer_config resource. - */ - public static function transferConfigName(string $project, string $transferConfig): string - { - return self::getPathTemplate('transferConfig')->render([ - 'project' => $project, - 'transfer_config' => $transferConfig, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - dataSource: projects/{project}/dataSources/{data_source} - * - location: projects/{project}/locations/{location} - * - project: projects/{project} - * - projectDataSource: projects/{project}/dataSources/{data_source} - * - projectLocationDataSource: projects/{project}/locations/{location}/dataSources/{data_source} - * - projectLocationTransferConfig: projects/{project}/locations/{location}/transferConfigs/{transfer_config} - * - projectLocationTransferConfigRun: projects/{project}/locations/{location}/transferConfigs/{transfer_config}/runs/{run} - * - projectTransferConfig: projects/{project}/transferConfigs/{transfer_config} - * - projectTransferConfigRun: projects/{project}/transferConfigs/{transfer_config}/runs/{run} - * - run: projects/{project}/transferConfigs/{transfer_config}/runs/{run} - * - transferConfig: projects/{project}/transferConfigs/{transfer_config} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'bigquerydatatransfer.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Returns true if valid credentials exist for the given data source and - * requesting user. - * - * The async variant is {@see self::checkValidCredsAsync()} . - * - * @param CheckValidCredsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CheckValidCredsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function checkValidCreds(CheckValidCredsRequest $request, array $callOptions = []): CheckValidCredsResponse - { - return $this->startApiCall('CheckValidCreds', $request, $callOptions)->wait(); - } - - /** - * Creates a new data transfer configuration. - * - * The async variant is {@see self::createTransferConfigAsync()} . - * - * @param CreateTransferConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TransferConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTransferConfig(CreateTransferConfigRequest $request, array $callOptions = []): TransferConfig - { - return $this->startApiCall('CreateTransferConfig', $request, $callOptions)->wait(); - } - - /** - * Deletes a data transfer configuration, including any associated transfer - * runs and logs. - * - * The async variant is {@see self::deleteTransferConfigAsync()} . - * - * @param DeleteTransferConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTransferConfig(DeleteTransferConfigRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteTransferConfig', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified transfer run. - * - * The async variant is {@see self::deleteTransferRunAsync()} . - * - * @param DeleteTransferRunRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTransferRun(DeleteTransferRunRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteTransferRun', $request, $callOptions)->wait(); - } - - /** - * Enroll data sources in a user project. This allows users to create transfer - * configurations for these data sources. They will also appear in the - * ListDataSources RPC and as such, will appear in the - * [BigQuery UI](https://console.cloud.google.com/bigquery), and the documents - * can be found in the public guide for - * [BigQuery Web UI](https://cloud.google.com/bigquery/bigquery-web-ui) and - * [Data Transfer - * Service](https://cloud.google.com/bigquery/docs/working-with-transfers). - * - * The async variant is {@see self::enrollDataSourcesAsync()} . - * - * @param EnrollDataSourcesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function enrollDataSources(EnrollDataSourcesRequest $request, array $callOptions = []): void - { - $this->startApiCall('EnrollDataSources', $request, $callOptions)->wait(); - } - - /** - * Retrieves a supported data source and returns its settings. - * - * The async variant is {@see self::getDataSourceAsync()} . - * - * @param GetDataSourceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataSource - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDataSource(GetDataSourceRequest $request, array $callOptions = []): DataSource - { - return $this->startApiCall('GetDataSource', $request, $callOptions)->wait(); - } - - /** - * Returns information about a data transfer config. - * - * The async variant is {@see self::getTransferConfigAsync()} . - * - * @param GetTransferConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TransferConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTransferConfig(GetTransferConfigRequest $request, array $callOptions = []): TransferConfig - { - return $this->startApiCall('GetTransferConfig', $request, $callOptions)->wait(); - } - - /** - * Returns information about the particular transfer run. - * - * The async variant is {@see self::getTransferRunAsync()} . - * - * @param GetTransferRunRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TransferRun - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTransferRun(GetTransferRunRequest $request, array $callOptions = []): TransferRun - { - return $this->startApiCall('GetTransferRun', $request, $callOptions)->wait(); - } - - /** - * Lists supported data sources and returns their settings. - * - * The async variant is {@see self::listDataSourcesAsync()} . - * - * @param ListDataSourcesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDataSources(ListDataSourcesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDataSources', $request, $callOptions); - } - - /** - * Returns information about all transfer configs owned by a project in the - * specified location. - * - * The async variant is {@see self::listTransferConfigsAsync()} . - * - * @param ListTransferConfigsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTransferConfigs(ListTransferConfigsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTransferConfigs', $request, $callOptions); - } - - /** - * Returns log messages for the transfer run. - * - * The async variant is {@see self::listTransferLogsAsync()} . - * - * @param ListTransferLogsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTransferLogs(ListTransferLogsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTransferLogs', $request, $callOptions); - } - - /** - * Returns information about running and completed transfer runs. - * - * The async variant is {@see self::listTransferRunsAsync()} . - * - * @param ListTransferRunsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTransferRuns(ListTransferRunsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTransferRuns', $request, $callOptions); - } - - /** - * Creates transfer runs for a time range [start_time, end_time]. - * For each date - or whatever granularity the data source supports - in the - * range, one transfer run is created. - * Note that runs are created per UTC time in the time range. - * DEPRECATED: use StartManualTransferRuns instead. - * - * The async variant is {@see self::scheduleTransferRunsAsync()} . - * - * @param ScheduleTransferRunsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ScheduleTransferRunsResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @deprecated This method will be removed in the next major version update. - */ - public function scheduleTransferRuns(ScheduleTransferRunsRequest $request, array $callOptions = []): ScheduleTransferRunsResponse - { - return $this->startApiCall('ScheduleTransferRuns', $request, $callOptions)->wait(); - } - - /** - * Start manual transfer runs to be executed now with schedule_time equal to - * current time. The transfer runs can be created for a time range where the - * run_time is between start_time (inclusive) and end_time (exclusive), or for - * a specific run_time. - * - * The async variant is {@see self::startManualTransferRunsAsync()} . - * - * @param StartManualTransferRunsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 StartManualTransferRunsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function startManualTransferRuns(StartManualTransferRunsRequest $request, array $callOptions = []): StartManualTransferRunsResponse - { - return $this->startApiCall('StartManualTransferRuns', $request, $callOptions)->wait(); - } - - /** - * Updates a data transfer configuration. - * All fields must be set, even if they are not updated. - * - * The async variant is {@see self::updateTransferConfigAsync()} . - * - * @param UpdateTransferConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TransferConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateTransferConfig(UpdateTransferConfigRequest $request, array $callOptions = []): TransferConfig - { - return $this->startApiCall('UpdateTransferConfig', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/BigQueryDataTransfer/src/V1/Client/DataTransferServiceClient.php b/BigQueryDataTransfer/src/V1/Client/DataTransferServiceClient.php index a3bc4318efb0..e6e2b601b0e6 100644 --- a/BigQueryDataTransfer/src/V1/Client/DataTransferServiceClient.php +++ b/BigQueryDataTransfer/src/V1/Client/DataTransferServiceClient.php @@ -24,17 +24,847 @@ namespace Google\Cloud\BigQuery\DataTransfer\V1\Client; -use Google\Cloud\BigQuery\DataTransfer\V1\Client\BaseClient\DataTransferServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\BigQuery\DataTransfer\V1\CheckValidCredsRequest; +use Google\Cloud\BigQuery\DataTransfer\V1\CheckValidCredsResponse; +use Google\Cloud\BigQuery\DataTransfer\V1\CreateTransferConfigRequest; +use Google\Cloud\BigQuery\DataTransfer\V1\DataSource; +use Google\Cloud\BigQuery\DataTransfer\V1\DeleteTransferConfigRequest; +use Google\Cloud\BigQuery\DataTransfer\V1\DeleteTransferRunRequest; +use Google\Cloud\BigQuery\DataTransfer\V1\EnrollDataSourcesRequest; +use Google\Cloud\BigQuery\DataTransfer\V1\GetDataSourceRequest; +use Google\Cloud\BigQuery\DataTransfer\V1\GetTransferConfigRequest; +use Google\Cloud\BigQuery\DataTransfer\V1\GetTransferRunRequest; +use Google\Cloud\BigQuery\DataTransfer\V1\ListDataSourcesRequest; +use Google\Cloud\BigQuery\DataTransfer\V1\ListTransferConfigsRequest; +use Google\Cloud\BigQuery\DataTransfer\V1\ListTransferLogsRequest; +use Google\Cloud\BigQuery\DataTransfer\V1\ListTransferRunsRequest; +use Google\Cloud\BigQuery\DataTransfer\V1\ScheduleTransferRunsRequest; +use Google\Cloud\BigQuery\DataTransfer\V1\ScheduleTransferRunsResponse; +use Google\Cloud\BigQuery\DataTransfer\V1\StartManualTransferRunsRequest; +use Google\Cloud\BigQuery\DataTransfer\V1\StartManualTransferRunsResponse; +use Google\Cloud\BigQuery\DataTransfer\V1\TransferConfig; +use Google\Cloud\BigQuery\DataTransfer\V1\TransferRun; +use Google\Cloud\BigQuery\DataTransfer\V1\UpdateTransferConfigRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: This API allows users to manage their data transfers into BigQuery. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\BigQuery\DataTransfer\V1\DataTransferServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface checkValidCredsAsync(CheckValidCredsRequest $request, array $optionalArgs = []) + * @method PromiseInterface createTransferConfigAsync(CreateTransferConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTransferConfigAsync(DeleteTransferConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTransferRunAsync(DeleteTransferRunRequest $request, array $optionalArgs = []) + * @method PromiseInterface enrollDataSourcesAsync(EnrollDataSourcesRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDataSourceAsync(GetDataSourceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTransferConfigAsync(GetTransferConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTransferRunAsync(GetTransferRunRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDataSourcesAsync(ListDataSourcesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTransferConfigsAsync(ListTransferConfigsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTransferLogsAsync(ListTransferLogsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTransferRunsAsync(ListTransferRunsRequest $request, array $optionalArgs = []) + * @method PromiseInterface scheduleTransferRunsAsync(ScheduleTransferRunsRequest $request, array $optionalArgs = []) + * @method PromiseInterface startManualTransferRunsAsync(StartManualTransferRunsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateTransferConfigAsync(UpdateTransferConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class DataTransferServiceClient extends DataTransferServiceBaseClient +final class DataTransferServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DataTransferServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.bigquery.datatransfer.v1.DataTransferService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'bigquerydatatransfer.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/data_transfer_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/data_transfer_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/data_transfer_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/data_transfer_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a data_source + * resource. + * + * @param string $project + * @param string $dataSource + * + * @return string The formatted data_source resource. + */ + public static function dataSourceName(string $project, string $dataSource): string + { + return self::getPathTemplate('dataSource')->render([ + 'project' => $project, + 'data_source' => $dataSource, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_data_source resource. + * + * @param string $project + * @param string $dataSource + * + * @return string The formatted project_data_source resource. + */ + public static function projectDataSourceName(string $project, string $dataSource): string + { + return self::getPathTemplate('projectDataSource')->render([ + 'project' => $project, + 'data_source' => $dataSource, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_source resource. + * + * @param string $project + * @param string $location + * @param string $dataSource + * + * @return string The formatted project_location_data_source resource. + */ + public static function projectLocationDataSourceName(string $project, string $location, string $dataSource): string + { + return self::getPathTemplate('projectLocationDataSource')->render([ + 'project' => $project, + 'location' => $location, + 'data_source' => $dataSource, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_transfer_config resource. + * + * @param string $project + * @param string $location + * @param string $transferConfig + * + * @return string The formatted project_location_transfer_config resource. + */ + public static function projectLocationTransferConfigName(string $project, string $location, string $transferConfig): string + { + return self::getPathTemplate('projectLocationTransferConfig')->render([ + 'project' => $project, + 'location' => $location, + 'transfer_config' => $transferConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_transfer_config_run resource. + * + * @param string $project + * @param string $location + * @param string $transferConfig + * @param string $run + * + * @return string The formatted project_location_transfer_config_run resource. + */ + public static function projectLocationTransferConfigRunName(string $project, string $location, string $transferConfig, string $run): string + { + return self::getPathTemplate('projectLocationTransferConfigRun')->render([ + 'project' => $project, + 'location' => $location, + 'transfer_config' => $transferConfig, + 'run' => $run, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_transfer_config resource. + * + * @param string $project + * @param string $transferConfig + * + * @return string The formatted project_transfer_config resource. + */ + public static function projectTransferConfigName(string $project, string $transferConfig): string + { + return self::getPathTemplate('projectTransferConfig')->render([ + 'project' => $project, + 'transfer_config' => $transferConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_transfer_config_run resource. + * + * @param string $project + * @param string $transferConfig + * @param string $run + * + * @return string The formatted project_transfer_config_run resource. + */ + public static function projectTransferConfigRunName(string $project, string $transferConfig, string $run): string + { + return self::getPathTemplate('projectTransferConfigRun')->render([ + 'project' => $project, + 'transfer_config' => $transferConfig, + 'run' => $run, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a run + * resource. + * + * @param string $project + * @param string $transferConfig + * @param string $run + * + * @return string The formatted run resource. + */ + public static function runName(string $project, string $transferConfig, string $run): string + { + return self::getPathTemplate('run')->render([ + 'project' => $project, + 'transfer_config' => $transferConfig, + 'run' => $run, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * transfer_config resource. + * + * @param string $project + * @param string $transferConfig + * + * @return string The formatted transfer_config resource. + */ + public static function transferConfigName(string $project, string $transferConfig): string + { + return self::getPathTemplate('transferConfig')->render([ + 'project' => $project, + 'transfer_config' => $transferConfig, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - dataSource: projects/{project}/dataSources/{data_source} + * - location: projects/{project}/locations/{location} + * - project: projects/{project} + * - projectDataSource: projects/{project}/dataSources/{data_source} + * - projectLocationDataSource: projects/{project}/locations/{location}/dataSources/{data_source} + * - projectLocationTransferConfig: projects/{project}/locations/{location}/transferConfigs/{transfer_config} + * - projectLocationTransferConfigRun: projects/{project}/locations/{location}/transferConfigs/{transfer_config}/runs/{run} + * - projectTransferConfig: projects/{project}/transferConfigs/{transfer_config} + * - projectTransferConfigRun: projects/{project}/transferConfigs/{transfer_config}/runs/{run} + * - run: projects/{project}/transferConfigs/{transfer_config}/runs/{run} + * - transferConfig: projects/{project}/transferConfigs/{transfer_config} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'bigquerydatatransfer.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Returns true if valid credentials exist for the given data source and + * requesting user. + * + * The async variant is {@see DataTransferServiceClient::checkValidCredsAsync()} . + * + * @param CheckValidCredsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CheckValidCredsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function checkValidCreds(CheckValidCredsRequest $request, array $callOptions = []): CheckValidCredsResponse + { + return $this->startApiCall('CheckValidCreds', $request, $callOptions)->wait(); + } + + /** + * Creates a new data transfer configuration. + * + * The async variant is + * {@see DataTransferServiceClient::createTransferConfigAsync()} . + * + * @param CreateTransferConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TransferConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTransferConfig(CreateTransferConfigRequest $request, array $callOptions = []): TransferConfig + { + return $this->startApiCall('CreateTransferConfig', $request, $callOptions)->wait(); + } + + /** + * Deletes a data transfer configuration, including any associated transfer + * runs and logs. + * + * The async variant is + * {@see DataTransferServiceClient::deleteTransferConfigAsync()} . + * + * @param DeleteTransferConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTransferConfig(DeleteTransferConfigRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteTransferConfig', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified transfer run. + * + * The async variant is {@see DataTransferServiceClient::deleteTransferRunAsync()} + * . + * + * @param DeleteTransferRunRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTransferRun(DeleteTransferRunRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteTransferRun', $request, $callOptions)->wait(); + } + + /** + * Enroll data sources in a user project. This allows users to create transfer + * configurations for these data sources. They will also appear in the + * ListDataSources RPC and as such, will appear in the + * [BigQuery UI](https://console.cloud.google.com/bigquery), and the documents + * can be found in the public guide for + * [BigQuery Web UI](https://cloud.google.com/bigquery/bigquery-web-ui) and + * [Data Transfer + * Service](https://cloud.google.com/bigquery/docs/working-with-transfers). + * + * The async variant is {@see DataTransferServiceClient::enrollDataSourcesAsync()} + * . + * + * @param EnrollDataSourcesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function enrollDataSources(EnrollDataSourcesRequest $request, array $callOptions = []): void + { + $this->startApiCall('EnrollDataSources', $request, $callOptions)->wait(); + } + + /** + * Retrieves a supported data source and returns its settings. + * + * The async variant is {@see DataTransferServiceClient::getDataSourceAsync()} . + * + * @param GetDataSourceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataSource + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDataSource(GetDataSourceRequest $request, array $callOptions = []): DataSource + { + return $this->startApiCall('GetDataSource', $request, $callOptions)->wait(); + } + + /** + * Returns information about a data transfer config. + * + * The async variant is {@see DataTransferServiceClient::getTransferConfigAsync()} + * . + * + * @param GetTransferConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TransferConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTransferConfig(GetTransferConfigRequest $request, array $callOptions = []): TransferConfig + { + return $this->startApiCall('GetTransferConfig', $request, $callOptions)->wait(); + } + + /** + * Returns information about the particular transfer run. + * + * The async variant is {@see DataTransferServiceClient::getTransferRunAsync()} . + * + * @param GetTransferRunRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TransferRun + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTransferRun(GetTransferRunRequest $request, array $callOptions = []): TransferRun + { + return $this->startApiCall('GetTransferRun', $request, $callOptions)->wait(); + } + + /** + * Lists supported data sources and returns their settings. + * + * The async variant is {@see DataTransferServiceClient::listDataSourcesAsync()} . + * + * @param ListDataSourcesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDataSources(ListDataSourcesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDataSources', $request, $callOptions); + } + + /** + * Returns information about all transfer configs owned by a project in the + * specified location. + * + * The async variant is + * {@see DataTransferServiceClient::listTransferConfigsAsync()} . + * + * @param ListTransferConfigsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTransferConfigs(ListTransferConfigsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTransferConfigs', $request, $callOptions); + } + + /** + * Returns log messages for the transfer run. + * + * The async variant is {@see DataTransferServiceClient::listTransferLogsAsync()} . + * + * @param ListTransferLogsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTransferLogs(ListTransferLogsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTransferLogs', $request, $callOptions); + } + + /** + * Returns information about running and completed transfer runs. + * + * The async variant is {@see DataTransferServiceClient::listTransferRunsAsync()} . + * + * @param ListTransferRunsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTransferRuns(ListTransferRunsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTransferRuns', $request, $callOptions); + } + + /** + * Creates transfer runs for a time range [start_time, end_time]. + * For each date - or whatever granularity the data source supports - in the + * range, one transfer run is created. + * Note that runs are created per UTC time in the time range. + * DEPRECATED: use StartManualTransferRuns instead. + * + * The async variant is + * {@see DataTransferServiceClient::scheduleTransferRunsAsync()} . + * + * @param ScheduleTransferRunsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ScheduleTransferRunsResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @deprecated This method will be removed in the next major version update. + */ + public function scheduleTransferRuns(ScheduleTransferRunsRequest $request, array $callOptions = []): ScheduleTransferRunsResponse + { + return $this->startApiCall('ScheduleTransferRuns', $request, $callOptions)->wait(); + } + + /** + * Start manual transfer runs to be executed now with schedule_time equal to + * current time. The transfer runs can be created for a time range where the + * run_time is between start_time (inclusive) and end_time (exclusive), or for + * a specific run_time. + * + * The async variant is + * {@see DataTransferServiceClient::startManualTransferRunsAsync()} . + * + * @param StartManualTransferRunsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 StartManualTransferRunsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function startManualTransferRuns(StartManualTransferRunsRequest $request, array $callOptions = []): StartManualTransferRunsResponse + { + return $this->startApiCall('StartManualTransferRuns', $request, $callOptions)->wait(); + } + + /** + * Updates a data transfer configuration. + * All fields must be set, even if they are not updated. + * + * The async variant is + * {@see DataTransferServiceClient::updateTransferConfigAsync()} . + * + * @param UpdateTransferConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TransferConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTransferConfig(UpdateTransferConfigRequest $request, array $callOptions = []): TransferConfig + { + return $this->startApiCall('UpdateTransferConfig', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see DataTransferServiceClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see DataTransferServiceClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/BigQueryMigration/composer.json b/BigQueryMigration/composer.json index cbe3004f6118..2d64f623b7ce 100644 --- a/BigQueryMigration/composer.json +++ b/BigQueryMigration/composer.json @@ -19,7 +19,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/BigQueryMigration/src/V2/Client/BaseClient/MigrationServiceBaseClient.php b/BigQueryMigration/src/V2/Client/BaseClient/MigrationServiceBaseClient.php deleted file mode 100644 index 9984b0b30384..000000000000 --- a/BigQueryMigration/src/V2/Client/BaseClient/MigrationServiceBaseClient.php +++ /dev/null @@ -1,449 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/migration_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/migration_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/migration_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/migration_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * migration_subtask resource. - * - * @param string $project - * @param string $location - * @param string $workflow - * @param string $subtask - * - * @return string The formatted migration_subtask resource. - */ - public static function migrationSubtaskName(string $project, string $location, string $workflow, string $subtask): string - { - return self::getPathTemplate('migrationSubtask')->render([ - 'project' => $project, - 'location' => $location, - 'workflow' => $workflow, - 'subtask' => $subtask, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * migration_workflow resource. - * - * @param string $project - * @param string $location - * @param string $workflow - * - * @return string The formatted migration_workflow resource. - */ - public static function migrationWorkflowName(string $project, string $location, string $workflow): string - { - return self::getPathTemplate('migrationWorkflow')->render([ - 'project' => $project, - 'location' => $location, - 'workflow' => $workflow, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - location: projects/{project}/locations/{location} - * - migrationSubtask: projects/{project}/locations/{location}/workflows/{workflow}/subtasks/{subtask} - * - migrationWorkflow: projects/{project}/locations/{location}/workflows/{workflow} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'bigquerymigration.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a migration workflow. - * - * The async variant is {@see self::createMigrationWorkflowAsync()} . - * - * @example samples/V2/MigrationServiceClient/create_migration_workflow.php - * - * @param CreateMigrationWorkflowRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MigrationWorkflow - * - * @throws ApiException Thrown if the API call fails. - */ - public function createMigrationWorkflow(CreateMigrationWorkflowRequest $request, array $callOptions = []): MigrationWorkflow - { - return $this->startApiCall('CreateMigrationWorkflow', $request, $callOptions)->wait(); - } - - /** - * Deletes a migration workflow by name. - * - * The async variant is {@see self::deleteMigrationWorkflowAsync()} . - * - * @example samples/V2/MigrationServiceClient/delete_migration_workflow.php - * - * @param DeleteMigrationWorkflowRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteMigrationWorkflow(DeleteMigrationWorkflowRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteMigrationWorkflow', $request, $callOptions)->wait(); - } - - /** - * Gets a previously created migration subtask. - * - * The async variant is {@see self::getMigrationSubtaskAsync()} . - * - * @example samples/V2/MigrationServiceClient/get_migration_subtask.php - * - * @param GetMigrationSubtaskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MigrationSubtask - * - * @throws ApiException Thrown if the API call fails. - */ - public function getMigrationSubtask(GetMigrationSubtaskRequest $request, array $callOptions = []): MigrationSubtask - { - return $this->startApiCall('GetMigrationSubtask', $request, $callOptions)->wait(); - } - - /** - * Gets a previously created migration workflow. - * - * The async variant is {@see self::getMigrationWorkflowAsync()} . - * - * @example samples/V2/MigrationServiceClient/get_migration_workflow.php - * - * @param GetMigrationWorkflowRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MigrationWorkflow - * - * @throws ApiException Thrown if the API call fails. - */ - public function getMigrationWorkflow(GetMigrationWorkflowRequest $request, array $callOptions = []): MigrationWorkflow - { - return $this->startApiCall('GetMigrationWorkflow', $request, $callOptions)->wait(); - } - - /** - * Lists previously created migration subtasks. - * - * The async variant is {@see self::listMigrationSubtasksAsync()} . - * - * @example samples/V2/MigrationServiceClient/list_migration_subtasks.php - * - * @param ListMigrationSubtasksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listMigrationSubtasks(ListMigrationSubtasksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListMigrationSubtasks', $request, $callOptions); - } - - /** - * Lists previously created migration workflow. - * - * The async variant is {@see self::listMigrationWorkflowsAsync()} . - * - * @example samples/V2/MigrationServiceClient/list_migration_workflows.php - * - * @param ListMigrationWorkflowsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listMigrationWorkflows(ListMigrationWorkflowsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListMigrationWorkflows', $request, $callOptions); - } - - /** - * Starts a previously created migration workflow. I.e., the state transitions - * from DRAFT to RUNNING. This is a no-op if the state is already RUNNING. - * An error will be signaled if the state is anything other than DRAFT or - * RUNNING. - * - * The async variant is {@see self::startMigrationWorkflowAsync()} . - * - * @example samples/V2/MigrationServiceClient/start_migration_workflow.php - * - * @param StartMigrationWorkflowRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function startMigrationWorkflow(StartMigrationWorkflowRequest $request, array $callOptions = []): void - { - $this->startApiCall('StartMigrationWorkflow', $request, $callOptions)->wait(); - } -} diff --git a/BigQueryMigration/src/V2/Client/MigrationServiceClient.php b/BigQueryMigration/src/V2/Client/MigrationServiceClient.php index a391ae3c7b57..333ac22f47bc 100644 --- a/BigQueryMigration/src/V2/Client/MigrationServiceClient.php +++ b/BigQueryMigration/src/V2/Client/MigrationServiceClient.php @@ -24,17 +24,430 @@ namespace Google\Cloud\BigQuery\Migration\V2\Client; -use Google\Cloud\BigQuery\Migration\V2\Client\BaseClient\MigrationServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\BigQuery\Migration\V2\CreateMigrationWorkflowRequest; +use Google\Cloud\BigQuery\Migration\V2\DeleteMigrationWorkflowRequest; +use Google\Cloud\BigQuery\Migration\V2\GetMigrationSubtaskRequest; +use Google\Cloud\BigQuery\Migration\V2\GetMigrationWorkflowRequest; +use Google\Cloud\BigQuery\Migration\V2\ListMigrationSubtasksRequest; +use Google\Cloud\BigQuery\Migration\V2\ListMigrationWorkflowsRequest; +use Google\Cloud\BigQuery\Migration\V2\MigrationSubtask; +use Google\Cloud\BigQuery\Migration\V2\MigrationWorkflow; +use Google\Cloud\BigQuery\Migration\V2\StartMigrationWorkflowRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service to handle EDW migrations. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\BigQuery\Migration\V2\MigrationServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createMigrationWorkflowAsync(CreateMigrationWorkflowRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteMigrationWorkflowAsync(DeleteMigrationWorkflowRequest $request, array $optionalArgs = []) + * @method PromiseInterface getMigrationSubtaskAsync(GetMigrationSubtaskRequest $request, array $optionalArgs = []) + * @method PromiseInterface getMigrationWorkflowAsync(GetMigrationWorkflowRequest $request, array $optionalArgs = []) + * @method PromiseInterface listMigrationSubtasksAsync(ListMigrationSubtasksRequest $request, array $optionalArgs = []) + * @method PromiseInterface listMigrationWorkflowsAsync(ListMigrationWorkflowsRequest $request, array $optionalArgs = []) + * @method PromiseInterface startMigrationWorkflowAsync(StartMigrationWorkflowRequest $request, array $optionalArgs = []) */ -final class MigrationServiceClient extends MigrationServiceBaseClient +final class MigrationServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see MigrationServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.bigquery.migration.v2.MigrationService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'bigquerymigration.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/migration_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/migration_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/migration_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/migration_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * migration_subtask resource. + * + * @param string $project + * @param string $location + * @param string $workflow + * @param string $subtask + * + * @return string The formatted migration_subtask resource. + */ + public static function migrationSubtaskName(string $project, string $location, string $workflow, string $subtask): string + { + return self::getPathTemplate('migrationSubtask')->render([ + 'project' => $project, + 'location' => $location, + 'workflow' => $workflow, + 'subtask' => $subtask, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * migration_workflow resource. + * + * @param string $project + * @param string $location + * @param string $workflow + * + * @return string The formatted migration_workflow resource. + */ + public static function migrationWorkflowName(string $project, string $location, string $workflow): string + { + return self::getPathTemplate('migrationWorkflow')->render([ + 'project' => $project, + 'location' => $location, + 'workflow' => $workflow, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - location: projects/{project}/locations/{location} + * - migrationSubtask: projects/{project}/locations/{location}/workflows/{workflow}/subtasks/{subtask} + * - migrationWorkflow: projects/{project}/locations/{location}/workflows/{workflow} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'bigquerymigration.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a migration workflow. + * + * The async variant is + * {@see MigrationServiceClient::createMigrationWorkflowAsync()} . + * + * @example samples/V2/MigrationServiceClient/create_migration_workflow.php + * + * @param CreateMigrationWorkflowRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MigrationWorkflow + * + * @throws ApiException Thrown if the API call fails. + */ + public function createMigrationWorkflow(CreateMigrationWorkflowRequest $request, array $callOptions = []): MigrationWorkflow + { + return $this->startApiCall('CreateMigrationWorkflow', $request, $callOptions)->wait(); + } + + /** + * Deletes a migration workflow by name. + * + * The async variant is + * {@see MigrationServiceClient::deleteMigrationWorkflowAsync()} . + * + * @example samples/V2/MigrationServiceClient/delete_migration_workflow.php + * + * @param DeleteMigrationWorkflowRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteMigrationWorkflow(DeleteMigrationWorkflowRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteMigrationWorkflow', $request, $callOptions)->wait(); + } + + /** + * Gets a previously created migration subtask. + * + * The async variant is {@see MigrationServiceClient::getMigrationSubtaskAsync()} . + * + * @example samples/V2/MigrationServiceClient/get_migration_subtask.php + * + * @param GetMigrationSubtaskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MigrationSubtask + * + * @throws ApiException Thrown if the API call fails. + */ + public function getMigrationSubtask(GetMigrationSubtaskRequest $request, array $callOptions = []): MigrationSubtask + { + return $this->startApiCall('GetMigrationSubtask', $request, $callOptions)->wait(); + } + + /** + * Gets a previously created migration workflow. + * + * The async variant is {@see MigrationServiceClient::getMigrationWorkflowAsync()} + * . + * + * @example samples/V2/MigrationServiceClient/get_migration_workflow.php + * + * @param GetMigrationWorkflowRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MigrationWorkflow + * + * @throws ApiException Thrown if the API call fails. + */ + public function getMigrationWorkflow(GetMigrationWorkflowRequest $request, array $callOptions = []): MigrationWorkflow + { + return $this->startApiCall('GetMigrationWorkflow', $request, $callOptions)->wait(); + } + + /** + * Lists previously created migration subtasks. + * + * The async variant is {@see MigrationServiceClient::listMigrationSubtasksAsync()} + * . + * + * @example samples/V2/MigrationServiceClient/list_migration_subtasks.php + * + * @param ListMigrationSubtasksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listMigrationSubtasks(ListMigrationSubtasksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListMigrationSubtasks', $request, $callOptions); + } + + /** + * Lists previously created migration workflow. + * + * The async variant is + * {@see MigrationServiceClient::listMigrationWorkflowsAsync()} . + * + * @example samples/V2/MigrationServiceClient/list_migration_workflows.php + * + * @param ListMigrationWorkflowsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listMigrationWorkflows(ListMigrationWorkflowsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListMigrationWorkflows', $request, $callOptions); + } + + /** + * Starts a previously created migration workflow. I.e., the state transitions + * from DRAFT to RUNNING. This is a no-op if the state is already RUNNING. + * An error will be signaled if the state is anything other than DRAFT or + * RUNNING. + * + * The async variant is + * {@see MigrationServiceClient::startMigrationWorkflowAsync()} . + * + * @example samples/V2/MigrationServiceClient/start_migration_workflow.php + * + * @param StartMigrationWorkflowRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function startMigrationWorkflow(StartMigrationWorkflowRequest $request, array $callOptions = []): void + { + $this->startApiCall('StartMigrationWorkflow', $request, $callOptions)->wait(); + } } diff --git a/BigQueryReservation/composer.json b/BigQueryReservation/composer.json index c9917809b08d..915b419e8460 100644 --- a/BigQueryReservation/composer.json +++ b/BigQueryReservation/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/BigQueryReservation/src/V1/Client/BaseClient/ReservationServiceBaseClient.php b/BigQueryReservation/src/V1/Client/BaseClient/ReservationServiceBaseClient.php deleted file mode 100644 index 3e1df6aec86b..000000000000 --- a/BigQueryReservation/src/V1/Client/BaseClient/ReservationServiceBaseClient.php +++ /dev/null @@ -1,997 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/reservation_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/reservation_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/reservation_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/reservation_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a assignment - * resource. - * - * @param string $project - * @param string $location - * @param string $reservation - * @param string $assignment - * - * @return string The formatted assignment resource. - */ - public static function assignmentName(string $project, string $location, string $reservation, string $assignment): string - { - return self::getPathTemplate('assignment')->render([ - 'project' => $project, - 'location' => $location, - 'reservation' => $reservation, - 'assignment' => $assignment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * bi_reservation resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted bi_reservation resource. - */ - public static function biReservationName(string $project, string $location): string - { - return self::getPathTemplate('biReservation')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * capacity_commitment resource. - * - * @param string $project - * @param string $location - * @param string $capacityCommitment - * - * @return string The formatted capacity_commitment resource. - */ - public static function capacityCommitmentName(string $project, string $location, string $capacityCommitment): string - { - return self::getPathTemplate('capacityCommitment')->render([ - 'project' => $project, - 'location' => $location, - 'capacity_commitment' => $capacityCommitment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a reservation - * resource. - * - * @param string $project - * @param string $location - * @param string $reservation - * - * @return string The formatted reservation resource. - */ - public static function reservationName(string $project, string $location, string $reservation): string - { - return self::getPathTemplate('reservation')->render([ - 'project' => $project, - 'location' => $location, - 'reservation' => $reservation, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - assignment: projects/{project}/locations/{location}/reservations/{reservation}/assignments/{assignment} - * - biReservation: projects/{project}/locations/{location}/biReservation - * - capacityCommitment: projects/{project}/locations/{location}/capacityCommitments/{capacity_commitment} - * - location: projects/{project}/locations/{location} - * - reservation: projects/{project}/locations/{location}/reservations/{reservation} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'bigqueryreservation.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates an assignment object which allows the given project to submit jobs - * of a certain type using slots from the specified reservation. - * - * Currently a - * resource (project, folder, organization) can only have one assignment per - * each (job_type, location) combination, and that reservation will be used - * for all jobs of the matching type. - * - * Different assignments can be created on different levels of the - * projects, folders or organization hierarchy. During query execution, - * the assignment is looked up at the project, folder and organization levels - * in that order. The first assignment found is applied to the query. - * - * When creating assignments, it does not matter if other assignments exist at - * higher levels. - * - * Example: - * - * * The organization `organizationA` contains two projects, `project1` - * and `project2`. - * * Assignments for all three entities (`organizationA`, `project1`, and - * `project2`) could all be created and mapped to the same or different - * reservations. - * - * "None" assignments represent an absence of the assignment. Projects - * assigned to None use on-demand pricing. To create a "None" assignment, use - * "none" as a reservation_id in the parent. Example parent: - * `projects/myproject/locations/US/reservations/none`. - * - * Returns `google.rpc.Code.PERMISSION_DENIED` if user does not have - * 'bigquery.admin' permissions on the project using the reservation - * and the project that owns this reservation. - * - * Returns `google.rpc.Code.INVALID_ARGUMENT` when location of the assignment - * does not match location of the reservation. - * - * The async variant is {@see self::createAssignmentAsync()} . - * - * @param CreateAssignmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Assignment - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAssignment(CreateAssignmentRequest $request, array $callOptions = []): Assignment - { - return $this->startApiCall('CreateAssignment', $request, $callOptions)->wait(); - } - - /** - * Creates a new capacity commitment resource. - * - * The async variant is {@see self::createCapacityCommitmentAsync()} . - * - * @param CreateCapacityCommitmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CapacityCommitment - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCapacityCommitment(CreateCapacityCommitmentRequest $request, array $callOptions = []): CapacityCommitment - { - return $this->startApiCall('CreateCapacityCommitment', $request, $callOptions)->wait(); - } - - /** - * Creates a new reservation resource. - * - * The async variant is {@see self::createReservationAsync()} . - * - * @param CreateReservationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Reservation - * - * @throws ApiException Thrown if the API call fails. - */ - public function createReservation(CreateReservationRequest $request, array $callOptions = []): Reservation - { - return $this->startApiCall('CreateReservation', $request, $callOptions)->wait(); - } - - /** - * Deletes a assignment. No expansion will happen. - * - * Example: - * - * * Organization `organizationA` contains two projects, `project1` and - * `project2`. - * * Reservation `res1` exists and was created previously. - * * CreateAssignment was used previously to define the following - * associations between entities and reservations: `` - * and `` - * - * In this example, deletion of the `` assignment won't - * affect the other assignment ``. After said deletion, - * queries from `project1` will still use `res1` while queries from - * `project2` will switch to use on-demand mode. - * - * The async variant is {@see self::deleteAssignmentAsync()} . - * - * @param DeleteAssignmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAssignment(DeleteAssignmentRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteAssignment', $request, $callOptions)->wait(); - } - - /** - * Deletes a capacity commitment. Attempting to delete capacity commitment - * before its commitment_end_time will fail with the error code - * `google.rpc.Code.FAILED_PRECONDITION`. - * - * The async variant is {@see self::deleteCapacityCommitmentAsync()} . - * - * @param DeleteCapacityCommitmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteCapacityCommitment(DeleteCapacityCommitmentRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteCapacityCommitment', $request, $callOptions)->wait(); - } - - /** - * Deletes a reservation. - * Returns `google.rpc.Code.FAILED_PRECONDITION` when reservation has - * assignments. - * - * The async variant is {@see self::deleteReservationAsync()} . - * - * @param DeleteReservationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteReservation(DeleteReservationRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteReservation', $request, $callOptions)->wait(); - } - - /** - * Retrieves a BI reservation. - * - * The async variant is {@see self::getBiReservationAsync()} . - * - * @param GetBiReservationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BiReservation - * - * @throws ApiException Thrown if the API call fails. - */ - public function getBiReservation(GetBiReservationRequest $request, array $callOptions = []): BiReservation - { - return $this->startApiCall('GetBiReservation', $request, $callOptions)->wait(); - } - - /** - * Returns information about the capacity commitment. - * - * The async variant is {@see self::getCapacityCommitmentAsync()} . - * - * @param GetCapacityCommitmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CapacityCommitment - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCapacityCommitment(GetCapacityCommitmentRequest $request, array $callOptions = []): CapacityCommitment - { - return $this->startApiCall('GetCapacityCommitment', $request, $callOptions)->wait(); - } - - /** - * Returns information about the reservation. - * - * The async variant is {@see self::getReservationAsync()} . - * - * @param GetReservationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Reservation - * - * @throws ApiException Thrown if the API call fails. - */ - public function getReservation(GetReservationRequest $request, array $callOptions = []): Reservation - { - return $this->startApiCall('GetReservation', $request, $callOptions)->wait(); - } - - /** - * Lists assignments. - * - * Only explicitly created assignments will be returned. - * - * Example: - * - * * Organization `organizationA` contains two projects, `project1` and - * `project2`. - * * Reservation `res1` exists and was created previously. - * * CreateAssignment was used previously to define the following - * associations between entities and reservations: `` - * and `` - * - * In this example, ListAssignments will just return the above two assignments - * for reservation `res1`, and no expansion/merge will happen. - * - * The wildcard "-" can be used for - * reservations in the request. In that case all assignments belongs to the - * specified project and location will be listed. - * - * **Note** "-" cannot be used for projects nor locations. - * - * The async variant is {@see self::listAssignmentsAsync()} . - * - * @param ListAssignmentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAssignments(ListAssignmentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAssignments', $request, $callOptions); - } - - /** - * Lists all the capacity commitments for the admin project. - * - * The async variant is {@see self::listCapacityCommitmentsAsync()} . - * - * @param ListCapacityCommitmentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCapacityCommitments(ListCapacityCommitmentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCapacityCommitments', $request, $callOptions); - } - - /** - * Lists all the reservations for the project in the specified location. - * - * The async variant is {@see self::listReservationsAsync()} . - * - * @param ListReservationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listReservations(ListReservationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListReservations', $request, $callOptions); - } - - /** - * Merges capacity commitments of the same plan into a single commitment. - * - * The resulting capacity commitment has the greater commitment_end_time - * out of the to-be-merged capacity commitments. - * - * Attempting to merge capacity commitments of different plan will fail - * with the error code `google.rpc.Code.FAILED_PRECONDITION`. - * - * The async variant is {@see self::mergeCapacityCommitmentsAsync()} . - * - * @param MergeCapacityCommitmentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CapacityCommitment - * - * @throws ApiException Thrown if the API call fails. - */ - public function mergeCapacityCommitments(MergeCapacityCommitmentsRequest $request, array $callOptions = []): CapacityCommitment - { - return $this->startApiCall('MergeCapacityCommitments', $request, $callOptions)->wait(); - } - - /** - * Moves an assignment under a new reservation. - * - * This differs from removing an existing assignment and recreating a new one - * by providing a transactional change that ensures an assignee always has an - * associated reservation. - * - * The async variant is {@see self::moveAssignmentAsync()} . - * - * @param MoveAssignmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Assignment - * - * @throws ApiException Thrown if the API call fails. - */ - public function moveAssignment(MoveAssignmentRequest $request, array $callOptions = []): Assignment - { - return $this->startApiCall('MoveAssignment', $request, $callOptions)->wait(); - } - - /** - * Looks up assignments for a specified resource for a particular region. - * If the request is about a project: - * - * 1. Assignments created on the project will be returned if they exist. - * 2. Otherwise assignments created on the closest ancestor will be - * returned. - * 3. Assignments for different JobTypes will all be returned. - * - * The same logic applies if the request is about a folder. - * - * If the request is about an organization, then assignments created on the - * organization will be returned (organization doesn't have ancestors). - * - * Comparing to ListAssignments, there are some behavior - * differences: - * - * 1. permission on the assignee will be verified in this API. - * 2. Hierarchy lookup (project->folder->organization) happens in this API. - * 3. Parent here is `projects/*/locations/*`, instead of - * `projects/*/locations/*reservations/*`. - * - * The async variant is {@see self::searchAllAssignmentsAsync()} . - * - * @param SearchAllAssignmentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchAllAssignments(SearchAllAssignmentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchAllAssignments', $request, $callOptions); - } - - /** - * Deprecated: Looks up assignments for a specified resource for a particular - * region. If the request is about a project: - * - * 1. Assignments created on the project will be returned if they exist. - * 2. Otherwise assignments created on the closest ancestor will be - * returned. - * 3. Assignments for different JobTypes will all be returned. - * - * The same logic applies if the request is about a folder. - * - * If the request is about an organization, then assignments created on the - * organization will be returned (organization doesn't have ancestors). - * - * Comparing to ListAssignments, there are some behavior - * differences: - * - * 1. permission on the assignee will be verified in this API. - * 2. Hierarchy lookup (project->folder->organization) happens in this API. - * 3. Parent here is `projects/*/locations/*`, instead of - * `projects/*/locations/*reservations/*`. - * - * **Note** "-" cannot be used for projects - * nor locations. - * - * The async variant is {@see self::searchAssignmentsAsync()} . - * - * @param SearchAssignmentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @deprecated This method will be removed in the next major version update. - */ - public function searchAssignments(SearchAssignmentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchAssignments', $request, $callOptions); - } - - /** - * Splits capacity commitment to two commitments of the same plan and - * `commitment_end_time`. - * - * A common use case is to enable downgrading commitments. - * - * For example, in order to downgrade from 10000 slots to 8000, you might - * split a 10000 capacity commitment into commitments of 2000 and 8000. Then, - * you delete the first one after the commitment end time passes. - * - * The async variant is {@see self::splitCapacityCommitmentAsync()} . - * - * @param SplitCapacityCommitmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SplitCapacityCommitmentResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function splitCapacityCommitment(SplitCapacityCommitmentRequest $request, array $callOptions = []): SplitCapacityCommitmentResponse - { - return $this->startApiCall('SplitCapacityCommitment', $request, $callOptions)->wait(); - } - - /** - * Updates an existing assignment. - * - * Only the `priority` field can be updated. - * - * The async variant is {@see self::updateAssignmentAsync()} . - * - * @param UpdateAssignmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Assignment - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAssignment(UpdateAssignmentRequest $request, array $callOptions = []): Assignment - { - return $this->startApiCall('UpdateAssignment', $request, $callOptions)->wait(); - } - - /** - * Updates a BI reservation. - * - * Only fields specified in the `field_mask` are updated. - * - * A singleton BI reservation always exists with default size 0. - * In order to reserve BI capacity it needs to be updated to an amount - * greater than 0. In order to release BI capacity reservation size - * must be set to 0. - * - * The async variant is {@see self::updateBiReservationAsync()} . - * - * @param UpdateBiReservationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BiReservation - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateBiReservation(UpdateBiReservationRequest $request, array $callOptions = []): BiReservation - { - return $this->startApiCall('UpdateBiReservation', $request, $callOptions)->wait(); - } - - /** - * Updates an existing capacity commitment. - * - * Only `plan` and `renewal_plan` fields can be updated. - * - * Plan can only be changed to a plan of a longer commitment period. - * Attempting to change to a plan with shorter commitment period will fail - * with the error code `google.rpc.Code.FAILED_PRECONDITION`. - * - * The async variant is {@see self::updateCapacityCommitmentAsync()} . - * - * @param UpdateCapacityCommitmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CapacityCommitment - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCapacityCommitment(UpdateCapacityCommitmentRequest $request, array $callOptions = []): CapacityCommitment - { - return $this->startApiCall('UpdateCapacityCommitment', $request, $callOptions)->wait(); - } - - /** - * Updates an existing reservation resource. - * - * The async variant is {@see self::updateReservationAsync()} . - * - * @param UpdateReservationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Reservation - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateReservation(UpdateReservationRequest $request, array $callOptions = []): Reservation - { - return $this->startApiCall('UpdateReservation', $request, $callOptions)->wait(); - } -} diff --git a/BigQueryReservation/src/V1/Client/ReservationServiceClient.php b/BigQueryReservation/src/V1/Client/ReservationServiceClient.php index bd4bae9be653..697c8956f626 100644 --- a/BigQueryReservation/src/V1/Client/ReservationServiceClient.php +++ b/BigQueryReservation/src/V1/Client/ReservationServiceClient.php @@ -24,17 +24,981 @@ namespace Google\Cloud\BigQuery\Reservation\V1\Client; -use Google\Cloud\BigQuery\Reservation\V1\Client\BaseClient\ReservationServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\BigQuery\Reservation\V1\Assignment; +use Google\Cloud\BigQuery\Reservation\V1\BiReservation; +use Google\Cloud\BigQuery\Reservation\V1\CapacityCommitment; +use Google\Cloud\BigQuery\Reservation\V1\CreateAssignmentRequest; +use Google\Cloud\BigQuery\Reservation\V1\CreateCapacityCommitmentRequest; +use Google\Cloud\BigQuery\Reservation\V1\CreateReservationRequest; +use Google\Cloud\BigQuery\Reservation\V1\DeleteAssignmentRequest; +use Google\Cloud\BigQuery\Reservation\V1\DeleteCapacityCommitmentRequest; +use Google\Cloud\BigQuery\Reservation\V1\DeleteReservationRequest; +use Google\Cloud\BigQuery\Reservation\V1\GetBiReservationRequest; +use Google\Cloud\BigQuery\Reservation\V1\GetCapacityCommitmentRequest; +use Google\Cloud\BigQuery\Reservation\V1\GetReservationRequest; +use Google\Cloud\BigQuery\Reservation\V1\ListAssignmentsRequest; +use Google\Cloud\BigQuery\Reservation\V1\ListCapacityCommitmentsRequest; +use Google\Cloud\BigQuery\Reservation\V1\ListReservationsRequest; +use Google\Cloud\BigQuery\Reservation\V1\MergeCapacityCommitmentsRequest; +use Google\Cloud\BigQuery\Reservation\V1\MoveAssignmentRequest; +use Google\Cloud\BigQuery\Reservation\V1\Reservation; +use Google\Cloud\BigQuery\Reservation\V1\SearchAllAssignmentsRequest; +use Google\Cloud\BigQuery\Reservation\V1\SearchAssignmentsRequest; +use Google\Cloud\BigQuery\Reservation\V1\SplitCapacityCommitmentRequest; +use Google\Cloud\BigQuery\Reservation\V1\SplitCapacityCommitmentResponse; +use Google\Cloud\BigQuery\Reservation\V1\UpdateAssignmentRequest; +use Google\Cloud\BigQuery\Reservation\V1\UpdateBiReservationRequest; +use Google\Cloud\BigQuery\Reservation\V1\UpdateCapacityCommitmentRequest; +use Google\Cloud\BigQuery\Reservation\V1\UpdateReservationRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: This API allows users to manage their BigQuery reservations. * - * This class is currently experimental and may be subject to changes. + * A reservation provides computational resource guarantees, in the form of + * [slots](https://cloud.google.com/bigquery/docs/slots), to users. A slot is a + * unit of computational power in BigQuery, and serves as the basic unit of + * parallelism. In a scan of a multi-partitioned table, a single slot operates + * on a single partition of the table. A reservation resource exists as a child + * resource of the admin project and location, e.g.: + * `projects/myproject/locations/US/reservations/reservationName`. + * + * A capacity commitment is a way to purchase compute capacity for BigQuery jobs + * (in the form of slots) with some committed period of usage. A capacity + * commitment resource exists as a child resource of the admin project and + * location, e.g.: + * `projects/myproject/locations/US/capacityCommitments/id`. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\BigQuery\Reservation\V1\ReservationServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createAssignmentAsync(CreateAssignmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface createCapacityCommitmentAsync(CreateCapacityCommitmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface createReservationAsync(CreateReservationRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAssignmentAsync(DeleteAssignmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteCapacityCommitmentAsync(DeleteCapacityCommitmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteReservationAsync(DeleteReservationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getBiReservationAsync(GetBiReservationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCapacityCommitmentAsync(GetCapacityCommitmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getReservationAsync(GetReservationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAssignmentsAsync(ListAssignmentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCapacityCommitmentsAsync(ListCapacityCommitmentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listReservationsAsync(ListReservationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface mergeCapacityCommitmentsAsync(MergeCapacityCommitmentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface moveAssignmentAsync(MoveAssignmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchAllAssignmentsAsync(SearchAllAssignmentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchAssignmentsAsync(SearchAssignmentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface splitCapacityCommitmentAsync(SplitCapacityCommitmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAssignmentAsync(UpdateAssignmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateBiReservationAsync(UpdateBiReservationRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCapacityCommitmentAsync(UpdateCapacityCommitmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateReservationAsync(UpdateReservationRequest $request, array $optionalArgs = []) */ -final class ReservationServiceClient extends ReservationServiceBaseClient +final class ReservationServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ReservationServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.bigquery.reservation.v1.ReservationService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'bigqueryreservation.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/bigquery', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/reservation_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/reservation_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/reservation_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/reservation_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a assignment + * resource. + * + * @param string $project + * @param string $location + * @param string $reservation + * @param string $assignment + * + * @return string The formatted assignment resource. + */ + public static function assignmentName(string $project, string $location, string $reservation, string $assignment): string + { + return self::getPathTemplate('assignment')->render([ + 'project' => $project, + 'location' => $location, + 'reservation' => $reservation, + 'assignment' => $assignment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * bi_reservation resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted bi_reservation resource. + */ + public static function biReservationName(string $project, string $location): string + { + return self::getPathTemplate('biReservation')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * capacity_commitment resource. + * + * @param string $project + * @param string $location + * @param string $capacityCommitment + * + * @return string The formatted capacity_commitment resource. + */ + public static function capacityCommitmentName(string $project, string $location, string $capacityCommitment): string + { + return self::getPathTemplate('capacityCommitment')->render([ + 'project' => $project, + 'location' => $location, + 'capacity_commitment' => $capacityCommitment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a reservation + * resource. + * + * @param string $project + * @param string $location + * @param string $reservation + * + * @return string The formatted reservation resource. + */ + public static function reservationName(string $project, string $location, string $reservation): string + { + return self::getPathTemplate('reservation')->render([ + 'project' => $project, + 'location' => $location, + 'reservation' => $reservation, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - assignment: projects/{project}/locations/{location}/reservations/{reservation}/assignments/{assignment} + * - biReservation: projects/{project}/locations/{location}/biReservation + * - capacityCommitment: projects/{project}/locations/{location}/capacityCommitments/{capacity_commitment} + * - location: projects/{project}/locations/{location} + * - reservation: projects/{project}/locations/{location}/reservations/{reservation} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'bigqueryreservation.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates an assignment object which allows the given project to submit jobs + * of a certain type using slots from the specified reservation. + * + * Currently a + * resource (project, folder, organization) can only have one assignment per + * each (job_type, location) combination, and that reservation will be used + * for all jobs of the matching type. + * + * Different assignments can be created on different levels of the + * projects, folders or organization hierarchy. During query execution, + * the assignment is looked up at the project, folder and organization levels + * in that order. The first assignment found is applied to the query. + * + * When creating assignments, it does not matter if other assignments exist at + * higher levels. + * + * Example: + * + * * The organization `organizationA` contains two projects, `project1` + * and `project2`. + * * Assignments for all three entities (`organizationA`, `project1`, and + * `project2`) could all be created and mapped to the same or different + * reservations. + * + * "None" assignments represent an absence of the assignment. Projects + * assigned to None use on-demand pricing. To create a "None" assignment, use + * "none" as a reservation_id in the parent. Example parent: + * `projects/myproject/locations/US/reservations/none`. + * + * Returns `google.rpc.Code.PERMISSION_DENIED` if user does not have + * 'bigquery.admin' permissions on the project using the reservation + * and the project that owns this reservation. + * + * Returns `google.rpc.Code.INVALID_ARGUMENT` when location of the assignment + * does not match location of the reservation. + * + * The async variant is {@see ReservationServiceClient::createAssignmentAsync()} . + * + * @param CreateAssignmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Assignment + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAssignment(CreateAssignmentRequest $request, array $callOptions = []): Assignment + { + return $this->startApiCall('CreateAssignment', $request, $callOptions)->wait(); + } + + /** + * Creates a new capacity commitment resource. + * + * The async variant is + * {@see ReservationServiceClient::createCapacityCommitmentAsync()} . + * + * @param CreateCapacityCommitmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CapacityCommitment + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCapacityCommitment(CreateCapacityCommitmentRequest $request, array $callOptions = []): CapacityCommitment + { + return $this->startApiCall('CreateCapacityCommitment', $request, $callOptions)->wait(); + } + + /** + * Creates a new reservation resource. + * + * The async variant is {@see ReservationServiceClient::createReservationAsync()} . + * + * @param CreateReservationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Reservation + * + * @throws ApiException Thrown if the API call fails. + */ + public function createReservation(CreateReservationRequest $request, array $callOptions = []): Reservation + { + return $this->startApiCall('CreateReservation', $request, $callOptions)->wait(); + } + + /** + * Deletes a assignment. No expansion will happen. + * + * Example: + * + * * Organization `organizationA` contains two projects, `project1` and + * `project2`. + * * Reservation `res1` exists and was created previously. + * * CreateAssignment was used previously to define the following + * associations between entities and reservations: `` + * and `` + * + * In this example, deletion of the `` assignment won't + * affect the other assignment ``. After said deletion, + * queries from `project1` will still use `res1` while queries from + * `project2` will switch to use on-demand mode. + * + * The async variant is {@see ReservationServiceClient::deleteAssignmentAsync()} . + * + * @param DeleteAssignmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAssignment(DeleteAssignmentRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteAssignment', $request, $callOptions)->wait(); + } + + /** + * Deletes a capacity commitment. Attempting to delete capacity commitment + * before its commitment_end_time will fail with the error code + * `google.rpc.Code.FAILED_PRECONDITION`. + * + * The async variant is + * {@see ReservationServiceClient::deleteCapacityCommitmentAsync()} . + * + * @param DeleteCapacityCommitmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteCapacityCommitment(DeleteCapacityCommitmentRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteCapacityCommitment', $request, $callOptions)->wait(); + } + + /** + * Deletes a reservation. + * Returns `google.rpc.Code.FAILED_PRECONDITION` when reservation has + * assignments. + * + * The async variant is {@see ReservationServiceClient::deleteReservationAsync()} . + * + * @param DeleteReservationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteReservation(DeleteReservationRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteReservation', $request, $callOptions)->wait(); + } + + /** + * Retrieves a BI reservation. + * + * The async variant is {@see ReservationServiceClient::getBiReservationAsync()} . + * + * @param GetBiReservationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BiReservation + * + * @throws ApiException Thrown if the API call fails. + */ + public function getBiReservation(GetBiReservationRequest $request, array $callOptions = []): BiReservation + { + return $this->startApiCall('GetBiReservation', $request, $callOptions)->wait(); + } + + /** + * Returns information about the capacity commitment. + * + * The async variant is + * {@see ReservationServiceClient::getCapacityCommitmentAsync()} . + * + * @param GetCapacityCommitmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CapacityCommitment + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCapacityCommitment(GetCapacityCommitmentRequest $request, array $callOptions = []): CapacityCommitment + { + return $this->startApiCall('GetCapacityCommitment', $request, $callOptions)->wait(); + } + + /** + * Returns information about the reservation. + * + * The async variant is {@see ReservationServiceClient::getReservationAsync()} . + * + * @param GetReservationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Reservation + * + * @throws ApiException Thrown if the API call fails. + */ + public function getReservation(GetReservationRequest $request, array $callOptions = []): Reservation + { + return $this->startApiCall('GetReservation', $request, $callOptions)->wait(); + } + + /** + * Lists assignments. + * + * Only explicitly created assignments will be returned. + * + * Example: + * + * * Organization `organizationA` contains two projects, `project1` and + * `project2`. + * * Reservation `res1` exists and was created previously. + * * CreateAssignment was used previously to define the following + * associations between entities and reservations: `` + * and `` + * + * In this example, ListAssignments will just return the above two assignments + * for reservation `res1`, and no expansion/merge will happen. + * + * The wildcard "-" can be used for + * reservations in the request. In that case all assignments belongs to the + * specified project and location will be listed. + * + * **Note** "-" cannot be used for projects nor locations. + * + * The async variant is {@see ReservationServiceClient::listAssignmentsAsync()} . + * + * @param ListAssignmentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAssignments(ListAssignmentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAssignments', $request, $callOptions); + } + + /** + * Lists all the capacity commitments for the admin project. + * + * The async variant is + * {@see ReservationServiceClient::listCapacityCommitmentsAsync()} . + * + * @param ListCapacityCommitmentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCapacityCommitments(ListCapacityCommitmentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCapacityCommitments', $request, $callOptions); + } + + /** + * Lists all the reservations for the project in the specified location. + * + * The async variant is {@see ReservationServiceClient::listReservationsAsync()} . + * + * @param ListReservationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listReservations(ListReservationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListReservations', $request, $callOptions); + } + + /** + * Merges capacity commitments of the same plan into a single commitment. + * + * The resulting capacity commitment has the greater commitment_end_time + * out of the to-be-merged capacity commitments. + * + * Attempting to merge capacity commitments of different plan will fail + * with the error code `google.rpc.Code.FAILED_PRECONDITION`. + * + * The async variant is + * {@see ReservationServiceClient::mergeCapacityCommitmentsAsync()} . + * + * @param MergeCapacityCommitmentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CapacityCommitment + * + * @throws ApiException Thrown if the API call fails. + */ + public function mergeCapacityCommitments(MergeCapacityCommitmentsRequest $request, array $callOptions = []): CapacityCommitment + { + return $this->startApiCall('MergeCapacityCommitments', $request, $callOptions)->wait(); + } + + /** + * Moves an assignment under a new reservation. + * + * This differs from removing an existing assignment and recreating a new one + * by providing a transactional change that ensures an assignee always has an + * associated reservation. + * + * The async variant is {@see ReservationServiceClient::moveAssignmentAsync()} . + * + * @param MoveAssignmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Assignment + * + * @throws ApiException Thrown if the API call fails. + */ + public function moveAssignment(MoveAssignmentRequest $request, array $callOptions = []): Assignment + { + return $this->startApiCall('MoveAssignment', $request, $callOptions)->wait(); + } + + /** + * Looks up assignments for a specified resource for a particular region. + * If the request is about a project: + * + * 1. Assignments created on the project will be returned if they exist. + * 2. Otherwise assignments created on the closest ancestor will be + * returned. + * 3. Assignments for different JobTypes will all be returned. + * + * The same logic applies if the request is about a folder. + * + * If the request is about an organization, then assignments created on the + * organization will be returned (organization doesn't have ancestors). + * + * Comparing to ListAssignments, there are some behavior + * differences: + * + * 1. permission on the assignee will be verified in this API. + * 2. Hierarchy lookup (project->folder->organization) happens in this API. + * 3. Parent here is `projects/*/locations/*`, instead of + * `projects/*/locations/*reservations/*`. + * + * The async variant is + * {@see ReservationServiceClient::searchAllAssignmentsAsync()} . + * + * @param SearchAllAssignmentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchAllAssignments(SearchAllAssignmentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchAllAssignments', $request, $callOptions); + } + + /** + * Deprecated: Looks up assignments for a specified resource for a particular + * region. If the request is about a project: + * + * 1. Assignments created on the project will be returned if they exist. + * 2. Otherwise assignments created on the closest ancestor will be + * returned. + * 3. Assignments for different JobTypes will all be returned. + * + * The same logic applies if the request is about a folder. + * + * If the request is about an organization, then assignments created on the + * organization will be returned (organization doesn't have ancestors). + * + * Comparing to ListAssignments, there are some behavior + * differences: + * + * 1. permission on the assignee will be verified in this API. + * 2. Hierarchy lookup (project->folder->organization) happens in this API. + * 3. Parent here is `projects/*/locations/*`, instead of + * `projects/*/locations/*reservations/*`. + * + * **Note** "-" cannot be used for projects + * nor locations. + * + * The async variant is {@see ReservationServiceClient::searchAssignmentsAsync()} . + * + * @param SearchAssignmentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @deprecated This method will be removed in the next major version update. + */ + public function searchAssignments(SearchAssignmentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchAssignments', $request, $callOptions); + } + + /** + * Splits capacity commitment to two commitments of the same plan and + * `commitment_end_time`. + * + * A common use case is to enable downgrading commitments. + * + * For example, in order to downgrade from 10000 slots to 8000, you might + * split a 10000 capacity commitment into commitments of 2000 and 8000. Then, + * you delete the first one after the commitment end time passes. + * + * The async variant is + * {@see ReservationServiceClient::splitCapacityCommitmentAsync()} . + * + * @param SplitCapacityCommitmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SplitCapacityCommitmentResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function splitCapacityCommitment(SplitCapacityCommitmentRequest $request, array $callOptions = []): SplitCapacityCommitmentResponse + { + return $this->startApiCall('SplitCapacityCommitment', $request, $callOptions)->wait(); + } + + /** + * Updates an existing assignment. + * + * Only the `priority` field can be updated. + * + * The async variant is {@see ReservationServiceClient::updateAssignmentAsync()} . + * + * @param UpdateAssignmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Assignment + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAssignment(UpdateAssignmentRequest $request, array $callOptions = []): Assignment + { + return $this->startApiCall('UpdateAssignment', $request, $callOptions)->wait(); + } + + /** + * Updates a BI reservation. + * + * Only fields specified in the `field_mask` are updated. + * + * A singleton BI reservation always exists with default size 0. + * In order to reserve BI capacity it needs to be updated to an amount + * greater than 0. In order to release BI capacity reservation size + * must be set to 0. + * + * The async variant is {@see ReservationServiceClient::updateBiReservationAsync()} + * . + * + * @param UpdateBiReservationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BiReservation + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateBiReservation(UpdateBiReservationRequest $request, array $callOptions = []): BiReservation + { + return $this->startApiCall('UpdateBiReservation', $request, $callOptions)->wait(); + } + + /** + * Updates an existing capacity commitment. + * + * Only `plan` and `renewal_plan` fields can be updated. + * + * Plan can only be changed to a plan of a longer commitment period. + * Attempting to change to a plan with shorter commitment period will fail + * with the error code `google.rpc.Code.FAILED_PRECONDITION`. + * + * The async variant is + * {@see ReservationServiceClient::updateCapacityCommitmentAsync()} . + * + * @param UpdateCapacityCommitmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CapacityCommitment + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCapacityCommitment(UpdateCapacityCommitmentRequest $request, array $callOptions = []): CapacityCommitment + { + return $this->startApiCall('UpdateCapacityCommitment', $request, $callOptions)->wait(); + } + + /** + * Updates an existing reservation resource. + * + * The async variant is {@see ReservationServiceClient::updateReservationAsync()} . + * + * @param UpdateReservationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Reservation + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateReservation(UpdateReservationRequest $request, array $callOptions = []): Reservation + { + return $this->startApiCall('UpdateReservation', $request, $callOptions)->wait(); + } } diff --git a/BigQueryStorage/composer.json b/BigQueryStorage/composer.json index d303e62c2e02..54b6dfa77402 100644 --- a/BigQueryStorage/composer.json +++ b/BigQueryStorage/composer.json @@ -27,7 +27,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/BigQueryStorage/src/V1/Client/BaseClient/BigQueryReadBaseClient.php b/BigQueryStorage/src/V1/Client/BaseClient/BigQueryReadBaseClient.php deleted file mode 100644 index 0336b097ce7e..000000000000 --- a/BigQueryStorage/src/V1/Client/BaseClient/BigQueryReadBaseClient.php +++ /dev/null @@ -1,383 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/big_query_read_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/big_query_read_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/big_query_read_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/big_query_read_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a read_session - * resource. - * - * @param string $project - * @param string $location - * @param string $session - * - * @return string The formatted read_session resource. - */ - public static function readSessionName(string $project, string $location, string $session): string - { - return self::getPathTemplate('readSession')->render([ - 'project' => $project, - 'location' => $location, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a read_stream - * resource. - * - * @param string $project - * @param string $location - * @param string $session - * @param string $stream - * - * @return string The formatted read_stream resource. - */ - public static function readStreamName(string $project, string $location, string $session, string $stream): string - { - return self::getPathTemplate('readStream')->render([ - 'project' => $project, - 'location' => $location, - 'session' => $session, - 'stream' => $stream, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a table - * resource. - * - * @param string $project - * @param string $dataset - * @param string $table - * - * @return string The formatted table resource. - */ - public static function tableName(string $project, string $dataset, string $table): string - { - return self::getPathTemplate('table')->render([ - 'project' => $project, - 'dataset' => $dataset, - 'table' => $table, - ]); - } - - /** - * 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} - * - readSession: projects/{project}/locations/{location}/sessions/{session} - * - readStream: projects/{project}/locations/{location}/sessions/{session}/streams/{stream} - * - table: projects/{project}/datasets/{dataset}/tables/{table} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'bigquerystorage.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new read session. A read session divides the contents of a - * BigQuery table into one or more streams, which can then be used to read - * data from the table. The read session also specifies properties of the - * data to be read, such as a list of columns or a push-down filter describing - * the rows to be returned. - * - * A particular row can be read by at most one stream. When the caller has - * reached the end of each stream in the session, then all the data in the - * table has been read. - * - * Data is assigned to each stream such that roughly the same number of - * rows can be read from each stream. Because the server-side unit for - * assigning data is collections of rows, the API does not guarantee that - * each stream will return the same number or rows. Additionally, the - * limits are enforced based on the number of pre-filtered rows, so some - * filters can lead to lopsided assignments. - * - * Read sessions automatically expire 6 hours after they are created and do - * not require manual clean-up by the caller. - * - * The async variant is {@see self::createReadSessionAsync()} . - * - * @param CreateReadSessionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ReadSession - * - * @throws ApiException Thrown if the API call fails. - */ - public function createReadSession(CreateReadSessionRequest $request, array $callOptions = []): ReadSession - { - return $this->startApiCall('CreateReadSession', $request, $callOptions)->wait(); - } - - /** - * Reads rows from the stream in the format prescribed by the ReadSession. - * Each response contains one or more table rows, up to a maximum of 100 MiB - * per response; read requests which attempt to read individual rows larger - * than 100 MiB will fail. - * - * Each request also returns a set of stream statistics reflecting the current - * state of the stream. - * - * @param ReadRowsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return ServerStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function readRows(ReadRowsRequest $request, array $callOptions = []): ServerStream - { - return $this->startApiCall('ReadRows', $request, $callOptions); - } - - /** - * Splits a given `ReadStream` into two `ReadStream` objects. These - * `ReadStream` objects are referred to as the primary and the residual - * streams of the split. The original `ReadStream` can still be read from in - * the same manner as before. Both of the returned `ReadStream` objects can - * also be read from, and the rows returned by both child streams will be - * the same as the rows read from the original stream. - * - * Moreover, the two child streams will be allocated back-to-back in the - * original `ReadStream`. Concretely, it is guaranteed that for streams - * original, primary, and residual, that original[0-j] = primary[0-j] and - * original[j-n] = residual[0-m] once the streams have been read to - * completion. - * - * The async variant is {@see self::splitReadStreamAsync()} . - * - * @param SplitReadStreamRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SplitReadStreamResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function splitReadStream(SplitReadStreamRequest $request, array $callOptions = []): SplitReadStreamResponse - { - return $this->startApiCall('SplitReadStream', $request, $callOptions)->wait(); - } -} diff --git a/BigQueryStorage/src/V1/Client/BaseClient/BigQueryWriteBaseClient.php b/BigQueryStorage/src/V1/Client/BaseClient/BigQueryWriteBaseClient.php deleted file mode 100644 index 1d518da91946..000000000000 --- a/BigQueryStorage/src/V1/Client/BaseClient/BigQueryWriteBaseClient.php +++ /dev/null @@ -1,442 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/big_query_write_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/big_query_write_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/big_query_write_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/big_query_write_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a table - * resource. - * - * @param string $project - * @param string $dataset - * @param string $table - * - * @return string The formatted table resource. - */ - public static function tableName(string $project, string $dataset, string $table): string - { - return self::getPathTemplate('table')->render([ - 'project' => $project, - 'dataset' => $dataset, - 'table' => $table, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a write_stream - * resource. - * - * @param string $project - * @param string $dataset - * @param string $table - * @param string $stream - * - * @return string The formatted write_stream resource. - */ - public static function writeStreamName(string $project, string $dataset, string $table, string $stream): string - { - return self::getPathTemplate('writeStream')->render([ - 'project' => $project, - 'dataset' => $dataset, - 'table' => $table, - 'stream' => $stream, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - table: projects/{project}/datasets/{dataset}/tables/{table} - * - writeStream: projects/{project}/datasets/{dataset}/tables/{table}/streams/{stream} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'bigquerystorage.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Appends data to the given stream. - * - * If `offset` is specified, the `offset` is checked against the end of - * stream. The server returns `OUT_OF_RANGE` in `AppendRowsResponse` if an - * attempt is made to append to an offset beyond the current end of the stream - * or `ALREADY_EXISTS` if user provides an `offset` that has already been - * written to. User can retry with adjusted offset within the same RPC - * connection. If `offset` is not specified, append happens at the end of the - * stream. - * - * The response contains an optional offset at which the append - * happened. No offset information will be returned for appends to a - * default stream. - * - * Responses are received in the same order in which requests are sent. - * There will be one response for each successful inserted request. Responses - * may optionally embed error information if the originating AppendRequest was - * not successfully processed. - * - * The specifics of when successfully appended data is made visible to the - * table are governed by the type of stream: - * - * * For COMMITTED streams (which includes the default stream), data is - * visible immediately upon successful append. - * - * * For BUFFERED streams, data is made visible via a subsequent `FlushRows` - * rpc which advances a cursor to a newer offset in the stream. - * - * * For PENDING streams, data is not made visible until the stream itself is - * finalized (via the `FinalizeWriteStream` rpc), and the stream is explicitly - * committed via the `BatchCommitWriteStreams` rpc. - * - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return BidiStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function appendRows(array $callOptions = []): BidiStream - { - return $this->startApiCall('AppendRows', null, $callOptions); - } - - /** - * Atomically commits a group of `PENDING` streams that belong to the same - * `parent` table. - * - * Streams must be finalized before commit and cannot be committed multiple - * times. Once a stream is committed, data in the stream becomes available - * for read operations. - * - * The async variant is {@see self::batchCommitWriteStreamsAsync()} . - * - * @param BatchCommitWriteStreamsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BatchCommitWriteStreamsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchCommitWriteStreams(BatchCommitWriteStreamsRequest $request, array $callOptions = []): BatchCommitWriteStreamsResponse - { - return $this->startApiCall('BatchCommitWriteStreams', $request, $callOptions)->wait(); - } - - /** - * Creates a write stream to the given table. - * Additionally, every table has a special stream named '_default' - * to which data can be written. This stream doesn't need to be created using - * CreateWriteStream. It is a stream that can be used simultaneously by any - * number of clients. Data written to this stream is considered committed as - * soon as an acknowledgement is received. - * - * The async variant is {@see self::createWriteStreamAsync()} . - * - * @param CreateWriteStreamRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 WriteStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function createWriteStream(CreateWriteStreamRequest $request, array $callOptions = []): WriteStream - { - return $this->startApiCall('CreateWriteStream', $request, $callOptions)->wait(); - } - - /** - * Finalize a write stream so that no new data can be appended to the - * stream. Finalize is not supported on the '_default' stream. - * - * The async variant is {@see self::finalizeWriteStreamAsync()} . - * - * @param FinalizeWriteStreamRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FinalizeWriteStreamResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function finalizeWriteStream(FinalizeWriteStreamRequest $request, array $callOptions = []): FinalizeWriteStreamResponse - { - return $this->startApiCall('FinalizeWriteStream', $request, $callOptions)->wait(); - } - - /** - * Flushes rows to a BUFFERED stream. - * - * If users are appending rows to BUFFERED stream, flush operation is - * required in order for the rows to become available for reading. A - * Flush operation flushes up to any previously flushed offset in a BUFFERED - * stream, to the offset specified in the request. - * - * Flush is not supported on the _default stream, since it is not BUFFERED. - * - * The async variant is {@see self::flushRowsAsync()} . - * - * @param FlushRowsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FlushRowsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function flushRows(FlushRowsRequest $request, array $callOptions = []): FlushRowsResponse - { - return $this->startApiCall('FlushRows', $request, $callOptions)->wait(); - } - - /** - * Gets information about a write stream. - * - * The async variant is {@see self::getWriteStreamAsync()} . - * - * @param GetWriteStreamRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 WriteStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function getWriteStream(GetWriteStreamRequest $request, array $callOptions = []): WriteStream - { - return $this->startApiCall('GetWriteStream', $request, $callOptions)->wait(); - } -} diff --git a/BigQueryStorage/src/V1/Client/BigQueryReadClient.php b/BigQueryStorage/src/V1/Client/BigQueryReadClient.php index 186239dc4d76..513da87ab7ac 100644 --- a/BigQueryStorage/src/V1/Client/BigQueryReadClient.php +++ b/BigQueryStorage/src/V1/Client/BigQueryReadClient.php @@ -24,17 +24,358 @@ namespace Google\Cloud\BigQuery\Storage\V1\Client; -use Google\Cloud\BigQuery\Storage\V1\Client\BaseClient\BigQueryReadBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\ServerStream; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\BigQuery\Storage\V1\CreateReadSessionRequest; +use Google\Cloud\BigQuery\Storage\V1\ReadRowsRequest; +use Google\Cloud\BigQuery\Storage\V1\ReadSession; +use Google\Cloud\BigQuery\Storage\V1\SplitReadStreamRequest; +use Google\Cloud\BigQuery\Storage\V1\SplitReadStreamResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: BigQuery Read API. * - * This class is currently experimental and may be subject to changes. + * The Read API can be used to read data from BigQuery. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\BigQuery\Storage\V1\BigQueryReadClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createReadSessionAsync(CreateReadSessionRequest $request, array $optionalArgs = []) + * @method PromiseInterface splitReadStreamAsync(SplitReadStreamRequest $request, array $optionalArgs = []) */ -final class BigQueryReadClient extends BigQueryReadBaseClient +final class BigQueryReadClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see BigQueryReadBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.bigquery.storage.v1.BigQueryRead'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'bigquerystorage.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/bigquery', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/big_query_read_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/big_query_read_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/big_query_read_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/big_query_read_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a read_session + * resource. + * + * @param string $project + * @param string $location + * @param string $session + * + * @return string The formatted read_session resource. + */ + public static function readSessionName(string $project, string $location, string $session): string + { + return self::getPathTemplate('readSession')->render([ + 'project' => $project, + 'location' => $location, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a read_stream + * resource. + * + * @param string $project + * @param string $location + * @param string $session + * @param string $stream + * + * @return string The formatted read_stream resource. + */ + public static function readStreamName(string $project, string $location, string $session, string $stream): string + { + return self::getPathTemplate('readStream')->render([ + 'project' => $project, + 'location' => $location, + 'session' => $session, + 'stream' => $stream, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a table + * resource. + * + * @param string $project + * @param string $dataset + * @param string $table + * + * @return string The formatted table resource. + */ + public static function tableName(string $project, string $dataset, string $table): string + { + return self::getPathTemplate('table')->render([ + 'project' => $project, + 'dataset' => $dataset, + 'table' => $table, + ]); + } + + /** + * 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} + * - readSession: projects/{project}/locations/{location}/sessions/{session} + * - readStream: projects/{project}/locations/{location}/sessions/{session}/streams/{stream} + * - table: projects/{project}/datasets/{dataset}/tables/{table} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'bigquerystorage.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new read session. A read session divides the contents of a + * BigQuery table into one or more streams, which can then be used to read + * data from the table. The read session also specifies properties of the + * data to be read, such as a list of columns or a push-down filter describing + * the rows to be returned. + * + * A particular row can be read by at most one stream. When the caller has + * reached the end of each stream in the session, then all the data in the + * table has been read. + * + * Data is assigned to each stream such that roughly the same number of + * rows can be read from each stream. Because the server-side unit for + * assigning data is collections of rows, the API does not guarantee that + * each stream will return the same number or rows. Additionally, the + * limits are enforced based on the number of pre-filtered rows, so some + * filters can lead to lopsided assignments. + * + * Read sessions automatically expire 6 hours after they are created and do + * not require manual clean-up by the caller. + * + * The async variant is {@see BigQueryReadClient::createReadSessionAsync()} . + * + * @param CreateReadSessionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ReadSession + * + * @throws ApiException Thrown if the API call fails. + */ + public function createReadSession(CreateReadSessionRequest $request, array $callOptions = []): ReadSession + { + return $this->startApiCall('CreateReadSession', $request, $callOptions)->wait(); + } + + /** + * Reads rows from the stream in the format prescribed by the ReadSession. + * Each response contains one or more table rows, up to a maximum of 100 MiB + * per response; read requests which attempt to read individual rows larger + * than 100 MiB will fail. + * + * Each request also returns a set of stream statistics reflecting the current + * state of the stream. + * + * @param ReadRowsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return ServerStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function readRows(ReadRowsRequest $request, array $callOptions = []): ServerStream + { + return $this->startApiCall('ReadRows', $request, $callOptions); + } + + /** + * Splits a given `ReadStream` into two `ReadStream` objects. These + * `ReadStream` objects are referred to as the primary and the residual + * streams of the split. The original `ReadStream` can still be read from in + * the same manner as before. Both of the returned `ReadStream` objects can + * also be read from, and the rows returned by both child streams will be + * the same as the rows read from the original stream. + * + * Moreover, the two child streams will be allocated back-to-back in the + * original `ReadStream`. Concretely, it is guaranteed that for streams + * original, primary, and residual, that original[0-j] = primary[0-j] and + * original[j-n] = residual[0-m] once the streams have been read to + * completion. + * + * The async variant is {@see BigQueryReadClient::splitReadStreamAsync()} . + * + * @param SplitReadStreamRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SplitReadStreamResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function splitReadStream(SplitReadStreamRequest $request, array $callOptions = []): SplitReadStreamResponse + { + return $this->startApiCall('SplitReadStream', $request, $callOptions)->wait(); + } } diff --git a/BigQueryStorage/src/V1/Client/BigQueryWriteClient.php b/BigQueryStorage/src/V1/Client/BigQueryWriteClient.php index a476522ea3d7..d0ca6b74cb0e 100644 --- a/BigQueryStorage/src/V1/Client/BigQueryWriteClient.php +++ b/BigQueryStorage/src/V1/Client/BigQueryWriteClient.php @@ -24,17 +24,418 @@ namespace Google\Cloud\BigQuery\Storage\V1\Client; -use Google\Cloud\BigQuery\Storage\V1\Client\BaseClient\BigQueryWriteBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\BidiStream; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\BigQuery\Storage\V1\BatchCommitWriteStreamsRequest; +use Google\Cloud\BigQuery\Storage\V1\BatchCommitWriteStreamsResponse; +use Google\Cloud\BigQuery\Storage\V1\CreateWriteStreamRequest; +use Google\Cloud\BigQuery\Storage\V1\FinalizeWriteStreamRequest; +use Google\Cloud\BigQuery\Storage\V1\FinalizeWriteStreamResponse; +use Google\Cloud\BigQuery\Storage\V1\FlushRowsRequest; +use Google\Cloud\BigQuery\Storage\V1\FlushRowsResponse; +use Google\Cloud\BigQuery\Storage\V1\GetWriteStreamRequest; +use Google\Cloud\BigQuery\Storage\V1\WriteStream; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: BigQuery Write API. * - * This class is currently experimental and may be subject to changes. + * The Write API can be used to write data to BigQuery. + * + * For supplementary information about the Write API, see: + * https://cloud.google.com/bigquery/docs/write-api + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\BigQuery\Storage\V1\BigQueryWriteClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface batchCommitWriteStreamsAsync(BatchCommitWriteStreamsRequest $request, array $optionalArgs = []) + * @method PromiseInterface createWriteStreamAsync(CreateWriteStreamRequest $request, array $optionalArgs = []) + * @method PromiseInterface finalizeWriteStreamAsync(FinalizeWriteStreamRequest $request, array $optionalArgs = []) + * @method PromiseInterface flushRowsAsync(FlushRowsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getWriteStreamAsync(GetWriteStreamRequest $request, array $optionalArgs = []) */ -final class BigQueryWriteClient extends BigQueryWriteBaseClient +final class BigQueryWriteClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see BigQueryWriteBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.bigquery.storage.v1.BigQueryWrite'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'bigquerystorage.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/bigquery', + 'https://www.googleapis.com/auth/bigquery.insertdata', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/big_query_write_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/big_query_write_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/big_query_write_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/big_query_write_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a table + * resource. + * + * @param string $project + * @param string $dataset + * @param string $table + * + * @return string The formatted table resource. + */ + public static function tableName(string $project, string $dataset, string $table): string + { + return self::getPathTemplate('table')->render([ + 'project' => $project, + 'dataset' => $dataset, + 'table' => $table, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a write_stream + * resource. + * + * @param string $project + * @param string $dataset + * @param string $table + * @param string $stream + * + * @return string The formatted write_stream resource. + */ + public static function writeStreamName(string $project, string $dataset, string $table, string $stream): string + { + return self::getPathTemplate('writeStream')->render([ + 'project' => $project, + 'dataset' => $dataset, + 'table' => $table, + 'stream' => $stream, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - table: projects/{project}/datasets/{dataset}/tables/{table} + * - writeStream: projects/{project}/datasets/{dataset}/tables/{table}/streams/{stream} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'bigquerystorage.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Appends data to the given stream. + * + * If `offset` is specified, the `offset` is checked against the end of + * stream. The server returns `OUT_OF_RANGE` in `AppendRowsResponse` if an + * attempt is made to append to an offset beyond the current end of the stream + * or `ALREADY_EXISTS` if user provides an `offset` that has already been + * written to. User can retry with adjusted offset within the same RPC + * connection. If `offset` is not specified, append happens at the end of the + * stream. + * + * The response contains an optional offset at which the append + * happened. No offset information will be returned for appends to a + * default stream. + * + * Responses are received in the same order in which requests are sent. + * There will be one response for each successful inserted request. Responses + * may optionally embed error information if the originating AppendRequest was + * not successfully processed. + * + * The specifics of when successfully appended data is made visible to the + * table are governed by the type of stream: + * + * * For COMMITTED streams (which includes the default stream), data is + * visible immediately upon successful append. + * + * * For BUFFERED streams, data is made visible via a subsequent `FlushRows` + * rpc which advances a cursor to a newer offset in the stream. + * + * * For PENDING streams, data is not made visible until the stream itself is + * finalized (via the `FinalizeWriteStream` rpc), and the stream is explicitly + * committed via the `BatchCommitWriteStreams` rpc. + * + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return BidiStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function appendRows(array $callOptions = []): BidiStream + { + return $this->startApiCall('AppendRows', null, $callOptions); + } + + /** + * Atomically commits a group of `PENDING` streams that belong to the same + * `parent` table. + * + * Streams must be finalized before commit and cannot be committed multiple + * times. Once a stream is committed, data in the stream becomes available + * for read operations. + * + * The async variant is {@see BigQueryWriteClient::batchCommitWriteStreamsAsync()} + * . + * + * @param BatchCommitWriteStreamsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BatchCommitWriteStreamsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchCommitWriteStreams(BatchCommitWriteStreamsRequest $request, array $callOptions = []): BatchCommitWriteStreamsResponse + { + return $this->startApiCall('BatchCommitWriteStreams', $request, $callOptions)->wait(); + } + + /** + * Creates a write stream to the given table. + * Additionally, every table has a special stream named '_default' + * to which data can be written. This stream doesn't need to be created using + * CreateWriteStream. It is a stream that can be used simultaneously by any + * number of clients. Data written to this stream is considered committed as + * soon as an acknowledgement is received. + * + * The async variant is {@see BigQueryWriteClient::createWriteStreamAsync()} . + * + * @param CreateWriteStreamRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 WriteStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function createWriteStream(CreateWriteStreamRequest $request, array $callOptions = []): WriteStream + { + return $this->startApiCall('CreateWriteStream', $request, $callOptions)->wait(); + } + + /** + * Finalize a write stream so that no new data can be appended to the + * stream. Finalize is not supported on the '_default' stream. + * + * The async variant is {@see BigQueryWriteClient::finalizeWriteStreamAsync()} . + * + * @param FinalizeWriteStreamRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FinalizeWriteStreamResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function finalizeWriteStream(FinalizeWriteStreamRequest $request, array $callOptions = []): FinalizeWriteStreamResponse + { + return $this->startApiCall('FinalizeWriteStream', $request, $callOptions)->wait(); + } + + /** + * Flushes rows to a BUFFERED stream. + * + * If users are appending rows to BUFFERED stream, flush operation is + * required in order for the rows to become available for reading. A + * Flush operation flushes up to any previously flushed offset in a BUFFERED + * stream, to the offset specified in the request. + * + * Flush is not supported on the _default stream, since it is not BUFFERED. + * + * The async variant is {@see BigQueryWriteClient::flushRowsAsync()} . + * + * @param FlushRowsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FlushRowsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function flushRows(FlushRowsRequest $request, array $callOptions = []): FlushRowsResponse + { + return $this->startApiCall('FlushRows', $request, $callOptions)->wait(); + } + + /** + * Gets information about a write stream. + * + * The async variant is {@see BigQueryWriteClient::getWriteStreamAsync()} . + * + * @param GetWriteStreamRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 WriteStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function getWriteStream(GetWriteStreamRequest $request, array $callOptions = []): WriteStream + { + return $this->startApiCall('GetWriteStream', $request, $callOptions)->wait(); + } } diff --git a/Bigtable/VERSION b/Bigtable/VERSION index ac786b645446..5e57fb89558c 100644 --- a/Bigtable/VERSION +++ b/Bigtable/VERSION @@ -1 +1 @@ -1.28.3 +1.29.0 diff --git a/Bigtable/composer.json b/Bigtable/composer.json index ea896a261a2b..da2ce80851c3 100644 --- a/Bigtable/composer.json +++ b/Bigtable/composer.json @@ -5,8 +5,8 @@ "minimum-stability": "stable", "require": { "php": ">=7.4", - "google/gax": "^1.19.1", - "google/cloud-core": "^1.39" + "google/gax": "^1.24.0", + "google/cloud-core": "^1.52.7" }, "require-dev": { "phpunit/phpunit": "^9.0", diff --git a/Bigtable/metadata/Admin/V2/Instance.php b/Bigtable/metadata/Admin/V2/Instance.php index 7d4fa2b47844..0a3f9c79aa42 100644 Binary files a/Bigtable/metadata/Admin/V2/Instance.php and b/Bigtable/metadata/Admin/V2/Instance.php differ diff --git a/Bigtable/src/Admin/V2/AppProfile.php b/Bigtable/src/Admin/V2/AppProfile.php index 4c9fcc1d52a6..645c6ac2a02d 100644 --- a/Bigtable/src/Admin/V2/AppProfile.php +++ b/Bigtable/src/Admin/V2/AppProfile.php @@ -43,6 +43,7 @@ class AppProfile extends \Google\Protobuf\Internal\Message */ private $description = ''; protected $routing_policy; + protected $isolation; /** * Constructor. @@ -68,6 +69,13 @@ class AppProfile extends \Google\Protobuf\Internal\Message * Use a multi-cluster routing policy. * @type \Google\Cloud\Bigtable\Admin\V2\AppProfile\SingleClusterRouting $single_cluster_routing * Use a single-cluster routing policy. + * @type int $priority + * This field has been deprecated in favor of `standard_isolation.priority`. + * If you set this field, `standard_isolation.priority` will be set instead. + * The priority of requests sent using this app profile. + * @type \Google\Cloud\Bigtable\Admin\V2\AppProfile\StandardIsolation $standard_isolation + * The standard options used for isolating this app profile's traffic from + * other use cases. * } */ public function __construct($data = NULL) { @@ -231,6 +239,79 @@ public function setSingleClusterRouting($var) return $this; } + /** + * This field has been deprecated in favor of `standard_isolation.priority`. + * If you set this field, `standard_isolation.priority` will be set instead. + * The priority of requests sent using this app profile. + * + * Generated from protobuf field .google.bigtable.admin.v2.AppProfile.Priority priority = 7 [deprecated = true]; + * @return int + * @deprecated + */ + public function getPriority() + { + @trigger_error('priority is deprecated.', E_USER_DEPRECATED); + return $this->readOneof(7); + } + + public function hasPriority() + { + @trigger_error('priority is deprecated.', E_USER_DEPRECATED); + return $this->hasOneof(7); + } + + /** + * This field has been deprecated in favor of `standard_isolation.priority`. + * If you set this field, `standard_isolation.priority` will be set instead. + * The priority of requests sent using this app profile. + * + * Generated from protobuf field .google.bigtable.admin.v2.AppProfile.Priority priority = 7 [deprecated = true]; + * @param int $var + * @return $this + * @deprecated + */ + public function setPriority($var) + { + @trigger_error('priority is deprecated.', E_USER_DEPRECATED); + GPBUtil::checkEnum($var, \Google\Cloud\Bigtable\Admin\V2\AppProfile\Priority::class); + $this->writeOneof(7, $var); + + return $this; + } + + /** + * The standard options used for isolating this app profile's traffic from + * other use cases. + * + * Generated from protobuf field .google.bigtable.admin.v2.AppProfile.StandardIsolation standard_isolation = 11; + * @return \Google\Cloud\Bigtable\Admin\V2\AppProfile\StandardIsolation|null + */ + public function getStandardIsolation() + { + return $this->readOneof(11); + } + + public function hasStandardIsolation() + { + return $this->hasOneof(11); + } + + /** + * The standard options used for isolating this app profile's traffic from + * other use cases. + * + * Generated from protobuf field .google.bigtable.admin.v2.AppProfile.StandardIsolation standard_isolation = 11; + * @param \Google\Cloud\Bigtable\Admin\V2\AppProfile\StandardIsolation $var + * @return $this + */ + public function setStandardIsolation($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\Admin\V2\AppProfile\StandardIsolation::class); + $this->writeOneof(11, $var); + + return $this; + } + /** * @return string */ @@ -239,5 +320,13 @@ public function getRoutingPolicy() return $this->whichOneof("routing_policy"); } + /** + * @return string + */ + public function getIsolation() + { + return $this->whichOneof("isolation"); + } + } diff --git a/Bigtable/src/Admin/V2/AppProfile/Priority.php b/Bigtable/src/Admin/V2/AppProfile/Priority.php new file mode 100644 index 000000000000..df376e17c64e --- /dev/null +++ b/Bigtable/src/Admin/V2/AppProfile/Priority.php @@ -0,0 +1,67 @@ +google.bigtable.admin.v2.AppProfile.Priority + */ +class Priority +{ + /** + * Default value. Mapped to PRIORITY_HIGH (the legacy behavior) on creation. + * + * Generated from protobuf enum PRIORITY_UNSPECIFIED = 0; + */ + const PRIORITY_UNSPECIFIED = 0; + /** + * Generated from protobuf enum PRIORITY_LOW = 1; + */ + const PRIORITY_LOW = 1; + /** + * Generated from protobuf enum PRIORITY_MEDIUM = 2; + */ + const PRIORITY_MEDIUM = 2; + /** + * Generated from protobuf enum PRIORITY_HIGH = 3; + */ + const PRIORITY_HIGH = 3; + + private static $valueToName = [ + self::PRIORITY_UNSPECIFIED => 'PRIORITY_UNSPECIFIED', + self::PRIORITY_LOW => 'PRIORITY_LOW', + self::PRIORITY_MEDIUM => 'PRIORITY_MEDIUM', + self::PRIORITY_HIGH => 'PRIORITY_HIGH', + ]; + + 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(Priority::class, \Google\Cloud\Bigtable\Admin\V2\AppProfile_Priority::class); + diff --git a/Bigtable/src/Admin/V2/AppProfile/StandardIsolation.php b/Bigtable/src/Admin/V2/AppProfile/StandardIsolation.php new file mode 100644 index 000000000000..42e7b0d4dbb5 --- /dev/null +++ b/Bigtable/src/Admin/V2/AppProfile/StandardIsolation.php @@ -0,0 +1,71 @@ +google.bigtable.admin.v2.AppProfile.StandardIsolation + */ +class StandardIsolation extends \Google\Protobuf\Internal\Message +{ + /** + * The priority of requests sent using this app profile. + * + * Generated from protobuf field .google.bigtable.admin.v2.AppProfile.Priority priority = 1; + */ + private $priority = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $priority + * The priority of requests sent using this app profile. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Bigtable\Admin\V2\Instance::initOnce(); + parent::__construct($data); + } + + /** + * The priority of requests sent using this app profile. + * + * Generated from protobuf field .google.bigtable.admin.v2.AppProfile.Priority priority = 1; + * @return int + */ + public function getPriority() + { + return $this->priority; + } + + /** + * The priority of requests sent using this app profile. + * + * Generated from protobuf field .google.bigtable.admin.v2.AppProfile.Priority priority = 1; + * @param int $var + * @return $this + */ + public function setPriority($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Bigtable\Admin\V2\AppProfile\Priority::class); + $this->priority = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(StandardIsolation::class, \Google\Cloud\Bigtable\Admin\V2\AppProfile_StandardIsolation::class); + diff --git a/Bigtable/src/Admin/V2/AutoscalingTargets.php b/Bigtable/src/Admin/V2/AutoscalingTargets.php index 1772596d015c..7faa6668dd66 100644 --- a/Bigtable/src/Admin/V2/AutoscalingTargets.php +++ b/Bigtable/src/Admin/V2/AutoscalingTargets.php @@ -27,7 +27,7 @@ class AutoscalingTargets extends \Google\Protobuf\Internal\Message /** * The storage utilization that the Autoscaler should be trying to achieve. * This number is limited between 2560 (2.5TiB) and 5120 (5TiB) for a SSD - * cluster and between 8192 (8TiB) and 16384 (16TiB) for an HDD cluster; + * cluster and between 8192 (8TiB) and 16384 (16TiB) for an HDD cluster, * otherwise it will return INVALID_ARGUMENT error. If this value is set to 0, * it will be treated as if it were set to the default value: 2560 for SSD, * 8192 for HDD. @@ -50,7 +50,7 @@ class AutoscalingTargets extends \Google\Protobuf\Internal\Message * @type int $storage_utilization_gib_per_node * The storage utilization that the Autoscaler should be trying to achieve. * This number is limited between 2560 (2.5TiB) and 5120 (5TiB) for a SSD - * cluster and between 8192 (8TiB) and 16384 (16TiB) for an HDD cluster; + * cluster and between 8192 (8TiB) and 16384 (16TiB) for an HDD cluster, * otherwise it will return INVALID_ARGUMENT error. If this value is set to 0, * it will be treated as if it were set to the default value: 2560 for SSD, * 8192 for HDD. @@ -96,7 +96,7 @@ public function setCpuUtilizationPercent($var) /** * The storage utilization that the Autoscaler should be trying to achieve. * This number is limited between 2560 (2.5TiB) and 5120 (5TiB) for a SSD - * cluster and between 8192 (8TiB) and 16384 (16TiB) for an HDD cluster; + * cluster and between 8192 (8TiB) and 16384 (16TiB) for an HDD cluster, * otherwise it will return INVALID_ARGUMENT error. If this value is set to 0, * it will be treated as if it were set to the default value: 2560 for SSD, * 8192 for HDD. @@ -112,7 +112,7 @@ public function getStorageUtilizationGibPerNode() /** * The storage utilization that the Autoscaler should be trying to achieve. * This number is limited between 2560 (2.5TiB) and 5120 (5TiB) for a SSD - * cluster and between 8192 (8TiB) and 16384 (16TiB) for an HDD cluster; + * cluster and between 8192 (8TiB) and 16384 (16TiB) for an HDD cluster, * otherwise it will return INVALID_ARGUMENT error. If this value is set to 0, * it will be treated as if it were set to the default value: 2560 for SSD, * 8192 for HDD. diff --git a/Bigtable/src/Admin/V2/Client/BaseClient/BigtableInstanceAdminBaseClient.php b/Bigtable/src/Admin/V2/Client/BaseClient/BigtableInstanceAdminBaseClient.php deleted file mode 100644 index 02786c351389..000000000000 --- a/Bigtable/src/Admin/V2/Client/BaseClient/BigtableInstanceAdminBaseClient.php +++ /dev/null @@ -1,927 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/bigtable_instance_admin_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/bigtable_instance_admin_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/bigtable_instance_admin_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/bigtable_instance_admin_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a app_profile - * resource. - * - * @param string $project - * @param string $instance - * @param string $appProfile - * - * @return string The formatted app_profile resource. - */ - public static function appProfileName(string $project, string $instance, string $appProfile): string - { - return self::getPathTemplate('appProfile')->render([ - 'project' => $project, - 'instance' => $instance, - 'app_profile' => $appProfile, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a cluster - * resource. - * - * @param string $project - * @param string $instance - * @param string $cluster - * - * @return string The formatted cluster resource. - */ - public static function clusterName(string $project, string $instance, string $cluster): string - { - return self::getPathTemplate('cluster')->render([ - 'project' => $project, - 'instance' => $instance, - 'cluster' => $cluster, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a crypto_key - * resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * @param string $cryptoKey - * - * @return string The formatted crypto_key resource. - */ - public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string - { - return self::getPathTemplate('cryptoKey')->render([ - 'project' => $project, - 'location' => $location, - 'key_ring' => $keyRing, - 'crypto_key' => $cryptoKey, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a instance - * resource. - * - * @param string $project - * @param string $instance - * - * @return string The formatted instance resource. - */ - public static function instanceName(string $project, string $instance): string - { - return self::getPathTemplate('instance')->render([ - 'project' => $project, - 'instance' => $instance, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->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 - * - appProfile: projects/{project}/instances/{instance}/appProfiles/{app_profile} - * - cluster: projects/{project}/instances/{instance}/clusters/{cluster} - * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} - * - instance: projects/{project}/instances/{instance} - * - location: projects/{project}/locations/{location} - * - 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. - */ - public static function parseName(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'bigtableadmin.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates an app profile within an instance. - * - * The async variant is {@see self::createAppProfileAsync()} . - * - * @param CreateAppProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AppProfile - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAppProfile(CreateAppProfileRequest $request, array $callOptions = []): AppProfile - { - return $this->startApiCall('CreateAppProfile', $request, $callOptions)->wait(); - } - - /** - * Creates a cluster within an instance. - * - * Note that exactly one of Cluster.serve_nodes and - * Cluster.cluster_config.cluster_autoscaling_config can be set. If - * serve_nodes is set to non-zero, then the cluster is manually scaled. If - * cluster_config.cluster_autoscaling_config is non-empty, then autoscaling is - * enabled. - * - * The async variant is {@see self::createClusterAsync()} . - * - * @param CreateClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCluster(CreateClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateCluster', $request, $callOptions)->wait(); - } - - /** - * Create an instance within a project. - * - * Note that exactly one of Cluster.serve_nodes and - * Cluster.cluster_config.cluster_autoscaling_config can be set. If - * serve_nodes is set to non-zero, then the cluster is manually scaled. If - * cluster_config.cluster_autoscaling_config is non-empty, then autoscaling is - * enabled. - * - * The async variant is {@see self::createInstanceAsync()} . - * - * @param CreateInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createInstance(CreateInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateInstance', $request, $callOptions)->wait(); - } - - /** - * Deletes an app profile from an instance. - * - * The async variant is {@see self::deleteAppProfileAsync()} . - * - * @param DeleteAppProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAppProfile(DeleteAppProfileRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteAppProfile', $request, $callOptions)->wait(); - } - - /** - * Deletes a cluster from an instance. - * - * The async variant is {@see self::deleteClusterAsync()} . - * - * @param DeleteClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteCluster(DeleteClusterRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteCluster', $request, $callOptions)->wait(); - } - - /** - * Delete an instance from a project. - * - * The async variant is {@see self::deleteInstanceAsync()} . - * - * @param DeleteInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); - } - - /** - * Gets information about an app profile. - * - * The async variant is {@see self::getAppProfileAsync()} . - * - * @param GetAppProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AppProfile - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAppProfile(GetAppProfileRequest $request, array $callOptions = []): AppProfile - { - return $this->startApiCall('GetAppProfile', $request, $callOptions)->wait(); - } - - /** - * Gets information about a cluster. - * - * The async variant is {@see self::getClusterAsync()} . - * - * @param GetClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Cluster - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCluster(GetClusterRequest $request, array $callOptions = []): Cluster - { - return $this->startApiCall('GetCluster', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for an instance resource. Returns an empty - * policy if an instance exists but does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets information about an instance. - * - * The async variant is {@see self::getInstanceAsync()} . - * - * @param GetInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Instance - * - * @throws ApiException Thrown if the API call fails. - */ - public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance - { - return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); - } - - /** - * Lists information about app profiles in an instance. - * - * The async variant is {@see self::listAppProfilesAsync()} . - * - * @param ListAppProfilesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAppProfiles(ListAppProfilesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAppProfiles', $request, $callOptions); - } - - /** - * Lists information about clusters in an instance. - * - * The async variant is {@see self::listClustersAsync()} . - * - * @param ListClustersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ListClustersResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listClusters(ListClustersRequest $request, array $callOptions = []): ListClustersResponse - { - return $this->startApiCall('ListClusters', $request, $callOptions)->wait(); - } - - /** - * Lists hot tablets in a cluster, within the time range provided. Hot - * tablets are ordered based on CPU usage. - * - * The async variant is {@see self::listHotTabletsAsync()} . - * - * @param ListHotTabletsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listHotTablets(ListHotTabletsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListHotTablets', $request, $callOptions); - } - - /** - * Lists information about instances in a project. - * - * The async variant is {@see self::listInstancesAsync()} . - * - * @param ListInstancesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ListInstancesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listInstances(ListInstancesRequest $request, array $callOptions = []): ListInstancesResponse - { - return $this->startApiCall('ListInstances', $request, $callOptions)->wait(); - } - - /** - * Partially updates a cluster within a project. This method is the preferred - * way to update a Cluster. - * - * To enable and update autoscaling, set - * cluster_config.cluster_autoscaling_config. When autoscaling is enabled, - * serve_nodes is treated as an OUTPUT_ONLY field, meaning that updates to it - * are ignored. Note that an update cannot simultaneously set serve_nodes to - * non-zero and cluster_config.cluster_autoscaling_config to non-empty, and - * also specify both in the update_mask. - * - * To disable autoscaling, clear cluster_config.cluster_autoscaling_config, - * and explicitly set a serve_node count via the update_mask. - * - * The async variant is {@see self::partialUpdateClusterAsync()} . - * - * @param PartialUpdateClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function partialUpdateCluster(PartialUpdateClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('PartialUpdateCluster', $request, $callOptions)->wait(); - } - - /** - * Partially updates an instance within a project. This method can modify all - * fields of an Instance and is the preferred way to update an Instance. - * - * The async variant is {@see self::partialUpdateInstanceAsync()} . - * - * @param PartialUpdateInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function partialUpdateInstance(PartialUpdateInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('PartialUpdateInstance', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on an instance resource. Replaces any - * existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that the caller has on the specified instance resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Updates an app profile within an instance. - * - * The async variant is {@see self::updateAppProfileAsync()} . - * - * @param UpdateAppProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAppProfile(UpdateAppProfileRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateAppProfile', $request, $callOptions)->wait(); - } - - /** - * Updates a cluster within an instance. - * - * Note that UpdateCluster does not support updating - * cluster_config.cluster_autoscaling_config. In order to update it, you - * must use PartialUpdateCluster. - * - * The async variant is {@see self::updateClusterAsync()} . - * - * @param Cluster $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCluster(Cluster $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateCluster', $request, $callOptions)->wait(); - } - - /** - * Updates an instance within a project. This method updates only the display - * name and type for an Instance. To update other Instance properties, such as - * labels, use PartialUpdateInstance. - * - * The async variant is {@see self::updateInstanceAsync()} . - * - * @param Instance $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Instance - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateInstance(Instance $request, array $callOptions = []): Instance - { - return $this->startApiCall('UpdateInstance', $request, $callOptions)->wait(); - } -} diff --git a/Bigtable/src/Admin/V2/Client/BaseClient/BigtableTableAdminBaseClient.php b/Bigtable/src/Admin/V2/Client/BaseClient/BigtableTableAdminBaseClient.php deleted file mode 100644 index 7a44865f3144..000000000000 --- a/Bigtable/src/Admin/V2/Client/BaseClient/BigtableTableAdminBaseClient.php +++ /dev/null @@ -1,1076 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/bigtable_table_admin_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/bigtable_table_admin_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/bigtable_table_admin_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/bigtable_table_admin_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a backup - * resource. - * - * @param string $project - * @param string $instance - * @param string $cluster - * @param string $backup - * - * @return string The formatted backup resource. - */ - public static function backupName(string $project, string $instance, string $cluster, string $backup): string - { - return self::getPathTemplate('backup')->render([ - 'project' => $project, - 'instance' => $instance, - 'cluster' => $cluster, - 'backup' => $backup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a cluster - * resource. - * - * @param string $project - * @param string $instance - * @param string $cluster - * - * @return string The formatted cluster resource. - */ - public static function clusterName(string $project, string $instance, string $cluster): string - { - return self::getPathTemplate('cluster')->render([ - 'project' => $project, - 'instance' => $instance, - 'cluster' => $cluster, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * crypto_key_version resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * @param string $cryptoKey - * @param string $cryptoKeyVersion - * - * @return string The formatted crypto_key_version resource. - */ - public static function cryptoKeyVersionName(string $project, string $location, string $keyRing, string $cryptoKey, string $cryptoKeyVersion): string - { - return self::getPathTemplate('cryptoKeyVersion')->render([ - 'project' => $project, - 'location' => $location, - 'key_ring' => $keyRing, - 'crypto_key' => $cryptoKey, - 'crypto_key_version' => $cryptoKeyVersion, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a instance - * resource. - * - * @param string $project - * @param string $instance - * - * @return string The formatted instance resource. - */ - public static function instanceName(string $project, string $instance): string - { - return self::getPathTemplate('instance')->render([ - 'project' => $project, - 'instance' => $instance, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a snapshot - * resource. - * - * @param string $project - * @param string $instance - * @param string $cluster - * @param string $snapshot - * - * @return string The formatted snapshot resource. - */ - public static function snapshotName(string $project, string $instance, string $cluster, string $snapshot): string - { - return self::getPathTemplate('snapshot')->render([ - 'project' => $project, - 'instance' => $instance, - 'cluster' => $cluster, - 'snapshot' => $snapshot, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a table - * resource. - * - * @param string $project - * @param string $instance - * @param string $table - * - * @return string The formatted table resource. - */ - public static function tableName(string $project, string $instance, string $table): string - { - return self::getPathTemplate('table')->render([ - 'project' => $project, - 'instance' => $instance, - 'table' => $table, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - backup: projects/{project}/instances/{instance}/clusters/{cluster}/backups/{backup} - * - cluster: projects/{project}/instances/{instance}/clusters/{cluster} - * - cryptoKeyVersion: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version} - * - instance: projects/{project}/instances/{instance} - * - snapshot: projects/{project}/instances/{instance}/clusters/{cluster}/snapshots/{snapshot} - * - table: projects/{project}/instances/{instance}/tables/{table} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'bigtableadmin.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Checks replication consistency based on a consistency token, that is, if - * replication has caught up based on the conditions specified in the token - * and the check request. - * - * The async variant is {@see self::checkConsistencyAsync()} . - * - * @param CheckConsistencyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CheckConsistencyResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function checkConsistency(CheckConsistencyRequest $request, array $callOptions = []): CheckConsistencyResponse - { - return $this->startApiCall('CheckConsistency', $request, $callOptions)->wait(); - } - - /** - * Copy a Cloud Bigtable backup to a new backup in the destination cluster - * located in the destination instance and project. - * - * The async variant is {@see self::copyBackupAsync()} . - * - * @param CopyBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function copyBackup(CopyBackupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CopyBackup', $request, $callOptions)->wait(); - } - - /** - * Starts creating a new Cloud Bigtable Backup. The returned backup - * [long-running operation][google.longrunning.Operation] can be used to - * track creation of the backup. The - * [metadata][google.longrunning.Operation.metadata] field type is - * [CreateBackupMetadata][google.bigtable.admin.v2.CreateBackupMetadata]. The - * [response][google.longrunning.Operation.response] field type is - * [Backup][google.bigtable.admin.v2.Backup], if successful. Cancelling the - * returned operation will stop the creation and delete the backup. - * - * The async variant is {@see self::createBackupAsync()} . - * - * @param CreateBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createBackup(CreateBackupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateBackup', $request, $callOptions)->wait(); - } - - /** - * Creates a new table in the specified instance. - * The table can be created with a full set of initial column families, - * specified in the request. - * - * The async variant is {@see self::createTableAsync()} . - * - * @param CreateTableRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Table - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTable(CreateTableRequest $request, array $callOptions = []): Table - { - return $this->startApiCall('CreateTable', $request, $callOptions)->wait(); - } - - /** - * Creates a new table from the specified snapshot. The target table must - * not exist. The snapshot and the table must be in the same instance. - * - * Note: This is a private alpha release of Cloud Bigtable snapshots. This - * feature is not currently available to most Cloud Bigtable customers. This - * feature might be changed in backward-incompatible ways and is not - * recommended for production use. It is not subject to any SLA or deprecation - * policy. - * - * The async variant is {@see self::createTableFromSnapshotAsync()} . - * - * @param CreateTableFromSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTableFromSnapshot(CreateTableFromSnapshotRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateTableFromSnapshot', $request, $callOptions)->wait(); - } - - /** - * Deletes a pending or completed Cloud Bigtable backup. - * - * The async variant is {@see self::deleteBackupAsync()} . - * - * @param DeleteBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteBackup(DeleteBackupRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteBackup', $request, $callOptions)->wait(); - } - - /** - * Permanently deletes the specified snapshot. - * - * Note: This is a private alpha release of Cloud Bigtable snapshots. This - * feature is not currently available to most Cloud Bigtable customers. This - * feature might be changed in backward-incompatible ways and is not - * recommended for production use. It is not subject to any SLA or deprecation - * policy. - * - * The async variant is {@see self::deleteSnapshotAsync()} . - * - * @param DeleteSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSnapshot(DeleteSnapshotRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteSnapshot', $request, $callOptions)->wait(); - } - - /** - * Permanently deletes a specified table and all of its data. - * - * The async variant is {@see self::deleteTableAsync()} . - * - * @param DeleteTableRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTable(DeleteTableRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteTable', $request, $callOptions)->wait(); - } - - /** - * Permanently drop/delete a row range from a specified table. The request can - * specify whether to delete all rows in a table, or only those that match a - * particular prefix. - * - * The async variant is {@see self::dropRowRangeAsync()} . - * - * @param DropRowRangeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function dropRowRange(DropRowRangeRequest $request, array $callOptions = []): void - { - $this->startApiCall('DropRowRange', $request, $callOptions)->wait(); - } - - /** - * Generates a consistency token for a Table, which can be used in - * CheckConsistency to check whether mutations to the table that finished - * before this call started have been replicated. The tokens will be available - * for 90 days. - * - * The async variant is {@see self::generateConsistencyTokenAsync()} . - * - * @param GenerateConsistencyTokenRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GenerateConsistencyTokenResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function generateConsistencyToken(GenerateConsistencyTokenRequest $request, array $callOptions = []): GenerateConsistencyTokenResponse - { - return $this->startApiCall('GenerateConsistencyToken', $request, $callOptions)->wait(); - } - - /** - * Gets metadata on a pending or completed Cloud Bigtable Backup. - * - * The async variant is {@see self::getBackupAsync()} . - * - * @param GetBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Backup - * - * @throws ApiException Thrown if the API call fails. - */ - public function getBackup(GetBackupRequest $request, array $callOptions = []): Backup - { - return $this->startApiCall('GetBackup', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a Table or Backup resource. - * Returns an empty policy if the resource exists but does not have a policy - * set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets metadata information about the specified snapshot. - * - * Note: This is a private alpha release of Cloud Bigtable snapshots. This - * feature is not currently available to most Cloud Bigtable customers. This - * feature might be changed in backward-incompatible ways and is not - * recommended for production use. It is not subject to any SLA or deprecation - * policy. - * - * The async variant is {@see self::getSnapshotAsync()} . - * - * @param GetSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Snapshot - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSnapshot(GetSnapshotRequest $request, array $callOptions = []): Snapshot - { - return $this->startApiCall('GetSnapshot', $request, $callOptions)->wait(); - } - - /** - * Gets metadata information about the specified table. - * - * The async variant is {@see self::getTableAsync()} . - * - * @param GetTableRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Table - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTable(GetTableRequest $request, array $callOptions = []): Table - { - return $this->startApiCall('GetTable', $request, $callOptions)->wait(); - } - - /** - * Lists Cloud Bigtable backups. Returns both completed and pending - * backups. - * - * The async variant is {@see self::listBackupsAsync()} . - * - * @param ListBackupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listBackups(ListBackupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListBackups', $request, $callOptions); - } - - /** - * Lists all snapshots associated with the specified cluster. - * - * Note: This is a private alpha release of Cloud Bigtable snapshots. This - * feature is not currently available to most Cloud Bigtable customers. This - * feature might be changed in backward-incompatible ways and is not - * recommended for production use. It is not subject to any SLA or deprecation - * policy. - * - * The async variant is {@see self::listSnapshotsAsync()} . - * - * @param ListSnapshotsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSnapshots(ListSnapshotsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSnapshots', $request, $callOptions); - } - - /** - * Lists all tables served from a specified instance. - * - * The async variant is {@see self::listTablesAsync()} . - * - * @param ListTablesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTables(ListTablesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTables', $request, $callOptions); - } - - /** - * Performs a series of column family modifications on the specified table. - * Either all or none of the modifications will occur before this method - * returns, but data requests received prior to that point may see a table - * where only some modifications have taken effect. - * - * The async variant is {@see self::modifyColumnFamiliesAsync()} . - * - * @param ModifyColumnFamiliesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Table - * - * @throws ApiException Thrown if the API call fails. - */ - public function modifyColumnFamilies(ModifyColumnFamiliesRequest $request, array $callOptions = []): Table - { - return $this->startApiCall('ModifyColumnFamilies', $request, $callOptions)->wait(); - } - - /** - * Create a new table by restoring from a completed backup. The - * returned table [long-running operation][google.longrunning.Operation] can - * be used to track the progress of the operation, and to cancel it. The - * [metadata][google.longrunning.Operation.metadata] field type is - * [RestoreTableMetadata][google.bigtable.admin.RestoreTableMetadata]. The - * [response][google.longrunning.Operation.response] type is - * [Table][google.bigtable.admin.v2.Table], if successful. - * - * The async variant is {@see self::restoreTableAsync()} . - * - * @param RestoreTableRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function restoreTable(RestoreTableRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RestoreTable', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on a Table or Backup resource. - * Replaces any existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Creates a new snapshot in the specified cluster from the specified - * source table. The cluster and the table must be in the same instance. - * - * Note: This is a private alpha release of Cloud Bigtable snapshots. This - * feature is not currently available to most Cloud Bigtable customers. This - * feature might be changed in backward-incompatible ways and is not - * recommended for production use. It is not subject to any SLA or deprecation - * policy. - * - * The async variant is {@see self::snapshotTableAsync()} . - * - * @param SnapshotTableRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function snapshotTable(SnapshotTableRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SnapshotTable', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that the caller has on the specified Table or Backup - * resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Restores a specified table which was accidentally deleted. - * - * The async variant is {@see self::undeleteTableAsync()} . - * - * @param UndeleteTableRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function undeleteTable(UndeleteTableRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UndeleteTable', $request, $callOptions)->wait(); - } - - /** - * Updates a pending or completed Cloud Bigtable Backup. - * - * The async variant is {@see self::updateBackupAsync()} . - * - * @param UpdateBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Backup - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateBackup(UpdateBackupRequest $request, array $callOptions = []): Backup - { - return $this->startApiCall('UpdateBackup', $request, $callOptions)->wait(); - } - - /** - * Updates a specified table. - * - * The async variant is {@see self::updateTableAsync()} . - * - * @param UpdateTableRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateTable(UpdateTableRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateTable', $request, $callOptions)->wait(); - } -} diff --git a/Bigtable/src/Admin/V2/Client/BigtableInstanceAdminClient.php b/Bigtable/src/Admin/V2/Client/BigtableInstanceAdminClient.php index 266de39d9767..ec9ddd3d659a 100644 --- a/Bigtable/src/Admin/V2/Client/BigtableInstanceAdminClient.php +++ b/Bigtable/src/Admin/V2/Client/BigtableInstanceAdminClient.php @@ -24,17 +24,909 @@ namespace Google\Cloud\Bigtable\Admin\V2\Client; -use Google\Cloud\Bigtable\Admin\V2\Client\BaseClient\BigtableInstanceAdminBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Bigtable\Admin\V2\AppProfile; +use Google\Cloud\Bigtable\Admin\V2\Cluster; +use Google\Cloud\Bigtable\Admin\V2\CreateAppProfileRequest; +use Google\Cloud\Bigtable\Admin\V2\CreateClusterRequest; +use Google\Cloud\Bigtable\Admin\V2\CreateInstanceRequest; +use Google\Cloud\Bigtable\Admin\V2\DeleteAppProfileRequest; +use Google\Cloud\Bigtable\Admin\V2\DeleteClusterRequest; +use Google\Cloud\Bigtable\Admin\V2\DeleteInstanceRequest; +use Google\Cloud\Bigtable\Admin\V2\GetAppProfileRequest; +use Google\Cloud\Bigtable\Admin\V2\GetClusterRequest; +use Google\Cloud\Bigtable\Admin\V2\GetInstanceRequest; +use Google\Cloud\Bigtable\Admin\V2\Instance; +use Google\Cloud\Bigtable\Admin\V2\ListAppProfilesRequest; +use Google\Cloud\Bigtable\Admin\V2\ListClustersRequest; +use Google\Cloud\Bigtable\Admin\V2\ListClustersResponse; +use Google\Cloud\Bigtable\Admin\V2\ListHotTabletsRequest; +use Google\Cloud\Bigtable\Admin\V2\ListInstancesRequest; +use Google\Cloud\Bigtable\Admin\V2\ListInstancesResponse; +use Google\Cloud\Bigtable\Admin\V2\PartialUpdateClusterRequest; +use Google\Cloud\Bigtable\Admin\V2\PartialUpdateInstanceRequest; +use Google\Cloud\Bigtable\Admin\V2\UpdateAppProfileRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for creating, configuring, and deleting Cloud Bigtable Instances and + * Clusters. Provides access to the Instance and Cluster schemas only, not the + * tables' metadata or data stored in those tables. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createAppProfileAsync(CreateAppProfileRequest $request, array $optionalArgs = []) + * @method PromiseInterface createClusterAsync(CreateClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface createInstanceAsync(CreateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAppProfileAsync(DeleteAppProfileRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteClusterAsync(DeleteClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteInstanceAsync(DeleteInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAppProfileAsync(GetAppProfileRequest $request, array $optionalArgs = []) + * @method PromiseInterface getClusterAsync(GetClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInstanceAsync(GetInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAppProfilesAsync(ListAppProfilesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listClustersAsync(ListClustersRequest $request, array $optionalArgs = []) + * @method PromiseInterface listHotTabletsAsync(ListHotTabletsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInstancesAsync(ListInstancesRequest $request, array $optionalArgs = []) + * @method PromiseInterface partialUpdateClusterAsync(PartialUpdateClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface partialUpdateInstanceAsync(PartialUpdateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAppProfileAsync(UpdateAppProfileRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateClusterAsync(Cluster $request, array $optionalArgs = []) + * @method PromiseInterface updateInstanceAsync(Instance $request, array $optionalArgs = []) */ -final class BigtableInstanceAdminClient extends BigtableInstanceAdminBaseClient +final class BigtableInstanceAdminClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see BigtableInstanceAdminBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.bigtable.admin.v2.BigtableInstanceAdmin'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'bigtableadmin.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/bigtable.admin', + 'https://www.googleapis.com/auth/bigtable.admin.cluster', + 'https://www.googleapis.com/auth/bigtable.admin.instance', + 'https://www.googleapis.com/auth/cloud-bigtable.admin', + 'https://www.googleapis.com/auth/cloud-bigtable.admin.cluster', + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/bigtable_instance_admin_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/bigtable_instance_admin_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/bigtable_instance_admin_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/bigtable_instance_admin_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a app_profile + * resource. + * + * @param string $project + * @param string $instance + * @param string $appProfile + * + * @return string The formatted app_profile resource. + */ + public static function appProfileName(string $project, string $instance, string $appProfile): string + { + return self::getPathTemplate('appProfile')->render([ + 'project' => $project, + 'instance' => $instance, + 'app_profile' => $appProfile, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a cluster + * resource. + * + * @param string $project + * @param string $instance + * @param string $cluster + * + * @return string The formatted cluster resource. + */ + public static function clusterName(string $project, string $instance, string $cluster): string + { + return self::getPathTemplate('cluster')->render([ + 'project' => $project, + 'instance' => $instance, + 'cluster' => $cluster, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a crypto_key + * resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * + * @return string The formatted crypto_key resource. + */ + public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string + { + return self::getPathTemplate('cryptoKey')->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'crypto_key' => $cryptoKey, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a instance + * resource. + * + * @param string $project + * @param string $instance + * + * @return string The formatted instance resource. + */ + public static function instanceName(string $project, string $instance): string + { + return self::getPathTemplate('instance')->render([ + 'project' => $project, + 'instance' => $instance, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->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 + * - appProfile: projects/{project}/instances/{instance}/appProfiles/{app_profile} + * - cluster: projects/{project}/instances/{instance}/clusters/{cluster} + * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} + * - instance: projects/{project}/instances/{instance} + * - location: projects/{project}/locations/{location} + * - 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. + */ + public static function parseName(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'bigtableadmin.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates an app profile within an instance. + * + * The async variant is {@see BigtableInstanceAdminClient::createAppProfileAsync()} + * . + * + * @param CreateAppProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AppProfile + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAppProfile(CreateAppProfileRequest $request, array $callOptions = []): AppProfile + { + return $this->startApiCall('CreateAppProfile', $request, $callOptions)->wait(); + } + + /** + * Creates a cluster within an instance. + * + * Note that exactly one of Cluster.serve_nodes and + * Cluster.cluster_config.cluster_autoscaling_config can be set. If + * serve_nodes is set to non-zero, then the cluster is manually scaled. If + * cluster_config.cluster_autoscaling_config is non-empty, then autoscaling is + * enabled. + * + * The async variant is {@see BigtableInstanceAdminClient::createClusterAsync()} . + * + * @param CreateClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCluster(CreateClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateCluster', $request, $callOptions)->wait(); + } + + /** + * Create an instance within a project. + * + * Note that exactly one of Cluster.serve_nodes and + * Cluster.cluster_config.cluster_autoscaling_config can be set. If + * serve_nodes is set to non-zero, then the cluster is manually scaled. If + * cluster_config.cluster_autoscaling_config is non-empty, then autoscaling is + * enabled. + * + * The async variant is {@see BigtableInstanceAdminClient::createInstanceAsync()} . + * + * @param CreateInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createInstance(CreateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateInstance', $request, $callOptions)->wait(); + } + + /** + * Deletes an app profile from an instance. + * + * The async variant is {@see BigtableInstanceAdminClient::deleteAppProfileAsync()} + * . + * + * @param DeleteAppProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAppProfile(DeleteAppProfileRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteAppProfile', $request, $callOptions)->wait(); + } + + /** + * Deletes a cluster from an instance. + * + * The async variant is {@see BigtableInstanceAdminClient::deleteClusterAsync()} . + * + * @param DeleteClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteCluster(DeleteClusterRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteCluster', $request, $callOptions)->wait(); + } + + /** + * Delete an instance from a project. + * + * The async variant is {@see BigtableInstanceAdminClient::deleteInstanceAsync()} . + * + * @param DeleteInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); + } + + /** + * Gets information about an app profile. + * + * The async variant is {@see BigtableInstanceAdminClient::getAppProfileAsync()} . + * + * @param GetAppProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AppProfile + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAppProfile(GetAppProfileRequest $request, array $callOptions = []): AppProfile + { + return $this->startApiCall('GetAppProfile', $request, $callOptions)->wait(); + } + + /** + * Gets information about a cluster. + * + * The async variant is {@see BigtableInstanceAdminClient::getClusterAsync()} . + * + * @param GetClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Cluster + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCluster(GetClusterRequest $request, array $callOptions = []): Cluster + { + return $this->startApiCall('GetCluster', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for an instance resource. Returns an empty + * policy if an instance exists but does not have a policy set. + * + * The async variant is {@see BigtableInstanceAdminClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets information about an instance. + * + * The async variant is {@see BigtableInstanceAdminClient::getInstanceAsync()} . + * + * @param GetInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Instance + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance + { + return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); + } + + /** + * Lists information about app profiles in an instance. + * + * The async variant is {@see BigtableInstanceAdminClient::listAppProfilesAsync()} + * . + * + * @param ListAppProfilesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAppProfiles(ListAppProfilesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAppProfiles', $request, $callOptions); + } + + /** + * Lists information about clusters in an instance. + * + * The async variant is {@see BigtableInstanceAdminClient::listClustersAsync()} . + * + * @param ListClustersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ListClustersResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listClusters(ListClustersRequest $request, array $callOptions = []): ListClustersResponse + { + return $this->startApiCall('ListClusters', $request, $callOptions)->wait(); + } + + /** + * Lists hot tablets in a cluster, within the time range provided. Hot + * tablets are ordered based on CPU usage. + * + * The async variant is {@see BigtableInstanceAdminClient::listHotTabletsAsync()} . + * + * @param ListHotTabletsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listHotTablets(ListHotTabletsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListHotTablets', $request, $callOptions); + } + + /** + * Lists information about instances in a project. + * + * The async variant is {@see BigtableInstanceAdminClient::listInstancesAsync()} . + * + * @param ListInstancesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ListInstancesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInstances(ListInstancesRequest $request, array $callOptions = []): ListInstancesResponse + { + return $this->startApiCall('ListInstances', $request, $callOptions)->wait(); + } + + /** + * Partially updates a cluster within a project. This method is the preferred + * way to update a Cluster. + * + * To enable and update autoscaling, set + * cluster_config.cluster_autoscaling_config. When autoscaling is enabled, + * serve_nodes is treated as an OUTPUT_ONLY field, meaning that updates to it + * are ignored. Note that an update cannot simultaneously set serve_nodes to + * non-zero and cluster_config.cluster_autoscaling_config to non-empty, and + * also specify both in the update_mask. + * + * To disable autoscaling, clear cluster_config.cluster_autoscaling_config, + * and explicitly set a serve_node count via the update_mask. + * + * The async variant is + * {@see BigtableInstanceAdminClient::partialUpdateClusterAsync()} . + * + * @param PartialUpdateClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function partialUpdateCluster(PartialUpdateClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('PartialUpdateCluster', $request, $callOptions)->wait(); + } + + /** + * Partially updates an instance within a project. This method can modify all + * fields of an Instance and is the preferred way to update an Instance. + * + * The async variant is + * {@see BigtableInstanceAdminClient::partialUpdateInstanceAsync()} . + * + * @param PartialUpdateInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function partialUpdateInstance(PartialUpdateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('PartialUpdateInstance', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on an instance resource. Replaces any + * existing policy. + * + * The async variant is {@see BigtableInstanceAdminClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that the caller has on the specified instance resource. + * + * The async variant is + * {@see BigtableInstanceAdminClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates an app profile within an instance. + * + * The async variant is {@see BigtableInstanceAdminClient::updateAppProfileAsync()} + * . + * + * @param UpdateAppProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAppProfile(UpdateAppProfileRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateAppProfile', $request, $callOptions)->wait(); + } + + /** + * Updates a cluster within an instance. + * + * Note that UpdateCluster does not support updating + * cluster_config.cluster_autoscaling_config. In order to update it, you + * must use PartialUpdateCluster. + * + * The async variant is {@see BigtableInstanceAdminClient::updateClusterAsync()} . + * + * @param Cluster $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCluster(Cluster $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateCluster', $request, $callOptions)->wait(); + } + + /** + * Updates an instance within a project. This method updates only the display + * name and type for an Instance. To update other Instance properties, such as + * labels, use PartialUpdateInstance. + * + * The async variant is {@see BigtableInstanceAdminClient::updateInstanceAsync()} . + * + * @param Instance $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Instance + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateInstance(Instance $request, array $callOptions = []): Instance + { + return $this->startApiCall('UpdateInstance', $request, $callOptions)->wait(); + } } diff --git a/Bigtable/src/Admin/V2/Client/BigtableTableAdminClient.php b/Bigtable/src/Admin/V2/Client/BigtableTableAdminClient.php index 39b138c69690..d98cfe11065c 100644 --- a/Bigtable/src/Admin/V2/Client/BigtableTableAdminClient.php +++ b/Bigtable/src/Admin/V2/Client/BigtableTableAdminClient.php @@ -24,17 +24,1055 @@ namespace Google\Cloud\Bigtable\Admin\V2\Client; -use Google\Cloud\Bigtable\Admin\V2\Client\BaseClient\BigtableTableAdminBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Bigtable\Admin\V2\Backup; +use Google\Cloud\Bigtable\Admin\V2\CheckConsistencyRequest; +use Google\Cloud\Bigtable\Admin\V2\CheckConsistencyResponse; +use Google\Cloud\Bigtable\Admin\V2\CopyBackupRequest; +use Google\Cloud\Bigtable\Admin\V2\CreateBackupMetadata; +use Google\Cloud\Bigtable\Admin\V2\CreateBackupRequest; +use Google\Cloud\Bigtable\Admin\V2\CreateTableFromSnapshotRequest; +use Google\Cloud\Bigtable\Admin\V2\CreateTableRequest; +use Google\Cloud\Bigtable\Admin\V2\DeleteBackupRequest; +use Google\Cloud\Bigtable\Admin\V2\DeleteSnapshotRequest; +use Google\Cloud\Bigtable\Admin\V2\DeleteTableRequest; +use Google\Cloud\Bigtable\Admin\V2\DropRowRangeRequest; +use Google\Cloud\Bigtable\Admin\V2\GenerateConsistencyTokenRequest; +use Google\Cloud\Bigtable\Admin\V2\GenerateConsistencyTokenResponse; +use Google\Cloud\Bigtable\Admin\V2\GetBackupRequest; +use Google\Cloud\Bigtable\Admin\V2\GetSnapshotRequest; +use Google\Cloud\Bigtable\Admin\V2\GetTableRequest; +use Google\Cloud\Bigtable\Admin\V2\ListBackupsRequest; +use Google\Cloud\Bigtable\Admin\V2\ListSnapshotsRequest; +use Google\Cloud\Bigtable\Admin\V2\ListTablesRequest; +use Google\Cloud\Bigtable\Admin\V2\ModifyColumnFamiliesRequest; +use Google\Cloud\Bigtable\Admin\V2\RestoreTableMetadata; +use Google\Cloud\Bigtable\Admin\V2\RestoreTableRequest; +use Google\Cloud\Bigtable\Admin\V2\Snapshot; +use Google\Cloud\Bigtable\Admin\V2\SnapshotTableRequest; +use Google\Cloud\Bigtable\Admin\V2\Table; +use Google\Cloud\Bigtable\Admin\V2\UndeleteTableRequest; +use Google\Cloud\Bigtable\Admin\V2\UpdateBackupRequest; +use Google\Cloud\Bigtable\Admin\V2\UpdateTableRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for creating, configuring, and deleting Cloud Bigtable tables. * - * This class is currently experimental and may be subject to changes. + * + * Provides access to the table schemas only, not the data stored within + * the tables. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface checkConsistencyAsync(CheckConsistencyRequest $request, array $optionalArgs = []) + * @method PromiseInterface copyBackupAsync(CopyBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface createBackupAsync(CreateBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface createTableAsync(CreateTableRequest $request, array $optionalArgs = []) + * @method PromiseInterface createTableFromSnapshotAsync(CreateTableFromSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteBackupAsync(DeleteBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSnapshotAsync(DeleteSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTableAsync(DeleteTableRequest $request, array $optionalArgs = []) + * @method PromiseInterface dropRowRangeAsync(DropRowRangeRequest $request, array $optionalArgs = []) + * @method PromiseInterface generateConsistencyTokenAsync(GenerateConsistencyTokenRequest $request, array $optionalArgs = []) + * @method PromiseInterface getBackupAsync(GetBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSnapshotAsync(GetSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTableAsync(GetTableRequest $request, array $optionalArgs = []) + * @method PromiseInterface listBackupsAsync(ListBackupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSnapshotsAsync(ListSnapshotsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTablesAsync(ListTablesRequest $request, array $optionalArgs = []) + * @method PromiseInterface modifyColumnFamiliesAsync(ModifyColumnFamiliesRequest $request, array $optionalArgs = []) + * @method PromiseInterface restoreTableAsync(RestoreTableRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface snapshotTableAsync(SnapshotTableRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface undeleteTableAsync(UndeleteTableRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateBackupAsync(UpdateBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateTableAsync(UpdateTableRequest $request, array $optionalArgs = []) */ -final class BigtableTableAdminClient extends BigtableTableAdminBaseClient +final class BigtableTableAdminClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see BigtableTableAdminBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.bigtable.admin.v2.BigtableTableAdmin'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'bigtableadmin.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/bigtable.admin', + 'https://www.googleapis.com/auth/bigtable.admin.table', + 'https://www.googleapis.com/auth/cloud-bigtable.admin', + 'https://www.googleapis.com/auth/cloud-bigtable.admin.table', + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/bigtable_table_admin_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/bigtable_table_admin_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/bigtable_table_admin_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/bigtable_table_admin_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a backup + * resource. + * + * @param string $project + * @param string $instance + * @param string $cluster + * @param string $backup + * + * @return string The formatted backup resource. + */ + public static function backupName(string $project, string $instance, string $cluster, string $backup): string + { + return self::getPathTemplate('backup')->render([ + 'project' => $project, + 'instance' => $instance, + 'cluster' => $cluster, + 'backup' => $backup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a cluster + * resource. + * + * @param string $project + * @param string $instance + * @param string $cluster + * + * @return string The formatted cluster resource. + */ + public static function clusterName(string $project, string $instance, string $cluster): string + { + return self::getPathTemplate('cluster')->render([ + 'project' => $project, + 'instance' => $instance, + 'cluster' => $cluster, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * crypto_key_version resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * @param string $cryptoKeyVersion + * + * @return string The formatted crypto_key_version resource. + */ + public static function cryptoKeyVersionName(string $project, string $location, string $keyRing, string $cryptoKey, string $cryptoKeyVersion): string + { + return self::getPathTemplate('cryptoKeyVersion')->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'crypto_key' => $cryptoKey, + 'crypto_key_version' => $cryptoKeyVersion, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a instance + * resource. + * + * @param string $project + * @param string $instance + * + * @return string The formatted instance resource. + */ + public static function instanceName(string $project, string $instance): string + { + return self::getPathTemplate('instance')->render([ + 'project' => $project, + 'instance' => $instance, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a snapshot + * resource. + * + * @param string $project + * @param string $instance + * @param string $cluster + * @param string $snapshot + * + * @return string The formatted snapshot resource. + */ + public static function snapshotName(string $project, string $instance, string $cluster, string $snapshot): string + { + return self::getPathTemplate('snapshot')->render([ + 'project' => $project, + 'instance' => $instance, + 'cluster' => $cluster, + 'snapshot' => $snapshot, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a table + * resource. + * + * @param string $project + * @param string $instance + * @param string $table + * + * @return string The formatted table resource. + */ + public static function tableName(string $project, string $instance, string $table): string + { + return self::getPathTemplate('table')->render([ + 'project' => $project, + 'instance' => $instance, + 'table' => $table, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - backup: projects/{project}/instances/{instance}/clusters/{cluster}/backups/{backup} + * - cluster: projects/{project}/instances/{instance}/clusters/{cluster} + * - cryptoKeyVersion: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version} + * - instance: projects/{project}/instances/{instance} + * - snapshot: projects/{project}/instances/{instance}/clusters/{cluster}/snapshots/{snapshot} + * - table: projects/{project}/instances/{instance}/tables/{table} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'bigtableadmin.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Checks replication consistency based on a consistency token, that is, if + * replication has caught up based on the conditions specified in the token + * and the check request. + * + * The async variant is {@see BigtableTableAdminClient::checkConsistencyAsync()} . + * + * @param CheckConsistencyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CheckConsistencyResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function checkConsistency(CheckConsistencyRequest $request, array $callOptions = []): CheckConsistencyResponse + { + return $this->startApiCall('CheckConsistency', $request, $callOptions)->wait(); + } + + /** + * Copy a Cloud Bigtable backup to a new backup in the destination cluster + * located in the destination instance and project. + * + * The async variant is {@see BigtableTableAdminClient::copyBackupAsync()} . + * + * @param CopyBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function copyBackup(CopyBackupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CopyBackup', $request, $callOptions)->wait(); + } + + /** + * Starts creating a new Cloud Bigtable Backup. The returned backup + * [long-running operation][google.longrunning.Operation] can be used to + * track creation of the backup. The + * [metadata][google.longrunning.Operation.metadata] field type is + * [CreateBackupMetadata][google.bigtable.admin.v2.CreateBackupMetadata]. The + * [response][google.longrunning.Operation.response] field type is + * [Backup][google.bigtable.admin.v2.Backup], if successful. Cancelling the + * returned operation will stop the creation and delete the backup. + * + * The async variant is {@see BigtableTableAdminClient::createBackupAsync()} . + * + * @param CreateBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createBackup(CreateBackupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateBackup', $request, $callOptions)->wait(); + } + + /** + * Creates a new table in the specified instance. + * The table can be created with a full set of initial column families, + * specified in the request. + * + * The async variant is {@see BigtableTableAdminClient::createTableAsync()} . + * + * @param CreateTableRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Table + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTable(CreateTableRequest $request, array $callOptions = []): Table + { + return $this->startApiCall('CreateTable', $request, $callOptions)->wait(); + } + + /** + * Creates a new table from the specified snapshot. The target table must + * not exist. The snapshot and the table must be in the same instance. + * + * Note: This is a private alpha release of Cloud Bigtable snapshots. This + * feature is not currently available to most Cloud Bigtable customers. This + * feature might be changed in backward-incompatible ways and is not + * recommended for production use. It is not subject to any SLA or deprecation + * policy. + * + * The async variant is + * {@see BigtableTableAdminClient::createTableFromSnapshotAsync()} . + * + * @param CreateTableFromSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTableFromSnapshot(CreateTableFromSnapshotRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateTableFromSnapshot', $request, $callOptions)->wait(); + } + + /** + * Deletes a pending or completed Cloud Bigtable backup. + * + * The async variant is {@see BigtableTableAdminClient::deleteBackupAsync()} . + * + * @param DeleteBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteBackup(DeleteBackupRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteBackup', $request, $callOptions)->wait(); + } + + /** + * Permanently deletes the specified snapshot. + * + * Note: This is a private alpha release of Cloud Bigtable snapshots. This + * feature is not currently available to most Cloud Bigtable customers. This + * feature might be changed in backward-incompatible ways and is not + * recommended for production use. It is not subject to any SLA or deprecation + * policy. + * + * The async variant is {@see BigtableTableAdminClient::deleteSnapshotAsync()} . + * + * @param DeleteSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSnapshot(DeleteSnapshotRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteSnapshot', $request, $callOptions)->wait(); + } + + /** + * Permanently deletes a specified table and all of its data. + * + * The async variant is {@see BigtableTableAdminClient::deleteTableAsync()} . + * + * @param DeleteTableRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTable(DeleteTableRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteTable', $request, $callOptions)->wait(); + } + + /** + * Permanently drop/delete a row range from a specified table. The request can + * specify whether to delete all rows in a table, or only those that match a + * particular prefix. + * + * The async variant is {@see BigtableTableAdminClient::dropRowRangeAsync()} . + * + * @param DropRowRangeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function dropRowRange(DropRowRangeRequest $request, array $callOptions = []): void + { + $this->startApiCall('DropRowRange', $request, $callOptions)->wait(); + } + + /** + * Generates a consistency token for a Table, which can be used in + * CheckConsistency to check whether mutations to the table that finished + * before this call started have been replicated. The tokens will be available + * for 90 days. + * + * The async variant is + * {@see BigtableTableAdminClient::generateConsistencyTokenAsync()} . + * + * @param GenerateConsistencyTokenRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GenerateConsistencyTokenResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function generateConsistencyToken(GenerateConsistencyTokenRequest $request, array $callOptions = []): GenerateConsistencyTokenResponse + { + return $this->startApiCall('GenerateConsistencyToken', $request, $callOptions)->wait(); + } + + /** + * Gets metadata on a pending or completed Cloud Bigtable Backup. + * + * The async variant is {@see BigtableTableAdminClient::getBackupAsync()} . + * + * @param GetBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Backup + * + * @throws ApiException Thrown if the API call fails. + */ + public function getBackup(GetBackupRequest $request, array $callOptions = []): Backup + { + return $this->startApiCall('GetBackup', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a Table or Backup resource. + * Returns an empty policy if the resource exists but does not have a policy + * set. + * + * The async variant is {@see BigtableTableAdminClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets metadata information about the specified snapshot. + * + * Note: This is a private alpha release of Cloud Bigtable snapshots. This + * feature is not currently available to most Cloud Bigtable customers. This + * feature might be changed in backward-incompatible ways and is not + * recommended for production use. It is not subject to any SLA or deprecation + * policy. + * + * The async variant is {@see BigtableTableAdminClient::getSnapshotAsync()} . + * + * @param GetSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Snapshot + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSnapshot(GetSnapshotRequest $request, array $callOptions = []): Snapshot + { + return $this->startApiCall('GetSnapshot', $request, $callOptions)->wait(); + } + + /** + * Gets metadata information about the specified table. + * + * The async variant is {@see BigtableTableAdminClient::getTableAsync()} . + * + * @param GetTableRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Table + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTable(GetTableRequest $request, array $callOptions = []): Table + { + return $this->startApiCall('GetTable', $request, $callOptions)->wait(); + } + + /** + * Lists Cloud Bigtable backups. Returns both completed and pending + * backups. + * + * The async variant is {@see BigtableTableAdminClient::listBackupsAsync()} . + * + * @param ListBackupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listBackups(ListBackupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListBackups', $request, $callOptions); + } + + /** + * Lists all snapshots associated with the specified cluster. + * + * Note: This is a private alpha release of Cloud Bigtable snapshots. This + * feature is not currently available to most Cloud Bigtable customers. This + * feature might be changed in backward-incompatible ways and is not + * recommended for production use. It is not subject to any SLA or deprecation + * policy. + * + * The async variant is {@see BigtableTableAdminClient::listSnapshotsAsync()} . + * + * @param ListSnapshotsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSnapshots(ListSnapshotsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSnapshots', $request, $callOptions); + } + + /** + * Lists all tables served from a specified instance. + * + * The async variant is {@see BigtableTableAdminClient::listTablesAsync()} . + * + * @param ListTablesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTables(ListTablesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTables', $request, $callOptions); + } + + /** + * Performs a series of column family modifications on the specified table. + * Either all or none of the modifications will occur before this method + * returns, but data requests received prior to that point may see a table + * where only some modifications have taken effect. + * + * The async variant is + * {@see BigtableTableAdminClient::modifyColumnFamiliesAsync()} . + * + * @param ModifyColumnFamiliesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Table + * + * @throws ApiException Thrown if the API call fails. + */ + public function modifyColumnFamilies(ModifyColumnFamiliesRequest $request, array $callOptions = []): Table + { + return $this->startApiCall('ModifyColumnFamilies', $request, $callOptions)->wait(); + } + + /** + * Create a new table by restoring from a completed backup. The + * returned table [long-running operation][google.longrunning.Operation] can + * be used to track the progress of the operation, and to cancel it. The + * [metadata][google.longrunning.Operation.metadata] field type is + * [RestoreTableMetadata][google.bigtable.admin.RestoreTableMetadata]. The + * [response][google.longrunning.Operation.response] type is + * [Table][google.bigtable.admin.v2.Table], if successful. + * + * The async variant is {@see BigtableTableAdminClient::restoreTableAsync()} . + * + * @param RestoreTableRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function restoreTable(RestoreTableRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RestoreTable', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on a Table or Backup resource. + * Replaces any existing policy. + * + * The async variant is {@see BigtableTableAdminClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Creates a new snapshot in the specified cluster from the specified + * source table. The cluster and the table must be in the same instance. + * + * Note: This is a private alpha release of Cloud Bigtable snapshots. This + * feature is not currently available to most Cloud Bigtable customers. This + * feature might be changed in backward-incompatible ways and is not + * recommended for production use. It is not subject to any SLA or deprecation + * policy. + * + * The async variant is {@see BigtableTableAdminClient::snapshotTableAsync()} . + * + * @param SnapshotTableRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function snapshotTable(SnapshotTableRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SnapshotTable', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that the caller has on the specified Table or Backup + * resource. + * + * The async variant is {@see BigtableTableAdminClient::testIamPermissionsAsync()} + * . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Restores a specified table which was accidentally deleted. + * + * The async variant is {@see BigtableTableAdminClient::undeleteTableAsync()} . + * + * @param UndeleteTableRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function undeleteTable(UndeleteTableRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UndeleteTable', $request, $callOptions)->wait(); + } + + /** + * Updates a pending or completed Cloud Bigtable Backup. + * + * The async variant is {@see BigtableTableAdminClient::updateBackupAsync()} . + * + * @param UpdateBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Backup + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateBackup(UpdateBackupRequest $request, array $callOptions = []): Backup + { + return $this->startApiCall('UpdateBackup', $request, $callOptions)->wait(); + } + + /** + * Updates a specified table. + * + * The async variant is {@see BigtableTableAdminClient::updateTableAsync()} . + * + * @param UpdateTableRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTable(UpdateTableRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateTable', $request, $callOptions)->wait(); + } } diff --git a/Bigtable/src/Admin/V2/Cluster.php b/Bigtable/src/Admin/V2/Cluster.php index 48f9f80a2826..21ebc80ddbdf 100644 --- a/Bigtable/src/Admin/V2/Cluster.php +++ b/Bigtable/src/Admin/V2/Cluster.php @@ -25,8 +25,8 @@ class Cluster extends \Google\Protobuf\Internal\Message */ private $name = ''; /** - * Immutable. The location where this cluster's nodes and storage reside. For best - * performance, clients should be located as close as possible to this + * Immutable. The location where this cluster's nodes and storage reside. For + * best performance, clients should be located as close as possible to this * cluster. Currently only zones are supported, so values should be of the * form `projects/{project}/locations/{zone}`. * @@ -71,8 +71,8 @@ class Cluster extends \Google\Protobuf\Internal\Message * The unique name of the cluster. Values are of the form * `projects/{project}/instances/{instance}/clusters/[a-z][-a-z0-9]*`. * @type string $location - * Immutable. The location where this cluster's nodes and storage reside. For best - * performance, clients should be located as close as possible to this + * Immutable. The location where this cluster's nodes and storage reside. For + * best performance, clients should be located as close as possible to this * cluster. Currently only zones are supported, so values should be of the * form `projects/{project}/locations/{zone}`. * @type int $state @@ -123,8 +123,8 @@ public function setName($var) } /** - * Immutable. The location where this cluster's nodes and storage reside. For best - * performance, clients should be located as close as possible to this + * Immutable. The location where this cluster's nodes and storage reside. For + * best performance, clients should be located as close as possible to this * cluster. Currently only zones are supported, so values should be of the * form `projects/{project}/locations/{zone}`. * @@ -137,8 +137,8 @@ public function getLocation() } /** - * Immutable. The location where this cluster's nodes and storage reside. For best - * performance, clients should be located as close as possible to this + * Immutable. The location where this cluster's nodes and storage reside. For + * best performance, clients should be located as close as possible to this * cluster. Currently only zones are supported, so values should be of the * form `projects/{project}/locations/{zone}`. * diff --git a/Bigtable/src/Admin/V2/CreateAppProfileRequest.php b/Bigtable/src/Admin/V2/CreateAppProfileRequest.php index 4b19e43ba658..3495b4a6bced 100644 --- a/Bigtable/src/Admin/V2/CreateAppProfileRequest.php +++ b/Bigtable/src/Admin/V2/CreateAppProfileRequest.php @@ -16,16 +16,15 @@ class CreateAppProfileRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The unique name of the instance in which to create the new app profile. - * Values are of the form - * `projects/{project}/instances/{instance}`. + * Required. The unique name of the instance in which to create the new app + * profile. Values are of the form `projects/{project}/instances/{instance}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ private $parent = ''; /** - * Required. The ID to be used when referring to the new app profile within its - * instance, e.g., just `myprofile` rather than + * Required. The ID to be used when referring to the new app profile within + * its instance, e.g., just `myprofile` rather than * `projects/myproject/instances/myinstance/appProfiles/myprofile`. * * Generated from protobuf field string app_profile_id = 2 [(.google.api.field_behavior) = REQUIRED]; @@ -46,12 +45,11 @@ class CreateAppProfileRequest extends \Google\Protobuf\Internal\Message private $ignore_warnings = false; /** - * @param string $parent Required. The unique name of the instance in which to create the new app profile. - * Values are of the form - * `projects/{project}/instances/{instance}`. Please see + * @param string $parent Required. The unique name of the instance in which to create the new app + * profile. Values are of the form `projects/{project}/instances/{instance}`. Please see * {@see BigtableInstanceAdminClient::instanceName()} for help formatting this field. - * @param string $appProfileId Required. The ID to be used when referring to the new app profile within its - * instance, e.g., just `myprofile` rather than + * @param string $appProfileId Required. The ID to be used when referring to the new app profile within + * its instance, e.g., just `myprofile` rather than * `projects/myproject/instances/myinstance/appProfiles/myprofile`. * @param \Google\Cloud\Bigtable\Admin\V2\AppProfile $appProfile Required. The app profile to be created. * Fields marked `OutputOnly` will be ignored. @@ -75,12 +73,11 @@ public static function build(string $parent, string $appProfileId, \Google\Cloud * Optional. Data for populating the Message object. * * @type string $parent - * Required. The unique name of the instance in which to create the new app profile. - * Values are of the form - * `projects/{project}/instances/{instance}`. + * Required. The unique name of the instance in which to create the new app + * profile. Values are of the form `projects/{project}/instances/{instance}`. * @type string $app_profile_id - * Required. The ID to be used when referring to the new app profile within its - * instance, e.g., just `myprofile` rather than + * Required. The ID to be used when referring to the new app profile within + * its instance, e.g., just `myprofile` rather than * `projects/myproject/instances/myinstance/appProfiles/myprofile`. * @type \Google\Cloud\Bigtable\Admin\V2\AppProfile $app_profile * Required. The app profile to be created. @@ -95,9 +92,8 @@ public function __construct($data = NULL) { } /** - * Required. The unique name of the instance in which to create the new app profile. - * Values are of the form - * `projects/{project}/instances/{instance}`. + * Required. The unique name of the instance in which to create the new app + * profile. Values are of the form `projects/{project}/instances/{instance}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @return string @@ -108,9 +104,8 @@ public function getParent() } /** - * Required. The unique name of the instance in which to create the new app profile. - * Values are of the form - * `projects/{project}/instances/{instance}`. + * Required. The unique name of the instance in which to create the new app + * profile. Values are of the form `projects/{project}/instances/{instance}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @param string $var @@ -125,8 +120,8 @@ public function setParent($var) } /** - * Required. The ID to be used when referring to the new app profile within its - * instance, e.g., just `myprofile` rather than + * Required. The ID to be used when referring to the new app profile within + * its instance, e.g., just `myprofile` rather than * `projects/myproject/instances/myinstance/appProfiles/myprofile`. * * Generated from protobuf field string app_profile_id = 2 [(.google.api.field_behavior) = REQUIRED]; @@ -138,8 +133,8 @@ public function getAppProfileId() } /** - * Required. The ID to be used when referring to the new app profile within its - * instance, e.g., just `myprofile` rather than + * Required. The ID to be used when referring to the new app profile within + * its instance, e.g., just `myprofile` rather than * `projects/myproject/instances/myinstance/appProfiles/myprofile`. * * Generated from protobuf field string app_profile_id = 2 [(.google.api.field_behavior) = REQUIRED]; diff --git a/Bigtable/src/Admin/V2/CreateClusterRequest.php b/Bigtable/src/Admin/V2/CreateClusterRequest.php index 02d9f012ded6..7f851c492e46 100644 --- a/Bigtable/src/Admin/V2/CreateClusterRequest.php +++ b/Bigtable/src/Admin/V2/CreateClusterRequest.php @@ -16,16 +16,15 @@ class CreateClusterRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The unique name of the instance in which to create the new cluster. - * Values are of the form - * `projects/{project}/instances/{instance}`. + * Required. The unique name of the instance in which to create the new + * cluster. Values are of the form `projects/{project}/instances/{instance}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ private $parent = ''; /** - * Required. The ID to be used when referring to the new cluster within its instance, - * e.g., just `mycluster` rather than + * Required. The ID to be used when referring to the new cluster within its + * instance, e.g., just `mycluster` rather than * `projects/myproject/instances/myinstance/clusters/mycluster`. * * Generated from protobuf field string cluster_id = 2 [(.google.api.field_behavior) = REQUIRED]; @@ -40,12 +39,11 @@ class CreateClusterRequest extends \Google\Protobuf\Internal\Message private $cluster = null; /** - * @param string $parent Required. The unique name of the instance in which to create the new cluster. - * Values are of the form - * `projects/{project}/instances/{instance}`. Please see + * @param string $parent Required. The unique name of the instance in which to create the new + * cluster. Values are of the form `projects/{project}/instances/{instance}`. Please see * {@see BigtableInstanceAdminClient::instanceName()} for help formatting this field. - * @param string $clusterId Required. The ID to be used when referring to the new cluster within its instance, - * e.g., just `mycluster` rather than + * @param string $clusterId Required. The ID to be used when referring to the new cluster within its + * instance, e.g., just `mycluster` rather than * `projects/myproject/instances/myinstance/clusters/mycluster`. * @param \Google\Cloud\Bigtable\Admin\V2\Cluster $cluster Required. The cluster to be created. * Fields marked `OutputOnly` must be left blank. @@ -69,12 +67,11 @@ public static function build(string $parent, string $clusterId, \Google\Cloud\Bi * Optional. Data for populating the Message object. * * @type string $parent - * Required. The unique name of the instance in which to create the new cluster. - * Values are of the form - * `projects/{project}/instances/{instance}`. + * Required. The unique name of the instance in which to create the new + * cluster. Values are of the form `projects/{project}/instances/{instance}`. * @type string $cluster_id - * Required. The ID to be used when referring to the new cluster within its instance, - * e.g., just `mycluster` rather than + * Required. The ID to be used when referring to the new cluster within its + * instance, e.g., just `mycluster` rather than * `projects/myproject/instances/myinstance/clusters/mycluster`. * @type \Google\Cloud\Bigtable\Admin\V2\Cluster $cluster * Required. The cluster to be created. @@ -87,9 +84,8 @@ public function __construct($data = NULL) { } /** - * Required. The unique name of the instance in which to create the new cluster. - * Values are of the form - * `projects/{project}/instances/{instance}`. + * Required. The unique name of the instance in which to create the new + * cluster. Values are of the form `projects/{project}/instances/{instance}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @return string @@ -100,9 +96,8 @@ public function getParent() } /** - * Required. The unique name of the instance in which to create the new cluster. - * Values are of the form - * `projects/{project}/instances/{instance}`. + * Required. The unique name of the instance in which to create the new + * cluster. Values are of the form `projects/{project}/instances/{instance}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @param string $var @@ -117,8 +112,8 @@ public function setParent($var) } /** - * Required. The ID to be used when referring to the new cluster within its instance, - * e.g., just `mycluster` rather than + * Required. The ID to be used when referring to the new cluster within its + * instance, e.g., just `mycluster` rather than * `projects/myproject/instances/myinstance/clusters/mycluster`. * * Generated from protobuf field string cluster_id = 2 [(.google.api.field_behavior) = REQUIRED]; @@ -130,8 +125,8 @@ public function getClusterId() } /** - * Required. The ID to be used when referring to the new cluster within its instance, - * e.g., just `mycluster` rather than + * Required. The ID to be used when referring to the new cluster within its + * instance, e.g., just `mycluster` rather than * `projects/myproject/instances/myinstance/clusters/mycluster`. * * Generated from protobuf field string cluster_id = 2 [(.google.api.field_behavior) = REQUIRED]; diff --git a/Bigtable/src/Admin/V2/CreateInstanceRequest.php b/Bigtable/src/Admin/V2/CreateInstanceRequest.php index 4c526c27deff..5649c4eed16f 100644 --- a/Bigtable/src/Admin/V2/CreateInstanceRequest.php +++ b/Bigtable/src/Admin/V2/CreateInstanceRequest.php @@ -16,15 +16,15 @@ class CreateInstanceRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The unique name of the project in which to create the new instance. - * Values are of the form `projects/{project}`. + * Required. The unique name of the project in which to create the new + * instance. Values are of the form `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ private $parent = ''; /** - * Required. The ID to be used when referring to the new instance within its project, - * e.g., just `myinstance` rather than + * Required. The ID to be used when referring to the new instance within its + * project, e.g., just `myinstance` rather than * `projects/myproject/instances/myinstance`. * * Generated from protobuf field string instance_id = 2 [(.google.api.field_behavior) = REQUIRED]; @@ -49,11 +49,11 @@ class CreateInstanceRequest extends \Google\Protobuf\Internal\Message private $clusters; /** - * @param string $parent Required. The unique name of the project in which to create the new instance. - * Values are of the form `projects/{project}`. Please see + * @param string $parent Required. The unique name of the project in which to create the new + * instance. Values are of the form `projects/{project}`. Please see * {@see BigtableInstanceAdminClient::projectName()} for help formatting this field. - * @param string $instanceId Required. The ID to be used when referring to the new instance within its project, - * e.g., just `myinstance` rather than + * @param string $instanceId Required. The ID to be used when referring to the new instance within its + * project, e.g., just `myinstance` rather than * `projects/myproject/instances/myinstance`. * @param \Google\Cloud\Bigtable\Admin\V2\Instance $instance Required. The instance to create. * Fields marked `OutputOnly` must be left blank. @@ -83,11 +83,11 @@ public static function build(string $parent, string $instanceId, \Google\Cloud\B * Optional. Data for populating the Message object. * * @type string $parent - * Required. The unique name of the project in which to create the new instance. - * Values are of the form `projects/{project}`. + * Required. The unique name of the project in which to create the new + * instance. Values are of the form `projects/{project}`. * @type string $instance_id - * Required. The ID to be used when referring to the new instance within its project, - * e.g., just `myinstance` rather than + * Required. The ID to be used when referring to the new instance within its + * project, e.g., just `myinstance` rather than * `projects/myproject/instances/myinstance`. * @type \Google\Cloud\Bigtable\Admin\V2\Instance $instance * Required. The instance to create. @@ -106,8 +106,8 @@ public function __construct($data = NULL) { } /** - * Required. The unique name of the project in which to create the new instance. - * Values are of the form `projects/{project}`. + * Required. The unique name of the project in which to create the new + * instance. Values are of the form `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @return string @@ -118,8 +118,8 @@ public function getParent() } /** - * Required. The unique name of the project in which to create the new instance. - * Values are of the form `projects/{project}`. + * Required. The unique name of the project in which to create the new + * instance. Values are of the form `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @param string $var @@ -134,8 +134,8 @@ public function setParent($var) } /** - * Required. The ID to be used when referring to the new instance within its project, - * e.g., just `myinstance` rather than + * Required. The ID to be used when referring to the new instance within its + * project, e.g., just `myinstance` rather than * `projects/myproject/instances/myinstance`. * * Generated from protobuf field string instance_id = 2 [(.google.api.field_behavior) = REQUIRED]; @@ -147,8 +147,8 @@ public function getInstanceId() } /** - * Required. The ID to be used when referring to the new instance within its project, - * e.g., just `myinstance` rather than + * Required. The ID to be used when referring to the new instance within its + * project, e.g., just `myinstance` rather than * `projects/myproject/instances/myinstance`. * * Generated from protobuf field string instance_id = 2 [(.google.api.field_behavior) = REQUIRED]; diff --git a/Bigtable/src/Admin/V2/DeleteAppProfileRequest.php b/Bigtable/src/Admin/V2/DeleteAppProfileRequest.php index 6d19b576f881..4122b01fc891 100644 --- a/Bigtable/src/Admin/V2/DeleteAppProfileRequest.php +++ b/Bigtable/src/Admin/V2/DeleteAppProfileRequest.php @@ -16,7 +16,8 @@ class DeleteAppProfileRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The unique name of the app profile to be deleted. Values are of the form + * Required. The unique name of the app profile to be deleted. Values are of + * the form * `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -30,7 +31,8 @@ class DeleteAppProfileRequest extends \Google\Protobuf\Internal\Message private $ignore_warnings = false; /** - * @param string $name Required. The unique name of the app profile to be deleted. Values are of the form + * @param string $name Required. The unique name of the app profile to be deleted. Values are of + * the form * `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. Please see * {@see BigtableInstanceAdminClient::appProfileName()} for help formatting this field. * @@ -51,7 +53,8 @@ public static function build(string $name): self * Optional. Data for populating the Message object. * * @type string $name - * Required. The unique name of the app profile to be deleted. Values are of the form + * Required. The unique name of the app profile to be deleted. Values are of + * the form * `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. * @type bool $ignore_warnings * Required. If true, ignore safety checks when deleting the app profile. @@ -63,7 +66,8 @@ public function __construct($data = NULL) { } /** - * Required. The unique name of the app profile to be deleted. Values are of the form + * Required. The unique name of the app profile to be deleted. Values are of + * the form * `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -75,7 +79,8 @@ public function getName() } /** - * Required. The unique name of the app profile to be deleted. Values are of the form + * Required. The unique name of the app profile to be deleted. Values are of + * the form * `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { diff --git a/Bigtable/src/Admin/V2/DeleteClusterRequest.php b/Bigtable/src/Admin/V2/DeleteClusterRequest.php index 54aa06180071..7f83bd0b9c61 100644 --- a/Bigtable/src/Admin/V2/DeleteClusterRequest.php +++ b/Bigtable/src/Admin/V2/DeleteClusterRequest.php @@ -16,16 +16,16 @@ class DeleteClusterRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The unique name of the cluster to be deleted. Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}`. + * Required. The unique name of the cluster to be deleted. Values are of the + * form `projects/{project}/instances/{instance}/clusters/{cluster}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ private $name = ''; /** - * @param string $name Required. The unique name of the cluster to be deleted. Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}`. Please see + * @param string $name Required. The unique name of the cluster to be deleted. Values are of the + * form `projects/{project}/instances/{instance}/clusters/{cluster}`. Please see * {@see BigtableInstanceAdminClient::clusterName()} for help formatting this field. * * @return \Google\Cloud\Bigtable\Admin\V2\DeleteClusterRequest @@ -45,8 +45,8 @@ public static function build(string $name): self * Optional. Data for populating the Message object. * * @type string $name - * Required. The unique name of the cluster to be deleted. Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}`. + * Required. The unique name of the cluster to be deleted. Values are of the + * form `projects/{project}/instances/{instance}/clusters/{cluster}`. * } */ public function __construct($data = NULL) { @@ -55,8 +55,8 @@ public function __construct($data = NULL) { } /** - * Required. The unique name of the cluster to be deleted. Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}`. + * Required. The unique name of the cluster to be deleted. Values are of the + * form `projects/{project}/instances/{instance}/clusters/{cluster}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @return string @@ -67,8 +67,8 @@ public function getName() } /** - * Required. The unique name of the cluster to be deleted. Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}`. + * Required. The unique name of the cluster to be deleted. Values are of the + * form `projects/{project}/instances/{instance}/clusters/{cluster}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @param string $var diff --git a/Bigtable/src/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php b/Bigtable/src/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php index 63bca441d831..2a88c3530bea 100644 --- a/Bigtable/src/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php +++ b/Bigtable/src/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php @@ -494,11 +494,10 @@ public function __construct(array $options = []) * } * ``` * - * @param string $parent Required. The unique name of the instance in which to create the new app profile. - * Values are of the form - * `projects/{project}/instances/{instance}`. - * @param string $appProfileId Required. The ID to be used when referring to the new app profile within its - * instance, e.g., just `myprofile` rather than + * @param string $parent Required. The unique name of the instance in which to create the new app + * profile. Values are of the form `projects/{project}/instances/{instance}`. + * @param string $appProfileId Required. The ID to be used when referring to the new app profile within + * its instance, e.g., just `myprofile` rather than * `projects/myproject/instances/myinstance/appProfiles/myprofile`. * @param AppProfile $appProfile Required. The app profile to be created. * Fields marked `OutputOnly` will be ignored. @@ -581,11 +580,10 @@ public function createAppProfile($parent, $appProfileId, $appProfile, array $opt * } * ``` * - * @param string $parent Required. The unique name of the instance in which to create the new cluster. - * Values are of the form - * `projects/{project}/instances/{instance}`. - * @param string $clusterId Required. The ID to be used when referring to the new cluster within its instance, - * e.g., just `mycluster` rather than + * @param string $parent Required. The unique name of the instance in which to create the new + * cluster. Values are of the form `projects/{project}/instances/{instance}`. + * @param string $clusterId Required. The ID to be used when referring to the new cluster within its + * instance, e.g., just `mycluster` rather than * `projects/myproject/instances/myinstance/clusters/mycluster`. * @param Cluster $cluster Required. The cluster to be created. * Fields marked `OutputOnly` must be left blank. @@ -663,10 +661,10 @@ public function createCluster($parent, $clusterId, $cluster, array $optionalArgs * } * ``` * - * @param string $parent Required. The unique name of the project in which to create the new instance. - * Values are of the form `projects/{project}`. - * @param string $instanceId Required. The ID to be used when referring to the new instance within its project, - * e.g., just `myinstance` rather than + * @param string $parent Required. The unique name of the project in which to create the new + * instance. Values are of the form `projects/{project}`. + * @param string $instanceId Required. The ID to be used when referring to the new instance within its + * project, e.g., just `myinstance` rather than * `projects/myproject/instances/myinstance`. * @param Instance $instance Required. The instance to create. * Fields marked `OutputOnly` must be left blank. @@ -717,7 +715,8 @@ public function createInstance($parent, $instanceId, $instance, $clusters, array * } * ``` * - * @param string $name Required. The unique name of the app profile to be deleted. Values are of the form + * @param string $name Required. The unique name of the app profile to be deleted. Values are of + * the form * `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. * @param bool $ignoreWarnings Required. If true, ignore safety checks when deleting the app profile. * @param array $optionalArgs { @@ -757,8 +756,8 @@ public function deleteAppProfile($name, $ignoreWarnings, array $optionalArgs = [ * } * ``` * - * @param string $name Required. The unique name of the cluster to be deleted. Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}`. + * @param string $name Required. The unique name of the cluster to be deleted. Values are of the + * form `projects/{project}/instances/{instance}/clusters/{cluster}`. * @param array $optionalArgs { * Optional. * @@ -833,8 +832,8 @@ public function deleteInstance($name, array $optionalArgs = []) * } * ``` * - * @param string $name Required. The unique name of the requested app profile. Values are of the form - * `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. + * @param string $name Required. The unique name of the requested app profile. Values are of the + * form `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. * @param array $optionalArgs { * Optional. * @@ -1013,8 +1012,8 @@ public function getInstance($name, array $optionalArgs = []) * } * ``` * - * @param string $parent Required. The unique name of the instance for which a list of app profiles is - * requested. Values are of the form + * @param string $parent Required. The unique name of the instance for which a list of app profiles + * is requested. Values are of the form * `projects/{project}/instances/{instance}`. * Use `{instance} = '-'` to list AppProfiles for all Instances in a project, * e.g., `projects/myproject/instances/-`. @@ -1073,10 +1072,11 @@ public function listAppProfiles($parent, array $optionalArgs = []) * } * ``` * - * @param string $parent Required. The unique name of the instance for which a list of clusters is requested. - * Values are of the form `projects/{project}/instances/{instance}`. - * Use `{instance} = '-'` to list Clusters for all Instances in a project, - * e.g., `projects/myproject/instances/-`. + * @param string $parent Required. The unique name of the instance for which a list of clusters is + * requested. Values are of the form + * `projects/{project}/instances/{instance}`. Use `{instance} = '-'` to list + * Clusters for all Instances in a project, e.g., + * `projects/myproject/instances/-`. * @param array $optionalArgs { * Optional. * @@ -1209,8 +1209,8 @@ public function listHotTablets($parent, array $optionalArgs = []) * } * ``` * - * @param string $parent Required. The unique name of the project for which a list of instances is requested. - * Values are of the form `projects/{project}`. + * @param string $parent Required. The unique name of the project for which a list of instances is + * requested. Values are of the form `projects/{project}`. * @param array $optionalArgs { * Optional. * @@ -1292,8 +1292,8 @@ public function listInstances($parent, array $optionalArgs = []) * } * ``` * - * @param Cluster $cluster Required. The Cluster which contains the partial updates to be applied, subject to - * the update_mask. + * @param Cluster $cluster Required. The Cluster which contains the partial updates to be applied, + * subject to the update_mask. * @param FieldMask $updateMask Required. The subset of Cluster fields which should be replaced. * @param array $optionalArgs { * Optional. @@ -1618,8 +1618,8 @@ public function updateAppProfile($appProfile, $updateMask, array $optionalArgs = * Optional. * * @type string $location - * Immutable. The location where this cluster's nodes and storage reside. For best - * performance, clients should be located as close as possible to this + * Immutable. The location where this cluster's nodes and storage reside. For + * best performance, clients should be located as close as possible to this * cluster. Currently only zones are supported, so values should be of the * form `projects/{project}/locations/{zone}`. * @type int $state @@ -1720,9 +1720,9 @@ public function updateCluster($name, $serveNodes, array $optionalArgs = []) * The current state of the instance. * For allowed values, use constants defined on {@see \Google\Cloud\Bigtable\Admin\V2\Instance\State} * @type Timestamp $createTime - * Output only. A server-assigned timestamp representing when this Instance was created. - * For instances created before this field was added (August 2021), this value - * is `seconds: 0, nanos: 1`. + * Output only. A server-assigned timestamp representing when this Instance + * was created. For instances created before this field was added (August + * 2021), this value is `seconds: 0, nanos: 1`. * @type bool $satisfiesPzs * Output only. Reserved for future use. * @type RetrySettings|array $retrySettings diff --git a/Bigtable/src/Admin/V2/GetAppProfileRequest.php b/Bigtable/src/Admin/V2/GetAppProfileRequest.php index f3b4ead92ce9..de9af9eb1acd 100644 --- a/Bigtable/src/Admin/V2/GetAppProfileRequest.php +++ b/Bigtable/src/Admin/V2/GetAppProfileRequest.php @@ -16,16 +16,16 @@ class GetAppProfileRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The unique name of the requested app profile. Values are of the form - * `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. + * Required. The unique name of the requested app profile. Values are of the + * form `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ private $name = ''; /** - * @param string $name Required. The unique name of the requested app profile. Values are of the form - * `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. Please see + * @param string $name Required. The unique name of the requested app profile. Values are of the + * form `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. Please see * {@see BigtableInstanceAdminClient::appProfileName()} for help formatting this field. * * @return \Google\Cloud\Bigtable\Admin\V2\GetAppProfileRequest @@ -45,8 +45,8 @@ public static function build(string $name): self * Optional. Data for populating the Message object. * * @type string $name - * Required. The unique name of the requested app profile. Values are of the form - * `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. + * Required. The unique name of the requested app profile. Values are of the + * form `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. * } */ public function __construct($data = NULL) { @@ -55,8 +55,8 @@ public function __construct($data = NULL) { } /** - * Required. The unique name of the requested app profile. Values are of the form - * `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. + * Required. The unique name of the requested app profile. Values are of the + * form `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @return string @@ -67,8 +67,8 @@ public function getName() } /** - * Required. The unique name of the requested app profile. Values are of the form - * `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. + * Required. The unique name of the requested app profile. Values are of the + * form `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @param string $var diff --git a/Bigtable/src/Admin/V2/HotTablet.php b/Bigtable/src/Admin/V2/HotTablet.php index e3e13a3a8ab2..fed0f7cc296c 100644 --- a/Bigtable/src/Admin/V2/HotTablet.php +++ b/Bigtable/src/Admin/V2/HotTablet.php @@ -58,10 +58,10 @@ class HotTablet extends \Google\Protobuf\Internal\Message */ private $end_key = ''; /** - * Output only. The average CPU usage spent by a node on this tablet over the start_time to - * end_time time range. The percentage is the amount of CPU used by the node - * to serve the tablet, from 0% (tablet was not interacted with) to 100% (the - * node spent all cycles serving the hot tablet). + * Output only. The average CPU usage spent by a node on this tablet over the + * start_time to end_time time range. The percentage is the amount of CPU used + * by the node to serve the tablet, from 0% (tablet was not interacted with) + * to 100% (the node spent all cycles serving the hot tablet). * * Generated from protobuf field float node_cpu_usage_percent = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ @@ -88,10 +88,10 @@ class HotTablet extends \Google\Protobuf\Internal\Message * @type string $end_key * Tablet End Key (inclusive). * @type float $node_cpu_usage_percent - * Output only. The average CPU usage spent by a node on this tablet over the start_time to - * end_time time range. The percentage is the amount of CPU used by the node - * to serve the tablet, from 0% (tablet was not interacted with) to 100% (the - * node spent all cycles serving the hot tablet). + * Output only. The average CPU usage spent by a node on this tablet over the + * start_time to end_time time range. The percentage is the amount of CPU used + * by the node to serve the tablet, from 0% (tablet was not interacted with) + * to 100% (the node spent all cycles serving the hot tablet). * } */ public function __construct($data = NULL) { @@ -280,10 +280,10 @@ public function setEndKey($var) } /** - * Output only. The average CPU usage spent by a node on this tablet over the start_time to - * end_time time range. The percentage is the amount of CPU used by the node - * to serve the tablet, from 0% (tablet was not interacted with) to 100% (the - * node spent all cycles serving the hot tablet). + * Output only. The average CPU usage spent by a node on this tablet over the + * start_time to end_time time range. The percentage is the amount of CPU used + * by the node to serve the tablet, from 0% (tablet was not interacted with) + * to 100% (the node spent all cycles serving the hot tablet). * * Generated from protobuf field float node_cpu_usage_percent = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @return float @@ -294,10 +294,10 @@ public function getNodeCpuUsagePercent() } /** - * Output only. The average CPU usage spent by a node on this tablet over the start_time to - * end_time time range. The percentage is the amount of CPU used by the node - * to serve the tablet, from 0% (tablet was not interacted with) to 100% (the - * node spent all cycles serving the hot tablet). + * Output only. The average CPU usage spent by a node on this tablet over the + * start_time to end_time time range. The percentage is the amount of CPU used + * by the node to serve the tablet, from 0% (tablet was not interacted with) + * to 100% (the node spent all cycles serving the hot tablet). * * Generated from protobuf field float node_cpu_usage_percent = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param float $var diff --git a/Bigtable/src/Admin/V2/Instance.php b/Bigtable/src/Admin/V2/Instance.php index 1427584e47a6..ba69bf7c6cf6 100644 --- a/Bigtable/src/Admin/V2/Instance.php +++ b/Bigtable/src/Admin/V2/Instance.php @@ -62,9 +62,9 @@ class Instance extends \Google\Protobuf\Internal\Message */ private $labels; /** - * Output only. A server-assigned timestamp representing when this Instance was created. - * For instances created before this field was added (August 2021), this value - * is `seconds: 0, nanos: 1`. + * Output only. A server-assigned timestamp representing when this Instance + * was created. For instances created before this field was added (August + * 2021), this value is `seconds: 0, nanos: 1`. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ @@ -106,9 +106,9 @@ class Instance extends \Google\Protobuf\Internal\Message * * No more than 64 labels can be associated with a given resource. * * Keys and values must both be under 128 bytes. * @type \Google\Protobuf\Timestamp $create_time - * Output only. A server-assigned timestamp representing when this Instance was created. - * For instances created before this field was added (August 2021), this value - * is `seconds: 0, nanos: 1`. + * Output only. A server-assigned timestamp representing when this Instance + * was created. For instances created before this field was added (August + * 2021), this value is `seconds: 0, nanos: 1`. * @type bool $satisfies_pzs * Output only. Reserved for future use. * } @@ -275,9 +275,9 @@ public function setLabels($var) } /** - * Output only. A server-assigned timestamp representing when this Instance was created. - * For instances created before this field was added (August 2021), this value - * is `seconds: 0, nanos: 1`. + * Output only. A server-assigned timestamp representing when this Instance + * was created. For instances created before this field was added (August + * 2021), this value is `seconds: 0, nanos: 1`. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @return \Google\Protobuf\Timestamp|null @@ -298,9 +298,9 @@ public function clearCreateTime() } /** - * Output only. A server-assigned timestamp representing when this Instance was created. - * For instances created before this field was added (August 2021), this value - * is `seconds: 0, nanos: 1`. + * Output only. A server-assigned timestamp representing when this Instance + * was created. For instances created before this field was added (August + * 2021), this value is `seconds: 0, nanos: 1`. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param \Google\Protobuf\Timestamp $var diff --git a/Bigtable/src/Admin/V2/ListAppProfilesRequest.php b/Bigtable/src/Admin/V2/ListAppProfilesRequest.php index aa5346ff4497..24de37843fbf 100644 --- a/Bigtable/src/Admin/V2/ListAppProfilesRequest.php +++ b/Bigtable/src/Admin/V2/ListAppProfilesRequest.php @@ -16,8 +16,8 @@ class ListAppProfilesRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The unique name of the instance for which a list of app profiles is - * requested. Values are of the form + * Required. The unique name of the instance for which a list of app profiles + * is requested. Values are of the form * `projects/{project}/instances/{instance}`. * Use `{instance} = '-'` to list AppProfiles for all Instances in a project, * e.g., `projects/myproject/instances/-`. @@ -45,8 +45,8 @@ class ListAppProfilesRequest extends \Google\Protobuf\Internal\Message private $page_token = ''; /** - * @param string $parent Required. The unique name of the instance for which a list of app profiles is - * requested. Values are of the form + * @param string $parent Required. The unique name of the instance for which a list of app profiles + * is requested. Values are of the form * `projects/{project}/instances/{instance}`. * Use `{instance} = '-'` to list AppProfiles for all Instances in a project, * e.g., `projects/myproject/instances/-`. Please see @@ -69,8 +69,8 @@ public static function build(string $parent): self * Optional. Data for populating the Message object. * * @type string $parent - * Required. The unique name of the instance for which a list of app profiles is - * requested. Values are of the form + * Required. The unique name of the instance for which a list of app profiles + * is requested. Values are of the form * `projects/{project}/instances/{instance}`. * Use `{instance} = '-'` to list AppProfiles for all Instances in a project, * e.g., `projects/myproject/instances/-`. @@ -92,8 +92,8 @@ public function __construct($data = NULL) { } /** - * Required. The unique name of the instance for which a list of app profiles is - * requested. Values are of the form + * Required. The unique name of the instance for which a list of app profiles + * is requested. Values are of the form * `projects/{project}/instances/{instance}`. * Use `{instance} = '-'` to list AppProfiles for all Instances in a project, * e.g., `projects/myproject/instances/-`. @@ -107,8 +107,8 @@ public function getParent() } /** - * Required. The unique name of the instance for which a list of app profiles is - * requested. Values are of the form + * Required. The unique name of the instance for which a list of app profiles + * is requested. Values are of the form * `projects/{project}/instances/{instance}`. * Use `{instance} = '-'` to list AppProfiles for all Instances in a project, * e.g., `projects/myproject/instances/-`. diff --git a/Bigtable/src/Admin/V2/ListClustersRequest.php b/Bigtable/src/Admin/V2/ListClustersRequest.php index a84b55c0c9e4..8376ed2de6bb 100644 --- a/Bigtable/src/Admin/V2/ListClustersRequest.php +++ b/Bigtable/src/Admin/V2/ListClustersRequest.php @@ -16,10 +16,11 @@ class ListClustersRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The unique name of the instance for which a list of clusters is requested. - * Values are of the form `projects/{project}/instances/{instance}`. - * Use `{instance} = '-'` to list Clusters for all Instances in a project, - * e.g., `projects/myproject/instances/-`. + * Required. The unique name of the instance for which a list of clusters is + * requested. Values are of the form + * `projects/{project}/instances/{instance}`. Use `{instance} = '-'` to list + * Clusters for all Instances in a project, e.g., + * `projects/myproject/instances/-`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ @@ -32,10 +33,11 @@ class ListClustersRequest extends \Google\Protobuf\Internal\Message private $page_token = ''; /** - * @param string $parent Required. The unique name of the instance for which a list of clusters is requested. - * Values are of the form `projects/{project}/instances/{instance}`. - * Use `{instance} = '-'` to list Clusters for all Instances in a project, - * e.g., `projects/myproject/instances/-`. Please see + * @param string $parent Required. The unique name of the instance for which a list of clusters is + * requested. Values are of the form + * `projects/{project}/instances/{instance}`. Use `{instance} = '-'` to list + * Clusters for all Instances in a project, e.g., + * `projects/myproject/instances/-`. Please see * {@see BigtableInstanceAdminClient::instanceName()} for help formatting this field. * * @return \Google\Cloud\Bigtable\Admin\V2\ListClustersRequest @@ -55,10 +57,11 @@ public static function build(string $parent): self * Optional. Data for populating the Message object. * * @type string $parent - * Required. The unique name of the instance for which a list of clusters is requested. - * Values are of the form `projects/{project}/instances/{instance}`. - * Use `{instance} = '-'` to list Clusters for all Instances in a project, - * e.g., `projects/myproject/instances/-`. + * Required. The unique name of the instance for which a list of clusters is + * requested. Values are of the form + * `projects/{project}/instances/{instance}`. Use `{instance} = '-'` to list + * Clusters for all Instances in a project, e.g., + * `projects/myproject/instances/-`. * @type string $page_token * DEPRECATED: This field is unused and ignored. * } @@ -69,10 +72,11 @@ public function __construct($data = NULL) { } /** - * Required. The unique name of the instance for which a list of clusters is requested. - * Values are of the form `projects/{project}/instances/{instance}`. - * Use `{instance} = '-'` to list Clusters for all Instances in a project, - * e.g., `projects/myproject/instances/-`. + * Required. The unique name of the instance for which a list of clusters is + * requested. Values are of the form + * `projects/{project}/instances/{instance}`. Use `{instance} = '-'` to list + * Clusters for all Instances in a project, e.g., + * `projects/myproject/instances/-`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @return string @@ -83,10 +87,11 @@ public function getParent() } /** - * Required. The unique name of the instance for which a list of clusters is requested. - * Values are of the form `projects/{project}/instances/{instance}`. - * Use `{instance} = '-'` to list Clusters for all Instances in a project, - * e.g., `projects/myproject/instances/-`. + * Required. The unique name of the instance for which a list of clusters is + * requested. Values are of the form + * `projects/{project}/instances/{instance}`. Use `{instance} = '-'` to list + * Clusters for all Instances in a project, e.g., + * `projects/myproject/instances/-`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @param string $var diff --git a/Bigtable/src/Admin/V2/ListInstancesRequest.php b/Bigtable/src/Admin/V2/ListInstancesRequest.php index b65aff330037..e87c9af9c131 100644 --- a/Bigtable/src/Admin/V2/ListInstancesRequest.php +++ b/Bigtable/src/Admin/V2/ListInstancesRequest.php @@ -16,8 +16,8 @@ class ListInstancesRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The unique name of the project for which a list of instances is requested. - * Values are of the form `projects/{project}`. + * Required. The unique name of the project for which a list of instances is + * requested. Values are of the form `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ @@ -30,8 +30,8 @@ class ListInstancesRequest extends \Google\Protobuf\Internal\Message private $page_token = ''; /** - * @param string $parent Required. The unique name of the project for which a list of instances is requested. - * Values are of the form `projects/{project}`. Please see + * @param string $parent Required. The unique name of the project for which a list of instances is + * requested. Values are of the form `projects/{project}`. Please see * {@see BigtableInstanceAdminClient::projectName()} for help formatting this field. * * @return \Google\Cloud\Bigtable\Admin\V2\ListInstancesRequest @@ -51,8 +51,8 @@ public static function build(string $parent): self * Optional. Data for populating the Message object. * * @type string $parent - * Required. The unique name of the project for which a list of instances is requested. - * Values are of the form `projects/{project}`. + * Required. The unique name of the project for which a list of instances is + * requested. Values are of the form `projects/{project}`. * @type string $page_token * DEPRECATED: This field is unused and ignored. * } @@ -63,8 +63,8 @@ public function __construct($data = NULL) { } /** - * Required. The unique name of the project for which a list of instances is requested. - * Values are of the form `projects/{project}`. + * Required. The unique name of the project for which a list of instances is + * requested. Values are of the form `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @return string @@ -75,8 +75,8 @@ public function getParent() } /** - * Required. The unique name of the project for which a list of instances is requested. - * Values are of the form `projects/{project}`. + * Required. The unique name of the project for which a list of instances is + * requested. Values are of the form `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @param string $var diff --git a/Bigtable/src/Admin/V2/PartialUpdateClusterRequest.php b/Bigtable/src/Admin/V2/PartialUpdateClusterRequest.php index 7c0d70d10db4..d9d6c1483e99 100644 --- a/Bigtable/src/Admin/V2/PartialUpdateClusterRequest.php +++ b/Bigtable/src/Admin/V2/PartialUpdateClusterRequest.php @@ -16,8 +16,8 @@ class PartialUpdateClusterRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The Cluster which contains the partial updates to be applied, subject to - * the update_mask. + * Required. The Cluster which contains the partial updates to be applied, + * subject to the update_mask. * * Generated from protobuf field .google.bigtable.admin.v2.Cluster cluster = 1 [(.google.api.field_behavior) = REQUIRED]; */ @@ -30,8 +30,8 @@ class PartialUpdateClusterRequest extends \Google\Protobuf\Internal\Message private $update_mask = null; /** - * @param \Google\Cloud\Bigtable\Admin\V2\Cluster $cluster Required. The Cluster which contains the partial updates to be applied, subject to - * the update_mask. + * @param \Google\Cloud\Bigtable\Admin\V2\Cluster $cluster Required. The Cluster which contains the partial updates to be applied, + * subject to the update_mask. * @param \Google\Protobuf\FieldMask $updateMask Required. The subset of Cluster fields which should be replaced. * * @return \Google\Cloud\Bigtable\Admin\V2\PartialUpdateClusterRequest @@ -52,8 +52,8 @@ public static function build(\Google\Cloud\Bigtable\Admin\V2\Cluster $cluster, \ * Optional. Data for populating the Message object. * * @type \Google\Cloud\Bigtable\Admin\V2\Cluster $cluster - * Required. The Cluster which contains the partial updates to be applied, subject to - * the update_mask. + * Required. The Cluster which contains the partial updates to be applied, + * subject to the update_mask. * @type \Google\Protobuf\FieldMask $update_mask * Required. The subset of Cluster fields which should be replaced. * } @@ -64,8 +64,8 @@ public function __construct($data = NULL) { } /** - * Required. The Cluster which contains the partial updates to be applied, subject to - * the update_mask. + * Required. The Cluster which contains the partial updates to be applied, + * subject to the update_mask. * * Generated from protobuf field .google.bigtable.admin.v2.Cluster cluster = 1 [(.google.api.field_behavior) = REQUIRED]; * @return \Google\Cloud\Bigtable\Admin\V2\Cluster|null @@ -86,8 +86,8 @@ public function clearCluster() } /** - * Required. The Cluster which contains the partial updates to be applied, subject to - * the update_mask. + * Required. The Cluster which contains the partial updates to be applied, + * subject to the update_mask. * * Generated from protobuf field .google.bigtable.admin.v2.Cluster cluster = 1 [(.google.api.field_behavior) = REQUIRED]; * @param \Google\Cloud\Bigtable\Admin\V2\Cluster $var diff --git a/Bigtable/src/BigtableClient.php b/Bigtable/src/BigtableClient.php index 5e519616bef5..30e41e6dd7df 100644 --- a/Bigtable/src/BigtableClient.php +++ b/Bigtable/src/BigtableClient.php @@ -40,7 +40,7 @@ class BigtableClient { use ArrayTrait; - const VERSION = '1.28.3'; + const VERSION = '1.29.0'; /** * @var GapicClient diff --git a/Bigtable/src/V2/Client/BaseClient/BigtableBaseClient.php b/Bigtable/src/V2/Client/BaseClient/BigtableBaseClient.php deleted file mode 100644 index 2eab76000e34..000000000000 --- a/Bigtable/src/V2/Client/BaseClient/BigtableBaseClient.php +++ /dev/null @@ -1,470 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/bigtable_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/bigtable_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/bigtable_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/bigtable_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a instance - * resource. - * - * @param string $project - * @param string $instance - * - * @return string The formatted instance resource. - */ - public static function instanceName(string $project, string $instance): string - { - return self::getPathTemplate('instance')->render([ - 'project' => $project, - 'instance' => $instance, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a table - * resource. - * - * @param string $project - * @param string $instance - * @param string $table - * - * @return string The formatted table resource. - */ - public static function tableName(string $project, string $instance, string $table): string - { - return self::getPathTemplate('table')->render([ - 'project' => $project, - 'instance' => $instance, - 'table' => $table, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - instance: projects/{project}/instances/{instance} - * - table: projects/{project}/instances/{instance}/tables/{table} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'bigtable.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Mutates a row atomically based on the output of a predicate Reader filter. - * - * The async variant is {@see self::checkAndMutateRowAsync()} . - * - * @param CheckAndMutateRowRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CheckAndMutateRowResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function checkAndMutateRow(CheckAndMutateRowRequest $request, array $callOptions = []): CheckAndMutateRowResponse - { - return $this->startApiCall('CheckAndMutateRow', $request, $callOptions)->wait(); - } - - /** - * NOTE: This API is intended to be used by Apache Beam BigtableIO. - * Returns the current list of partitions that make up the table's - * change stream. The union of partitions will cover the entire keyspace. - * Partitions can be read with `ReadChangeStream`. - * - * @param GenerateInitialChangeStreamPartitionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return ServerStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function generateInitialChangeStreamPartitions(GenerateInitialChangeStreamPartitionsRequest $request, array $callOptions = []): ServerStream - { - return $this->startApiCall('GenerateInitialChangeStreamPartitions', $request, $callOptions); - } - - /** - * Mutates a row atomically. Cells already present in the row are left - * unchanged unless explicitly changed by `mutation`. - * - * The async variant is {@see self::mutateRowAsync()} . - * - * @param MutateRowRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MutateRowResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function mutateRow(MutateRowRequest $request, array $callOptions = []): MutateRowResponse - { - return $this->startApiCall('MutateRow', $request, $callOptions)->wait(); - } - - /** - * Mutates multiple rows in a batch. Each individual row is mutated - * atomically as in MutateRow, but the entire batch is not executed - * atomically. - * - * @param MutateRowsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return ServerStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function mutateRows(MutateRowsRequest $request, array $callOptions = []): ServerStream - { - return $this->startApiCall('MutateRows', $request, $callOptions); - } - - /** - * Warm up associated instance metadata for this connection. - * This call is not required but may be useful for connection keep-alive. - * - * The async variant is {@see self::pingAndWarmAsync()} . - * - * @param PingAndWarmRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PingAndWarmResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function pingAndWarm(PingAndWarmRequest $request, array $callOptions = []): PingAndWarmResponse - { - return $this->startApiCall('PingAndWarm', $request, $callOptions)->wait(); - } - - /** - * NOTE: This API is intended to be used by Apache Beam BigtableIO. - * Reads changes from a table's change stream. Changes will - * reflect both user-initiated mutations and mutations that are caused by - * garbage collection. - * - * @param ReadChangeStreamRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return ServerStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function readChangeStream(ReadChangeStreamRequest $request, array $callOptions = []): ServerStream - { - return $this->startApiCall('ReadChangeStream', $request, $callOptions); - } - - /** - * Modifies a row atomically on the server. The method reads the latest - * existing timestamp and value from the specified columns and writes a new - * entry based on pre-defined read/modify/write rules. The new value for the - * timestamp is the greater of the existing timestamp or the current server - * time. The method returns the new contents of all modified cells. - * - * The async variant is {@see self::readModifyWriteRowAsync()} . - * - * @param ReadModifyWriteRowRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ReadModifyWriteRowResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function readModifyWriteRow(ReadModifyWriteRowRequest $request, array $callOptions = []): ReadModifyWriteRowResponse - { - return $this->startApiCall('ReadModifyWriteRow', $request, $callOptions)->wait(); - } - - /** - * Streams back the contents of all requested rows in key order, optionally - * applying the same Reader filter to each. Depending on their size, - * rows and cells may be broken up across multiple responses, but - * atomicity of each row will still be preserved. See the - * ReadRowsResponse documentation for details. - * - * @param ReadRowsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return ServerStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function readRows(ReadRowsRequest $request, array $callOptions = []): ServerStream - { - return $this->startApiCall('ReadRows', $request, $callOptions); - } - - /** - * Returns a sample of row keys in the table. The returned row keys will - * delimit contiguous sections of the table of approximately equal size, - * which can be used to break up the data for distributed tasks like - * mapreduces. - * - * @param SampleRowKeysRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return ServerStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function sampleRowKeys(SampleRowKeysRequest $request, array $callOptions = []): ServerStream - { - return $this->startApiCall('SampleRowKeys', $request, $callOptions); - } -} diff --git a/Bigtable/src/V2/Client/BigtableClient.php b/Bigtable/src/V2/Client/BigtableClient.php index 0155d8640fc6..4406696e16df 100644 --- a/Bigtable/src/V2/Client/BigtableClient.php +++ b/Bigtable/src/V2/Client/BigtableClient.php @@ -24,17 +24,445 @@ namespace Google\Cloud\Bigtable\V2\Client; -use Google\Cloud\Bigtable\V2\Client\BaseClient\BigtableBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\ServerStream; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Bigtable\V2\CheckAndMutateRowRequest; +use Google\Cloud\Bigtable\V2\CheckAndMutateRowResponse; +use Google\Cloud\Bigtable\V2\GenerateInitialChangeStreamPartitionsRequest; +use Google\Cloud\Bigtable\V2\MutateRowRequest; +use Google\Cloud\Bigtable\V2\MutateRowResponse; +use Google\Cloud\Bigtable\V2\MutateRowsRequest; +use Google\Cloud\Bigtable\V2\MutateRowsRequest\Entry; +use Google\Cloud\Bigtable\V2\Mutation; +use Google\Cloud\Bigtable\V2\PingAndWarmRequest; +use Google\Cloud\Bigtable\V2\PingAndWarmResponse; +use Google\Cloud\Bigtable\V2\ReadChangeStreamRequest; +use Google\Cloud\Bigtable\V2\ReadModifyWriteRowRequest; +use Google\Cloud\Bigtable\V2\ReadModifyWriteRowResponse; +use Google\Cloud\Bigtable\V2\ReadRowsRequest; +use Google\Cloud\Bigtable\V2\SampleRowKeysRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for reading from and writing to existing Bigtable tables. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Bigtable\V2\BigtableClient} for the stable implementation * * @experimental + * + * @method PromiseInterface checkAndMutateRowAsync(CheckAndMutateRowRequest $request, array $optionalArgs = []) + * @method PromiseInterface mutateRowAsync(MutateRowRequest $request, array $optionalArgs = []) + * @method PromiseInterface pingAndWarmAsync(PingAndWarmRequest $request, array $optionalArgs = []) + * @method PromiseInterface readModifyWriteRowAsync(ReadModifyWriteRowRequest $request, array $optionalArgs = []) */ -final class BigtableClient extends BigtableBaseClient +final class BigtableClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see BigtableBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.bigtable.v2.Bigtable'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'bigtable.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/bigtable.data', + 'https://www.googleapis.com/auth/bigtable.data.readonly', + 'https://www.googleapis.com/auth/cloud-bigtable.data', + 'https://www.googleapis.com/auth/cloud-bigtable.data.readonly', + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/bigtable_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/bigtable_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/bigtable_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/bigtable_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a instance + * resource. + * + * @param string $project + * @param string $instance + * + * @return string The formatted instance resource. + */ + public static function instanceName(string $project, string $instance): string + { + return self::getPathTemplate('instance')->render([ + 'project' => $project, + 'instance' => $instance, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a table + * resource. + * + * @param string $project + * @param string $instance + * @param string $table + * + * @return string The formatted table resource. + */ + public static function tableName(string $project, string $instance, string $table): string + { + return self::getPathTemplate('table')->render([ + 'project' => $project, + 'instance' => $instance, + 'table' => $table, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - instance: projects/{project}/instances/{instance} + * - table: projects/{project}/instances/{instance}/tables/{table} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'bigtable.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Mutates a row atomically based on the output of a predicate Reader filter. + * + * The async variant is {@see BigtableClient::checkAndMutateRowAsync()} . + * + * @param CheckAndMutateRowRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CheckAndMutateRowResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function checkAndMutateRow(CheckAndMutateRowRequest $request, array $callOptions = []): CheckAndMutateRowResponse + { + return $this->startApiCall('CheckAndMutateRow', $request, $callOptions)->wait(); + } + + /** + * NOTE: This API is intended to be used by Apache Beam BigtableIO. + * Returns the current list of partitions that make up the table's + * change stream. The union of partitions will cover the entire keyspace. + * Partitions can be read with `ReadChangeStream`. + * + * @param GenerateInitialChangeStreamPartitionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return ServerStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function generateInitialChangeStreamPartitions(GenerateInitialChangeStreamPartitionsRequest $request, array $callOptions = []): ServerStream + { + return $this->startApiCall('GenerateInitialChangeStreamPartitions', $request, $callOptions); + } + + /** + * Mutates a row atomically. Cells already present in the row are left + * unchanged unless explicitly changed by `mutation`. + * + * The async variant is {@see BigtableClient::mutateRowAsync()} . + * + * @param MutateRowRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MutateRowResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function mutateRow(MutateRowRequest $request, array $callOptions = []): MutateRowResponse + { + return $this->startApiCall('MutateRow', $request, $callOptions)->wait(); + } + + /** + * Mutates multiple rows in a batch. Each individual row is mutated + * atomically as in MutateRow, but the entire batch is not executed + * atomically. + * + * @param MutateRowsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return ServerStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function mutateRows(MutateRowsRequest $request, array $callOptions = []): ServerStream + { + return $this->startApiCall('MutateRows', $request, $callOptions); + } + + /** + * Warm up associated instance metadata for this connection. + * This call is not required but may be useful for connection keep-alive. + * + * The async variant is {@see BigtableClient::pingAndWarmAsync()} . + * + * @param PingAndWarmRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PingAndWarmResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function pingAndWarm(PingAndWarmRequest $request, array $callOptions = []): PingAndWarmResponse + { + return $this->startApiCall('PingAndWarm', $request, $callOptions)->wait(); + } + + /** + * NOTE: This API is intended to be used by Apache Beam BigtableIO. + * Reads changes from a table's change stream. Changes will + * reflect both user-initiated mutations and mutations that are caused by + * garbage collection. + * + * @param ReadChangeStreamRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return ServerStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function readChangeStream(ReadChangeStreamRequest $request, array $callOptions = []): ServerStream + { + return $this->startApiCall('ReadChangeStream', $request, $callOptions); + } + + /** + * Modifies a row atomically on the server. The method reads the latest + * existing timestamp and value from the specified columns and writes a new + * entry based on pre-defined read/modify/write rules. The new value for the + * timestamp is the greater of the existing timestamp or the current server + * time. The method returns the new contents of all modified cells. + * + * The async variant is {@see BigtableClient::readModifyWriteRowAsync()} . + * + * @param ReadModifyWriteRowRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ReadModifyWriteRowResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function readModifyWriteRow(ReadModifyWriteRowRequest $request, array $callOptions = []): ReadModifyWriteRowResponse + { + return $this->startApiCall('ReadModifyWriteRow', $request, $callOptions)->wait(); + } + + /** + * Streams back the contents of all requested rows in key order, optionally + * applying the same Reader filter to each. Depending on their size, + * rows and cells may be broken up across multiple responses, but + * atomicity of each row will still be preserved. See the + * ReadRowsResponse documentation for details. + * + * @param ReadRowsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return ServerStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function readRows(ReadRowsRequest $request, array $callOptions = []): ServerStream + { + return $this->startApiCall('ReadRows', $request, $callOptions); + } + + /** + * Returns a sample of row keys in the table. The returned row keys will + * delimit contiguous sections of the table of approximately equal size, + * which can be used to break up the data for distributed tasks like + * mapreduces. + * + * @param SampleRowKeysRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return ServerStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function sampleRowKeys(SampleRowKeysRequest $request, array $callOptions = []): ServerStream + { + return $this->startApiCall('SampleRowKeys', $request, $callOptions); + } } diff --git a/Billing/composer.json b/Billing/composer.json index 253998bc6aa4..e6106cbe0e04 100644 --- a/Billing/composer.json +++ b/Billing/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Billing/src/V1/Client/BaseClient/CloudBillingBaseClient.php b/Billing/src/V1/Client/BaseClient/CloudBillingBaseClient.php deleted file mode 100644 index 1cec5b5328ff..000000000000 --- a/Billing/src/V1/Client/BaseClient/CloudBillingBaseClient.php +++ /dev/null @@ -1,575 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/cloud_billing_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/cloud_billing_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/cloud_billing_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/cloud_billing_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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(string $billingAccount): string - { - return self::getPathTemplate('billingAccount')->render([ - 'billing_account' => $billingAccount, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_billing_info resource. - * - * @param string $project - * - * @return string The formatted project_billing_info resource. - */ - public static function projectBillingInfoName(string $project): string - { - return self::getPathTemplate('projectBillingInfo')->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 - * - billingAccount: billingAccounts/{billing_account} - * - project: projects/{project} - * - projectBillingInfo: projects/{project}/billingInfo - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudbilling.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * This method creates [billing - * subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). - * - * Google Cloud resellers should use the - * Channel Services APIs, - * [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) - * and - * [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). - * - * When creating a subaccount, the current authenticated user must have the - * `billing.accounts.update` IAM permission on the parent account, which is - * typically given to billing account - * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). - * This method will return an error if the parent account has not been - * provisioned for subaccounts. - * - * The async variant is {@see self::createBillingAccountAsync()} . - * - * @param CreateBillingAccountRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BillingAccount - * - * @throws ApiException Thrown if the API call fails. - */ - public function createBillingAccount(CreateBillingAccountRequest $request, array $callOptions = []): BillingAccount - { - return $this->startApiCall('CreateBillingAccount', $request, $callOptions)->wait(); - } - - /** - * Gets information about a billing account. The current authenticated user - * must be a [viewer of the billing - * account](https://cloud.google.com/billing/docs/how-to/billing-access). - * - * The async variant is {@see self::getBillingAccountAsync()} . - * - * @param GetBillingAccountRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BillingAccount - * - * @throws ApiException Thrown if the API call fails. - */ - public function getBillingAccount(GetBillingAccountRequest $request, array $callOptions = []): BillingAccount - { - return $this->startApiCall('GetBillingAccount', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a billing account. - * The caller must have the `billing.accounts.getIamPolicy` permission on the - * account, which is often given to billing account - * [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets the billing information for a project. The current authenticated user - * must have the `resourcemanager.projects.get` permission for the project, - * which can be granted by assigning the [Project - * Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) - * role. - * - * The async variant is {@see self::getProjectBillingInfoAsync()} . - * - * @param GetProjectBillingInfoRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ProjectBillingInfo - * - * @throws ApiException Thrown if the API call fails. - */ - public function getProjectBillingInfo(GetProjectBillingInfoRequest $request, array $callOptions = []): ProjectBillingInfo - { - return $this->startApiCall('GetProjectBillingInfo', $request, $callOptions)->wait(); - } - - /** - * Lists the billing accounts that the current authenticated user has - * permission to - * [view](https://cloud.google.com/billing/docs/how-to/billing-access). - * - * The async variant is {@see self::listBillingAccountsAsync()} . - * - * @param ListBillingAccountsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listBillingAccounts(ListBillingAccountsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListBillingAccounts', $request, $callOptions); - } - - /** - * Lists the projects associated with a billing account. The current - * authenticated user must have the `billing.resourceAssociations.list` IAM - * permission, which is often given to billing account - * [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). - * - * The async variant is {@see self::listProjectBillingInfoAsync()} . - * - * @param ListProjectBillingInfoRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listProjectBillingInfo(ListProjectBillingInfoRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListProjectBillingInfo', $request, $callOptions); - } - - /** - * Sets the access control policy for a billing account. Replaces any existing - * policy. - * The caller must have the `billing.accounts.setIamPolicy` permission on the - * account, which is often given to billing account - * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Tests the access control policy for a billing account. This method takes - * the resource and a set of permissions as input and returns the subset of - * the input permissions that the caller is allowed for that resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Updates a billing account's fields. - * Currently the only field that can be edited is `display_name`. - * The current authenticated user must have the `billing.accounts.update` - * IAM permission, which is typically given to the - * [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) - * of the billing account. - * - * The async variant is {@see self::updateBillingAccountAsync()} . - * - * @param UpdateBillingAccountRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BillingAccount - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateBillingAccount(UpdateBillingAccountRequest $request, array $callOptions = []): BillingAccount - { - return $this->startApiCall('UpdateBillingAccount', $request, $callOptions)->wait(); - } - - /** - * Sets or updates the billing account associated with a project. You specify - * the new billing account by setting the `billing_account_name` in the - * `ProjectBillingInfo` resource to the resource name of a billing account. - * Associating a project with an open billing account enables billing on the - * project and allows charges for resource usage. If the project already had a - * billing account, this method changes the billing account used for resource - * usage charges. - * - * *Note:* Incurred charges that have not yet been reported in the transaction - * history of the Google Cloud Console might be billed to the new billing - * account, even if the charge occurred before the new billing account was - * assigned to the project. - * - * The current authenticated user must have ownership privileges for both the - * [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo - * ) and the [billing - * account](https://cloud.google.com/billing/docs/how-to/billing-access). - * - * You can disable billing on the project by setting the - * `billing_account_name` field to empty. This action disassociates the - * current billing account from the project. Any billable activity of your - * in-use services will stop, and your application could stop functioning as - * expected. Any unbilled charges to date will be billed to the previously - * associated account. The current authenticated user must be either an owner - * of the project or an owner of the billing account for the project. - * - * Note that associating a project with a *closed* billing account will have - * much the same effect as disabling billing on the project: any paid - * resources used by the project will be shut down. Thus, unless you wish to - * disable billing, you should always call this method with the name of an - * *open* billing account. - * - * The async variant is {@see self::updateProjectBillingInfoAsync()} . - * - * @param UpdateProjectBillingInfoRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ProjectBillingInfo - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateProjectBillingInfo(UpdateProjectBillingInfoRequest $request, array $callOptions = []): ProjectBillingInfo - { - return $this->startApiCall('UpdateProjectBillingInfo', $request, $callOptions)->wait(); - } -} diff --git a/Billing/src/V1/Client/BaseClient/CloudCatalogBaseClient.php b/Billing/src/V1/Client/BaseClient/CloudCatalogBaseClient.php deleted file mode 100644 index 3173e8eb1364..000000000000 --- a/Billing/src/V1/Client/BaseClient/CloudCatalogBaseClient.php +++ /dev/null @@ -1,263 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/cloud_catalog_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/cloud_catalog_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/cloud_catalog_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/cloud_catalog_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a service - * resource. - * - * @param string $service - * - * @return string The formatted service resource. - */ - public static function serviceName(string $service): string - { - return self::getPathTemplate('service')->render([ - 'service' => $service, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - service: services/{service} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudbilling.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Lists all public cloud services. - * - * The async variant is {@see self::listServicesAsync()} . - * - * @param ListServicesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listServices(ListServicesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListServices', $request, $callOptions); - } - - /** - * Lists all publicly available SKUs for a given cloud service. - * - * The async variant is {@see self::listSkusAsync()} . - * - * @param ListSkusRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSkus(ListSkusRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSkus', $request, $callOptions); - } -} diff --git a/Billing/src/V1/Client/CloudBillingClient.php b/Billing/src/V1/Client/CloudBillingClient.php index e9741a831a04..41213378b1d8 100644 --- a/Billing/src/V1/Client/CloudBillingClient.php +++ b/Billing/src/V1/Client/CloudBillingClient.php @@ -24,17 +24,551 @@ namespace Google\Cloud\Billing\V1\Client; -use Google\Cloud\Billing\V1\Client\BaseClient\CloudBillingBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Billing\V1\BillingAccount; +use Google\Cloud\Billing\V1\CreateBillingAccountRequest; +use Google\Cloud\Billing\V1\GetBillingAccountRequest; +use Google\Cloud\Billing\V1\GetProjectBillingInfoRequest; +use Google\Cloud\Billing\V1\ListBillingAccountsRequest; +use Google\Cloud\Billing\V1\ListProjectBillingInfoRequest; +use Google\Cloud\Billing\V1\ProjectBillingInfo; +use Google\Cloud\Billing\V1\UpdateBillingAccountRequest; +use Google\Cloud\Billing\V1\UpdateProjectBillingInfoRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Retrieves the Google Cloud Console billing accounts and associates them with + * projects. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Billing\V1\CloudBillingClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createBillingAccountAsync(CreateBillingAccountRequest $request, array $optionalArgs = []) + * @method PromiseInterface getBillingAccountAsync(GetBillingAccountRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getProjectBillingInfoAsync(GetProjectBillingInfoRequest $request, array $optionalArgs = []) + * @method PromiseInterface listBillingAccountsAsync(ListBillingAccountsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listProjectBillingInfoAsync(ListProjectBillingInfoRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateBillingAccountAsync(UpdateBillingAccountRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateProjectBillingInfoAsync(UpdateProjectBillingInfoRequest $request, array $optionalArgs = []) */ -final class CloudBillingClient extends CloudBillingBaseClient +final class CloudBillingClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CloudBillingBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.billing.v1.CloudBilling'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudbilling.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-billing', + 'https://www.googleapis.com/auth/cloud-billing.readonly', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/cloud_billing_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/cloud_billing_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/cloud_billing_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/cloud_billing_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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(string $billingAccount): string + { + return self::getPathTemplate('billingAccount')->render([ + 'billing_account' => $billingAccount, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_billing_info resource. + * + * @param string $project + * + * @return string The formatted project_billing_info resource. + */ + public static function projectBillingInfoName(string $project): string + { + return self::getPathTemplate('projectBillingInfo')->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 + * - billingAccount: billingAccounts/{billing_account} + * - project: projects/{project} + * - projectBillingInfo: projects/{project}/billingInfo + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudbilling.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * This method creates [billing + * subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). + * + * Google Cloud resellers should use the + * Channel Services APIs, + * [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) + * and + * [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). + * + * When creating a subaccount, the current authenticated user must have the + * `billing.accounts.update` IAM permission on the parent account, which is + * typically given to billing account + * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). + * This method will return an error if the parent account has not been + * provisioned for subaccounts. + * + * The async variant is {@see CloudBillingClient::createBillingAccountAsync()} . + * + * @param CreateBillingAccountRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BillingAccount + * + * @throws ApiException Thrown if the API call fails. + */ + public function createBillingAccount(CreateBillingAccountRequest $request, array $callOptions = []): BillingAccount + { + return $this->startApiCall('CreateBillingAccount', $request, $callOptions)->wait(); + } + + /** + * Gets information about a billing account. The current authenticated user + * must be a [viewer of the billing + * account](https://cloud.google.com/billing/docs/how-to/billing-access). + * + * The async variant is {@see CloudBillingClient::getBillingAccountAsync()} . + * + * @param GetBillingAccountRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BillingAccount + * + * @throws ApiException Thrown if the API call fails. + */ + public function getBillingAccount(GetBillingAccountRequest $request, array $callOptions = []): BillingAccount + { + return $this->startApiCall('GetBillingAccount', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a billing account. + * The caller must have the `billing.accounts.getIamPolicy` permission on the + * account, which is often given to billing account + * [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). + * + * The async variant is {@see CloudBillingClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets the billing information for a project. The current authenticated user + * must have the `resourcemanager.projects.get` permission for the project, + * which can be granted by assigning the [Project + * Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) + * role. + * + * The async variant is {@see CloudBillingClient::getProjectBillingInfoAsync()} . + * + * @param GetProjectBillingInfoRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ProjectBillingInfo + * + * @throws ApiException Thrown if the API call fails. + */ + public function getProjectBillingInfo(GetProjectBillingInfoRequest $request, array $callOptions = []): ProjectBillingInfo + { + return $this->startApiCall('GetProjectBillingInfo', $request, $callOptions)->wait(); + } + + /** + * Lists the billing accounts that the current authenticated user has + * permission to + * [view](https://cloud.google.com/billing/docs/how-to/billing-access). + * + * The async variant is {@see CloudBillingClient::listBillingAccountsAsync()} . + * + * @param ListBillingAccountsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listBillingAccounts(ListBillingAccountsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListBillingAccounts', $request, $callOptions); + } + + /** + * Lists the projects associated with a billing account. The current + * authenticated user must have the `billing.resourceAssociations.list` IAM + * permission, which is often given to billing account + * [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). + * + * The async variant is {@see CloudBillingClient::listProjectBillingInfoAsync()} . + * + * @param ListProjectBillingInfoRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listProjectBillingInfo(ListProjectBillingInfoRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListProjectBillingInfo', $request, $callOptions); + } + + /** + * Sets the access control policy for a billing account. Replaces any existing + * policy. + * The caller must have the `billing.accounts.setIamPolicy` permission on the + * account, which is often given to billing account + * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). + * + * The async variant is {@see CloudBillingClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Tests the access control policy for a billing account. This method takes + * the resource and a set of permissions as input and returns the subset of + * the input permissions that the caller is allowed for that resource. + * + * The async variant is {@see CloudBillingClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates a billing account's fields. + * Currently the only field that can be edited is `display_name`. + * The current authenticated user must have the `billing.accounts.update` + * IAM permission, which is typically given to the + * [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) + * of the billing account. + * + * The async variant is {@see CloudBillingClient::updateBillingAccountAsync()} . + * + * @param UpdateBillingAccountRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BillingAccount + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateBillingAccount(UpdateBillingAccountRequest $request, array $callOptions = []): BillingAccount + { + return $this->startApiCall('UpdateBillingAccount', $request, $callOptions)->wait(); + } + + /** + * Sets or updates the billing account associated with a project. You specify + * the new billing account by setting the `billing_account_name` in the + * `ProjectBillingInfo` resource to the resource name of a billing account. + * Associating a project with an open billing account enables billing on the + * project and allows charges for resource usage. If the project already had a + * billing account, this method changes the billing account used for resource + * usage charges. + * + * *Note:* Incurred charges that have not yet been reported in the transaction + * history of the Google Cloud Console might be billed to the new billing + * account, even if the charge occurred before the new billing account was + * assigned to the project. + * + * The current authenticated user must have ownership privileges for both the + * [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo + * ) and the [billing + * account](https://cloud.google.com/billing/docs/how-to/billing-access). + * + * You can disable billing on the project by setting the + * `billing_account_name` field to empty. This action disassociates the + * current billing account from the project. Any billable activity of your + * in-use services will stop, and your application could stop functioning as + * expected. Any unbilled charges to date will be billed to the previously + * associated account. The current authenticated user must be either an owner + * of the project or an owner of the billing account for the project. + * + * Note that associating a project with a *closed* billing account will have + * much the same effect as disabling billing on the project: any paid + * resources used by the project will be shut down. Thus, unless you wish to + * disable billing, you should always call this method with the name of an + * *open* billing account. + * + * The async variant is {@see CloudBillingClient::updateProjectBillingInfoAsync()} + * . + * + * @param UpdateProjectBillingInfoRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ProjectBillingInfo + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateProjectBillingInfo(UpdateProjectBillingInfoRequest $request, array $callOptions = []): ProjectBillingInfo + { + return $this->startApiCall('UpdateProjectBillingInfo', $request, $callOptions)->wait(); + } } diff --git a/Billing/src/V1/Client/CloudCatalogClient.php b/Billing/src/V1/Client/CloudCatalogClient.php index c69f5a2e206c..b99c8efab945 100644 --- a/Billing/src/V1/Client/CloudCatalogClient.php +++ b/Billing/src/V1/Client/CloudCatalogClient.php @@ -24,17 +24,238 @@ namespace Google\Cloud\Billing\V1\Client; -use Google\Cloud\Billing\V1\Client\BaseClient\CloudCatalogBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Billing\V1\ListServicesRequest; +use Google\Cloud\Billing\V1\ListSkusRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A catalog of Google Cloud Platform services and SKUs. + * Provides pricing information and metadata on Google Cloud Platform services + * and SKUs. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Billing\V1\CloudCatalogClient} for the stable implementation * * @experimental + * + * @method PromiseInterface listServicesAsync(ListServicesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSkusAsync(ListSkusRequest $request, array $optionalArgs = []) */ -final class CloudCatalogClient extends CloudCatalogBaseClient +final class CloudCatalogClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CloudCatalogBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.billing.v1.CloudCatalog'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudbilling.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-billing', + 'https://www.googleapis.com/auth/cloud-billing.readonly', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/cloud_catalog_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/cloud_catalog_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/cloud_catalog_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/cloud_catalog_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a service + * resource. + * + * @param string $service + * + * @return string The formatted service resource. + */ + public static function serviceName(string $service): string + { + return self::getPathTemplate('service')->render([ + 'service' => $service, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - service: services/{service} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudbilling.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Lists all public cloud services. + * + * The async variant is {@see CloudCatalogClient::listServicesAsync()} . + * + * @param ListServicesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listServices(ListServicesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListServices', $request, $callOptions); + } + + /** + * Lists all publicly available SKUs for a given cloud service. + * + * The async variant is {@see CloudCatalogClient::listSkusAsync()} . + * + * @param ListSkusRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSkus(ListSkusRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSkus', $request, $callOptions); + } } diff --git a/BillingBudgets/composer.json b/BillingBudgets/composer.json index ed5a09d344f4..154772032091 100644 --- a/BillingBudgets/composer.json +++ b/BillingBudgets/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/BillingBudgets/src/V1/Client/BaseClient/BudgetServiceBaseClient.php b/BillingBudgets/src/V1/Client/BaseClient/BudgetServiceBaseClient.php deleted file mode 100644 index 161acce50fae..000000000000 --- a/BillingBudgets/src/V1/Client/BaseClient/BudgetServiceBaseClient.php +++ /dev/null @@ -1,373 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/budget_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/budget_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/budget_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/budget_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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(string $billingAccount): string - { - return self::getPathTemplate('billingAccount')->render([ - 'billing_account' => $billingAccount, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a budget - * resource. - * - * @param string $billingAccount - * @param string $budget - * - * @return string The formatted budget resource. - */ - public static function budgetName(string $billingAccount, string $budget): string - { - return self::getPathTemplate('budget')->render([ - 'billing_account' => $billingAccount, - 'budget' => $budget, - ]); - } - - /** - * 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} - * - budget: billingAccounts/{billing_account}/budgets/{budget} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'billingbudgets.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new budget. See - * [Quotas and limits](https://cloud.google.com/billing/quotas) - * for more information on the limits of the number of budgets you can create. - * - * The async variant is {@see self::createBudgetAsync()} . - * - * @param CreateBudgetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Budget - * - * @throws ApiException Thrown if the API call fails. - */ - public function createBudget(CreateBudgetRequest $request, array $callOptions = []): Budget - { - return $this->startApiCall('CreateBudget', $request, $callOptions)->wait(); - } - - /** - * Deletes a budget. Returns successfully if already deleted. - * - * The async variant is {@see self::deleteBudgetAsync()} . - * - * @param DeleteBudgetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteBudget(DeleteBudgetRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteBudget', $request, $callOptions)->wait(); - } - - /** - * Returns a budget. - * - * WARNING: There are some fields exposed on the Google Cloud Console that - * aren't available on this API. When reading from the API, you will not - * see these fields in the return value, though they may have been set - * in the Cloud Console. - * - * The async variant is {@see self::getBudgetAsync()} . - * - * @param GetBudgetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Budget - * - * @throws ApiException Thrown if the API call fails. - */ - public function getBudget(GetBudgetRequest $request, array $callOptions = []): Budget - { - return $this->startApiCall('GetBudget', $request, $callOptions)->wait(); - } - - /** - * Returns a list of budgets for a billing account. - * - * WARNING: There are some fields exposed on the Google Cloud Console that - * aren't available on this API. When reading from the API, you will not - * see these fields in the return value, though they may have been set - * in the Cloud Console. - * - * The async variant is {@see self::listBudgetsAsync()} . - * - * @param ListBudgetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listBudgets(ListBudgetsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListBudgets', $request, $callOptions); - } - - /** - * Updates a budget and returns the updated budget. - * - * WARNING: There are some fields exposed on the Google Cloud Console that - * aren't available on this API. Budget fields that are not exposed in - * this API will not be changed by this method. - * - * The async variant is {@see self::updateBudgetAsync()} . - * - * @param UpdateBudgetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Budget - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateBudget(UpdateBudgetRequest $request, array $callOptions = []): Budget - { - return $this->startApiCall('UpdateBudget', $request, $callOptions)->wait(); - } -} diff --git a/BillingBudgets/src/V1/Client/BudgetServiceClient.php b/BillingBudgets/src/V1/Client/BudgetServiceClient.php index bf47d414f0a9..3dd1e331e72b 100644 --- a/BillingBudgets/src/V1/Client/BudgetServiceClient.php +++ b/BillingBudgets/src/V1/Client/BudgetServiceClient.php @@ -24,17 +24,348 @@ namespace Google\Cloud\Billing\Budgets\V1\Client; -use Google\Cloud\Billing\Budgets\V1\Client\BaseClient\BudgetServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Billing\Budgets\V1\Budget; +use Google\Cloud\Billing\Budgets\V1\CreateBudgetRequest; +use Google\Cloud\Billing\Budgets\V1\DeleteBudgetRequest; +use Google\Cloud\Billing\Budgets\V1\GetBudgetRequest; +use Google\Cloud\Billing\Budgets\V1\ListBudgetsRequest; +use Google\Cloud\Billing\Budgets\V1\UpdateBudgetRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: BudgetService stores Cloud Billing budgets, which define a + * budget plan and rules to execute as we track spend against that plan. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Billing\Budgets\V1\BudgetServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createBudgetAsync(CreateBudgetRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteBudgetAsync(DeleteBudgetRequest $request, array $optionalArgs = []) + * @method PromiseInterface getBudgetAsync(GetBudgetRequest $request, array $optionalArgs = []) + * @method PromiseInterface listBudgetsAsync(ListBudgetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateBudgetAsync(UpdateBudgetRequest $request, array $optionalArgs = []) */ -final class BudgetServiceClient extends BudgetServiceBaseClient +final class BudgetServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see BudgetServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.billing.budgets.v1.BudgetService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'billingbudgets.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-billing', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/budget_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/budget_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/budget_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/budget_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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(string $billingAccount): string + { + return self::getPathTemplate('billingAccount')->render([ + 'billing_account' => $billingAccount, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a budget + * resource. + * + * @param string $billingAccount + * @param string $budget + * + * @return string The formatted budget resource. + */ + public static function budgetName(string $billingAccount, string $budget): string + { + return self::getPathTemplate('budget')->render([ + 'billing_account' => $billingAccount, + 'budget' => $budget, + ]); + } + + /** + * 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} + * - budget: billingAccounts/{billing_account}/budgets/{budget} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'billingbudgets.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new budget. See + * [Quotas and limits](https://cloud.google.com/billing/quotas) + * for more information on the limits of the number of budgets you can create. + * + * The async variant is {@see BudgetServiceClient::createBudgetAsync()} . + * + * @param CreateBudgetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Budget + * + * @throws ApiException Thrown if the API call fails. + */ + public function createBudget(CreateBudgetRequest $request, array $callOptions = []): Budget + { + return $this->startApiCall('CreateBudget', $request, $callOptions)->wait(); + } + + /** + * Deletes a budget. Returns successfully if already deleted. + * + * The async variant is {@see BudgetServiceClient::deleteBudgetAsync()} . + * + * @param DeleteBudgetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteBudget(DeleteBudgetRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteBudget', $request, $callOptions)->wait(); + } + + /** + * Returns a budget. + * + * WARNING: There are some fields exposed on the Google Cloud Console that + * aren't available on this API. When reading from the API, you will not + * see these fields in the return value, though they may have been set + * in the Cloud Console. + * + * The async variant is {@see BudgetServiceClient::getBudgetAsync()} . + * + * @param GetBudgetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Budget + * + * @throws ApiException Thrown if the API call fails. + */ + public function getBudget(GetBudgetRequest $request, array $callOptions = []): Budget + { + return $this->startApiCall('GetBudget', $request, $callOptions)->wait(); + } + + /** + * Returns a list of budgets for a billing account. + * + * WARNING: There are some fields exposed on the Google Cloud Console that + * aren't available on this API. When reading from the API, you will not + * see these fields in the return value, though they may have been set + * in the Cloud Console. + * + * The async variant is {@see BudgetServiceClient::listBudgetsAsync()} . + * + * @param ListBudgetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listBudgets(ListBudgetsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListBudgets', $request, $callOptions); + } + + /** + * Updates a budget and returns the updated budget. + * + * WARNING: There are some fields exposed on the Google Cloud Console that + * aren't available on this API. Budget fields that are not exposed in + * this API will not be changed by this method. + * + * The async variant is {@see BudgetServiceClient::updateBudgetAsync()} . + * + * @param UpdateBudgetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Budget + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateBudget(UpdateBudgetRequest $request, array $callOptions = []): Budget + { + return $this->startApiCall('UpdateBudget', $request, $callOptions)->wait(); + } } diff --git a/BinaryAuthorization/composer.json b/BinaryAuthorization/composer.json index b6610519f4fd..fb8295bcc1ca 100644 --- a/BinaryAuthorization/composer.json +++ b/BinaryAuthorization/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1", + "google/gax": "^1.24.0", "google/grafeas": "^0.8.0" }, "require-dev": { diff --git a/BinaryAuthorization/src/V1/Client/BaseClient/BinauthzManagementServiceV1BaseClient.php b/BinaryAuthorization/src/V1/Client/BaseClient/BinauthzManagementServiceV1BaseClient.php deleted file mode 100644 index 18d3d0bf207d..000000000000 --- a/BinaryAuthorization/src/V1/Client/BaseClient/BinauthzManagementServiceV1BaseClient.php +++ /dev/null @@ -1,491 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/binauthz_management_service_v1_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/binauthz_management_service_v1_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/binauthz_management_service_v1_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/binauthz_management_service_v1_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a attestor - * resource. - * - * @param string $project - * @param string $attestor - * - * @return string The formatted attestor resource. - */ - public static function attestorName(string $project, string $attestor): string - { - return self::getPathTemplate('attestor')->render([ - 'project' => $project, - 'attestor' => $attestor, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * location_policy resource. - * - * @param string $location - * - * @return string The formatted location_policy resource. - */ - public static function locationPolicyName(string $location): string - { - return self::getPathTemplate('locationPolicy')->render([ - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a policy - * resource. - * - * @param string $project - * - * @return string The formatted policy resource. - */ - public static function policyName(string $project): string - { - return self::getPathTemplate('policy')->render([ - 'project' => $project, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_policy resource. - * - * @param string $project - * - * @return string The formatted project_policy resource. - */ - public static function projectPolicyName(string $project): string - { - return self::getPathTemplate('projectPolicy')->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 - * - attestor: projects/{project}/attestors/{attestor} - * - locationPolicy: locations/{location}/policy - * - policy: projects/{project}/policy - * - project: projects/{project} - * - projectPolicy: projects/{project}/policy - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'binaryauthorization.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates an [attestor][google.cloud.binaryauthorization.v1.Attestor], and returns a copy of the new - * [attestor][google.cloud.binaryauthorization.v1.Attestor]. Returns NOT_FOUND if the project does not exist, - * INVALID_ARGUMENT if the request is malformed, ALREADY_EXISTS if the - * [attestor][google.cloud.binaryauthorization.v1.Attestor] already exists. - * - * The async variant is {@see self::createAttestorAsync()} . - * - * @example samples/V1/BinauthzManagementServiceV1Client/create_attestor.php - * - * @param CreateAttestorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Attestor - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAttestor(CreateAttestorRequest $request, array $callOptions = []): Attestor - { - return $this->startApiCall('CreateAttestor', $request, $callOptions)->wait(); - } - - /** - * Deletes an [attestor][google.cloud.binaryauthorization.v1.Attestor]. Returns NOT_FOUND if the - * [attestor][google.cloud.binaryauthorization.v1.Attestor] does not exist. - * - * The async variant is {@see self::deleteAttestorAsync()} . - * - * @example samples/V1/BinauthzManagementServiceV1Client/delete_attestor.php - * - * @param DeleteAttestorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAttestor(DeleteAttestorRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteAttestor', $request, $callOptions)->wait(); - } - - /** - * Gets an [attestor][google.cloud.binaryauthorization.v1.Attestor]. - * Returns NOT_FOUND if the [attestor][google.cloud.binaryauthorization.v1.Attestor] does not exist. - * - * The async variant is {@see self::getAttestorAsync()} . - * - * @example samples/V1/BinauthzManagementServiceV1Client/get_attestor.php - * - * @param GetAttestorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Attestor - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAttestor(GetAttestorRequest $request, array $callOptions = []): Attestor - { - return $this->startApiCall('GetAttestor', $request, $callOptions)->wait(); - } - - /** - * A [policy][google.cloud.binaryauthorization.v1.Policy] specifies the [attestors][google.cloud.binaryauthorization.v1.Attestor] that must attest to - * a container image, before the project is allowed to deploy that - * image. There is at most one policy per project. All image admission - * requests are permitted if a project has no policy. - * - * Gets the [policy][google.cloud.binaryauthorization.v1.Policy] for this project. Returns a default - * [policy][google.cloud.binaryauthorization.v1.Policy] if the project does not have one. - * - * The async variant is {@see self::getPolicyAsync()} . - * - * @example samples/V1/BinauthzManagementServiceV1Client/get_policy.php - * - * @param GetPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getPolicy(GetPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetPolicy', $request, $callOptions)->wait(); - } - - /** - * Lists [attestors][google.cloud.binaryauthorization.v1.Attestor]. - * Returns INVALID_ARGUMENT if the project does not exist. - * - * The async variant is {@see self::listAttestorsAsync()} . - * - * @example samples/V1/BinauthzManagementServiceV1Client/list_attestors.php - * - * @param ListAttestorsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAttestors(ListAttestorsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAttestors', $request, $callOptions); - } - - /** - * Updates an [attestor][google.cloud.binaryauthorization.v1.Attestor]. - * Returns NOT_FOUND if the [attestor][google.cloud.binaryauthorization.v1.Attestor] does not exist. - * - * The async variant is {@see self::updateAttestorAsync()} . - * - * @example samples/V1/BinauthzManagementServiceV1Client/update_attestor.php - * - * @param UpdateAttestorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Attestor - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAttestor(UpdateAttestorRequest $request, array $callOptions = []): Attestor - { - return $this->startApiCall('UpdateAttestor', $request, $callOptions)->wait(); - } - - /** - * Creates or updates a project's [policy][google.cloud.binaryauthorization.v1.Policy], and returns a copy of the - * new [policy][google.cloud.binaryauthorization.v1.Policy]. A policy is always updated as a whole, to avoid race - * conditions with concurrent policy enforcement (or management!) - * requests. Returns NOT_FOUND if the project does not exist, INVALID_ARGUMENT - * if the request is malformed. - * - * The async variant is {@see self::updatePolicyAsync()} . - * - * @example samples/V1/BinauthzManagementServiceV1Client/update_policy.php - * - * @param UpdatePolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function updatePolicy(UpdatePolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('UpdatePolicy', $request, $callOptions)->wait(); - } -} diff --git a/BinaryAuthorization/src/V1/Client/BaseClient/SystemPolicyV1BaseClient.php b/BinaryAuthorization/src/V1/Client/BaseClient/SystemPolicyV1BaseClient.php deleted file mode 100644 index 4bd3be8cedad..000000000000 --- a/BinaryAuthorization/src/V1/Client/BaseClient/SystemPolicyV1BaseClient.php +++ /dev/null @@ -1,266 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/system_policy_v1_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/system_policy_v1_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/system_policy_v1_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/system_policy_v1_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * location_policy resource. - * - * @param string $location - * - * @return string The formatted location_policy resource. - */ - public static function locationPolicyName(string $location): string - { - return self::getPathTemplate('locationPolicy')->render([ - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a policy - * resource. - * - * @param string $project - * - * @return string The formatted policy resource. - */ - public static function policyName(string $project): string - { - return self::getPathTemplate('policy')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_policy resource. - * - * @param string $project - * - * @return string The formatted project_policy resource. - */ - public static function projectPolicyName(string $project): string - { - return self::getPathTemplate('projectPolicy')->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 - * - locationPolicy: locations/{location}/policy - * - policy: projects/{project}/policy - * - projectPolicy: projects/{project}/policy - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'binaryauthorization.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Gets the current system policy in the specified location. - * - * The async variant is {@see self::getSystemPolicyAsync()} . - * - * @example samples/V1/SystemPolicyV1Client/get_system_policy.php - * - * @param GetSystemPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSystemPolicy(GetSystemPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetSystemPolicy', $request, $callOptions)->wait(); - } -} diff --git a/BinaryAuthorization/src/V1/Client/BaseClient/ValidationHelperV1BaseClient.php b/BinaryAuthorization/src/V1/Client/BaseClient/ValidationHelperV1BaseClient.php deleted file mode 100644 index 3ec704cb3dee..000000000000 --- a/BinaryAuthorization/src/V1/Client/BaseClient/ValidationHelperV1BaseClient.php +++ /dev/null @@ -1,189 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/validation_helper_v1_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/validation_helper_v1_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/validation_helper_v1_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/validation_helper_v1_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'binaryauthorization.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Returns whether the given Attestation for the given image URI - * was signed by the given Attestor - * - * The async variant is {@see self::validateAttestationOccurrenceAsync()} . - * - * @example samples/V1/ValidationHelperV1Client/validate_attestation_occurrence.php - * - * @param ValidateAttestationOccurrenceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ValidateAttestationOccurrenceResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function validateAttestationOccurrence(ValidateAttestationOccurrenceRequest $request, array $callOptions = []): ValidateAttestationOccurrenceResponse - { - return $this->startApiCall('ValidateAttestationOccurrence', $request, $callOptions)->wait(); - } -} diff --git a/BinaryAuthorization/src/V1/Client/BinauthzManagementServiceV1Client.php b/BinaryAuthorization/src/V1/Client/BinauthzManagementServiceV1Client.php index 783cccfb2a84..80e10ee0ef0b 100644 --- a/BinaryAuthorization/src/V1/Client/BinauthzManagementServiceV1Client.php +++ b/BinaryAuthorization/src/V1/Client/BinauthzManagementServiceV1Client.php @@ -24,17 +24,473 @@ namespace Google\Cloud\BinaryAuthorization\V1\Client; -use Google\Cloud\BinaryAuthorization\V1\Client\BaseClient\BinauthzManagementServiceV1BaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\BinaryAuthorization\V1\Attestor; +use Google\Cloud\BinaryAuthorization\V1\CreateAttestorRequest; +use Google\Cloud\BinaryAuthorization\V1\DeleteAttestorRequest; +use Google\Cloud\BinaryAuthorization\V1\GetAttestorRequest; +use Google\Cloud\BinaryAuthorization\V1\GetPolicyRequest; +use Google\Cloud\BinaryAuthorization\V1\ListAttestorsRequest; +use Google\Cloud\BinaryAuthorization\V1\Policy; +use Google\Cloud\BinaryAuthorization\V1\UpdateAttestorRequest; +use Google\Cloud\BinaryAuthorization\V1\UpdatePolicyRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Google Cloud Management Service for Binary Authorization admission policies + * and attestation authorities. + * + * This API implements a REST model with the following objects: + * + * * [Policy][google.cloud.binaryauthorization.v1.Policy] + * * [Attestor][google.cloud.binaryauthorization.v1.Attestor] + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createAttestorAsync(CreateAttestorRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAttestorAsync(DeleteAttestorRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAttestorAsync(GetAttestorRequest $request, array $optionalArgs = []) + * @method PromiseInterface getPolicyAsync(GetPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAttestorsAsync(ListAttestorsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAttestorAsync(UpdateAttestorRequest $request, array $optionalArgs = []) + * @method PromiseInterface updatePolicyAsync(UpdatePolicyRequest $request, array $optionalArgs = []) */ -final class BinauthzManagementServiceV1Client extends BinauthzManagementServiceV1BaseClient +final class BinauthzManagementServiceV1Client { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see BinauthzManagementServiceV1BaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'binaryauthorization.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/binauthz_management_service_v1_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/binauthz_management_service_v1_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/binauthz_management_service_v1_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/binauthz_management_service_v1_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a attestor + * resource. + * + * @param string $project + * @param string $attestor + * + * @return string The formatted attestor resource. + */ + public static function attestorName(string $project, string $attestor): string + { + return self::getPathTemplate('attestor')->render([ + 'project' => $project, + 'attestor' => $attestor, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * location_policy resource. + * + * @param string $location + * + * @return string The formatted location_policy resource. + */ + public static function locationPolicyName(string $location): string + { + return self::getPathTemplate('locationPolicy')->render([ + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a policy + * resource. + * + * @param string $project + * + * @return string The formatted policy resource. + */ + public static function policyName(string $project): string + { + return self::getPathTemplate('policy')->render([ + 'project' => $project, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_policy resource. + * + * @param string $project + * + * @return string The formatted project_policy resource. + */ + public static function projectPolicyName(string $project): string + { + return self::getPathTemplate('projectPolicy')->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 + * - attestor: projects/{project}/attestors/{attestor} + * - locationPolicy: locations/{location}/policy + * - policy: projects/{project}/policy + * - project: projects/{project} + * - projectPolicy: projects/{project}/policy + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'binaryauthorization.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates an [attestor][google.cloud.binaryauthorization.v1.Attestor], and returns a copy of the new + * [attestor][google.cloud.binaryauthorization.v1.Attestor]. Returns NOT_FOUND if the project does not exist, + * INVALID_ARGUMENT if the request is malformed, ALREADY_EXISTS if the + * [attestor][google.cloud.binaryauthorization.v1.Attestor] already exists. + * + * The async variant is + * {@see BinauthzManagementServiceV1Client::createAttestorAsync()} . + * + * @example samples/V1/BinauthzManagementServiceV1Client/create_attestor.php + * + * @param CreateAttestorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Attestor + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAttestor(CreateAttestorRequest $request, array $callOptions = []): Attestor + { + return $this->startApiCall('CreateAttestor', $request, $callOptions)->wait(); + } + + /** + * Deletes an [attestor][google.cloud.binaryauthorization.v1.Attestor]. Returns NOT_FOUND if the + * [attestor][google.cloud.binaryauthorization.v1.Attestor] does not exist. + * + * The async variant is + * {@see BinauthzManagementServiceV1Client::deleteAttestorAsync()} . + * + * @example samples/V1/BinauthzManagementServiceV1Client/delete_attestor.php + * + * @param DeleteAttestorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAttestor(DeleteAttestorRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteAttestor', $request, $callOptions)->wait(); + } + + /** + * Gets an [attestor][google.cloud.binaryauthorization.v1.Attestor]. + * Returns NOT_FOUND if the [attestor][google.cloud.binaryauthorization.v1.Attestor] does not exist. + * + * The async variant is + * {@see BinauthzManagementServiceV1Client::getAttestorAsync()} . + * + * @example samples/V1/BinauthzManagementServiceV1Client/get_attestor.php + * + * @param GetAttestorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Attestor + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAttestor(GetAttestorRequest $request, array $callOptions = []): Attestor + { + return $this->startApiCall('GetAttestor', $request, $callOptions)->wait(); + } + + /** + * A [policy][google.cloud.binaryauthorization.v1.Policy] specifies the [attestors][google.cloud.binaryauthorization.v1.Attestor] that must attest to + * a container image, before the project is allowed to deploy that + * image. There is at most one policy per project. All image admission + * requests are permitted if a project has no policy. + * + * Gets the [policy][google.cloud.binaryauthorization.v1.Policy] for this project. Returns a default + * [policy][google.cloud.binaryauthorization.v1.Policy] if the project does not have one. + * + * The async variant is {@see BinauthzManagementServiceV1Client::getPolicyAsync()} + * . + * + * @example samples/V1/BinauthzManagementServiceV1Client/get_policy.php + * + * @param GetPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getPolicy(GetPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetPolicy', $request, $callOptions)->wait(); + } + + /** + * Lists [attestors][google.cloud.binaryauthorization.v1.Attestor]. + * Returns INVALID_ARGUMENT if the project does not exist. + * + * The async variant is + * {@see BinauthzManagementServiceV1Client::listAttestorsAsync()} . + * + * @example samples/V1/BinauthzManagementServiceV1Client/list_attestors.php + * + * @param ListAttestorsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAttestors(ListAttestorsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAttestors', $request, $callOptions); + } + + /** + * Updates an [attestor][google.cloud.binaryauthorization.v1.Attestor]. + * Returns NOT_FOUND if the [attestor][google.cloud.binaryauthorization.v1.Attestor] does not exist. + * + * The async variant is + * {@see BinauthzManagementServiceV1Client::updateAttestorAsync()} . + * + * @example samples/V1/BinauthzManagementServiceV1Client/update_attestor.php + * + * @param UpdateAttestorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Attestor + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAttestor(UpdateAttestorRequest $request, array $callOptions = []): Attestor + { + return $this->startApiCall('UpdateAttestor', $request, $callOptions)->wait(); + } + + /** + * Creates or updates a project's [policy][google.cloud.binaryauthorization.v1.Policy], and returns a copy of the + * new [policy][google.cloud.binaryauthorization.v1.Policy]. A policy is always updated as a whole, to avoid race + * conditions with concurrent policy enforcement (or management!) + * requests. Returns NOT_FOUND if the project does not exist, INVALID_ARGUMENT + * if the request is malformed. + * + * The async variant is + * {@see BinauthzManagementServiceV1Client::updatePolicyAsync()} . + * + * @example samples/V1/BinauthzManagementServiceV1Client/update_policy.php + * + * @param UpdatePolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function updatePolicy(UpdatePolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('UpdatePolicy', $request, $callOptions)->wait(); + } } diff --git a/BinaryAuthorization/src/V1/Client/SystemPolicyV1Client.php b/BinaryAuthorization/src/V1/Client/SystemPolicyV1Client.php index bdca3915326c..7e61eba2b0ae 100644 --- a/BinaryAuthorization/src/V1/Client/SystemPolicyV1Client.php +++ b/BinaryAuthorization/src/V1/Client/SystemPolicyV1Client.php @@ -24,17 +24,241 @@ namespace Google\Cloud\BinaryAuthorization\V1\Client; -use Google\Cloud\BinaryAuthorization\V1\Client\BaseClient\SystemPolicyV1BaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\BinaryAuthorization\V1\GetSystemPolicyRequest; +use Google\Cloud\BinaryAuthorization\V1\Policy; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: API for working with the system policy. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface getSystemPolicyAsync(GetSystemPolicyRequest $request, array $optionalArgs = []) */ -final class SystemPolicyV1Client extends SystemPolicyV1BaseClient +final class SystemPolicyV1Client { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SystemPolicyV1BaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.binaryauthorization.v1.SystemPolicyV1'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'binaryauthorization.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/system_policy_v1_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/system_policy_v1_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/system_policy_v1_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/system_policy_v1_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * location_policy resource. + * + * @param string $location + * + * @return string The formatted location_policy resource. + */ + public static function locationPolicyName(string $location): string + { + return self::getPathTemplate('locationPolicy')->render([ + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a policy + * resource. + * + * @param string $project + * + * @return string The formatted policy resource. + */ + public static function policyName(string $project): string + { + return self::getPathTemplate('policy')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_policy resource. + * + * @param string $project + * + * @return string The formatted project_policy resource. + */ + public static function projectPolicyName(string $project): string + { + return self::getPathTemplate('projectPolicy')->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 + * - locationPolicy: locations/{location}/policy + * - policy: projects/{project}/policy + * - projectPolicy: projects/{project}/policy + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'binaryauthorization.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Gets the current system policy in the specified location. + * + * The async variant is {@see SystemPolicyV1Client::getSystemPolicyAsync()} . + * + * @example samples/V1/SystemPolicyV1Client/get_system_policy.php + * + * @param GetSystemPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSystemPolicy(GetSystemPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetSystemPolicy', $request, $callOptions)->wait(); + } } diff --git a/BinaryAuthorization/src/V1/Client/ValidationHelperV1Client.php b/BinaryAuthorization/src/V1/Client/ValidationHelperV1Client.php index fb673d1ebabc..9ac3fd764d39 100644 --- a/BinaryAuthorization/src/V1/Client/ValidationHelperV1Client.php +++ b/BinaryAuthorization/src/V1/Client/ValidationHelperV1Client.php @@ -24,17 +24,165 @@ namespace Google\Cloud\BinaryAuthorization\V1\Client; -use Google\Cloud\BinaryAuthorization\V1\Client\BaseClient\ValidationHelperV1BaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\BinaryAuthorization\V1\ValidateAttestationOccurrenceRequest; +use Google\Cloud\BinaryAuthorization\V1\ValidateAttestationOccurrenceResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: BinAuthz Attestor verification + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface validateAttestationOccurrenceAsync(ValidateAttestationOccurrenceRequest $request, array $optionalArgs = []) */ -final class ValidationHelperV1Client extends ValidationHelperV1BaseClient +final class ValidationHelperV1Client { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ValidationHelperV1BaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.binaryauthorization.v1.ValidationHelperV1'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'binaryauthorization.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/validation_helper_v1_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/validation_helper_v1_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/validation_helper_v1_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/validation_helper_v1_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'binaryauthorization.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Returns whether the given Attestation for the given image URI + * was signed by the given Attestor + * + * The async variant is + * {@see ValidationHelperV1Client::validateAttestationOccurrenceAsync()} . + * + * @example samples/V1/ValidationHelperV1Client/validate_attestation_occurrence.php + * + * @param ValidateAttestationOccurrenceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ValidateAttestationOccurrenceResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function validateAttestationOccurrence(ValidateAttestationOccurrenceRequest $request, array $callOptions = []): ValidateAttestationOccurrenceResponse + { + return $this->startApiCall('ValidateAttestationOccurrence', $request, $callOptions)->wait(); + } } diff --git a/Build/composer.json b/Build/composer.json index a7b55624e438..92bc3798d355 100644 --- a/Build/composer.json +++ b/Build/composer.json @@ -25,7 +25,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Build/src/V2/Client/BaseClient/RepositoryManagerBaseClient.php b/Build/src/V2/Client/BaseClient/RepositoryManagerBaseClient.php deleted file mode 100644 index 60caad3173f3..000000000000 --- a/Build/src/V2/Client/BaseClient/RepositoryManagerBaseClient.php +++ /dev/null @@ -1,823 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/repository_manager_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/repository_manager_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/repository_manager_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/repository_manager_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a connection - * resource. - * - * @param string $project - * @param string $location - * @param string $connection - * - * @return string The formatted connection resource. - */ - public static function connectionName(string $project, string $location, string $connection): string - { - return self::getPathTemplate('connection')->render([ - 'project' => $project, - 'location' => $location, - 'connection' => $connection, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a repository - * resource. - * - * @param string $project - * @param string $location - * @param string $connection - * @param string $repository - * - * @return string The formatted repository resource. - */ - public static function repositoryName(string $project, string $location, string $connection, string $repository): string - { - return self::getPathTemplate('repository')->render([ - 'project' => $project, - 'location' => $location, - 'connection' => $connection, - 'repository' => $repository, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * secret_version resource. - * - * @param string $project - * @param string $secret - * @param string $version - * - * @return string The formatted secret_version resource. - */ - public static function secretVersionName(string $project, string $secret, string $version): string - { - return self::getPathTemplate('secretVersion')->render([ - 'project' => $project, - 'secret' => $secret, - 'version' => $version, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a service - * resource. - * - * @param string $project - * @param string $location - * @param string $namespace - * @param string $service - * - * @return string The formatted service resource. - */ - public static function serviceName(string $project, string $location, string $namespace, string $service): string - { - return self::getPathTemplate('service')->render([ - 'project' => $project, - 'location' => $location, - 'namespace' => $namespace, - 'service' => $service, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - connection: projects/{project}/locations/{location}/connections/{connection} - * - location: projects/{project}/locations/{location} - * - repository: projects/{project}/locations/{location}/connections/{connection}/repositories/{repository} - * - secretVersion: projects/{project}/secrets/{secret}/versions/{version} - * - service: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudbuild.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates multiple repositories inside a connection. - * - * The async variant is {@see self::batchCreateRepositoriesAsync()} . - * - * @example samples/V2/RepositoryManagerClient/batch_create_repositories.php - * - * @param BatchCreateRepositoriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchCreateRepositories(BatchCreateRepositoriesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BatchCreateRepositories', $request, $callOptions)->wait(); - } - - /** - * Creates a Connection. - * - * The async variant is {@see self::createConnectionAsync()} . - * - * @example samples/V2/RepositoryManagerClient/create_connection.php - * - * @param CreateConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createConnection(CreateConnectionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateConnection', $request, $callOptions)->wait(); - } - - /** - * Creates a Repository. - * - * The async variant is {@see self::createRepositoryAsync()} . - * - * @example samples/V2/RepositoryManagerClient/create_repository.php - * - * @param CreateRepositoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createRepository(CreateRepositoryRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateRepository', $request, $callOptions)->wait(); - } - - /** - * Deletes a single connection. - * - * The async variant is {@see self::deleteConnectionAsync()} . - * - * @example samples/V2/RepositoryManagerClient/delete_connection.php - * - * @param DeleteConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteConnection(DeleteConnectionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteConnection', $request, $callOptions)->wait(); - } - - /** - * Deletes a single repository. - * - * The async variant is {@see self::deleteRepositoryAsync()} . - * - * @example samples/V2/RepositoryManagerClient/delete_repository.php - * - * @param DeleteRepositoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteRepository(DeleteRepositoryRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteRepository', $request, $callOptions)->wait(); - } - - /** - * Fetch the list of branches or tags for a given repository. - * - * The async variant is {@see self::fetchGitRefsAsync()} . - * - * @example samples/V2/RepositoryManagerClient/fetch_git_refs.php - * - * @param FetchGitRefsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FetchGitRefsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function fetchGitRefs(FetchGitRefsRequest $request, array $callOptions = []): FetchGitRefsResponse - { - return $this->startApiCall('FetchGitRefs', $request, $callOptions)->wait(); - } - - /** - * FetchLinkableRepositories get repositories from SCM that are - * accessible and could be added to the connection. - * - * The async variant is {@see self::fetchLinkableRepositoriesAsync()} . - * - * @example samples/V2/RepositoryManagerClient/fetch_linkable_repositories.php - * - * @param FetchLinkableRepositoriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function fetchLinkableRepositories(FetchLinkableRepositoriesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('FetchLinkableRepositories', $request, $callOptions); - } - - /** - * Fetches read token of a given repository. - * - * The async variant is {@see self::fetchReadTokenAsync()} . - * - * @example samples/V2/RepositoryManagerClient/fetch_read_token.php - * - * @param FetchReadTokenRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FetchReadTokenResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function fetchReadToken(FetchReadTokenRequest $request, array $callOptions = []): FetchReadTokenResponse - { - return $this->startApiCall('FetchReadToken', $request, $callOptions)->wait(); - } - - /** - * Fetches read/write token of a given repository. - * - * The async variant is {@see self::fetchReadWriteTokenAsync()} . - * - * @example samples/V2/RepositoryManagerClient/fetch_read_write_token.php - * - * @param FetchReadWriteTokenRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FetchReadWriteTokenResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function fetchReadWriteToken(FetchReadWriteTokenRequest $request, array $callOptions = []): FetchReadWriteTokenResponse - { - return $this->startApiCall('FetchReadWriteToken', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single connection. - * - * The async variant is {@see self::getConnectionAsync()} . - * - * @example samples/V2/RepositoryManagerClient/get_connection.php - * - * @param GetConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Connection - * - * @throws ApiException Thrown if the API call fails. - */ - public function getConnection(GetConnectionRequest $request, array $callOptions = []): Connection - { - return $this->startApiCall('GetConnection', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single repository. - * - * The async variant is {@see self::getRepositoryAsync()} . - * - * @example samples/V2/RepositoryManagerClient/get_repository.php - * - * @param GetRepositoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Repository - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRepository(GetRepositoryRequest $request, array $callOptions = []): Repository - { - return $this->startApiCall('GetRepository', $request, $callOptions)->wait(); - } - - /** - * Lists Connections in a given project and location. - * - * The async variant is {@see self::listConnectionsAsync()} . - * - * @example samples/V2/RepositoryManagerClient/list_connections.php - * - * @param ListConnectionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listConnections(ListConnectionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListConnections', $request, $callOptions); - } - - /** - * Lists Repositories in a given connection. - * - * The async variant is {@see self::listRepositoriesAsync()} . - * - * @example samples/V2/RepositoryManagerClient/list_repositories.php - * - * @param ListRepositoriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listRepositories(ListRepositoriesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListRepositories', $request, $callOptions); - } - - /** - * Updates a single connection. - * - * The async variant is {@see self::updateConnectionAsync()} . - * - * @example samples/V2/RepositoryManagerClient/update_connection.php - * - * @param UpdateConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateConnection(UpdateConnectionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateConnection', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V2/RepositoryManagerClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V2/RepositoryManagerClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V2/RepositoryManagerClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Build/src/V2/Client/RepositoryManagerClient.php b/Build/src/V2/Client/RepositoryManagerClient.php index 3d202c1cee2a..ca816706f11c 100644 --- a/Build/src/V2/Client/RepositoryManagerClient.php +++ b/Build/src/V2/Client/RepositoryManagerClient.php @@ -24,17 +24,801 @@ namespace Google\Cloud\Build\V2\Client; -use Google\Cloud\Build\V2\Client\BaseClient\RepositoryManagerBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Build\V2\BatchCreateRepositoriesRequest; +use Google\Cloud\Build\V2\Connection; +use Google\Cloud\Build\V2\CreateConnectionRequest; +use Google\Cloud\Build\V2\CreateRepositoryRequest; +use Google\Cloud\Build\V2\DeleteConnectionRequest; +use Google\Cloud\Build\V2\DeleteRepositoryRequest; +use Google\Cloud\Build\V2\FetchGitRefsRequest; +use Google\Cloud\Build\V2\FetchGitRefsResponse; +use Google\Cloud\Build\V2\FetchLinkableRepositoriesRequest; +use Google\Cloud\Build\V2\FetchReadTokenRequest; +use Google\Cloud\Build\V2\FetchReadTokenResponse; +use Google\Cloud\Build\V2\FetchReadWriteTokenRequest; +use Google\Cloud\Build\V2\FetchReadWriteTokenResponse; +use Google\Cloud\Build\V2\GetConnectionRequest; +use Google\Cloud\Build\V2\GetRepositoryRequest; +use Google\Cloud\Build\V2\ListConnectionsRequest; +use Google\Cloud\Build\V2\ListRepositoriesRequest; +use Google\Cloud\Build\V2\Repository; +use Google\Cloud\Build\V2\UpdateConnectionRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Manages connections to source code repositories. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Build\V2\RepositoryManagerClient} for the stable implementation * * @experimental + * + * @method PromiseInterface batchCreateRepositoriesAsync(BatchCreateRepositoriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface createConnectionAsync(CreateConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface createRepositoryAsync(CreateRepositoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteConnectionAsync(DeleteConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteRepositoryAsync(DeleteRepositoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface fetchGitRefsAsync(FetchGitRefsRequest $request, array $optionalArgs = []) + * @method PromiseInterface fetchLinkableRepositoriesAsync(FetchLinkableRepositoriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface fetchReadTokenAsync(FetchReadTokenRequest $request, array $optionalArgs = []) + * @method PromiseInterface fetchReadWriteTokenAsync(FetchReadWriteTokenRequest $request, array $optionalArgs = []) + * @method PromiseInterface getConnectionAsync(GetConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRepositoryAsync(GetRepositoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface listConnectionsAsync(ListConnectionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listRepositoriesAsync(ListRepositoriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateConnectionAsync(UpdateConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class RepositoryManagerClient extends RepositoryManagerBaseClient +final class RepositoryManagerClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RepositoryManagerBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.devtools.cloudbuild.v2.RepositoryManager'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudbuild.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/repository_manager_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/repository_manager_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/repository_manager_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/repository_manager_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a connection + * resource. + * + * @param string $project + * @param string $location + * @param string $connection + * + * @return string The formatted connection resource. + */ + public static function connectionName(string $project, string $location, string $connection): string + { + return self::getPathTemplate('connection')->render([ + 'project' => $project, + 'location' => $location, + 'connection' => $connection, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a repository + * resource. + * + * @param string $project + * @param string $location + * @param string $connection + * @param string $repository + * + * @return string The formatted repository resource. + */ + public static function repositoryName(string $project, string $location, string $connection, string $repository): string + { + return self::getPathTemplate('repository')->render([ + 'project' => $project, + 'location' => $location, + 'connection' => $connection, + 'repository' => $repository, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * secret_version resource. + * + * @param string $project + * @param string $secret + * @param string $version + * + * @return string The formatted secret_version resource. + */ + public static function secretVersionName(string $project, string $secret, string $version): string + { + return self::getPathTemplate('secretVersion')->render([ + 'project' => $project, + 'secret' => $secret, + 'version' => $version, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a service + * resource. + * + * @param string $project + * @param string $location + * @param string $namespace + * @param string $service + * + * @return string The formatted service resource. + */ + public static function serviceName(string $project, string $location, string $namespace, string $service): string + { + return self::getPathTemplate('service')->render([ + 'project' => $project, + 'location' => $location, + 'namespace' => $namespace, + 'service' => $service, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - connection: projects/{project}/locations/{location}/connections/{connection} + * - location: projects/{project}/locations/{location} + * - repository: projects/{project}/locations/{location}/connections/{connection}/repositories/{repository} + * - secretVersion: projects/{project}/secrets/{secret}/versions/{version} + * - service: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudbuild.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates multiple repositories inside a connection. + * + * The async variant is + * {@see RepositoryManagerClient::batchCreateRepositoriesAsync()} . + * + * @example samples/V2/RepositoryManagerClient/batch_create_repositories.php + * + * @param BatchCreateRepositoriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchCreateRepositories(BatchCreateRepositoriesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchCreateRepositories', $request, $callOptions)->wait(); + } + + /** + * Creates a Connection. + * + * The async variant is {@see RepositoryManagerClient::createConnectionAsync()} . + * + * @example samples/V2/RepositoryManagerClient/create_connection.php + * + * @param CreateConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createConnection(CreateConnectionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateConnection', $request, $callOptions)->wait(); + } + + /** + * Creates a Repository. + * + * The async variant is {@see RepositoryManagerClient::createRepositoryAsync()} . + * + * @example samples/V2/RepositoryManagerClient/create_repository.php + * + * @param CreateRepositoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createRepository(CreateRepositoryRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateRepository', $request, $callOptions)->wait(); + } + + /** + * Deletes a single connection. + * + * The async variant is {@see RepositoryManagerClient::deleteConnectionAsync()} . + * + * @example samples/V2/RepositoryManagerClient/delete_connection.php + * + * @param DeleteConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteConnection(DeleteConnectionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteConnection', $request, $callOptions)->wait(); + } + + /** + * Deletes a single repository. + * + * The async variant is {@see RepositoryManagerClient::deleteRepositoryAsync()} . + * + * @example samples/V2/RepositoryManagerClient/delete_repository.php + * + * @param DeleteRepositoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteRepository(DeleteRepositoryRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteRepository', $request, $callOptions)->wait(); + } + + /** + * Fetch the list of branches or tags for a given repository. + * + * The async variant is {@see RepositoryManagerClient::fetchGitRefsAsync()} . + * + * @example samples/V2/RepositoryManagerClient/fetch_git_refs.php + * + * @param FetchGitRefsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FetchGitRefsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function fetchGitRefs(FetchGitRefsRequest $request, array $callOptions = []): FetchGitRefsResponse + { + return $this->startApiCall('FetchGitRefs', $request, $callOptions)->wait(); + } + + /** + * FetchLinkableRepositories get repositories from SCM that are + * accessible and could be added to the connection. + * + * The async variant is + * {@see RepositoryManagerClient::fetchLinkableRepositoriesAsync()} . + * + * @example samples/V2/RepositoryManagerClient/fetch_linkable_repositories.php + * + * @param FetchLinkableRepositoriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function fetchLinkableRepositories(FetchLinkableRepositoriesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('FetchLinkableRepositories', $request, $callOptions); + } + + /** + * Fetches read token of a given repository. + * + * The async variant is {@see RepositoryManagerClient::fetchReadTokenAsync()} . + * + * @example samples/V2/RepositoryManagerClient/fetch_read_token.php + * + * @param FetchReadTokenRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FetchReadTokenResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function fetchReadToken(FetchReadTokenRequest $request, array $callOptions = []): FetchReadTokenResponse + { + return $this->startApiCall('FetchReadToken', $request, $callOptions)->wait(); + } + + /** + * Fetches read/write token of a given repository. + * + * The async variant is {@see RepositoryManagerClient::fetchReadWriteTokenAsync()} + * . + * + * @example samples/V2/RepositoryManagerClient/fetch_read_write_token.php + * + * @param FetchReadWriteTokenRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FetchReadWriteTokenResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function fetchReadWriteToken(FetchReadWriteTokenRequest $request, array $callOptions = []): FetchReadWriteTokenResponse + { + return $this->startApiCall('FetchReadWriteToken', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single connection. + * + * The async variant is {@see RepositoryManagerClient::getConnectionAsync()} . + * + * @example samples/V2/RepositoryManagerClient/get_connection.php + * + * @param GetConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Connection + * + * @throws ApiException Thrown if the API call fails. + */ + public function getConnection(GetConnectionRequest $request, array $callOptions = []): Connection + { + return $this->startApiCall('GetConnection', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single repository. + * + * The async variant is {@see RepositoryManagerClient::getRepositoryAsync()} . + * + * @example samples/V2/RepositoryManagerClient/get_repository.php + * + * @param GetRepositoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Repository + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRepository(GetRepositoryRequest $request, array $callOptions = []): Repository + { + return $this->startApiCall('GetRepository', $request, $callOptions)->wait(); + } + + /** + * Lists Connections in a given project and location. + * + * The async variant is {@see RepositoryManagerClient::listConnectionsAsync()} . + * + * @example samples/V2/RepositoryManagerClient/list_connections.php + * + * @param ListConnectionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listConnections(ListConnectionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListConnections', $request, $callOptions); + } + + /** + * Lists Repositories in a given connection. + * + * The async variant is {@see RepositoryManagerClient::listRepositoriesAsync()} . + * + * @example samples/V2/RepositoryManagerClient/list_repositories.php + * + * @param ListRepositoriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listRepositories(ListRepositoriesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListRepositories', $request, $callOptions); + } + + /** + * Updates a single connection. + * + * The async variant is {@see RepositoryManagerClient::updateConnectionAsync()} . + * + * @example samples/V2/RepositoryManagerClient/update_connection.php + * + * @param UpdateConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateConnection(UpdateConnectionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateConnection', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see RepositoryManagerClient::getIamPolicyAsync()} . + * + * @example samples/V2/RepositoryManagerClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see RepositoryManagerClient::setIamPolicyAsync()} . + * + * @example samples/V2/RepositoryManagerClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see RepositoryManagerClient::testIamPermissionsAsync()} . + * + * @example samples/V2/RepositoryManagerClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a44ebd43484..ede0bc7aee6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,87 @@ # Changelog +## 0.222.0 + +
google/cloud-ai-platform 0.26.0 + + + +### Features + +* Add DatasetVersion and dataset version RPCs to DatasetService ([#6672](https://github.com/googleapis/google-cloud-php/issues/6672)) ([c8ab13d](https://github.com/googleapis/google-cloud-php/commit/c8ab13d20fa205f8cc2007be256cbdc14d767cf9)) +* Add PersistentDiskSpec ([c8ab13d](https://github.com/googleapis/google-cloud-php/commit/c8ab13d20fa205f8cc2007be256cbdc14d767cf9)) + +
+ +
google/cloud-batch 0.12.0 + + + +### Features + +* Add InstancePolicy.reservation field for restricting jobs to a specific reservation ([#6674](https://github.com/googleapis/google-cloud-php/issues/6674)) ([26cec7d](https://github.com/googleapis/google-cloud-php/commit/26cec7dbbe6af8f60cedc6220e4504683ed77696)) + + +### Documentation + +* Elaborate the usage of Container.volumes proto field ([26cec7d](https://github.com/googleapis/google-cloud-php/commit/26cec7dbbe6af8f60cedc6220e4504683ed77696)) + +
+ +
google/cloud-bigtable 1.29.0 + + + +### Features + +* Add support for Cloud Bigtable Request Priorities in App Profiles ([#6682](https://github.com/googleapis/google-cloud-php/issues/6682)) ([668b030](https://github.com/googleapis/google-cloud-php/commit/668b03025f01493b9c0bcd1366558f0dfd31291a)) + +
+ +
google/cloud-core 1.52.6 + + + +
+ +
google/cloud-firestore 1.37.3 + + + +
+ +
google/cloud-recaptcha-enterprise 1.5.0 + + + +### Features + +* Added AndroidKeySettings.support_non_google_app_store_distribution ([6597d90](https://github.com/googleapis/google-cloud-php/commit/6597d9006ce281ebdf52e363431c62a057244b25)) +* Added Assessment.firewall_policy_assessment, fraud_signals ([6597d90](https://github.com/googleapis/google-cloud-php/commit/6597d9006ce281ebdf52e363431c62a057244b25)) +* Added FraudPreventionAssessment.behavioral_trust_verdict ([6597d90](https://github.com/googleapis/google-cloud-php/commit/6597d9006ce281ebdf52e363431c62a057244b25)) +* Added IOSKeySettings.apple_developer_id ([6597d90](https://github.com/googleapis/google-cloud-php/commit/6597d9006ce281ebdf52e363431c62a057244b25)) +* Added new fields to Event message ([6597d90](https://github.com/googleapis/google-cloud-php/commit/6597d9006ce281ebdf52e363431c62a057244b25)) +* Added RiskAnalysis.extended_verdict_reasons ([6597d90](https://github.com/googleapis/google-cloud-php/commit/6597d9006ce281ebdf52e363431c62a057244b25)) +* Added WafFeature.EXPRESS enum value ([6597d90](https://github.com/googleapis/google-cloud-php/commit/6597d9006ce281ebdf52e363431c62a057244b25)) +* Added WafService.FASTLY enum value ([6597d90](https://github.com/googleapis/google-cloud-php/commit/6597d9006ce281ebdf52e363431c62a057244b25)) +* FirewallPolicy CRUD API ([#6680](https://github.com/googleapis/google-cloud-php/issues/6680)) ([6597d90](https://github.com/googleapis/google-cloud-php/commit/6597d9006ce281ebdf52e363431c62a057244b25)) + +
+ +
google/cloud-sql-admin 0.6.0 + + + +### âš  BREAKING CHANGES + +* Enum ExternalSyncParallelLevel moved to the top level ([#6676](https://github.com/googleapis/google-cloud-php/issues/6676)) + +### Bug Fixes + +* Enum ExternalSyncParallelLevel moved to the top level ([#6676](https://github.com/googleapis/google-cloud-php/issues/6676)) ([e3ffe20](https://github.com/googleapis/google-cloud-php/commit/e3ffe20c6cd2bb58e0e5b93aaecdc0474dcbfe6e)) + +
+ ## 0.221.0
google/cloud-advisorynotifications 0.5.0 diff --git a/CertificateManager/composer.json b/CertificateManager/composer.json index 57ac47cac7e4..444144468c85 100644 --- a/CertificateManager/composer.json +++ b/CertificateManager/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/CertificateManager/src/V1/Client/BaseClient/CertificateManagerBaseClient.php b/CertificateManager/src/V1/Client/BaseClient/CertificateManagerBaseClient.php deleted file mode 100644 index 38a4afae92d9..000000000000 --- a/CertificateManager/src/V1/Client/BaseClient/CertificateManagerBaseClient.php +++ /dev/null @@ -1,1128 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/certificate_manager_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/certificate_manager_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/certificate_manager_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/certificate_manager_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a ca_pool - * resource. - * - * @param string $project - * @param string $location - * @param string $caPool - * - * @return string The formatted ca_pool resource. - */ - public static function caPoolName(string $project, string $location, string $caPool): string - { - return self::getPathTemplate('caPool')->render([ - 'project' => $project, - 'location' => $location, - 'ca_pool' => $caPool, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a certificate - * resource. - * - * @param string $project - * @param string $location - * @param string $certificate - * - * @return string The formatted certificate resource. - */ - public static function certificateName(string $project, string $location, string $certificate): string - { - return self::getPathTemplate('certificate')->render([ - 'project' => $project, - 'location' => $location, - 'certificate' => $certificate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * certificate_issuance_config resource. - * - * @param string $project - * @param string $location - * @param string $certificateIssuanceConfig - * - * @return string The formatted certificate_issuance_config resource. - */ - public static function certificateIssuanceConfigName(string $project, string $location, string $certificateIssuanceConfig): string - { - return self::getPathTemplate('certificateIssuanceConfig')->render([ - 'project' => $project, - 'location' => $location, - 'certificate_issuance_config' => $certificateIssuanceConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * certificate_map resource. - * - * @param string $project - * @param string $location - * @param string $certificateMap - * - * @return string The formatted certificate_map resource. - */ - public static function certificateMapName(string $project, string $location, string $certificateMap): string - { - return self::getPathTemplate('certificateMap')->render([ - 'project' => $project, - 'location' => $location, - 'certificate_map' => $certificateMap, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * certificate_map_entry resource. - * - * @param string $project - * @param string $location - * @param string $certificateMap - * @param string $certificateMapEntry - * - * @return string The formatted certificate_map_entry resource. - */ - public static function certificateMapEntryName(string $project, string $location, string $certificateMap, string $certificateMapEntry): string - { - return self::getPathTemplate('certificateMapEntry')->render([ - 'project' => $project, - 'location' => $location, - 'certificate_map' => $certificateMap, - 'certificate_map_entry' => $certificateMapEntry, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * dns_authorization resource. - * - * @param string $project - * @param string $location - * @param string $dnsAuthorization - * - * @return string The formatted dns_authorization resource. - */ - public static function dnsAuthorizationName(string $project, string $location, string $dnsAuthorization): string - { - return self::getPathTemplate('dnsAuthorization')->render([ - 'project' => $project, - 'location' => $location, - 'dns_authorization' => $dnsAuthorization, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - caPool: projects/{project}/locations/{location}/caPools/{ca_pool} - * - certificate: projects/{project}/locations/{location}/certificates/{certificate} - * - certificateIssuanceConfig: projects/{project}/locations/{location}/certificateIssuanceConfigs/{certificate_issuance_config} - * - certificateMap: projects/{project}/locations/{location}/certificateMaps/{certificate_map} - * - certificateMapEntry: projects/{project}/locations/{location}/certificateMaps/{certificate_map}/certificateMapEntries/{certificate_map_entry} - * - dnsAuthorization: projects/{project}/locations/{location}/dnsAuthorizations/{dns_authorization} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'certificatemanager.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new Certificate in a given project and location. - * - * The async variant is {@see self::createCertificateAsync()} . - * - * @example samples/V1/CertificateManagerClient/create_certificate.php - * - * @param CreateCertificateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCertificate(CreateCertificateRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateCertificate', $request, $callOptions)->wait(); - } - - /** - * Creates a new CertificateIssuanceConfig in a given project and location. - * - * The async variant is {@see self::createCertificateIssuanceConfigAsync()} . - * - * @example samples/V1/CertificateManagerClient/create_certificate_issuance_config.php - * - * @param CreateCertificateIssuanceConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCertificateIssuanceConfig(CreateCertificateIssuanceConfigRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateCertificateIssuanceConfig', $request, $callOptions)->wait(); - } - - /** - * Creates a new CertificateMap in a given project and location. - * - * The async variant is {@see self::createCertificateMapAsync()} . - * - * @example samples/V1/CertificateManagerClient/create_certificate_map.php - * - * @param CreateCertificateMapRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCertificateMap(CreateCertificateMapRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateCertificateMap', $request, $callOptions)->wait(); - } - - /** - * Creates a new CertificateMapEntry in a given project and location. - * - * The async variant is {@see self::createCertificateMapEntryAsync()} . - * - * @example samples/V1/CertificateManagerClient/create_certificate_map_entry.php - * - * @param CreateCertificateMapEntryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCertificateMapEntry(CreateCertificateMapEntryRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateCertificateMapEntry', $request, $callOptions)->wait(); - } - - /** - * Creates a new DnsAuthorization in a given project and location. - * - * The async variant is {@see self::createDnsAuthorizationAsync()} . - * - * @example samples/V1/CertificateManagerClient/create_dns_authorization.php - * - * @param CreateDnsAuthorizationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDnsAuthorization(CreateDnsAuthorizationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateDnsAuthorization', $request, $callOptions)->wait(); - } - - /** - * Deletes a single Certificate. - * - * The async variant is {@see self::deleteCertificateAsync()} . - * - * @example samples/V1/CertificateManagerClient/delete_certificate.php - * - * @param DeleteCertificateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteCertificate(DeleteCertificateRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteCertificate', $request, $callOptions)->wait(); - } - - /** - * Deletes a single CertificateIssuanceConfig. - * - * The async variant is {@see self::deleteCertificateIssuanceConfigAsync()} . - * - * @example samples/V1/CertificateManagerClient/delete_certificate_issuance_config.php - * - * @param DeleteCertificateIssuanceConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteCertificateIssuanceConfig(DeleteCertificateIssuanceConfigRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteCertificateIssuanceConfig', $request, $callOptions)->wait(); - } - - /** - * Deletes a single CertificateMap. A Certificate Map can't be deleted - * if it contains Certificate Map Entries. Remove all the entries from - * the map before calling this method. - * - * The async variant is {@see self::deleteCertificateMapAsync()} . - * - * @example samples/V1/CertificateManagerClient/delete_certificate_map.php - * - * @param DeleteCertificateMapRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteCertificateMap(DeleteCertificateMapRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteCertificateMap', $request, $callOptions)->wait(); - } - - /** - * Deletes a single CertificateMapEntry. - * - * The async variant is {@see self::deleteCertificateMapEntryAsync()} . - * - * @example samples/V1/CertificateManagerClient/delete_certificate_map_entry.php - * - * @param DeleteCertificateMapEntryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteCertificateMapEntry(DeleteCertificateMapEntryRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteCertificateMapEntry', $request, $callOptions)->wait(); - } - - /** - * Deletes a single DnsAuthorization. - * - * The async variant is {@see self::deleteDnsAuthorizationAsync()} . - * - * @example samples/V1/CertificateManagerClient/delete_dns_authorization.php - * - * @param DeleteDnsAuthorizationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDnsAuthorization(DeleteDnsAuthorizationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteDnsAuthorization', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single Certificate. - * - * The async variant is {@see self::getCertificateAsync()} . - * - * @example samples/V1/CertificateManagerClient/get_certificate.php - * - * @param GetCertificateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Certificate - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCertificate(GetCertificateRequest $request, array $callOptions = []): Certificate - { - return $this->startApiCall('GetCertificate', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single CertificateIssuanceConfig. - * - * The async variant is {@see self::getCertificateIssuanceConfigAsync()} . - * - * @example samples/V1/CertificateManagerClient/get_certificate_issuance_config.php - * - * @param GetCertificateIssuanceConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CertificateIssuanceConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCertificateIssuanceConfig(GetCertificateIssuanceConfigRequest $request, array $callOptions = []): CertificateIssuanceConfig - { - return $this->startApiCall('GetCertificateIssuanceConfig', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single CertificateMap. - * - * The async variant is {@see self::getCertificateMapAsync()} . - * - * @example samples/V1/CertificateManagerClient/get_certificate_map.php - * - * @param GetCertificateMapRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CertificateMap - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCertificateMap(GetCertificateMapRequest $request, array $callOptions = []): CertificateMap - { - return $this->startApiCall('GetCertificateMap', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single CertificateMapEntry. - * - * The async variant is {@see self::getCertificateMapEntryAsync()} . - * - * @example samples/V1/CertificateManagerClient/get_certificate_map_entry.php - * - * @param GetCertificateMapEntryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CertificateMapEntry - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCertificateMapEntry(GetCertificateMapEntryRequest $request, array $callOptions = []): CertificateMapEntry - { - return $this->startApiCall('GetCertificateMapEntry', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single DnsAuthorization. - * - * The async variant is {@see self::getDnsAuthorizationAsync()} . - * - * @example samples/V1/CertificateManagerClient/get_dns_authorization.php - * - * @param GetDnsAuthorizationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DnsAuthorization - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDnsAuthorization(GetDnsAuthorizationRequest $request, array $callOptions = []): DnsAuthorization - { - return $this->startApiCall('GetDnsAuthorization', $request, $callOptions)->wait(); - } - - /** - * Lists CertificateIssuanceConfigs in a given project and location. - * - * The async variant is {@see self::listCertificateIssuanceConfigsAsync()} . - * - * @example samples/V1/CertificateManagerClient/list_certificate_issuance_configs.php - * - * @param ListCertificateIssuanceConfigsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCertificateIssuanceConfigs(ListCertificateIssuanceConfigsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCertificateIssuanceConfigs', $request, $callOptions); - } - - /** - * Lists CertificateMapEntries in a given project and location. - * - * The async variant is {@see self::listCertificateMapEntriesAsync()} . - * - * @example samples/V1/CertificateManagerClient/list_certificate_map_entries.php - * - * @param ListCertificateMapEntriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCertificateMapEntries(ListCertificateMapEntriesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCertificateMapEntries', $request, $callOptions); - } - - /** - * Lists CertificateMaps in a given project and location. - * - * The async variant is {@see self::listCertificateMapsAsync()} . - * - * @example samples/V1/CertificateManagerClient/list_certificate_maps.php - * - * @param ListCertificateMapsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCertificateMaps(ListCertificateMapsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCertificateMaps', $request, $callOptions); - } - - /** - * Lists Certificates in a given project and location. - * - * The async variant is {@see self::listCertificatesAsync()} . - * - * @example samples/V1/CertificateManagerClient/list_certificates.php - * - * @param ListCertificatesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCertificates(ListCertificatesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCertificates', $request, $callOptions); - } - - /** - * Lists DnsAuthorizations in a given project and location. - * - * The async variant is {@see self::listDnsAuthorizationsAsync()} . - * - * @example samples/V1/CertificateManagerClient/list_dns_authorizations.php - * - * @param ListDnsAuthorizationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDnsAuthorizations(ListDnsAuthorizationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDnsAuthorizations', $request, $callOptions); - } - - /** - * Updates a Certificate. - * - * The async variant is {@see self::updateCertificateAsync()} . - * - * @example samples/V1/CertificateManagerClient/update_certificate.php - * - * @param UpdateCertificateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCertificate(UpdateCertificateRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateCertificate', $request, $callOptions)->wait(); - } - - /** - * Updates a CertificateMap. - * - * The async variant is {@see self::updateCertificateMapAsync()} . - * - * @example samples/V1/CertificateManagerClient/update_certificate_map.php - * - * @param UpdateCertificateMapRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCertificateMap(UpdateCertificateMapRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateCertificateMap', $request, $callOptions)->wait(); - } - - /** - * Updates a CertificateMapEntry. - * - * The async variant is {@see self::updateCertificateMapEntryAsync()} . - * - * @example samples/V1/CertificateManagerClient/update_certificate_map_entry.php - * - * @param UpdateCertificateMapEntryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCertificateMapEntry(UpdateCertificateMapEntryRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateCertificateMapEntry', $request, $callOptions)->wait(); - } - - /** - * Updates a DnsAuthorization. - * - * The async variant is {@see self::updateDnsAuthorizationAsync()} . - * - * @example samples/V1/CertificateManagerClient/update_dns_authorization.php - * - * @param UpdateDnsAuthorizationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDnsAuthorization(UpdateDnsAuthorizationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateDnsAuthorization', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/CertificateManagerClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/CertificateManagerClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/CertificateManager/src/V1/Client/CertificateManagerClient.php b/CertificateManager/src/V1/Client/CertificateManagerClient.php index 69f89dc8a4e8..bce2808ad073 100644 --- a/CertificateManager/src/V1/Client/CertificateManagerClient.php +++ b/CertificateManager/src/V1/Client/CertificateManagerClient.php @@ -24,17 +24,1121 @@ namespace Google\Cloud\CertificateManager\V1\Client; -use Google\Cloud\CertificateManager\V1\Client\BaseClient\CertificateManagerBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\CertificateManager\V1\Certificate; +use Google\Cloud\CertificateManager\V1\CertificateIssuanceConfig; +use Google\Cloud\CertificateManager\V1\CertificateMap; +use Google\Cloud\CertificateManager\V1\CertificateMapEntry; +use Google\Cloud\CertificateManager\V1\CreateCertificateIssuanceConfigRequest; +use Google\Cloud\CertificateManager\V1\CreateCertificateMapEntryRequest; +use Google\Cloud\CertificateManager\V1\CreateCertificateMapRequest; +use Google\Cloud\CertificateManager\V1\CreateCertificateRequest; +use Google\Cloud\CertificateManager\V1\CreateDnsAuthorizationRequest; +use Google\Cloud\CertificateManager\V1\DeleteCertificateIssuanceConfigRequest; +use Google\Cloud\CertificateManager\V1\DeleteCertificateMapEntryRequest; +use Google\Cloud\CertificateManager\V1\DeleteCertificateMapRequest; +use Google\Cloud\CertificateManager\V1\DeleteCertificateRequest; +use Google\Cloud\CertificateManager\V1\DeleteDnsAuthorizationRequest; +use Google\Cloud\CertificateManager\V1\DnsAuthorization; +use Google\Cloud\CertificateManager\V1\GetCertificateIssuanceConfigRequest; +use Google\Cloud\CertificateManager\V1\GetCertificateMapEntryRequest; +use Google\Cloud\CertificateManager\V1\GetCertificateMapRequest; +use Google\Cloud\CertificateManager\V1\GetCertificateRequest; +use Google\Cloud\CertificateManager\V1\GetDnsAuthorizationRequest; +use Google\Cloud\CertificateManager\V1\ListCertificateIssuanceConfigsRequest; +use Google\Cloud\CertificateManager\V1\ListCertificateMapEntriesRequest; +use Google\Cloud\CertificateManager\V1\ListCertificateMapsRequest; +use Google\Cloud\CertificateManager\V1\ListCertificatesRequest; +use Google\Cloud\CertificateManager\V1\ListDnsAuthorizationsRequest; +use Google\Cloud\CertificateManager\V1\UpdateCertificateMapEntryRequest; +use Google\Cloud\CertificateManager\V1\UpdateCertificateMapRequest; +use Google\Cloud\CertificateManager\V1\UpdateCertificateRequest; +use Google\Cloud\CertificateManager\V1\UpdateDnsAuthorizationRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: API Overview * - * This class is currently experimental and may be subject to changes. + * Certificates Manager API allows customers to see and manage all their TLS + * certificates. + * + * Certificates Manager API service provides methods to manage certificates, + * group them into collections, and create serving configuration that can be + * easily applied to other Cloud resources e.g. Target Proxies. + * + * Data Model + * + * The Certificates Manager service exposes the following resources: + * + * * `Certificate` that describes a single TLS certificate. + * * `CertificateMap` that describes a collection of certificates that can be + * attached to a target resource. + * * `CertificateMapEntry` that describes a single configuration entry that + * consists of a SNI and a group of certificates. It's a subresource of + * CertificateMap. + * + * Certificate, CertificateMap and CertificateMapEntry IDs + * have to fully match the regexp `[a-z0-9-]{1,63}`. In other words, + * - only lower case letters, digits, and hyphen are allowed + * - length of the resource ID has to be in [1,63] range. + * + * Provides methods to manage Cloud Certificate Manager entities. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\CertificateManager\V1\CertificateManagerClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createCertificateAsync(CreateCertificateRequest $request, array $optionalArgs = []) + * @method PromiseInterface createCertificateIssuanceConfigAsync(CreateCertificateIssuanceConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface createCertificateMapAsync(CreateCertificateMapRequest $request, array $optionalArgs = []) + * @method PromiseInterface createCertificateMapEntryAsync(CreateCertificateMapEntryRequest $request, array $optionalArgs = []) + * @method PromiseInterface createDnsAuthorizationAsync(CreateDnsAuthorizationRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteCertificateAsync(DeleteCertificateRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteCertificateIssuanceConfigAsync(DeleteCertificateIssuanceConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteCertificateMapAsync(DeleteCertificateMapRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteCertificateMapEntryAsync(DeleteCertificateMapEntryRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDnsAuthorizationAsync(DeleteDnsAuthorizationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCertificateAsync(GetCertificateRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCertificateIssuanceConfigAsync(GetCertificateIssuanceConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCertificateMapAsync(GetCertificateMapRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCertificateMapEntryAsync(GetCertificateMapEntryRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDnsAuthorizationAsync(GetDnsAuthorizationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCertificateIssuanceConfigsAsync(ListCertificateIssuanceConfigsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCertificateMapEntriesAsync(ListCertificateMapEntriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCertificateMapsAsync(ListCertificateMapsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCertificatesAsync(ListCertificatesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDnsAuthorizationsAsync(ListDnsAuthorizationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCertificateAsync(UpdateCertificateRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCertificateMapAsync(UpdateCertificateMapRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCertificateMapEntryAsync(UpdateCertificateMapEntryRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDnsAuthorizationAsync(UpdateDnsAuthorizationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class CertificateManagerClient extends CertificateManagerBaseClient +final class CertificateManagerClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CertificateManagerBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.certificatemanager.v1.CertificateManager'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'certificatemanager.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/certificate_manager_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/certificate_manager_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/certificate_manager_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/certificate_manager_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a ca_pool + * resource. + * + * @param string $project + * @param string $location + * @param string $caPool + * + * @return string The formatted ca_pool resource. + */ + public static function caPoolName(string $project, string $location, string $caPool): string + { + return self::getPathTemplate('caPool')->render([ + 'project' => $project, + 'location' => $location, + 'ca_pool' => $caPool, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a certificate + * resource. + * + * @param string $project + * @param string $location + * @param string $certificate + * + * @return string The formatted certificate resource. + */ + public static function certificateName(string $project, string $location, string $certificate): string + { + return self::getPathTemplate('certificate')->render([ + 'project' => $project, + 'location' => $location, + 'certificate' => $certificate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * certificate_issuance_config resource. + * + * @param string $project + * @param string $location + * @param string $certificateIssuanceConfig + * + * @return string The formatted certificate_issuance_config resource. + */ + public static function certificateIssuanceConfigName(string $project, string $location, string $certificateIssuanceConfig): string + { + return self::getPathTemplate('certificateIssuanceConfig')->render([ + 'project' => $project, + 'location' => $location, + 'certificate_issuance_config' => $certificateIssuanceConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * certificate_map resource. + * + * @param string $project + * @param string $location + * @param string $certificateMap + * + * @return string The formatted certificate_map resource. + */ + public static function certificateMapName(string $project, string $location, string $certificateMap): string + { + return self::getPathTemplate('certificateMap')->render([ + 'project' => $project, + 'location' => $location, + 'certificate_map' => $certificateMap, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * certificate_map_entry resource. + * + * @param string $project + * @param string $location + * @param string $certificateMap + * @param string $certificateMapEntry + * + * @return string The formatted certificate_map_entry resource. + */ + public static function certificateMapEntryName(string $project, string $location, string $certificateMap, string $certificateMapEntry): string + { + return self::getPathTemplate('certificateMapEntry')->render([ + 'project' => $project, + 'location' => $location, + 'certificate_map' => $certificateMap, + 'certificate_map_entry' => $certificateMapEntry, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * dns_authorization resource. + * + * @param string $project + * @param string $location + * @param string $dnsAuthorization + * + * @return string The formatted dns_authorization resource. + */ + public static function dnsAuthorizationName(string $project, string $location, string $dnsAuthorization): string + { + return self::getPathTemplate('dnsAuthorization')->render([ + 'project' => $project, + 'location' => $location, + 'dns_authorization' => $dnsAuthorization, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - caPool: projects/{project}/locations/{location}/caPools/{ca_pool} + * - certificate: projects/{project}/locations/{location}/certificates/{certificate} + * - certificateIssuanceConfig: projects/{project}/locations/{location}/certificateIssuanceConfigs/{certificate_issuance_config} + * - certificateMap: projects/{project}/locations/{location}/certificateMaps/{certificate_map} + * - certificateMapEntry: projects/{project}/locations/{location}/certificateMaps/{certificate_map}/certificateMapEntries/{certificate_map_entry} + * - dnsAuthorization: projects/{project}/locations/{location}/dnsAuthorizations/{dns_authorization} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'certificatemanager.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new Certificate in a given project and location. + * + * The async variant is {@see CertificateManagerClient::createCertificateAsync()} . + * + * @example samples/V1/CertificateManagerClient/create_certificate.php + * + * @param CreateCertificateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCertificate(CreateCertificateRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateCertificate', $request, $callOptions)->wait(); + } + + /** + * Creates a new CertificateIssuanceConfig in a given project and location. + * + * The async variant is + * {@see CertificateManagerClient::createCertificateIssuanceConfigAsync()} . + * + * @example samples/V1/CertificateManagerClient/create_certificate_issuance_config.php + * + * @param CreateCertificateIssuanceConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCertificateIssuanceConfig(CreateCertificateIssuanceConfigRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateCertificateIssuanceConfig', $request, $callOptions)->wait(); + } + + /** + * Creates a new CertificateMap in a given project and location. + * + * The async variant is + * {@see CertificateManagerClient::createCertificateMapAsync()} . + * + * @example samples/V1/CertificateManagerClient/create_certificate_map.php + * + * @param CreateCertificateMapRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCertificateMap(CreateCertificateMapRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateCertificateMap', $request, $callOptions)->wait(); + } + + /** + * Creates a new CertificateMapEntry in a given project and location. + * + * The async variant is + * {@see CertificateManagerClient::createCertificateMapEntryAsync()} . + * + * @example samples/V1/CertificateManagerClient/create_certificate_map_entry.php + * + * @param CreateCertificateMapEntryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCertificateMapEntry(CreateCertificateMapEntryRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateCertificateMapEntry', $request, $callOptions)->wait(); + } + + /** + * Creates a new DnsAuthorization in a given project and location. + * + * The async variant is + * {@see CertificateManagerClient::createDnsAuthorizationAsync()} . + * + * @example samples/V1/CertificateManagerClient/create_dns_authorization.php + * + * @param CreateDnsAuthorizationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDnsAuthorization(CreateDnsAuthorizationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateDnsAuthorization', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Certificate. + * + * The async variant is {@see CertificateManagerClient::deleteCertificateAsync()} . + * + * @example samples/V1/CertificateManagerClient/delete_certificate.php + * + * @param DeleteCertificateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteCertificate(DeleteCertificateRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteCertificate', $request, $callOptions)->wait(); + } + + /** + * Deletes a single CertificateIssuanceConfig. + * + * The async variant is + * {@see CertificateManagerClient::deleteCertificateIssuanceConfigAsync()} . + * + * @example samples/V1/CertificateManagerClient/delete_certificate_issuance_config.php + * + * @param DeleteCertificateIssuanceConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteCertificateIssuanceConfig(DeleteCertificateIssuanceConfigRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteCertificateIssuanceConfig', $request, $callOptions)->wait(); + } + + /** + * Deletes a single CertificateMap. A Certificate Map can't be deleted + * if it contains Certificate Map Entries. Remove all the entries from + * the map before calling this method. + * + * The async variant is + * {@see CertificateManagerClient::deleteCertificateMapAsync()} . + * + * @example samples/V1/CertificateManagerClient/delete_certificate_map.php + * + * @param DeleteCertificateMapRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteCertificateMap(DeleteCertificateMapRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteCertificateMap', $request, $callOptions)->wait(); + } + + /** + * Deletes a single CertificateMapEntry. + * + * The async variant is + * {@see CertificateManagerClient::deleteCertificateMapEntryAsync()} . + * + * @example samples/V1/CertificateManagerClient/delete_certificate_map_entry.php + * + * @param DeleteCertificateMapEntryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteCertificateMapEntry(DeleteCertificateMapEntryRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteCertificateMapEntry', $request, $callOptions)->wait(); + } + + /** + * Deletes a single DnsAuthorization. + * + * The async variant is + * {@see CertificateManagerClient::deleteDnsAuthorizationAsync()} . + * + * @example samples/V1/CertificateManagerClient/delete_dns_authorization.php + * + * @param DeleteDnsAuthorizationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDnsAuthorization(DeleteDnsAuthorizationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteDnsAuthorization', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Certificate. + * + * The async variant is {@see CertificateManagerClient::getCertificateAsync()} . + * + * @example samples/V1/CertificateManagerClient/get_certificate.php + * + * @param GetCertificateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Certificate + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCertificate(GetCertificateRequest $request, array $callOptions = []): Certificate + { + return $this->startApiCall('GetCertificate', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single CertificateIssuanceConfig. + * + * The async variant is + * {@see CertificateManagerClient::getCertificateIssuanceConfigAsync()} . + * + * @example samples/V1/CertificateManagerClient/get_certificate_issuance_config.php + * + * @param GetCertificateIssuanceConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CertificateIssuanceConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCertificateIssuanceConfig(GetCertificateIssuanceConfigRequest $request, array $callOptions = []): CertificateIssuanceConfig + { + return $this->startApiCall('GetCertificateIssuanceConfig', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single CertificateMap. + * + * The async variant is {@see CertificateManagerClient::getCertificateMapAsync()} . + * + * @example samples/V1/CertificateManagerClient/get_certificate_map.php + * + * @param GetCertificateMapRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CertificateMap + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCertificateMap(GetCertificateMapRequest $request, array $callOptions = []): CertificateMap + { + return $this->startApiCall('GetCertificateMap', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single CertificateMapEntry. + * + * The async variant is + * {@see CertificateManagerClient::getCertificateMapEntryAsync()} . + * + * @example samples/V1/CertificateManagerClient/get_certificate_map_entry.php + * + * @param GetCertificateMapEntryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CertificateMapEntry + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCertificateMapEntry(GetCertificateMapEntryRequest $request, array $callOptions = []): CertificateMapEntry + { + return $this->startApiCall('GetCertificateMapEntry', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single DnsAuthorization. + * + * The async variant is {@see CertificateManagerClient::getDnsAuthorizationAsync()} + * . + * + * @example samples/V1/CertificateManagerClient/get_dns_authorization.php + * + * @param GetDnsAuthorizationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DnsAuthorization + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDnsAuthorization(GetDnsAuthorizationRequest $request, array $callOptions = []): DnsAuthorization + { + return $this->startApiCall('GetDnsAuthorization', $request, $callOptions)->wait(); + } + + /** + * Lists CertificateIssuanceConfigs in a given project and location. + * + * The async variant is + * {@see CertificateManagerClient::listCertificateIssuanceConfigsAsync()} . + * + * @example samples/V1/CertificateManagerClient/list_certificate_issuance_configs.php + * + * @param ListCertificateIssuanceConfigsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCertificateIssuanceConfigs(ListCertificateIssuanceConfigsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCertificateIssuanceConfigs', $request, $callOptions); + } + + /** + * Lists CertificateMapEntries in a given project and location. + * + * The async variant is + * {@see CertificateManagerClient::listCertificateMapEntriesAsync()} . + * + * @example samples/V1/CertificateManagerClient/list_certificate_map_entries.php + * + * @param ListCertificateMapEntriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCertificateMapEntries(ListCertificateMapEntriesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCertificateMapEntries', $request, $callOptions); + } + + /** + * Lists CertificateMaps in a given project and location. + * + * The async variant is {@see CertificateManagerClient::listCertificateMapsAsync()} + * . + * + * @example samples/V1/CertificateManagerClient/list_certificate_maps.php + * + * @param ListCertificateMapsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCertificateMaps(ListCertificateMapsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCertificateMaps', $request, $callOptions); + } + + /** + * Lists Certificates in a given project and location. + * + * The async variant is {@see CertificateManagerClient::listCertificatesAsync()} . + * + * @example samples/V1/CertificateManagerClient/list_certificates.php + * + * @param ListCertificatesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCertificates(ListCertificatesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCertificates', $request, $callOptions); + } + + /** + * Lists DnsAuthorizations in a given project and location. + * + * The async variant is + * {@see CertificateManagerClient::listDnsAuthorizationsAsync()} . + * + * @example samples/V1/CertificateManagerClient/list_dns_authorizations.php + * + * @param ListDnsAuthorizationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDnsAuthorizations(ListDnsAuthorizationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDnsAuthorizations', $request, $callOptions); + } + + /** + * Updates a Certificate. + * + * The async variant is {@see CertificateManagerClient::updateCertificateAsync()} . + * + * @example samples/V1/CertificateManagerClient/update_certificate.php + * + * @param UpdateCertificateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCertificate(UpdateCertificateRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateCertificate', $request, $callOptions)->wait(); + } + + /** + * Updates a CertificateMap. + * + * The async variant is + * {@see CertificateManagerClient::updateCertificateMapAsync()} . + * + * @example samples/V1/CertificateManagerClient/update_certificate_map.php + * + * @param UpdateCertificateMapRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCertificateMap(UpdateCertificateMapRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateCertificateMap', $request, $callOptions)->wait(); + } + + /** + * Updates a CertificateMapEntry. + * + * The async variant is + * {@see CertificateManagerClient::updateCertificateMapEntryAsync()} . + * + * @example samples/V1/CertificateManagerClient/update_certificate_map_entry.php + * + * @param UpdateCertificateMapEntryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCertificateMapEntry(UpdateCertificateMapEntryRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateCertificateMapEntry', $request, $callOptions)->wait(); + } + + /** + * Updates a DnsAuthorization. + * + * The async variant is + * {@see CertificateManagerClient::updateDnsAuthorizationAsync()} . + * + * @example samples/V1/CertificateManagerClient/update_dns_authorization.php + * + * @param UpdateDnsAuthorizationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDnsAuthorization(UpdateDnsAuthorizationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateDnsAuthorization', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see CertificateManagerClient::getLocationAsync()} . + * + * @example samples/V1/CertificateManagerClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see CertificateManagerClient::listLocationsAsync()} . + * + * @example samples/V1/CertificateManagerClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Channel/composer.json b/Channel/composer.json index 49e37e1555bd..501f7dc4d348 100644 --- a/Channel/composer.json +++ b/Channel/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Channel/src/V1/Client/BaseClient/CloudChannelReportsServiceBaseClient.php b/Channel/src/V1/Client/BaseClient/CloudChannelReportsServiceBaseClient.php deleted file mode 100644 index eb86995558a3..000000000000 --- a/Channel/src/V1/Client/BaseClient/CloudChannelReportsServiceBaseClient.php +++ /dev/null @@ -1,371 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/cloud_channel_reports_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/cloud_channel_reports_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/cloud_channel_reports_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/cloud_channel_reports_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a report - * resource. - * - * @param string $account - * @param string $report - * - * @return string The formatted report resource. - */ - public static function reportName(string $account, string $report): string - { - return self::getPathTemplate('report')->render([ - 'account' => $account, - 'report' => $report, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a report_job - * resource. - * - * @param string $account - * @param string $reportJob - * - * @return string The formatted report_job resource. - */ - public static function reportJobName(string $account, string $reportJob): string - { - return self::getPathTemplate('reportJob')->render([ - 'account' => $account, - 'report_job' => $reportJob, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - report: accounts/{account}/reports/{report} - * - reportJob: accounts/{account}/reportJobs/{report_job} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudchannel.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves data generated by - * [CloudChannelReportsService.RunReportJob][google.cloud.channel.v1.CloudChannelReportsService.RunReportJob]. - * - * The async variant is {@see self::fetchReportResultsAsync()} . - * - * @param FetchReportResultsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function fetchReportResults(FetchReportResultsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('FetchReportResults', $request, $callOptions); - } - - /** - * Lists the reports that RunReportJob can run. These reports include an ID, - * a description, and the list of columns that will be in the result. - * - * The async variant is {@see self::listReportsAsync()} . - * - * @param ListReportsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listReports(ListReportsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListReports', $request, $callOptions); - } - - /** - * Begins generation of data for a given report. The report - * identifier is a UID (for example, `613bf59q`). - * - * Possible error codes: - * - * * PERMISSION_DENIED: The user doesn't have access to this report. - * * INVALID_ARGUMENT: Required request parameters are missing - * or invalid. - * * NOT_FOUND: The report identifier was not found. - * * INTERNAL: Any non-user error related to a technical issue - * in the backend. Contact Cloud Channel support. - * * UNKNOWN: Any non-user error related to a technical issue - * in the backend. Contact Cloud Channel support. - * - * Return value: - * The ID of a long-running operation. - * - * To get the results of the operation, call the GetOperation method of - * CloudChannelOperationsService. The Operation metadata contains an - * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - * - * To get the results of report generation, call - * [CloudChannelReportsService.FetchReportResults][google.cloud.channel.v1.CloudChannelReportsService.FetchReportResults] - * with the - * [RunReportJobResponse.report_job][google.cloud.channel.v1.RunReportJobResponse.report_job]. - * - * The async variant is {@see self::runReportJobAsync()} . - * - * @param RunReportJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function runReportJob(RunReportJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RunReportJob', $request, $callOptions)->wait(); - } -} diff --git a/Channel/src/V1/Client/BaseClient/CloudChannelServiceBaseClient.php b/Channel/src/V1/Client/BaseClient/CloudChannelServiceBaseClient.php deleted file mode 100644 index 0b70add491e3..000000000000 --- a/Channel/src/V1/Client/BaseClient/CloudChannelServiceBaseClient.php +++ /dev/null @@ -1,2585 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/cloud_channel_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/cloud_channel_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/cloud_channel_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/cloud_channel_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * channel_partner_link resource. - * - * @param string $account - * @param string $channelPartnerLink - * - * @return string The formatted channel_partner_link resource. - */ - public static function channelPartnerLinkName(string $account, string $channelPartnerLink): string - { - return self::getPathTemplate('channelPartnerLink')->render([ - 'account' => $account, - 'channel_partner_link' => $channelPartnerLink, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * channel_partner_repricing_config resource. - * - * @param string $account - * @param string $channelPartner - * @param string $channelPartnerRepricingConfig - * - * @return string The formatted channel_partner_repricing_config resource. - */ - public static function channelPartnerRepricingConfigName(string $account, string $channelPartner, string $channelPartnerRepricingConfig): string - { - return self::getPathTemplate('channelPartnerRepricingConfig')->render([ - 'account' => $account, - 'channel_partner' => $channelPartner, - 'channel_partner_repricing_config' => $channelPartnerRepricingConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a customer - * resource. - * - * @param string $account - * @param string $customer - * - * @return string The formatted customer resource. - */ - public static function customerName(string $account, string $customer): string - { - return self::getPathTemplate('customer')->render([ - 'account' => $account, - 'customer' => $customer, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * customer_repricing_config resource. - * - * @param string $account - * @param string $customer - * @param string $customerRepricingConfig - * - * @return string The formatted customer_repricing_config resource. - */ - public static function customerRepricingConfigName(string $account, string $customer, string $customerRepricingConfig): string - { - return self::getPathTemplate('customerRepricingConfig')->render([ - 'account' => $account, - 'customer' => $customer, - 'customer_repricing_config' => $customerRepricingConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a entitlement - * resource. - * - * @param string $account - * @param string $customer - * @param string $entitlement - * - * @return string The formatted entitlement resource. - */ - public static function entitlementName(string $account, string $customer, string $entitlement): string - { - return self::getPathTemplate('entitlement')->render([ - 'account' => $account, - 'customer' => $customer, - 'entitlement' => $entitlement, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a offer - * resource. - * - * @param string $account - * @param string $offer - * - * @return string The formatted offer resource. - */ - public static function offerName(string $account, string $offer): string - { - return self::getPathTemplate('offer')->render([ - 'account' => $account, - 'offer' => $offer, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a product - * resource. - * - * @param string $product - * - * @return string The formatted product resource. - */ - public static function productName(string $product): string - { - return self::getPathTemplate('product')->render([ - 'product' => $product, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a sku_group - * resource. - * - * @param string $account - * @param string $skuGroup - * - * @return string The formatted sku_group resource. - */ - public static function skuGroupName(string $account, string $skuGroup): string - { - return self::getPathTemplate('skuGroup')->render([ - 'account' => $account, - 'sku_group' => $skuGroup, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - channelPartnerLink: accounts/{account}/channelPartnerLinks/{channel_partner_link} - * - channelPartnerRepricingConfig: accounts/{account}/channelPartnerLinks/{channel_partner}/channelPartnerRepricingConfigs/{channel_partner_repricing_config} - * - customer: accounts/{account}/customers/{customer} - * - customerRepricingConfig: accounts/{account}/customers/{customer}/customerRepricingConfigs/{customer_repricing_config} - * - entitlement: accounts/{account}/customers/{customer}/entitlements/{entitlement} - * - offer: accounts/{account}/offers/{offer} - * - product: products/{product} - * - skuGroup: accounts/{account}/skuGroups/{sku_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. - */ - public static function parseName(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudchannel.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Activates a previously suspended entitlement. Entitlements suspended for - * pending ToS acceptance can't be activated using this method. - * - * An entitlement activation is a long-running operation and it updates - * the state of the customer entitlement. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The reseller account making the request is different - * from the reseller account in the API request. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * * NOT_FOUND: Entitlement resource not found. - * * SUSPENSION_NOT_RESELLER_INITIATED: Can only activate reseller-initiated - * suspensions and entitlements that have accepted the TOS. - * * NOT_SUSPENDED: Can only activate suspended entitlements not in an ACTIVE - * state. - * * INTERNAL: Any non-user error related to a technical issue in the - * backend. Contact Cloud Channel support. - * * UNKNOWN: Any non-user error related to a technical issue in the backend. - * Contact Cloud Channel support. - * - * Return value: - * The ID of a long-running operation. - * - * To get the results of the operation, call the GetOperation method of - * CloudChannelOperationsService. The Operation metadata will contain an - * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - * - * The async variant is {@see self::activateEntitlementAsync()} . - * - * @param ActivateEntitlementRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function activateEntitlement(ActivateEntitlementRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ActivateEntitlement', $request, $callOptions)->wait(); - } - - /** - * Cancels a previously fulfilled entitlement. - * - * An entitlement cancellation is a long-running operation. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The reseller account making the request is different - * from the reseller account in the API request. - * * FAILED_PRECONDITION: There are Google Cloud projects linked to the - * Google Cloud entitlement's Cloud Billing subaccount. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * * NOT_FOUND: Entitlement resource not found. - * * DELETION_TYPE_NOT_ALLOWED: Cancel is only allowed for Google Workspace - * add-ons, or entitlements for Google Cloud's development platform. - * * INTERNAL: Any non-user error related to a technical issue in the - * backend. Contact Cloud Channel support. - * * UNKNOWN: Any non-user error related to a technical issue in the backend. - * Contact Cloud Channel support. - * - * Return value: - * The ID of a long-running operation. - * - * To get the results of the operation, call the GetOperation method of - * CloudChannelOperationsService. The response will contain - * google.protobuf.Empty on success. The Operation metadata will contain an - * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - * - * The async variant is {@see self::cancelEntitlementAsync()} . - * - * @param CancelEntitlementRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function cancelEntitlement(CancelEntitlementRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CancelEntitlement', $request, $callOptions)->wait(); - } - - /** - * Updates the Offer for an existing customer entitlement. - * - * An entitlement update is a long-running operation and it updates the - * entitlement as a result of fulfillment. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The customer doesn't belong to the reseller. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * * NOT_FOUND: Offer or Entitlement resource not found. - * * INTERNAL: Any non-user error related to a technical issue in the - * backend. Contact Cloud Channel support. - * * UNKNOWN: Any non-user error related to a technical issue in the backend. - * Contact Cloud Channel support. - * - * Return value: - * The ID of a long-running operation. - * - * To get the results of the operation, call the GetOperation method of - * CloudChannelOperationsService. The Operation metadata will contain an - * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - * - * The async variant is {@see self::changeOfferAsync()} . - * - * @param ChangeOfferRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function changeOffer(ChangeOfferRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ChangeOffer', $request, $callOptions)->wait(); - } - - /** - * Change parameters of the entitlement. - * - * An entitlement update is a long-running operation and it updates the - * entitlement as a result of fulfillment. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The customer doesn't belong to the reseller. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * For example, the number of seats being changed is greater than the allowed - * number of max seats, or decreasing seats for a commitment based plan. - * * NOT_FOUND: Entitlement resource not found. - * * INTERNAL: Any non-user error related to a technical issue in the - * backend. Contact Cloud Channel support. - * * UNKNOWN: Any non-user error related to a technical issue in the backend. - * Contact Cloud Channel support. - * - * Return value: - * The ID of a long-running operation. - * - * To get the results of the operation, call the GetOperation method of - * CloudChannelOperationsService. The Operation metadata will contain an - * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - * - * The async variant is {@see self::changeParametersAsync()} . - * - * @param ChangeParametersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function changeParameters(ChangeParametersRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ChangeParameters', $request, $callOptions)->wait(); - } - - /** - * Updates the renewal settings for an existing customer entitlement. - * - * An entitlement update is a long-running operation and it updates the - * entitlement as a result of fulfillment. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The customer doesn't belong to the reseller. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * * NOT_FOUND: Entitlement resource not found. - * * NOT_COMMITMENT_PLAN: Renewal Settings are only applicable for a - * commitment plan. Can't enable or disable renewals for non-commitment plans. - * * INTERNAL: Any non-user error related to a technical issue in the - * backend. Contact Cloud Channel support. - * * UNKNOWN: Any non-user error related to a technical issue in the backend. - * Contact Cloud Channel support. - * - * Return value: - * The ID of a long-running operation. - * - * To get the results of the operation, call the GetOperation method of - * CloudChannelOperationsService. The Operation metadata will contain an - * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - * - * The async variant is {@see self::changeRenewalSettingsAsync()} . - * - * @param ChangeRenewalSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function changeRenewalSettings(ChangeRenewalSettingsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ChangeRenewalSettings', $request, $callOptions)->wait(); - } - - /** - * Confirms the existence of Cloud Identity accounts based on the domain and - * if the Cloud Identity accounts are owned by the reseller. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The reseller account making the request is different - * from the reseller account in the API request. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * * INVALID_VALUE: Invalid domain value in the request. - * - * Return value: - * A list of - * [CloudIdentityCustomerAccount][google.cloud.channel.v1.CloudIdentityCustomerAccount] - * resources for the domain (may be empty) - * - * Note: in the v1alpha1 version of the API, a NOT_FOUND error returns if - * no - * [CloudIdentityCustomerAccount][google.cloud.channel.v1.CloudIdentityCustomerAccount] - * resources match the domain. - * - * The async variant is {@see self::checkCloudIdentityAccountsExistAsync()} . - * - * @param CheckCloudIdentityAccountsExistRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CheckCloudIdentityAccountsExistResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function checkCloudIdentityAccountsExist(CheckCloudIdentityAccountsExistRequest $request, array $callOptions = []): CheckCloudIdentityAccountsExistResponse - { - return $this->startApiCall('CheckCloudIdentityAccountsExist', $request, $callOptions)->wait(); - } - - /** - * Initiates a channel partner link between a distributor and a reseller, or - * between resellers in an n-tier reseller channel. - * Invited partners need to follow the invite_link_uri provided in the - * response to accept. After accepting the invitation, a link is set up - * between the two parties. - * You must be a distributor to call this method. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The reseller account making the request is different - * from the reseller account in the API request. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * * ALREADY_EXISTS: The ChannelPartnerLink sent in the request already - * exists. - * * NOT_FOUND: No Cloud Identity customer exists for provided domain. - * * INTERNAL: Any non-user error related to a technical issue in the - * backend. Contact Cloud Channel support. - * * UNKNOWN: Any non-user error related to a technical issue in the backend. - * Contact Cloud Channel support. - * - * Return value: - * The new [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - * resource. - * - * The async variant is {@see self::createChannelPartnerLinkAsync()} . - * - * @param CreateChannelPartnerLinkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ChannelPartnerLink - * - * @throws ApiException Thrown if the API call fails. - */ - public function createChannelPartnerLink(CreateChannelPartnerLinkRequest $request, array $callOptions = []): ChannelPartnerLink - { - return $this->startApiCall('CreateChannelPartnerLink', $request, $callOptions)->wait(); - } - - /** - * Creates a ChannelPartnerRepricingConfig. Call this method to set - * modifications for a specific ChannelPartner's bill. You can only create - * configs if the - * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month] - * is a future month. If needed, you can create a config for the current - * month, with some restrictions. - * - * When creating a config for a future month, make sure there are no existing - * configs for that - * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month]. - * - * The following restrictions are for creating configs in the current month. - * - * * This functionality is reserved for recovering from an erroneous config, - * and should not be used for regular business cases. - * * The new config will not modify exports used with other configs. - * Changes to the config may be immediate, but may take up to 24 hours. - * * There is a limit of ten configs for any ChannelPartner or - * [RepricingConfig.EntitlementGranularity.entitlement][google.cloud.channel.v1.RepricingConfig.EntitlementGranularity.entitlement], - * for any - * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month]. - * * The contained - * [ChannelPartnerRepricingConfig.repricing_config][google.cloud.channel.v1.ChannelPartnerRepricingConfig.repricing_config] - * value must be different from the value used in the current config for a - * ChannelPartner. - * - * Possible Error Codes: - * - * * PERMISSION_DENIED: If the account making the request and the account - * being queried are different. - * * INVALID_ARGUMENT: Missing or invalid required parameters in the - * request. Also displays if the updated config is for the current month or - * past months. - * * NOT_FOUND: The - * [ChannelPartnerRepricingConfig][google.cloud.channel.v1.ChannelPartnerRepricingConfig] - * specified does not exist or is not associated with the given account. - * * INTERNAL: Any non-user error related to technical issues in the - * backend. In this case, contact Cloud Channel support. - * - * Return Value: - * If successful, the updated - * [ChannelPartnerRepricingConfig][google.cloud.channel.v1.ChannelPartnerRepricingConfig] - * resource, otherwise returns an error. - * - * The async variant is {@see self::createChannelPartnerRepricingConfigAsync()} . - * - * @param CreateChannelPartnerRepricingConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ChannelPartnerRepricingConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function createChannelPartnerRepricingConfig(CreateChannelPartnerRepricingConfigRequest $request, array $callOptions = []): ChannelPartnerRepricingConfig - { - return $this->startApiCall('CreateChannelPartnerRepricingConfig', $request, $callOptions)->wait(); - } - - /** - * Creates a new [Customer][google.cloud.channel.v1.Customer] resource under - * the reseller or distributor account. - * - * Possible error codes: - * - * * PERMISSION_DENIED: - * * The reseller account making the request is different from the - * reseller account in the API request. - * * You are not authorized to create a customer. See - * https://support.google.com/channelservices/answer/9759265 - * * INVALID_ARGUMENT: - * * Required request parameters are missing or invalid. - * * Domain field value doesn't match the primary email domain. - * - * Return value: - * The newly created [Customer][google.cloud.channel.v1.Customer] resource. - * - * The async variant is {@see self::createCustomerAsync()} . - * - * @param CreateCustomerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Customer - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCustomer(CreateCustomerRequest $request, array $callOptions = []): Customer - { - return $this->startApiCall('CreateCustomer', $request, $callOptions)->wait(); - } - - /** - * Creates a CustomerRepricingConfig. Call this method to set modifications - * for a specific customer's bill. You can only create configs if the - * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month] - * is a future month. If needed, you can create a config for the current - * month, with some restrictions. - * - * When creating a config for a future month, make sure there are no existing - * configs for that - * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month]. - * - * The following restrictions are for creating configs in the current month. - * - * * This functionality is reserved for recovering from an erroneous config, - * and should not be used for regular business cases. - * * The new config will not modify exports used with other configs. - * Changes to the config may be immediate, but may take up to 24 hours. - * * There is a limit of ten configs for any - * [RepricingConfig.EntitlementGranularity.entitlement][google.cloud.channel.v1.RepricingConfig.EntitlementGranularity.entitlement], - * for any - * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month]. - * * The contained - * [CustomerRepricingConfig.repricing_config][google.cloud.channel.v1.CustomerRepricingConfig.repricing_config] - * value must be different from the value used in the current config for a - * [RepricingConfig.EntitlementGranularity.entitlement][google.cloud.channel.v1.RepricingConfig.EntitlementGranularity.entitlement]. - * - * Possible Error Codes: - * - * * PERMISSION_DENIED: If the account making the request and the account - * being queried are different. - * * INVALID_ARGUMENT: Missing or invalid required parameters in the - * request. Also displays if the updated config is for the current month or - * past months. - * * NOT_FOUND: The - * [CustomerRepricingConfig][google.cloud.channel.v1.CustomerRepricingConfig] - * specified does not exist or is not associated with the given account. - * * INTERNAL: Any non-user error related to technical issues in the - * backend. In this case, contact Cloud Channel support. - * - * Return Value: - * If successful, the updated - * [CustomerRepricingConfig][google.cloud.channel.v1.CustomerRepricingConfig] - * resource, otherwise returns an error. - * - * The async variant is {@see self::createCustomerRepricingConfigAsync()} . - * - * @param CreateCustomerRepricingConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CustomerRepricingConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCustomerRepricingConfig(CreateCustomerRepricingConfigRequest $request, array $callOptions = []): CustomerRepricingConfig - { - return $this->startApiCall('CreateCustomerRepricingConfig', $request, $callOptions)->wait(); - } - - /** - * Creates an entitlement for a customer. - * - * Possible error codes: - * - * * PERMISSION_DENIED: - * * The customer doesn't belong to the reseller. - * * The reseller is not authorized to transact on this Product. See - * https://support.google.com/channelservices/answer/9759265 - * * INVALID_ARGUMENT: - * * Required request parameters are missing or invalid. - * * There is already a customer entitlement for a SKU from the same - * product family. - * * INVALID_VALUE: Make sure the OfferId is valid. If it is, contact - * Google Channel support for further troubleshooting. - * * NOT_FOUND: The customer or offer resource was not found. - * * ALREADY_EXISTS: - * * The SKU was already purchased for the customer. - * * The customer's primary email already exists. Retry - * after changing the customer's primary contact email. - * * CONDITION_NOT_MET or FAILED_PRECONDITION: - * * The domain required for purchasing a SKU has not been verified. - * * A pre-requisite SKU required to purchase an Add-On SKU is missing. - * For example, Google Workspace Business Starter is required to purchase - * Vault or Drive. - * * (Developer accounts only) Reseller and resold domain must meet the - * following naming requirements: - * * Domain names must start with goog-test. - * * Domain names must include the reseller domain. - * * INTERNAL: Any non-user error related to a technical issue in the - * backend. Contact Cloud Channel support. - * * UNKNOWN: Any non-user error related to a technical issue in the backend. - * Contact Cloud Channel support. - * - * Return value: - * The ID of a long-running operation. - * - * To get the results of the operation, call the GetOperation method of - * CloudChannelOperationsService. The Operation metadata will contain an - * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - * - * The async variant is {@see self::createEntitlementAsync()} . - * - * @param CreateEntitlementRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createEntitlement(CreateEntitlementRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateEntitlement', $request, $callOptions)->wait(); - } - - /** - * Deletes the given - * [ChannelPartnerRepricingConfig][google.cloud.channel.v1.ChannelPartnerRepricingConfig] - * permanently. You can only delete configs if their - * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month] - * is set to a date after the current month. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The account making the request does not own - * this customer. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * * FAILED_PRECONDITION: The - * [ChannelPartnerRepricingConfig][google.cloud.channel.v1.ChannelPartnerRepricingConfig] - * is active or in the past. - * * NOT_FOUND: No - * [ChannelPartnerRepricingConfig][google.cloud.channel.v1.ChannelPartnerRepricingConfig] - * found for the name in the request. - * - * The async variant is {@see self::deleteChannelPartnerRepricingConfigAsync()} . - * - * @param DeleteChannelPartnerRepricingConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteChannelPartnerRepricingConfig(DeleteChannelPartnerRepricingConfigRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteChannelPartnerRepricingConfig', $request, $callOptions)->wait(); - } - - /** - * Deletes the given [Customer][google.cloud.channel.v1.Customer] permanently. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The account making the request does not own - * this customer. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * * FAILED_PRECONDITION: The customer has existing entitlements. - * * NOT_FOUND: No [Customer][google.cloud.channel.v1.Customer] resource found - * for the name in the request. - * - * The async variant is {@see self::deleteCustomerAsync()} . - * - * @param DeleteCustomerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteCustomer(DeleteCustomerRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteCustomer', $request, $callOptions)->wait(); - } - - /** - * Deletes the given - * [CustomerRepricingConfig][google.cloud.channel.v1.CustomerRepricingConfig] - * permanently. You can only delete configs if their - * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month] - * is set to a date after the current month. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The account making the request does not own - * this customer. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * * FAILED_PRECONDITION: The - * [CustomerRepricingConfig][google.cloud.channel.v1.CustomerRepricingConfig] - * is active or in the past. - * * NOT_FOUND: No - * [CustomerRepricingConfig][google.cloud.channel.v1.CustomerRepricingConfig] - * found for the name in the request. - * - * The async variant is {@see self::deleteCustomerRepricingConfigAsync()} . - * - * @param DeleteCustomerRepricingConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteCustomerRepricingConfig(DeleteCustomerRepricingConfigRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteCustomerRepricingConfig', $request, $callOptions)->wait(); - } - - /** - * Returns the requested - * [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] resource. - * You must be a distributor to call this method. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The reseller account making the request is different - * from the reseller account in the API request. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * * NOT_FOUND: ChannelPartnerLink resource not found because of an - * invalid channel partner link name. - * - * Return value: - * The [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] - * resource. - * - * The async variant is {@see self::getChannelPartnerLinkAsync()} . - * - * @param GetChannelPartnerLinkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ChannelPartnerLink - * - * @throws ApiException Thrown if the API call fails. - */ - public function getChannelPartnerLink(GetChannelPartnerLinkRequest $request, array $callOptions = []): ChannelPartnerLink - { - return $this->startApiCall('GetChannelPartnerLink', $request, $callOptions)->wait(); - } - - /** - * Gets information about how a Distributor modifies their bill before sending - * it to a ChannelPartner. - * - * Possible Error Codes: - * - * * PERMISSION_DENIED: If the account making the request and the account - * being queried are different. - * * NOT_FOUND: The - * [ChannelPartnerRepricingConfig][google.cloud.channel.v1.ChannelPartnerRepricingConfig] - * was not found. - * * INTERNAL: Any non-user error related to technical issues in the - * backend. In this case, contact Cloud Channel support. - * - * Return Value: - * If successful, the - * [ChannelPartnerRepricingConfig][google.cloud.channel.v1.ChannelPartnerRepricingConfig] - * resource, otherwise returns an error. - * - * The async variant is {@see self::getChannelPartnerRepricingConfigAsync()} . - * - * @param GetChannelPartnerRepricingConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ChannelPartnerRepricingConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getChannelPartnerRepricingConfig(GetChannelPartnerRepricingConfigRequest $request, array $callOptions = []): ChannelPartnerRepricingConfig - { - return $this->startApiCall('GetChannelPartnerRepricingConfig', $request, $callOptions)->wait(); - } - - /** - * Returns the requested [Customer][google.cloud.channel.v1.Customer] - * resource. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The reseller account making the request is different - * from the reseller account in the API request. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * * NOT_FOUND: The customer resource doesn't exist. Usually the result of an - * invalid name parameter. - * - * Return value: - * The [Customer][google.cloud.channel.v1.Customer] resource. - * - * The async variant is {@see self::getCustomerAsync()} . - * - * @param GetCustomerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Customer - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCustomer(GetCustomerRequest $request, array $callOptions = []): Customer - { - return $this->startApiCall('GetCustomer', $request, $callOptions)->wait(); - } - - /** - * Gets information about how a Reseller modifies their bill before sending - * it to a Customer. - * - * Possible Error Codes: - * - * * PERMISSION_DENIED: If the account making the request and the account - * being queried are different. - * * NOT_FOUND: The - * [CustomerRepricingConfig][google.cloud.channel.v1.CustomerRepricingConfig] - * was not found. - * * INTERNAL: Any non-user error related to technical issues in the - * backend. In this case, contact Cloud Channel support. - * - * Return Value: - * If successful, the - * [CustomerRepricingConfig][google.cloud.channel.v1.CustomerRepricingConfig] - * resource, otherwise returns an error. - * - * The async variant is {@see self::getCustomerRepricingConfigAsync()} . - * - * @param GetCustomerRepricingConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CustomerRepricingConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCustomerRepricingConfig(GetCustomerRepricingConfigRequest $request, array $callOptions = []): CustomerRepricingConfig - { - return $this->startApiCall('GetCustomerRepricingConfig', $request, $callOptions)->wait(); - } - - /** - * Returns the requested [Entitlement][google.cloud.channel.v1.Entitlement] - * resource. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The customer doesn't belong to the reseller. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * * NOT_FOUND: The customer entitlement was not found. - * - * Return value: - * The requested [Entitlement][google.cloud.channel.v1.Entitlement] resource. - * - * The async variant is {@see self::getEntitlementAsync()} . - * - * @param GetEntitlementRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Entitlement - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEntitlement(GetEntitlementRequest $request, array $callOptions = []): Entitlement - { - return $this->startApiCall('GetEntitlement', $request, $callOptions)->wait(); - } - - /** - * Imports a [Customer][google.cloud.channel.v1.Customer] from the Cloud - * Identity associated with the provided Cloud Identity ID or domain before a - * TransferEntitlements call. If a linked Customer already exists and - * overwrite_if_exists is true, it will update that Customer's data. - * - * Possible error codes: - * - * * PERMISSION_DENIED: - * * The reseller account making the request is different from the - * reseller account in the API request. - * * You are not authorized to import the customer. See - * https://support.google.com/channelservices/answer/9759265 - * * NOT_FOUND: Cloud Identity doesn't exist or was deleted. - * * INVALID_ARGUMENT: Required parameters are missing, or the auth_token is - * expired or invalid. - * * ALREADY_EXISTS: A customer already exists and has conflicting critical - * fields. Requires an overwrite. - * - * Return value: - * The [Customer][google.cloud.channel.v1.Customer]. - * - * The async variant is {@see self::importCustomerAsync()} . - * - * @param ImportCustomerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Customer - * - * @throws ApiException Thrown if the API call fails. - */ - public function importCustomer(ImportCustomerRequest $request, array $callOptions = []): Customer - { - return $this->startApiCall('ImportCustomer', $request, $callOptions)->wait(); - } - - /** - * List [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink]s - * belonging to a distributor. You must be a distributor to call this method. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The reseller account making the request is different - * from the reseller account in the API request. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * - * Return value: - * The list of the distributor account's - * [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] resources. - * - * The async variant is {@see self::listChannelPartnerLinksAsync()} . - * - * @param ListChannelPartnerLinksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listChannelPartnerLinks(ListChannelPartnerLinksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListChannelPartnerLinks', $request, $callOptions); - } - - /** - * Lists information about how a Reseller modifies their bill before sending - * it to a ChannelPartner. - * - * Possible Error Codes: - * - * * PERMISSION_DENIED: If the account making the request and the account - * being queried are different. - * * NOT_FOUND: The - * [ChannelPartnerRepricingConfig][google.cloud.channel.v1.ChannelPartnerRepricingConfig] - * specified does not exist or is not associated with the given account. - * * INTERNAL: Any non-user error related to technical issues in the - * backend. In this case, contact Cloud Channel support. - * - * Return Value: - * If successful, the - * [ChannelPartnerRepricingConfig][google.cloud.channel.v1.ChannelPartnerRepricingConfig] - * resources. The data for each resource is displayed in the ascending order - * of: - * - * * Channel Partner ID - * * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month] - * * [ChannelPartnerRepricingConfig.update_time][google.cloud.channel.v1.ChannelPartnerRepricingConfig.update_time] - * - * If unsuccessful, returns an error. - * - * The async variant is {@see self::listChannelPartnerRepricingConfigsAsync()} . - * - * @param ListChannelPartnerRepricingConfigsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listChannelPartnerRepricingConfigs(ListChannelPartnerRepricingConfigsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListChannelPartnerRepricingConfigs', $request, $callOptions); - } - - /** - * Lists information about how a Reseller modifies their bill before sending - * it to a Customer. - * - * Possible Error Codes: - * - * * PERMISSION_DENIED: If the account making the request and the account - * being queried are different. - * * NOT_FOUND: The - * [CustomerRepricingConfig][google.cloud.channel.v1.CustomerRepricingConfig] - * specified does not exist or is not associated with the given account. - * * INTERNAL: Any non-user error related to technical issues in the - * backend. In this case, contact Cloud Channel support. - * - * Return Value: - * If successful, the - * [CustomerRepricingConfig][google.cloud.channel.v1.CustomerRepricingConfig] - * resources. The data for each resource is displayed in the ascending order - * of: - * - * * Customer ID - * * [RepricingConfig.EntitlementGranularity.entitlement][google.cloud.channel.v1.RepricingConfig.EntitlementGranularity.entitlement] - * * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month] - * * [CustomerRepricingConfig.update_time][google.cloud.channel.v1.CustomerRepricingConfig.update_time] - * - * If unsuccessful, returns an error. - * - * The async variant is {@see self::listCustomerRepricingConfigsAsync()} . - * - * @param ListCustomerRepricingConfigsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCustomerRepricingConfigs(ListCustomerRepricingConfigsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCustomerRepricingConfigs', $request, $callOptions); - } - - /** - * List [Customer][google.cloud.channel.v1.Customer]s. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The reseller account making the request is different - * from the reseller account in the API request. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * - * Return value: - * List of [Customer][google.cloud.channel.v1.Customer]s, or an empty list if - * there are no customers. - * - * The async variant is {@see self::listCustomersAsync()} . - * - * @param ListCustomersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCustomers(ListCustomersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCustomers', $request, $callOptions); - } - - /** - * List entitlement history. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The reseller account making the request and the - * provided reseller account are different. - * * INVALID_ARGUMENT: Missing or invalid required fields in the request. - * * NOT_FOUND: The parent resource doesn't exist. Usually the result of an - * invalid name parameter. - * * INTERNAL: Any non-user error related to a technical issue in the backend. - * In this case, contact CloudChannel support. - * * UNKNOWN: Any non-user error related to a technical issue in the backend. - * In this case, contact Cloud Channel support. - * - * Return value: - * List of [EntitlementChange][google.cloud.channel.v1.EntitlementChange]s. - * - * The async variant is {@see self::listEntitlementChangesAsync()} . - * - * @param ListEntitlementChangesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listEntitlementChanges(ListEntitlementChangesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListEntitlementChanges', $request, $callOptions); - } - - /** - * Lists [Entitlement][google.cloud.channel.v1.Entitlement]s belonging to a - * customer. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The customer doesn't belong to the reseller. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * - * Return value: - * A list of the customer's - * [Entitlement][google.cloud.channel.v1.Entitlement]s. - * - * The async variant is {@see self::listEntitlementsAsync()} . - * - * @param ListEntitlementsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listEntitlements(ListEntitlementsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListEntitlements', $request, $callOptions); - } - - /** - * Lists the Offers the reseller can sell. - * - * Possible error codes: - * - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * - * The async variant is {@see self::listOffersAsync()} . - * - * @param ListOffersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listOffers(ListOffersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListOffers', $request, $callOptions); - } - - /** - * Lists the Products the reseller is authorized to sell. - * - * Possible error codes: - * - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * - * The async variant is {@see self::listProductsAsync()} . - * - * @param ListProductsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listProducts(ListProductsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListProducts', $request, $callOptions); - } - - /** - * Lists the following: - * - * * Offers that you can purchase for a customer. - * * Offers that you can change for an entitlement. - * - * Possible error codes: - * - * * PERMISSION_DENIED: - * * The customer doesn't belong to the reseller - * * The reseller is not authorized to transact on this Product. See - * https://support.google.com/channelservices/answer/9759265 - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * - * The async variant is {@see self::listPurchasableOffersAsync()} . - * - * @param ListPurchasableOffersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPurchasableOffers(ListPurchasableOffersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPurchasableOffers', $request, $callOptions); - } - - /** - * Lists the following: - * - * * SKUs that you can purchase for a customer - * * SKUs that you can upgrade or downgrade for an entitlement. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The customer doesn't belong to the reseller. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * - * The async variant is {@see self::listPurchasableSkusAsync()} . - * - * @param ListPurchasableSkusRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPurchasableSkus(ListPurchasableSkusRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPurchasableSkus', $request, $callOptions); - } - - /** - * Lists the Billable SKUs in a given SKU group. - * - * Possible error codes: - * PERMISSION_DENIED: If the account making the request and the account - * being queried for are different, or the account doesn't exist. - * INVALID_ARGUMENT: Missing or invalid required parameters in the - * request. - * INTERNAL: Any non-user error related to technical issue in the - * backend. In this case, contact cloud channel support. - * - * Return Value: - * If successful, the [BillableSku][google.cloud.channel.v1.BillableSku] - * resources. The data for each resource is displayed in the ascending order - * of: - * - * * [BillableSku.service_display_name][google.cloud.channel.v1.BillableSku.service_display_name] - * * [BillableSku.sku_display_name][google.cloud.channel.v1.BillableSku.sku_display_name] - * - * If unsuccessful, returns an error. - * - * The async variant is {@see self::listSkuGroupBillableSkusAsync()} . - * - * @param ListSkuGroupBillableSkusRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSkuGroupBillableSkus(ListSkuGroupBillableSkusRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSkuGroupBillableSkus', $request, $callOptions); - } - - /** - * Lists the Rebilling supported SKU groups the account is authorized to - * sell. - * Reference: https://cloud.google.com/skus/sku-groups - * - * Possible Error Codes: - * - * * PERMISSION_DENIED: If the account making the request and the account - * being queried are different, or the account doesn't exist. - * * INTERNAL: Any non-user error related to technical issues in the - * backend. In this case, contact Cloud Channel support. - * - * Return Value: - * If successful, the [SkuGroup][google.cloud.channel.v1.SkuGroup] resources. - * The data for each resource is displayed in the alphabetical order of SKU - * group display name. - * The data for each resource is displayed in the ascending order of - * [SkuGroup.display_name][google.cloud.channel.v1.SkuGroup.display_name] - * - * If unsuccessful, returns an error. - * - * The async variant is {@see self::listSkuGroupsAsync()} . - * - * @param ListSkuGroupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSkuGroups(ListSkuGroupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSkuGroups', $request, $callOptions); - } - - /** - * Lists the SKUs for a product the reseller is authorized to sell. - * - * Possible error codes: - * - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * - * The async variant is {@see self::listSkusAsync()} . - * - * @param ListSkusRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSkus(ListSkusRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSkus', $request, $callOptions); - } - - /** - * Lists service accounts with subscriber privileges on the Cloud Pub/Sub - * topic created for this Channel Services account. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The reseller account making the request and the - * provided reseller account are different, or the impersonated user - * is not a super admin. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * * NOT_FOUND: The topic resource doesn't exist. - * * INTERNAL: Any non-user error related to a technical issue in the - * backend. Contact Cloud Channel support. - * * UNKNOWN: Any non-user error related to a technical issue in the backend. - * Contact Cloud Channel support. - * - * Return value: - * A list of service email addresses. - * - * The async variant is {@see self::listSubscribersAsync()} . - * - * @param ListSubscribersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSubscribers(ListSubscribersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSubscribers', $request, $callOptions); - } - - /** - * List [TransferableOffer][google.cloud.channel.v1.TransferableOffer]s of a - * customer based on Cloud Identity ID or Customer Name in the request. - * - * Use this method when a reseller gets the entitlement information of an - * unowned customer. The reseller should provide the customer's - * Cloud Identity ID or Customer Name. - * - * Possible error codes: - * - * * PERMISSION_DENIED: - * * The customer doesn't belong to the reseller and has no auth token. - * * The customer provided incorrect reseller information when generating - * auth token. - * * The reseller account making the request is different - * from the reseller account in the query. - * * The reseller is not authorized to transact on this Product. See - * https://support.google.com/channelservices/answer/9759265 - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * - * Return value: - * List of [TransferableOffer][google.cloud.channel.v1.TransferableOffer] for - * the given customer and SKU. - * - * The async variant is {@see self::listTransferableOffersAsync()} . - * - * @param ListTransferableOffersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTransferableOffers(ListTransferableOffersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTransferableOffers', $request, $callOptions); - } - - /** - * List [TransferableSku][google.cloud.channel.v1.TransferableSku]s of a - * customer based on the Cloud Identity ID or Customer Name in the request. - * - * Use this method to list the entitlements information of an - * unowned customer. You should provide the customer's - * Cloud Identity ID or Customer Name. - * - * Possible error codes: - * - * * PERMISSION_DENIED: - * * The customer doesn't belong to the reseller and has no auth token. - * * The supplied auth token is invalid. - * * The reseller account making the request is different - * from the reseller account in the query. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * - * Return value: - * A list of the customer's - * [TransferableSku][google.cloud.channel.v1.TransferableSku]. - * - * The async variant is {@see self::listTransferableSkusAsync()} . - * - * @param ListTransferableSkusRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTransferableSkus(ListTransferableSkusRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTransferableSkus', $request, $callOptions); - } - - /** - * Returns the requested [Offer][google.cloud.channel.v1.Offer] resource. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The entitlement doesn't belong to the reseller. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * * NOT_FOUND: Entitlement or offer was not found. - * - * Return value: - * The [Offer][google.cloud.channel.v1.Offer] resource. - * - * The async variant is {@see self::lookupOfferAsync()} . - * - * @param LookupOfferRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Offer - * - * @throws ApiException Thrown if the API call fails. - */ - public function lookupOffer(LookupOfferRequest $request, array $callOptions = []): Offer - { - return $this->startApiCall('LookupOffer', $request, $callOptions)->wait(); - } - - /** - * Creates a Cloud Identity for the given customer using the customer's - * information, or the information provided here. - * - * Possible error codes: - * - * * PERMISSION_DENIED: - * * The customer doesn't belong to the reseller. - * * You are not authorized to provision cloud identity id. See - * https://support.google.com/channelservices/answer/9759265 - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * * NOT_FOUND: The customer was not found. - * * ALREADY_EXISTS: The customer's primary email already exists. Retry - * after changing the customer's primary contact email. - * * INTERNAL: Any non-user error related to a technical issue in the - * backend. Contact Cloud Channel support. - * * UNKNOWN: Any non-user error related to a technical issue in the backend. - * Contact Cloud Channel support. - * - * Return value: - * The ID of a long-running operation. - * - * To get the results of the operation, call the GetOperation method of - * CloudChannelOperationsService. The Operation metadata contains an - * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - * - * The async variant is {@see self::provisionCloudIdentityAsync()} . - * - * @param ProvisionCloudIdentityRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function provisionCloudIdentity(ProvisionCloudIdentityRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ProvisionCloudIdentity', $request, $callOptions)->wait(); - } - - /** - * Lists the billing accounts that are eligible to purchase particular SKUs - * for a given customer. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The customer doesn't belong to the reseller. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * - * Return value: - * Based on the provided list of SKUs, returns a list of SKU groups that must - * be purchased using the same billing account and the billing accounts - * eligible to purchase each SKU group. - * - * The async variant is {@see self::queryEligibleBillingAccountsAsync()} . - * - * @param QueryEligibleBillingAccountsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 QueryEligibleBillingAccountsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function queryEligibleBillingAccounts(QueryEligibleBillingAccountsRequest $request, array $callOptions = []): QueryEligibleBillingAccountsResponse - { - return $this->startApiCall('QueryEligibleBillingAccounts', $request, $callOptions)->wait(); - } - - /** - * Registers a service account with subscriber privileges on the Cloud Pub/Sub - * topic for this Channel Services account. After you create a - * subscriber, you get the events through - * [SubscriberEvent][google.cloud.channel.v1.SubscriberEvent] - * - * Possible error codes: - * - * * PERMISSION_DENIED: The reseller account making the request and the - * provided reseller account are different, or the impersonated user - * is not a super admin. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * * INTERNAL: Any non-user error related to a technical issue in the - * backend. Contact Cloud Channel support. - * * UNKNOWN: Any non-user error related to a technical issue in the backend. - * Contact Cloud Channel support. - * - * Return value: - * The topic name with the registered service email address. - * - * The async variant is {@see self::registerSubscriberAsync()} . - * - * @param RegisterSubscriberRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RegisterSubscriberResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function registerSubscriber(RegisterSubscriberRequest $request, array $callOptions = []): RegisterSubscriberResponse - { - return $this->startApiCall('RegisterSubscriber', $request, $callOptions)->wait(); - } - - /** - * Starts paid service for a trial entitlement. - * - * Starts paid service for a trial entitlement immediately. This method is - * only applicable if a plan is set up for a trial entitlement but has some - * trial days remaining. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The customer doesn't belong to the reseller. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * * NOT_FOUND: Entitlement resource not found. - * * FAILED_PRECONDITION/NOT_IN_TRIAL: This method only works for - * entitlement on trial plans. - * * INTERNAL: Any non-user error related to a technical issue in the - * backend. Contact Cloud Channel support. - * * UNKNOWN: Any non-user error related to a technical issue in the backend. - * Contact Cloud Channel support. - * - * Return value: - * The ID of a long-running operation. - * - * To get the results of the operation, call the GetOperation method of - * CloudChannelOperationsService. The Operation metadata will contain an - * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - * - * The async variant is {@see self::startPaidServiceAsync()} . - * - * @param StartPaidServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function startPaidService(StartPaidServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StartPaidService', $request, $callOptions)->wait(); - } - - /** - * Suspends a previously fulfilled entitlement. - * - * An entitlement suspension is a long-running operation. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The customer doesn't belong to the reseller. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * * NOT_FOUND: Entitlement resource not found. - * * NOT_ACTIVE: Entitlement is not active. - * * INTERNAL: Any non-user error related to a technical issue in the - * backend. Contact Cloud Channel support. - * * UNKNOWN: Any non-user error related to a technical issue in the backend. - * Contact Cloud Channel support. - * - * Return value: - * The ID of a long-running operation. - * - * To get the results of the operation, call the GetOperation method of - * CloudChannelOperationsService. The Operation metadata will contain an - * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - * - * The async variant is {@see self::suspendEntitlementAsync()} . - * - * @param SuspendEntitlementRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function suspendEntitlement(SuspendEntitlementRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SuspendEntitlement', $request, $callOptions)->wait(); - } - - /** - * Transfers customer entitlements to new reseller. - * - * Possible error codes: - * - * * PERMISSION_DENIED: - * * The customer doesn't belong to the reseller. - * * The reseller is not authorized to transact on this Product. See - * https://support.google.com/channelservices/answer/9759265 - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * * NOT_FOUND: The customer or offer resource was not found. - * * ALREADY_EXISTS: The SKU was already transferred for the customer. - * * CONDITION_NOT_MET or FAILED_PRECONDITION: - * * The SKU requires domain verification to transfer, but the domain is - * not verified. - * * An Add-On SKU (example, Vault or Drive) is missing the - * pre-requisite SKU (example, G Suite Basic). - * * (Developer accounts only) Reseller and resold domain must meet the - * following naming requirements: - * * Domain names must start with goog-test. - * * Domain names must include the reseller domain. - * * Specify all transferring entitlements. - * * INTERNAL: Any non-user error related to a technical issue in the - * backend. Contact Cloud Channel support. - * * UNKNOWN: Any non-user error related to a technical issue in the backend. - * Contact Cloud Channel support. - * - * Return value: - * The ID of a long-running operation. - * - * To get the results of the operation, call the GetOperation method of - * CloudChannelOperationsService. The Operation metadata will contain an - * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - * - * The async variant is {@see self::transferEntitlementsAsync()} . - * - * @param TransferEntitlementsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function transferEntitlements(TransferEntitlementsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('TransferEntitlements', $request, $callOptions)->wait(); - } - - /** - * Transfers customer entitlements from their current reseller to Google. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The customer doesn't belong to the reseller. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * * NOT_FOUND: The customer or offer resource was not found. - * * ALREADY_EXISTS: The SKU was already transferred for the customer. - * * CONDITION_NOT_MET or FAILED_PRECONDITION: - * * The SKU requires domain verification to transfer, but the domain is - * not verified. - * * An Add-On SKU (example, Vault or Drive) is missing the - * pre-requisite SKU (example, G Suite Basic). - * * (Developer accounts only) Reseller and resold domain must meet the - * following naming requirements: - * * Domain names must start with goog-test. - * * Domain names must include the reseller domain. - * * INTERNAL: Any non-user error related to a technical issue in the - * backend. Contact Cloud Channel support. - * * UNKNOWN: Any non-user error related to a technical issue in the backend. - * Contact Cloud Channel support. - * - * Return value: - * The ID of a long-running operation. - * - * To get the results of the operation, call the GetOperation method of - * CloudChannelOperationsService. The response will contain - * google.protobuf.Empty on success. The Operation metadata will contain an - * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. - * - * The async variant is {@see self::transferEntitlementsToGoogleAsync()} . - * - * @param TransferEntitlementsToGoogleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function transferEntitlementsToGoogle(TransferEntitlementsToGoogleRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('TransferEntitlementsToGoogle', $request, $callOptions)->wait(); - } - - /** - * Unregisters a service account with subscriber privileges on the Cloud - * Pub/Sub topic created for this Channel Services account. If there are no - * service accounts left with subscriber privileges, this deletes the topic. - * You can call ListSubscribers to check for these accounts. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The reseller account making the request and the - * provided reseller account are different, or the impersonated user - * is not a super admin. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * * NOT_FOUND: The topic resource doesn't exist. - * * INTERNAL: Any non-user error related to a technical issue in the - * backend. Contact Cloud Channel support. - * * UNKNOWN: Any non-user error related to a technical issue in the backend. - * Contact Cloud Channel support. - * - * Return value: - * The topic name that unregistered the service email address. - * Returns a success response if the service email address wasn't registered - * with the topic. - * - * The async variant is {@see self::unregisterSubscriberAsync()} . - * - * @param UnregisterSubscriberRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 UnregisterSubscriberResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function unregisterSubscriber(UnregisterSubscriberRequest $request, array $callOptions = []): UnregisterSubscriberResponse - { - return $this->startApiCall('UnregisterSubscriber', $request, $callOptions)->wait(); - } - - /** - * Updates a channel partner link. Distributors call this method to change a - * link's status. For example, to suspend a partner link. - * You must be a distributor to call this method. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The reseller account making the request is different - * from the reseller account in the API request. - * * INVALID_ARGUMENT: - * * Required request parameters are missing or invalid. - * * Link state cannot change from invited to active or suspended. - * * Cannot send reseller_cloud_identity_id, invite_url, or name in update - * mask. - * * NOT_FOUND: ChannelPartnerLink resource not found. - * * INTERNAL: Any non-user error related to a technical issue in the - * backend. Contact Cloud Channel support. - * * UNKNOWN: Any non-user error related to a technical issue in the backend. - * Contact Cloud Channel support. - * - * Return value: - * The updated - * [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] resource. - * - * The async variant is {@see self::updateChannelPartnerLinkAsync()} . - * - * @param UpdateChannelPartnerLinkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ChannelPartnerLink - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateChannelPartnerLink(UpdateChannelPartnerLinkRequest $request, array $callOptions = []): ChannelPartnerLink - { - return $this->startApiCall('UpdateChannelPartnerLink', $request, $callOptions)->wait(); - } - - /** - * Updates a ChannelPartnerRepricingConfig. Call this method to set - * modifications for a specific ChannelPartner's bill. This method overwrites - * the existing CustomerRepricingConfig. - * - * You can only update configs if the - * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month] - * is a future month. To make changes to configs for the current month, use - * [CreateChannelPartnerRepricingConfig][google.cloud.channel.v1.CloudChannelService.CreateChannelPartnerRepricingConfig], - * taking note of its restrictions. You cannot update the - * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month]. - * - * When updating a config in the future: - * - * * This config must already exist. - * - * Possible Error Codes: - * - * * PERMISSION_DENIED: If the account making the request and the account - * being queried are different. - * * INVALID_ARGUMENT: Missing or invalid required parameters in the - * request. Also displays if the updated config is for the current month or - * past months. - * * NOT_FOUND: The - * [ChannelPartnerRepricingConfig][google.cloud.channel.v1.ChannelPartnerRepricingConfig] - * specified does not exist or is not associated with the given account. - * * INTERNAL: Any non-user error related to technical issues in the - * backend. In this case, contact Cloud Channel support. - * - * Return Value: - * If successful, the updated - * [ChannelPartnerRepricingConfig][google.cloud.channel.v1.ChannelPartnerRepricingConfig] - * resource, otherwise returns an error. - * - * The async variant is {@see self::updateChannelPartnerRepricingConfigAsync()} . - * - * @param UpdateChannelPartnerRepricingConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ChannelPartnerRepricingConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateChannelPartnerRepricingConfig(UpdateChannelPartnerRepricingConfigRequest $request, array $callOptions = []): ChannelPartnerRepricingConfig - { - return $this->startApiCall('UpdateChannelPartnerRepricingConfig', $request, $callOptions)->wait(); - } - - /** - * Updates an existing [Customer][google.cloud.channel.v1.Customer] resource - * for the reseller or distributor. - * - * Possible error codes: - * - * * PERMISSION_DENIED: The reseller account making the request is different - * from the reseller account in the API request. - * * INVALID_ARGUMENT: Required request parameters are missing or invalid. - * * NOT_FOUND: No [Customer][google.cloud.channel.v1.Customer] resource found - * for the name in the request. - * - * Return value: - * The updated [Customer][google.cloud.channel.v1.Customer] resource. - * - * The async variant is {@see self::updateCustomerAsync()} . - * - * @param UpdateCustomerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Customer - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCustomer(UpdateCustomerRequest $request, array $callOptions = []): Customer - { - return $this->startApiCall('UpdateCustomer', $request, $callOptions)->wait(); - } - - /** - * Updates a CustomerRepricingConfig. Call this method to set modifications - * for a specific customer's bill. This method overwrites the existing - * CustomerRepricingConfig. - * - * You can only update configs if the - * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month] - * is a future month. To make changes to configs for the current month, use - * [CreateCustomerRepricingConfig][google.cloud.channel.v1.CloudChannelService.CreateCustomerRepricingConfig], - * taking note of its restrictions. You cannot update the - * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month]. - * - * When updating a config in the future: - * - * * This config must already exist. - * - * Possible Error Codes: - * - * * PERMISSION_DENIED: If the account making the request and the account - * being queried are different. - * * INVALID_ARGUMENT: Missing or invalid required parameters in the - * request. Also displays if the updated config is for the current month or - * past months. - * * NOT_FOUND: The - * [CustomerRepricingConfig][google.cloud.channel.v1.CustomerRepricingConfig] - * specified does not exist or is not associated with the given account. - * * INTERNAL: Any non-user error related to technical issues in the - * backend. In this case, contact Cloud Channel support. - * - * Return Value: - * If successful, the updated - * [CustomerRepricingConfig][google.cloud.channel.v1.CustomerRepricingConfig] - * resource, otherwise returns an error. - * - * The async variant is {@see self::updateCustomerRepricingConfigAsync()} . - * - * @param UpdateCustomerRepricingConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CustomerRepricingConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCustomerRepricingConfig(UpdateCustomerRepricingConfigRequest $request, array $callOptions = []): CustomerRepricingConfig - { - return $this->startApiCall('UpdateCustomerRepricingConfig', $request, $callOptions)->wait(); - } -} diff --git a/Channel/src/V1/Client/CloudChannelReportsServiceClient.php b/Channel/src/V1/Client/CloudChannelReportsServiceClient.php index 0f254cc499c7..7bfb6ef09856 100644 --- a/Channel/src/V1/Client/CloudChannelReportsServiceClient.php +++ b/Channel/src/V1/Client/CloudChannelReportsServiceClient.php @@ -24,17 +24,349 @@ namespace Google\Cloud\Channel\V1\Client; -use Google\Cloud\Channel\V1\Client\BaseClient\CloudChannelReportsServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Channel\V1\FetchReportResultsRequest; +use Google\Cloud\Channel\V1\ListReportsRequest; +use Google\Cloud\Channel\V1\OperationMetadata; +use Google\Cloud\Channel\V1\RunReportJobRequest; +use Google\Cloud\Channel\V1\RunReportJobResponse; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: CloudChannelReportsService lets Google Cloud resellers and + * distributors retrieve and combine a variety of data in Cloud Channel for + * multiple products (Google Cloud, Google Voice, and Google Workspace.) * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Channel\V1\CloudChannelReportsServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface fetchReportResultsAsync(FetchReportResultsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listReportsAsync(ListReportsRequest $request, array $optionalArgs = []) + * @method PromiseInterface runReportJobAsync(RunReportJobRequest $request, array $optionalArgs = []) */ -final class CloudChannelReportsServiceClient extends CloudChannelReportsServiceBaseClient +final class CloudChannelReportsServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CloudChannelReportsServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.channel.v1.CloudChannelReportsService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudchannel.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/apps.reports.usage.readonly', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/cloud_channel_reports_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/cloud_channel_reports_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/cloud_channel_reports_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/cloud_channel_reports_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a report + * resource. + * + * @param string $account + * @param string $report + * + * @return string The formatted report resource. + */ + public static function reportName(string $account, string $report): string + { + return self::getPathTemplate('report')->render([ + 'account' => $account, + 'report' => $report, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a report_job + * resource. + * + * @param string $account + * @param string $reportJob + * + * @return string The formatted report_job resource. + */ + public static function reportJobName(string $account, string $reportJob): string + { + return self::getPathTemplate('reportJob')->render([ + 'account' => $account, + 'report_job' => $reportJob, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - report: accounts/{account}/reports/{report} + * - reportJob: accounts/{account}/reportJobs/{report_job} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudchannel.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves data generated by + * [CloudChannelReportsService.RunReportJob][google.cloud.channel.v1.CloudChannelReportsService.RunReportJob]. + * + * The async variant is + * {@see CloudChannelReportsServiceClient::fetchReportResultsAsync()} . + * + * @param FetchReportResultsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function fetchReportResults(FetchReportResultsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('FetchReportResults', $request, $callOptions); + } + + /** + * Lists the reports that RunReportJob can run. These reports include an ID, + * a description, and the list of columns that will be in the result. + * + * The async variant is {@see CloudChannelReportsServiceClient::listReportsAsync()} + * . + * + * @param ListReportsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listReports(ListReportsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListReports', $request, $callOptions); + } + + /** + * Begins generation of data for a given report. The report + * identifier is a UID (for example, `613bf59q`). + * + * Possible error codes: + * + * * PERMISSION_DENIED: The user doesn't have access to this report. + * * INVALID_ARGUMENT: Required request parameters are missing + * or invalid. + * * NOT_FOUND: The report identifier was not found. + * * INTERNAL: Any non-user error related to a technical issue + * in the backend. Contact Cloud Channel support. + * * UNKNOWN: Any non-user error related to a technical issue + * in the backend. Contact Cloud Channel support. + * + * Return value: + * The ID of a long-running operation. + * + * To get the results of the operation, call the GetOperation method of + * CloudChannelOperationsService. The Operation metadata contains an + * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + * + * To get the results of report generation, call + * [CloudChannelReportsService.FetchReportResults][google.cloud.channel.v1.CloudChannelReportsService.FetchReportResults] + * with the + * [RunReportJobResponse.report_job][google.cloud.channel.v1.RunReportJobResponse.report_job]. + * + * The async variant is + * {@see CloudChannelReportsServiceClient::runReportJobAsync()} . + * + * @param RunReportJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function runReportJob(RunReportJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RunReportJob', $request, $callOptions)->wait(); + } } diff --git a/Channel/src/V1/Client/CloudChannelServiceClient.php b/Channel/src/V1/Client/CloudChannelServiceClient.php index 7aa7552b61b7..aae34b68741f 100644 --- a/Channel/src/V1/Client/CloudChannelServiceClient.php +++ b/Channel/src/V1/Client/CloudChannelServiceClient.php @@ -24,17 +24,2592 @@ namespace Google\Cloud\Channel\V1\Client; -use Google\Cloud\Channel\V1\Client\BaseClient\CloudChannelServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Channel\V1\ActivateEntitlementRequest; +use Google\Cloud\Channel\V1\CancelEntitlementRequest; +use Google\Cloud\Channel\V1\ChangeOfferRequest; +use Google\Cloud\Channel\V1\ChangeParametersRequest; +use Google\Cloud\Channel\V1\ChangeRenewalSettingsRequest; +use Google\Cloud\Channel\V1\ChannelPartnerLink; +use Google\Cloud\Channel\V1\ChannelPartnerRepricingConfig; +use Google\Cloud\Channel\V1\CheckCloudIdentityAccountsExistRequest; +use Google\Cloud\Channel\V1\CheckCloudIdentityAccountsExistResponse; +use Google\Cloud\Channel\V1\CreateChannelPartnerLinkRequest; +use Google\Cloud\Channel\V1\CreateChannelPartnerRepricingConfigRequest; +use Google\Cloud\Channel\V1\CreateCustomerRepricingConfigRequest; +use Google\Cloud\Channel\V1\CreateCustomerRequest; +use Google\Cloud\Channel\V1\CreateEntitlementRequest; +use Google\Cloud\Channel\V1\Customer; +use Google\Cloud\Channel\V1\CustomerRepricingConfig; +use Google\Cloud\Channel\V1\DeleteChannelPartnerRepricingConfigRequest; +use Google\Cloud\Channel\V1\DeleteCustomerRepricingConfigRequest; +use Google\Cloud\Channel\V1\DeleteCustomerRequest; +use Google\Cloud\Channel\V1\Entitlement; +use Google\Cloud\Channel\V1\GetChannelPartnerLinkRequest; +use Google\Cloud\Channel\V1\GetChannelPartnerRepricingConfigRequest; +use Google\Cloud\Channel\V1\GetCustomerRepricingConfigRequest; +use Google\Cloud\Channel\V1\GetCustomerRequest; +use Google\Cloud\Channel\V1\GetEntitlementRequest; +use Google\Cloud\Channel\V1\ImportCustomerRequest; +use Google\Cloud\Channel\V1\ListChannelPartnerLinksRequest; +use Google\Cloud\Channel\V1\ListChannelPartnerRepricingConfigsRequest; +use Google\Cloud\Channel\V1\ListCustomerRepricingConfigsRequest; +use Google\Cloud\Channel\V1\ListCustomersRequest; +use Google\Cloud\Channel\V1\ListEntitlementChangesRequest; +use Google\Cloud\Channel\V1\ListEntitlementsRequest; +use Google\Cloud\Channel\V1\ListOffersRequest; +use Google\Cloud\Channel\V1\ListProductsRequest; +use Google\Cloud\Channel\V1\ListPurchasableOffersRequest; +use Google\Cloud\Channel\V1\ListPurchasableSkusRequest; +use Google\Cloud\Channel\V1\ListSkuGroupBillableSkusRequest; +use Google\Cloud\Channel\V1\ListSkuGroupsRequest; +use Google\Cloud\Channel\V1\ListSkusRequest; +use Google\Cloud\Channel\V1\ListSubscribersRequest; +use Google\Cloud\Channel\V1\ListTransferableOffersRequest; +use Google\Cloud\Channel\V1\ListTransferableSkusRequest; +use Google\Cloud\Channel\V1\LookupOfferRequest; +use Google\Cloud\Channel\V1\Offer; +use Google\Cloud\Channel\V1\OperationMetadata; +use Google\Cloud\Channel\V1\Parameter; +use Google\Cloud\Channel\V1\ProvisionCloudIdentityRequest; +use Google\Cloud\Channel\V1\QueryEligibleBillingAccountsRequest; +use Google\Cloud\Channel\V1\QueryEligibleBillingAccountsResponse; +use Google\Cloud\Channel\V1\RegisterSubscriberRequest; +use Google\Cloud\Channel\V1\RegisterSubscriberResponse; +use Google\Cloud\Channel\V1\StartPaidServiceRequest; +use Google\Cloud\Channel\V1\SuspendEntitlementRequest; +use Google\Cloud\Channel\V1\TransferEntitlementsRequest; +use Google\Cloud\Channel\V1\TransferEntitlementsToGoogleRequest; +use Google\Cloud\Channel\V1\UnregisterSubscriberRequest; +use Google\Cloud\Channel\V1\UnregisterSubscriberResponse; +use Google\Cloud\Channel\V1\UpdateChannelPartnerLinkRequest; +use Google\Cloud\Channel\V1\UpdateChannelPartnerRepricingConfigRequest; +use Google\Cloud\Channel\V1\UpdateCustomerRepricingConfigRequest; +use Google\Cloud\Channel\V1\UpdateCustomerRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: CloudChannelService lets Google cloud resellers and distributors manage + * their customers, channel partners, entitlements, and reports. * - * This class is currently experimental and may be subject to changes. + * Using this service: + * 1. Resellers and distributors can manage a customer entity. + * 2. Distributors can register an authorized reseller in their channel and + * provide them with delegated admin access. + * 3. Resellers and distributors can manage customer entitlements. + * + * CloudChannelService exposes the following resources: + * - [Customer][google.cloud.channel.v1.Customer]s: An entity-usually an + * enterprise-managed by a reseller or distributor. + * + * - [Entitlement][google.cloud.channel.v1.Entitlement]s: An entity that + * provides a customer with the means to use a service. Entitlements are created + * or updated as a result of a successful fulfillment. + * + * - [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink]s: An + * entity that identifies links between distributors and their indirect + * resellers in a channel. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Channel\V1\CloudChannelServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface activateEntitlementAsync(ActivateEntitlementRequest $request, array $optionalArgs = []) + * @method PromiseInterface cancelEntitlementAsync(CancelEntitlementRequest $request, array $optionalArgs = []) + * @method PromiseInterface changeOfferAsync(ChangeOfferRequest $request, array $optionalArgs = []) + * @method PromiseInterface changeParametersAsync(ChangeParametersRequest $request, array $optionalArgs = []) + * @method PromiseInterface changeRenewalSettingsAsync(ChangeRenewalSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface checkCloudIdentityAccountsExistAsync(CheckCloudIdentityAccountsExistRequest $request, array $optionalArgs = []) + * @method PromiseInterface createChannelPartnerLinkAsync(CreateChannelPartnerLinkRequest $request, array $optionalArgs = []) + * @method PromiseInterface createChannelPartnerRepricingConfigAsync(CreateChannelPartnerRepricingConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface createCustomerAsync(CreateCustomerRequest $request, array $optionalArgs = []) + * @method PromiseInterface createCustomerRepricingConfigAsync(CreateCustomerRepricingConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface createEntitlementAsync(CreateEntitlementRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteChannelPartnerRepricingConfigAsync(DeleteChannelPartnerRepricingConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteCustomerAsync(DeleteCustomerRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteCustomerRepricingConfigAsync(DeleteCustomerRepricingConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getChannelPartnerLinkAsync(GetChannelPartnerLinkRequest $request, array $optionalArgs = []) + * @method PromiseInterface getChannelPartnerRepricingConfigAsync(GetChannelPartnerRepricingConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCustomerAsync(GetCustomerRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCustomerRepricingConfigAsync(GetCustomerRepricingConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEntitlementAsync(GetEntitlementRequest $request, array $optionalArgs = []) + * @method PromiseInterface importCustomerAsync(ImportCustomerRequest $request, array $optionalArgs = []) + * @method PromiseInterface listChannelPartnerLinksAsync(ListChannelPartnerLinksRequest $request, array $optionalArgs = []) + * @method PromiseInterface listChannelPartnerRepricingConfigsAsync(ListChannelPartnerRepricingConfigsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCustomerRepricingConfigsAsync(ListCustomerRepricingConfigsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCustomersAsync(ListCustomersRequest $request, array $optionalArgs = []) + * @method PromiseInterface listEntitlementChangesAsync(ListEntitlementChangesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listEntitlementsAsync(ListEntitlementsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listOffersAsync(ListOffersRequest $request, array $optionalArgs = []) + * @method PromiseInterface listProductsAsync(ListProductsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPurchasableOffersAsync(ListPurchasableOffersRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPurchasableSkusAsync(ListPurchasableSkusRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSkuGroupBillableSkusAsync(ListSkuGroupBillableSkusRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSkuGroupsAsync(ListSkuGroupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSkusAsync(ListSkusRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSubscribersAsync(ListSubscribersRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTransferableOffersAsync(ListTransferableOffersRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTransferableSkusAsync(ListTransferableSkusRequest $request, array $optionalArgs = []) + * @method PromiseInterface lookupOfferAsync(LookupOfferRequest $request, array $optionalArgs = []) + * @method PromiseInterface provisionCloudIdentityAsync(ProvisionCloudIdentityRequest $request, array $optionalArgs = []) + * @method PromiseInterface queryEligibleBillingAccountsAsync(QueryEligibleBillingAccountsRequest $request, array $optionalArgs = []) + * @method PromiseInterface registerSubscriberAsync(RegisterSubscriberRequest $request, array $optionalArgs = []) + * @method PromiseInterface startPaidServiceAsync(StartPaidServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface suspendEntitlementAsync(SuspendEntitlementRequest $request, array $optionalArgs = []) + * @method PromiseInterface transferEntitlementsAsync(TransferEntitlementsRequest $request, array $optionalArgs = []) + * @method PromiseInterface transferEntitlementsToGoogleAsync(TransferEntitlementsToGoogleRequest $request, array $optionalArgs = []) + * @method PromiseInterface unregisterSubscriberAsync(UnregisterSubscriberRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateChannelPartnerLinkAsync(UpdateChannelPartnerLinkRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateChannelPartnerRepricingConfigAsync(UpdateChannelPartnerRepricingConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCustomerAsync(UpdateCustomerRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCustomerRepricingConfigAsync(UpdateCustomerRepricingConfigRequest $request, array $optionalArgs = []) */ -final class CloudChannelServiceClient extends CloudChannelServiceBaseClient +final class CloudChannelServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CloudChannelServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.channel.v1.CloudChannelService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudchannel.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/apps.order', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/cloud_channel_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/cloud_channel_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/cloud_channel_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/cloud_channel_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * channel_partner_link resource. + * + * @param string $account + * @param string $channelPartnerLink + * + * @return string The formatted channel_partner_link resource. + */ + public static function channelPartnerLinkName(string $account, string $channelPartnerLink): string + { + return self::getPathTemplate('channelPartnerLink')->render([ + 'account' => $account, + 'channel_partner_link' => $channelPartnerLink, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * channel_partner_repricing_config resource. + * + * @param string $account + * @param string $channelPartner + * @param string $channelPartnerRepricingConfig + * + * @return string The formatted channel_partner_repricing_config resource. + */ + public static function channelPartnerRepricingConfigName(string $account, string $channelPartner, string $channelPartnerRepricingConfig): string + { + return self::getPathTemplate('channelPartnerRepricingConfig')->render([ + 'account' => $account, + 'channel_partner' => $channelPartner, + 'channel_partner_repricing_config' => $channelPartnerRepricingConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a customer + * resource. + * + * @param string $account + * @param string $customer + * + * @return string The formatted customer resource. + */ + public static function customerName(string $account, string $customer): string + { + return self::getPathTemplate('customer')->render([ + 'account' => $account, + 'customer' => $customer, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * customer_repricing_config resource. + * + * @param string $account + * @param string $customer + * @param string $customerRepricingConfig + * + * @return string The formatted customer_repricing_config resource. + */ + public static function customerRepricingConfigName(string $account, string $customer, string $customerRepricingConfig): string + { + return self::getPathTemplate('customerRepricingConfig')->render([ + 'account' => $account, + 'customer' => $customer, + 'customer_repricing_config' => $customerRepricingConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a entitlement + * resource. + * + * @param string $account + * @param string $customer + * @param string $entitlement + * + * @return string The formatted entitlement resource. + */ + public static function entitlementName(string $account, string $customer, string $entitlement): string + { + return self::getPathTemplate('entitlement')->render([ + 'account' => $account, + 'customer' => $customer, + 'entitlement' => $entitlement, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a offer + * resource. + * + * @param string $account + * @param string $offer + * + * @return string The formatted offer resource. + */ + public static function offerName(string $account, string $offer): string + { + return self::getPathTemplate('offer')->render([ + 'account' => $account, + 'offer' => $offer, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a product + * resource. + * + * @param string $product + * + * @return string The formatted product resource. + */ + public static function productName(string $product): string + { + return self::getPathTemplate('product')->render([ + 'product' => $product, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a sku_group + * resource. + * + * @param string $account + * @param string $skuGroup + * + * @return string The formatted sku_group resource. + */ + public static function skuGroupName(string $account, string $skuGroup): string + { + return self::getPathTemplate('skuGroup')->render([ + 'account' => $account, + 'sku_group' => $skuGroup, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - channelPartnerLink: accounts/{account}/channelPartnerLinks/{channel_partner_link} + * - channelPartnerRepricingConfig: accounts/{account}/channelPartnerLinks/{channel_partner}/channelPartnerRepricingConfigs/{channel_partner_repricing_config} + * - customer: accounts/{account}/customers/{customer} + * - customerRepricingConfig: accounts/{account}/customers/{customer}/customerRepricingConfigs/{customer_repricing_config} + * - entitlement: accounts/{account}/customers/{customer}/entitlements/{entitlement} + * - offer: accounts/{account}/offers/{offer} + * - product: products/{product} + * - skuGroup: accounts/{account}/skuGroups/{sku_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. + */ + public static function parseName(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudchannel.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Activates a previously suspended entitlement. Entitlements suspended for + * pending ToS acceptance can't be activated using this method. + * + * An entitlement activation is a long-running operation and it updates + * the state of the customer entitlement. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The reseller account making the request is different + * from the reseller account in the API request. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * * NOT_FOUND: Entitlement resource not found. + * * SUSPENSION_NOT_RESELLER_INITIATED: Can only activate reseller-initiated + * suspensions and entitlements that have accepted the TOS. + * * NOT_SUSPENDED: Can only activate suspended entitlements not in an ACTIVE + * state. + * * INTERNAL: Any non-user error related to a technical issue in the + * backend. Contact Cloud Channel support. + * * UNKNOWN: Any non-user error related to a technical issue in the backend. + * Contact Cloud Channel support. + * + * Return value: + * The ID of a long-running operation. + * + * To get the results of the operation, call the GetOperation method of + * CloudChannelOperationsService. The Operation metadata will contain an + * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + * + * The async variant is + * {@see CloudChannelServiceClient::activateEntitlementAsync()} . + * + * @param ActivateEntitlementRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function activateEntitlement(ActivateEntitlementRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ActivateEntitlement', $request, $callOptions)->wait(); + } + + /** + * Cancels a previously fulfilled entitlement. + * + * An entitlement cancellation is a long-running operation. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The reseller account making the request is different + * from the reseller account in the API request. + * * FAILED_PRECONDITION: There are Google Cloud projects linked to the + * Google Cloud entitlement's Cloud Billing subaccount. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * * NOT_FOUND: Entitlement resource not found. + * * DELETION_TYPE_NOT_ALLOWED: Cancel is only allowed for Google Workspace + * add-ons, or entitlements for Google Cloud's development platform. + * * INTERNAL: Any non-user error related to a technical issue in the + * backend. Contact Cloud Channel support. + * * UNKNOWN: Any non-user error related to a technical issue in the backend. + * Contact Cloud Channel support. + * + * Return value: + * The ID of a long-running operation. + * + * To get the results of the operation, call the GetOperation method of + * CloudChannelOperationsService. The response will contain + * google.protobuf.Empty on success. The Operation metadata will contain an + * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + * + * The async variant is {@see CloudChannelServiceClient::cancelEntitlementAsync()} + * . + * + * @param CancelEntitlementRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function cancelEntitlement(CancelEntitlementRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CancelEntitlement', $request, $callOptions)->wait(); + } + + /** + * Updates the Offer for an existing customer entitlement. + * + * An entitlement update is a long-running operation and it updates the + * entitlement as a result of fulfillment. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The customer doesn't belong to the reseller. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * * NOT_FOUND: Offer or Entitlement resource not found. + * * INTERNAL: Any non-user error related to a technical issue in the + * backend. Contact Cloud Channel support. + * * UNKNOWN: Any non-user error related to a technical issue in the backend. + * Contact Cloud Channel support. + * + * Return value: + * The ID of a long-running operation. + * + * To get the results of the operation, call the GetOperation method of + * CloudChannelOperationsService. The Operation metadata will contain an + * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + * + * The async variant is {@see CloudChannelServiceClient::changeOfferAsync()} . + * + * @param ChangeOfferRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function changeOffer(ChangeOfferRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ChangeOffer', $request, $callOptions)->wait(); + } + + /** + * Change parameters of the entitlement. + * + * An entitlement update is a long-running operation and it updates the + * entitlement as a result of fulfillment. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The customer doesn't belong to the reseller. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * For example, the number of seats being changed is greater than the allowed + * number of max seats, or decreasing seats for a commitment based plan. + * * NOT_FOUND: Entitlement resource not found. + * * INTERNAL: Any non-user error related to a technical issue in the + * backend. Contact Cloud Channel support. + * * UNKNOWN: Any non-user error related to a technical issue in the backend. + * Contact Cloud Channel support. + * + * Return value: + * The ID of a long-running operation. + * + * To get the results of the operation, call the GetOperation method of + * CloudChannelOperationsService. The Operation metadata will contain an + * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + * + * The async variant is {@see CloudChannelServiceClient::changeParametersAsync()} . + * + * @param ChangeParametersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function changeParameters(ChangeParametersRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ChangeParameters', $request, $callOptions)->wait(); + } + + /** + * Updates the renewal settings for an existing customer entitlement. + * + * An entitlement update is a long-running operation and it updates the + * entitlement as a result of fulfillment. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The customer doesn't belong to the reseller. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * * NOT_FOUND: Entitlement resource not found. + * * NOT_COMMITMENT_PLAN: Renewal Settings are only applicable for a + * commitment plan. Can't enable or disable renewals for non-commitment plans. + * * INTERNAL: Any non-user error related to a technical issue in the + * backend. Contact Cloud Channel support. + * * UNKNOWN: Any non-user error related to a technical issue in the backend. + * Contact Cloud Channel support. + * + * Return value: + * The ID of a long-running operation. + * + * To get the results of the operation, call the GetOperation method of + * CloudChannelOperationsService. The Operation metadata will contain an + * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + * + * The async variant is + * {@see CloudChannelServiceClient::changeRenewalSettingsAsync()} . + * + * @param ChangeRenewalSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function changeRenewalSettings(ChangeRenewalSettingsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ChangeRenewalSettings', $request, $callOptions)->wait(); + } + + /** + * Confirms the existence of Cloud Identity accounts based on the domain and + * if the Cloud Identity accounts are owned by the reseller. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The reseller account making the request is different + * from the reseller account in the API request. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * * INVALID_VALUE: Invalid domain value in the request. + * + * Return value: + * A list of + * [CloudIdentityCustomerAccount][google.cloud.channel.v1.CloudIdentityCustomerAccount] + * resources for the domain (may be empty) + * + * Note: in the v1alpha1 version of the API, a NOT_FOUND error returns if + * no + * [CloudIdentityCustomerAccount][google.cloud.channel.v1.CloudIdentityCustomerAccount] + * resources match the domain. + * + * The async variant is + * {@see CloudChannelServiceClient::checkCloudIdentityAccountsExistAsync()} . + * + * @param CheckCloudIdentityAccountsExistRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CheckCloudIdentityAccountsExistResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function checkCloudIdentityAccountsExist(CheckCloudIdentityAccountsExistRequest $request, array $callOptions = []): CheckCloudIdentityAccountsExistResponse + { + return $this->startApiCall('CheckCloudIdentityAccountsExist', $request, $callOptions)->wait(); + } + + /** + * Initiates a channel partner link between a distributor and a reseller, or + * between resellers in an n-tier reseller channel. + * Invited partners need to follow the invite_link_uri provided in the + * response to accept. After accepting the invitation, a link is set up + * between the two parties. + * You must be a distributor to call this method. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The reseller account making the request is different + * from the reseller account in the API request. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * * ALREADY_EXISTS: The ChannelPartnerLink sent in the request already + * exists. + * * NOT_FOUND: No Cloud Identity customer exists for provided domain. + * * INTERNAL: Any non-user error related to a technical issue in the + * backend. Contact Cloud Channel support. + * * UNKNOWN: Any non-user error related to a technical issue in the backend. + * Contact Cloud Channel support. + * + * Return value: + * The new [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + * resource. + * + * The async variant is + * {@see CloudChannelServiceClient::createChannelPartnerLinkAsync()} . + * + * @param CreateChannelPartnerLinkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ChannelPartnerLink + * + * @throws ApiException Thrown if the API call fails. + */ + public function createChannelPartnerLink(CreateChannelPartnerLinkRequest $request, array $callOptions = []): ChannelPartnerLink + { + return $this->startApiCall('CreateChannelPartnerLink', $request, $callOptions)->wait(); + } + + /** + * Creates a ChannelPartnerRepricingConfig. Call this method to set + * modifications for a specific ChannelPartner's bill. You can only create + * configs if the + * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month] + * is a future month. If needed, you can create a config for the current + * month, with some restrictions. + * + * When creating a config for a future month, make sure there are no existing + * configs for that + * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month]. + * + * The following restrictions are for creating configs in the current month. + * + * * This functionality is reserved for recovering from an erroneous config, + * and should not be used for regular business cases. + * * The new config will not modify exports used with other configs. + * Changes to the config may be immediate, but may take up to 24 hours. + * * There is a limit of ten configs for any ChannelPartner or + * [RepricingConfig.EntitlementGranularity.entitlement][google.cloud.channel.v1.RepricingConfig.EntitlementGranularity.entitlement], + * for any + * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month]. + * * The contained + * [ChannelPartnerRepricingConfig.repricing_config][google.cloud.channel.v1.ChannelPartnerRepricingConfig.repricing_config] + * value must be different from the value used in the current config for a + * ChannelPartner. + * + * Possible Error Codes: + * + * * PERMISSION_DENIED: If the account making the request and the account + * being queried are different. + * * INVALID_ARGUMENT: Missing or invalid required parameters in the + * request. Also displays if the updated config is for the current month or + * past months. + * * NOT_FOUND: The + * [ChannelPartnerRepricingConfig][google.cloud.channel.v1.ChannelPartnerRepricingConfig] + * specified does not exist or is not associated with the given account. + * * INTERNAL: Any non-user error related to technical issues in the + * backend. In this case, contact Cloud Channel support. + * + * Return Value: + * If successful, the updated + * [ChannelPartnerRepricingConfig][google.cloud.channel.v1.ChannelPartnerRepricingConfig] + * resource, otherwise returns an error. + * + * The async variant is + * {@see CloudChannelServiceClient::createChannelPartnerRepricingConfigAsync()} . + * + * @param CreateChannelPartnerRepricingConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ChannelPartnerRepricingConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function createChannelPartnerRepricingConfig(CreateChannelPartnerRepricingConfigRequest $request, array $callOptions = []): ChannelPartnerRepricingConfig + { + return $this->startApiCall('CreateChannelPartnerRepricingConfig', $request, $callOptions)->wait(); + } + + /** + * Creates a new [Customer][google.cloud.channel.v1.Customer] resource under + * the reseller or distributor account. + * + * Possible error codes: + * + * * PERMISSION_DENIED: + * * The reseller account making the request is different from the + * reseller account in the API request. + * * You are not authorized to create a customer. See + * https://support.google.com/channelservices/answer/9759265 + * * INVALID_ARGUMENT: + * * Required request parameters are missing or invalid. + * * Domain field value doesn't match the primary email domain. + * + * Return value: + * The newly created [Customer][google.cloud.channel.v1.Customer] resource. + * + * The async variant is {@see CloudChannelServiceClient::createCustomerAsync()} . + * + * @param CreateCustomerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Customer + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCustomer(CreateCustomerRequest $request, array $callOptions = []): Customer + { + return $this->startApiCall('CreateCustomer', $request, $callOptions)->wait(); + } + + /** + * Creates a CustomerRepricingConfig. Call this method to set modifications + * for a specific customer's bill. You can only create configs if the + * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month] + * is a future month. If needed, you can create a config for the current + * month, with some restrictions. + * + * When creating a config for a future month, make sure there are no existing + * configs for that + * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month]. + * + * The following restrictions are for creating configs in the current month. + * + * * This functionality is reserved for recovering from an erroneous config, + * and should not be used for regular business cases. + * * The new config will not modify exports used with other configs. + * Changes to the config may be immediate, but may take up to 24 hours. + * * There is a limit of ten configs for any + * [RepricingConfig.EntitlementGranularity.entitlement][google.cloud.channel.v1.RepricingConfig.EntitlementGranularity.entitlement], + * for any + * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month]. + * * The contained + * [CustomerRepricingConfig.repricing_config][google.cloud.channel.v1.CustomerRepricingConfig.repricing_config] + * value must be different from the value used in the current config for a + * [RepricingConfig.EntitlementGranularity.entitlement][google.cloud.channel.v1.RepricingConfig.EntitlementGranularity.entitlement]. + * + * Possible Error Codes: + * + * * PERMISSION_DENIED: If the account making the request and the account + * being queried are different. + * * INVALID_ARGUMENT: Missing or invalid required parameters in the + * request. Also displays if the updated config is for the current month or + * past months. + * * NOT_FOUND: The + * [CustomerRepricingConfig][google.cloud.channel.v1.CustomerRepricingConfig] + * specified does not exist or is not associated with the given account. + * * INTERNAL: Any non-user error related to technical issues in the + * backend. In this case, contact Cloud Channel support. + * + * Return Value: + * If successful, the updated + * [CustomerRepricingConfig][google.cloud.channel.v1.CustomerRepricingConfig] + * resource, otherwise returns an error. + * + * The async variant is + * {@see CloudChannelServiceClient::createCustomerRepricingConfigAsync()} . + * + * @param CreateCustomerRepricingConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CustomerRepricingConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCustomerRepricingConfig(CreateCustomerRepricingConfigRequest $request, array $callOptions = []): CustomerRepricingConfig + { + return $this->startApiCall('CreateCustomerRepricingConfig', $request, $callOptions)->wait(); + } + + /** + * Creates an entitlement for a customer. + * + * Possible error codes: + * + * * PERMISSION_DENIED: + * * The customer doesn't belong to the reseller. + * * The reseller is not authorized to transact on this Product. See + * https://support.google.com/channelservices/answer/9759265 + * * INVALID_ARGUMENT: + * * Required request parameters are missing or invalid. + * * There is already a customer entitlement for a SKU from the same + * product family. + * * INVALID_VALUE: Make sure the OfferId is valid. If it is, contact + * Google Channel support for further troubleshooting. + * * NOT_FOUND: The customer or offer resource was not found. + * * ALREADY_EXISTS: + * * The SKU was already purchased for the customer. + * * The customer's primary email already exists. Retry + * after changing the customer's primary contact email. + * * CONDITION_NOT_MET or FAILED_PRECONDITION: + * * The domain required for purchasing a SKU has not been verified. + * * A pre-requisite SKU required to purchase an Add-On SKU is missing. + * For example, Google Workspace Business Starter is required to purchase + * Vault or Drive. + * * (Developer accounts only) Reseller and resold domain must meet the + * following naming requirements: + * * Domain names must start with goog-test. + * * Domain names must include the reseller domain. + * * INTERNAL: Any non-user error related to a technical issue in the + * backend. Contact Cloud Channel support. + * * UNKNOWN: Any non-user error related to a technical issue in the backend. + * Contact Cloud Channel support. + * + * Return value: + * The ID of a long-running operation. + * + * To get the results of the operation, call the GetOperation method of + * CloudChannelOperationsService. The Operation metadata will contain an + * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + * + * The async variant is {@see CloudChannelServiceClient::createEntitlementAsync()} + * . + * + * @param CreateEntitlementRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createEntitlement(CreateEntitlementRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateEntitlement', $request, $callOptions)->wait(); + } + + /** + * Deletes the given + * [ChannelPartnerRepricingConfig][google.cloud.channel.v1.ChannelPartnerRepricingConfig] + * permanently. You can only delete configs if their + * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month] + * is set to a date after the current month. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The account making the request does not own + * this customer. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * * FAILED_PRECONDITION: The + * [ChannelPartnerRepricingConfig][google.cloud.channel.v1.ChannelPartnerRepricingConfig] + * is active or in the past. + * * NOT_FOUND: No + * [ChannelPartnerRepricingConfig][google.cloud.channel.v1.ChannelPartnerRepricingConfig] + * found for the name in the request. + * + * The async variant is + * {@see CloudChannelServiceClient::deleteChannelPartnerRepricingConfigAsync()} . + * + * @param DeleteChannelPartnerRepricingConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteChannelPartnerRepricingConfig(DeleteChannelPartnerRepricingConfigRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteChannelPartnerRepricingConfig', $request, $callOptions)->wait(); + } + + /** + * Deletes the given [Customer][google.cloud.channel.v1.Customer] permanently. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The account making the request does not own + * this customer. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * * FAILED_PRECONDITION: The customer has existing entitlements. + * * NOT_FOUND: No [Customer][google.cloud.channel.v1.Customer] resource found + * for the name in the request. + * + * The async variant is {@see CloudChannelServiceClient::deleteCustomerAsync()} . + * + * @param DeleteCustomerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteCustomer(DeleteCustomerRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteCustomer', $request, $callOptions)->wait(); + } + + /** + * Deletes the given + * [CustomerRepricingConfig][google.cloud.channel.v1.CustomerRepricingConfig] + * permanently. You can only delete configs if their + * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month] + * is set to a date after the current month. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The account making the request does not own + * this customer. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * * FAILED_PRECONDITION: The + * [CustomerRepricingConfig][google.cloud.channel.v1.CustomerRepricingConfig] + * is active or in the past. + * * NOT_FOUND: No + * [CustomerRepricingConfig][google.cloud.channel.v1.CustomerRepricingConfig] + * found for the name in the request. + * + * The async variant is + * {@see CloudChannelServiceClient::deleteCustomerRepricingConfigAsync()} . + * + * @param DeleteCustomerRepricingConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteCustomerRepricingConfig(DeleteCustomerRepricingConfigRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteCustomerRepricingConfig', $request, $callOptions)->wait(); + } + + /** + * Returns the requested + * [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] resource. + * You must be a distributor to call this method. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The reseller account making the request is different + * from the reseller account in the API request. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * * NOT_FOUND: ChannelPartnerLink resource not found because of an + * invalid channel partner link name. + * + * Return value: + * The [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] + * resource. + * + * The async variant is + * {@see CloudChannelServiceClient::getChannelPartnerLinkAsync()} . + * + * @param GetChannelPartnerLinkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ChannelPartnerLink + * + * @throws ApiException Thrown if the API call fails. + */ + public function getChannelPartnerLink(GetChannelPartnerLinkRequest $request, array $callOptions = []): ChannelPartnerLink + { + return $this->startApiCall('GetChannelPartnerLink', $request, $callOptions)->wait(); + } + + /** + * Gets information about how a Distributor modifies their bill before sending + * it to a ChannelPartner. + * + * Possible Error Codes: + * + * * PERMISSION_DENIED: If the account making the request and the account + * being queried are different. + * * NOT_FOUND: The + * [ChannelPartnerRepricingConfig][google.cloud.channel.v1.ChannelPartnerRepricingConfig] + * was not found. + * * INTERNAL: Any non-user error related to technical issues in the + * backend. In this case, contact Cloud Channel support. + * + * Return Value: + * If successful, the + * [ChannelPartnerRepricingConfig][google.cloud.channel.v1.ChannelPartnerRepricingConfig] + * resource, otherwise returns an error. + * + * The async variant is + * {@see CloudChannelServiceClient::getChannelPartnerRepricingConfigAsync()} . + * + * @param GetChannelPartnerRepricingConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ChannelPartnerRepricingConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getChannelPartnerRepricingConfig(GetChannelPartnerRepricingConfigRequest $request, array $callOptions = []): ChannelPartnerRepricingConfig + { + return $this->startApiCall('GetChannelPartnerRepricingConfig', $request, $callOptions)->wait(); + } + + /** + * Returns the requested [Customer][google.cloud.channel.v1.Customer] + * resource. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The reseller account making the request is different + * from the reseller account in the API request. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * * NOT_FOUND: The customer resource doesn't exist. Usually the result of an + * invalid name parameter. + * + * Return value: + * The [Customer][google.cloud.channel.v1.Customer] resource. + * + * The async variant is {@see CloudChannelServiceClient::getCustomerAsync()} . + * + * @param GetCustomerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Customer + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCustomer(GetCustomerRequest $request, array $callOptions = []): Customer + { + return $this->startApiCall('GetCustomer', $request, $callOptions)->wait(); + } + + /** + * Gets information about how a Reseller modifies their bill before sending + * it to a Customer. + * + * Possible Error Codes: + * + * * PERMISSION_DENIED: If the account making the request and the account + * being queried are different. + * * NOT_FOUND: The + * [CustomerRepricingConfig][google.cloud.channel.v1.CustomerRepricingConfig] + * was not found. + * * INTERNAL: Any non-user error related to technical issues in the + * backend. In this case, contact Cloud Channel support. + * + * Return Value: + * If successful, the + * [CustomerRepricingConfig][google.cloud.channel.v1.CustomerRepricingConfig] + * resource, otherwise returns an error. + * + * The async variant is + * {@see CloudChannelServiceClient::getCustomerRepricingConfigAsync()} . + * + * @param GetCustomerRepricingConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CustomerRepricingConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCustomerRepricingConfig(GetCustomerRepricingConfigRequest $request, array $callOptions = []): CustomerRepricingConfig + { + return $this->startApiCall('GetCustomerRepricingConfig', $request, $callOptions)->wait(); + } + + /** + * Returns the requested [Entitlement][google.cloud.channel.v1.Entitlement] + * resource. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The customer doesn't belong to the reseller. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * * NOT_FOUND: The customer entitlement was not found. + * + * Return value: + * The requested [Entitlement][google.cloud.channel.v1.Entitlement] resource. + * + * The async variant is {@see CloudChannelServiceClient::getEntitlementAsync()} . + * + * @param GetEntitlementRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Entitlement + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEntitlement(GetEntitlementRequest $request, array $callOptions = []): Entitlement + { + return $this->startApiCall('GetEntitlement', $request, $callOptions)->wait(); + } + + /** + * Imports a [Customer][google.cloud.channel.v1.Customer] from the Cloud + * Identity associated with the provided Cloud Identity ID or domain before a + * TransferEntitlements call. If a linked Customer already exists and + * overwrite_if_exists is true, it will update that Customer's data. + * + * Possible error codes: + * + * * PERMISSION_DENIED: + * * The reseller account making the request is different from the + * reseller account in the API request. + * * You are not authorized to import the customer. See + * https://support.google.com/channelservices/answer/9759265 + * * NOT_FOUND: Cloud Identity doesn't exist or was deleted. + * * INVALID_ARGUMENT: Required parameters are missing, or the auth_token is + * expired or invalid. + * * ALREADY_EXISTS: A customer already exists and has conflicting critical + * fields. Requires an overwrite. + * + * Return value: + * The [Customer][google.cloud.channel.v1.Customer]. + * + * The async variant is {@see CloudChannelServiceClient::importCustomerAsync()} . + * + * @param ImportCustomerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Customer + * + * @throws ApiException Thrown if the API call fails. + */ + public function importCustomer(ImportCustomerRequest $request, array $callOptions = []): Customer + { + return $this->startApiCall('ImportCustomer', $request, $callOptions)->wait(); + } + + /** + * List [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink]s + * belonging to a distributor. You must be a distributor to call this method. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The reseller account making the request is different + * from the reseller account in the API request. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * + * Return value: + * The list of the distributor account's + * [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] resources. + * + * The async variant is + * {@see CloudChannelServiceClient::listChannelPartnerLinksAsync()} . + * + * @param ListChannelPartnerLinksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listChannelPartnerLinks(ListChannelPartnerLinksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListChannelPartnerLinks', $request, $callOptions); + } + + /** + * Lists information about how a Reseller modifies their bill before sending + * it to a ChannelPartner. + * + * Possible Error Codes: + * + * * PERMISSION_DENIED: If the account making the request and the account + * being queried are different. + * * NOT_FOUND: The + * [ChannelPartnerRepricingConfig][google.cloud.channel.v1.ChannelPartnerRepricingConfig] + * specified does not exist or is not associated with the given account. + * * INTERNAL: Any non-user error related to technical issues in the + * backend. In this case, contact Cloud Channel support. + * + * Return Value: + * If successful, the + * [ChannelPartnerRepricingConfig][google.cloud.channel.v1.ChannelPartnerRepricingConfig] + * resources. The data for each resource is displayed in the ascending order + * of: + * + * * Channel Partner ID + * * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month] + * * [ChannelPartnerRepricingConfig.update_time][google.cloud.channel.v1.ChannelPartnerRepricingConfig.update_time] + * + * If unsuccessful, returns an error. + * + * The async variant is + * {@see CloudChannelServiceClient::listChannelPartnerRepricingConfigsAsync()} . + * + * @param ListChannelPartnerRepricingConfigsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listChannelPartnerRepricingConfigs(ListChannelPartnerRepricingConfigsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListChannelPartnerRepricingConfigs', $request, $callOptions); + } + + /** + * Lists information about how a Reseller modifies their bill before sending + * it to a Customer. + * + * Possible Error Codes: + * + * * PERMISSION_DENIED: If the account making the request and the account + * being queried are different. + * * NOT_FOUND: The + * [CustomerRepricingConfig][google.cloud.channel.v1.CustomerRepricingConfig] + * specified does not exist or is not associated with the given account. + * * INTERNAL: Any non-user error related to technical issues in the + * backend. In this case, contact Cloud Channel support. + * + * Return Value: + * If successful, the + * [CustomerRepricingConfig][google.cloud.channel.v1.CustomerRepricingConfig] + * resources. The data for each resource is displayed in the ascending order + * of: + * + * * Customer ID + * * [RepricingConfig.EntitlementGranularity.entitlement][google.cloud.channel.v1.RepricingConfig.EntitlementGranularity.entitlement] + * * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month] + * * [CustomerRepricingConfig.update_time][google.cloud.channel.v1.CustomerRepricingConfig.update_time] + * + * If unsuccessful, returns an error. + * + * The async variant is + * {@see CloudChannelServiceClient::listCustomerRepricingConfigsAsync()} . + * + * @param ListCustomerRepricingConfigsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCustomerRepricingConfigs(ListCustomerRepricingConfigsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCustomerRepricingConfigs', $request, $callOptions); + } + + /** + * List [Customer][google.cloud.channel.v1.Customer]s. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The reseller account making the request is different + * from the reseller account in the API request. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * + * Return value: + * List of [Customer][google.cloud.channel.v1.Customer]s, or an empty list if + * there are no customers. + * + * The async variant is {@see CloudChannelServiceClient::listCustomersAsync()} . + * + * @param ListCustomersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCustomers(ListCustomersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCustomers', $request, $callOptions); + } + + /** + * List entitlement history. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The reseller account making the request and the + * provided reseller account are different. + * * INVALID_ARGUMENT: Missing or invalid required fields in the request. + * * NOT_FOUND: The parent resource doesn't exist. Usually the result of an + * invalid name parameter. + * * INTERNAL: Any non-user error related to a technical issue in the backend. + * In this case, contact CloudChannel support. + * * UNKNOWN: Any non-user error related to a technical issue in the backend. + * In this case, contact Cloud Channel support. + * + * Return value: + * List of [EntitlementChange][google.cloud.channel.v1.EntitlementChange]s. + * + * The async variant is + * {@see CloudChannelServiceClient::listEntitlementChangesAsync()} . + * + * @param ListEntitlementChangesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listEntitlementChanges(ListEntitlementChangesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEntitlementChanges', $request, $callOptions); + } + + /** + * Lists [Entitlement][google.cloud.channel.v1.Entitlement]s belonging to a + * customer. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The customer doesn't belong to the reseller. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * + * Return value: + * A list of the customer's + * [Entitlement][google.cloud.channel.v1.Entitlement]s. + * + * The async variant is {@see CloudChannelServiceClient::listEntitlementsAsync()} . + * + * @param ListEntitlementsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listEntitlements(ListEntitlementsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEntitlements', $request, $callOptions); + } + + /** + * Lists the Offers the reseller can sell. + * + * Possible error codes: + * + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * + * The async variant is {@see CloudChannelServiceClient::listOffersAsync()} . + * + * @param ListOffersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listOffers(ListOffersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListOffers', $request, $callOptions); + } + + /** + * Lists the Products the reseller is authorized to sell. + * + * Possible error codes: + * + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * + * The async variant is {@see CloudChannelServiceClient::listProductsAsync()} . + * + * @param ListProductsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listProducts(ListProductsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListProducts', $request, $callOptions); + } + + /** + * Lists the following: + * + * * Offers that you can purchase for a customer. + * * Offers that you can change for an entitlement. + * + * Possible error codes: + * + * * PERMISSION_DENIED: + * * The customer doesn't belong to the reseller + * * The reseller is not authorized to transact on this Product. See + * https://support.google.com/channelservices/answer/9759265 + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * + * The async variant is + * {@see CloudChannelServiceClient::listPurchasableOffersAsync()} . + * + * @param ListPurchasableOffersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPurchasableOffers(ListPurchasableOffersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPurchasableOffers', $request, $callOptions); + } + + /** + * Lists the following: + * + * * SKUs that you can purchase for a customer + * * SKUs that you can upgrade or downgrade for an entitlement. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The customer doesn't belong to the reseller. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * + * The async variant is + * {@see CloudChannelServiceClient::listPurchasableSkusAsync()} . + * + * @param ListPurchasableSkusRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPurchasableSkus(ListPurchasableSkusRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPurchasableSkus', $request, $callOptions); + } + + /** + * Lists the Billable SKUs in a given SKU group. + * + * Possible error codes: + * PERMISSION_DENIED: If the account making the request and the account + * being queried for are different, or the account doesn't exist. + * INVALID_ARGUMENT: Missing or invalid required parameters in the + * request. + * INTERNAL: Any non-user error related to technical issue in the + * backend. In this case, contact cloud channel support. + * + * Return Value: + * If successful, the [BillableSku][google.cloud.channel.v1.BillableSku] + * resources. The data for each resource is displayed in the ascending order + * of: + * + * * [BillableSku.service_display_name][google.cloud.channel.v1.BillableSku.service_display_name] + * * [BillableSku.sku_display_name][google.cloud.channel.v1.BillableSku.sku_display_name] + * + * If unsuccessful, returns an error. + * + * The async variant is + * {@see CloudChannelServiceClient::listSkuGroupBillableSkusAsync()} . + * + * @param ListSkuGroupBillableSkusRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSkuGroupBillableSkus(ListSkuGroupBillableSkusRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSkuGroupBillableSkus', $request, $callOptions); + } + + /** + * Lists the Rebilling supported SKU groups the account is authorized to + * sell. + * Reference: https://cloud.google.com/skus/sku-groups + * + * Possible Error Codes: + * + * * PERMISSION_DENIED: If the account making the request and the account + * being queried are different, or the account doesn't exist. + * * INTERNAL: Any non-user error related to technical issues in the + * backend. In this case, contact Cloud Channel support. + * + * Return Value: + * If successful, the [SkuGroup][google.cloud.channel.v1.SkuGroup] resources. + * The data for each resource is displayed in the alphabetical order of SKU + * group display name. + * The data for each resource is displayed in the ascending order of + * [SkuGroup.display_name][google.cloud.channel.v1.SkuGroup.display_name] + * + * If unsuccessful, returns an error. + * + * The async variant is {@see CloudChannelServiceClient::listSkuGroupsAsync()} . + * + * @param ListSkuGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSkuGroups(ListSkuGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSkuGroups', $request, $callOptions); + } + + /** + * Lists the SKUs for a product the reseller is authorized to sell. + * + * Possible error codes: + * + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * + * The async variant is {@see CloudChannelServiceClient::listSkusAsync()} . + * + * @param ListSkusRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSkus(ListSkusRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSkus', $request, $callOptions); + } + + /** + * Lists service accounts with subscriber privileges on the Cloud Pub/Sub + * topic created for this Channel Services account. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The reseller account making the request and the + * provided reseller account are different, or the impersonated user + * is not a super admin. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * * NOT_FOUND: The topic resource doesn't exist. + * * INTERNAL: Any non-user error related to a technical issue in the + * backend. Contact Cloud Channel support. + * * UNKNOWN: Any non-user error related to a technical issue in the backend. + * Contact Cloud Channel support. + * + * Return value: + * A list of service email addresses. + * + * The async variant is {@see CloudChannelServiceClient::listSubscribersAsync()} . + * + * @param ListSubscribersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSubscribers(ListSubscribersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSubscribers', $request, $callOptions); + } + + /** + * List [TransferableOffer][google.cloud.channel.v1.TransferableOffer]s of a + * customer based on Cloud Identity ID or Customer Name in the request. + * + * Use this method when a reseller gets the entitlement information of an + * unowned customer. The reseller should provide the customer's + * Cloud Identity ID or Customer Name. + * + * Possible error codes: + * + * * PERMISSION_DENIED: + * * The customer doesn't belong to the reseller and has no auth token. + * * The customer provided incorrect reseller information when generating + * auth token. + * * The reseller account making the request is different + * from the reseller account in the query. + * * The reseller is not authorized to transact on this Product. See + * https://support.google.com/channelservices/answer/9759265 + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * + * Return value: + * List of [TransferableOffer][google.cloud.channel.v1.TransferableOffer] for + * the given customer and SKU. + * + * The async variant is + * {@see CloudChannelServiceClient::listTransferableOffersAsync()} . + * + * @param ListTransferableOffersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTransferableOffers(ListTransferableOffersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTransferableOffers', $request, $callOptions); + } + + /** + * List [TransferableSku][google.cloud.channel.v1.TransferableSku]s of a + * customer based on the Cloud Identity ID or Customer Name in the request. + * + * Use this method to list the entitlements information of an + * unowned customer. You should provide the customer's + * Cloud Identity ID or Customer Name. + * + * Possible error codes: + * + * * PERMISSION_DENIED: + * * The customer doesn't belong to the reseller and has no auth token. + * * The supplied auth token is invalid. + * * The reseller account making the request is different + * from the reseller account in the query. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * + * Return value: + * A list of the customer's + * [TransferableSku][google.cloud.channel.v1.TransferableSku]. + * + * The async variant is + * {@see CloudChannelServiceClient::listTransferableSkusAsync()} . + * + * @param ListTransferableSkusRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTransferableSkus(ListTransferableSkusRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTransferableSkus', $request, $callOptions); + } + + /** + * Returns the requested [Offer][google.cloud.channel.v1.Offer] resource. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The entitlement doesn't belong to the reseller. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * * NOT_FOUND: Entitlement or offer was not found. + * + * Return value: + * The [Offer][google.cloud.channel.v1.Offer] resource. + * + * The async variant is {@see CloudChannelServiceClient::lookupOfferAsync()} . + * + * @param LookupOfferRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Offer + * + * @throws ApiException Thrown if the API call fails. + */ + public function lookupOffer(LookupOfferRequest $request, array $callOptions = []): Offer + { + return $this->startApiCall('LookupOffer', $request, $callOptions)->wait(); + } + + /** + * Creates a Cloud Identity for the given customer using the customer's + * information, or the information provided here. + * + * Possible error codes: + * + * * PERMISSION_DENIED: + * * The customer doesn't belong to the reseller. + * * You are not authorized to provision cloud identity id. See + * https://support.google.com/channelservices/answer/9759265 + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * * NOT_FOUND: The customer was not found. + * * ALREADY_EXISTS: The customer's primary email already exists. Retry + * after changing the customer's primary contact email. + * * INTERNAL: Any non-user error related to a technical issue in the + * backend. Contact Cloud Channel support. + * * UNKNOWN: Any non-user error related to a technical issue in the backend. + * Contact Cloud Channel support. + * + * Return value: + * The ID of a long-running operation. + * + * To get the results of the operation, call the GetOperation method of + * CloudChannelOperationsService. The Operation metadata contains an + * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + * + * The async variant is + * {@see CloudChannelServiceClient::provisionCloudIdentityAsync()} . + * + * @param ProvisionCloudIdentityRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function provisionCloudIdentity(ProvisionCloudIdentityRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ProvisionCloudIdentity', $request, $callOptions)->wait(); + } + + /** + * Lists the billing accounts that are eligible to purchase particular SKUs + * for a given customer. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The customer doesn't belong to the reseller. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * + * Return value: + * Based on the provided list of SKUs, returns a list of SKU groups that must + * be purchased using the same billing account and the billing accounts + * eligible to purchase each SKU group. + * + * The async variant is + * {@see CloudChannelServiceClient::queryEligibleBillingAccountsAsync()} . + * + * @param QueryEligibleBillingAccountsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 QueryEligibleBillingAccountsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function queryEligibleBillingAccounts(QueryEligibleBillingAccountsRequest $request, array $callOptions = []): QueryEligibleBillingAccountsResponse + { + return $this->startApiCall('QueryEligibleBillingAccounts', $request, $callOptions)->wait(); + } + + /** + * Registers a service account with subscriber privileges on the Cloud Pub/Sub + * topic for this Channel Services account. After you create a + * subscriber, you get the events through + * [SubscriberEvent][google.cloud.channel.v1.SubscriberEvent] + * + * Possible error codes: + * + * * PERMISSION_DENIED: The reseller account making the request and the + * provided reseller account are different, or the impersonated user + * is not a super admin. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * * INTERNAL: Any non-user error related to a technical issue in the + * backend. Contact Cloud Channel support. + * * UNKNOWN: Any non-user error related to a technical issue in the backend. + * Contact Cloud Channel support. + * + * Return value: + * The topic name with the registered service email address. + * + * The async variant is {@see CloudChannelServiceClient::registerSubscriberAsync()} + * . + * + * @param RegisterSubscriberRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RegisterSubscriberResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function registerSubscriber(RegisterSubscriberRequest $request, array $callOptions = []): RegisterSubscriberResponse + { + return $this->startApiCall('RegisterSubscriber', $request, $callOptions)->wait(); + } + + /** + * Starts paid service for a trial entitlement. + * + * Starts paid service for a trial entitlement immediately. This method is + * only applicable if a plan is set up for a trial entitlement but has some + * trial days remaining. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The customer doesn't belong to the reseller. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * * NOT_FOUND: Entitlement resource not found. + * * FAILED_PRECONDITION/NOT_IN_TRIAL: This method only works for + * entitlement on trial plans. + * * INTERNAL: Any non-user error related to a technical issue in the + * backend. Contact Cloud Channel support. + * * UNKNOWN: Any non-user error related to a technical issue in the backend. + * Contact Cloud Channel support. + * + * Return value: + * The ID of a long-running operation. + * + * To get the results of the operation, call the GetOperation method of + * CloudChannelOperationsService. The Operation metadata will contain an + * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + * + * The async variant is {@see CloudChannelServiceClient::startPaidServiceAsync()} . + * + * @param StartPaidServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function startPaidService(StartPaidServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StartPaidService', $request, $callOptions)->wait(); + } + + /** + * Suspends a previously fulfilled entitlement. + * + * An entitlement suspension is a long-running operation. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The customer doesn't belong to the reseller. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * * NOT_FOUND: Entitlement resource not found. + * * NOT_ACTIVE: Entitlement is not active. + * * INTERNAL: Any non-user error related to a technical issue in the + * backend. Contact Cloud Channel support. + * * UNKNOWN: Any non-user error related to a technical issue in the backend. + * Contact Cloud Channel support. + * + * Return value: + * The ID of a long-running operation. + * + * To get the results of the operation, call the GetOperation method of + * CloudChannelOperationsService. The Operation metadata will contain an + * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + * + * The async variant is {@see CloudChannelServiceClient::suspendEntitlementAsync()} + * . + * + * @param SuspendEntitlementRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function suspendEntitlement(SuspendEntitlementRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SuspendEntitlement', $request, $callOptions)->wait(); + } + + /** + * Transfers customer entitlements to new reseller. + * + * Possible error codes: + * + * * PERMISSION_DENIED: + * * The customer doesn't belong to the reseller. + * * The reseller is not authorized to transact on this Product. See + * https://support.google.com/channelservices/answer/9759265 + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * * NOT_FOUND: The customer or offer resource was not found. + * * ALREADY_EXISTS: The SKU was already transferred for the customer. + * * CONDITION_NOT_MET or FAILED_PRECONDITION: + * * The SKU requires domain verification to transfer, but the domain is + * not verified. + * * An Add-On SKU (example, Vault or Drive) is missing the + * pre-requisite SKU (example, G Suite Basic). + * * (Developer accounts only) Reseller and resold domain must meet the + * following naming requirements: + * * Domain names must start with goog-test. + * * Domain names must include the reseller domain. + * * Specify all transferring entitlements. + * * INTERNAL: Any non-user error related to a technical issue in the + * backend. Contact Cloud Channel support. + * * UNKNOWN: Any non-user error related to a technical issue in the backend. + * Contact Cloud Channel support. + * + * Return value: + * The ID of a long-running operation. + * + * To get the results of the operation, call the GetOperation method of + * CloudChannelOperationsService. The Operation metadata will contain an + * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + * + * The async variant is + * {@see CloudChannelServiceClient::transferEntitlementsAsync()} . + * + * @param TransferEntitlementsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function transferEntitlements(TransferEntitlementsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('TransferEntitlements', $request, $callOptions)->wait(); + } + + /** + * Transfers customer entitlements from their current reseller to Google. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The customer doesn't belong to the reseller. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * * NOT_FOUND: The customer or offer resource was not found. + * * ALREADY_EXISTS: The SKU was already transferred for the customer. + * * CONDITION_NOT_MET or FAILED_PRECONDITION: + * * The SKU requires domain verification to transfer, but the domain is + * not verified. + * * An Add-On SKU (example, Vault or Drive) is missing the + * pre-requisite SKU (example, G Suite Basic). + * * (Developer accounts only) Reseller and resold domain must meet the + * following naming requirements: + * * Domain names must start with goog-test. + * * Domain names must include the reseller domain. + * * INTERNAL: Any non-user error related to a technical issue in the + * backend. Contact Cloud Channel support. + * * UNKNOWN: Any non-user error related to a technical issue in the backend. + * Contact Cloud Channel support. + * + * Return value: + * The ID of a long-running operation. + * + * To get the results of the operation, call the GetOperation method of + * CloudChannelOperationsService. The response will contain + * google.protobuf.Empty on success. The Operation metadata will contain an + * instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata]. + * + * The async variant is + * {@see CloudChannelServiceClient::transferEntitlementsToGoogleAsync()} . + * + * @param TransferEntitlementsToGoogleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function transferEntitlementsToGoogle(TransferEntitlementsToGoogleRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('TransferEntitlementsToGoogle', $request, $callOptions)->wait(); + } + + /** + * Unregisters a service account with subscriber privileges on the Cloud + * Pub/Sub topic created for this Channel Services account. If there are no + * service accounts left with subscriber privileges, this deletes the topic. + * You can call ListSubscribers to check for these accounts. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The reseller account making the request and the + * provided reseller account are different, or the impersonated user + * is not a super admin. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * * NOT_FOUND: The topic resource doesn't exist. + * * INTERNAL: Any non-user error related to a technical issue in the + * backend. Contact Cloud Channel support. + * * UNKNOWN: Any non-user error related to a technical issue in the backend. + * Contact Cloud Channel support. + * + * Return value: + * The topic name that unregistered the service email address. + * Returns a success response if the service email address wasn't registered + * with the topic. + * + * The async variant is + * {@see CloudChannelServiceClient::unregisterSubscriberAsync()} . + * + * @param UnregisterSubscriberRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 UnregisterSubscriberResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function unregisterSubscriber(UnregisterSubscriberRequest $request, array $callOptions = []): UnregisterSubscriberResponse + { + return $this->startApiCall('UnregisterSubscriber', $request, $callOptions)->wait(); + } + + /** + * Updates a channel partner link. Distributors call this method to change a + * link's status. For example, to suspend a partner link. + * You must be a distributor to call this method. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The reseller account making the request is different + * from the reseller account in the API request. + * * INVALID_ARGUMENT: + * * Required request parameters are missing or invalid. + * * Link state cannot change from invited to active or suspended. + * * Cannot send reseller_cloud_identity_id, invite_url, or name in update + * mask. + * * NOT_FOUND: ChannelPartnerLink resource not found. + * * INTERNAL: Any non-user error related to a technical issue in the + * backend. Contact Cloud Channel support. + * * UNKNOWN: Any non-user error related to a technical issue in the backend. + * Contact Cloud Channel support. + * + * Return value: + * The updated + * [ChannelPartnerLink][google.cloud.channel.v1.ChannelPartnerLink] resource. + * + * The async variant is + * {@see CloudChannelServiceClient::updateChannelPartnerLinkAsync()} . + * + * @param UpdateChannelPartnerLinkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ChannelPartnerLink + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateChannelPartnerLink(UpdateChannelPartnerLinkRequest $request, array $callOptions = []): ChannelPartnerLink + { + return $this->startApiCall('UpdateChannelPartnerLink', $request, $callOptions)->wait(); + } + + /** + * Updates a ChannelPartnerRepricingConfig. Call this method to set + * modifications for a specific ChannelPartner's bill. This method overwrites + * the existing CustomerRepricingConfig. + * + * You can only update configs if the + * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month] + * is a future month. To make changes to configs for the current month, use + * [CreateChannelPartnerRepricingConfig][google.cloud.channel.v1.CloudChannelService.CreateChannelPartnerRepricingConfig], + * taking note of its restrictions. You cannot update the + * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month]. + * + * When updating a config in the future: + * + * * This config must already exist. + * + * Possible Error Codes: + * + * * PERMISSION_DENIED: If the account making the request and the account + * being queried are different. + * * INVALID_ARGUMENT: Missing or invalid required parameters in the + * request. Also displays if the updated config is for the current month or + * past months. + * * NOT_FOUND: The + * [ChannelPartnerRepricingConfig][google.cloud.channel.v1.ChannelPartnerRepricingConfig] + * specified does not exist or is not associated with the given account. + * * INTERNAL: Any non-user error related to technical issues in the + * backend. In this case, contact Cloud Channel support. + * + * Return Value: + * If successful, the updated + * [ChannelPartnerRepricingConfig][google.cloud.channel.v1.ChannelPartnerRepricingConfig] + * resource, otherwise returns an error. + * + * The async variant is + * {@see CloudChannelServiceClient::updateChannelPartnerRepricingConfigAsync()} . + * + * @param UpdateChannelPartnerRepricingConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ChannelPartnerRepricingConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateChannelPartnerRepricingConfig(UpdateChannelPartnerRepricingConfigRequest $request, array $callOptions = []): ChannelPartnerRepricingConfig + { + return $this->startApiCall('UpdateChannelPartnerRepricingConfig', $request, $callOptions)->wait(); + } + + /** + * Updates an existing [Customer][google.cloud.channel.v1.Customer] resource + * for the reseller or distributor. + * + * Possible error codes: + * + * * PERMISSION_DENIED: The reseller account making the request is different + * from the reseller account in the API request. + * * INVALID_ARGUMENT: Required request parameters are missing or invalid. + * * NOT_FOUND: No [Customer][google.cloud.channel.v1.Customer] resource found + * for the name in the request. + * + * Return value: + * The updated [Customer][google.cloud.channel.v1.Customer] resource. + * + * The async variant is {@see CloudChannelServiceClient::updateCustomerAsync()} . + * + * @param UpdateCustomerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Customer + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCustomer(UpdateCustomerRequest $request, array $callOptions = []): Customer + { + return $this->startApiCall('UpdateCustomer', $request, $callOptions)->wait(); + } + + /** + * Updates a CustomerRepricingConfig. Call this method to set modifications + * for a specific customer's bill. This method overwrites the existing + * CustomerRepricingConfig. + * + * You can only update configs if the + * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month] + * is a future month. To make changes to configs for the current month, use + * [CreateCustomerRepricingConfig][google.cloud.channel.v1.CloudChannelService.CreateCustomerRepricingConfig], + * taking note of its restrictions. You cannot update the + * [RepricingConfig.effective_invoice_month][google.cloud.channel.v1.RepricingConfig.effective_invoice_month]. + * + * When updating a config in the future: + * + * * This config must already exist. + * + * Possible Error Codes: + * + * * PERMISSION_DENIED: If the account making the request and the account + * being queried are different. + * * INVALID_ARGUMENT: Missing or invalid required parameters in the + * request. Also displays if the updated config is for the current month or + * past months. + * * NOT_FOUND: The + * [CustomerRepricingConfig][google.cloud.channel.v1.CustomerRepricingConfig] + * specified does not exist or is not associated with the given account. + * * INTERNAL: Any non-user error related to technical issues in the + * backend. In this case, contact Cloud Channel support. + * + * Return Value: + * If successful, the updated + * [CustomerRepricingConfig][google.cloud.channel.v1.CustomerRepricingConfig] + * resource, otherwise returns an error. + * + * The async variant is + * {@see CloudChannelServiceClient::updateCustomerRepricingConfigAsync()} . + * + * @param UpdateCustomerRepricingConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CustomerRepricingConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCustomerRepricingConfig(UpdateCustomerRepricingConfigRequest $request, array $callOptions = []): CustomerRepricingConfig + { + return $this->startApiCall('UpdateCustomerRepricingConfig', $request, $callOptions)->wait(); + } } diff --git a/CommerceConsumerProcurement/composer.json b/CommerceConsumerProcurement/composer.json index a57d96a4df3f..57886043c7f9 100644 --- a/CommerceConsumerProcurement/composer.json +++ b/CommerceConsumerProcurement/composer.json @@ -18,7 +18,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.21.0" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/CommerceConsumerProcurement/src/V1/Client/BaseClient/ConsumerProcurementServiceBaseClient.php b/CommerceConsumerProcurement/src/V1/Client/BaseClient/ConsumerProcurementServiceBaseClient.php deleted file mode 100644 index 882a8ca98c4b..000000000000 --- a/CommerceConsumerProcurement/src/V1/Client/BaseClient/ConsumerProcurementServiceBaseClient.php +++ /dev/null @@ -1,436 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . - '/../../resources/consumer_procurement_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../../resources/consumer_procurement_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . - '/../../resources/consumer_procurement_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../../resources/consumer_procurement_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; - $operation = new OperationResponse( - $operationName, - $this->getOperationsClient(), - $options - ); - $operation->reload(); - return $operation; - } - - /** - * 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(string $billingAccount): string - { - return self::getPathTemplate('billingAccount')->render([ - 'billing_account' => $billingAccount, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * consumer_billing_account_offer resource. - * - * @param string $consumerBillingAccount - * @param string $offer - * - * @return string The formatted consumer_billing_account_offer resource. - */ - public static function consumerBillingAccountOfferName( - string $consumerBillingAccount, - string $offer - ): string { - return self::getPathTemplate('consumerBillingAccountOffer')->render([ - 'consumer_billing_account' => $consumerBillingAccount, - 'offer' => $offer, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a offer - * resource. - * - * @param string $service - * @param string $offer - * - * @return string The formatted offer resource. - */ - public static function offerName(string $service, string $offer): string - { - return self::getPathTemplate('offer')->render([ - 'service' => $service, - 'offer' => $offer, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * service_offer resource. - * - * @param string $service - * @param string $offer - * - * @return string The formatted service_offer resource. - */ - public static function serviceOfferName( - string $service, - string $offer - ): string { - return self::getPathTemplate('serviceOffer')->render([ - 'service' => $service, - 'offer' => $offer, - ]); - } - - /** - * 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} - * - consumerBillingAccountOffer: billingAccounts/{consumer_billing_account}/offers/{offer} - * - offer: services/{service}/standardOffers/{offer} - * - serviceOffer: services/{service}/standardOffers/{offer} - * - * 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( - string $formattedName, - string $template = null - ): array { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 - * 'cloudcommerceconsumerprocurement.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error( - 'Call to undefined method ' . __CLASS__ . "::$method()", - E_USER_ERROR - ); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Returns the requested - * [Order][google.cloud.commerce.consumer.procurement.v1.Order] resource. - * - * The async variant is {@see self::getOrderAsync()} . - * - * @example samples/V1/ConsumerProcurementServiceClient/get_order.php - * - * @param GetOrderRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Order - * - * @throws ApiException Thrown if the API call fails. - */ - public function getOrder( - GetOrderRequest $request, - array $callOptions = [] - ): Order { - return $this->startApiCall('GetOrder', $request, $callOptions)->wait(); - } - - /** - * Lists [Order][google.cloud.commerce.consumer.procurement.v1.Order] - * resources that the user has access to, within the scope of the parent - * resource. - * - * The async variant is {@see self::listOrdersAsync()} . - * - * @example samples/V1/ConsumerProcurementServiceClient/list_orders.php - * - * @param ListOrdersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listOrders( - ListOrdersRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListOrders', $request, $callOptions); - } - - /** - * Creates a new [Order][google.cloud.commerce.consumer.procurement.v1.Order]. - * - * This API only supports GCP spend-based committed use - * discounts specified by GCP documentation. - * - * The returned long-running operation is in-progress until the backend - * completes the creation of the resource. Once completed, the order is - * in - * [OrderState.ORDER_STATE_ACTIVE][google.cloud.commerce.consumer.procurement.v1.OrderState.ORDER_STATE_ACTIVE]. - * In case of failure, the order resource will be removed. - * - * The async variant is {@see self::placeOrderAsync()} . - * - * @example samples/V1/ConsumerProcurementServiceClient/place_order.php - * - * @param PlaceOrderRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function placeOrder( - PlaceOrderRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'PlaceOrder', - $request, - $callOptions - )->wait(); - } -} diff --git a/CommerceConsumerProcurement/src/V1/Client/ConsumerProcurementServiceClient.php b/CommerceConsumerProcurement/src/V1/Client/ConsumerProcurementServiceClient.php index a7f8fd03791b..09dac2a01f18 100644 --- a/CommerceConsumerProcurement/src/V1/Client/ConsumerProcurementServiceClient.php +++ b/CommerceConsumerProcurement/src/V1/Client/ConsumerProcurementServiceClient.php @@ -24,17 +24,379 @@ namespace Google\Cloud\Commerce\Consumer\Procurement\V1\Client; -use Google\Cloud\Commerce\Consumer\Procurement\V1\Client\BaseClient\ConsumerProcurementServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Commerce\Consumer\Procurement\V1\GetOrderRequest; +use Google\Cloud\Commerce\Consumer\Procurement\V1\ListOrdersRequest; +use Google\Cloud\Commerce\Consumer\Procurement\V1\Order; +use Google\Cloud\Commerce\Consumer\Procurement\V1\PlaceOrderRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: ConsumerProcurementService allows customers to make purchases of products + * served by the Cloud Commerce platform. + * + * + * When purchases are made, the + * [ConsumerProcurementService][google.cloud.commerce.consumer.procurement.v1.ConsumerProcurementService] + * programs the appropriate backends, including both Google's own + * infrastructure, as well as third-party systems, and to enable billing setup + * for charging for the procured item. + * + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface getOrderAsync(GetOrderRequest $request, array $optionalArgs = []) + * @method PromiseInterface listOrdersAsync(ListOrdersRequest $request, array $optionalArgs = []) + * @method PromiseInterface placeOrderAsync(PlaceOrderRequest $request, array $optionalArgs = []) */ -final class ConsumerProcurementServiceClient extends ConsumerProcurementServiceBaseClient +final class ConsumerProcurementServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ConsumerProcurementServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.commerce.consumer.procurement.v1.ConsumerProcurementService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudcommerceconsumerprocurement.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/consumer_procurement_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/consumer_procurement_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/consumer_procurement_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/consumer_procurement_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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(string $billingAccount): string + { + return self::getPathTemplate('billingAccount')->render([ + 'billing_account' => $billingAccount, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * consumer_billing_account_offer resource. + * + * @param string $consumerBillingAccount + * @param string $offer + * + * @return string The formatted consumer_billing_account_offer resource. + */ + public static function consumerBillingAccountOfferName(string $consumerBillingAccount, string $offer): string + { + return self::getPathTemplate('consumerBillingAccountOffer')->render([ + 'consumer_billing_account' => $consumerBillingAccount, + 'offer' => $offer, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a offer + * resource. + * + * @param string $service + * @param string $offer + * + * @return string The formatted offer resource. + */ + public static function offerName(string $service, string $offer): string + { + return self::getPathTemplate('offer')->render([ + 'service' => $service, + 'offer' => $offer, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * service_offer resource. + * + * @param string $service + * @param string $offer + * + * @return string The formatted service_offer resource. + */ + public static function serviceOfferName(string $service, string $offer): string + { + return self::getPathTemplate('serviceOffer')->render([ + 'service' => $service, + 'offer' => $offer, + ]); + } + + /** + * 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} + * - consumerBillingAccountOffer: billingAccounts/{consumer_billing_account}/offers/{offer} + * - offer: services/{service}/standardOffers/{offer} + * - serviceOffer: services/{service}/standardOffers/{offer} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 + * 'cloudcommerceconsumerprocurement.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Returns the requested + * [Order][google.cloud.commerce.consumer.procurement.v1.Order] resource. + * + * The async variant is {@see ConsumerProcurementServiceClient::getOrderAsync()} . + * + * @example samples/V1/ConsumerProcurementServiceClient/get_order.php + * + * @param GetOrderRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Order + * + * @throws ApiException Thrown if the API call fails. + */ + public function getOrder(GetOrderRequest $request, array $callOptions = []): Order + { + return $this->startApiCall('GetOrder', $request, $callOptions)->wait(); + } + + /** + * Lists [Order][google.cloud.commerce.consumer.procurement.v1.Order] + * resources that the user has access to, within the scope of the parent + * resource. + * + * The async variant is {@see ConsumerProcurementServiceClient::listOrdersAsync()} + * . + * + * @example samples/V1/ConsumerProcurementServiceClient/list_orders.php + * + * @param ListOrdersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listOrders(ListOrdersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListOrders', $request, $callOptions); + } + + /** + * Creates a new [Order][google.cloud.commerce.consumer.procurement.v1.Order]. + * + * This API only supports GCP spend-based committed use + * discounts specified by GCP documentation. + * + * The returned long-running operation is in-progress until the backend + * completes the creation of the resource. Once completed, the order is + * in + * [OrderState.ORDER_STATE_ACTIVE][google.cloud.commerce.consumer.procurement.v1.OrderState.ORDER_STATE_ACTIVE]. + * In case of failure, the order resource will be removed. + * + * The async variant is {@see ConsumerProcurementServiceClient::placeOrderAsync()} + * . + * + * @example samples/V1/ConsumerProcurementServiceClient/place_order.php + * + * @param PlaceOrderRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function placeOrder(PlaceOrderRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('PlaceOrder', $request, $callOptions)->wait(); + } } diff --git a/Compute/composer.json b/Compute/composer.json index e9adcf618370..396a6b9bbebe 100644 --- a/Compute/composer.json +++ b/Compute/composer.json @@ -5,11 +5,11 @@ "minimum-stability": "stable", "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", - "google/cloud-core": "^1.39" + "google/cloud-core": "^1.52.7" }, "suggest": { "ext-protobuf": "Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions." diff --git a/Compute/src/V1/Client/AcceleratorTypesClient.php b/Compute/src/V1/Client/AcceleratorTypesClient.php index ee996d04d409..ef1e933765f0 100644 --- a/Compute/src/V1/Client/AcceleratorTypesClient.php +++ b/Compute/src/V1/Client/AcceleratorTypesClient.php @@ -24,17 +24,231 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\AcceleratorTypesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AcceleratorType; +use Google\Cloud\Compute\V1\AggregatedListAcceleratorTypesRequest; +use Google\Cloud\Compute\V1\GetAcceleratorTypeRequest; +use Google\Cloud\Compute\V1\ListAcceleratorTypesRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: + * Services * - * This class is currently experimental and may be subject to changes. + * The AcceleratorTypes API. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\AcceleratorTypesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListAcceleratorTypesRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetAcceleratorTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListAcceleratorTypesRequest $request, array $optionalArgs = []) */ -final class AcceleratorTypesClient extends AcceleratorTypesBaseClient +final class AcceleratorTypesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AcceleratorTypesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.AcceleratorTypes'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute.readonly', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/accelerator_types_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/accelerator_types_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/accelerator_types_rest_client_config.php', + ], + ], + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves an aggregated list of accelerator types. + * + * The async variant is {@see AcceleratorTypesClient::aggregatedListAsync()} . + * + * @param AggregatedListAcceleratorTypesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListAcceleratorTypesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Returns the specified accelerator type. + * + * The async variant is {@see AcceleratorTypesClient::getAsync()} . + * + * @param GetAcceleratorTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AcceleratorType + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetAcceleratorTypeRequest $request, array $callOptions = []): AcceleratorType + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of accelerator types that are available to the specified project. + * + * The async variant is {@see AcceleratorTypesClient::listAsync()} . + * + * @param ListAcceleratorTypesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListAcceleratorTypesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } } diff --git a/Compute/src/V1/Client/AddressesClient.php b/Compute/src/V1/Client/AddressesClient.php index 3538e22ff222..9118db5174c9 100644 --- a/Compute/src/V1/Client/AddressesClient.php +++ b/Compute/src/V1/Client/AddressesClient.php @@ -24,17 +24,385 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\AddressesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\Address; +use Google\Cloud\Compute\V1\AggregatedListAddressesRequest; +use Google\Cloud\Compute\V1\DeleteAddressRequest; +use Google\Cloud\Compute\V1\GetAddressRequest; +use Google\Cloud\Compute\V1\InsertAddressRequest; +use Google\Cloud\Compute\V1\ListAddressesRequest; +use Google\Cloud\Compute\V1\MoveAddressRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\SetLabelsAddressRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Addresses API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\AddressesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListAddressesRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteAddressRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetAddressRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertAddressRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListAddressesRequest $request, array $optionalArgs = []) + * @method PromiseInterface moveAsync(MoveAddressRequest $request, array $optionalArgs = []) + * @method PromiseInterface setLabelsAsync(SetLabelsAddressRequest $request, array $optionalArgs = []) */ -final class AddressesClient extends AddressesBaseClient +final class AddressesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AddressesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.Addresses'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/addresses_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/addresses_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/addresses_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves an aggregated list of addresses. + * + * The async variant is {@see AddressesClient::aggregatedListAsync()} . + * + * @param AggregatedListAddressesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListAddressesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified address resource. + * + * The async variant is {@see AddressesClient::deleteAsync()} . + * + * @param DeleteAddressRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteAddressRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified address resource. + * + * The async variant is {@see AddressesClient::getAsync()} . + * + * @param GetAddressRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Address + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetAddressRequest $request, array $callOptions = []): Address + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates an address resource in the specified project by using the data included in the request. + * + * The async variant is {@see AddressesClient::insertAsync()} . + * + * @param InsertAddressRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertAddressRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of addresses contained within the specified region. + * + * The async variant is {@see AddressesClient::listAsync()} . + * + * @param ListAddressesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListAddressesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Moves the specified address resource. + * + * The async variant is {@see AddressesClient::moveAsync()} . + * + * @param MoveAddressRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function move(MoveAddressRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Move', $request, $callOptions)->wait(); + } + + /** + * Sets the labels on an Address. To learn more about labels, read the Labeling Resources documentation. + * + * The async variant is {@see AddressesClient::setLabelsAsync()} . + * + * @param SetLabelsAddressRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setLabels(SetLabelsAddressRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/AutoscalersClient.php b/Compute/src/V1/Client/AutoscalersClient.php index 5bb07376df2b..8822fb816ae7 100644 --- a/Compute/src/V1/Client/AutoscalersClient.php +++ b/Compute/src/V1/Client/AutoscalersClient.php @@ -24,17 +24,385 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\AutoscalersBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListAutoscalersRequest; +use Google\Cloud\Compute\V1\Autoscaler; +use Google\Cloud\Compute\V1\DeleteAutoscalerRequest; +use Google\Cloud\Compute\V1\GetAutoscalerRequest; +use Google\Cloud\Compute\V1\InsertAutoscalerRequest; +use Google\Cloud\Compute\V1\ListAutoscalersRequest; +use Google\Cloud\Compute\V1\PatchAutoscalerRequest; +use Google\Cloud\Compute\V1\UpdateAutoscalerRequest; +use Google\Cloud\Compute\V1\ZoneOperationsClient; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Autoscalers API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\AutoscalersClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListAutoscalersRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteAutoscalerRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetAutoscalerRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertAutoscalerRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListAutoscalersRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchAutoscalerRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAsync(UpdateAutoscalerRequest $request, array $optionalArgs = []) */ -final class AutoscalersClient extends AutoscalersBaseClient +final class AutoscalersClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AutoscalersBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.Autoscalers'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/autoscalers_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/autoscalers_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/autoscalers_rest_client_config.php', + ], + ], + 'operationsClientClass' => ZoneOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an ZoneOperationsClient object with the same endpoint as $this. + * + * @return ZoneOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getZone', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves an aggregated list of autoscalers. + * + * The async variant is {@see AutoscalersClient::aggregatedListAsync()} . + * + * @param AggregatedListAutoscalersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListAutoscalersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified autoscaler. + * + * The async variant is {@see AutoscalersClient::deleteAsync()} . + * + * @param DeleteAutoscalerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteAutoscalerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified autoscaler resource. + * + * The async variant is {@see AutoscalersClient::getAsync()} . + * + * @param GetAutoscalerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Autoscaler + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetAutoscalerRequest $request, array $callOptions = []): Autoscaler + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates an autoscaler in the specified project using the data included in the request. + * + * The async variant is {@see AutoscalersClient::insertAsync()} . + * + * @param InsertAutoscalerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertAutoscalerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of autoscalers contained within the specified zone. + * + * The async variant is {@see AutoscalersClient::listAsync()} . + * + * @param ListAutoscalersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListAutoscalersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Updates an autoscaler in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * The async variant is {@see AutoscalersClient::patchAsync()} . + * + * @param PatchAutoscalerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchAutoscalerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Updates an autoscaler in the specified project using the data included in the request. + * + * The async variant is {@see AutoscalersClient::updateAsync()} . + * + * @param UpdateAutoscalerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function update(UpdateAutoscalerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Update', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/BackendBucketsClient.php b/Compute/src/V1/Client/BackendBucketsClient.php index 693ab2ddff14..d7753156072d 100644 --- a/Compute/src/V1/Client/BackendBucketsClient.php +++ b/Compute/src/V1/Client/BackendBucketsClient.php @@ -24,17 +24,436 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\BackendBucketsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AddSignedUrlKeyBackendBucketRequest; +use Google\Cloud\Compute\V1\BackendBucket; +use Google\Cloud\Compute\V1\DeleteBackendBucketRequest; +use Google\Cloud\Compute\V1\DeleteSignedUrlKeyBackendBucketRequest; +use Google\Cloud\Compute\V1\GetBackendBucketRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertBackendBucketRequest; +use Google\Cloud\Compute\V1\ListBackendBucketsRequest; +use Google\Cloud\Compute\V1\PatchBackendBucketRequest; +use Google\Cloud\Compute\V1\SetEdgeSecurityPolicyBackendBucketRequest; +use Google\Cloud\Compute\V1\UpdateBackendBucketRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The BackendBuckets API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\BackendBucketsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface addSignedUrlKeyAsync(AddSignedUrlKeyBackendBucketRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteBackendBucketRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSignedUrlKeyAsync(DeleteSignedUrlKeyBackendBucketRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetBackendBucketRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertBackendBucketRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListBackendBucketsRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchBackendBucketRequest $request, array $optionalArgs = []) + * @method PromiseInterface setEdgeSecurityPolicyAsync(SetEdgeSecurityPolicyBackendBucketRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAsync(UpdateBackendBucketRequest $request, array $optionalArgs = []) */ -final class BackendBucketsClient extends BackendBucketsBaseClient +final class BackendBucketsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see BackendBucketsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.BackendBuckets'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/backend_buckets_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/backend_buckets_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/backend_buckets_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Adds a key for validating requests with signed URLs for this backend bucket. + * + * The async variant is {@see BackendBucketsClient::addSignedUrlKeyAsync()} . + * + * @param AddSignedUrlKeyBackendBucketRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addSignedUrlKey(AddSignedUrlKeyBackendBucketRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddSignedUrlKey', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified BackendBucket resource. + * + * The async variant is {@see BackendBucketsClient::deleteAsync()} . + * + * @param DeleteBackendBucketRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteBackendBucketRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Deletes a key for validating requests with signed URLs for this backend bucket. + * + * The async variant is {@see BackendBucketsClient::deleteSignedUrlKeyAsync()} . + * + * @param DeleteSignedUrlKeyBackendBucketRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSignedUrlKey(DeleteSignedUrlKeyBackendBucketRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteSignedUrlKey', $request, $callOptions)->wait(); + } + + /** + * Returns the specified BackendBucket resource. + * + * The async variant is {@see BackendBucketsClient::getAsync()} . + * + * @param GetBackendBucketRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BackendBucket + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetBackendBucketRequest $request, array $callOptions = []): BackendBucket + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a BackendBucket resource in the specified project using the data included in the request. + * + * The async variant is {@see BackendBucketsClient::insertAsync()} . + * + * @param InsertBackendBucketRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertBackendBucketRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of BackendBucket resources available to the specified project. + * + * The async variant is {@see BackendBucketsClient::listAsync()} . + * + * @param ListBackendBucketsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListBackendBucketsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Updates the specified BackendBucket resource with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * The async variant is {@see BackendBucketsClient::patchAsync()} . + * + * @param PatchBackendBucketRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchBackendBucketRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Sets the edge security policy for the specified backend bucket. + * + * The async variant is {@see BackendBucketsClient::setEdgeSecurityPolicyAsync()} . + * + * @param SetEdgeSecurityPolicyBackendBucketRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setEdgeSecurityPolicy(SetEdgeSecurityPolicyBackendBucketRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetEdgeSecurityPolicy', $request, $callOptions)->wait(); + } + + /** + * Updates the specified BackendBucket resource with the data included in the request. + * + * The async variant is {@see BackendBucketsClient::updateAsync()} . + * + * @param UpdateBackendBucketRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function update(UpdateBackendBucketRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Update', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/BackendServicesClient.php b/Compute/src/V1/Client/BackendServicesClient.php index 004036a00243..c6aea3bc4e8d 100644 --- a/Compute/src/V1/Client/BackendServicesClient.php +++ b/Compute/src/V1/Client/BackendServicesClient.php @@ -24,17 +24,569 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\BackendServicesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AddSignedUrlKeyBackendServiceRequest; +use Google\Cloud\Compute\V1\AggregatedListBackendServicesRequest; +use Google\Cloud\Compute\V1\BackendService; +use Google\Cloud\Compute\V1\BackendServiceGroupHealth; +use Google\Cloud\Compute\V1\DeleteBackendServiceRequest; +use Google\Cloud\Compute\V1\DeleteSignedUrlKeyBackendServiceRequest; +use Google\Cloud\Compute\V1\GetBackendServiceRequest; +use Google\Cloud\Compute\V1\GetHealthBackendServiceRequest; +use Google\Cloud\Compute\V1\GetIamPolicyBackendServiceRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertBackendServiceRequest; +use Google\Cloud\Compute\V1\ListBackendServicesRequest; +use Google\Cloud\Compute\V1\PatchBackendServiceRequest; +use Google\Cloud\Compute\V1\Policy; +use Google\Cloud\Compute\V1\SetEdgeSecurityPolicyBackendServiceRequest; +use Google\Cloud\Compute\V1\SetIamPolicyBackendServiceRequest; +use Google\Cloud\Compute\V1\SetSecurityPolicyBackendServiceRequest; +use Google\Cloud\Compute\V1\UpdateBackendServiceRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The BackendServices API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\BackendServicesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface addSignedUrlKeyAsync(AddSignedUrlKeyBackendServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface aggregatedListAsync(AggregatedListBackendServicesRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteBackendServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSignedUrlKeyAsync(DeleteSignedUrlKeyBackendServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetBackendServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getHealthAsync(GetHealthBackendServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyBackendServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertBackendServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListBackendServicesRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchBackendServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setEdgeSecurityPolicyAsync(SetEdgeSecurityPolicyBackendServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyBackendServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setSecurityPolicyAsync(SetSecurityPolicyBackendServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAsync(UpdateBackendServiceRequest $request, array $optionalArgs = []) */ -final class BackendServicesClient extends BackendServicesBaseClient +final class BackendServicesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see BackendServicesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.BackendServices'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/backend_services_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/backend_services_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/backend_services_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Adds a key for validating requests with signed URLs for this backend service. + * + * The async variant is {@see BackendServicesClient::addSignedUrlKeyAsync()} . + * + * @param AddSignedUrlKeyBackendServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addSignedUrlKey(AddSignedUrlKeyBackendServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddSignedUrlKey', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of all BackendService resources, regional and global, available to the specified project. + * + * The async variant is {@see BackendServicesClient::aggregatedListAsync()} . + * + * @param AggregatedListBackendServicesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListBackendServicesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified BackendService resource. + * + * The async variant is {@see BackendServicesClient::deleteAsync()} . + * + * @param DeleteBackendServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteBackendServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Deletes a key for validating requests with signed URLs for this backend service. + * + * The async variant is {@see BackendServicesClient::deleteSignedUrlKeyAsync()} . + * + * @param DeleteSignedUrlKeyBackendServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSignedUrlKey(DeleteSignedUrlKeyBackendServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteSignedUrlKey', $request, $callOptions)->wait(); + } + + /** + * Returns the specified BackendService resource. + * + * The async variant is {@see BackendServicesClient::getAsync()} . + * + * @param GetBackendServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BackendService + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetBackendServiceRequest $request, array $callOptions = []): BackendService + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Gets the most recent health check results for this BackendService. Example request body: { "group": "/zones/us-east1-b/instanceGroups/lb-backend-example" } + * + * The async variant is {@see BackendServicesClient::getHealthAsync()} . + * + * @param GetHealthBackendServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BackendServiceGroupHealth + * + * @throws ApiException Thrown if the API call fails. + */ + public function getHealth(GetHealthBackendServiceRequest $request, array $callOptions = []): BackendServiceGroupHealth + { + return $this->startApiCall('GetHealth', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * The async variant is {@see BackendServicesClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyBackendServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyBackendServiceRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Creates a BackendService resource in the specified project using the data included in the request. For more information, see Backend services overview . + * + * The async variant is {@see BackendServicesClient::insertAsync()} . + * + * @param InsertBackendServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertBackendServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of BackendService resources available to the specified project. + * + * The async variant is {@see BackendServicesClient::listAsync()} . + * + * @param ListBackendServicesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListBackendServicesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Patches the specified BackendService resource with the data included in the request. For more information, see Backend services overview. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * The async variant is {@see BackendServicesClient::patchAsync()} . + * + * @param PatchBackendServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchBackendServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Sets the edge security policy for the specified backend service. + * + * The async variant is {@see BackendServicesClient::setEdgeSecurityPolicyAsync()} + * . + * + * @param SetEdgeSecurityPolicyBackendServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setEdgeSecurityPolicy(SetEdgeSecurityPolicyBackendServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetEdgeSecurityPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * The async variant is {@see BackendServicesClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyBackendServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyBackendServiceRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the Google Cloud Armor security policy for the specified backend service. For more information, see Google Cloud Armor Overview + * + * The async variant is {@see BackendServicesClient::setSecurityPolicyAsync()} . + * + * @param SetSecurityPolicyBackendServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setSecurityPolicy(SetSecurityPolicyBackendServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetSecurityPolicy', $request, $callOptions)->wait(); + } + + /** + * Updates the specified BackendService resource with the data included in the request. For more information, see Backend services overview. + * + * The async variant is {@see BackendServicesClient::updateAsync()} . + * + * @param UpdateBackendServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function update(UpdateBackendServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Update', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/BaseClient/AcceleratorTypesBaseClient.php b/Compute/src/V1/Client/BaseClient/AcceleratorTypesBaseClient.php deleted file mode 100644 index 72a7f15e10ca..000000000000 --- a/Compute/src/V1/Client/BaseClient/AcceleratorTypesBaseClient.php +++ /dev/null @@ -1,256 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/accelerator_types_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/accelerator_types_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/accelerator_types_rest_client_config.php', - ], - ], - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves an aggregated list of accelerator types. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListAcceleratorTypesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListAcceleratorTypesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Returns the specified accelerator type. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetAcceleratorTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AcceleratorType - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetAcceleratorTypeRequest $request, array $callOptions = []): AcceleratorType - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of accelerator types that are available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListAcceleratorTypesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListAcceleratorTypesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } -} diff --git a/Compute/src/V1/Client/BaseClient/AddressesBaseClient.php b/Compute/src/V1/Client/BaseClient/AddressesBaseClient.php deleted file mode 100644 index 4a1c0467b13f..000000000000 --- a/Compute/src/V1/Client/BaseClient/AddressesBaseClient.php +++ /dev/null @@ -1,410 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/addresses_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/addresses_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/addresses_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves an aggregated list of addresses. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListAddressesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListAddressesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified address resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteAddressRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteAddressRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified address resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetAddressRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Address - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetAddressRequest $request, array $callOptions = []): Address - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates an address resource in the specified project by using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertAddressRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertAddressRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of addresses contained within the specified region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListAddressesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListAddressesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Moves the specified address resource. - * - * The async variant is {@see self::moveAsync()} . - * - * @param MoveAddressRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function move(MoveAddressRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Move', $request, $callOptions)->wait(); - } - - /** - * Sets the labels on an Address. To learn more about labels, read the Labeling Resources documentation. - * - * The async variant is {@see self::setLabelsAsync()} . - * - * @param SetLabelsAddressRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setLabels(SetLabelsAddressRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/AutoscalersBaseClient.php b/Compute/src/V1/Client/BaseClient/AutoscalersBaseClient.php deleted file mode 100644 index c000af64e90e..000000000000 --- a/Compute/src/V1/Client/BaseClient/AutoscalersBaseClient.php +++ /dev/null @@ -1,410 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/autoscalers_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/autoscalers_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/autoscalers_rest_client_config.php', - ], - ], - 'operationsClientClass' => ZoneOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an ZoneOperationsClient object with the same endpoint as $this. - * - * @return ZoneOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getZone', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves an aggregated list of autoscalers. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListAutoscalersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListAutoscalersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified autoscaler. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteAutoscalerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteAutoscalerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified autoscaler resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetAutoscalerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Autoscaler - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetAutoscalerRequest $request, array $callOptions = []): Autoscaler - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates an autoscaler in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertAutoscalerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertAutoscalerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of autoscalers contained within the specified zone. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListAutoscalersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListAutoscalersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Updates an autoscaler in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchAutoscalerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchAutoscalerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Updates an autoscaler in the specified project using the data included in the request. - * - * The async variant is {@see self::updateAsync()} . - * - * @param UpdateAutoscalerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function update(UpdateAutoscalerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Update', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/BackendBucketsBaseClient.php b/Compute/src/V1/Client/BaseClient/BackendBucketsBaseClient.php deleted file mode 100644 index c6ae3721668a..000000000000 --- a/Compute/src/V1/Client/BaseClient/BackendBucketsBaseClient.php +++ /dev/null @@ -1,461 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/backend_buckets_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/backend_buckets_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/backend_buckets_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Adds a key for validating requests with signed URLs for this backend bucket. - * - * The async variant is {@see self::addSignedUrlKeyAsync()} . - * - * @param AddSignedUrlKeyBackendBucketRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addSignedUrlKey(AddSignedUrlKeyBackendBucketRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AddSignedUrlKey', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified BackendBucket resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteBackendBucketRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteBackendBucketRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Deletes a key for validating requests with signed URLs for this backend bucket. - * - * The async variant is {@see self::deleteSignedUrlKeyAsync()} . - * - * @param DeleteSignedUrlKeyBackendBucketRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSignedUrlKey(DeleteSignedUrlKeyBackendBucketRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteSignedUrlKey', $request, $callOptions)->wait(); - } - - /** - * Returns the specified BackendBucket resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetBackendBucketRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BackendBucket - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetBackendBucketRequest $request, array $callOptions = []): BackendBucket - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a BackendBucket resource in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertBackendBucketRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertBackendBucketRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of BackendBucket resources available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListBackendBucketsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListBackendBucketsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Updates the specified BackendBucket resource with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchBackendBucketRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchBackendBucketRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Sets the edge security policy for the specified backend bucket. - * - * The async variant is {@see self::setEdgeSecurityPolicyAsync()} . - * - * @param SetEdgeSecurityPolicyBackendBucketRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setEdgeSecurityPolicy(SetEdgeSecurityPolicyBackendBucketRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetEdgeSecurityPolicy', $request, $callOptions)->wait(); - } - - /** - * Updates the specified BackendBucket resource with the data included in the request. - * - * The async variant is {@see self::updateAsync()} . - * - * @param UpdateBackendBucketRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function update(UpdateBackendBucketRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Update', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/BackendServicesBaseClient.php b/Compute/src/V1/Client/BaseClient/BackendServicesBaseClient.php deleted file mode 100644 index a8938211fdf0..000000000000 --- a/Compute/src/V1/Client/BaseClient/BackendServicesBaseClient.php +++ /dev/null @@ -1,593 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/backend_services_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/backend_services_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/backend_services_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Adds a key for validating requests with signed URLs for this backend service. - * - * The async variant is {@see self::addSignedUrlKeyAsync()} . - * - * @param AddSignedUrlKeyBackendServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addSignedUrlKey(AddSignedUrlKeyBackendServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AddSignedUrlKey', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of all BackendService resources, regional and global, available to the specified project. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListBackendServicesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListBackendServicesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified BackendService resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteBackendServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteBackendServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Deletes a key for validating requests with signed URLs for this backend service. - * - * The async variant is {@see self::deleteSignedUrlKeyAsync()} . - * - * @param DeleteSignedUrlKeyBackendServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSignedUrlKey(DeleteSignedUrlKeyBackendServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteSignedUrlKey', $request, $callOptions)->wait(); - } - - /** - * Returns the specified BackendService resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetBackendServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BackendService - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetBackendServiceRequest $request, array $callOptions = []): BackendService - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Gets the most recent health check results for this BackendService. Example request body: { "group": "/zones/us-east1-b/instanceGroups/lb-backend-example" } - * - * The async variant is {@see self::getHealthAsync()} . - * - * @param GetHealthBackendServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BackendServiceGroupHealth - * - * @throws ApiException Thrown if the API call fails. - */ - public function getHealth(GetHealthBackendServiceRequest $request, array $callOptions = []): BackendServiceGroupHealth - { - return $this->startApiCall('GetHealth', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. May be empty if no such policy or resource exists. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyBackendServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyBackendServiceRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Creates a BackendService resource in the specified project using the data included in the request. For more information, see Backend services overview . - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertBackendServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertBackendServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of BackendService resources available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListBackendServicesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListBackendServicesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Patches the specified BackendService resource with the data included in the request. For more information, see Backend services overview. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchBackendServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchBackendServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Sets the edge security policy for the specified backend service. - * - * The async variant is {@see self::setEdgeSecurityPolicyAsync()} . - * - * @param SetEdgeSecurityPolicyBackendServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setEdgeSecurityPolicy(SetEdgeSecurityPolicyBackendServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetEdgeSecurityPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyBackendServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyBackendServiceRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the Google Cloud Armor security policy for the specified backend service. For more information, see Google Cloud Armor Overview - * - * The async variant is {@see self::setSecurityPolicyAsync()} . - * - * @param SetSecurityPolicyBackendServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setSecurityPolicy(SetSecurityPolicyBackendServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetSecurityPolicy', $request, $callOptions)->wait(); - } - - /** - * Updates the specified BackendService resource with the data included in the request. For more information, see Backend services overview. - * - * The async variant is {@see self::updateAsync()} . - * - * @param UpdateBackendServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function update(UpdateBackendServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Update', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/DiskTypesBaseClient.php b/Compute/src/V1/Client/BaseClient/DiskTypesBaseClient.php deleted file mode 100644 index e475e128af70..000000000000 --- a/Compute/src/V1/Client/BaseClient/DiskTypesBaseClient.php +++ /dev/null @@ -1,253 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/disk_types_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/disk_types_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/disk_types_rest_client_config.php', - ], - ], - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves an aggregated list of disk types. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListDiskTypesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListDiskTypesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Returns the specified disk type. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetDiskTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DiskType - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetDiskTypeRequest $request, array $callOptions = []): DiskType - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of disk types available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListDiskTypesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListDiskTypesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } -} diff --git a/Compute/src/V1/Client/BaseClient/DisksBaseClient.php b/Compute/src/V1/Client/BaseClient/DisksBaseClient.php deleted file mode 100644 index ee1c0d91e159..000000000000 --- a/Compute/src/V1/Client/BaseClient/DisksBaseClient.php +++ /dev/null @@ -1,698 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/disks_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/disks_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/disks_rest_client_config.php', - ], - ], - 'operationsClientClass' => ZoneOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an ZoneOperationsClient object with the same endpoint as $this. - * - * @return ZoneOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getZone', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Adds existing resource policies to a disk. You can only add one policy which will be applied to this disk for scheduling snapshot creation. - * - * The async variant is {@see self::addResourcePoliciesAsync()} . - * - * @param AddResourcePoliciesDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addResourcePolicies(AddResourcePoliciesDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AddResourcePolicies', $request, $callOptions)->wait(); - } - - /** - * Retrieves an aggregated list of persistent disks. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListDisksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListDisksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Bulk create a set of disks. - * - * The async variant is {@see self::bulkInsertAsync()} . - * - * @param BulkInsertDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function bulkInsert(BulkInsertDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BulkInsert', $request, $callOptions)->wait(); - } - - /** - * Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider using snapshots.insert instead, as that method supports more features, such as creating snapshots in a project different from the source disk project. - * - * The async variant is {@see self::createSnapshotAsync()} . - * - * @param CreateSnapshotDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSnapshot(CreateSnapshotDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateSnapshot', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified persistent disk. Deleting a disk removes its data permanently and is irreversible. However, deleting a disk does not delete any snapshots previously made from the disk. You must separately delete snapshots. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified persistent disk. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Disk - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetDiskRequest $request, array $callOptions = []): Disk - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. May be empty if no such policy or resource exists. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyDiskRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Creates a persistent disk in the specified project using the data in the request. You can create a disk from a source (sourceImage, sourceSnapshot, or sourceDisk) or create an empty 500 GB data disk by omitting all properties. You can also create a disk that is larger than the default size by specifying the sizeGb property. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of persistent disks contained within the specified zone. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListDisksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListDisksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Removes resource policies from a disk. - * - * The async variant is {@see self::removeResourcePoliciesAsync()} . - * - * @param RemoveResourcePoliciesDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function removeResourcePolicies(RemoveResourcePoliciesDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RemoveResourcePolicies', $request, $callOptions)->wait(); - } - - /** - * Resizes the specified persistent disk. You can only increase the size of the disk. - * - * The async variant is {@see self::resizeAsync()} . - * - * @param ResizeDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function resize(ResizeDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Resize', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyDiskRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the labels on a disk. To learn more about labels, read the Labeling Resources documentation. - * - * The async variant is {@see self::setLabelsAsync()} . - * - * @param SetLabelsDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setLabels(SetLabelsDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); - } - - /** - * Starts asynchronous replication. Must be invoked on the primary disk. - * - * The async variant is {@see self::startAsyncReplicationAsync()} . - * - * @param StartAsyncReplicationDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function startAsyncReplication(StartAsyncReplicationDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StartAsyncReplication', $request, $callOptions)->wait(); - } - - /** - * Stops asynchronous replication. Can be invoked either on the primary or on the secondary disk. - * - * The async variant is {@see self::stopAsyncReplicationAsync()} . - * - * @param StopAsyncReplicationDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function stopAsyncReplication(StopAsyncReplicationDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StopAsyncReplication', $request, $callOptions)->wait(); - } - - /** - * Stops asynchronous replication for a consistency group of disks. Can be invoked either in the primary or secondary scope. - * - * The async variant is {@see self::stopGroupAsyncReplicationAsync()} . - * - * @param StopGroupAsyncReplicationDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function stopGroupAsyncReplication(StopGroupAsyncReplicationDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StopGroupAsyncReplication', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsDiskRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Updates the specified disk with the data included in the request. The update is performed only on selected fields included as part of update-mask. Only the following fields can be modified: user_license. - * - * The async variant is {@see self::updateAsync()} . - * - * @param UpdateDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function update(UpdateDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Update', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/ExternalVpnGatewaysBaseClient.php b/Compute/src/V1/Client/BaseClient/ExternalVpnGatewaysBaseClient.php deleted file mode 100644 index 6e3d967171b9..000000000000 --- a/Compute/src/V1/Client/BaseClient/ExternalVpnGatewaysBaseClient.php +++ /dev/null @@ -1,385 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/external_vpn_gateways_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/external_vpn_gateways_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/external_vpn_gateways_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified externalVpnGateway. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteExternalVpnGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteExternalVpnGatewayRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified externalVpnGateway. Get a list of available externalVpnGateways by making a list() request. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetExternalVpnGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ExternalVpnGateway - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetExternalVpnGatewayRequest $request, array $callOptions = []): ExternalVpnGateway - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a ExternalVpnGateway in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertExternalVpnGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertExternalVpnGatewayRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of ExternalVpnGateway available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListExternalVpnGatewaysRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListExternalVpnGatewaysRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Sets the labels on an ExternalVpnGateway. To learn more about labels, read the Labeling Resources documentation. - * - * The async variant is {@see self::setLabelsAsync()} . - * - * @param SetLabelsExternalVpnGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setLabels(SetLabelsExternalVpnGatewayRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsExternalVpnGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsExternalVpnGatewayRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/FirewallPoliciesBaseClient.php b/Compute/src/V1/Client/BaseClient/FirewallPoliciesBaseClient.php deleted file mode 100644 index 99fe02a8686a..000000000000 --- a/Compute/src/V1/Client/BaseClient/FirewallPoliciesBaseClient.php +++ /dev/null @@ -1,699 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/firewall_policies_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/firewall_policies_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/firewall_policies_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOrganizationOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOrganizationOperationsClient object with the same endpoint as - * $this. - * - * @return GlobalOrganizationOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Inserts an association for the specified firewall policy. - * - * The async variant is {@see self::addAssociationAsync()} . - * - * @param AddAssociationFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addAssociation(AddAssociationFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AddAssociation', $request, $callOptions)->wait(); - } - - /** - * Inserts a rule into a firewall policy. - * - * The async variant is {@see self::addRuleAsync()} . - * - * @param AddRuleFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addRule(AddRuleFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AddRule', $request, $callOptions)->wait(); - } - - /** - * Copies rules to the specified firewall policy. - * - * The async variant is {@see self::cloneRulesAsync()} . - * - * @param CloneRulesFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function cloneRules(CloneRulesFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CloneRules', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified policy. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified firewall policy. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FirewallPolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicy - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Gets an association with the specified name. - * - * The async variant is {@see self::getAssociationAsync()} . - * - * @param GetAssociationFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FirewallPolicyAssociation - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAssociation(GetAssociationFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicyAssociation - { - return $this->startApiCall('GetAssociation', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. May be empty if no such policy or resource exists. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyFirewallPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets a rule of the specified priority. - * - * The async variant is {@see self::getRuleAsync()} . - * - * @param GetRuleFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FirewallPolicyRule - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRule(GetRuleFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicyRule - { - return $this->startApiCall('GetRule', $request, $callOptions)->wait(); - } - - /** - * Creates a new policy in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Lists all the policies that have been configured for the specified folder or organization. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListFirewallPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListFirewallPoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Lists associations of a specified target, i.e., organization or folder. - * - * The async variant is {@see self::listAssociationsAsync()} . - * - * @param ListAssociationsFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FirewallPoliciesListAssociationsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAssociations(ListAssociationsFirewallPolicyRequest $request, array $callOptions = []): FirewallPoliciesListAssociationsResponse - { - return $this->startApiCall('ListAssociations', $request, $callOptions)->wait(); - } - - /** - * Moves the specified firewall policy. - * - * The async variant is {@see self::moveAsync()} . - * - * @param MoveFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function move(MoveFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Move', $request, $callOptions)->wait(); - } - - /** - * Patches the specified policy with the data included in the request. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Patches a rule of the specified priority. - * - * The async variant is {@see self::patchRuleAsync()} . - * - * @param PatchRuleFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patchRule(PatchRuleFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('PatchRule', $request, $callOptions)->wait(); - } - - /** - * Removes an association for the specified firewall policy. - * - * The async variant is {@see self::removeAssociationAsync()} . - * - * @param RemoveAssociationFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function removeAssociation(RemoveAssociationFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RemoveAssociation', $request, $callOptions)->wait(); - } - - /** - * Deletes a rule of the specified priority. - * - * The async variant is {@see self::removeRuleAsync()} . - * - * @param RemoveRuleFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function removeRule(RemoveRuleFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RemoveRule', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyFirewallPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsFirewallPolicyRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/FirewallsBaseClient.php b/Compute/src/V1/Client/BaseClient/FirewallsBaseClient.php deleted file mode 100644 index 65de747c4714..000000000000 --- a/Compute/src/V1/Client/BaseClient/FirewallsBaseClient.php +++ /dev/null @@ -1,383 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/firewalls_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/firewalls_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/firewalls_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified firewall. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteFirewallRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteFirewallRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified firewall. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetFirewallRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Firewall - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetFirewallRequest $request, array $callOptions = []): Firewall - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a firewall rule in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertFirewallRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertFirewallRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of firewall rules available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListFirewallsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListFirewallsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Updates the specified firewall rule with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchFirewallRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchFirewallRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Updates the specified firewall rule with the data included in the request. Note that all fields will be updated if using PUT, even fields that are not specified. To update individual fields, please use PATCH instead. - * - * The async variant is {@see self::updateAsync()} . - * - * @param UpdateFirewallRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function update(UpdateFirewallRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Update', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/ForwardingRulesBaseClient.php b/Compute/src/V1/Client/BaseClient/ForwardingRulesBaseClient.php deleted file mode 100644 index b51362916d03..000000000000 --- a/Compute/src/V1/Client/BaseClient/ForwardingRulesBaseClient.php +++ /dev/null @@ -1,436 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/forwarding_rules_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/forwarding_rules_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/forwarding_rules_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves an aggregated list of forwarding rules. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListForwardingRulesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListForwardingRulesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified ForwardingRule resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteForwardingRuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteForwardingRuleRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified ForwardingRule resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetForwardingRuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ForwardingRule - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetForwardingRuleRequest $request, array $callOptions = []): ForwardingRule - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a ForwardingRule resource in the specified project and region using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertForwardingRuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertForwardingRuleRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of ForwardingRule resources available to the specified project and region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListForwardingRulesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListForwardingRulesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Updates the specified forwarding rule with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. Currently, you can only patch the network_tier field. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchForwardingRuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchForwardingRuleRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Sets the labels on the specified resource. To learn more about labels, read the Labeling Resources documentation. - * - * The async variant is {@see self::setLabelsAsync()} . - * - * @param SetLabelsForwardingRuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setLabels(SetLabelsForwardingRuleRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); - } - - /** - * Changes target URL for forwarding rule. The new target should be of the same type as the old target. - * - * The async variant is {@see self::setTargetAsync()} . - * - * @param SetTargetForwardingRuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setTarget(SetTargetForwardingRuleRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetTarget', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/GlobalAddressesBaseClient.php b/Compute/src/V1/Client/BaseClient/GlobalAddressesBaseClient.php deleted file mode 100644 index 3b070b10e3b2..000000000000 --- a/Compute/src/V1/Client/BaseClient/GlobalAddressesBaseClient.php +++ /dev/null @@ -1,383 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/global_addresses_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/global_addresses_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/global_addresses_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified address resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteGlobalAddressRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteGlobalAddressRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified address resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetGlobalAddressRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Address - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetGlobalAddressRequest $request, array $callOptions = []): Address - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates an address resource in the specified project by using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertGlobalAddressRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertGlobalAddressRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of global addresses. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListGlobalAddressesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListGlobalAddressesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Moves the specified address resource from one project to another project. - * - * The async variant is {@see self::moveAsync()} . - * - * @param MoveGlobalAddressRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function move(MoveGlobalAddressRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Move', $request, $callOptions)->wait(); - } - - /** - * Sets the labels on a GlobalAddress. To learn more about labels, read the Labeling Resources documentation. - * - * The async variant is {@see self::setLabelsAsync()} . - * - * @param SetLabelsGlobalAddressRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setLabels(SetLabelsGlobalAddressRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/GlobalForwardingRulesBaseClient.php b/Compute/src/V1/Client/BaseClient/GlobalForwardingRulesBaseClient.php deleted file mode 100644 index 1fbd11968504..000000000000 --- a/Compute/src/V1/Client/BaseClient/GlobalForwardingRulesBaseClient.php +++ /dev/null @@ -1,410 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/global_forwarding_rules_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/global_forwarding_rules_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/global_forwarding_rules_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified GlobalForwardingRule resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteGlobalForwardingRuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteGlobalForwardingRuleRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified GlobalForwardingRule resource. Gets a list of available forwarding rules by making a list() request. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetGlobalForwardingRuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ForwardingRule - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetGlobalForwardingRuleRequest $request, array $callOptions = []): ForwardingRule - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a GlobalForwardingRule resource in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertGlobalForwardingRuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertGlobalForwardingRuleRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of GlobalForwardingRule resources available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListGlobalForwardingRulesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListGlobalForwardingRulesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Updates the specified forwarding rule with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. Currently, you can only patch the network_tier field. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchGlobalForwardingRuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchGlobalForwardingRuleRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Sets the labels on the specified resource. To learn more about labels, read the Labeling resources documentation. - * - * The async variant is {@see self::setLabelsAsync()} . - * - * @param SetLabelsGlobalForwardingRuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setLabels(SetLabelsGlobalForwardingRuleRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); - } - - /** - * Changes target URL for the GlobalForwardingRule resource. The new target should be of the same type as the old target. - * - * The async variant is {@see self::setTargetAsync()} . - * - * @param SetTargetGlobalForwardingRuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setTarget(SetTargetGlobalForwardingRuleRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetTarget', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/GlobalNetworkEndpointGroupsBaseClient.php b/Compute/src/V1/Client/BaseClient/GlobalNetworkEndpointGroupsBaseClient.php deleted file mode 100644 index db7e23cfcb29..000000000000 --- a/Compute/src/V1/Client/BaseClient/GlobalNetworkEndpointGroupsBaseClient.php +++ /dev/null @@ -1,410 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/global_network_endpoint_groups_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/global_network_endpoint_groups_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/global_network_endpoint_groups_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Attach a network endpoint to the specified network endpoint group. - * - * The async variant is {@see self::attachNetworkEndpointsAsync()} . - * - * @param AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function attachNetworkEndpoints(AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AttachNetworkEndpoints', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified network endpoint group.Note that the NEG cannot be deleted if there are backend services referencing it. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteGlobalNetworkEndpointGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteGlobalNetworkEndpointGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Detach the network endpoint from the specified network endpoint group. - * - * The async variant is {@see self::detachNetworkEndpointsAsync()} . - * - * @param DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function detachNetworkEndpoints(DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DetachNetworkEndpoints', $request, $callOptions)->wait(); - } - - /** - * Returns the specified network endpoint group. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetGlobalNetworkEndpointGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NetworkEndpointGroup - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetGlobalNetworkEndpointGroupRequest $request, array $callOptions = []): NetworkEndpointGroup - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a network endpoint group in the specified project using the parameters that are included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertGlobalNetworkEndpointGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertGlobalNetworkEndpointGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of network endpoint groups that are located in the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListGlobalNetworkEndpointGroupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListGlobalNetworkEndpointGroupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Lists the network endpoints in the specified network endpoint group. - * - * The async variant is {@see self::listNetworkEndpointsAsync()} . - * - * @param ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listNetworkEndpoints(ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListNetworkEndpoints', $request, $callOptions); - } -} diff --git a/Compute/src/V1/Client/BaseClient/GlobalOperationsBaseClient.php b/Compute/src/V1/Client/BaseClient/GlobalOperationsBaseClient.php deleted file mode 100644 index 888f0c3192d1..000000000000 --- a/Compute/src/V1/Client/BaseClient/GlobalOperationsBaseClient.php +++ /dev/null @@ -1,305 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/global_operations_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/global_operations_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/global_operations_rest_client_config.php', - ], - ], - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves an aggregated list of all operations. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListGlobalOperationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListGlobalOperationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified Operations resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteGlobalOperationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DeleteGlobalOperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteGlobalOperationRequest $request, array $callOptions = []): DeleteGlobalOperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Retrieves the specified Operations resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetGlobalOperationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetGlobalOperationRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of Operation resources contained within the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListGlobalOperationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListGlobalOperationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method differs from the `GET` method in that it waits for no more than the default deadline (2 minutes) and then returns the current state of the operation, which might be `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`. - * - * The async variant is {@see self::waitAsync()} . - * - * @param WaitGlobalOperationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function wait(WaitGlobalOperationRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Wait', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/GlobalOrganizationOperationsBaseClient.php b/Compute/src/V1/Client/BaseClient/GlobalOrganizationOperationsBaseClient.php deleted file mode 100644 index b551afdb573a..000000000000 --- a/Compute/src/V1/Client/BaseClient/GlobalOrganizationOperationsBaseClient.php +++ /dev/null @@ -1,254 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/global_organization_operations_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/global_organization_operations_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/global_organization_operations_rest_client_config.php', - ], - ], - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified Operations resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteGlobalOrganizationOperationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DeleteGlobalOrganizationOperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteGlobalOrganizationOperationRequest $request, array $callOptions = []): DeleteGlobalOrganizationOperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Retrieves the specified Operations resource. Gets a list of operations by making a `list()` request. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetGlobalOrganizationOperationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetGlobalOrganizationOperationRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of Operation resources contained within the specified organization. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListGlobalOrganizationOperationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListGlobalOrganizationOperationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } -} diff --git a/Compute/src/V1/Client/BaseClient/GlobalPublicDelegatedPrefixesBaseClient.php b/Compute/src/V1/Client/BaseClient/GlobalPublicDelegatedPrefixesBaseClient.php deleted file mode 100644 index 44e466b0d423..000000000000 --- a/Compute/src/V1/Client/BaseClient/GlobalPublicDelegatedPrefixesBaseClient.php +++ /dev/null @@ -1,358 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/global_public_delegated_prefixes_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/global_public_delegated_prefixes_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/global_public_delegated_prefixes_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified global PublicDelegatedPrefix. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteGlobalPublicDelegatedPrefixeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteGlobalPublicDelegatedPrefixeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified global PublicDelegatedPrefix resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetGlobalPublicDelegatedPrefixeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PublicDelegatedPrefix - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetGlobalPublicDelegatedPrefixeRequest $request, array $callOptions = []): PublicDelegatedPrefix - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a global PublicDelegatedPrefix in the specified project using the parameters that are included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertGlobalPublicDelegatedPrefixeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertGlobalPublicDelegatedPrefixeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Lists the global PublicDelegatedPrefixes for a project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListGlobalPublicDelegatedPrefixesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListGlobalPublicDelegatedPrefixesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Patches the specified global PublicDelegatedPrefix resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchGlobalPublicDelegatedPrefixeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchGlobalPublicDelegatedPrefixeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/HealthChecksBaseClient.php b/Compute/src/V1/Client/BaseClient/HealthChecksBaseClient.php deleted file mode 100644 index e308ec0d8d8b..000000000000 --- a/Compute/src/V1/Client/BaseClient/HealthChecksBaseClient.php +++ /dev/null @@ -1,409 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/health_checks_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/health_checks_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/health_checks_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves the list of all HealthCheck resources, regional and global, available to the specified project. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListHealthChecksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListHealthChecksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified HealthCheck resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteHealthCheckRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteHealthCheckRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified HealthCheck resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetHealthCheckRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 HealthCheck - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetHealthCheckRequest $request, array $callOptions = []): HealthCheck - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a HealthCheck resource in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertHealthCheckRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertHealthCheckRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of HealthCheck resources available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListHealthChecksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListHealthChecksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Updates a HealthCheck resource in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchHealthCheckRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchHealthCheckRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Updates a HealthCheck resource in the specified project using the data included in the request. - * - * The async variant is {@see self::updateAsync()} . - * - * @param UpdateHealthCheckRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function update(UpdateHealthCheckRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Update', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/ImageFamilyViewsBaseClient.php b/Compute/src/V1/Client/BaseClient/ImageFamilyViewsBaseClient.php deleted file mode 100644 index 472338c4dc6b..000000000000 --- a/Compute/src/V1/Client/BaseClient/ImageFamilyViewsBaseClient.php +++ /dev/null @@ -1,200 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/image_family_views_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/image_family_views_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/image_family_views_rest_client_config.php', - ], - ], - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Returns the latest image that is part of an image family, is not deprecated and is rolled out in the specified zone. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetImageFamilyViewRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ImageFamilyView - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetImageFamilyViewRequest $request, array $callOptions = []): ImageFamilyView - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/ImagesBaseClient.php b/Compute/src/V1/Client/BaseClient/ImagesBaseClient.php deleted file mode 100644 index e4dcdbb3dc3e..000000000000 --- a/Compute/src/V1/Client/BaseClient/ImagesBaseClient.php +++ /dev/null @@ -1,515 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/images_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/images_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/images_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified image. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteImageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteImageRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Sets the deprecation status of an image. If an empty request body is given, clears the deprecation status instead. - * - * The async variant is {@see self::deprecateAsync()} . - * - * @param DeprecateImageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deprecate(DeprecateImageRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Deprecate', $request, $callOptions)->wait(); - } - - /** - * Returns the specified image. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetImageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Image - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetImageRequest $request, array $callOptions = []): Image - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Returns the latest image that is part of an image family and is not deprecated. For more information on image families, see Public image families documentation. - * - * The async variant is {@see self::getFromFamilyAsync()} . - * - * @param GetFromFamilyImageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Image - * - * @throws ApiException Thrown if the API call fails. - */ - public function getFromFamily(GetFromFamilyImageRequest $request, array $callOptions = []): Image - { - return $this->startApiCall('GetFromFamily', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. May be empty if no such policy or resource exists. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyImageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyImageRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Creates an image in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertImageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertImageRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of custom images available to the specified project. Custom images are images you create that belong to your project. This method does not get any images that belong to other projects, including publicly-available images, like Debian 8. If you want to get a list of publicly-available images, use this method to make a request to the respective image project, such as debian-cloud or windows-cloud. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListImagesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListImagesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Patches the specified image with the data included in the request. Only the following fields can be modified: family, description, deprecation status. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchImageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchImageRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyImageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyImageRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the labels on an image. To learn more about labels, read the Labeling Resources documentation. - * - * The async variant is {@see self::setLabelsAsync()} . - * - * @param SetLabelsImageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setLabels(SetLabelsImageRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsImageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsImageRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/InstanceGroupManagersBaseClient.php b/Compute/src/V1/Client/BaseClient/InstanceGroupManagersBaseClient.php deleted file mode 100644 index f74bf11bbddb..000000000000 --- a/Compute/src/V1/Client/BaseClient/InstanceGroupManagersBaseClient.php +++ /dev/null @@ -1,749 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/instance_group_managers_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/instance_group_managers_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/instance_group_managers_rest_client_config.php', - ], - ], - 'operationsClientClass' => ZoneOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an ZoneOperationsClient object with the same endpoint as $this. - * - * @return ZoneOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getZone', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Flags the specified instances to be removed from the managed instance group. Abandoning an instance does not delete the instance, but it does remove the instance from any target pools that are applied by the managed instance group. This method reduces the targetSize of the managed instance group by the number of instances that you abandon. This operation is marked as DONE when the action is scheduled even if the instances have not yet been removed from the group. You must separately verify the status of the abandoning action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. - * - * The async variant is {@see self::abandonInstancesAsync()} . - * - * @param AbandonInstancesInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function abandonInstances(AbandonInstancesInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AbandonInstances', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of managed instance groups and groups them by zone. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListInstanceGroupManagersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListInstanceGroupManagersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Applies changes to selected instances on the managed instance group. This method can be used to apply new overrides and/or new versions. - * - * The async variant is {@see self::applyUpdatesToInstancesAsync()} . - * - * @param ApplyUpdatesToInstancesInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function applyUpdatesToInstances(ApplyUpdatesToInstancesInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ApplyUpdatesToInstances', $request, $callOptions)->wait(); - } - - /** - * Creates instances with per-instance configurations in this managed instance group. Instances are created using the current instance template. The create instances operation is marked DONE if the createInstances request is successful. The underlying actions take additional time. You must separately verify the status of the creating or actions with the listmanagedinstances method. - * - * The async variant is {@see self::createInstancesAsync()} . - * - * @param CreateInstancesInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createInstances(CreateInstancesInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateInstances', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified managed instance group and all of the instances in that group. Note that the instance group must not belong to a backend service. Read Deleting an instance group for more information. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Flags the specified instances in the managed instance group for immediate deletion. The instances are also removed from any target pools of which they were a member. This method reduces the targetSize of the managed instance group by the number of instances that you delete. This operation is marked as DONE when the action is scheduled even if the instances are still being deleted. You must separately verify the status of the deleting action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. - * - * The async variant is {@see self::deleteInstancesAsync()} . - * - * @param DeleteInstancesInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteInstances(DeleteInstancesInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteInstances', $request, $callOptions)->wait(); - } - - /** - * Deletes selected per-instance configurations for the managed instance group. - * - * The async variant is {@see self::deletePerInstanceConfigsAsync()} . - * - * @param DeletePerInstanceConfigsInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deletePerInstanceConfigs(DeletePerInstanceConfigsInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeletePerInstanceConfigs', $request, $callOptions)->wait(); - } - - /** - * Returns all of the details about the specified managed instance group. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InstanceGroupManager - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetInstanceGroupManagerRequest $request, array $callOptions = []): InstanceGroupManager - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a managed instance group using the information that you specify in the request. After the group is created, instances in the group are created using the specified instance template. This operation is marked as DONE when the group is created even if the instances in the group have not yet been created. You must separately verify the status of the individual instances with the listmanagedinstances method. A managed instance group can have up to 1000 VM instances per group. Please contact Cloud Support if you need an increase in this limit. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of managed instance groups that are contained within the specified project and zone. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListInstanceGroupManagersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListInstanceGroupManagersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Lists all errors thrown by actions on instances for a given managed instance group. The filter and orderBy query parameters are not supported. - * - * The async variant is {@see self::listErrorsAsync()} . - * - * @param ListErrorsInstanceGroupManagersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listErrors(ListErrorsInstanceGroupManagersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListErrors', $request, $callOptions); - } - - /** - * Lists all of the instances in the managed instance group. Each instance in the list has a currentAction, which indicates the action that the managed instance group is performing on the instance. For example, if the group is still creating an instance, the currentAction is CREATING. If a previous action failed, the list displays the errors for that failed action. The orderBy query parameter is not supported. The `pageToken` query parameter is supported only in the alpha and beta API and only if the group's `listManagedInstancesResults` field is set to `PAGINATED`. - * - * The async variant is {@see self::listManagedInstancesAsync()} . - * - * @param ListManagedInstancesInstanceGroupManagersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listManagedInstances(ListManagedInstancesInstanceGroupManagersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListManagedInstances', $request, $callOptions); - } - - /** - * Lists all of the per-instance configurations defined for the managed instance group. The orderBy query parameter is not supported. - * - * The async variant is {@see self::listPerInstanceConfigsAsync()} . - * - * @param ListPerInstanceConfigsInstanceGroupManagersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPerInstanceConfigs(ListPerInstanceConfigsInstanceGroupManagersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPerInstanceConfigs', $request, $callOptions); - } - - /** - * Updates a managed instance group using the information that you specify in the request. This operation is marked as DONE when the group is patched even if the instances in the group are still in the process of being patched. You must separately verify the status of the individual instances with the listManagedInstances method. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. If you update your group to specify a new template or instance configuration, it's possible that your intended specification for each VM in the group is different from the current state of that VM. To learn how to apply an updated configuration to the VMs in a MIG, see Updating instances in a MIG. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Inserts or patches per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch. - * - * The async variant is {@see self::patchPerInstanceConfigsAsync()} . - * - * @param PatchPerInstanceConfigsInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patchPerInstanceConfigs(PatchPerInstanceConfigsInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('PatchPerInstanceConfigs', $request, $callOptions)->wait(); - } - - /** - * Flags the specified VM instances in the managed instance group to be immediately recreated. Each instance is recreated using the group's current configuration. This operation is marked as DONE when the flag is set even if the instances have not yet been recreated. You must separately verify the status of each instance by checking its currentAction field; for more information, see Checking the status of managed instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. - * - * The async variant is {@see self::recreateInstancesAsync()} . - * - * @param RecreateInstancesInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function recreateInstances(RecreateInstancesInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RecreateInstances', $request, $callOptions)->wait(); - } - - /** - * Resizes the managed instance group. If you increase the size, the group creates new instances using the current instance template. If you decrease the size, the group deletes instances. The resize operation is marked DONE when the resize actions are scheduled even if the group has not yet added or deleted any instances. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method. When resizing down, the instance group arbitrarily chooses the order in which VMs are deleted. The group takes into account some VM attributes when making the selection including: + The status of the VM instance. + The health of the VM instance. + The instance template version the VM is based on. + For regional managed instance groups, the location of the VM instance. This list is subject to change. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. - * - * The async variant is {@see self::resizeAsync()} . - * - * @param ResizeInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function resize(ResizeInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Resize', $request, $callOptions)->wait(); - } - - /** - * Specifies the instance template to use when creating new instances in this group. The templates for existing instances in the group do not change unless you run recreateInstances, run applyUpdatesToInstances, or set the group's updatePolicy.type to PROACTIVE. - * - * The async variant is {@see self::setInstanceTemplateAsync()} . - * - * @param SetInstanceTemplateInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setInstanceTemplate(SetInstanceTemplateInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetInstanceTemplate', $request, $callOptions)->wait(); - } - - /** - * Modifies the target pools to which all instances in this managed instance group are assigned. The target pools automatically apply to all of the instances in the managed instance group. This operation is marked DONE when you make the request even if the instances have not yet been added to their target pools. The change might take some time to apply to all of the instances in the group depending on the size of the group. - * - * The async variant is {@see self::setTargetPoolsAsync()} . - * - * @param SetTargetPoolsInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setTargetPools(SetTargetPoolsInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetTargetPools', $request, $callOptions)->wait(); - } - - /** - * Inserts or updates per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch. - * - * The async variant is {@see self::updatePerInstanceConfigsAsync()} . - * - * @param UpdatePerInstanceConfigsInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updatePerInstanceConfigs(UpdatePerInstanceConfigsInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdatePerInstanceConfigs', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/InstanceGroupsBaseClient.php b/Compute/src/V1/Client/BaseClient/InstanceGroupsBaseClient.php deleted file mode 100644 index 7998b02d8ba8..000000000000 --- a/Compute/src/V1/Client/BaseClient/InstanceGroupsBaseClient.php +++ /dev/null @@ -1,462 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/instance_groups_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/instance_groups_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/instance_groups_rest_client_config.php', - ], - ], - 'operationsClientClass' => ZoneOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an ZoneOperationsClient object with the same endpoint as $this. - * - * @return ZoneOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getZone', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Adds a list of instances to the specified instance group. All of the instances in the instance group must be in the same network/subnetwork. Read Adding instances for more information. - * - * The async variant is {@see self::addInstancesAsync()} . - * - * @param AddInstancesInstanceGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addInstances(AddInstancesInstanceGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AddInstances', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of instance groups and sorts them by zone. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListInstanceGroupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListInstanceGroupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified instance group. The instances in the group are not deleted. Note that instance group must not belong to a backend service. Read Deleting an instance group for more information. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteInstanceGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteInstanceGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified zonal instance group. Get a list of available zonal instance groups by making a list() request. For managed instance groups, use the instanceGroupManagers or regionInstanceGroupManagers methods instead. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetInstanceGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InstanceGroup - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetInstanceGroupRequest $request, array $callOptions = []): InstanceGroup - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates an instance group in the specified project using the parameters that are included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertInstanceGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertInstanceGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of zonal instance group resources contained within the specified zone. For managed instance groups, use the instanceGroupManagers or regionInstanceGroupManagers methods instead. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListInstanceGroupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListInstanceGroupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Lists the instances in the specified instance group. The orderBy query parameter is not supported. The filter query parameter is supported, but only for expressions that use `eq` (equal) or `ne` (not equal) operators. - * - * The async variant is {@see self::listInstancesAsync()} . - * - * @param ListInstancesInstanceGroupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listInstances(ListInstancesInstanceGroupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListInstances', $request, $callOptions); - } - - /** - * Removes one or more instances from the specified instance group, but does not delete those instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration before the VM instance is removed or deleted. - * - * The async variant is {@see self::removeInstancesAsync()} . - * - * @param RemoveInstancesInstanceGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function removeInstances(RemoveInstancesInstanceGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RemoveInstances', $request, $callOptions)->wait(); - } - - /** - * Sets the named ports for the specified instance group. - * - * The async variant is {@see self::setNamedPortsAsync()} . - * - * @param SetNamedPortsInstanceGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setNamedPorts(SetNamedPortsInstanceGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetNamedPorts', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/InstanceTemplatesBaseClient.php b/Compute/src/V1/Client/BaseClient/InstanceTemplatesBaseClient.php deleted file mode 100644 index ea7d12e7122f..000000000000 --- a/Compute/src/V1/Client/BaseClient/InstanceTemplatesBaseClient.php +++ /dev/null @@ -1,437 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/instance_templates_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/instance_templates_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/instance_templates_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves the list of all InstanceTemplates resources, regional and global, available to the specified project. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListInstanceTemplatesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListInstanceTemplatesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified instance template. Deleting an instance template is permanent and cannot be undone. It is not possible to delete templates that are already in use by a managed instance group. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteInstanceTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteInstanceTemplateRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified instance template. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetInstanceTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InstanceTemplate - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetInstanceTemplateRequest $request, array $callOptions = []): InstanceTemplate - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. May be empty if no such policy or resource exists. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyInstanceTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyInstanceTemplateRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Creates an instance template in the specified project using the data that is included in the request. If you are creating a new template to update an existing instance group, your new instance template must use the same network or, if applicable, the same subnetwork as the original template. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertInstanceTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertInstanceTemplateRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of instance templates that are contained within the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListInstanceTemplatesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListInstanceTemplatesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyInstanceTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyInstanceTemplateRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsInstanceTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsInstanceTemplateRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/InstancesBaseClient.php b/Compute/src/V1/Client/BaseClient/InstancesBaseClient.php deleted file mode 100644 index 97317f3b74fb..000000000000 --- a/Compute/src/V1/Client/BaseClient/InstancesBaseClient.php +++ /dev/null @@ -1,1432 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/instances_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/instances_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/instances_rest_client_config.php', - ], - ], - 'operationsClientClass' => ZoneOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an ZoneOperationsClient object with the same endpoint as $this. - * - * @return ZoneOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getZone', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Adds an access config to an instance's network interface. - * - * The async variant is {@see self::addAccessConfigAsync()} . - * - * @param AddAccessConfigInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addAccessConfig(AddAccessConfigInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AddAccessConfig', $request, $callOptions)->wait(); - } - - /** - * Adds existing resource policies to an instance. You can only add one policy right now which will be applied to this instance for scheduling live migrations. - * - * The async variant is {@see self::addResourcePoliciesAsync()} . - * - * @param AddResourcePoliciesInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addResourcePolicies(AddResourcePoliciesInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AddResourcePolicies', $request, $callOptions)->wait(); - } - - /** - * Retrieves an aggregated list of all of the instances in your project across all regions and zones. The performance of this method degrades when a filter is specified on a project that has a very large number of instances. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListInstancesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListInstancesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Attaches an existing Disk resource to an instance. You must first create the disk before you can attach it. It is not possible to create and attach a disk at the same time. For more information, read Adding a persistent disk to your instance. - * - * The async variant is {@see self::attachDiskAsync()} . - * - * @param AttachDiskInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function attachDisk(AttachDiskInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AttachDisk', $request, $callOptions)->wait(); - } - - /** - * Creates multiple instances. Count specifies the number of instances to create. For more information, see About bulk creation of VMs. - * - * The async variant is {@see self::bulkInsertAsync()} . - * - * @param BulkInsertInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function bulkInsert(BulkInsertInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BulkInsert', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified Instance resource. For more information, see Deleting an instance. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Deletes an access config from an instance's network interface. - * - * The async variant is {@see self::deleteAccessConfigAsync()} . - * - * @param DeleteAccessConfigInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAccessConfig(DeleteAccessConfigInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteAccessConfig', $request, $callOptions)->wait(); - } - - /** - * Detaches a disk from an instance. - * - * The async variant is {@see self::detachDiskAsync()} . - * - * @param DetachDiskInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function detachDisk(DetachDiskInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DetachDisk', $request, $callOptions)->wait(); - } - - /** - * Returns the specified Instance resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Instance - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetInstanceRequest $request, array $callOptions = []): Instance - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Returns effective firewalls applied to an interface of the instance. - * - * The async variant is {@see self::getEffectiveFirewallsAsync()} . - * - * @param GetEffectiveFirewallsInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InstancesGetEffectiveFirewallsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEffectiveFirewalls(GetEffectiveFirewallsInstanceRequest $request, array $callOptions = []): InstancesGetEffectiveFirewallsResponse - { - return $this->startApiCall('GetEffectiveFirewalls', $request, $callOptions)->wait(); - } - - /** - * Returns the specified guest attributes entry. - * - * The async variant is {@see self::getGuestAttributesAsync()} . - * - * @param GetGuestAttributesInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GuestAttributes - * - * @throws ApiException Thrown if the API call fails. - */ - public function getGuestAttributes(GetGuestAttributesInstanceRequest $request, array $callOptions = []): GuestAttributes - { - return $this->startApiCall('GetGuestAttributes', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. May be empty if no such policy or resource exists. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyInstanceRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns the screenshot from the specified instance. - * - * The async variant is {@see self::getScreenshotAsync()} . - * - * @param GetScreenshotInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Screenshot - * - * @throws ApiException Thrown if the API call fails. - */ - public function getScreenshot(GetScreenshotInstanceRequest $request, array $callOptions = []): Screenshot - { - return $this->startApiCall('GetScreenshot', $request, $callOptions)->wait(); - } - - /** - * Returns the last 1 MB of serial port output from the specified instance. - * - * The async variant is {@see self::getSerialPortOutputAsync()} . - * - * @param GetSerialPortOutputInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SerialPortOutput - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSerialPortOutput(GetSerialPortOutputInstanceRequest $request, array $callOptions = []): SerialPortOutput - { - return $this->startApiCall('GetSerialPortOutput', $request, $callOptions)->wait(); - } - - /** - * Returns the Shielded Instance Identity of an instance - * - * The async variant is {@see self::getShieldedInstanceIdentityAsync()} . - * - * @param GetShieldedInstanceIdentityInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ShieldedInstanceIdentity - * - * @throws ApiException Thrown if the API call fails. - */ - public function getShieldedInstanceIdentity(GetShieldedInstanceIdentityInstanceRequest $request, array $callOptions = []): ShieldedInstanceIdentity - { - return $this->startApiCall('GetShieldedInstanceIdentity', $request, $callOptions)->wait(); - } - - /** - * Creates an instance resource in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of instances contained within the specified zone. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListInstancesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListInstancesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Retrieves a list of resources that refer to the VM instance specified in the request. For example, if the VM instance is part of a managed or unmanaged instance group, the referrers list includes the instance group. For more information, read Viewing referrers to VM instances. - * - * The async variant is {@see self::listReferrersAsync()} . - * - * @param ListReferrersInstancesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listReferrers(ListReferrersInstancesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListReferrers', $request, $callOptions); - } - - /** - * Removes resource policies from an instance. - * - * The async variant is {@see self::removeResourcePoliciesAsync()} . - * - * @param RemoveResourcePoliciesInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function removeResourcePolicies(RemoveResourcePoliciesInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RemoveResourcePolicies', $request, $callOptions)->wait(); - } - - /** - * Performs a reset on the instance. This is a hard reset. The VM does not do a graceful shutdown. For more information, see Resetting an instance. - * - * The async variant is {@see self::resetAsync()} . - * - * @param ResetInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function reset(ResetInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Reset', $request, $callOptions)->wait(); - } - - /** - * Resumes an instance that was suspended using the instances().suspend method. - * - * The async variant is {@see self::resumeAsync()} . - * - * @param ResumeInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function resume(ResumeInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Resume', $request, $callOptions)->wait(); - } - - /** - * Sends diagnostic interrupt to the instance. - * - * The async variant is {@see self::sendDiagnosticInterruptAsync()} . - * - * @param SendDiagnosticInterruptInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SendDiagnosticInterruptInstanceResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function sendDiagnosticInterrupt(SendDiagnosticInterruptInstanceRequest $request, array $callOptions = []): SendDiagnosticInterruptInstanceResponse - { - return $this->startApiCall('SendDiagnosticInterrupt', $request, $callOptions)->wait(); - } - - /** - * Sets deletion protection on the instance. - * - * The async variant is {@see self::setDeletionProtectionAsync()} . - * - * @param SetDeletionProtectionInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setDeletionProtection(SetDeletionProtectionInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetDeletionProtection', $request, $callOptions)->wait(); - } - - /** - * Sets the auto-delete flag for a disk attached to an instance. - * - * The async variant is {@see self::setDiskAutoDeleteAsync()} . - * - * @param SetDiskAutoDeleteInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setDiskAutoDelete(SetDiskAutoDeleteInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetDiskAutoDelete', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyInstanceRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets labels on an instance. To learn more about labels, read the Labeling Resources documentation. - * - * The async variant is {@see self::setLabelsAsync()} . - * - * @param SetLabelsInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setLabels(SetLabelsInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); - } - - /** - * Changes the number and/or type of accelerator for a stopped instance to the values specified in the request. - * - * The async variant is {@see self::setMachineResourcesAsync()} . - * - * @param SetMachineResourcesInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setMachineResources(SetMachineResourcesInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetMachineResources', $request, $callOptions)->wait(); - } - - /** - * Changes the machine type for a stopped instance to the machine type specified in the request. - * - * The async variant is {@see self::setMachineTypeAsync()} . - * - * @param SetMachineTypeInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setMachineType(SetMachineTypeInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetMachineType', $request, $callOptions)->wait(); - } - - /** - * Sets metadata for the specified instance to the data included in the request. - * - * The async variant is {@see self::setMetadataAsync()} . - * - * @param SetMetadataInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setMetadata(SetMetadataInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetMetadata', $request, $callOptions)->wait(); - } - - /** - * Changes the minimum CPU platform that this instance should use. This method can only be called on a stopped instance. For more information, read Specifying a Minimum CPU Platform. - * - * The async variant is {@see self::setMinCpuPlatformAsync()} . - * - * @param SetMinCpuPlatformInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setMinCpuPlatform(SetMinCpuPlatformInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetMinCpuPlatform', $request, $callOptions)->wait(); - } - - /** - * Sets name of an instance. - * - * The async variant is {@see self::setNameAsync()} . - * - * @param SetNameInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setName(SetNameInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetName', $request, $callOptions)->wait(); - } - - /** - * Sets an instance's scheduling options. You can only call this method on a stopped instance, that is, a VM instance that is in a `TERMINATED` state. See Instance Life Cycle for more information on the possible instance states. For more information about setting scheduling options for a VM, see Set VM host maintenance policy. - * - * The async variant is {@see self::setSchedulingAsync()} . - * - * @param SetSchedulingInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setScheduling(SetSchedulingInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetScheduling', $request, $callOptions)->wait(); - } - - /** - * Sets the service account on the instance. For more information, read Changing the service account and access scopes for an instance. - * - * The async variant is {@see self::setServiceAccountAsync()} . - * - * @param SetServiceAccountInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setServiceAccount(SetServiceAccountInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetServiceAccount', $request, $callOptions)->wait(); - } - - /** - * Sets the Shielded Instance integrity policy for an instance. You can only use this method on a running instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. - * - * The async variant is {@see self::setShieldedInstanceIntegrityPolicyAsync()} . - * - * @param SetShieldedInstanceIntegrityPolicyInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setShieldedInstanceIntegrityPolicy(SetShieldedInstanceIntegrityPolicyInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetShieldedInstanceIntegrityPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets network tags for the specified instance to the data included in the request. - * - * The async variant is {@see self::setTagsAsync()} . - * - * @param SetTagsInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setTags(SetTagsInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetTags', $request, $callOptions)->wait(); - } - - /** - * Simulates a host maintenance event on a VM. For more information, see Simulate a host maintenance event. - * - * The async variant is {@see self::simulateMaintenanceEventAsync()} . - * - * @param SimulateMaintenanceEventInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function simulateMaintenanceEvent(SimulateMaintenanceEventInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SimulateMaintenanceEvent', $request, $callOptions)->wait(); - } - - /** - * Starts an instance that was stopped using the instances().stop method. For more information, see Restart an instance. - * - * The async variant is {@see self::startAsync()} . - * - * @param StartInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function start(StartInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Start', $request, $callOptions)->wait(); - } - - /** - * Starts an instance that was stopped using the instances().stop method. For more information, see Restart an instance. - * - * The async variant is {@see self::startWithEncryptionKeyAsync()} . - * - * @param StartWithEncryptionKeyInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function startWithEncryptionKey(StartWithEncryptionKeyInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StartWithEncryptionKey', $request, $callOptions)->wait(); - } - - /** - * Stops a running instance, shutting it down cleanly, and allows you to restart the instance at a later time. Stopped instances do not incur VM usage charges while they are stopped. However, resources that the VM is using, such as persistent disks and static IP addresses, will continue to be charged until they are deleted. For more information, see Stopping an instance. - * - * The async variant is {@see self::stopAsync()} . - * - * @param StopInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function stop(StopInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Stop', $request, $callOptions)->wait(); - } - - /** - * This method suspends a running instance, saving its state to persistent storage, and allows you to resume the instance at a later time. Suspended instances have no compute costs (cores or RAM), and incur only storage charges for the saved VM memory and localSSD data. Any charged resources the virtual machine was using, such as persistent disks and static IP addresses, will continue to be charged while the instance is suspended. For more information, see Suspending and resuming an instance. - * - * The async variant is {@see self::suspendAsync()} . - * - * @param SuspendInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function suspend(SuspendInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Suspend', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsInstanceRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Updates an instance only if the necessary resources are available. This method can update only a specific set of instance properties. See Updating a running instance for a list of updatable instance properties. - * - * The async variant is {@see self::updateAsync()} . - * - * @param UpdateInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function update(UpdateInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Update', $request, $callOptions)->wait(); - } - - /** - * Updates the specified access config from an instance's network interface with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. - * - * The async variant is {@see self::updateAccessConfigAsync()} . - * - * @param UpdateAccessConfigInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAccessConfig(UpdateAccessConfigInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateAccessConfig', $request, $callOptions)->wait(); - } - - /** - * Updates the Display config for a VM instance. You can only use this method on a stopped VM instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. - * - * The async variant is {@see self::updateDisplayDeviceAsync()} . - * - * @param UpdateDisplayDeviceInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDisplayDevice(UpdateDisplayDeviceInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateDisplayDevice', $request, $callOptions)->wait(); - } - - /** - * Updates an instance's network interface. This method can only update an interface's alias IP range and attached network. See Modifying alias IP ranges for an existing instance for instructions on changing alias IP ranges. See Migrating a VM between networks for instructions on migrating an interface. This method follows PATCH semantics. - * - * The async variant is {@see self::updateNetworkInterfaceAsync()} . - * - * @param UpdateNetworkInterfaceInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateNetworkInterface(UpdateNetworkInterfaceInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateNetworkInterface', $request, $callOptions)->wait(); - } - - /** - * Updates the Shielded Instance config for an instance. You can only use this method on a stopped instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. - * - * The async variant is {@see self::updateShieldedInstanceConfigAsync()} . - * - * @param UpdateShieldedInstanceConfigInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateShieldedInstanceConfig(UpdateShieldedInstanceConfigInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateShieldedInstanceConfig', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/InterconnectAttachmentsBaseClient.php b/Compute/src/V1/Client/BaseClient/InterconnectAttachmentsBaseClient.php deleted file mode 100644 index db7e18e20af4..000000000000 --- a/Compute/src/V1/Client/BaseClient/InterconnectAttachmentsBaseClient.php +++ /dev/null @@ -1,411 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/interconnect_attachments_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/interconnect_attachments_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/interconnect_attachments_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves an aggregated list of interconnect attachments. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListInterconnectAttachmentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListInterconnectAttachmentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified interconnect attachment. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteInterconnectAttachmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteInterconnectAttachmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified interconnect attachment. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetInterconnectAttachmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InterconnectAttachment - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetInterconnectAttachmentRequest $request, array $callOptions = []): InterconnectAttachment - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates an InterconnectAttachment in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertInterconnectAttachmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertInterconnectAttachmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of interconnect attachments contained within the specified region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListInterconnectAttachmentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListInterconnectAttachmentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Updates the specified interconnect attachment with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchInterconnectAttachmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchInterconnectAttachmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Sets the labels on an InterconnectAttachment. To learn more about labels, read the Labeling Resources documentation. - * - * The async variant is {@see self::setLabelsAsync()} . - * - * @param SetLabelsInterconnectAttachmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setLabels(SetLabelsInterconnectAttachmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/InterconnectLocationsBaseClient.php b/Compute/src/V1/Client/BaseClient/InterconnectLocationsBaseClient.php deleted file mode 100644 index 51fc5096049d..000000000000 --- a/Compute/src/V1/Client/BaseClient/InterconnectLocationsBaseClient.php +++ /dev/null @@ -1,228 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/interconnect_locations_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/interconnect_locations_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/interconnect_locations_rest_client_config.php', - ], - ], - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Returns the details for the specified interconnect location. Gets a list of available interconnect locations by making a list() request. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetInterconnectLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InterconnectLocation - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetInterconnectLocationRequest $request, array $callOptions = []): InterconnectLocation - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of interconnect locations available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListInterconnectLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListInterconnectLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } -} diff --git a/Compute/src/V1/Client/BaseClient/InterconnectRemoteLocationsBaseClient.php b/Compute/src/V1/Client/BaseClient/InterconnectRemoteLocationsBaseClient.php deleted file mode 100644 index 9245cab8d238..000000000000 --- a/Compute/src/V1/Client/BaseClient/InterconnectRemoteLocationsBaseClient.php +++ /dev/null @@ -1,228 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/interconnect_remote_locations_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/interconnect_remote_locations_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/interconnect_remote_locations_rest_client_config.php', - ], - ], - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Returns the details for the specified interconnect remote location. Gets a list of available interconnect remote locations by making a list() request. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetInterconnectRemoteLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InterconnectRemoteLocation - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetInterconnectRemoteLocationRequest $request, array $callOptions = []): InterconnectRemoteLocation - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of interconnect remote locations available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListInterconnectRemoteLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListInterconnectRemoteLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } -} diff --git a/Compute/src/V1/Client/BaseClient/InterconnectsBaseClient.php b/Compute/src/V1/Client/BaseClient/InterconnectsBaseClient.php deleted file mode 100644 index 747c48cf221e..000000000000 --- a/Compute/src/V1/Client/BaseClient/InterconnectsBaseClient.php +++ /dev/null @@ -1,410 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/interconnects_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/interconnects_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/interconnects_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified Interconnect. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteInterconnectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteInterconnectRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified Interconnect. Get a list of available Interconnects by making a list() request. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetInterconnectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Interconnect - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetInterconnectRequest $request, array $callOptions = []): Interconnect - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Returns the interconnectDiagnostics for the specified Interconnect. - * - * The async variant is {@see self::getDiagnosticsAsync()} . - * - * @param GetDiagnosticsInterconnectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InterconnectsGetDiagnosticsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDiagnostics(GetDiagnosticsInterconnectRequest $request, array $callOptions = []): InterconnectsGetDiagnosticsResponse - { - return $this->startApiCall('GetDiagnostics', $request, $callOptions)->wait(); - } - - /** - * Creates an Interconnect in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertInterconnectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertInterconnectRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of Interconnects available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListInterconnectsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListInterconnectsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Updates the specified Interconnect with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchInterconnectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchInterconnectRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Sets the labels on an Interconnect. To learn more about labels, read the Labeling Resources documentation. - * - * The async variant is {@see self::setLabelsAsync()} . - * - * @param SetLabelsInterconnectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setLabels(SetLabelsInterconnectRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/LicenseCodesBaseClient.php b/Compute/src/V1/Client/BaseClient/LicenseCodesBaseClient.php deleted file mode 100644 index 74d9eaff27ff..000000000000 --- a/Compute/src/V1/Client/BaseClient/LicenseCodesBaseClient.php +++ /dev/null @@ -1,227 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/license_codes_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/license_codes_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/license_codes_rest_client_config.php', - ], - ], - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Return a specified license code. License codes are mirrored across all projects that have permissions to read the License Code. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetLicenseCodeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LicenseCode - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetLicenseCodeRequest $request, array $callOptions = []): LicenseCode - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsLicenseCodeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsLicenseCodeRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/LicensesBaseClient.php b/Compute/src/V1/Client/BaseClient/LicensesBaseClient.php deleted file mode 100644 index 92e56bbb6493..000000000000 --- a/Compute/src/V1/Client/BaseClient/LicensesBaseClient.php +++ /dev/null @@ -1,411 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/licenses_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/licenses_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/licenses_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified license. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteLicenseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteLicenseRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified License resource. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetLicenseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 License - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetLicenseRequest $request, array $callOptions = []): License - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. May be empty if no such policy or resource exists. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyLicenseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyLicenseRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Create a License resource in the specified project. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertLicenseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertLicenseRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of licenses available in the specified project. This method does not get any licenses that belong to other projects, including licenses attached to publicly-available images, like Debian 9. If you want to get a list of publicly-available licenses, use this method to make a request to the respective image project, such as debian-cloud or windows-cloud. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListLicensesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListLicensesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyLicenseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyLicenseRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsLicenseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsLicenseRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/MachineImagesBaseClient.php b/Compute/src/V1/Client/BaseClient/MachineImagesBaseClient.php deleted file mode 100644 index e0b4f033e2da..000000000000 --- a/Compute/src/V1/Client/BaseClient/MachineImagesBaseClient.php +++ /dev/null @@ -1,411 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/machine_images_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/machine_images_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/machine_images_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified machine image. Deleting a machine image is permanent and cannot be undone. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteMachineImageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteMachineImageRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified machine image. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetMachineImageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MachineImage - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetMachineImageRequest $request, array $callOptions = []): MachineImage - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. May be empty if no such policy or resource exists. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyMachineImageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyMachineImageRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Creates a machine image in the specified project using the data that is included in the request. If you are creating a new machine image to update an existing instance, your new machine image should use the same network or, if applicable, the same subnetwork as the original instance. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertMachineImageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertMachineImageRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of machine images that are contained within the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListMachineImagesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListMachineImagesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyMachineImageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyMachineImageRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsMachineImageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsMachineImageRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/MachineTypesBaseClient.php b/Compute/src/V1/Client/BaseClient/MachineTypesBaseClient.php deleted file mode 100644 index eeb26b3ca339..000000000000 --- a/Compute/src/V1/Client/BaseClient/MachineTypesBaseClient.php +++ /dev/null @@ -1,253 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/machine_types_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/machine_types_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/machine_types_rest_client_config.php', - ], - ], - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves an aggregated list of machine types. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListMachineTypesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListMachineTypesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Returns the specified machine type. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetMachineTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MachineType - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetMachineTypeRequest $request, array $callOptions = []): MachineType - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of machine types available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListMachineTypesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListMachineTypesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } -} diff --git a/Compute/src/V1/Client/BaseClient/NetworkAttachmentsBaseClient.php b/Compute/src/V1/Client/BaseClient/NetworkAttachmentsBaseClient.php deleted file mode 100644 index a5414032e95d..000000000000 --- a/Compute/src/V1/Client/BaseClient/NetworkAttachmentsBaseClient.php +++ /dev/null @@ -1,438 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/network_attachments_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/network_attachments_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/network_attachments_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves the list of all NetworkAttachment resources, regional and global, available to the specified project. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListNetworkAttachmentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListNetworkAttachmentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified NetworkAttachment in the given scope - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteNetworkAttachmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteNetworkAttachmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified NetworkAttachment resource in the given scope. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetNetworkAttachmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NetworkAttachment - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetNetworkAttachmentRequest $request, array $callOptions = []): NetworkAttachment - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. May be empty if no such policy or resource exists. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyNetworkAttachmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyNetworkAttachmentRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Creates a NetworkAttachment in the specified project in the given scope using the parameters that are included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertNetworkAttachmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertNetworkAttachmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Lists the NetworkAttachments for a project in the given scope. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListNetworkAttachmentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListNetworkAttachmentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyNetworkAttachmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyNetworkAttachmentRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsNetworkAttachmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsNetworkAttachmentRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/NetworkEdgeSecurityServicesBaseClient.php b/Compute/src/V1/Client/BaseClient/NetworkEdgeSecurityServicesBaseClient.php deleted file mode 100644 index cc1ea482d494..000000000000 --- a/Compute/src/V1/Client/BaseClient/NetworkEdgeSecurityServicesBaseClient.php +++ /dev/null @@ -1,359 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/network_edge_security_services_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/network_edge_security_services_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/network_edge_security_services_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves the list of all NetworkEdgeSecurityService resources available to the specified project. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListNetworkEdgeSecurityServicesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListNetworkEdgeSecurityServicesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified service. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteNetworkEdgeSecurityServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteNetworkEdgeSecurityServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Gets a specified NetworkEdgeSecurityService. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetNetworkEdgeSecurityServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NetworkEdgeSecurityService - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetNetworkEdgeSecurityServiceRequest $request, array $callOptions = []): NetworkEdgeSecurityService - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a new service in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertNetworkEdgeSecurityServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertNetworkEdgeSecurityServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Patches the specified policy with the data included in the request. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchNetworkEdgeSecurityServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchNetworkEdgeSecurityServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/NetworkEndpointGroupsBaseClient.php b/Compute/src/V1/Client/BaseClient/NetworkEndpointGroupsBaseClient.php deleted file mode 100644 index cfd67fcfde82..000000000000 --- a/Compute/src/V1/Client/BaseClient/NetworkEndpointGroupsBaseClient.php +++ /dev/null @@ -1,464 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/network_endpoint_groups_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/network_endpoint_groups_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/network_endpoint_groups_rest_client_config.php', - ], - ], - 'operationsClientClass' => ZoneOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an ZoneOperationsClient object with the same endpoint as $this. - * - * @return ZoneOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getZone', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves the list of network endpoint groups and sorts them by zone. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListNetworkEndpointGroupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListNetworkEndpointGroupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Attach a list of network endpoints to the specified network endpoint group. - * - * The async variant is {@see self::attachNetworkEndpointsAsync()} . - * - * @param AttachNetworkEndpointsNetworkEndpointGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function attachNetworkEndpoints(AttachNetworkEndpointsNetworkEndpointGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AttachNetworkEndpoints', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified network endpoint group. The network endpoints in the NEG and the VM instances they belong to are not terminated when the NEG is deleted. Note that the NEG cannot be deleted if there are backend services referencing it. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteNetworkEndpointGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteNetworkEndpointGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Detach a list of network endpoints from the specified network endpoint group. - * - * The async variant is {@see self::detachNetworkEndpointsAsync()} . - * - * @param DetachNetworkEndpointsNetworkEndpointGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function detachNetworkEndpoints(DetachNetworkEndpointsNetworkEndpointGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DetachNetworkEndpoints', $request, $callOptions)->wait(); - } - - /** - * Returns the specified network endpoint group. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetNetworkEndpointGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NetworkEndpointGroup - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetNetworkEndpointGroupRequest $request, array $callOptions = []): NetworkEndpointGroup - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a network endpoint group in the specified project using the parameters that are included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertNetworkEndpointGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertNetworkEndpointGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of network endpoint groups that are located in the specified project and zone. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListNetworkEndpointGroupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListNetworkEndpointGroupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Lists the network endpoints in the specified network endpoint group. - * - * The async variant is {@see self::listNetworkEndpointsAsync()} . - * - * @param ListNetworkEndpointsNetworkEndpointGroupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listNetworkEndpoints(ListNetworkEndpointsNetworkEndpointGroupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListNetworkEndpoints', $request, $callOptions); - } - - /** - * Returns permissions that a caller has on the specified resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsNetworkEndpointGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsNetworkEndpointGroupRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/NetworkFirewallPoliciesBaseClient.php b/Compute/src/V1/Client/BaseClient/NetworkFirewallPoliciesBaseClient.php deleted file mode 100644 index 83fc156268bf..000000000000 --- a/Compute/src/V1/Client/BaseClient/NetworkFirewallPoliciesBaseClient.php +++ /dev/null @@ -1,648 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/network_firewall_policies_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/network_firewall_policies_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/network_firewall_policies_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Inserts an association for the specified firewall policy. - * - * The async variant is {@see self::addAssociationAsync()} . - * - * @param AddAssociationNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addAssociation(AddAssociationNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AddAssociation', $request, $callOptions)->wait(); - } - - /** - * Inserts a rule into a firewall policy. - * - * The async variant is {@see self::addRuleAsync()} . - * - * @param AddRuleNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addRule(AddRuleNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AddRule', $request, $callOptions)->wait(); - } - - /** - * Copies rules to the specified firewall policy. - * - * The async variant is {@see self::cloneRulesAsync()} . - * - * @param CloneRulesNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function cloneRules(CloneRulesNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CloneRules', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified policy. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified network firewall policy. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FirewallPolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetNetworkFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicy - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Gets an association with the specified name. - * - * The async variant is {@see self::getAssociationAsync()} . - * - * @param GetAssociationNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FirewallPolicyAssociation - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAssociation(GetAssociationNetworkFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicyAssociation - { - return $this->startApiCall('GetAssociation', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. May be empty if no such policy or resource exists. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyNetworkFirewallPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets a rule of the specified priority. - * - * The async variant is {@see self::getRuleAsync()} . - * - * @param GetRuleNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FirewallPolicyRule - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRule(GetRuleNetworkFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicyRule - { - return $this->startApiCall('GetRule', $request, $callOptions)->wait(); - } - - /** - * Creates a new policy in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Lists all the policies that have been configured for the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListNetworkFirewallPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListNetworkFirewallPoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Patches the specified policy with the data included in the request. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Patches a rule of the specified priority. - * - * The async variant is {@see self::patchRuleAsync()} . - * - * @param PatchRuleNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patchRule(PatchRuleNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('PatchRule', $request, $callOptions)->wait(); - } - - /** - * Removes an association for the specified firewall policy. - * - * The async variant is {@see self::removeAssociationAsync()} . - * - * @param RemoveAssociationNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function removeAssociation(RemoveAssociationNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RemoveAssociation', $request, $callOptions)->wait(); - } - - /** - * Deletes a rule of the specified priority. - * - * The async variant is {@see self::removeRuleAsync()} . - * - * @param RemoveRuleNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function removeRule(RemoveRuleNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RemoveRule', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyNetworkFirewallPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsNetworkFirewallPolicyRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/NetworksBaseClient.php b/Compute/src/V1/Client/BaseClient/NetworksBaseClient.php deleted file mode 100644 index c0795aae8171..000000000000 --- a/Compute/src/V1/Client/BaseClient/NetworksBaseClient.php +++ /dev/null @@ -1,514 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/networks_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/networks_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/networks_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Adds a peering to the specified network. - * - * The async variant is {@see self::addPeeringAsync()} . - * - * @param AddPeeringNetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addPeering(AddPeeringNetworkRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AddPeering', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified network. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteNetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteNetworkRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified network. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetNetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Network - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetNetworkRequest $request, array $callOptions = []): Network - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Returns the effective firewalls on a given network. - * - * The async variant is {@see self::getEffectiveFirewallsAsync()} . - * - * @param GetEffectiveFirewallsNetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NetworksGetEffectiveFirewallsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEffectiveFirewalls(GetEffectiveFirewallsNetworkRequest $request, array $callOptions = []): NetworksGetEffectiveFirewallsResponse - { - return $this->startApiCall('GetEffectiveFirewalls', $request, $callOptions)->wait(); - } - - /** - * Creates a network in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertNetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertNetworkRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of networks available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListNetworksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListNetworksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Lists the peering routes exchanged over peering connection. - * - * The async variant is {@see self::listPeeringRoutesAsync()} . - * - * @param ListPeeringRoutesNetworksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPeeringRoutes(ListPeeringRoutesNetworksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPeeringRoutes', $request, $callOptions); - } - - /** - * Patches the specified network with the data included in the request. Only the following fields can be modified: routingConfig.routingMode. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchNetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchNetworkRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Removes a peering from the specified network. - * - * The async variant is {@see self::removePeeringAsync()} . - * - * @param RemovePeeringNetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function removePeering(RemovePeeringNetworkRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RemovePeering', $request, $callOptions)->wait(); - } - - /** - * Switches the network mode from auto subnet mode to custom subnet mode. - * - * The async variant is {@see self::switchToCustomModeAsync()} . - * - * @param SwitchToCustomModeNetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function switchToCustomMode(SwitchToCustomModeNetworkRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SwitchToCustomMode', $request, $callOptions)->wait(); - } - - /** - * Updates the specified network peering with the data included in the request. You can only modify the NetworkPeering.export_custom_routes field and the NetworkPeering.import_custom_routes field. - * - * The async variant is {@see self::updatePeeringAsync()} . - * - * @param UpdatePeeringNetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updatePeering(UpdatePeeringNetworkRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdatePeering', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/NodeGroupsBaseClient.php b/Compute/src/V1/Client/BaseClient/NodeGroupsBaseClient.php deleted file mode 100644 index a0a26a753919..000000000000 --- a/Compute/src/V1/Client/BaseClient/NodeGroupsBaseClient.php +++ /dev/null @@ -1,594 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/node_groups_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/node_groups_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/node_groups_rest_client_config.php', - ], - ], - 'operationsClientClass' => ZoneOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an ZoneOperationsClient object with the same endpoint as $this. - * - * @return ZoneOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getZone', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Adds specified number of nodes to the node group. - * - * The async variant is {@see self::addNodesAsync()} . - * - * @param AddNodesNodeGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addNodes(AddNodesNodeGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AddNodes', $request, $callOptions)->wait(); - } - - /** - * Retrieves an aggregated list of node groups. Note: use nodeGroups.listNodes for more details about each group. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListNodeGroupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListNodeGroupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified NodeGroup resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteNodeGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteNodeGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Deletes specified nodes from the node group. - * - * The async variant is {@see self::deleteNodesAsync()} . - * - * @param DeleteNodesNodeGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteNodes(DeleteNodesNodeGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteNodes', $request, $callOptions)->wait(); - } - - /** - * Returns the specified NodeGroup. Get a list of available NodeGroups by making a list() request. Note: the "nodes" field should not be used. Use nodeGroups.listNodes instead. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetNodeGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NodeGroup - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetNodeGroupRequest $request, array $callOptions = []): NodeGroup - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. May be empty if no such policy or resource exists. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyNodeGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyNodeGroupRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Creates a NodeGroup resource in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertNodeGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertNodeGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of node groups available to the specified project. Note: use nodeGroups.listNodes for more details about each group. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListNodeGroupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListNodeGroupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Lists nodes in the node group. - * - * The async variant is {@see self::listNodesAsync()} . - * - * @param ListNodesNodeGroupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listNodes(ListNodesNodeGroupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListNodes', $request, $callOptions); - } - - /** - * Updates the specified node group. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchNodeGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchNodeGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyNodeGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyNodeGroupRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Updates the node template of the node group. - * - * The async variant is {@see self::setNodeTemplateAsync()} . - * - * @param SetNodeTemplateNodeGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setNodeTemplate(SetNodeTemplateNodeGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetNodeTemplate', $request, $callOptions)->wait(); - } - - /** - * Simulates maintenance event on specified nodes from the node group. - * - * The async variant is {@see self::simulateMaintenanceEventAsync()} . - * - * @param SimulateMaintenanceEventNodeGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function simulateMaintenanceEvent(SimulateMaintenanceEventNodeGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SimulateMaintenanceEvent', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsNodeGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsNodeGroupRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/NodeTemplatesBaseClient.php b/Compute/src/V1/Client/BaseClient/NodeTemplatesBaseClient.php deleted file mode 100644 index 2a2ce24ab5e8..000000000000 --- a/Compute/src/V1/Client/BaseClient/NodeTemplatesBaseClient.php +++ /dev/null @@ -1,438 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/node_templates_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/node_templates_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/node_templates_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves an aggregated list of node templates. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListNodeTemplatesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListNodeTemplatesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified NodeTemplate resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteNodeTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteNodeTemplateRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified node template. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetNodeTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NodeTemplate - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetNodeTemplateRequest $request, array $callOptions = []): NodeTemplate - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. May be empty if no such policy or resource exists. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyNodeTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyNodeTemplateRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Creates a NodeTemplate resource in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertNodeTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertNodeTemplateRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of node templates available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListNodeTemplatesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListNodeTemplatesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyNodeTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyNodeTemplateRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsNodeTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsNodeTemplateRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/NodeTypesBaseClient.php b/Compute/src/V1/Client/BaseClient/NodeTypesBaseClient.php deleted file mode 100644 index b14ed18c7575..000000000000 --- a/Compute/src/V1/Client/BaseClient/NodeTypesBaseClient.php +++ /dev/null @@ -1,253 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/node_types_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/node_types_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/node_types_rest_client_config.php', - ], - ], - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves an aggregated list of node types. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListNodeTypesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListNodeTypesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Returns the specified node type. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetNodeTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NodeType - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetNodeTypeRequest $request, array $callOptions = []): NodeType - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of node types available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListNodeTypesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListNodeTypesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } -} diff --git a/Compute/src/V1/Client/BaseClient/PacketMirroringsBaseClient.php b/Compute/src/V1/Client/BaseClient/PacketMirroringsBaseClient.php deleted file mode 100644 index 2dd438cb8899..000000000000 --- a/Compute/src/V1/Client/BaseClient/PacketMirroringsBaseClient.php +++ /dev/null @@ -1,411 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/packet_mirrorings_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/packet_mirrorings_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/packet_mirrorings_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves an aggregated list of packetMirrorings. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListPacketMirroringsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListPacketMirroringsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified PacketMirroring resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeletePacketMirroringRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeletePacketMirroringRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified PacketMirroring resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetPacketMirroringRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PacketMirroring - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetPacketMirroringRequest $request, array $callOptions = []): PacketMirroring - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a PacketMirroring resource in the specified project and region using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertPacketMirroringRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertPacketMirroringRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of PacketMirroring resources available to the specified project and region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListPacketMirroringsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListPacketMirroringsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Patches the specified PacketMirroring resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchPacketMirroringRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchPacketMirroringRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsPacketMirroringRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsPacketMirroringRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/ProjectsBaseClient.php b/Compute/src/V1/Client/BaseClient/ProjectsBaseClient.php deleted file mode 100644 index f84bce2fe057..000000000000 --- a/Compute/src/V1/Client/BaseClient/ProjectsBaseClient.php +++ /dev/null @@ -1,565 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/projects_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/projects_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/projects_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Disable this project as a shared VPC host project. - * - * The async variant is {@see self::disableXpnHostAsync()} . - * - * @param DisableXpnHostProjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function disableXpnHost(DisableXpnHostProjectRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DisableXpnHost', $request, $callOptions)->wait(); - } - - /** - * Disable a service resource (also known as service project) associated with this host project. - * - * The async variant is {@see self::disableXpnResourceAsync()} . - * - * @param DisableXpnResourceProjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function disableXpnResource(DisableXpnResourceProjectRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DisableXpnResource', $request, $callOptions)->wait(); - } - - /** - * Enable this project as a shared VPC host project. - * - * The async variant is {@see self::enableXpnHostAsync()} . - * - * @param EnableXpnHostProjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function enableXpnHost(EnableXpnHostProjectRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('EnableXpnHost', $request, $callOptions)->wait(); - } - - /** - * Enable service resource (a.k.a service project) for a host project, so that subnets in the host project can be used by instances in the service project. - * - * The async variant is {@see self::enableXpnResourceAsync()} . - * - * @param EnableXpnResourceProjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function enableXpnResource(EnableXpnResourceProjectRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('EnableXpnResource', $request, $callOptions)->wait(); - } - - /** - * Returns the specified Project resource. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the `quotas` field). To exclude one or more fields, set your request's `fields` query parameter to only include the fields you need. For example, to only include the `id` and `selfLink` fields, add the query parameter `?fields=id,selfLink` to your request. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetProjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Project - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetProjectRequest $request, array $callOptions = []): Project - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Gets the shared VPC host project that this project links to. May be empty if no link exists. - * - * The async variant is {@see self::getXpnHostAsync()} . - * - * @param GetXpnHostProjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Project - * - * @throws ApiException Thrown if the API call fails. - */ - public function getXpnHost(GetXpnHostProjectRequest $request, array $callOptions = []): Project - { - return $this->startApiCall('GetXpnHost', $request, $callOptions)->wait(); - } - - /** - * Gets service resources (a.k.a service project) associated with this host project. - * - * The async variant is {@see self::getXpnResourcesAsync()} . - * - * @param GetXpnResourcesProjectsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function getXpnResources(GetXpnResourcesProjectsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('GetXpnResources', $request, $callOptions); - } - - /** - * Lists all shared VPC host projects visible to the user in an organization. - * - * The async variant is {@see self::listXpnHostsAsync()} . - * - * @param ListXpnHostsProjectsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listXpnHosts(ListXpnHostsProjectsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListXpnHosts', $request, $callOptions); - } - - /** - * Moves a persistent disk from one zone to another. - * - * The async variant is {@see self::moveDiskAsync()} . - * - * @param MoveDiskProjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function moveDisk(MoveDiskProjectRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('MoveDisk', $request, $callOptions)->wait(); - } - - /** - * Moves an instance and its attached persistent disks from one zone to another. *Note*: Moving VMs or disks by using this method might cause unexpected behavior. For more information, see the [known issue](/compute/docs/troubleshooting/known-issues#moving_vms_or_disks_using_the_moveinstance_api_or_the_causes_unexpected_behavior). [Deprecated] This method is deprecated. See [moving instance across zones](https://cloud.google.com/compute/docs/instances/moving-instance-across-zones) instead. - * - * The async variant is {@see self::moveInstanceAsync()} . - * - * @param MoveInstanceProjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function moveInstance(MoveInstanceProjectRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('MoveInstance', $request, $callOptions)->wait(); - } - - /** - * Sets metadata common to all instances within the specified project using the data included in the request. - * - * The async variant is {@see self::setCommonInstanceMetadataAsync()} . - * - * @param SetCommonInstanceMetadataProjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setCommonInstanceMetadata(SetCommonInstanceMetadataProjectRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetCommonInstanceMetadata', $request, $callOptions)->wait(); - } - - /** - * Sets the default network tier of the project. The default network tier is used when an address/forwardingRule/instance is created without specifying the network tier field. - * - * The async variant is {@see self::setDefaultNetworkTierAsync()} . - * - * @param SetDefaultNetworkTierProjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setDefaultNetworkTier(SetDefaultNetworkTierProjectRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetDefaultNetworkTier', $request, $callOptions)->wait(); - } - - /** - * Enables the usage export feature and sets the usage export bucket where reports are stored. If you provide an empty request body using this method, the usage export feature will be disabled. - * - * The async variant is {@see self::setUsageExportBucketAsync()} . - * - * @param SetUsageExportBucketProjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setUsageExportBucket(SetUsageExportBucketProjectRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetUsageExportBucket', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/PublicAdvertisedPrefixesBaseClient.php b/Compute/src/V1/Client/BaseClient/PublicAdvertisedPrefixesBaseClient.php deleted file mode 100644 index 41c73dea840c..000000000000 --- a/Compute/src/V1/Client/BaseClient/PublicAdvertisedPrefixesBaseClient.php +++ /dev/null @@ -1,358 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/public_advertised_prefixes_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/public_advertised_prefixes_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/public_advertised_prefixes_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified PublicAdvertisedPrefix - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeletePublicAdvertisedPrefixeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeletePublicAdvertisedPrefixeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified PublicAdvertisedPrefix resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetPublicAdvertisedPrefixeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PublicAdvertisedPrefix - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetPublicAdvertisedPrefixeRequest $request, array $callOptions = []): PublicAdvertisedPrefix - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a PublicAdvertisedPrefix in the specified project using the parameters that are included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertPublicAdvertisedPrefixeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertPublicAdvertisedPrefixeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Lists the PublicAdvertisedPrefixes for a project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListPublicAdvertisedPrefixesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListPublicAdvertisedPrefixesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Patches the specified Router resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchPublicAdvertisedPrefixeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchPublicAdvertisedPrefixeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/PublicDelegatedPrefixesBaseClient.php b/Compute/src/V1/Client/BaseClient/PublicDelegatedPrefixesBaseClient.php deleted file mode 100644 index aceadd7ee6c2..000000000000 --- a/Compute/src/V1/Client/BaseClient/PublicDelegatedPrefixesBaseClient.php +++ /dev/null @@ -1,385 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/public_delegated_prefixes_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/public_delegated_prefixes_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/public_delegated_prefixes_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Lists all PublicDelegatedPrefix resources owned by the specific project across all scopes. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListPublicDelegatedPrefixesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListPublicDelegatedPrefixesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified PublicDelegatedPrefix in the given region. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeletePublicDelegatedPrefixeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeletePublicDelegatedPrefixeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified PublicDelegatedPrefix resource in the given region. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetPublicDelegatedPrefixeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PublicDelegatedPrefix - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetPublicDelegatedPrefixeRequest $request, array $callOptions = []): PublicDelegatedPrefix - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a PublicDelegatedPrefix in the specified project in the given region using the parameters that are included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertPublicDelegatedPrefixeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertPublicDelegatedPrefixeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Lists the PublicDelegatedPrefixes for a project in the given region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListPublicDelegatedPrefixesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListPublicDelegatedPrefixesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Patches the specified PublicDelegatedPrefix resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchPublicDelegatedPrefixeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchPublicDelegatedPrefixeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionAutoscalersBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionAutoscalersBaseClient.php deleted file mode 100644 index 75b8b9363c05..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionAutoscalersBaseClient.php +++ /dev/null @@ -1,384 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/region_autoscalers_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/region_autoscalers_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/region_autoscalers_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified autoscaler. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteRegionAutoscalerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteRegionAutoscalerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified autoscaler. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRegionAutoscalerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Autoscaler - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRegionAutoscalerRequest $request, array $callOptions = []): Autoscaler - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates an autoscaler in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertRegionAutoscalerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertRegionAutoscalerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of autoscalers contained within the specified region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRegionAutoscalersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRegionAutoscalersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Updates an autoscaler in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchRegionAutoscalerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchRegionAutoscalerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Updates an autoscaler in the specified project using the data included in the request. - * - * The async variant is {@see self::updateAsync()} . - * - * @param UpdateRegionAutoscalerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function update(UpdateRegionAutoscalerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Update', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionBackendServicesBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionBackendServicesBaseClient.php deleted file mode 100644 index f73f0c57d78f..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionBackendServicesBaseClient.php +++ /dev/null @@ -1,465 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/region_backend_services_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/region_backend_services_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/region_backend_services_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified regional BackendService resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteRegionBackendServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteRegionBackendServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified regional BackendService resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRegionBackendServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BackendService - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRegionBackendServiceRequest $request, array $callOptions = []): BackendService - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Gets the most recent health check results for this regional BackendService. - * - * The async variant is {@see self::getHealthAsync()} . - * - * @param GetHealthRegionBackendServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BackendServiceGroupHealth - * - * @throws ApiException Thrown if the API call fails. - */ - public function getHealth(GetHealthRegionBackendServiceRequest $request, array $callOptions = []): BackendServiceGroupHealth - { - return $this->startApiCall('GetHealth', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. May be empty if no such policy or resource exists. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRegionBackendServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRegionBackendServiceRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Creates a regional BackendService resource in the specified project using the data included in the request. For more information, see Backend services overview. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertRegionBackendServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertRegionBackendServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of regional BackendService resources available to the specified project in the given region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRegionBackendServicesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRegionBackendServicesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Updates the specified regional BackendService resource with the data included in the request. For more information, see Understanding backend services This method supports PATCH semantics and uses the JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchRegionBackendServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchRegionBackendServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRegionBackendServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRegionBackendServiceRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Updates the specified regional BackendService resource with the data included in the request. For more information, see Backend services overview . - * - * The async variant is {@see self::updateAsync()} . - * - * @param UpdateRegionBackendServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function update(UpdateRegionBackendServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Update', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionCommitmentsBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionCommitmentsBaseClient.php deleted file mode 100644 index 28fad3b0cd57..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionCommitmentsBaseClient.php +++ /dev/null @@ -1,358 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/region_commitments_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/region_commitments_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/region_commitments_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves an aggregated list of commitments by region. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListRegionCommitmentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListRegionCommitmentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Returns the specified commitment resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRegionCommitmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Commitment - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRegionCommitmentRequest $request, array $callOptions = []): Commitment - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a commitment in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertRegionCommitmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertRegionCommitmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of commitments contained within the specified region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRegionCommitmentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRegionCommitmentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Updates the specified commitment with the data included in the request. Update is performed only on selected fields included as part of update-mask. Only the following fields can be modified: auto_renew. - * - * The async variant is {@see self::updateAsync()} . - * - * @param UpdateRegionCommitmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function update(UpdateRegionCommitmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Update', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionDiskTypesBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionDiskTypesBaseClient.php deleted file mode 100644 index 4b83a049dd2c..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionDiskTypesBaseClient.php +++ /dev/null @@ -1,227 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/region_disk_types_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/region_disk_types_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/region_disk_types_rest_client_config.php', - ], - ], - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Returns the specified regional disk type. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRegionDiskTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DiskType - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRegionDiskTypeRequest $request, array $callOptions = []): DiskType - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of regional disk types available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRegionDiskTypesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRegionDiskTypesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionDisksBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionDisksBaseClient.php deleted file mode 100644 index ac2a2e411bfa..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionDisksBaseClient.php +++ /dev/null @@ -1,672 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/region_disks_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/region_disks_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/region_disks_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Adds existing resource policies to a regional disk. You can only add one policy which will be applied to this disk for scheduling snapshot creation. - * - * The async variant is {@see self::addResourcePoliciesAsync()} . - * - * @param AddResourcePoliciesRegionDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addResourcePolicies(AddResourcePoliciesRegionDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AddResourcePolicies', $request, $callOptions)->wait(); - } - - /** - * Bulk create a set of disks. - * - * The async variant is {@see self::bulkInsertAsync()} . - * - * @param BulkInsertRegionDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function bulkInsert(BulkInsertRegionDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BulkInsert', $request, $callOptions)->wait(); - } - - /** - * Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider using snapshots.insert instead, as that method supports more features, such as creating snapshots in a project different from the source disk project. - * - * The async variant is {@see self::createSnapshotAsync()} . - * - * @param CreateSnapshotRegionDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSnapshot(CreateSnapshotRegionDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateSnapshot', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified regional persistent disk. Deleting a regional disk removes all the replicas of its data permanently and is irreversible. However, deleting a disk does not delete any snapshots previously made from the disk. You must separately delete snapshots. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteRegionDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteRegionDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns a specified regional persistent disk. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRegionDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Disk - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRegionDiskRequest $request, array $callOptions = []): Disk - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. May be empty if no such policy or resource exists. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRegionDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRegionDiskRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Creates a persistent regional disk in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertRegionDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertRegionDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of persistent disks contained within the specified region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRegionDisksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRegionDisksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Removes resource policies from a regional disk. - * - * The async variant is {@see self::removeResourcePoliciesAsync()} . - * - * @param RemoveResourcePoliciesRegionDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function removeResourcePolicies(RemoveResourcePoliciesRegionDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RemoveResourcePolicies', $request, $callOptions)->wait(); - } - - /** - * Resizes the specified regional persistent disk. - * - * The async variant is {@see self::resizeAsync()} . - * - * @param ResizeRegionDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function resize(ResizeRegionDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Resize', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRegionDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRegionDiskRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the labels on the target regional disk. - * - * The async variant is {@see self::setLabelsAsync()} . - * - * @param SetLabelsRegionDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setLabels(SetLabelsRegionDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); - } - - /** - * Starts asynchronous replication. Must be invoked on the primary disk. - * - * The async variant is {@see self::startAsyncReplicationAsync()} . - * - * @param StartAsyncReplicationRegionDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function startAsyncReplication(StartAsyncReplicationRegionDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StartAsyncReplication', $request, $callOptions)->wait(); - } - - /** - * Stops asynchronous replication. Can be invoked either on the primary or on the secondary disk. - * - * The async variant is {@see self::stopAsyncReplicationAsync()} . - * - * @param StopAsyncReplicationRegionDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function stopAsyncReplication(StopAsyncReplicationRegionDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StopAsyncReplication', $request, $callOptions)->wait(); - } - - /** - * Stops asynchronous replication for a consistency group of disks. Can be invoked either in the primary or secondary scope. - * - * The async variant is {@see self::stopGroupAsyncReplicationAsync()} . - * - * @param StopGroupAsyncReplicationRegionDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function stopGroupAsyncReplication(StopGroupAsyncReplicationRegionDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StopGroupAsyncReplication', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRegionDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRegionDiskRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Update the specified disk with the data included in the request. Update is performed only on selected fields included as part of update-mask. Only the following fields can be modified: user_license. - * - * The async variant is {@see self::updateAsync()} . - * - * @param UpdateRegionDiskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function update(UpdateRegionDiskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Update', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionHealthCheckServicesBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionHealthCheckServicesBaseClient.php deleted file mode 100644 index 7d01449f0fa6..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionHealthCheckServicesBaseClient.php +++ /dev/null @@ -1,359 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/region_health_check_services_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/region_health_check_services_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/region_health_check_services_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified regional HealthCheckService. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteRegionHealthCheckServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteRegionHealthCheckServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified regional HealthCheckService resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRegionHealthCheckServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 HealthCheckService - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRegionHealthCheckServiceRequest $request, array $callOptions = []): HealthCheckService - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a regional HealthCheckService resource in the specified project and region using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertRegionHealthCheckServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertRegionHealthCheckServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Lists all the HealthCheckService resources that have been configured for the specified project in the given region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRegionHealthCheckServicesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRegionHealthCheckServicesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Updates the specified regional HealthCheckService resource with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchRegionHealthCheckServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchRegionHealthCheckServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionHealthChecksBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionHealthChecksBaseClient.php deleted file mode 100644 index e810eb665d24..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionHealthChecksBaseClient.php +++ /dev/null @@ -1,384 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/region_health_checks_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/region_health_checks_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/region_health_checks_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified HealthCheck resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteRegionHealthCheckRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteRegionHealthCheckRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified HealthCheck resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRegionHealthCheckRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 HealthCheck - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRegionHealthCheckRequest $request, array $callOptions = []): HealthCheck - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a HealthCheck resource in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertRegionHealthCheckRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertRegionHealthCheckRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of HealthCheck resources available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRegionHealthChecksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRegionHealthChecksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Updates a HealthCheck resource in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchRegionHealthCheckRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchRegionHealthCheckRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Updates a HealthCheck resource in the specified project using the data included in the request. - * - * The async variant is {@see self::updateAsync()} . - * - * @param UpdateRegionHealthCheckRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function update(UpdateRegionHealthCheckRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Update', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionInstanceGroupManagersBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionInstanceGroupManagersBaseClient.php deleted file mode 100644 index b3beff0643f2..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionInstanceGroupManagersBaseClient.php +++ /dev/null @@ -1,723 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/region_instance_group_managers_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/region_instance_group_managers_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/region_instance_group_managers_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Flags the specified instances to be immediately removed from the managed instance group. Abandoning an instance does not delete the instance, but it does remove the instance from any target pools that are applied by the managed instance group. This method reduces the targetSize of the managed instance group by the number of instances that you abandon. This operation is marked as DONE when the action is scheduled even if the instances have not yet been removed from the group. You must separately verify the status of the abandoning action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. - * - * The async variant is {@see self::abandonInstancesAsync()} . - * - * @param AbandonInstancesRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function abandonInstances(AbandonInstancesRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AbandonInstances', $request, $callOptions)->wait(); - } - - /** - * Apply updates to selected instances the managed instance group. - * - * The async variant is {@see self::applyUpdatesToInstancesAsync()} . - * - * @param ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function applyUpdatesToInstances(ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ApplyUpdatesToInstances', $request, $callOptions)->wait(); - } - - /** - * Creates instances with per-instance configurations in this regional managed instance group. Instances are created using the current instance template. The create instances operation is marked DONE if the createInstances request is successful. The underlying actions take additional time. You must separately verify the status of the creating or actions with the listmanagedinstances method. - * - * The async variant is {@see self::createInstancesAsync()} . - * - * @param CreateInstancesRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createInstances(CreateInstancesRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateInstances', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified managed instance group and all of the instances in that group. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Flags the specified instances in the managed instance group to be immediately deleted. The instances are also removed from any target pools of which they were a member. This method reduces the targetSize of the managed instance group by the number of instances that you delete. The deleteInstances operation is marked DONE if the deleteInstances request is successful. The underlying actions take additional time. You must separately verify the status of the deleting action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. - * - * The async variant is {@see self::deleteInstancesAsync()} . - * - * @param DeleteInstancesRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteInstances(DeleteInstancesRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteInstances', $request, $callOptions)->wait(); - } - - /** - * Deletes selected per-instance configurations for the managed instance group. - * - * The async variant is {@see self::deletePerInstanceConfigsAsync()} . - * - * @param DeletePerInstanceConfigsRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deletePerInstanceConfigs(DeletePerInstanceConfigsRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeletePerInstanceConfigs', $request, $callOptions)->wait(); - } - - /** - * Returns all of the details about the specified managed instance group. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InstanceGroupManager - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRegionInstanceGroupManagerRequest $request, array $callOptions = []): InstanceGroupManager - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a managed instance group using the information that you specify in the request. After the group is created, instances in the group are created using the specified instance template. This operation is marked as DONE when the group is created even if the instances in the group have not yet been created. You must separately verify the status of the individual instances with the listmanagedinstances method. A regional managed instance group can contain up to 2000 instances. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of managed instance groups that are contained within the specified region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRegionInstanceGroupManagersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRegionInstanceGroupManagersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Lists all errors thrown by actions on instances for a given regional managed instance group. The filter and orderBy query parameters are not supported. - * - * The async variant is {@see self::listErrorsAsync()} . - * - * @param ListErrorsRegionInstanceGroupManagersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listErrors(ListErrorsRegionInstanceGroupManagersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListErrors', $request, $callOptions); - } - - /** - * Lists the instances in the managed instance group and instances that are scheduled to be created. The list includes any current actions that the group has scheduled for its instances. The orderBy query parameter is not supported. The `pageToken` query parameter is supported only in the alpha and beta API and only if the group's `listManagedInstancesResults` field is set to `PAGINATED`. - * - * The async variant is {@see self::listManagedInstancesAsync()} . - * - * @param ListManagedInstancesRegionInstanceGroupManagersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listManagedInstances(ListManagedInstancesRegionInstanceGroupManagersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListManagedInstances', $request, $callOptions); - } - - /** - * Lists all of the per-instance configurations defined for the managed instance group. The orderBy query parameter is not supported. - * - * The async variant is {@see self::listPerInstanceConfigsAsync()} . - * - * @param ListPerInstanceConfigsRegionInstanceGroupManagersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPerInstanceConfigs(ListPerInstanceConfigsRegionInstanceGroupManagersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPerInstanceConfigs', $request, $callOptions); - } - - /** - * Updates a managed instance group using the information that you specify in the request. This operation is marked as DONE when the group is patched even if the instances in the group are still in the process of being patched. You must separately verify the status of the individual instances with the listmanagedinstances method. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. If you update your group to specify a new template or instance configuration, it's possible that your intended specification for each VM in the group is different from the current state of that VM. To learn how to apply an updated configuration to the VMs in a MIG, see Updating instances in a MIG. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Inserts or patches per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch. - * - * The async variant is {@see self::patchPerInstanceConfigsAsync()} . - * - * @param PatchPerInstanceConfigsRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patchPerInstanceConfigs(PatchPerInstanceConfigsRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('PatchPerInstanceConfigs', $request, $callOptions)->wait(); - } - - /** - * Flags the specified VM instances in the managed instance group to be immediately recreated. Each instance is recreated using the group's current configuration. This operation is marked as DONE when the flag is set even if the instances have not yet been recreated. You must separately verify the status of each instance by checking its currentAction field; for more information, see Checking the status of managed instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. - * - * The async variant is {@see self::recreateInstancesAsync()} . - * - * @param RecreateInstancesRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function recreateInstances(RecreateInstancesRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RecreateInstances', $request, $callOptions)->wait(); - } - - /** - * Changes the intended size of the managed instance group. If you increase the size, the group creates new instances using the current instance template. If you decrease the size, the group deletes one or more instances. The resize operation is marked DONE if the resize request is successful. The underlying actions take additional time. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. - * - * The async variant is {@see self::resizeAsync()} . - * - * @param ResizeRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function resize(ResizeRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Resize', $request, $callOptions)->wait(); - } - - /** - * Sets the instance template to use when creating new instances or recreating instances in this group. Existing instances are not affected. - * - * The async variant is {@see self::setInstanceTemplateAsync()} . - * - * @param SetInstanceTemplateRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setInstanceTemplate(SetInstanceTemplateRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetInstanceTemplate', $request, $callOptions)->wait(); - } - - /** - * Modifies the target pools to which all new instances in this group are assigned. Existing instances in the group are not affected. - * - * The async variant is {@see self::setTargetPoolsAsync()} . - * - * @param SetTargetPoolsRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setTargetPools(SetTargetPoolsRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetTargetPools', $request, $callOptions)->wait(); - } - - /** - * Inserts or updates per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch. - * - * The async variant is {@see self::updatePerInstanceConfigsAsync()} . - * - * @param UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updatePerInstanceConfigs(UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdatePerInstanceConfigs', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionInstanceGroupsBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionInstanceGroupsBaseClient.php deleted file mode 100644 index 05488d2493d0..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionInstanceGroupsBaseClient.php +++ /dev/null @@ -1,333 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/region_instance_groups_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/region_instance_groups_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/region_instance_groups_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Returns the specified instance group resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRegionInstanceGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InstanceGroup - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRegionInstanceGroupRequest $request, array $callOptions = []): InstanceGroup - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of instance group resources contained within the specified region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRegionInstanceGroupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRegionInstanceGroupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Lists the instances in the specified instance group and displays information about the named ports. Depending on the specified options, this method can list all instances or only the instances that are running. The orderBy query parameter is not supported. - * - * The async variant is {@see self::listInstancesAsync()} . - * - * @param ListInstancesRegionInstanceGroupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listInstances(ListInstancesRegionInstanceGroupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListInstances', $request, $callOptions); - } - - /** - * Sets the named ports for the specified regional instance group. - * - * The async variant is {@see self::setNamedPortsAsync()} . - * - * @param SetNamedPortsRegionInstanceGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setNamedPorts(SetNamedPortsRegionInstanceGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetNamedPorts', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionInstanceTemplatesBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionInstanceTemplatesBaseClient.php deleted file mode 100644 index a61712ac0d18..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionInstanceTemplatesBaseClient.php +++ /dev/null @@ -1,333 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/region_instance_templates_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/region_instance_templates_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/region_instance_templates_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified instance template. Deleting an instance template is permanent and cannot be undone. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteRegionInstanceTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteRegionInstanceTemplateRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified instance template. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRegionInstanceTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InstanceTemplate - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRegionInstanceTemplateRequest $request, array $callOptions = []): InstanceTemplate - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates an instance template in the specified project and region using the global instance template whose URL is included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertRegionInstanceTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertRegionInstanceTemplateRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of instance templates that are contained within the specified project and region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRegionInstanceTemplatesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRegionInstanceTemplatesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionInstancesBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionInstancesBaseClient.php deleted file mode 100644 index 2dfe117f7b40..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionInstancesBaseClient.php +++ /dev/null @@ -1,252 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/region_instances_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/region_instances_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/region_instances_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates multiple instances in a given region. Count specifies the number of instances to create. - * - * The async variant is {@see self::bulkInsertAsync()} . - * - * @param BulkInsertRegionInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function bulkInsert(BulkInsertRegionInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BulkInsert', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionNetworkEndpointGroupsBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionNetworkEndpointGroupsBaseClient.php deleted file mode 100644 index d253f8e89623..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionNetworkEndpointGroupsBaseClient.php +++ /dev/null @@ -1,333 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/region_network_endpoint_groups_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/region_network_endpoint_groups_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/region_network_endpoint_groups_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified network endpoint group. Note that the NEG cannot be deleted if it is configured as a backend of a backend service. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteRegionNetworkEndpointGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteRegionNetworkEndpointGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified network endpoint group. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRegionNetworkEndpointGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NetworkEndpointGroup - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRegionNetworkEndpointGroupRequest $request, array $callOptions = []): NetworkEndpointGroup - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a network endpoint group in the specified project using the parameters that are included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertRegionNetworkEndpointGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertRegionNetworkEndpointGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of regional network endpoint groups available to the specified project in the given region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRegionNetworkEndpointGroupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRegionNetworkEndpointGroupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionNetworkFirewallPoliciesBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionNetworkFirewallPoliciesBaseClient.php deleted file mode 100644 index cee669bf1fdc..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionNetworkFirewallPoliciesBaseClient.php +++ /dev/null @@ -1,676 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/region_network_firewall_policies_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/region_network_firewall_policies_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/region_network_firewall_policies_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Inserts an association for the specified network firewall policy. - * - * The async variant is {@see self::addAssociationAsync()} . - * - * @param AddAssociationRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addAssociation(AddAssociationRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AddAssociation', $request, $callOptions)->wait(); - } - - /** - * Inserts a rule into a network firewall policy. - * - * The async variant is {@see self::addRuleAsync()} . - * - * @param AddRuleRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addRule(AddRuleRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AddRule', $request, $callOptions)->wait(); - } - - /** - * Copies rules to the specified network firewall policy. - * - * The async variant is {@see self::cloneRulesAsync()} . - * - * @param CloneRulesRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function cloneRules(CloneRulesRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CloneRules', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified network firewall policy. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified network firewall policy. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FirewallPolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicy - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Gets an association with the specified name. - * - * The async variant is {@see self::getAssociationAsync()} . - * - * @param GetAssociationRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FirewallPolicyAssociation - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAssociation(GetAssociationRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicyAssociation - { - return $this->startApiCall('GetAssociation', $request, $callOptions)->wait(); - } - - /** - * Returns the effective firewalls on a given network. - * - * The async variant is {@see self::getEffectiveFirewallsAsync()} . - * - * @param GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEffectiveFirewalls(GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse - { - return $this->startApiCall('GetEffectiveFirewalls', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. May be empty if no such policy or resource exists. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets a rule of the specified priority. - * - * The async variant is {@see self::getRuleAsync()} . - * - * @param GetRuleRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FirewallPolicyRule - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRule(GetRuleRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicyRule - { - return $this->startApiCall('GetRule', $request, $callOptions)->wait(); - } - - /** - * Creates a new network firewall policy in the specified project and region. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Lists all the network firewall policies that have been configured for the specified project in the given region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRegionNetworkFirewallPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRegionNetworkFirewallPoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Patches the specified network firewall policy. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Patches a rule of the specified priority. - * - * The async variant is {@see self::patchRuleAsync()} . - * - * @param PatchRuleRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patchRule(PatchRuleRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('PatchRule', $request, $callOptions)->wait(); - } - - /** - * Removes an association for the specified network firewall policy. - * - * The async variant is {@see self::removeAssociationAsync()} . - * - * @param RemoveAssociationRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function removeAssociation(RemoveAssociationRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RemoveAssociation', $request, $callOptions)->wait(); - } - - /** - * Deletes a rule of the specified priority. - * - * The async variant is {@see self::removeRuleAsync()} . - * - * @param RemoveRuleRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function removeRule(RemoveRuleRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RemoveRule', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionNotificationEndpointsBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionNotificationEndpointsBaseClient.php deleted file mode 100644 index b0dd561483eb..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionNotificationEndpointsBaseClient.php +++ /dev/null @@ -1,333 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/region_notification_endpoints_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/region_notification_endpoints_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/region_notification_endpoints_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified NotificationEndpoint in the given region - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteRegionNotificationEndpointRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteRegionNotificationEndpointRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified NotificationEndpoint resource in the given region. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRegionNotificationEndpointRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NotificationEndpoint - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRegionNotificationEndpointRequest $request, array $callOptions = []): NotificationEndpoint - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Create a NotificationEndpoint in the specified project in the given region using the parameters that are included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertRegionNotificationEndpointRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertRegionNotificationEndpointRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Lists the NotificationEndpoints for a project in the given region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRegionNotificationEndpointsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRegionNotificationEndpointsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionOperationsBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionOperationsBaseClient.php deleted file mode 100644 index 9ca514e27f8a..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionOperationsBaseClient.php +++ /dev/null @@ -1,279 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/region_operations_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/region_operations_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/region_operations_rest_client_config.php', - ], - ], - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified region-specific Operations resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteRegionOperationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DeleteRegionOperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteRegionOperationRequest $request, array $callOptions = []): DeleteRegionOperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Retrieves the specified region-specific Operations resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRegionOperationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRegionOperationRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of Operation resources contained within the specified region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRegionOperationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRegionOperationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method differs from the `GET` method in that it waits for no more than the default deadline (2 minutes) and then returns the current state of the operation, which might be `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`. - * - * The async variant is {@see self::waitAsync()} . - * - * @param WaitRegionOperationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function wait(WaitRegionOperationRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Wait', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionSecurityPoliciesBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionSecurityPoliciesBaseClient.php deleted file mode 100644 index 2577a24644e1..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionSecurityPoliciesBaseClient.php +++ /dev/null @@ -1,359 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/region_security_policies_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/region_security_policies_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/region_security_policies_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified policy. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteRegionSecurityPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteRegionSecurityPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * List all of the ordered rules present in a single specified policy. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRegionSecurityPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SecurityPolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRegionSecurityPolicyRequest $request, array $callOptions = []): SecurityPolicy - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a new policy in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertRegionSecurityPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertRegionSecurityPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * List all the policies that have been configured for the specified project and region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRegionSecurityPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRegionSecurityPoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Patches the specified policy with the data included in the request. To clear fields in the policy, leave the fields empty and specify them in the updateMask. This cannot be used to be update the rules in the policy. Please use the per rule methods like addRule, patchRule, and removeRule instead. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchRegionSecurityPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchRegionSecurityPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionSslCertificatesBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionSslCertificatesBaseClient.php deleted file mode 100644 index 68b3a55a9b80..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionSslCertificatesBaseClient.php +++ /dev/null @@ -1,333 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/region_ssl_certificates_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/region_ssl_certificates_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/region_ssl_certificates_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified SslCertificate resource in the region. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteRegionSslCertificateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteRegionSslCertificateRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified SslCertificate resource in the specified region. Get a list of available SSL certificates by making a list() request. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRegionSslCertificateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SslCertificate - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRegionSslCertificateRequest $request, array $callOptions = []): SslCertificate - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a SslCertificate resource in the specified project and region using the data included in the request - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertRegionSslCertificateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertRegionSslCertificateRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of SslCertificate resources available to the specified project in the specified region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRegionSslCertificatesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRegionSslCertificatesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionSslPoliciesBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionSslPoliciesBaseClient.php deleted file mode 100644 index 02b764f985ad..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionSslPoliciesBaseClient.php +++ /dev/null @@ -1,385 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/region_ssl_policies_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/region_ssl_policies_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/region_ssl_policies_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified SSL policy. The SSL policy resource can be deleted only if it is not in use by any TargetHttpsProxy or TargetSslProxy resources. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteRegionSslPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteRegionSslPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Lists all of the ordered rules present in a single specified policy. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRegionSslPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SslPolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRegionSslPolicyRequest $request, array $callOptions = []): SslPolicy - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a new policy in the specified project and region using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertRegionSslPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertRegionSslPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Lists all the SSL policies that have been configured for the specified project and region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRegionSslPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRegionSslPoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Lists all features that can be specified in the SSL policy when using custom profile. - * - * The async variant is {@see self::listAvailableFeaturesAsync()} . - * - * @param ListAvailableFeaturesRegionSslPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SslPoliciesListAvailableFeaturesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAvailableFeatures(ListAvailableFeaturesRegionSslPoliciesRequest $request, array $callOptions = []): SslPoliciesListAvailableFeaturesResponse - { - return $this->startApiCall('ListAvailableFeatures', $request, $callOptions)->wait(); - } - - /** - * Patches the specified SSL policy with the data included in the request. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchRegionSslPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchRegionSslPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionTargetHttpProxiesBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionTargetHttpProxiesBaseClient.php deleted file mode 100644 index 6b4a816de026..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionTargetHttpProxiesBaseClient.php +++ /dev/null @@ -1,359 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/region_target_http_proxies_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/region_target_http_proxies_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/region_target_http_proxies_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified TargetHttpProxy resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteRegionTargetHttpProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteRegionTargetHttpProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified TargetHttpProxy resource in the specified region. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRegionTargetHttpProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TargetHttpProxy - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRegionTargetHttpProxyRequest $request, array $callOptions = []): TargetHttpProxy - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a TargetHttpProxy resource in the specified project and region using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertRegionTargetHttpProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertRegionTargetHttpProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of TargetHttpProxy resources available to the specified project in the specified region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRegionTargetHttpProxiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRegionTargetHttpProxiesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Changes the URL map for TargetHttpProxy. - * - * The async variant is {@see self::setUrlMapAsync()} . - * - * @param SetUrlMapRegionTargetHttpProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setUrlMap(SetUrlMapRegionTargetHttpProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetUrlMap', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionTargetHttpsProxiesBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionTargetHttpsProxiesBaseClient.php deleted file mode 100644 index 1e17aed1bd07..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionTargetHttpsProxiesBaseClient.php +++ /dev/null @@ -1,411 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/region_target_https_proxies_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/region_target_https_proxies_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/region_target_https_proxies_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified TargetHttpsProxy resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteRegionTargetHttpsProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteRegionTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified TargetHttpsProxy resource in the specified region. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRegionTargetHttpsProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TargetHttpsProxy - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRegionTargetHttpsProxyRequest $request, array $callOptions = []): TargetHttpsProxy - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a TargetHttpsProxy resource in the specified project and region using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertRegionTargetHttpsProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertRegionTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of TargetHttpsProxy resources available to the specified project in the specified region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRegionTargetHttpsProxiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRegionTargetHttpsProxiesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Patches the specified regional TargetHttpsProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchRegionTargetHttpsProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchRegionTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Replaces SslCertificates for TargetHttpsProxy. - * - * The async variant is {@see self::setSslCertificatesAsync()} . - * - * @param SetSslCertificatesRegionTargetHttpsProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setSslCertificates(SetSslCertificatesRegionTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetSslCertificates', $request, $callOptions)->wait(); - } - - /** - * Changes the URL map for TargetHttpsProxy. - * - * The async variant is {@see self::setUrlMapAsync()} . - * - * @param SetUrlMapRegionTargetHttpsProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setUrlMap(SetUrlMapRegionTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetUrlMap', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionTargetTcpProxiesBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionTargetTcpProxiesBaseClient.php deleted file mode 100644 index 21e9f532c58a..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionTargetTcpProxiesBaseClient.php +++ /dev/null @@ -1,333 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/region_target_tcp_proxies_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/region_target_tcp_proxies_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/region_target_tcp_proxies_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified TargetTcpProxy resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteRegionTargetTcpProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteRegionTargetTcpProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified TargetTcpProxy resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRegionTargetTcpProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TargetTcpProxy - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRegionTargetTcpProxyRequest $request, array $callOptions = []): TargetTcpProxy - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a TargetTcpProxy resource in the specified project and region using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertRegionTargetTcpProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertRegionTargetTcpProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of TargetTcpProxy resources available to the specified project in a given region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRegionTargetTcpProxiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRegionTargetTcpProxiesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionUrlMapsBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionUrlMapsBaseClient.php deleted file mode 100644 index 13682b575e4f..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionUrlMapsBaseClient.php +++ /dev/null @@ -1,411 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/region_url_maps_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/region_url_maps_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/region_url_maps_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified UrlMap resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteRegionUrlMapRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteRegionUrlMapRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified UrlMap resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRegionUrlMapRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 UrlMap - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRegionUrlMapRequest $request, array $callOptions = []): UrlMap - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a UrlMap resource in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertRegionUrlMapRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertRegionUrlMapRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of UrlMap resources available to the specified project in the specified region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRegionUrlMapsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRegionUrlMapsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Patches the specified UrlMap resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchRegionUrlMapRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchRegionUrlMapRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Updates the specified UrlMap resource with the data included in the request. - * - * The async variant is {@see self::updateAsync()} . - * - * @param UpdateRegionUrlMapRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function update(UpdateRegionUrlMapRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Update', $request, $callOptions)->wait(); - } - - /** - * Runs static validation for the UrlMap. In particular, the tests of the provided UrlMap will be run. Calling this method does NOT create the UrlMap. - * - * The async variant is {@see self::validateAsync()} . - * - * @param ValidateRegionUrlMapRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 UrlMapsValidateResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function validate(ValidateRegionUrlMapRequest $request, array $callOptions = []): UrlMapsValidateResponse - { - return $this->startApiCall('Validate', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RegionsBaseClient.php b/Compute/src/V1/Client/BaseClient/RegionsBaseClient.php deleted file mode 100644 index 48b4a4fd26f6..000000000000 --- a/Compute/src/V1/Client/BaseClient/RegionsBaseClient.php +++ /dev/null @@ -1,227 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/regions_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/regions_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/regions_rest_client_config.php', - ], - ], - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Returns the specified Region resource. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the `quotas` field). To exclude one or more fields, set your request's `fields` query parameter to only include the fields you need. For example, to only include the `id` and `selfLink` fields, add the query parameter `?fields=id,selfLink` to your request. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRegionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Region - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRegionRequest $request, array $callOptions = []): Region - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of region resources available to the specified project. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the `items.quotas` field). To exclude one or more fields, set your request's `fields` query parameter to only include the fields you need. For example, to only include the `id` and `selfLink` fields, add the query parameter `?fields=id,selfLink` to your request. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRegionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRegionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } -} diff --git a/Compute/src/V1/Client/BaseClient/ReservationsBaseClient.php b/Compute/src/V1/Client/BaseClient/ReservationsBaseClient.php deleted file mode 100644 index 61b39c19d654..000000000000 --- a/Compute/src/V1/Client/BaseClient/ReservationsBaseClient.php +++ /dev/null @@ -1,490 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/reservations_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/reservations_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/reservations_rest_client_config.php', - ], - ], - 'operationsClientClass' => ZoneOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an ZoneOperationsClient object with the same endpoint as $this. - * - * @return ZoneOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getZone', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves an aggregated list of reservations. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListReservationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListReservationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified reservation. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteReservationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteReservationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Retrieves information about the specified reservation. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetReservationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Reservation - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetReservationRequest $request, array $callOptions = []): Reservation - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. May be empty if no such policy or resource exists. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyReservationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyReservationRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Creates a new reservation. For more information, read Reserving zonal resources. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertReservationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertReservationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * A list of all the reservations that have been configured for the specified project in specified zone. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListReservationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListReservationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Resizes the reservation (applicable to standalone reservations only). For more information, read Modifying reservations. - * - * The async variant is {@see self::resizeAsync()} . - * - * @param ResizeReservationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function resize(ResizeReservationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Resize', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyReservationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyReservationRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsReservationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsReservationRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Update share settings of the reservation. - * - * The async variant is {@see self::updateAsync()} . - * - * @param UpdateReservationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function update(UpdateReservationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Update', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/ResourcePoliciesBaseClient.php b/Compute/src/V1/Client/BaseClient/ResourcePoliciesBaseClient.php deleted file mode 100644 index 6d9bac7d309b..000000000000 --- a/Compute/src/V1/Client/BaseClient/ResourcePoliciesBaseClient.php +++ /dev/null @@ -1,464 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/resource_policies_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/resource_policies_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/resource_policies_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves an aggregated list of resource policies. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListResourcePoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListResourcePoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified resource policy. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteResourcePolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteResourcePolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Retrieves all information of the specified resource policy. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetResourcePolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ResourcePolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetResourcePolicyRequest $request, array $callOptions = []): ResourcePolicy - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. May be empty if no such policy or resource exists. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyResourcePolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyResourcePolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Creates a new resource policy. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertResourcePolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertResourcePolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * A list all the resource policies that have been configured for the specified project in specified region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListResourcePoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListResourcePoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Modify the specified resource policy. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchResourcePolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchResourcePolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyResourcePolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyResourcePolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsResourcePolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsResourcePolicyRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RoutersBaseClient.php b/Compute/src/V1/Client/BaseClient/RoutersBaseClient.php deleted file mode 100644 index ca5e43314b51..000000000000 --- a/Compute/src/V1/Client/BaseClient/RoutersBaseClient.php +++ /dev/null @@ -1,490 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/routers_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/routers_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/routers_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves an aggregated list of routers. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListRoutersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListRoutersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified Router resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteRouterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteRouterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified Router resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRouterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Router - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRouterRequest $request, array $callOptions = []): Router - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Retrieves runtime Nat mapping information of VM endpoints. - * - * The async variant is {@see self::getNatMappingInfoAsync()} . - * - * @param GetNatMappingInfoRoutersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function getNatMappingInfo(GetNatMappingInfoRoutersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('GetNatMappingInfo', $request, $callOptions); - } - - /** - * Retrieves runtime information of the specified router. - * - * The async variant is {@see self::getRouterStatusAsync()} . - * - * @param GetRouterStatusRouterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RouterStatusResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRouterStatus(GetRouterStatusRouterRequest $request, array $callOptions = []): RouterStatusResponse - { - return $this->startApiCall('GetRouterStatus', $request, $callOptions)->wait(); - } - - /** - * Creates a Router resource in the specified project and region using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertRouterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertRouterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of Router resources available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRoutersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRoutersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Patches the specified Router resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchRouterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchRouterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Preview fields auto-generated during router create and update operations. Calling this method does NOT create or update the router. - * - * The async variant is {@see self::previewAsync()} . - * - * @param PreviewRouterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RoutersPreviewResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function preview(PreviewRouterRequest $request, array $callOptions = []): RoutersPreviewResponse - { - return $this->startApiCall('Preview', $request, $callOptions)->wait(); - } - - /** - * Updates the specified Router resource with the data included in the request. This method conforms to PUT semantics, which requests that the state of the target resource be created or replaced with the state defined by the representation enclosed in the request message payload. - * - * The async variant is {@see self::updateAsync()} . - * - * @param UpdateRouterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function update(UpdateRouterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Update', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/RoutesBaseClient.php b/Compute/src/V1/Client/BaseClient/RoutesBaseClient.php deleted file mode 100644 index 7bc984e59c91..000000000000 --- a/Compute/src/V1/Client/BaseClient/RoutesBaseClient.php +++ /dev/null @@ -1,331 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/routes_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/routes_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/routes_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified Route resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteRouteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteRouteRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified Route resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetRouteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Route - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetRouteRequest $request, array $callOptions = []): Route - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a Route resource in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertRouteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertRouteRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of Route resources available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListRoutesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListRoutesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } -} diff --git a/Compute/src/V1/Client/BaseClient/SecurityPoliciesBaseClient.php b/Compute/src/V1/Client/BaseClient/SecurityPoliciesBaseClient.php deleted file mode 100644 index ae92418ca2bd..000000000000 --- a/Compute/src/V1/Client/BaseClient/SecurityPoliciesBaseClient.php +++ /dev/null @@ -1,541 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/security_policies_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/security_policies_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/security_policies_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Inserts a rule into a security policy. - * - * The async variant is {@see self::addRuleAsync()} . - * - * @param AddRuleSecurityPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addRule(AddRuleSecurityPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AddRule', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of all SecurityPolicy resources, regional and global, available to the specified project. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListSecurityPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListSecurityPoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified policy. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteSecurityPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteSecurityPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * List all of the ordered rules present in a single specified policy. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetSecurityPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SecurityPolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetSecurityPolicyRequest $request, array $callOptions = []): SecurityPolicy - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Gets a rule at the specified priority. - * - * The async variant is {@see self::getRuleAsync()} . - * - * @param GetRuleSecurityPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SecurityPolicyRule - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRule(GetRuleSecurityPolicyRequest $request, array $callOptions = []): SecurityPolicyRule - { - return $this->startApiCall('GetRule', $request, $callOptions)->wait(); - } - - /** - * Creates a new policy in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertSecurityPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertSecurityPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * List all the policies that have been configured for the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListSecurityPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListSecurityPoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Gets the current list of preconfigured Web Application Firewall (WAF) expressions. - * - * The async variant is {@see self::listPreconfiguredExpressionSetsAsync()} . - * - * @param ListPreconfiguredExpressionSetsSecurityPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SecurityPoliciesListPreconfiguredExpressionSetsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPreconfiguredExpressionSets(ListPreconfiguredExpressionSetsSecurityPoliciesRequest $request, array $callOptions = []): SecurityPoliciesListPreconfiguredExpressionSetsResponse - { - return $this->startApiCall('ListPreconfiguredExpressionSets', $request, $callOptions)->wait(); - } - - /** - * Patches the specified policy with the data included in the request. To clear fields in the policy, leave the fields empty and specify them in the updateMask. This cannot be used to be update the rules in the policy. Please use the per rule methods like addRule, patchRule, and removeRule instead. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchSecurityPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchSecurityPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Patches a rule at the specified priority. To clear fields in the rule, leave the fields empty and specify them in the updateMask. - * - * The async variant is {@see self::patchRuleAsync()} . - * - * @param PatchRuleSecurityPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patchRule(PatchRuleSecurityPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('PatchRule', $request, $callOptions)->wait(); - } - - /** - * Deletes a rule at the specified priority. - * - * The async variant is {@see self::removeRuleAsync()} . - * - * @param RemoveRuleSecurityPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function removeRule(RemoveRuleSecurityPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RemoveRule', $request, $callOptions)->wait(); - } - - /** - * Sets the labels on a security policy. To learn more about labels, read the Labeling Resources documentation. - * - * The async variant is {@see self::setLabelsAsync()} . - * - * @param SetLabelsSecurityPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setLabels(SetLabelsSecurityPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/ServiceAttachmentsBaseClient.php b/Compute/src/V1/Client/BaseClient/ServiceAttachmentsBaseClient.php deleted file mode 100644 index 9060f65707a2..000000000000 --- a/Compute/src/V1/Client/BaseClient/ServiceAttachmentsBaseClient.php +++ /dev/null @@ -1,464 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/service_attachments_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/service_attachments_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/service_attachments_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves the list of all ServiceAttachment resources, regional and global, available to the specified project. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListServiceAttachmentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListServiceAttachmentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified ServiceAttachment in the given scope - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteServiceAttachmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteServiceAttachmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified ServiceAttachment resource in the given scope. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetServiceAttachmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ServiceAttachment - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetServiceAttachmentRequest $request, array $callOptions = []): ServiceAttachment - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. May be empty if no such policy or resource exists. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyServiceAttachmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyServiceAttachmentRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Creates a ServiceAttachment in the specified project in the given scope using the parameters that are included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertServiceAttachmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertServiceAttachmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Lists the ServiceAttachments for a project in the given scope. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListServiceAttachmentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListServiceAttachmentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Patches the specified ServiceAttachment resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchServiceAttachmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchServiceAttachmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyServiceAttachmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyServiceAttachmentRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsServiceAttachmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsServiceAttachmentRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/SnapshotsBaseClient.php b/Compute/src/V1/Client/BaseClient/SnapshotsBaseClient.php deleted file mode 100644 index 95ae79d251c7..000000000000 --- a/Compute/src/V1/Client/BaseClient/SnapshotsBaseClient.php +++ /dev/null @@ -1,437 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/snapshots_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/snapshots_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/snapshots_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified Snapshot resource. Keep in mind that deleting a single snapshot might not necessarily delete all the data on that snapshot. If any data on the snapshot that is marked for deletion is needed for subsequent snapshots, the data will be moved to the next corresponding snapshot. For more information, see Deleting snapshots. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteSnapshotRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified Snapshot resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Snapshot - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetSnapshotRequest $request, array $callOptions = []): Snapshot - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. May be empty if no such policy or resource exists. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicySnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicySnapshotRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Creates a snapshot in the specified project using the data included in the request. For regular snapshot creation, consider using this method instead of disks.createSnapshot, as this method supports more features, such as creating snapshots in a project different from the source disk project. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertSnapshotRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of Snapshot resources contained within the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListSnapshotsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListSnapshotsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicySnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicySnapshotRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the labels on a snapshot. To learn more about labels, read the Labeling Resources documentation. - * - * The async variant is {@see self::setLabelsAsync()} . - * - * @param SetLabelsSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setLabels(SetLabelsSnapshotRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsSnapshotRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/SslCertificatesBaseClient.php b/Compute/src/V1/Client/BaseClient/SslCertificatesBaseClient.php deleted file mode 100644 index 28e709b22d73..000000000000 --- a/Compute/src/V1/Client/BaseClient/SslCertificatesBaseClient.php +++ /dev/null @@ -1,357 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/ssl_certificates_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/ssl_certificates_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/ssl_certificates_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves the list of all SslCertificate resources, regional and global, available to the specified project. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListSslCertificatesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListSslCertificatesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified SslCertificate resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteSslCertificateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteSslCertificateRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified SslCertificate resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetSslCertificateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SslCertificate - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetSslCertificateRequest $request, array $callOptions = []): SslCertificate - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a SslCertificate resource in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertSslCertificateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertSslCertificateRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of SslCertificate resources available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListSslCertificatesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListSslCertificatesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } -} diff --git a/Compute/src/V1/Client/BaseClient/SslPoliciesBaseClient.php b/Compute/src/V1/Client/BaseClient/SslPoliciesBaseClient.php deleted file mode 100644 index 2c33fa830607..000000000000 --- a/Compute/src/V1/Client/BaseClient/SslPoliciesBaseClient.php +++ /dev/null @@ -1,410 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/ssl_policies_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/ssl_policies_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/ssl_policies_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves the list of all SslPolicy resources, regional and global, available to the specified project. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListSslPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListSslPoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified SSL policy. The SSL policy resource can be deleted only if it is not in use by any TargetHttpsProxy or TargetSslProxy resources. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteSslPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteSslPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Lists all of the ordered rules present in a single specified policy. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetSslPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SslPolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetSslPolicyRequest $request, array $callOptions = []): SslPolicy - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Returns the specified SSL policy resource. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertSslPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertSslPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Lists all the SSL policies that have been configured for the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListSslPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListSslPoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Lists all features that can be specified in the SSL policy when using custom profile. - * - * The async variant is {@see self::listAvailableFeaturesAsync()} . - * - * @param ListAvailableFeaturesSslPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SslPoliciesListAvailableFeaturesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAvailableFeatures(ListAvailableFeaturesSslPoliciesRequest $request, array $callOptions = []): SslPoliciesListAvailableFeaturesResponse - { - return $this->startApiCall('ListAvailableFeatures', $request, $callOptions)->wait(); - } - - /** - * Patches the specified SSL policy with the data included in the request. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchSslPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchSslPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/SubnetworksBaseClient.php b/Compute/src/V1/Client/BaseClient/SubnetworksBaseClient.php deleted file mode 100644 index e8682c83a081..000000000000 --- a/Compute/src/V1/Client/BaseClient/SubnetworksBaseClient.php +++ /dev/null @@ -1,542 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/subnetworks_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/subnetworks_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/subnetworks_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves an aggregated list of subnetworks. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListSubnetworksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListSubnetworksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified subnetwork. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteSubnetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteSubnetworkRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Expands the IP CIDR range of the subnetwork to a specified value. - * - * The async variant is {@see self::expandIpCidrRangeAsync()} . - * - * @param ExpandIpCidrRangeSubnetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function expandIpCidrRange(ExpandIpCidrRangeSubnetworkRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ExpandIpCidrRange', $request, $callOptions)->wait(); - } - - /** - * Returns the specified subnetwork. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetSubnetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Subnetwork - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetSubnetworkRequest $request, array $callOptions = []): Subnetwork - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. May be empty if no such policy or resource exists. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicySubnetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicySubnetworkRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Creates a subnetwork in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertSubnetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertSubnetworkRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of subnetworks available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListSubnetworksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListSubnetworksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Retrieves an aggregated list of all usable subnetworks in the project. - * - * The async variant is {@see self::listUsableAsync()} . - * - * @param ListUsableSubnetworksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listUsable(ListUsableSubnetworksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListUsable', $request, $callOptions); - } - - /** - * Patches the specified subnetwork with the data included in the request. Only certain fields can be updated with a patch request as indicated in the field descriptions. You must specify the current fingerprint of the subnetwork resource being patched. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchSubnetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchSubnetworkRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicySubnetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicySubnetworkRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Set whether VMs in this subnet can access Google services without assigning external IP addresses through Private Google Access. - * - * The async variant is {@see self::setPrivateIpGoogleAccessAsync()} . - * - * @param SetPrivateIpGoogleAccessSubnetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setPrivateIpGoogleAccess(SetPrivateIpGoogleAccessSubnetworkRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetPrivateIpGoogleAccess', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsSubnetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsSubnetworkRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/TargetGrpcProxiesBaseClient.php b/Compute/src/V1/Client/BaseClient/TargetGrpcProxiesBaseClient.php deleted file mode 100644 index 84a3c6dd8930..000000000000 --- a/Compute/src/V1/Client/BaseClient/TargetGrpcProxiesBaseClient.php +++ /dev/null @@ -1,357 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/target_grpc_proxies_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/target_grpc_proxies_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/target_grpc_proxies_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified TargetGrpcProxy in the given scope - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteTargetGrpcProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteTargetGrpcProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified TargetGrpcProxy resource in the given scope. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetTargetGrpcProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TargetGrpcProxy - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetTargetGrpcProxyRequest $request, array $callOptions = []): TargetGrpcProxy - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a TargetGrpcProxy in the specified project in the given scope using the parameters that are included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertTargetGrpcProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertTargetGrpcProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Lists the TargetGrpcProxies for a project in the given scope. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListTargetGrpcProxiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListTargetGrpcProxiesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Patches the specified TargetGrpcProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchTargetGrpcProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchTargetGrpcProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/TargetHttpProxiesBaseClient.php b/Compute/src/V1/Client/BaseClient/TargetHttpProxiesBaseClient.php deleted file mode 100644 index a97422e2d257..000000000000 --- a/Compute/src/V1/Client/BaseClient/TargetHttpProxiesBaseClient.php +++ /dev/null @@ -1,409 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/target_http_proxies_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/target_http_proxies_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/target_http_proxies_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves the list of all TargetHttpProxy resources, regional and global, available to the specified project. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListTargetHttpProxiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListTargetHttpProxiesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified TargetHttpProxy resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteTargetHttpProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteTargetHttpProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified TargetHttpProxy resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetTargetHttpProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TargetHttpProxy - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetTargetHttpProxyRequest $request, array $callOptions = []): TargetHttpProxy - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a TargetHttpProxy resource in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertTargetHttpProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertTargetHttpProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of TargetHttpProxy resources available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListTargetHttpProxiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListTargetHttpProxiesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Patches the specified TargetHttpProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchTargetHttpProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchTargetHttpProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Changes the URL map for TargetHttpProxy. - * - * The async variant is {@see self::setUrlMapAsync()} . - * - * @param SetUrlMapTargetHttpProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setUrlMap(SetUrlMapTargetHttpProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetUrlMap', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/TargetHttpsProxiesBaseClient.php b/Compute/src/V1/Client/BaseClient/TargetHttpsProxiesBaseClient.php deleted file mode 100644 index c43355f42f82..000000000000 --- a/Compute/src/V1/Client/BaseClient/TargetHttpsProxiesBaseClient.php +++ /dev/null @@ -1,513 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/target_https_proxies_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/target_https_proxies_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/target_https_proxies_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves the list of all TargetHttpsProxy resources, regional and global, available to the specified project. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListTargetHttpsProxiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListTargetHttpsProxiesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified TargetHttpsProxy resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteTargetHttpsProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified TargetHttpsProxy resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetTargetHttpsProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TargetHttpsProxy - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetTargetHttpsProxyRequest $request, array $callOptions = []): TargetHttpsProxy - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a TargetHttpsProxy resource in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertTargetHttpsProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of TargetHttpsProxy resources available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListTargetHttpsProxiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListTargetHttpsProxiesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Patches the specified TargetHttpsProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchTargetHttpsProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Changes the Certificate Map for TargetHttpsProxy. - * - * The async variant is {@see self::setCertificateMapAsync()} . - * - * @param SetCertificateMapTargetHttpsProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setCertificateMap(SetCertificateMapTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetCertificateMap', $request, $callOptions)->wait(); - } - - /** - * Sets the QUIC override policy for TargetHttpsProxy. - * - * The async variant is {@see self::setQuicOverrideAsync()} . - * - * @param SetQuicOverrideTargetHttpsProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setQuicOverride(SetQuicOverrideTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetQuicOverride', $request, $callOptions)->wait(); - } - - /** - * Replaces SslCertificates for TargetHttpsProxy. - * - * The async variant is {@see self::setSslCertificatesAsync()} . - * - * @param SetSslCertificatesTargetHttpsProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setSslCertificates(SetSslCertificatesTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetSslCertificates', $request, $callOptions)->wait(); - } - - /** - * Sets the SSL policy for TargetHttpsProxy. The SSL policy specifies the server-side support for SSL features. This affects connections between clients and the HTTPS proxy load balancer. They do not affect the connection between the load balancer and the backends. - * - * The async variant is {@see self::setSslPolicyAsync()} . - * - * @param SetSslPolicyTargetHttpsProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setSslPolicy(SetSslPolicyTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetSslPolicy', $request, $callOptions)->wait(); - } - - /** - * Changes the URL map for TargetHttpsProxy. - * - * The async variant is {@see self::setUrlMapAsync()} . - * - * @param SetUrlMapTargetHttpsProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setUrlMap(SetUrlMapTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetUrlMap', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/TargetInstancesBaseClient.php b/Compute/src/V1/Client/BaseClient/TargetInstancesBaseClient.php deleted file mode 100644 index d8fed49a2419..000000000000 --- a/Compute/src/V1/Client/BaseClient/TargetInstancesBaseClient.php +++ /dev/null @@ -1,358 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/target_instances_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/target_instances_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/target_instances_rest_client_config.php', - ], - ], - 'operationsClientClass' => ZoneOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an ZoneOperationsClient object with the same endpoint as $this. - * - * @return ZoneOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getZone', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves an aggregated list of target instances. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListTargetInstancesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListTargetInstancesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified TargetInstance resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteTargetInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteTargetInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified TargetInstance resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetTargetInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TargetInstance - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetTargetInstanceRequest $request, array $callOptions = []): TargetInstance - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a TargetInstance resource in the specified project and zone using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertTargetInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertTargetInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of TargetInstance resources available to the specified project and zone. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListTargetInstancesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListTargetInstancesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } -} diff --git a/Compute/src/V1/Client/BaseClient/TargetPoolsBaseClient.php b/Compute/src/V1/Client/BaseClient/TargetPoolsBaseClient.php deleted file mode 100644 index f98af2a40ca1..000000000000 --- a/Compute/src/V1/Client/BaseClient/TargetPoolsBaseClient.php +++ /dev/null @@ -1,515 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/target_pools_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/target_pools_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/target_pools_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Adds health check URLs to a target pool. - * - * The async variant is {@see self::addHealthCheckAsync()} . - * - * @param AddHealthCheckTargetPoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addHealthCheck(AddHealthCheckTargetPoolRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AddHealthCheck', $request, $callOptions)->wait(); - } - - /** - * Adds an instance to a target pool. - * - * The async variant is {@see self::addInstanceAsync()} . - * - * @param AddInstanceTargetPoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addInstance(AddInstanceTargetPoolRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AddInstance', $request, $callOptions)->wait(); - } - - /** - * Retrieves an aggregated list of target pools. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListTargetPoolsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListTargetPoolsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified target pool. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteTargetPoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteTargetPoolRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified target pool. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetTargetPoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TargetPool - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetTargetPoolRequest $request, array $callOptions = []): TargetPool - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Gets the most recent health check results for each IP for the instance that is referenced by the given target pool. - * - * The async variant is {@see self::getHealthAsync()} . - * - * @param GetHealthTargetPoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TargetPoolInstanceHealth - * - * @throws ApiException Thrown if the API call fails. - */ - public function getHealth(GetHealthTargetPoolRequest $request, array $callOptions = []): TargetPoolInstanceHealth - { - return $this->startApiCall('GetHealth', $request, $callOptions)->wait(); - } - - /** - * Creates a target pool in the specified project and region using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertTargetPoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertTargetPoolRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of target pools available to the specified project and region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListTargetPoolsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListTargetPoolsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Removes health check URL from a target pool. - * - * The async variant is {@see self::removeHealthCheckAsync()} . - * - * @param RemoveHealthCheckTargetPoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function removeHealthCheck(RemoveHealthCheckTargetPoolRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RemoveHealthCheck', $request, $callOptions)->wait(); - } - - /** - * Removes instance URL from a target pool. - * - * The async variant is {@see self::removeInstanceAsync()} . - * - * @param RemoveInstanceTargetPoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function removeInstance(RemoveInstanceTargetPoolRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RemoveInstance', $request, $callOptions)->wait(); - } - - /** - * Changes a backup target pool's configurations. - * - * The async variant is {@see self::setBackupAsync()} . - * - * @param SetBackupTargetPoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setBackup(SetBackupTargetPoolRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetBackup', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/TargetSslProxiesBaseClient.php b/Compute/src/V1/Client/BaseClient/TargetSslProxiesBaseClient.php deleted file mode 100644 index cb5143883b65..000000000000 --- a/Compute/src/V1/Client/BaseClient/TargetSslProxiesBaseClient.php +++ /dev/null @@ -1,461 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/target_ssl_proxies_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/target_ssl_proxies_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/target_ssl_proxies_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified TargetSslProxy resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteTargetSslProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteTargetSslProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified TargetSslProxy resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetTargetSslProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TargetSslProxy - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetTargetSslProxyRequest $request, array $callOptions = []): TargetSslProxy - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a TargetSslProxy resource in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertTargetSslProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertTargetSslProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of TargetSslProxy resources available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListTargetSslProxiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListTargetSslProxiesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Changes the BackendService for TargetSslProxy. - * - * The async variant is {@see self::setBackendServiceAsync()} . - * - * @param SetBackendServiceTargetSslProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setBackendService(SetBackendServiceTargetSslProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetBackendService', $request, $callOptions)->wait(); - } - - /** - * Changes the Certificate Map for TargetSslProxy. - * - * The async variant is {@see self::setCertificateMapAsync()} . - * - * @param SetCertificateMapTargetSslProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setCertificateMap(SetCertificateMapTargetSslProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetCertificateMap', $request, $callOptions)->wait(); - } - - /** - * Changes the ProxyHeaderType for TargetSslProxy. - * - * The async variant is {@see self::setProxyHeaderAsync()} . - * - * @param SetProxyHeaderTargetSslProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setProxyHeader(SetProxyHeaderTargetSslProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetProxyHeader', $request, $callOptions)->wait(); - } - - /** - * Changes SslCertificates for TargetSslProxy. - * - * The async variant is {@see self::setSslCertificatesAsync()} . - * - * @param SetSslCertificatesTargetSslProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setSslCertificates(SetSslCertificatesTargetSslProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetSslCertificates', $request, $callOptions)->wait(); - } - - /** - * Sets the SSL policy for TargetSslProxy. The SSL policy specifies the server-side support for SSL features. This affects connections between clients and the SSL proxy load balancer. They do not affect the connection between the load balancer and the backends. - * - * The async variant is {@see self::setSslPolicyAsync()} . - * - * @param SetSslPolicyTargetSslProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setSslPolicy(SetSslPolicyTargetSslProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetSslPolicy', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/TargetTcpProxiesBaseClient.php b/Compute/src/V1/Client/BaseClient/TargetTcpProxiesBaseClient.php deleted file mode 100644 index 3052e3131661..000000000000 --- a/Compute/src/V1/Client/BaseClient/TargetTcpProxiesBaseClient.php +++ /dev/null @@ -1,409 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/target_tcp_proxies_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/target_tcp_proxies_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/target_tcp_proxies_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves the list of all TargetTcpProxy resources, regional and global, available to the specified project. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListTargetTcpProxiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListTargetTcpProxiesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified TargetTcpProxy resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteTargetTcpProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteTargetTcpProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified TargetTcpProxy resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetTargetTcpProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TargetTcpProxy - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetTargetTcpProxyRequest $request, array $callOptions = []): TargetTcpProxy - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a TargetTcpProxy resource in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertTargetTcpProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertTargetTcpProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of TargetTcpProxy resources available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListTargetTcpProxiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListTargetTcpProxiesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Changes the BackendService for TargetTcpProxy. - * - * The async variant is {@see self::setBackendServiceAsync()} . - * - * @param SetBackendServiceTargetTcpProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setBackendService(SetBackendServiceTargetTcpProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetBackendService', $request, $callOptions)->wait(); - } - - /** - * Changes the ProxyHeaderType for TargetTcpProxy. - * - * The async variant is {@see self::setProxyHeaderAsync()} . - * - * @param SetProxyHeaderTargetTcpProxyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setProxyHeader(SetProxyHeaderTargetTcpProxyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetProxyHeader', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/TargetVpnGatewaysBaseClient.php b/Compute/src/V1/Client/BaseClient/TargetVpnGatewaysBaseClient.php deleted file mode 100644 index a3b1f6b7ff0d..000000000000 --- a/Compute/src/V1/Client/BaseClient/TargetVpnGatewaysBaseClient.php +++ /dev/null @@ -1,384 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/target_vpn_gateways_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/target_vpn_gateways_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/target_vpn_gateways_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves an aggregated list of target VPN gateways. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListTargetVpnGatewaysRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListTargetVpnGatewaysRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified target VPN gateway. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteTargetVpnGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteTargetVpnGatewayRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified target VPN gateway. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetTargetVpnGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TargetVpnGateway - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetTargetVpnGatewayRequest $request, array $callOptions = []): TargetVpnGateway - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a target VPN gateway in the specified project and region using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertTargetVpnGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertTargetVpnGatewayRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of target VPN gateways available to the specified project and region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListTargetVpnGatewaysRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListTargetVpnGatewaysRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Sets the labels on a TargetVpnGateway. To learn more about labels, read the Labeling Resources documentation. - * - * The async variant is {@see self::setLabelsAsync()} . - * - * @param SetLabelsTargetVpnGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setLabels(SetLabelsTargetVpnGatewayRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/UrlMapsBaseClient.php b/Compute/src/V1/Client/BaseClient/UrlMapsBaseClient.php deleted file mode 100644 index 12d686c0baf9..000000000000 --- a/Compute/src/V1/Client/BaseClient/UrlMapsBaseClient.php +++ /dev/null @@ -1,462 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/url_maps_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/url_maps_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/url_maps_rest_client_config.php', - ], - ], - 'operationsClientClass' => GlobalOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an GlobalOperationsClient object with the same endpoint as $this. - * - * @return GlobalOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves the list of all UrlMap resources, regional and global, available to the specified project. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListUrlMapsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListUrlMapsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified UrlMap resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteUrlMapRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteUrlMapRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified UrlMap resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetUrlMapRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 UrlMap - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetUrlMapRequest $request, array $callOptions = []): UrlMap - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a UrlMap resource in the specified project using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertUrlMapRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertUrlMapRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Initiates a cache invalidation operation, invalidating the specified path, scoped to the specified UrlMap. For more information, see [Invalidating cached content](https://cloud.google.com/cdn/docs/invalidating-cached-content). - * - * The async variant is {@see self::invalidateCacheAsync()} . - * - * @param InvalidateCacheUrlMapRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function invalidateCache(InvalidateCacheUrlMapRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('InvalidateCache', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of UrlMap resources available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListUrlMapsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListUrlMapsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Patches the specified UrlMap resource with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. - * - * The async variant is {@see self::patchAsync()} . - * - * @param PatchUrlMapRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(PatchUrlMapRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Updates the specified UrlMap resource with the data included in the request. - * - * The async variant is {@see self::updateAsync()} . - * - * @param UpdateUrlMapRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function update(UpdateUrlMapRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Update', $request, $callOptions)->wait(); - } - - /** - * Runs static validation for the UrlMap. In particular, the tests of the provided UrlMap will be run. Calling this method does NOT create the UrlMap. - * - * The async variant is {@see self::validateAsync()} . - * - * @param ValidateUrlMapRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 UrlMapsValidateResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function validate(ValidateUrlMapRequest $request, array $callOptions = []): UrlMapsValidateResponse - { - return $this->startApiCall('Validate', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/VpnGatewaysBaseClient.php b/Compute/src/V1/Client/BaseClient/VpnGatewaysBaseClient.php deleted file mode 100644 index c38b41d52b4b..000000000000 --- a/Compute/src/V1/Client/BaseClient/VpnGatewaysBaseClient.php +++ /dev/null @@ -1,438 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/vpn_gateways_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/vpn_gateways_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/vpn_gateways_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves an aggregated list of VPN gateways. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListVpnGatewaysRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListVpnGatewaysRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified VPN gateway. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteVpnGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteVpnGatewayRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified VPN gateway. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetVpnGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 VpnGateway - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetVpnGatewayRequest $request, array $callOptions = []): VpnGateway - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Returns the status for the specified VPN gateway. - * - * The async variant is {@see self::getStatusAsync()} . - * - * @param GetStatusVpnGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 VpnGatewaysGetStatusResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function getStatus(GetStatusVpnGatewayRequest $request, array $callOptions = []): VpnGatewaysGetStatusResponse - { - return $this->startApiCall('GetStatus', $request, $callOptions)->wait(); - } - - /** - * Creates a VPN gateway in the specified project and region using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertVpnGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertVpnGatewayRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of VPN gateways available to the specified project and region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListVpnGatewaysRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListVpnGatewaysRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Sets the labels on a VpnGateway. To learn more about labels, read the Labeling Resources documentation. - * - * The async variant is {@see self::setLabelsAsync()} . - * - * @param SetLabelsVpnGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setLabels(SetLabelsVpnGatewayRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsVpnGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsVpnGatewayRequest $request, array $callOptions = []): TestPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/VpnTunnelsBaseClient.php b/Compute/src/V1/Client/BaseClient/VpnTunnelsBaseClient.php deleted file mode 100644 index 3fcdfaf2e75b..000000000000 --- a/Compute/src/V1/Client/BaseClient/VpnTunnelsBaseClient.php +++ /dev/null @@ -1,384 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/vpn_tunnels_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/vpn_tunnels_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/vpn_tunnels_rest_client_config.php', - ], - ], - 'operationsClientClass' => RegionOperationsClient::class, - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * Return an RegionOperationsClient object with the same endpoint as $this. - * - * @return RegionOperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** Return the default longrunning operation descriptor config. */ - private function getDefaultOperationDescriptor() - { - return [ - 'additionalArgumentMethods' => [ - 'getProject', - 'getRegion', - ], - 'getOperationMethod' => 'get', - 'cancelOperationMethod' => null, - 'deleteOperationMethod' => 'delete', - 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', - 'operationErrorMessageMethod' => 'getHttpErrorMessage', - 'operationNameMethod' => 'getName', - 'operationStatusMethod' => 'getStatus', - 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, - ]; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves an aggregated list of VPN tunnels. - * - * The async variant is {@see self::aggregatedListAsync()} . - * - * @param AggregatedListVpnTunnelsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregatedList(AggregatedListVpnTunnelsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedList', $request, $callOptions); - } - - /** - * Deletes the specified VpnTunnel resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteVpnTunnelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteVpnTunnelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Returns the specified VpnTunnel resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetVpnTunnelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 VpnTunnel - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetVpnTunnelRequest $request, array $callOptions = []): VpnTunnel - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a VpnTunnel resource in the specified project and region using the data included in the request. - * - * The async variant is {@see self::insertAsync()} . - * - * @param InsertVpnTunnelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(InsertVpnTunnelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of VpnTunnel resources contained in the specified project and region. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListVpnTunnelsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListVpnTunnelsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Sets the labels on a VpnTunnel. To learn more about labels, read the Labeling Resources documentation. - * - * The async variant is {@see self::setLabelsAsync()} . - * - * @param SetLabelsVpnTunnelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setLabels(SetLabelsVpnTunnelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/ZoneOperationsBaseClient.php b/Compute/src/V1/Client/BaseClient/ZoneOperationsBaseClient.php deleted file mode 100644 index 00b26db880d5..000000000000 --- a/Compute/src/V1/Client/BaseClient/ZoneOperationsBaseClient.php +++ /dev/null @@ -1,279 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/zone_operations_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/zone_operations_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/zone_operations_rest_client_config.php', - ], - ], - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified zone-specific Operations resource. - * - * The async variant is {@see self::deleteAsync()} . - * - * @param DeleteZoneOperationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DeleteZoneOperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(DeleteZoneOperationRequest $request, array $callOptions = []): DeleteZoneOperationResponse - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Retrieves the specified zone-specific Operations resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetZoneOperationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetZoneOperationRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of Operation resources contained within the specified zone. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListZoneOperationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListZoneOperationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } - - /** - * Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method waits for no more than the 2 minutes and then returns the current state of the operation, which might be `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`. - * - * The async variant is {@see self::waitAsync()} . - * - * @param WaitZoneOperationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function wait(WaitZoneOperationRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Wait', $request, $callOptions)->wait(); - } -} diff --git a/Compute/src/V1/Client/BaseClient/ZonesBaseClient.php b/Compute/src/V1/Client/BaseClient/ZonesBaseClient.php deleted file mode 100644 index f9026ed530c1..000000000000 --- a/Compute/src/V1/Client/BaseClient/ZonesBaseClient.php +++ /dev/null @@ -1,227 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/zones_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/zones_descriptor_config.php', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - 'useJwtAccessWithScope' => false, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/zones_rest_client_config.php', - ], - ], - ]; - } - - /** Implements GapicClientTrait::defaultTransport. */ - private static function defaultTransport() - { - return 'rest'; - } - - /** Implements GapicClientTrait::getSupportedTransports. */ - private static function getSupportedTransports() - { - return [ - 'rest', - ]; - } - - /** - * 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 'compute.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. At the moment, supports only - * `rest`. *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 = [ - * 'rest' => [...], - * ]; - * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Returns the specified Zone resource. - * - * The async variant is {@see self::getAsync()} . - * - * @param GetZoneRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Zone - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(GetZoneRequest $request, array $callOptions = []): Zone - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Retrieves the list of Zone resources available to the specified project. - * - * The async variant is {@see self::listAsync()} . - * - * @param ListZonesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(ListZonesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('List', $request, $callOptions); - } -} diff --git a/Compute/src/V1/Client/DiskTypesClient.php b/Compute/src/V1/Client/DiskTypesClient.php index 67096e9275fa..c52a4628a73d 100644 --- a/Compute/src/V1/Client/DiskTypesClient.php +++ b/Compute/src/V1/Client/DiskTypesClient.php @@ -24,17 +24,228 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\DiskTypesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListDiskTypesRequest; +use Google\Cloud\Compute\V1\DiskType; +use Google\Cloud\Compute\V1\GetDiskTypeRequest; +use Google\Cloud\Compute\V1\ListDiskTypesRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The DiskTypes API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\DiskTypesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListDiskTypesRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetDiskTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListDiskTypesRequest $request, array $optionalArgs = []) */ -final class DiskTypesClient extends DiskTypesBaseClient +final class DiskTypesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DiskTypesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.DiskTypes'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute.readonly', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/disk_types_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/disk_types_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/disk_types_rest_client_config.php', + ], + ], + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves an aggregated list of disk types. + * + * The async variant is {@see DiskTypesClient::aggregatedListAsync()} . + * + * @param AggregatedListDiskTypesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListDiskTypesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Returns the specified disk type. + * + * The async variant is {@see DiskTypesClient::getAsync()} . + * + * @param GetDiskTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DiskType + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetDiskTypeRequest $request, array $callOptions = []): DiskType + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of disk types available to the specified project. + * + * The async variant is {@see DiskTypesClient::listAsync()} . + * + * @param ListDiskTypesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListDiskTypesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } } diff --git a/Compute/src/V1/Client/DisksClient.php b/Compute/src/V1/Client/DisksClient.php index 3dcc32df786a..8bb7a5657189 100644 --- a/Compute/src/V1/Client/DisksClient.php +++ b/Compute/src/V1/Client/DisksClient.php @@ -24,17 +24,673 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\DisksBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AddResourcePoliciesDiskRequest; +use Google\Cloud\Compute\V1\AggregatedListDisksRequest; +use Google\Cloud\Compute\V1\BulkInsertDiskRequest; +use Google\Cloud\Compute\V1\CreateSnapshotDiskRequest; +use Google\Cloud\Compute\V1\DeleteDiskRequest; +use Google\Cloud\Compute\V1\Disk; +use Google\Cloud\Compute\V1\GetDiskRequest; +use Google\Cloud\Compute\V1\GetIamPolicyDiskRequest; +use Google\Cloud\Compute\V1\InsertDiskRequest; +use Google\Cloud\Compute\V1\ListDisksRequest; +use Google\Cloud\Compute\V1\Policy; +use Google\Cloud\Compute\V1\RemoveResourcePoliciesDiskRequest; +use Google\Cloud\Compute\V1\ResizeDiskRequest; +use Google\Cloud\Compute\V1\SetIamPolicyDiskRequest; +use Google\Cloud\Compute\V1\SetLabelsDiskRequest; +use Google\Cloud\Compute\V1\StartAsyncReplicationDiskRequest; +use Google\Cloud\Compute\V1\StopAsyncReplicationDiskRequest; +use Google\Cloud\Compute\V1\StopGroupAsyncReplicationDiskRequest; +use Google\Cloud\Compute\V1\TestIamPermissionsDiskRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use Google\Cloud\Compute\V1\UpdateDiskRequest; +use Google\Cloud\Compute\V1\ZoneOperationsClient; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Disks API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\DisksClient} for the stable implementation * * @experimental + * + * @method PromiseInterface addResourcePoliciesAsync(AddResourcePoliciesDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface aggregatedListAsync(AggregatedListDisksRequest $request, array $optionalArgs = []) + * @method PromiseInterface bulkInsertAsync(BulkInsertDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSnapshotAsync(CreateSnapshotDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListDisksRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeResourcePoliciesAsync(RemoveResourcePoliciesDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface resizeAsync(ResizeDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface setLabelsAsync(SetLabelsDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface startAsyncReplicationAsync(StartAsyncReplicationDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface stopAsyncReplicationAsync(StopAsyncReplicationDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface stopGroupAsyncReplicationAsync(StopGroupAsyncReplicationDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAsync(UpdateDiskRequest $request, array $optionalArgs = []) */ -final class DisksClient extends DisksBaseClient +final class DisksClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DisksBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.Disks'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/disks_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/disks_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/disks_rest_client_config.php', + ], + ], + 'operationsClientClass' => ZoneOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an ZoneOperationsClient object with the same endpoint as $this. + * + * @return ZoneOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getZone', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Adds existing resource policies to a disk. You can only add one policy which will be applied to this disk for scheduling snapshot creation. + * + * The async variant is {@see DisksClient::addResourcePoliciesAsync()} . + * + * @param AddResourcePoliciesDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addResourcePolicies(AddResourcePoliciesDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddResourcePolicies', $request, $callOptions)->wait(); + } + + /** + * Retrieves an aggregated list of persistent disks. + * + * The async variant is {@see DisksClient::aggregatedListAsync()} . + * + * @param AggregatedListDisksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListDisksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Bulk create a set of disks. + * + * The async variant is {@see DisksClient::bulkInsertAsync()} . + * + * @param BulkInsertDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function bulkInsert(BulkInsertDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BulkInsert', $request, $callOptions)->wait(); + } + + /** + * Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider using snapshots.insert instead, as that method supports more features, such as creating snapshots in a project different from the source disk project. + * + * The async variant is {@see DisksClient::createSnapshotAsync()} . + * + * @param CreateSnapshotDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSnapshot(CreateSnapshotDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateSnapshot', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified persistent disk. Deleting a disk removes its data permanently and is irreversible. However, deleting a disk does not delete any snapshots previously made from the disk. You must separately delete snapshots. + * + * The async variant is {@see DisksClient::deleteAsync()} . + * + * @param DeleteDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified persistent disk. + * + * The async variant is {@see DisksClient::getAsync()} . + * + * @param GetDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Disk + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetDiskRequest $request, array $callOptions = []): Disk + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * The async variant is {@see DisksClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyDiskRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Creates a persistent disk in the specified project using the data in the request. You can create a disk from a source (sourceImage, sourceSnapshot, or sourceDisk) or create an empty 500 GB data disk by omitting all properties. You can also create a disk that is larger than the default size by specifying the sizeGb property. + * + * The async variant is {@see DisksClient::insertAsync()} . + * + * @param InsertDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of persistent disks contained within the specified zone. + * + * The async variant is {@see DisksClient::listAsync()} . + * + * @param ListDisksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListDisksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Removes resource policies from a disk. + * + * The async variant is {@see DisksClient::removeResourcePoliciesAsync()} . + * + * @param RemoveResourcePoliciesDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeResourcePolicies(RemoveResourcePoliciesDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RemoveResourcePolicies', $request, $callOptions)->wait(); + } + + /** + * Resizes the specified persistent disk. You can only increase the size of the disk. + * + * The async variant is {@see DisksClient::resizeAsync()} . + * + * @param ResizeDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function resize(ResizeDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Resize', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * The async variant is {@see DisksClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyDiskRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the labels on a disk. To learn more about labels, read the Labeling Resources documentation. + * + * The async variant is {@see DisksClient::setLabelsAsync()} . + * + * @param SetLabelsDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setLabels(SetLabelsDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); + } + + /** + * Starts asynchronous replication. Must be invoked on the primary disk. + * + * The async variant is {@see DisksClient::startAsyncReplicationAsync()} . + * + * @param StartAsyncReplicationDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function startAsyncReplication(StartAsyncReplicationDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StartAsyncReplication', $request, $callOptions)->wait(); + } + + /** + * Stops asynchronous replication. Can be invoked either on the primary or on the secondary disk. + * + * The async variant is {@see DisksClient::stopAsyncReplicationAsync()} . + * + * @param StopAsyncReplicationDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function stopAsyncReplication(StopAsyncReplicationDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StopAsyncReplication', $request, $callOptions)->wait(); + } + + /** + * Stops asynchronous replication for a consistency group of disks. Can be invoked either in the primary or secondary scope. + * + * The async variant is {@see DisksClient::stopGroupAsyncReplicationAsync()} . + * + * @param StopGroupAsyncReplicationDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function stopGroupAsyncReplication(StopGroupAsyncReplicationDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StopGroupAsyncReplication', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. + * + * The async variant is {@see DisksClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsDiskRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates the specified disk with the data included in the request. The update is performed only on selected fields included as part of update-mask. Only the following fields can be modified: user_license. + * + * The async variant is {@see DisksClient::updateAsync()} . + * + * @param UpdateDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function update(UpdateDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Update', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/ExternalVpnGatewaysClient.php b/Compute/src/V1/Client/ExternalVpnGatewaysClient.php index 827142b4d4e6..fcb0f5f481e4 100644 --- a/Compute/src/V1/Client/ExternalVpnGatewaysClient.php +++ b/Compute/src/V1/Client/ExternalVpnGatewaysClient.php @@ -24,17 +24,361 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\ExternalVpnGatewaysBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteExternalVpnGatewayRequest; +use Google\Cloud\Compute\V1\ExternalVpnGateway; +use Google\Cloud\Compute\V1\GetExternalVpnGatewayRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertExternalVpnGatewayRequest; +use Google\Cloud\Compute\V1\ListExternalVpnGatewaysRequest; +use Google\Cloud\Compute\V1\SetLabelsExternalVpnGatewayRequest; +use Google\Cloud\Compute\V1\TestIamPermissionsExternalVpnGatewayRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The ExternalVpnGateways API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\ExternalVpnGatewaysClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteExternalVpnGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetExternalVpnGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertExternalVpnGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListExternalVpnGatewaysRequest $request, array $optionalArgs = []) + * @method PromiseInterface setLabelsAsync(SetLabelsExternalVpnGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsExternalVpnGatewayRequest $request, array $optionalArgs = []) */ -final class ExternalVpnGatewaysClient extends ExternalVpnGatewaysBaseClient +final class ExternalVpnGatewaysClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ExternalVpnGatewaysBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.ExternalVpnGateways'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/external_vpn_gateways_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/external_vpn_gateways_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/external_vpn_gateways_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified externalVpnGateway. + * + * The async variant is {@see ExternalVpnGatewaysClient::deleteAsync()} . + * + * @param DeleteExternalVpnGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteExternalVpnGatewayRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified externalVpnGateway. Get a list of available externalVpnGateways by making a list() request. + * + * The async variant is {@see ExternalVpnGatewaysClient::getAsync()} . + * + * @param GetExternalVpnGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ExternalVpnGateway + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetExternalVpnGatewayRequest $request, array $callOptions = []): ExternalVpnGateway + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a ExternalVpnGateway in the specified project using the data included in the request. + * + * The async variant is {@see ExternalVpnGatewaysClient::insertAsync()} . + * + * @param InsertExternalVpnGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertExternalVpnGatewayRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of ExternalVpnGateway available to the specified project. + * + * The async variant is {@see ExternalVpnGatewaysClient::listAsync()} . + * + * @param ListExternalVpnGatewaysRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListExternalVpnGatewaysRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Sets the labels on an ExternalVpnGateway. To learn more about labels, read the Labeling Resources documentation. + * + * The async variant is {@see ExternalVpnGatewaysClient::setLabelsAsync()} . + * + * @param SetLabelsExternalVpnGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setLabels(SetLabelsExternalVpnGatewayRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. + * + * The async variant is {@see ExternalVpnGatewaysClient::testIamPermissionsAsync()} + * . + * + * @param TestIamPermissionsExternalVpnGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsExternalVpnGatewayRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/FirewallPoliciesClient.php b/Compute/src/V1/Client/FirewallPoliciesClient.php index 2978fafb33f4..3c618954a08a 100644 --- a/Compute/src/V1/Client/FirewallPoliciesClient.php +++ b/Compute/src/V1/Client/FirewallPoliciesClient.php @@ -24,17 +24,674 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\FirewallPoliciesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AddAssociationFirewallPolicyRequest; +use Google\Cloud\Compute\V1\AddRuleFirewallPolicyRequest; +use Google\Cloud\Compute\V1\CloneRulesFirewallPolicyRequest; +use Google\Cloud\Compute\V1\DeleteFirewallPolicyRequest; +use Google\Cloud\Compute\V1\FirewallPoliciesListAssociationsResponse; +use Google\Cloud\Compute\V1\FirewallPolicy; +use Google\Cloud\Compute\V1\FirewallPolicyAssociation; +use Google\Cloud\Compute\V1\FirewallPolicyRule; +use Google\Cloud\Compute\V1\GetAssociationFirewallPolicyRequest; +use Google\Cloud\Compute\V1\GetFirewallPolicyRequest; +use Google\Cloud\Compute\V1\GetIamPolicyFirewallPolicyRequest; +use Google\Cloud\Compute\V1\GetRuleFirewallPolicyRequest; +use Google\Cloud\Compute\V1\GlobalOrganizationOperationsClient; +use Google\Cloud\Compute\V1\InsertFirewallPolicyRequest; +use Google\Cloud\Compute\V1\ListAssociationsFirewallPolicyRequest; +use Google\Cloud\Compute\V1\ListFirewallPoliciesRequest; +use Google\Cloud\Compute\V1\MoveFirewallPolicyRequest; +use Google\Cloud\Compute\V1\PatchFirewallPolicyRequest; +use Google\Cloud\Compute\V1\PatchRuleFirewallPolicyRequest; +use Google\Cloud\Compute\V1\Policy; +use Google\Cloud\Compute\V1\RemoveAssociationFirewallPolicyRequest; +use Google\Cloud\Compute\V1\RemoveRuleFirewallPolicyRequest; +use Google\Cloud\Compute\V1\SetIamPolicyFirewallPolicyRequest; +use Google\Cloud\Compute\V1\TestIamPermissionsFirewallPolicyRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The FirewallPolicies API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\FirewallPoliciesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface addAssociationAsync(AddAssociationFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface addRuleAsync(AddRuleFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface cloneRulesAsync(CloneRulesFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAssociationAsync(GetAssociationFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRuleAsync(GetRuleFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListFirewallPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAssociationsAsync(ListAssociationsFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface moveAsync(MoveFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchRuleAsync(PatchRuleFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeAssociationAsync(RemoveAssociationFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeRuleAsync(RemoveRuleFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsFirewallPolicyRequest $request, array $optionalArgs = []) */ -final class FirewallPoliciesClient extends FirewallPoliciesBaseClient +final class FirewallPoliciesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see FirewallPoliciesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.FirewallPolicies'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/firewall_policies_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/firewall_policies_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/firewall_policies_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOrganizationOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOrganizationOperationsClient object with the same endpoint as + * $this. + * + * @return GlobalOrganizationOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Inserts an association for the specified firewall policy. + * + * The async variant is {@see FirewallPoliciesClient::addAssociationAsync()} . + * + * @param AddAssociationFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addAssociation(AddAssociationFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddAssociation', $request, $callOptions)->wait(); + } + + /** + * Inserts a rule into a firewall policy. + * + * The async variant is {@see FirewallPoliciesClient::addRuleAsync()} . + * + * @param AddRuleFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addRule(AddRuleFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddRule', $request, $callOptions)->wait(); + } + + /** + * Copies rules to the specified firewall policy. + * + * The async variant is {@see FirewallPoliciesClient::cloneRulesAsync()} . + * + * @param CloneRulesFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function cloneRules(CloneRulesFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CloneRules', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified policy. + * + * The async variant is {@see FirewallPoliciesClient::deleteAsync()} . + * + * @param DeleteFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified firewall policy. + * + * The async variant is {@see FirewallPoliciesClient::getAsync()} . + * + * @param GetFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FirewallPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicy + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Gets an association with the specified name. + * + * The async variant is {@see FirewallPoliciesClient::getAssociationAsync()} . + * + * @param GetAssociationFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FirewallPolicyAssociation + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAssociation(GetAssociationFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicyAssociation + { + return $this->startApiCall('GetAssociation', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * The async variant is {@see FirewallPoliciesClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyFirewallPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets a rule of the specified priority. + * + * The async variant is {@see FirewallPoliciesClient::getRuleAsync()} . + * + * @param GetRuleFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FirewallPolicyRule + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRule(GetRuleFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicyRule + { + return $this->startApiCall('GetRule', $request, $callOptions)->wait(); + } + + /** + * Creates a new policy in the specified project using the data included in the request. + * + * The async variant is {@see FirewallPoliciesClient::insertAsync()} . + * + * @param InsertFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Lists all the policies that have been configured for the specified folder or organization. + * + * The async variant is {@see FirewallPoliciesClient::listAsync()} . + * + * @param ListFirewallPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListFirewallPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Lists associations of a specified target, i.e., organization or folder. + * + * The async variant is {@see FirewallPoliciesClient::listAssociationsAsync()} . + * + * @param ListAssociationsFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FirewallPoliciesListAssociationsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAssociations(ListAssociationsFirewallPolicyRequest $request, array $callOptions = []): FirewallPoliciesListAssociationsResponse + { + return $this->startApiCall('ListAssociations', $request, $callOptions)->wait(); + } + + /** + * Moves the specified firewall policy. + * + * The async variant is {@see FirewallPoliciesClient::moveAsync()} . + * + * @param MoveFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function move(MoveFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Move', $request, $callOptions)->wait(); + } + + /** + * Patches the specified policy with the data included in the request. + * + * The async variant is {@see FirewallPoliciesClient::patchAsync()} . + * + * @param PatchFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Patches a rule of the specified priority. + * + * The async variant is {@see FirewallPoliciesClient::patchRuleAsync()} . + * + * @param PatchRuleFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patchRule(PatchRuleFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('PatchRule', $request, $callOptions)->wait(); + } + + /** + * Removes an association for the specified firewall policy. + * + * The async variant is {@see FirewallPoliciesClient::removeAssociationAsync()} . + * + * @param RemoveAssociationFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeAssociation(RemoveAssociationFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RemoveAssociation', $request, $callOptions)->wait(); + } + + /** + * Deletes a rule of the specified priority. + * + * The async variant is {@see FirewallPoliciesClient::removeRuleAsync()} . + * + * @param RemoveRuleFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeRule(RemoveRuleFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RemoveRule', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * The async variant is {@see FirewallPoliciesClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyFirewallPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. + * + * The async variant is {@see FirewallPoliciesClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsFirewallPolicyRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/FirewallsClient.php b/Compute/src/V1/Client/FirewallsClient.php index 6556d52f2de7..0ceef38e32e6 100644 --- a/Compute/src/V1/Client/FirewallsClient.php +++ b/Compute/src/V1/Client/FirewallsClient.php @@ -24,17 +24,358 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\FirewallsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteFirewallRequest; +use Google\Cloud\Compute\V1\Firewall; +use Google\Cloud\Compute\V1\GetFirewallRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertFirewallRequest; +use Google\Cloud\Compute\V1\ListFirewallsRequest; +use Google\Cloud\Compute\V1\PatchFirewallRequest; +use Google\Cloud\Compute\V1\UpdateFirewallRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Firewalls API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\FirewallsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteFirewallRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetFirewallRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertFirewallRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListFirewallsRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchFirewallRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAsync(UpdateFirewallRequest $request, array $optionalArgs = []) */ -final class FirewallsClient extends FirewallsBaseClient +final class FirewallsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see FirewallsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.Firewalls'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/firewalls_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/firewalls_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/firewalls_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified firewall. + * + * The async variant is {@see FirewallsClient::deleteAsync()} . + * + * @param DeleteFirewallRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteFirewallRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified firewall. + * + * The async variant is {@see FirewallsClient::getAsync()} . + * + * @param GetFirewallRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Firewall + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetFirewallRequest $request, array $callOptions = []): Firewall + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a firewall rule in the specified project using the data included in the request. + * + * The async variant is {@see FirewallsClient::insertAsync()} . + * + * @param InsertFirewallRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertFirewallRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of firewall rules available to the specified project. + * + * The async variant is {@see FirewallsClient::listAsync()} . + * + * @param ListFirewallsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListFirewallsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Updates the specified firewall rule with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * The async variant is {@see FirewallsClient::patchAsync()} . + * + * @param PatchFirewallRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchFirewallRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Updates the specified firewall rule with the data included in the request. Note that all fields will be updated if using PUT, even fields that are not specified. To update individual fields, please use PATCH instead. + * + * The async variant is {@see FirewallsClient::updateAsync()} . + * + * @param UpdateFirewallRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function update(UpdateFirewallRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Update', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/ForwardingRulesClient.php b/Compute/src/V1/Client/ForwardingRulesClient.php index 01d12288cac4..2b9b4c0f2dc5 100644 --- a/Compute/src/V1/Client/ForwardingRulesClient.php +++ b/Compute/src/V1/Client/ForwardingRulesClient.php @@ -24,17 +24,411 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\ForwardingRulesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListForwardingRulesRequest; +use Google\Cloud\Compute\V1\DeleteForwardingRuleRequest; +use Google\Cloud\Compute\V1\ForwardingRule; +use Google\Cloud\Compute\V1\GetForwardingRuleRequest; +use Google\Cloud\Compute\V1\InsertForwardingRuleRequest; +use Google\Cloud\Compute\V1\ListForwardingRulesRequest; +use Google\Cloud\Compute\V1\PatchForwardingRuleRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\SetLabelsForwardingRuleRequest; +use Google\Cloud\Compute\V1\SetTargetForwardingRuleRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The ForwardingRules API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\ForwardingRulesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListForwardingRulesRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteForwardingRuleRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetForwardingRuleRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertForwardingRuleRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListForwardingRulesRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchForwardingRuleRequest $request, array $optionalArgs = []) + * @method PromiseInterface setLabelsAsync(SetLabelsForwardingRuleRequest $request, array $optionalArgs = []) + * @method PromiseInterface setTargetAsync(SetTargetForwardingRuleRequest $request, array $optionalArgs = []) */ -final class ForwardingRulesClient extends ForwardingRulesBaseClient +final class ForwardingRulesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ForwardingRulesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.ForwardingRules'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/forwarding_rules_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/forwarding_rules_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/forwarding_rules_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves an aggregated list of forwarding rules. + * + * The async variant is {@see ForwardingRulesClient::aggregatedListAsync()} . + * + * @param AggregatedListForwardingRulesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListForwardingRulesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified ForwardingRule resource. + * + * The async variant is {@see ForwardingRulesClient::deleteAsync()} . + * + * @param DeleteForwardingRuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteForwardingRuleRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified ForwardingRule resource. + * + * The async variant is {@see ForwardingRulesClient::getAsync()} . + * + * @param GetForwardingRuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ForwardingRule + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetForwardingRuleRequest $request, array $callOptions = []): ForwardingRule + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a ForwardingRule resource in the specified project and region using the data included in the request. + * + * The async variant is {@see ForwardingRulesClient::insertAsync()} . + * + * @param InsertForwardingRuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertForwardingRuleRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of ForwardingRule resources available to the specified project and region. + * + * The async variant is {@see ForwardingRulesClient::listAsync()} . + * + * @param ListForwardingRulesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListForwardingRulesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Updates the specified forwarding rule with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. Currently, you can only patch the network_tier field. + * + * The async variant is {@see ForwardingRulesClient::patchAsync()} . + * + * @param PatchForwardingRuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchForwardingRuleRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Sets the labels on the specified resource. To learn more about labels, read the Labeling Resources documentation. + * + * The async variant is {@see ForwardingRulesClient::setLabelsAsync()} . + * + * @param SetLabelsForwardingRuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setLabels(SetLabelsForwardingRuleRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); + } + + /** + * Changes target URL for forwarding rule. The new target should be of the same type as the old target. + * + * The async variant is {@see ForwardingRulesClient::setTargetAsync()} . + * + * @param SetTargetForwardingRuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setTarget(SetTargetForwardingRuleRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetTarget', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/GlobalAddressesClient.php b/Compute/src/V1/Client/GlobalAddressesClient.php index 24e6e7fb9c6b..d0c063d22888 100644 --- a/Compute/src/V1/Client/GlobalAddressesClient.php +++ b/Compute/src/V1/Client/GlobalAddressesClient.php @@ -24,17 +24,358 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\GlobalAddressesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\Address; +use Google\Cloud\Compute\V1\DeleteGlobalAddressRequest; +use Google\Cloud\Compute\V1\GetGlobalAddressRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertGlobalAddressRequest; +use Google\Cloud\Compute\V1\ListGlobalAddressesRequest; +use Google\Cloud\Compute\V1\MoveGlobalAddressRequest; +use Google\Cloud\Compute\V1\SetLabelsGlobalAddressRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The GlobalAddresses API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\GlobalAddressesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteGlobalAddressRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetGlobalAddressRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertGlobalAddressRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListGlobalAddressesRequest $request, array $optionalArgs = []) + * @method PromiseInterface moveAsync(MoveGlobalAddressRequest $request, array $optionalArgs = []) + * @method PromiseInterface setLabelsAsync(SetLabelsGlobalAddressRequest $request, array $optionalArgs = []) */ -final class GlobalAddressesClient extends GlobalAddressesBaseClient +final class GlobalAddressesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see GlobalAddressesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.GlobalAddresses'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/global_addresses_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/global_addresses_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/global_addresses_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified address resource. + * + * The async variant is {@see GlobalAddressesClient::deleteAsync()} . + * + * @param DeleteGlobalAddressRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteGlobalAddressRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified address resource. + * + * The async variant is {@see GlobalAddressesClient::getAsync()} . + * + * @param GetGlobalAddressRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Address + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetGlobalAddressRequest $request, array $callOptions = []): Address + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates an address resource in the specified project by using the data included in the request. + * + * The async variant is {@see GlobalAddressesClient::insertAsync()} . + * + * @param InsertGlobalAddressRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertGlobalAddressRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of global addresses. + * + * The async variant is {@see GlobalAddressesClient::listAsync()} . + * + * @param ListGlobalAddressesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListGlobalAddressesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Moves the specified address resource from one project to another project. + * + * The async variant is {@see GlobalAddressesClient::moveAsync()} . + * + * @param MoveGlobalAddressRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function move(MoveGlobalAddressRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Move', $request, $callOptions)->wait(); + } + + /** + * Sets the labels on a GlobalAddress. To learn more about labels, read the Labeling Resources documentation. + * + * The async variant is {@see GlobalAddressesClient::setLabelsAsync()} . + * + * @param SetLabelsGlobalAddressRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setLabels(SetLabelsGlobalAddressRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/GlobalForwardingRulesClient.php b/Compute/src/V1/Client/GlobalForwardingRulesClient.php index 07d27e31e133..136ab71c02cf 100644 --- a/Compute/src/V1/Client/GlobalForwardingRulesClient.php +++ b/Compute/src/V1/Client/GlobalForwardingRulesClient.php @@ -24,17 +24,385 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\GlobalForwardingRulesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteGlobalForwardingRuleRequest; +use Google\Cloud\Compute\V1\ForwardingRule; +use Google\Cloud\Compute\V1\GetGlobalForwardingRuleRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertGlobalForwardingRuleRequest; +use Google\Cloud\Compute\V1\ListGlobalForwardingRulesRequest; +use Google\Cloud\Compute\V1\PatchGlobalForwardingRuleRequest; +use Google\Cloud\Compute\V1\SetLabelsGlobalForwardingRuleRequest; +use Google\Cloud\Compute\V1\SetTargetGlobalForwardingRuleRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The GlobalForwardingRules API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\GlobalForwardingRulesClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteGlobalForwardingRuleRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetGlobalForwardingRuleRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertGlobalForwardingRuleRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListGlobalForwardingRulesRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchGlobalForwardingRuleRequest $request, array $optionalArgs = []) + * @method PromiseInterface setLabelsAsync(SetLabelsGlobalForwardingRuleRequest $request, array $optionalArgs = []) + * @method PromiseInterface setTargetAsync(SetTargetGlobalForwardingRuleRequest $request, array $optionalArgs = []) */ -final class GlobalForwardingRulesClient extends GlobalForwardingRulesBaseClient +final class GlobalForwardingRulesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see GlobalForwardingRulesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.GlobalForwardingRules'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/global_forwarding_rules_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/global_forwarding_rules_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/global_forwarding_rules_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified GlobalForwardingRule resource. + * + * The async variant is {@see GlobalForwardingRulesClient::deleteAsync()} . + * + * @param DeleteGlobalForwardingRuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteGlobalForwardingRuleRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified GlobalForwardingRule resource. Gets a list of available forwarding rules by making a list() request. + * + * The async variant is {@see GlobalForwardingRulesClient::getAsync()} . + * + * @param GetGlobalForwardingRuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ForwardingRule + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetGlobalForwardingRuleRequest $request, array $callOptions = []): ForwardingRule + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a GlobalForwardingRule resource in the specified project using the data included in the request. + * + * The async variant is {@see GlobalForwardingRulesClient::insertAsync()} . + * + * @param InsertGlobalForwardingRuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertGlobalForwardingRuleRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of GlobalForwardingRule resources available to the specified project. + * + * The async variant is {@see GlobalForwardingRulesClient::listAsync()} . + * + * @param ListGlobalForwardingRulesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListGlobalForwardingRulesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Updates the specified forwarding rule with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. Currently, you can only patch the network_tier field. + * + * The async variant is {@see GlobalForwardingRulesClient::patchAsync()} . + * + * @param PatchGlobalForwardingRuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchGlobalForwardingRuleRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Sets the labels on the specified resource. To learn more about labels, read the Labeling resources documentation. + * + * The async variant is {@see GlobalForwardingRulesClient::setLabelsAsync()} . + * + * @param SetLabelsGlobalForwardingRuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setLabels(SetLabelsGlobalForwardingRuleRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); + } + + /** + * Changes target URL for the GlobalForwardingRule resource. The new target should be of the same type as the old target. + * + * The async variant is {@see GlobalForwardingRulesClient::setTargetAsync()} . + * + * @param SetTargetGlobalForwardingRuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setTarget(SetTargetGlobalForwardingRuleRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetTarget', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/GlobalNetworkEndpointGroupsClient.php b/Compute/src/V1/Client/GlobalNetworkEndpointGroupsClient.php index 98d0e4449b96..13ca13f9b288 100644 --- a/Compute/src/V1/Client/GlobalNetworkEndpointGroupsClient.php +++ b/Compute/src/V1/Client/GlobalNetworkEndpointGroupsClient.php @@ -24,17 +24,388 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\GlobalNetworkEndpointGroupsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest; +use Google\Cloud\Compute\V1\DeleteGlobalNetworkEndpointGroupRequest; +use Google\Cloud\Compute\V1\DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest; +use Google\Cloud\Compute\V1\GetGlobalNetworkEndpointGroupRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertGlobalNetworkEndpointGroupRequest; +use Google\Cloud\Compute\V1\ListGlobalNetworkEndpointGroupsRequest; +use Google\Cloud\Compute\V1\ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest; +use Google\Cloud\Compute\V1\NetworkEndpointGroup; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The GlobalNetworkEndpointGroups API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\GlobalNetworkEndpointGroupsClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface attachNetworkEndpointsAsync(AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteGlobalNetworkEndpointGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface detachNetworkEndpointsAsync(DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetGlobalNetworkEndpointGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertGlobalNetworkEndpointGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListGlobalNetworkEndpointGroupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listNetworkEndpointsAsync(ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest $request, array $optionalArgs = []) */ -final class GlobalNetworkEndpointGroupsClient extends GlobalNetworkEndpointGroupsBaseClient +final class GlobalNetworkEndpointGroupsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see GlobalNetworkEndpointGroupsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.GlobalNetworkEndpointGroups'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/global_network_endpoint_groups_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/global_network_endpoint_groups_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/global_network_endpoint_groups_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Attach a network endpoint to the specified network endpoint group. + * + * The async variant is + * {@see GlobalNetworkEndpointGroupsClient::attachNetworkEndpointsAsync()} . + * + * @param AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function attachNetworkEndpoints(AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AttachNetworkEndpoints', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified network endpoint group.Note that the NEG cannot be deleted if there are backend services referencing it. + * + * The async variant is {@see GlobalNetworkEndpointGroupsClient::deleteAsync()} . + * + * @param DeleteGlobalNetworkEndpointGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteGlobalNetworkEndpointGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Detach the network endpoint from the specified network endpoint group. + * + * The async variant is + * {@see GlobalNetworkEndpointGroupsClient::detachNetworkEndpointsAsync()} . + * + * @param DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function detachNetworkEndpoints(DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DetachNetworkEndpoints', $request, $callOptions)->wait(); + } + + /** + * Returns the specified network endpoint group. + * + * The async variant is {@see GlobalNetworkEndpointGroupsClient::getAsync()} . + * + * @param GetGlobalNetworkEndpointGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NetworkEndpointGroup + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetGlobalNetworkEndpointGroupRequest $request, array $callOptions = []): NetworkEndpointGroup + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a network endpoint group in the specified project using the parameters that are included in the request. + * + * The async variant is {@see GlobalNetworkEndpointGroupsClient::insertAsync()} . + * + * @param InsertGlobalNetworkEndpointGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertGlobalNetworkEndpointGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of network endpoint groups that are located in the specified project. + * + * The async variant is {@see GlobalNetworkEndpointGroupsClient::listAsync()} . + * + * @param ListGlobalNetworkEndpointGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListGlobalNetworkEndpointGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Lists the network endpoints in the specified network endpoint group. + * + * The async variant is + * {@see GlobalNetworkEndpointGroupsClient::listNetworkEndpointsAsync()} . + * + * @param ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listNetworkEndpoints(ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListNetworkEndpoints', $request, $callOptions); + } } diff --git a/Compute/src/V1/Client/GlobalOperationsClient.php b/Compute/src/V1/Client/GlobalOperationsClient.php index 77f184884925..2368f01f12de 100644 --- a/Compute/src/V1/Client/GlobalOperationsClient.php +++ b/Compute/src/V1/Client/GlobalOperationsClient.php @@ -24,17 +24,280 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\GlobalOperationsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListGlobalOperationsRequest; +use Google\Cloud\Compute\V1\DeleteGlobalOperationRequest; +use Google\Cloud\Compute\V1\DeleteGlobalOperationResponse; +use Google\Cloud\Compute\V1\GetGlobalOperationRequest; +use Google\Cloud\Compute\V1\ListGlobalOperationsRequest; +use Google\Cloud\Compute\V1\Operation; +use Google\Cloud\Compute\V1\WaitGlobalOperationRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The GlobalOperations API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\GlobalOperationsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListGlobalOperationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteGlobalOperationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetGlobalOperationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListGlobalOperationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface waitAsync(WaitGlobalOperationRequest $request, array $optionalArgs = []) */ -final class GlobalOperationsClient extends GlobalOperationsBaseClient +final class GlobalOperationsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see GlobalOperationsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.GlobalOperations'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/global_operations_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/global_operations_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/global_operations_rest_client_config.php', + ], + ], + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves an aggregated list of all operations. + * + * The async variant is {@see GlobalOperationsClient::aggregatedListAsync()} . + * + * @param AggregatedListGlobalOperationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListGlobalOperationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified Operations resource. + * + * The async variant is {@see GlobalOperationsClient::deleteAsync()} . + * + * @param DeleteGlobalOperationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DeleteGlobalOperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteGlobalOperationRequest $request, array $callOptions = []): DeleteGlobalOperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified Operations resource. + * + * The async variant is {@see GlobalOperationsClient::getAsync()} . + * + * @param GetGlobalOperationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetGlobalOperationRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of Operation resources contained within the specified project. + * + * The async variant is {@see GlobalOperationsClient::listAsync()} . + * + * @param ListGlobalOperationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListGlobalOperationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method differs from the `GET` method in that it waits for no more than the default deadline (2 minutes) and then returns the current state of the operation, which might be `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`. + * + * The async variant is {@see GlobalOperationsClient::waitAsync()} . + * + * @param WaitGlobalOperationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function wait(WaitGlobalOperationRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Wait', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/GlobalOrganizationOperationsClient.php b/Compute/src/V1/Client/GlobalOrganizationOperationsClient.php index 2ae610830b65..0b3c25958781 100644 --- a/Compute/src/V1/Client/GlobalOrganizationOperationsClient.php +++ b/Compute/src/V1/Client/GlobalOrganizationOperationsClient.php @@ -24,17 +24,229 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\GlobalOrganizationOperationsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteGlobalOrganizationOperationRequest; +use Google\Cloud\Compute\V1\DeleteGlobalOrganizationOperationResponse; +use Google\Cloud\Compute\V1\GetGlobalOrganizationOperationRequest; +use Google\Cloud\Compute\V1\ListGlobalOrganizationOperationsRequest; +use Google\Cloud\Compute\V1\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The GlobalOrganizationOperations API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\GlobalOrganizationOperationsClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteGlobalOrganizationOperationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetGlobalOrganizationOperationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListGlobalOrganizationOperationsRequest $request, array $optionalArgs = []) */ -final class GlobalOrganizationOperationsClient extends GlobalOrganizationOperationsBaseClient +final class GlobalOrganizationOperationsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see GlobalOrganizationOperationsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.GlobalOrganizationOperations'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/global_organization_operations_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/global_organization_operations_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/global_organization_operations_rest_client_config.php', + ], + ], + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified Operations resource. + * + * The async variant is {@see GlobalOrganizationOperationsClient::deleteAsync()} . + * + * @param DeleteGlobalOrganizationOperationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DeleteGlobalOrganizationOperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteGlobalOrganizationOperationRequest $request, array $callOptions = []): DeleteGlobalOrganizationOperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified Operations resource. Gets a list of operations by making a `list()` request. + * + * The async variant is {@see GlobalOrganizationOperationsClient::getAsync()} . + * + * @param GetGlobalOrganizationOperationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetGlobalOrganizationOperationRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of Operation resources contained within the specified organization. + * + * The async variant is {@see GlobalOrganizationOperationsClient::listAsync()} . + * + * @param ListGlobalOrganizationOperationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListGlobalOrganizationOperationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } } diff --git a/Compute/src/V1/Client/GlobalPublicDelegatedPrefixesClient.php b/Compute/src/V1/Client/GlobalPublicDelegatedPrefixesClient.php index 9397a51fd76f..c82d7ab02764 100644 --- a/Compute/src/V1/Client/GlobalPublicDelegatedPrefixesClient.php +++ b/Compute/src/V1/Client/GlobalPublicDelegatedPrefixesClient.php @@ -24,17 +24,333 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\GlobalPublicDelegatedPrefixesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteGlobalPublicDelegatedPrefixeRequest; +use Google\Cloud\Compute\V1\GetGlobalPublicDelegatedPrefixeRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertGlobalPublicDelegatedPrefixeRequest; +use Google\Cloud\Compute\V1\ListGlobalPublicDelegatedPrefixesRequest; +use Google\Cloud\Compute\V1\PatchGlobalPublicDelegatedPrefixeRequest; +use Google\Cloud\Compute\V1\PublicDelegatedPrefix; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The GlobalPublicDelegatedPrefixes API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\GlobalPublicDelegatedPrefixesClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteGlobalPublicDelegatedPrefixeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetGlobalPublicDelegatedPrefixeRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertGlobalPublicDelegatedPrefixeRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListGlobalPublicDelegatedPrefixesRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchGlobalPublicDelegatedPrefixeRequest $request, array $optionalArgs = []) */ -final class GlobalPublicDelegatedPrefixesClient extends GlobalPublicDelegatedPrefixesBaseClient +final class GlobalPublicDelegatedPrefixesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see GlobalPublicDelegatedPrefixesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.GlobalPublicDelegatedPrefixes'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/global_public_delegated_prefixes_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/global_public_delegated_prefixes_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/global_public_delegated_prefixes_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified global PublicDelegatedPrefix. + * + * The async variant is {@see GlobalPublicDelegatedPrefixesClient::deleteAsync()} . + * + * @param DeleteGlobalPublicDelegatedPrefixeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteGlobalPublicDelegatedPrefixeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified global PublicDelegatedPrefix resource. + * + * The async variant is {@see GlobalPublicDelegatedPrefixesClient::getAsync()} . + * + * @param GetGlobalPublicDelegatedPrefixeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PublicDelegatedPrefix + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetGlobalPublicDelegatedPrefixeRequest $request, array $callOptions = []): PublicDelegatedPrefix + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a global PublicDelegatedPrefix in the specified project using the parameters that are included in the request. + * + * The async variant is {@see GlobalPublicDelegatedPrefixesClient::insertAsync()} . + * + * @param InsertGlobalPublicDelegatedPrefixeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertGlobalPublicDelegatedPrefixeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Lists the global PublicDelegatedPrefixes for a project. + * + * The async variant is {@see GlobalPublicDelegatedPrefixesClient::listAsync()} . + * + * @param ListGlobalPublicDelegatedPrefixesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListGlobalPublicDelegatedPrefixesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Patches the specified global PublicDelegatedPrefix resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + * + * The async variant is {@see GlobalPublicDelegatedPrefixesClient::patchAsync()} . + * + * @param PatchGlobalPublicDelegatedPrefixeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchGlobalPublicDelegatedPrefixeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/HealthChecksClient.php b/Compute/src/V1/Client/HealthChecksClient.php index 5ae2d19b9a8e..44ea69048265 100644 --- a/Compute/src/V1/Client/HealthChecksClient.php +++ b/Compute/src/V1/Client/HealthChecksClient.php @@ -24,17 +24,384 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\HealthChecksBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListHealthChecksRequest; +use Google\Cloud\Compute\V1\DeleteHealthCheckRequest; +use Google\Cloud\Compute\V1\GetHealthCheckRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\HealthCheck; +use Google\Cloud\Compute\V1\InsertHealthCheckRequest; +use Google\Cloud\Compute\V1\ListHealthChecksRequest; +use Google\Cloud\Compute\V1\PatchHealthCheckRequest; +use Google\Cloud\Compute\V1\UpdateHealthCheckRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The HealthChecks API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\HealthChecksClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListHealthChecksRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteHealthCheckRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetHealthCheckRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertHealthCheckRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListHealthChecksRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchHealthCheckRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAsync(UpdateHealthCheckRequest $request, array $optionalArgs = []) */ -final class HealthChecksClient extends HealthChecksBaseClient +final class HealthChecksClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see HealthChecksBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.HealthChecks'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/health_checks_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/health_checks_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/health_checks_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves the list of all HealthCheck resources, regional and global, available to the specified project. + * + * The async variant is {@see HealthChecksClient::aggregatedListAsync()} . + * + * @param AggregatedListHealthChecksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListHealthChecksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified HealthCheck resource. + * + * The async variant is {@see HealthChecksClient::deleteAsync()} . + * + * @param DeleteHealthCheckRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteHealthCheckRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified HealthCheck resource. + * + * The async variant is {@see HealthChecksClient::getAsync()} . + * + * @param GetHealthCheckRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 HealthCheck + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetHealthCheckRequest $request, array $callOptions = []): HealthCheck + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a HealthCheck resource in the specified project using the data included in the request. + * + * The async variant is {@see HealthChecksClient::insertAsync()} . + * + * @param InsertHealthCheckRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertHealthCheckRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of HealthCheck resources available to the specified project. + * + * The async variant is {@see HealthChecksClient::listAsync()} . + * + * @param ListHealthChecksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListHealthChecksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Updates a HealthCheck resource in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * The async variant is {@see HealthChecksClient::patchAsync()} . + * + * @param PatchHealthCheckRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchHealthCheckRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Updates a HealthCheck resource in the specified project using the data included in the request. + * + * The async variant is {@see HealthChecksClient::updateAsync()} . + * + * @param UpdateHealthCheckRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function update(UpdateHealthCheckRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Update', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/ImageFamilyViewsClient.php b/Compute/src/V1/Client/ImageFamilyViewsClient.php index ba86c43569af..28f802c6d9f3 100644 --- a/Compute/src/V1/Client/ImageFamilyViewsClient.php +++ b/Compute/src/V1/Client/ImageFamilyViewsClient.php @@ -24,17 +24,175 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\ImageFamilyViewsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\GetImageFamilyViewRequest; +use Google\Cloud\Compute\V1\ImageFamilyView; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The ImageFamilyViews API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\ImageFamilyViewsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface getAsync(GetImageFamilyViewRequest $request, array $optionalArgs = []) */ -final class ImageFamilyViewsClient extends ImageFamilyViewsBaseClient +final class ImageFamilyViewsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ImageFamilyViewsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.ImageFamilyViews'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute.readonly', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/image_family_views_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/image_family_views_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/image_family_views_rest_client_config.php', + ], + ], + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Returns the latest image that is part of an image family, is not deprecated and is rolled out in the specified zone. + * + * The async variant is {@see ImageFamilyViewsClient::getAsync()} . + * + * @param GetImageFamilyViewRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ImageFamilyView + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetImageFamilyViewRequest $request, array $callOptions = []): ImageFamilyView + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/ImagesClient.php b/Compute/src/V1/Client/ImagesClient.php index daab46c5c2ac..59f22d14a377 100644 --- a/Compute/src/V1/Client/ImagesClient.php +++ b/Compute/src/V1/Client/ImagesClient.php @@ -24,17 +24,490 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\ImagesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteImageRequest; +use Google\Cloud\Compute\V1\DeprecateImageRequest; +use Google\Cloud\Compute\V1\GetFromFamilyImageRequest; +use Google\Cloud\Compute\V1\GetIamPolicyImageRequest; +use Google\Cloud\Compute\V1\GetImageRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\Image; +use Google\Cloud\Compute\V1\InsertImageRequest; +use Google\Cloud\Compute\V1\ListImagesRequest; +use Google\Cloud\Compute\V1\PatchImageRequest; +use Google\Cloud\Compute\V1\Policy; +use Google\Cloud\Compute\V1\SetIamPolicyImageRequest; +use Google\Cloud\Compute\V1\SetLabelsImageRequest; +use Google\Cloud\Compute\V1\TestIamPermissionsImageRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Images API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\ImagesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteImageRequest $request, array $optionalArgs = []) + * @method PromiseInterface deprecateAsync(DeprecateImageRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetImageRequest $request, array $optionalArgs = []) + * @method PromiseInterface getFromFamilyAsync(GetFromFamilyImageRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyImageRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertImageRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListImagesRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchImageRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyImageRequest $request, array $optionalArgs = []) + * @method PromiseInterface setLabelsAsync(SetLabelsImageRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsImageRequest $request, array $optionalArgs = []) */ -final class ImagesClient extends ImagesBaseClient +final class ImagesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ImagesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.Images'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/images_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/images_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/images_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified image. + * + * The async variant is {@see ImagesClient::deleteAsync()} . + * + * @param DeleteImageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteImageRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Sets the deprecation status of an image. If an empty request body is given, clears the deprecation status instead. + * + * The async variant is {@see ImagesClient::deprecateAsync()} . + * + * @param DeprecateImageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deprecate(DeprecateImageRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Deprecate', $request, $callOptions)->wait(); + } + + /** + * Returns the specified image. + * + * The async variant is {@see ImagesClient::getAsync()} . + * + * @param GetImageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Image + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetImageRequest $request, array $callOptions = []): Image + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Returns the latest image that is part of an image family and is not deprecated. For more information on image families, see Public image families documentation. + * + * The async variant is {@see ImagesClient::getFromFamilyAsync()} . + * + * @param GetFromFamilyImageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Image + * + * @throws ApiException Thrown if the API call fails. + */ + public function getFromFamily(GetFromFamilyImageRequest $request, array $callOptions = []): Image + { + return $this->startApiCall('GetFromFamily', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * The async variant is {@see ImagesClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyImageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyImageRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Creates an image in the specified project using the data included in the request. + * + * The async variant is {@see ImagesClient::insertAsync()} . + * + * @param InsertImageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertImageRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of custom images available to the specified project. Custom images are images you create that belong to your project. This method does not get any images that belong to other projects, including publicly-available images, like Debian 8. If you want to get a list of publicly-available images, use this method to make a request to the respective image project, such as debian-cloud or windows-cloud. + * + * The async variant is {@see ImagesClient::listAsync()} . + * + * @param ListImagesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListImagesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Patches the specified image with the data included in the request. Only the following fields can be modified: family, description, deprecation status. + * + * The async variant is {@see ImagesClient::patchAsync()} . + * + * @param PatchImageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchImageRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * The async variant is {@see ImagesClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyImageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyImageRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the labels on an image. To learn more about labels, read the Labeling Resources documentation. + * + * The async variant is {@see ImagesClient::setLabelsAsync()} . + * + * @param SetLabelsImageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setLabels(SetLabelsImageRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. + * + * The async variant is {@see ImagesClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsImageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsImageRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/InstanceGroupManagersClient.php b/Compute/src/V1/Client/InstanceGroupManagersClient.php index 0984621ef013..49c0f5359664 100644 --- a/Compute/src/V1/Client/InstanceGroupManagersClient.php +++ b/Compute/src/V1/Client/InstanceGroupManagersClient.php @@ -24,17 +24,735 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\InstanceGroupManagersBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AbandonInstancesInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\AggregatedListInstanceGroupManagersRequest; +use Google\Cloud\Compute\V1\ApplyUpdatesToInstancesInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\CreateInstancesInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\DeleteInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\DeleteInstancesInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\DeletePerInstanceConfigsInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\GetInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\InsertInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\InstanceGroupManager; +use Google\Cloud\Compute\V1\ListErrorsInstanceGroupManagersRequest; +use Google\Cloud\Compute\V1\ListInstanceGroupManagersRequest; +use Google\Cloud\Compute\V1\ListManagedInstancesInstanceGroupManagersRequest; +use Google\Cloud\Compute\V1\ListPerInstanceConfigsInstanceGroupManagersRequest; +use Google\Cloud\Compute\V1\PatchInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\PatchPerInstanceConfigsInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\RecreateInstancesInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\ResizeInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\SetInstanceTemplateInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\SetTargetPoolsInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\UpdatePerInstanceConfigsInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\ZoneOperationsClient; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The InstanceGroupManagers API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\InstanceGroupManagersClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface abandonInstancesAsync(AbandonInstancesInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface aggregatedListAsync(AggregatedListInstanceGroupManagersRequest $request, array $optionalArgs = []) + * @method PromiseInterface applyUpdatesToInstancesAsync(ApplyUpdatesToInstancesInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface createInstancesAsync(CreateInstancesInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteInstancesAsync(DeleteInstancesInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface deletePerInstanceConfigsAsync(DeletePerInstanceConfigsInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListInstanceGroupManagersRequest $request, array $optionalArgs = []) + * @method PromiseInterface listErrorsAsync(ListErrorsInstanceGroupManagersRequest $request, array $optionalArgs = []) + * @method PromiseInterface listManagedInstancesAsync(ListManagedInstancesInstanceGroupManagersRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPerInstanceConfigsAsync(ListPerInstanceConfigsInstanceGroupManagersRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchPerInstanceConfigsAsync(PatchPerInstanceConfigsInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface recreateInstancesAsync(RecreateInstancesInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface resizeAsync(ResizeInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface setInstanceTemplateAsync(SetInstanceTemplateInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface setTargetPoolsAsync(SetTargetPoolsInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface updatePerInstanceConfigsAsync(UpdatePerInstanceConfigsInstanceGroupManagerRequest $request, array $optionalArgs = []) */ -final class InstanceGroupManagersClient extends InstanceGroupManagersBaseClient +final class InstanceGroupManagersClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see InstanceGroupManagersBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.InstanceGroupManagers'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/instance_group_managers_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/instance_group_managers_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/instance_group_managers_rest_client_config.php', + ], + ], + 'operationsClientClass' => ZoneOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an ZoneOperationsClient object with the same endpoint as $this. + * + * @return ZoneOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getZone', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Flags the specified instances to be removed from the managed instance group. Abandoning an instance does not delete the instance, but it does remove the instance from any target pools that are applied by the managed instance group. This method reduces the targetSize of the managed instance group by the number of instances that you abandon. This operation is marked as DONE when the action is scheduled even if the instances have not yet been removed from the group. You must separately verify the status of the abandoning action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. + * + * The async variant is {@see InstanceGroupManagersClient::abandonInstancesAsync()} + * . + * + * @param AbandonInstancesInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function abandonInstances(AbandonInstancesInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AbandonInstances', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of managed instance groups and groups them by zone. + * + * The async variant is {@see InstanceGroupManagersClient::aggregatedListAsync()} . + * + * @param AggregatedListInstanceGroupManagersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListInstanceGroupManagersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Applies changes to selected instances on the managed instance group. This method can be used to apply new overrides and/or new versions. + * + * The async variant is + * {@see InstanceGroupManagersClient::applyUpdatesToInstancesAsync()} . + * + * @param ApplyUpdatesToInstancesInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function applyUpdatesToInstances(ApplyUpdatesToInstancesInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ApplyUpdatesToInstances', $request, $callOptions)->wait(); + } + + /** + * Creates instances with per-instance configurations in this managed instance group. Instances are created using the current instance template. The create instances operation is marked DONE if the createInstances request is successful. The underlying actions take additional time. You must separately verify the status of the creating or actions with the listmanagedinstances method. + * + * The async variant is {@see InstanceGroupManagersClient::createInstancesAsync()} + * . + * + * @param CreateInstancesInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createInstances(CreateInstancesInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateInstances', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified managed instance group and all of the instances in that group. Note that the instance group must not belong to a backend service. Read Deleting an instance group for more information. + * + * The async variant is {@see InstanceGroupManagersClient::deleteAsync()} . + * + * @param DeleteInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Flags the specified instances in the managed instance group for immediate deletion. The instances are also removed from any target pools of which they were a member. This method reduces the targetSize of the managed instance group by the number of instances that you delete. This operation is marked as DONE when the action is scheduled even if the instances are still being deleted. You must separately verify the status of the deleting action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. + * + * The async variant is {@see InstanceGroupManagersClient::deleteInstancesAsync()} + * . + * + * @param DeleteInstancesInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteInstances(DeleteInstancesInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteInstances', $request, $callOptions)->wait(); + } + + /** + * Deletes selected per-instance configurations for the managed instance group. + * + * The async variant is + * {@see InstanceGroupManagersClient::deletePerInstanceConfigsAsync()} . + * + * @param DeletePerInstanceConfigsInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deletePerInstanceConfigs(DeletePerInstanceConfigsInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeletePerInstanceConfigs', $request, $callOptions)->wait(); + } + + /** + * Returns all of the details about the specified managed instance group. + * + * The async variant is {@see InstanceGroupManagersClient::getAsync()} . + * + * @param GetInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InstanceGroupManager + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetInstanceGroupManagerRequest $request, array $callOptions = []): InstanceGroupManager + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a managed instance group using the information that you specify in the request. After the group is created, instances in the group are created using the specified instance template. This operation is marked as DONE when the group is created even if the instances in the group have not yet been created. You must separately verify the status of the individual instances with the listmanagedinstances method. A managed instance group can have up to 1000 VM instances per group. Please contact Cloud Support if you need an increase in this limit. + * + * The async variant is {@see InstanceGroupManagersClient::insertAsync()} . + * + * @param InsertInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of managed instance groups that are contained within the specified project and zone. + * + * The async variant is {@see InstanceGroupManagersClient::listAsync()} . + * + * @param ListInstanceGroupManagersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListInstanceGroupManagersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Lists all errors thrown by actions on instances for a given managed instance group. The filter and orderBy query parameters are not supported. + * + * The async variant is {@see InstanceGroupManagersClient::listErrorsAsync()} . + * + * @param ListErrorsInstanceGroupManagersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listErrors(ListErrorsInstanceGroupManagersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListErrors', $request, $callOptions); + } + + /** + * Lists all of the instances in the managed instance group. Each instance in the list has a currentAction, which indicates the action that the managed instance group is performing on the instance. For example, if the group is still creating an instance, the currentAction is CREATING. If a previous action failed, the list displays the errors for that failed action. The orderBy query parameter is not supported. The `pageToken` query parameter is supported only in the alpha and beta API and only if the group's `listManagedInstancesResults` field is set to `PAGINATED`. + * + * The async variant is + * {@see InstanceGroupManagersClient::listManagedInstancesAsync()} . + * + * @param ListManagedInstancesInstanceGroupManagersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listManagedInstances(ListManagedInstancesInstanceGroupManagersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListManagedInstances', $request, $callOptions); + } + + /** + * Lists all of the per-instance configurations defined for the managed instance group. The orderBy query parameter is not supported. + * + * The async variant is + * {@see InstanceGroupManagersClient::listPerInstanceConfigsAsync()} . + * + * @param ListPerInstanceConfigsInstanceGroupManagersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPerInstanceConfigs(ListPerInstanceConfigsInstanceGroupManagersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPerInstanceConfigs', $request, $callOptions); + } + + /** + * Updates a managed instance group using the information that you specify in the request. This operation is marked as DONE when the group is patched even if the instances in the group are still in the process of being patched. You must separately verify the status of the individual instances with the listManagedInstances method. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. If you update your group to specify a new template or instance configuration, it's possible that your intended specification for each VM in the group is different from the current state of that VM. To learn how to apply an updated configuration to the VMs in a MIG, see Updating instances in a MIG. + * + * The async variant is {@see InstanceGroupManagersClient::patchAsync()} . + * + * @param PatchInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Inserts or patches per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch. + * + * The async variant is + * {@see InstanceGroupManagersClient::patchPerInstanceConfigsAsync()} . + * + * @param PatchPerInstanceConfigsInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patchPerInstanceConfigs(PatchPerInstanceConfigsInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('PatchPerInstanceConfigs', $request, $callOptions)->wait(); + } + + /** + * Flags the specified VM instances in the managed instance group to be immediately recreated. Each instance is recreated using the group's current configuration. This operation is marked as DONE when the flag is set even if the instances have not yet been recreated. You must separately verify the status of each instance by checking its currentAction field; for more information, see Checking the status of managed instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. + * + * The async variant is + * {@see InstanceGroupManagersClient::recreateInstancesAsync()} . + * + * @param RecreateInstancesInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function recreateInstances(RecreateInstancesInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RecreateInstances', $request, $callOptions)->wait(); + } + + /** + * Resizes the managed instance group. If you increase the size, the group creates new instances using the current instance template. If you decrease the size, the group deletes instances. The resize operation is marked DONE when the resize actions are scheduled even if the group has not yet added or deleted any instances. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method. When resizing down, the instance group arbitrarily chooses the order in which VMs are deleted. The group takes into account some VM attributes when making the selection including: + The status of the VM instance. + The health of the VM instance. + The instance template version the VM is based on. + For regional managed instance groups, the location of the VM instance. This list is subject to change. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. + * + * The async variant is {@see InstanceGroupManagersClient::resizeAsync()} . + * + * @param ResizeInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function resize(ResizeInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Resize', $request, $callOptions)->wait(); + } + + /** + * Specifies the instance template to use when creating new instances in this group. The templates for existing instances in the group do not change unless you run recreateInstances, run applyUpdatesToInstances, or set the group's updatePolicy.type to PROACTIVE. + * + * The async variant is + * {@see InstanceGroupManagersClient::setInstanceTemplateAsync()} . + * + * @param SetInstanceTemplateInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setInstanceTemplate(SetInstanceTemplateInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetInstanceTemplate', $request, $callOptions)->wait(); + } + + /** + * Modifies the target pools to which all instances in this managed instance group are assigned. The target pools automatically apply to all of the instances in the managed instance group. This operation is marked DONE when you make the request even if the instances have not yet been added to their target pools. The change might take some time to apply to all of the instances in the group depending on the size of the group. + * + * The async variant is {@see InstanceGroupManagersClient::setTargetPoolsAsync()} . + * + * @param SetTargetPoolsInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setTargetPools(SetTargetPoolsInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetTargetPools', $request, $callOptions)->wait(); + } + + /** + * Inserts or updates per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch. + * + * The async variant is + * {@see InstanceGroupManagersClient::updatePerInstanceConfigsAsync()} . + * + * @param UpdatePerInstanceConfigsInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updatePerInstanceConfigs(UpdatePerInstanceConfigsInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdatePerInstanceConfigs', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/InstanceGroupsClient.php b/Compute/src/V1/Client/InstanceGroupsClient.php index 52cea9018cb2..f662904d484b 100644 --- a/Compute/src/V1/Client/InstanceGroupsClient.php +++ b/Compute/src/V1/Client/InstanceGroupsClient.php @@ -24,17 +24,437 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\InstanceGroupsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AddInstancesInstanceGroupRequest; +use Google\Cloud\Compute\V1\AggregatedListInstanceGroupsRequest; +use Google\Cloud\Compute\V1\DeleteInstanceGroupRequest; +use Google\Cloud\Compute\V1\GetInstanceGroupRequest; +use Google\Cloud\Compute\V1\InsertInstanceGroupRequest; +use Google\Cloud\Compute\V1\InstanceGroup; +use Google\Cloud\Compute\V1\ListInstanceGroupsRequest; +use Google\Cloud\Compute\V1\ListInstancesInstanceGroupsRequest; +use Google\Cloud\Compute\V1\RemoveInstancesInstanceGroupRequest; +use Google\Cloud\Compute\V1\SetNamedPortsInstanceGroupRequest; +use Google\Cloud\Compute\V1\ZoneOperationsClient; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The InstanceGroups API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\InstanceGroupsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface addInstancesAsync(AddInstancesInstanceGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface aggregatedListAsync(AggregatedListInstanceGroupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteInstanceGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetInstanceGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertInstanceGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListInstanceGroupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInstancesAsync(ListInstancesInstanceGroupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeInstancesAsync(RemoveInstancesInstanceGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface setNamedPortsAsync(SetNamedPortsInstanceGroupRequest $request, array $optionalArgs = []) */ -final class InstanceGroupsClient extends InstanceGroupsBaseClient +final class InstanceGroupsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see InstanceGroupsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.InstanceGroups'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/instance_groups_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/instance_groups_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/instance_groups_rest_client_config.php', + ], + ], + 'operationsClientClass' => ZoneOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an ZoneOperationsClient object with the same endpoint as $this. + * + * @return ZoneOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getZone', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Adds a list of instances to the specified instance group. All of the instances in the instance group must be in the same network/subnetwork. Read Adding instances for more information. + * + * The async variant is {@see InstanceGroupsClient::addInstancesAsync()} . + * + * @param AddInstancesInstanceGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addInstances(AddInstancesInstanceGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddInstances', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of instance groups and sorts them by zone. + * + * The async variant is {@see InstanceGroupsClient::aggregatedListAsync()} . + * + * @param AggregatedListInstanceGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListInstanceGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified instance group. The instances in the group are not deleted. Note that instance group must not belong to a backend service. Read Deleting an instance group for more information. + * + * The async variant is {@see InstanceGroupsClient::deleteAsync()} . + * + * @param DeleteInstanceGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteInstanceGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified zonal instance group. Get a list of available zonal instance groups by making a list() request. For managed instance groups, use the instanceGroupManagers or regionInstanceGroupManagers methods instead. + * + * The async variant is {@see InstanceGroupsClient::getAsync()} . + * + * @param GetInstanceGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InstanceGroup + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetInstanceGroupRequest $request, array $callOptions = []): InstanceGroup + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates an instance group in the specified project using the parameters that are included in the request. + * + * The async variant is {@see InstanceGroupsClient::insertAsync()} . + * + * @param InsertInstanceGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertInstanceGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of zonal instance group resources contained within the specified zone. For managed instance groups, use the instanceGroupManagers or regionInstanceGroupManagers methods instead. + * + * The async variant is {@see InstanceGroupsClient::listAsync()} . + * + * @param ListInstanceGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListInstanceGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Lists the instances in the specified instance group. The orderBy query parameter is not supported. The filter query parameter is supported, but only for expressions that use `eq` (equal) or `ne` (not equal) operators. + * + * The async variant is {@see InstanceGroupsClient::listInstancesAsync()} . + * + * @param ListInstancesInstanceGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInstances(ListInstancesInstanceGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInstances', $request, $callOptions); + } + + /** + * Removes one or more instances from the specified instance group, but does not delete those instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration before the VM instance is removed or deleted. + * + * The async variant is {@see InstanceGroupsClient::removeInstancesAsync()} . + * + * @param RemoveInstancesInstanceGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeInstances(RemoveInstancesInstanceGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RemoveInstances', $request, $callOptions)->wait(); + } + + /** + * Sets the named ports for the specified instance group. + * + * The async variant is {@see InstanceGroupsClient::setNamedPortsAsync()} . + * + * @param SetNamedPortsInstanceGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setNamedPorts(SetNamedPortsInstanceGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetNamedPorts', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/InstanceTemplatesClient.php b/Compute/src/V1/Client/InstanceTemplatesClient.php index 64841e1eeb1a..47179cf2599a 100644 --- a/Compute/src/V1/Client/InstanceTemplatesClient.php +++ b/Compute/src/V1/Client/InstanceTemplatesClient.php @@ -24,17 +24,412 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\InstanceTemplatesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListInstanceTemplatesRequest; +use Google\Cloud\Compute\V1\DeleteInstanceTemplateRequest; +use Google\Cloud\Compute\V1\GetIamPolicyInstanceTemplateRequest; +use Google\Cloud\Compute\V1\GetInstanceTemplateRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertInstanceTemplateRequest; +use Google\Cloud\Compute\V1\InstanceTemplate; +use Google\Cloud\Compute\V1\ListInstanceTemplatesRequest; +use Google\Cloud\Compute\V1\Policy; +use Google\Cloud\Compute\V1\SetIamPolicyInstanceTemplateRequest; +use Google\Cloud\Compute\V1\TestIamPermissionsInstanceTemplateRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The InstanceTemplates API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\InstanceTemplatesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListInstanceTemplatesRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteInstanceTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetInstanceTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyInstanceTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertInstanceTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListInstanceTemplatesRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyInstanceTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsInstanceTemplateRequest $request, array $optionalArgs = []) */ -final class InstanceTemplatesClient extends InstanceTemplatesBaseClient +final class InstanceTemplatesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see InstanceTemplatesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.InstanceTemplates'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/instance_templates_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/instance_templates_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/instance_templates_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves the list of all InstanceTemplates resources, regional and global, available to the specified project. + * + * The async variant is {@see InstanceTemplatesClient::aggregatedListAsync()} . + * + * @param AggregatedListInstanceTemplatesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListInstanceTemplatesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified instance template. Deleting an instance template is permanent and cannot be undone. It is not possible to delete templates that are already in use by a managed instance group. + * + * The async variant is {@see InstanceTemplatesClient::deleteAsync()} . + * + * @param DeleteInstanceTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteInstanceTemplateRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified instance template. + * + * The async variant is {@see InstanceTemplatesClient::getAsync()} . + * + * @param GetInstanceTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InstanceTemplate + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetInstanceTemplateRequest $request, array $callOptions = []): InstanceTemplate + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * The async variant is {@see InstanceTemplatesClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyInstanceTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyInstanceTemplateRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Creates an instance template in the specified project using the data that is included in the request. If you are creating a new template to update an existing instance group, your new instance template must use the same network or, if applicable, the same subnetwork as the original template. + * + * The async variant is {@see InstanceTemplatesClient::insertAsync()} . + * + * @param InsertInstanceTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertInstanceTemplateRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of instance templates that are contained within the specified project. + * + * The async variant is {@see InstanceTemplatesClient::listAsync()} . + * + * @param ListInstanceTemplatesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListInstanceTemplatesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * The async variant is {@see InstanceTemplatesClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyInstanceTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyInstanceTemplateRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. + * + * The async variant is {@see InstanceTemplatesClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsInstanceTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsInstanceTemplateRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/InstancesClient.php b/Compute/src/V1/Client/InstancesClient.php index b2a8664e48d3..031e91faa56f 100644 --- a/Compute/src/V1/Client/InstancesClient.php +++ b/Compute/src/V1/Client/InstancesClient.php @@ -24,17 +24,1410 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\InstancesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AddAccessConfigInstanceRequest; +use Google\Cloud\Compute\V1\AddResourcePoliciesInstanceRequest; +use Google\Cloud\Compute\V1\AggregatedListInstancesRequest; +use Google\Cloud\Compute\V1\AttachDiskInstanceRequest; +use Google\Cloud\Compute\V1\BulkInsertInstanceRequest; +use Google\Cloud\Compute\V1\DeleteAccessConfigInstanceRequest; +use Google\Cloud\Compute\V1\DeleteInstanceRequest; +use Google\Cloud\Compute\V1\DetachDiskInstanceRequest; +use Google\Cloud\Compute\V1\GetEffectiveFirewallsInstanceRequest; +use Google\Cloud\Compute\V1\GetGuestAttributesInstanceRequest; +use Google\Cloud\Compute\V1\GetIamPolicyInstanceRequest; +use Google\Cloud\Compute\V1\GetInstanceRequest; +use Google\Cloud\Compute\V1\GetScreenshotInstanceRequest; +use Google\Cloud\Compute\V1\GetSerialPortOutputInstanceRequest; +use Google\Cloud\Compute\V1\GetShieldedInstanceIdentityInstanceRequest; +use Google\Cloud\Compute\V1\GuestAttributes; +use Google\Cloud\Compute\V1\InsertInstanceRequest; +use Google\Cloud\Compute\V1\Instance; +use Google\Cloud\Compute\V1\InstancesGetEffectiveFirewallsResponse; +use Google\Cloud\Compute\V1\ListInstancesRequest; +use Google\Cloud\Compute\V1\ListReferrersInstancesRequest; +use Google\Cloud\Compute\V1\Policy; +use Google\Cloud\Compute\V1\RemoveResourcePoliciesInstanceRequest; +use Google\Cloud\Compute\V1\ResetInstanceRequest; +use Google\Cloud\Compute\V1\ResumeInstanceRequest; +use Google\Cloud\Compute\V1\Screenshot; +use Google\Cloud\Compute\V1\SendDiagnosticInterruptInstanceRequest; +use Google\Cloud\Compute\V1\SendDiagnosticInterruptInstanceResponse; +use Google\Cloud\Compute\V1\SerialPortOutput; +use Google\Cloud\Compute\V1\SetDeletionProtectionInstanceRequest; +use Google\Cloud\Compute\V1\SetDiskAutoDeleteInstanceRequest; +use Google\Cloud\Compute\V1\SetIamPolicyInstanceRequest; +use Google\Cloud\Compute\V1\SetLabelsInstanceRequest; +use Google\Cloud\Compute\V1\SetMachineResourcesInstanceRequest; +use Google\Cloud\Compute\V1\SetMachineTypeInstanceRequest; +use Google\Cloud\Compute\V1\SetMetadataInstanceRequest; +use Google\Cloud\Compute\V1\SetMinCpuPlatformInstanceRequest; +use Google\Cloud\Compute\V1\SetNameInstanceRequest; +use Google\Cloud\Compute\V1\SetSchedulingInstanceRequest; +use Google\Cloud\Compute\V1\SetServiceAccountInstanceRequest; +use Google\Cloud\Compute\V1\SetShieldedInstanceIntegrityPolicyInstanceRequest; +use Google\Cloud\Compute\V1\SetTagsInstanceRequest; +use Google\Cloud\Compute\V1\ShieldedInstanceIdentity; +use Google\Cloud\Compute\V1\SimulateMaintenanceEventInstanceRequest; +use Google\Cloud\Compute\V1\StartInstanceRequest; +use Google\Cloud\Compute\V1\StartWithEncryptionKeyInstanceRequest; +use Google\Cloud\Compute\V1\StopInstanceRequest; +use Google\Cloud\Compute\V1\SuspendInstanceRequest; +use Google\Cloud\Compute\V1\TestIamPermissionsInstanceRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use Google\Cloud\Compute\V1\UpdateAccessConfigInstanceRequest; +use Google\Cloud\Compute\V1\UpdateDisplayDeviceInstanceRequest; +use Google\Cloud\Compute\V1\UpdateInstanceRequest; +use Google\Cloud\Compute\V1\UpdateNetworkInterfaceInstanceRequest; +use Google\Cloud\Compute\V1\UpdateShieldedInstanceConfigInstanceRequest; +use Google\Cloud\Compute\V1\ZoneOperationsClient; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Instances API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\InstancesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface addAccessConfigAsync(AddAccessConfigInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface addResourcePoliciesAsync(AddResourcePoliciesInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface aggregatedListAsync(AggregatedListInstancesRequest $request, array $optionalArgs = []) + * @method PromiseInterface attachDiskAsync(AttachDiskInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface bulkInsertAsync(BulkInsertInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAccessConfigAsync(DeleteAccessConfigInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface detachDiskAsync(DetachDiskInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEffectiveFirewallsAsync(GetEffectiveFirewallsInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getGuestAttributesAsync(GetGuestAttributesInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getScreenshotAsync(GetScreenshotInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSerialPortOutputAsync(GetSerialPortOutputInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getShieldedInstanceIdentityAsync(GetShieldedInstanceIdentityInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListInstancesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listReferrersAsync(ListReferrersInstancesRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeResourcePoliciesAsync(RemoveResourcePoliciesInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface resetAsync(ResetInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface resumeAsync(ResumeInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface sendDiagnosticInterruptAsync(SendDiagnosticInterruptInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setDeletionProtectionAsync(SetDeletionProtectionInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setDiskAutoDeleteAsync(SetDiskAutoDeleteInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setLabelsAsync(SetLabelsInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setMachineResourcesAsync(SetMachineResourcesInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setMachineTypeAsync(SetMachineTypeInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setMetadataAsync(SetMetadataInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setMinCpuPlatformAsync(SetMinCpuPlatformInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setNameAsync(SetNameInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setSchedulingAsync(SetSchedulingInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setServiceAccountAsync(SetServiceAccountInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setShieldedInstanceIntegrityPolicyAsync(SetShieldedInstanceIntegrityPolicyInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setTagsAsync(SetTagsInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface simulateMaintenanceEventAsync(SimulateMaintenanceEventInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface startAsync(StartInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface startWithEncryptionKeyAsync(StartWithEncryptionKeyInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface stopAsync(StopInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface suspendAsync(SuspendInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAsync(UpdateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAccessConfigAsync(UpdateAccessConfigInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDisplayDeviceAsync(UpdateDisplayDeviceInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateNetworkInterfaceAsync(UpdateNetworkInterfaceInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateShieldedInstanceConfigAsync(UpdateShieldedInstanceConfigInstanceRequest $request, array $optionalArgs = []) */ -final class InstancesClient extends InstancesBaseClient +final class InstancesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see InstancesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.Instances'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/instances_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/instances_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/instances_rest_client_config.php', + ], + ], + 'operationsClientClass' => ZoneOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an ZoneOperationsClient object with the same endpoint as $this. + * + * @return ZoneOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getZone', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Adds an access config to an instance's network interface. + * + * The async variant is {@see InstancesClient::addAccessConfigAsync()} . + * + * @param AddAccessConfigInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addAccessConfig(AddAccessConfigInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddAccessConfig', $request, $callOptions)->wait(); + } + + /** + * Adds existing resource policies to an instance. You can only add one policy right now which will be applied to this instance for scheduling live migrations. + * + * The async variant is {@see InstancesClient::addResourcePoliciesAsync()} . + * + * @param AddResourcePoliciesInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addResourcePolicies(AddResourcePoliciesInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddResourcePolicies', $request, $callOptions)->wait(); + } + + /** + * Retrieves an aggregated list of all of the instances in your project across all regions and zones. The performance of this method degrades when a filter is specified on a project that has a very large number of instances. + * + * The async variant is {@see InstancesClient::aggregatedListAsync()} . + * + * @param AggregatedListInstancesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListInstancesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Attaches an existing Disk resource to an instance. You must first create the disk before you can attach it. It is not possible to create and attach a disk at the same time. For more information, read Adding a persistent disk to your instance. + * + * The async variant is {@see InstancesClient::attachDiskAsync()} . + * + * @param AttachDiskInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function attachDisk(AttachDiskInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AttachDisk', $request, $callOptions)->wait(); + } + + /** + * Creates multiple instances. Count specifies the number of instances to create. For more information, see About bulk creation of VMs. + * + * The async variant is {@see InstancesClient::bulkInsertAsync()} . + * + * @param BulkInsertInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function bulkInsert(BulkInsertInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BulkInsert', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified Instance resource. For more information, see Deleting an instance. + * + * The async variant is {@see InstancesClient::deleteAsync()} . + * + * @param DeleteInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Deletes an access config from an instance's network interface. + * + * The async variant is {@see InstancesClient::deleteAccessConfigAsync()} . + * + * @param DeleteAccessConfigInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAccessConfig(DeleteAccessConfigInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteAccessConfig', $request, $callOptions)->wait(); + } + + /** + * Detaches a disk from an instance. + * + * The async variant is {@see InstancesClient::detachDiskAsync()} . + * + * @param DetachDiskInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function detachDisk(DetachDiskInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DetachDisk', $request, $callOptions)->wait(); + } + + /** + * Returns the specified Instance resource. + * + * The async variant is {@see InstancesClient::getAsync()} . + * + * @param GetInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Instance + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetInstanceRequest $request, array $callOptions = []): Instance + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Returns effective firewalls applied to an interface of the instance. + * + * The async variant is {@see InstancesClient::getEffectiveFirewallsAsync()} . + * + * @param GetEffectiveFirewallsInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InstancesGetEffectiveFirewallsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEffectiveFirewalls(GetEffectiveFirewallsInstanceRequest $request, array $callOptions = []): InstancesGetEffectiveFirewallsResponse + { + return $this->startApiCall('GetEffectiveFirewalls', $request, $callOptions)->wait(); + } + + /** + * Returns the specified guest attributes entry. + * + * The async variant is {@see InstancesClient::getGuestAttributesAsync()} . + * + * @param GetGuestAttributesInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GuestAttributes + * + * @throws ApiException Thrown if the API call fails. + */ + public function getGuestAttributes(GetGuestAttributesInstanceRequest $request, array $callOptions = []): GuestAttributes + { + return $this->startApiCall('GetGuestAttributes', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * The async variant is {@see InstancesClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyInstanceRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns the screenshot from the specified instance. + * + * The async variant is {@see InstancesClient::getScreenshotAsync()} . + * + * @param GetScreenshotInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Screenshot + * + * @throws ApiException Thrown if the API call fails. + */ + public function getScreenshot(GetScreenshotInstanceRequest $request, array $callOptions = []): Screenshot + { + return $this->startApiCall('GetScreenshot', $request, $callOptions)->wait(); + } + + /** + * Returns the last 1 MB of serial port output from the specified instance. + * + * The async variant is {@see InstancesClient::getSerialPortOutputAsync()} . + * + * @param GetSerialPortOutputInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SerialPortOutput + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSerialPortOutput(GetSerialPortOutputInstanceRequest $request, array $callOptions = []): SerialPortOutput + { + return $this->startApiCall('GetSerialPortOutput', $request, $callOptions)->wait(); + } + + /** + * Returns the Shielded Instance Identity of an instance + * + * The async variant is {@see InstancesClient::getShieldedInstanceIdentityAsync()} + * . + * + * @param GetShieldedInstanceIdentityInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ShieldedInstanceIdentity + * + * @throws ApiException Thrown if the API call fails. + */ + public function getShieldedInstanceIdentity(GetShieldedInstanceIdentityInstanceRequest $request, array $callOptions = []): ShieldedInstanceIdentity + { + return $this->startApiCall('GetShieldedInstanceIdentity', $request, $callOptions)->wait(); + } + + /** + * Creates an instance resource in the specified project using the data included in the request. + * + * The async variant is {@see InstancesClient::insertAsync()} . + * + * @param InsertInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of instances contained within the specified zone. + * + * The async variant is {@see InstancesClient::listAsync()} . + * + * @param ListInstancesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListInstancesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Retrieves a list of resources that refer to the VM instance specified in the request. For example, if the VM instance is part of a managed or unmanaged instance group, the referrers list includes the instance group. For more information, read Viewing referrers to VM instances. + * + * The async variant is {@see InstancesClient::listReferrersAsync()} . + * + * @param ListReferrersInstancesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listReferrers(ListReferrersInstancesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListReferrers', $request, $callOptions); + } + + /** + * Removes resource policies from an instance. + * + * The async variant is {@see InstancesClient::removeResourcePoliciesAsync()} . + * + * @param RemoveResourcePoliciesInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeResourcePolicies(RemoveResourcePoliciesInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RemoveResourcePolicies', $request, $callOptions)->wait(); + } + + /** + * Performs a reset on the instance. This is a hard reset. The VM does not do a graceful shutdown. For more information, see Resetting an instance. + * + * The async variant is {@see InstancesClient::resetAsync()} . + * + * @param ResetInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function reset(ResetInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Reset', $request, $callOptions)->wait(); + } + + /** + * Resumes an instance that was suspended using the instances().suspend method. + * + * The async variant is {@see InstancesClient::resumeAsync()} . + * + * @param ResumeInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function resume(ResumeInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Resume', $request, $callOptions)->wait(); + } + + /** + * Sends diagnostic interrupt to the instance. + * + * The async variant is {@see InstancesClient::sendDiagnosticInterruptAsync()} . + * + * @param SendDiagnosticInterruptInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SendDiagnosticInterruptInstanceResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function sendDiagnosticInterrupt(SendDiagnosticInterruptInstanceRequest $request, array $callOptions = []): SendDiagnosticInterruptInstanceResponse + { + return $this->startApiCall('SendDiagnosticInterrupt', $request, $callOptions)->wait(); + } + + /** + * Sets deletion protection on the instance. + * + * The async variant is {@see InstancesClient::setDeletionProtectionAsync()} . + * + * @param SetDeletionProtectionInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setDeletionProtection(SetDeletionProtectionInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetDeletionProtection', $request, $callOptions)->wait(); + } + + /** + * Sets the auto-delete flag for a disk attached to an instance. + * + * The async variant is {@see InstancesClient::setDiskAutoDeleteAsync()} . + * + * @param SetDiskAutoDeleteInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setDiskAutoDelete(SetDiskAutoDeleteInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetDiskAutoDelete', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * The async variant is {@see InstancesClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyInstanceRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets labels on an instance. To learn more about labels, read the Labeling Resources documentation. + * + * The async variant is {@see InstancesClient::setLabelsAsync()} . + * + * @param SetLabelsInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setLabels(SetLabelsInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); + } + + /** + * Changes the number and/or type of accelerator for a stopped instance to the values specified in the request. + * + * The async variant is {@see InstancesClient::setMachineResourcesAsync()} . + * + * @param SetMachineResourcesInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setMachineResources(SetMachineResourcesInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetMachineResources', $request, $callOptions)->wait(); + } + + /** + * Changes the machine type for a stopped instance to the machine type specified in the request. + * + * The async variant is {@see InstancesClient::setMachineTypeAsync()} . + * + * @param SetMachineTypeInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setMachineType(SetMachineTypeInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetMachineType', $request, $callOptions)->wait(); + } + + /** + * Sets metadata for the specified instance to the data included in the request. + * + * The async variant is {@see InstancesClient::setMetadataAsync()} . + * + * @param SetMetadataInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setMetadata(SetMetadataInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetMetadata', $request, $callOptions)->wait(); + } + + /** + * Changes the minimum CPU platform that this instance should use. This method can only be called on a stopped instance. For more information, read Specifying a Minimum CPU Platform. + * + * The async variant is {@see InstancesClient::setMinCpuPlatformAsync()} . + * + * @param SetMinCpuPlatformInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setMinCpuPlatform(SetMinCpuPlatformInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetMinCpuPlatform', $request, $callOptions)->wait(); + } + + /** + * Sets name of an instance. + * + * The async variant is {@see InstancesClient::setNameAsync()} . + * + * @param SetNameInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setName(SetNameInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetName', $request, $callOptions)->wait(); + } + + /** + * Sets an instance's scheduling options. You can only call this method on a stopped instance, that is, a VM instance that is in a `TERMINATED` state. See Instance Life Cycle for more information on the possible instance states. For more information about setting scheduling options for a VM, see Set VM host maintenance policy. + * + * The async variant is {@see InstancesClient::setSchedulingAsync()} . + * + * @param SetSchedulingInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setScheduling(SetSchedulingInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetScheduling', $request, $callOptions)->wait(); + } + + /** + * Sets the service account on the instance. For more information, read Changing the service account and access scopes for an instance. + * + * The async variant is {@see InstancesClient::setServiceAccountAsync()} . + * + * @param SetServiceAccountInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setServiceAccount(SetServiceAccountInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetServiceAccount', $request, $callOptions)->wait(); + } + + /** + * Sets the Shielded Instance integrity policy for an instance. You can only use this method on a running instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * The async variant is + * {@see InstancesClient::setShieldedInstanceIntegrityPolicyAsync()} . + * + * @param SetShieldedInstanceIntegrityPolicyInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setShieldedInstanceIntegrityPolicy(SetShieldedInstanceIntegrityPolicyInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetShieldedInstanceIntegrityPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets network tags for the specified instance to the data included in the request. + * + * The async variant is {@see InstancesClient::setTagsAsync()} . + * + * @param SetTagsInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setTags(SetTagsInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetTags', $request, $callOptions)->wait(); + } + + /** + * Simulates a host maintenance event on a VM. For more information, see Simulate a host maintenance event. + * + * The async variant is {@see InstancesClient::simulateMaintenanceEventAsync()} . + * + * @param SimulateMaintenanceEventInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function simulateMaintenanceEvent(SimulateMaintenanceEventInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SimulateMaintenanceEvent', $request, $callOptions)->wait(); + } + + /** + * Starts an instance that was stopped using the instances().stop method. For more information, see Restart an instance. + * + * The async variant is {@see InstancesClient::startAsync()} . + * + * @param StartInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function start(StartInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Start', $request, $callOptions)->wait(); + } + + /** + * Starts an instance that was stopped using the instances().stop method. For more information, see Restart an instance. + * + * The async variant is {@see InstancesClient::startWithEncryptionKeyAsync()} . + * + * @param StartWithEncryptionKeyInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function startWithEncryptionKey(StartWithEncryptionKeyInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StartWithEncryptionKey', $request, $callOptions)->wait(); + } + + /** + * Stops a running instance, shutting it down cleanly, and allows you to restart the instance at a later time. Stopped instances do not incur VM usage charges while they are stopped. However, resources that the VM is using, such as persistent disks and static IP addresses, will continue to be charged until they are deleted. For more information, see Stopping an instance. + * + * The async variant is {@see InstancesClient::stopAsync()} . + * + * @param StopInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function stop(StopInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Stop', $request, $callOptions)->wait(); + } + + /** + * This method suspends a running instance, saving its state to persistent storage, and allows you to resume the instance at a later time. Suspended instances have no compute costs (cores or RAM), and incur only storage charges for the saved VM memory and localSSD data. Any charged resources the virtual machine was using, such as persistent disks and static IP addresses, will continue to be charged while the instance is suspended. For more information, see Suspending and resuming an instance. + * + * The async variant is {@see InstancesClient::suspendAsync()} . + * + * @param SuspendInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function suspend(SuspendInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Suspend', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. + * + * The async variant is {@see InstancesClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsInstanceRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates an instance only if the necessary resources are available. This method can update only a specific set of instance properties. See Updating a running instance for a list of updatable instance properties. + * + * The async variant is {@see InstancesClient::updateAsync()} . + * + * @param UpdateInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function update(UpdateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Update', $request, $callOptions)->wait(); + } + + /** + * Updates the specified access config from an instance's network interface with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * The async variant is {@see InstancesClient::updateAccessConfigAsync()} . + * + * @param UpdateAccessConfigInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAccessConfig(UpdateAccessConfigInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateAccessConfig', $request, $callOptions)->wait(); + } + + /** + * Updates the Display config for a VM instance. You can only use this method on a stopped VM instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * The async variant is {@see InstancesClient::updateDisplayDeviceAsync()} . + * + * @param UpdateDisplayDeviceInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDisplayDevice(UpdateDisplayDeviceInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateDisplayDevice', $request, $callOptions)->wait(); + } + + /** + * Updates an instance's network interface. This method can only update an interface's alias IP range and attached network. See Modifying alias IP ranges for an existing instance for instructions on changing alias IP ranges. See Migrating a VM between networks for instructions on migrating an interface. This method follows PATCH semantics. + * + * The async variant is {@see InstancesClient::updateNetworkInterfaceAsync()} . + * + * @param UpdateNetworkInterfaceInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateNetworkInterface(UpdateNetworkInterfaceInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateNetworkInterface', $request, $callOptions)->wait(); + } + + /** + * Updates the Shielded Instance config for an instance. You can only use this method on a stopped instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * The async variant is {@see InstancesClient::updateShieldedInstanceConfigAsync()} + * . + * + * @param UpdateShieldedInstanceConfigInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateShieldedInstanceConfig(UpdateShieldedInstanceConfigInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateShieldedInstanceConfig', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/InterconnectAttachmentsClient.php b/Compute/src/V1/Client/InterconnectAttachmentsClient.php index dbce0b031446..bbd32107f729 100644 --- a/Compute/src/V1/Client/InterconnectAttachmentsClient.php +++ b/Compute/src/V1/Client/InterconnectAttachmentsClient.php @@ -24,17 +24,387 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\InterconnectAttachmentsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListInterconnectAttachmentsRequest; +use Google\Cloud\Compute\V1\DeleteInterconnectAttachmentRequest; +use Google\Cloud\Compute\V1\GetInterconnectAttachmentRequest; +use Google\Cloud\Compute\V1\InsertInterconnectAttachmentRequest; +use Google\Cloud\Compute\V1\InterconnectAttachment; +use Google\Cloud\Compute\V1\ListInterconnectAttachmentsRequest; +use Google\Cloud\Compute\V1\PatchInterconnectAttachmentRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\SetLabelsInterconnectAttachmentRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The InterconnectAttachments API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\InterconnectAttachmentsClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListInterconnectAttachmentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteInterconnectAttachmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetInterconnectAttachmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertInterconnectAttachmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListInterconnectAttachmentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchInterconnectAttachmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface setLabelsAsync(SetLabelsInterconnectAttachmentRequest $request, array $optionalArgs = []) */ -final class InterconnectAttachmentsClient extends InterconnectAttachmentsBaseClient +final class InterconnectAttachmentsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see InterconnectAttachmentsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.InterconnectAttachments'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/interconnect_attachments_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/interconnect_attachments_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/interconnect_attachments_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves an aggregated list of interconnect attachments. + * + * The async variant is {@see InterconnectAttachmentsClient::aggregatedListAsync()} + * . + * + * @param AggregatedListInterconnectAttachmentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListInterconnectAttachmentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified interconnect attachment. + * + * The async variant is {@see InterconnectAttachmentsClient::deleteAsync()} . + * + * @param DeleteInterconnectAttachmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteInterconnectAttachmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified interconnect attachment. + * + * The async variant is {@see InterconnectAttachmentsClient::getAsync()} . + * + * @param GetInterconnectAttachmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InterconnectAttachment + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetInterconnectAttachmentRequest $request, array $callOptions = []): InterconnectAttachment + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates an InterconnectAttachment in the specified project using the data included in the request. + * + * The async variant is {@see InterconnectAttachmentsClient::insertAsync()} . + * + * @param InsertInterconnectAttachmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertInterconnectAttachmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of interconnect attachments contained within the specified region. + * + * The async variant is {@see InterconnectAttachmentsClient::listAsync()} . + * + * @param ListInterconnectAttachmentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListInterconnectAttachmentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Updates the specified interconnect attachment with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * The async variant is {@see InterconnectAttachmentsClient::patchAsync()} . + * + * @param PatchInterconnectAttachmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchInterconnectAttachmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Sets the labels on an InterconnectAttachment. To learn more about labels, read the Labeling Resources documentation. + * + * The async variant is {@see InterconnectAttachmentsClient::setLabelsAsync()} . + * + * @param SetLabelsInterconnectAttachmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setLabels(SetLabelsInterconnectAttachmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/InterconnectLocationsClient.php b/Compute/src/V1/Client/InterconnectLocationsClient.php index 20403ff13fee..65df4dfdacac 100644 --- a/Compute/src/V1/Client/InterconnectLocationsClient.php +++ b/Compute/src/V1/Client/InterconnectLocationsClient.php @@ -24,17 +24,203 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\InterconnectLocationsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\GetInterconnectLocationRequest; +use Google\Cloud\Compute\V1\InterconnectLocation; +use Google\Cloud\Compute\V1\ListInterconnectLocationsRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The InterconnectLocations API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\InterconnectLocationsClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface getAsync(GetInterconnectLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListInterconnectLocationsRequest $request, array $optionalArgs = []) */ -final class InterconnectLocationsClient extends InterconnectLocationsBaseClient +final class InterconnectLocationsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see InterconnectLocationsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.InterconnectLocations'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute.readonly', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/interconnect_locations_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/interconnect_locations_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/interconnect_locations_rest_client_config.php', + ], + ], + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Returns the details for the specified interconnect location. Gets a list of available interconnect locations by making a list() request. + * + * The async variant is {@see InterconnectLocationsClient::getAsync()} . + * + * @param GetInterconnectLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InterconnectLocation + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetInterconnectLocationRequest $request, array $callOptions = []): InterconnectLocation + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of interconnect locations available to the specified project. + * + * The async variant is {@see InterconnectLocationsClient::listAsync()} . + * + * @param ListInterconnectLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListInterconnectLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } } diff --git a/Compute/src/V1/Client/InterconnectRemoteLocationsClient.php b/Compute/src/V1/Client/InterconnectRemoteLocationsClient.php index 7607f1915359..97049c62689c 100644 --- a/Compute/src/V1/Client/InterconnectRemoteLocationsClient.php +++ b/Compute/src/V1/Client/InterconnectRemoteLocationsClient.php @@ -24,17 +24,203 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\InterconnectRemoteLocationsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\GetInterconnectRemoteLocationRequest; +use Google\Cloud\Compute\V1\InterconnectRemoteLocation; +use Google\Cloud\Compute\V1\ListInterconnectRemoteLocationsRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The InterconnectRemoteLocations API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\InterconnectRemoteLocationsClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface getAsync(GetInterconnectRemoteLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListInterconnectRemoteLocationsRequest $request, array $optionalArgs = []) */ -final class InterconnectRemoteLocationsClient extends InterconnectRemoteLocationsBaseClient +final class InterconnectRemoteLocationsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see InterconnectRemoteLocationsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.InterconnectRemoteLocations'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute.readonly', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/interconnect_remote_locations_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/interconnect_remote_locations_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/interconnect_remote_locations_rest_client_config.php', + ], + ], + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Returns the details for the specified interconnect remote location. Gets a list of available interconnect remote locations by making a list() request. + * + * The async variant is {@see InterconnectRemoteLocationsClient::getAsync()} . + * + * @param GetInterconnectRemoteLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InterconnectRemoteLocation + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetInterconnectRemoteLocationRequest $request, array $callOptions = []): InterconnectRemoteLocation + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of interconnect remote locations available to the specified project. + * + * The async variant is {@see InterconnectRemoteLocationsClient::listAsync()} . + * + * @param ListInterconnectRemoteLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListInterconnectRemoteLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } } diff --git a/Compute/src/V1/Client/InterconnectsClient.php b/Compute/src/V1/Client/InterconnectsClient.php index c8b363c77818..2154836e71db 100644 --- a/Compute/src/V1/Client/InterconnectsClient.php +++ b/Compute/src/V1/Client/InterconnectsClient.php @@ -24,17 +24,385 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\InterconnectsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteInterconnectRequest; +use Google\Cloud\Compute\V1\GetDiagnosticsInterconnectRequest; +use Google\Cloud\Compute\V1\GetInterconnectRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertInterconnectRequest; +use Google\Cloud\Compute\V1\Interconnect; +use Google\Cloud\Compute\V1\InterconnectsGetDiagnosticsResponse; +use Google\Cloud\Compute\V1\ListInterconnectsRequest; +use Google\Cloud\Compute\V1\PatchInterconnectRequest; +use Google\Cloud\Compute\V1\SetLabelsInterconnectRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Interconnects API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\InterconnectsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteInterconnectRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetInterconnectRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDiagnosticsAsync(GetDiagnosticsInterconnectRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertInterconnectRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListInterconnectsRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchInterconnectRequest $request, array $optionalArgs = []) + * @method PromiseInterface setLabelsAsync(SetLabelsInterconnectRequest $request, array $optionalArgs = []) */ -final class InterconnectsClient extends InterconnectsBaseClient +final class InterconnectsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see InterconnectsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.Interconnects'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/interconnects_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/interconnects_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/interconnects_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified Interconnect. + * + * The async variant is {@see InterconnectsClient::deleteAsync()} . + * + * @param DeleteInterconnectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteInterconnectRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified Interconnect. Get a list of available Interconnects by making a list() request. + * + * The async variant is {@see InterconnectsClient::getAsync()} . + * + * @param GetInterconnectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Interconnect + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetInterconnectRequest $request, array $callOptions = []): Interconnect + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Returns the interconnectDiagnostics for the specified Interconnect. + * + * The async variant is {@see InterconnectsClient::getDiagnosticsAsync()} . + * + * @param GetDiagnosticsInterconnectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InterconnectsGetDiagnosticsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDiagnostics(GetDiagnosticsInterconnectRequest $request, array $callOptions = []): InterconnectsGetDiagnosticsResponse + { + return $this->startApiCall('GetDiagnostics', $request, $callOptions)->wait(); + } + + /** + * Creates an Interconnect in the specified project using the data included in the request. + * + * The async variant is {@see InterconnectsClient::insertAsync()} . + * + * @param InsertInterconnectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertInterconnectRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of Interconnects available to the specified project. + * + * The async variant is {@see InterconnectsClient::listAsync()} . + * + * @param ListInterconnectsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListInterconnectsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Updates the specified Interconnect with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * The async variant is {@see InterconnectsClient::patchAsync()} . + * + * @param PatchInterconnectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchInterconnectRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Sets the labels on an Interconnect. To learn more about labels, read the Labeling Resources documentation. + * + * The async variant is {@see InterconnectsClient::setLabelsAsync()} . + * + * @param SetLabelsInterconnectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setLabels(SetLabelsInterconnectRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/LicenseCodesClient.php b/Compute/src/V1/Client/LicenseCodesClient.php index 1457b999a1ed..ee3b745fea4e 100644 --- a/Compute/src/V1/Client/LicenseCodesClient.php +++ b/Compute/src/V1/Client/LicenseCodesClient.php @@ -24,17 +24,202 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\LicenseCodesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\GetLicenseCodeRequest; +use Google\Cloud\Compute\V1\LicenseCode; +use Google\Cloud\Compute\V1\TestIamPermissionsLicenseCodeRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The LicenseCodes API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\LicenseCodesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface getAsync(GetLicenseCodeRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsLicenseCodeRequest $request, array $optionalArgs = []) */ -final class LicenseCodesClient extends LicenseCodesBaseClient +final class LicenseCodesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see LicenseCodesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.LicenseCodes'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute.readonly', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/license_codes_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/license_codes_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/license_codes_rest_client_config.php', + ], + ], + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Return a specified license code. License codes are mirrored across all projects that have permissions to read the License Code. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + * + * The async variant is {@see LicenseCodesClient::getAsync()} . + * + * @param GetLicenseCodeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LicenseCode + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetLicenseCodeRequest $request, array $callOptions = []): LicenseCode + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + * + * The async variant is {@see LicenseCodesClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsLicenseCodeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsLicenseCodeRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/LicensesClient.php b/Compute/src/V1/Client/LicensesClient.php index 90b853d1241b..8dfa849088c6 100644 --- a/Compute/src/V1/Client/LicensesClient.php +++ b/Compute/src/V1/Client/LicensesClient.php @@ -24,17 +24,386 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\LicensesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteLicenseRequest; +use Google\Cloud\Compute\V1\GetIamPolicyLicenseRequest; +use Google\Cloud\Compute\V1\GetLicenseRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertLicenseRequest; +use Google\Cloud\Compute\V1\License; +use Google\Cloud\Compute\V1\ListLicensesRequest; +use Google\Cloud\Compute\V1\Policy; +use Google\Cloud\Compute\V1\SetIamPolicyLicenseRequest; +use Google\Cloud\Compute\V1\TestIamPermissionsLicenseRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Licenses API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\LicensesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteLicenseRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetLicenseRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyLicenseRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertLicenseRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListLicensesRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyLicenseRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsLicenseRequest $request, array $optionalArgs = []) */ -final class LicensesClient extends LicensesBaseClient +final class LicensesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see LicensesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.Licenses'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/licenses_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/licenses_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/licenses_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified license. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + * + * The async variant is {@see LicensesClient::deleteAsync()} . + * + * @param DeleteLicenseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteLicenseRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified License resource. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + * + * The async variant is {@see LicensesClient::getAsync()} . + * + * @param GetLicenseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 License + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetLicenseRequest $request, array $callOptions = []): License + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + * + * The async variant is {@see LicensesClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyLicenseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyLicenseRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Create a License resource in the specified project. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + * + * The async variant is {@see LicensesClient::insertAsync()} . + * + * @param InsertLicenseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertLicenseRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of licenses available in the specified project. This method does not get any licenses that belong to other projects, including licenses attached to publicly-available images, like Debian 9. If you want to get a list of publicly-available licenses, use this method to make a request to the respective image project, such as debian-cloud or windows-cloud. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + * + * The async variant is {@see LicensesClient::listAsync()} . + * + * @param ListLicensesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListLicensesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Sets the access control policy on the specified resource. Replaces any existing policy. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + * + * The async variant is {@see LicensesClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyLicenseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyLicenseRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. + * + * The async variant is {@see LicensesClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsLicenseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsLicenseRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/MachineImagesClient.php b/Compute/src/V1/Client/MachineImagesClient.php index cf07acd21652..ca5ce7b96357 100644 --- a/Compute/src/V1/Client/MachineImagesClient.php +++ b/Compute/src/V1/Client/MachineImagesClient.php @@ -24,17 +24,386 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\MachineImagesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteMachineImageRequest; +use Google\Cloud\Compute\V1\GetIamPolicyMachineImageRequest; +use Google\Cloud\Compute\V1\GetMachineImageRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertMachineImageRequest; +use Google\Cloud\Compute\V1\ListMachineImagesRequest; +use Google\Cloud\Compute\V1\MachineImage; +use Google\Cloud\Compute\V1\Policy; +use Google\Cloud\Compute\V1\SetIamPolicyMachineImageRequest; +use Google\Cloud\Compute\V1\TestIamPermissionsMachineImageRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The MachineImages API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\MachineImagesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteMachineImageRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetMachineImageRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyMachineImageRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertMachineImageRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListMachineImagesRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyMachineImageRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsMachineImageRequest $request, array $optionalArgs = []) */ -final class MachineImagesClient extends MachineImagesBaseClient +final class MachineImagesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see MachineImagesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.MachineImages'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/machine_images_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/machine_images_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/machine_images_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified machine image. Deleting a machine image is permanent and cannot be undone. + * + * The async variant is {@see MachineImagesClient::deleteAsync()} . + * + * @param DeleteMachineImageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteMachineImageRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified machine image. + * + * The async variant is {@see MachineImagesClient::getAsync()} . + * + * @param GetMachineImageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MachineImage + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetMachineImageRequest $request, array $callOptions = []): MachineImage + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * The async variant is {@see MachineImagesClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyMachineImageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyMachineImageRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Creates a machine image in the specified project using the data that is included in the request. If you are creating a new machine image to update an existing instance, your new machine image should use the same network or, if applicable, the same subnetwork as the original instance. + * + * The async variant is {@see MachineImagesClient::insertAsync()} . + * + * @param InsertMachineImageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertMachineImageRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of machine images that are contained within the specified project. + * + * The async variant is {@see MachineImagesClient::listAsync()} . + * + * @param ListMachineImagesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListMachineImagesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * The async variant is {@see MachineImagesClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyMachineImageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyMachineImageRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. + * + * The async variant is {@see MachineImagesClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsMachineImageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsMachineImageRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/MachineTypesClient.php b/Compute/src/V1/Client/MachineTypesClient.php index 4ee92b0f5f99..aa90727554fe 100644 --- a/Compute/src/V1/Client/MachineTypesClient.php +++ b/Compute/src/V1/Client/MachineTypesClient.php @@ -24,17 +24,228 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\MachineTypesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListMachineTypesRequest; +use Google\Cloud\Compute\V1\GetMachineTypeRequest; +use Google\Cloud\Compute\V1\ListMachineTypesRequest; +use Google\Cloud\Compute\V1\MachineType; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The MachineTypes API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\MachineTypesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListMachineTypesRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetMachineTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListMachineTypesRequest $request, array $optionalArgs = []) */ -final class MachineTypesClient extends MachineTypesBaseClient +final class MachineTypesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see MachineTypesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.MachineTypes'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute.readonly', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/machine_types_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/machine_types_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/machine_types_rest_client_config.php', + ], + ], + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves an aggregated list of machine types. + * + * The async variant is {@see MachineTypesClient::aggregatedListAsync()} . + * + * @param AggregatedListMachineTypesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListMachineTypesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Returns the specified machine type. + * + * The async variant is {@see MachineTypesClient::getAsync()} . + * + * @param GetMachineTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MachineType + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetMachineTypeRequest $request, array $callOptions = []): MachineType + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of machine types available to the specified project. + * + * The async variant is {@see MachineTypesClient::listAsync()} . + * + * @param ListMachineTypesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListMachineTypesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } } diff --git a/Compute/src/V1/Client/NetworkAttachmentsClient.php b/Compute/src/V1/Client/NetworkAttachmentsClient.php index 5957cdcf48d3..d7654c38eae1 100644 --- a/Compute/src/V1/Client/NetworkAttachmentsClient.php +++ b/Compute/src/V1/Client/NetworkAttachmentsClient.php @@ -24,17 +24,414 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\NetworkAttachmentsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListNetworkAttachmentsRequest; +use Google\Cloud\Compute\V1\DeleteNetworkAttachmentRequest; +use Google\Cloud\Compute\V1\GetIamPolicyNetworkAttachmentRequest; +use Google\Cloud\Compute\V1\GetNetworkAttachmentRequest; +use Google\Cloud\Compute\V1\InsertNetworkAttachmentRequest; +use Google\Cloud\Compute\V1\ListNetworkAttachmentsRequest; +use Google\Cloud\Compute\V1\NetworkAttachment; +use Google\Cloud\Compute\V1\Policy; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\SetIamPolicyNetworkAttachmentRequest; +use Google\Cloud\Compute\V1\TestIamPermissionsNetworkAttachmentRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The NetworkAttachments API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\NetworkAttachmentsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListNetworkAttachmentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteNetworkAttachmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetNetworkAttachmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyNetworkAttachmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertNetworkAttachmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListNetworkAttachmentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyNetworkAttachmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsNetworkAttachmentRequest $request, array $optionalArgs = []) */ -final class NetworkAttachmentsClient extends NetworkAttachmentsBaseClient +final class NetworkAttachmentsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see NetworkAttachmentsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.NetworkAttachments'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/network_attachments_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/network_attachments_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/network_attachments_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves the list of all NetworkAttachment resources, regional and global, available to the specified project. + * + * The async variant is {@see NetworkAttachmentsClient::aggregatedListAsync()} . + * + * @param AggregatedListNetworkAttachmentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListNetworkAttachmentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified NetworkAttachment in the given scope + * + * The async variant is {@see NetworkAttachmentsClient::deleteAsync()} . + * + * @param DeleteNetworkAttachmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteNetworkAttachmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified NetworkAttachment resource in the given scope. + * + * The async variant is {@see NetworkAttachmentsClient::getAsync()} . + * + * @param GetNetworkAttachmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NetworkAttachment + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetNetworkAttachmentRequest $request, array $callOptions = []): NetworkAttachment + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * The async variant is {@see NetworkAttachmentsClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyNetworkAttachmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyNetworkAttachmentRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Creates a NetworkAttachment in the specified project in the given scope using the parameters that are included in the request. + * + * The async variant is {@see NetworkAttachmentsClient::insertAsync()} . + * + * @param InsertNetworkAttachmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertNetworkAttachmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Lists the NetworkAttachments for a project in the given scope. + * + * The async variant is {@see NetworkAttachmentsClient::listAsync()} . + * + * @param ListNetworkAttachmentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListNetworkAttachmentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * The async variant is {@see NetworkAttachmentsClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyNetworkAttachmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyNetworkAttachmentRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. + * + * The async variant is {@see NetworkAttachmentsClient::testIamPermissionsAsync()} + * . + * + * @param TestIamPermissionsNetworkAttachmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsNetworkAttachmentRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/NetworkEdgeSecurityServicesClient.php b/Compute/src/V1/Client/NetworkEdgeSecurityServicesClient.php index f14645fa7f65..2913e7e3b37f 100644 --- a/Compute/src/V1/Client/NetworkEdgeSecurityServicesClient.php +++ b/Compute/src/V1/Client/NetworkEdgeSecurityServicesClient.php @@ -24,17 +24,335 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\NetworkEdgeSecurityServicesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListNetworkEdgeSecurityServicesRequest; +use Google\Cloud\Compute\V1\DeleteNetworkEdgeSecurityServiceRequest; +use Google\Cloud\Compute\V1\GetNetworkEdgeSecurityServiceRequest; +use Google\Cloud\Compute\V1\InsertNetworkEdgeSecurityServiceRequest; +use Google\Cloud\Compute\V1\NetworkEdgeSecurityService; +use Google\Cloud\Compute\V1\PatchNetworkEdgeSecurityServiceRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The NetworkEdgeSecurityServices API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\NetworkEdgeSecurityServicesClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListNetworkEdgeSecurityServicesRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteNetworkEdgeSecurityServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetNetworkEdgeSecurityServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertNetworkEdgeSecurityServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchNetworkEdgeSecurityServiceRequest $request, array $optionalArgs = []) */ -final class NetworkEdgeSecurityServicesClient extends NetworkEdgeSecurityServicesBaseClient +final class NetworkEdgeSecurityServicesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see NetworkEdgeSecurityServicesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.NetworkEdgeSecurityServices'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/network_edge_security_services_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/network_edge_security_services_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/network_edge_security_services_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves the list of all NetworkEdgeSecurityService resources available to the specified project. + * + * The async variant is + * {@see NetworkEdgeSecurityServicesClient::aggregatedListAsync()} . + * + * @param AggregatedListNetworkEdgeSecurityServicesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListNetworkEdgeSecurityServicesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified service. + * + * The async variant is {@see NetworkEdgeSecurityServicesClient::deleteAsync()} . + * + * @param DeleteNetworkEdgeSecurityServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteNetworkEdgeSecurityServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Gets a specified NetworkEdgeSecurityService. + * + * The async variant is {@see NetworkEdgeSecurityServicesClient::getAsync()} . + * + * @param GetNetworkEdgeSecurityServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NetworkEdgeSecurityService + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetNetworkEdgeSecurityServiceRequest $request, array $callOptions = []): NetworkEdgeSecurityService + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a new service in the specified project using the data included in the request. + * + * The async variant is {@see NetworkEdgeSecurityServicesClient::insertAsync()} . + * + * @param InsertNetworkEdgeSecurityServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertNetworkEdgeSecurityServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Patches the specified policy with the data included in the request. + * + * The async variant is {@see NetworkEdgeSecurityServicesClient::patchAsync()} . + * + * @param PatchNetworkEdgeSecurityServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchNetworkEdgeSecurityServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/NetworkEndpointGroupsClient.php b/Compute/src/V1/Client/NetworkEndpointGroupsClient.php index 1a3ce1da675e..7ccff71de669 100644 --- a/Compute/src/V1/Client/NetworkEndpointGroupsClient.php +++ b/Compute/src/V1/Client/NetworkEndpointGroupsClient.php @@ -24,17 +24,443 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\NetworkEndpointGroupsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListNetworkEndpointGroupsRequest; +use Google\Cloud\Compute\V1\AttachNetworkEndpointsNetworkEndpointGroupRequest; +use Google\Cloud\Compute\V1\DeleteNetworkEndpointGroupRequest; +use Google\Cloud\Compute\V1\DetachNetworkEndpointsNetworkEndpointGroupRequest; +use Google\Cloud\Compute\V1\GetNetworkEndpointGroupRequest; +use Google\Cloud\Compute\V1\InsertNetworkEndpointGroupRequest; +use Google\Cloud\Compute\V1\ListNetworkEndpointGroupsRequest; +use Google\Cloud\Compute\V1\ListNetworkEndpointsNetworkEndpointGroupsRequest; +use Google\Cloud\Compute\V1\NetworkEndpointGroup; +use Google\Cloud\Compute\V1\TestIamPermissionsNetworkEndpointGroupRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use Google\Cloud\Compute\V1\ZoneOperationsClient; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The NetworkEndpointGroups API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\NetworkEndpointGroupsClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListNetworkEndpointGroupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface attachNetworkEndpointsAsync(AttachNetworkEndpointsNetworkEndpointGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteNetworkEndpointGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface detachNetworkEndpointsAsync(DetachNetworkEndpointsNetworkEndpointGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetNetworkEndpointGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertNetworkEndpointGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListNetworkEndpointGroupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listNetworkEndpointsAsync(ListNetworkEndpointsNetworkEndpointGroupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsNetworkEndpointGroupRequest $request, array $optionalArgs = []) */ -final class NetworkEndpointGroupsClient extends NetworkEndpointGroupsBaseClient +final class NetworkEndpointGroupsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see NetworkEndpointGroupsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.NetworkEndpointGroups'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/network_endpoint_groups_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/network_endpoint_groups_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/network_endpoint_groups_rest_client_config.php', + ], + ], + 'operationsClientClass' => ZoneOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an ZoneOperationsClient object with the same endpoint as $this. + * + * @return ZoneOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getZone', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves the list of network endpoint groups and sorts them by zone. + * + * The async variant is {@see NetworkEndpointGroupsClient::aggregatedListAsync()} . + * + * @param AggregatedListNetworkEndpointGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListNetworkEndpointGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Attach a list of network endpoints to the specified network endpoint group. + * + * The async variant is + * {@see NetworkEndpointGroupsClient::attachNetworkEndpointsAsync()} . + * + * @param AttachNetworkEndpointsNetworkEndpointGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function attachNetworkEndpoints(AttachNetworkEndpointsNetworkEndpointGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AttachNetworkEndpoints', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified network endpoint group. The network endpoints in the NEG and the VM instances they belong to are not terminated when the NEG is deleted. Note that the NEG cannot be deleted if there are backend services referencing it. + * + * The async variant is {@see NetworkEndpointGroupsClient::deleteAsync()} . + * + * @param DeleteNetworkEndpointGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteNetworkEndpointGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Detach a list of network endpoints from the specified network endpoint group. + * + * The async variant is + * {@see NetworkEndpointGroupsClient::detachNetworkEndpointsAsync()} . + * + * @param DetachNetworkEndpointsNetworkEndpointGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function detachNetworkEndpoints(DetachNetworkEndpointsNetworkEndpointGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DetachNetworkEndpoints', $request, $callOptions)->wait(); + } + + /** + * Returns the specified network endpoint group. + * + * The async variant is {@see NetworkEndpointGroupsClient::getAsync()} . + * + * @param GetNetworkEndpointGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NetworkEndpointGroup + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetNetworkEndpointGroupRequest $request, array $callOptions = []): NetworkEndpointGroup + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a network endpoint group in the specified project using the parameters that are included in the request. + * + * The async variant is {@see NetworkEndpointGroupsClient::insertAsync()} . + * + * @param InsertNetworkEndpointGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertNetworkEndpointGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of network endpoint groups that are located in the specified project and zone. + * + * The async variant is {@see NetworkEndpointGroupsClient::listAsync()} . + * + * @param ListNetworkEndpointGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListNetworkEndpointGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Lists the network endpoints in the specified network endpoint group. + * + * The async variant is + * {@see NetworkEndpointGroupsClient::listNetworkEndpointsAsync()} . + * + * @param ListNetworkEndpointsNetworkEndpointGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listNetworkEndpoints(ListNetworkEndpointsNetworkEndpointGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListNetworkEndpoints', $request, $callOptions); + } + + /** + * Returns permissions that a caller has on the specified resource. + * + * The async variant is + * {@see NetworkEndpointGroupsClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsNetworkEndpointGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsNetworkEndpointGroupRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/NetworkFirewallPoliciesClient.php b/Compute/src/V1/Client/NetworkFirewallPoliciesClient.php index 3d1ed91e8ecf..fff0dc2f7c2e 100644 --- a/Compute/src/V1/Client/NetworkFirewallPoliciesClient.php +++ b/Compute/src/V1/Client/NetworkFirewallPoliciesClient.php @@ -24,17 +24,627 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\NetworkFirewallPoliciesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AddAssociationNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\AddRuleNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\CloneRulesNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\DeleteNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\FirewallPolicy; +use Google\Cloud\Compute\V1\FirewallPolicyAssociation; +use Google\Cloud\Compute\V1\FirewallPolicyRule; +use Google\Cloud\Compute\V1\GetAssociationNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\GetIamPolicyNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\GetNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\GetRuleNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\ListNetworkFirewallPoliciesRequest; +use Google\Cloud\Compute\V1\PatchNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\PatchRuleNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\Policy; +use Google\Cloud\Compute\V1\RemoveAssociationNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\RemoveRuleNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\SetIamPolicyNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\TestIamPermissionsNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The NetworkFirewallPolicies API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\NetworkFirewallPoliciesClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface addAssociationAsync(AddAssociationNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface addRuleAsync(AddRuleNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface cloneRulesAsync(CloneRulesNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAssociationAsync(GetAssociationNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRuleAsync(GetRuleNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListNetworkFirewallPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchRuleAsync(PatchRuleNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeAssociationAsync(RemoveAssociationNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeRuleAsync(RemoveRuleNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsNetworkFirewallPolicyRequest $request, array $optionalArgs = []) */ -final class NetworkFirewallPoliciesClient extends NetworkFirewallPoliciesBaseClient +final class NetworkFirewallPoliciesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see NetworkFirewallPoliciesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.NetworkFirewallPolicies'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/network_firewall_policies_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/network_firewall_policies_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/network_firewall_policies_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Inserts an association for the specified firewall policy. + * + * The async variant is {@see NetworkFirewallPoliciesClient::addAssociationAsync()} + * . + * + * @param AddAssociationNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addAssociation(AddAssociationNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddAssociation', $request, $callOptions)->wait(); + } + + /** + * Inserts a rule into a firewall policy. + * + * The async variant is {@see NetworkFirewallPoliciesClient::addRuleAsync()} . + * + * @param AddRuleNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addRule(AddRuleNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddRule', $request, $callOptions)->wait(); + } + + /** + * Copies rules to the specified firewall policy. + * + * The async variant is {@see NetworkFirewallPoliciesClient::cloneRulesAsync()} . + * + * @param CloneRulesNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function cloneRules(CloneRulesNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CloneRules', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified policy. + * + * The async variant is {@see NetworkFirewallPoliciesClient::deleteAsync()} . + * + * @param DeleteNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified network firewall policy. + * + * The async variant is {@see NetworkFirewallPoliciesClient::getAsync()} . + * + * @param GetNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FirewallPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetNetworkFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicy + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Gets an association with the specified name. + * + * The async variant is {@see NetworkFirewallPoliciesClient::getAssociationAsync()} + * . + * + * @param GetAssociationNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FirewallPolicyAssociation + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAssociation(GetAssociationNetworkFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicyAssociation + { + return $this->startApiCall('GetAssociation', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * The async variant is {@see NetworkFirewallPoliciesClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyNetworkFirewallPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets a rule of the specified priority. + * + * The async variant is {@see NetworkFirewallPoliciesClient::getRuleAsync()} . + * + * @param GetRuleNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FirewallPolicyRule + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRule(GetRuleNetworkFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicyRule + { + return $this->startApiCall('GetRule', $request, $callOptions)->wait(); + } + + /** + * Creates a new policy in the specified project using the data included in the request. + * + * The async variant is {@see NetworkFirewallPoliciesClient::insertAsync()} . + * + * @param InsertNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Lists all the policies that have been configured for the specified project. + * + * The async variant is {@see NetworkFirewallPoliciesClient::listAsync()} . + * + * @param ListNetworkFirewallPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListNetworkFirewallPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Patches the specified policy with the data included in the request. + * + * The async variant is {@see NetworkFirewallPoliciesClient::patchAsync()} . + * + * @param PatchNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Patches a rule of the specified priority. + * + * The async variant is {@see NetworkFirewallPoliciesClient::patchRuleAsync()} . + * + * @param PatchRuleNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patchRule(PatchRuleNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('PatchRule', $request, $callOptions)->wait(); + } + + /** + * Removes an association for the specified firewall policy. + * + * The async variant is + * {@see NetworkFirewallPoliciesClient::removeAssociationAsync()} . + * + * @param RemoveAssociationNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeAssociation(RemoveAssociationNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RemoveAssociation', $request, $callOptions)->wait(); + } + + /** + * Deletes a rule of the specified priority. + * + * The async variant is {@see NetworkFirewallPoliciesClient::removeRuleAsync()} . + * + * @param RemoveRuleNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeRule(RemoveRuleNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RemoveRule', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * The async variant is {@see NetworkFirewallPoliciesClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyNetworkFirewallPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. + * + * The async variant is + * {@see NetworkFirewallPoliciesClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsNetworkFirewallPolicyRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/NetworksClient.php b/Compute/src/V1/Client/NetworksClient.php index 622483dbebca..583b77cf6db9 100644 --- a/Compute/src/V1/Client/NetworksClient.php +++ b/Compute/src/V1/Client/NetworksClient.php @@ -24,17 +24,489 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\NetworksBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AddPeeringNetworkRequest; +use Google\Cloud\Compute\V1\DeleteNetworkRequest; +use Google\Cloud\Compute\V1\GetEffectiveFirewallsNetworkRequest; +use Google\Cloud\Compute\V1\GetNetworkRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertNetworkRequest; +use Google\Cloud\Compute\V1\ListNetworksRequest; +use Google\Cloud\Compute\V1\ListPeeringRoutesNetworksRequest; +use Google\Cloud\Compute\V1\Network; +use Google\Cloud\Compute\V1\NetworksGetEffectiveFirewallsResponse; +use Google\Cloud\Compute\V1\PatchNetworkRequest; +use Google\Cloud\Compute\V1\RemovePeeringNetworkRequest; +use Google\Cloud\Compute\V1\SwitchToCustomModeNetworkRequest; +use Google\Cloud\Compute\V1\UpdatePeeringNetworkRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Networks API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\NetworksClient} for the stable implementation * * @experimental + * + * @method PromiseInterface addPeeringAsync(AddPeeringNetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteNetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetNetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEffectiveFirewallsAsync(GetEffectiveFirewallsNetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertNetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListNetworksRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPeeringRoutesAsync(ListPeeringRoutesNetworksRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchNetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface removePeeringAsync(RemovePeeringNetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface switchToCustomModeAsync(SwitchToCustomModeNetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface updatePeeringAsync(UpdatePeeringNetworkRequest $request, array $optionalArgs = []) */ -final class NetworksClient extends NetworksBaseClient +final class NetworksClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see NetworksBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.Networks'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/networks_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/networks_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/networks_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Adds a peering to the specified network. + * + * The async variant is {@see NetworksClient::addPeeringAsync()} . + * + * @param AddPeeringNetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addPeering(AddPeeringNetworkRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddPeering', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified network. + * + * The async variant is {@see NetworksClient::deleteAsync()} . + * + * @param DeleteNetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteNetworkRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified network. + * + * The async variant is {@see NetworksClient::getAsync()} . + * + * @param GetNetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Network + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetNetworkRequest $request, array $callOptions = []): Network + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Returns the effective firewalls on a given network. + * + * The async variant is {@see NetworksClient::getEffectiveFirewallsAsync()} . + * + * @param GetEffectiveFirewallsNetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NetworksGetEffectiveFirewallsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEffectiveFirewalls(GetEffectiveFirewallsNetworkRequest $request, array $callOptions = []): NetworksGetEffectiveFirewallsResponse + { + return $this->startApiCall('GetEffectiveFirewalls', $request, $callOptions)->wait(); + } + + /** + * Creates a network in the specified project using the data included in the request. + * + * The async variant is {@see NetworksClient::insertAsync()} . + * + * @param InsertNetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertNetworkRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of networks available to the specified project. + * + * The async variant is {@see NetworksClient::listAsync()} . + * + * @param ListNetworksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListNetworksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Lists the peering routes exchanged over peering connection. + * + * The async variant is {@see NetworksClient::listPeeringRoutesAsync()} . + * + * @param ListPeeringRoutesNetworksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPeeringRoutes(ListPeeringRoutesNetworksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPeeringRoutes', $request, $callOptions); + } + + /** + * Patches the specified network with the data included in the request. Only the following fields can be modified: routingConfig.routingMode. + * + * The async variant is {@see NetworksClient::patchAsync()} . + * + * @param PatchNetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchNetworkRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Removes a peering from the specified network. + * + * The async variant is {@see NetworksClient::removePeeringAsync()} . + * + * @param RemovePeeringNetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function removePeering(RemovePeeringNetworkRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RemovePeering', $request, $callOptions)->wait(); + } + + /** + * Switches the network mode from auto subnet mode to custom subnet mode. + * + * The async variant is {@see NetworksClient::switchToCustomModeAsync()} . + * + * @param SwitchToCustomModeNetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function switchToCustomMode(SwitchToCustomModeNetworkRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SwitchToCustomMode', $request, $callOptions)->wait(); + } + + /** + * Updates the specified network peering with the data included in the request. You can only modify the NetworkPeering.export_custom_routes field and the NetworkPeering.import_custom_routes field. + * + * The async variant is {@see NetworksClient::updatePeeringAsync()} . + * + * @param UpdatePeeringNetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updatePeering(UpdatePeeringNetworkRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdatePeering', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/NodeGroupsClient.php b/Compute/src/V1/Client/NodeGroupsClient.php index b9831b525853..fc062f2b968c 100644 --- a/Compute/src/V1/Client/NodeGroupsClient.php +++ b/Compute/src/V1/Client/NodeGroupsClient.php @@ -24,17 +24,569 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\NodeGroupsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AddNodesNodeGroupRequest; +use Google\Cloud\Compute\V1\AggregatedListNodeGroupsRequest; +use Google\Cloud\Compute\V1\DeleteNodeGroupRequest; +use Google\Cloud\Compute\V1\DeleteNodesNodeGroupRequest; +use Google\Cloud\Compute\V1\GetIamPolicyNodeGroupRequest; +use Google\Cloud\Compute\V1\GetNodeGroupRequest; +use Google\Cloud\Compute\V1\InsertNodeGroupRequest; +use Google\Cloud\Compute\V1\ListNodeGroupsRequest; +use Google\Cloud\Compute\V1\ListNodesNodeGroupsRequest; +use Google\Cloud\Compute\V1\NodeGroup; +use Google\Cloud\Compute\V1\PatchNodeGroupRequest; +use Google\Cloud\Compute\V1\Policy; +use Google\Cloud\Compute\V1\SetIamPolicyNodeGroupRequest; +use Google\Cloud\Compute\V1\SetNodeTemplateNodeGroupRequest; +use Google\Cloud\Compute\V1\SimulateMaintenanceEventNodeGroupRequest; +use Google\Cloud\Compute\V1\TestIamPermissionsNodeGroupRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use Google\Cloud\Compute\V1\ZoneOperationsClient; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The NodeGroups API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\NodeGroupsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface addNodesAsync(AddNodesNodeGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface aggregatedListAsync(AggregatedListNodeGroupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteNodeGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteNodesAsync(DeleteNodesNodeGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetNodeGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyNodeGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertNodeGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListNodeGroupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listNodesAsync(ListNodesNodeGroupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchNodeGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyNodeGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface setNodeTemplateAsync(SetNodeTemplateNodeGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface simulateMaintenanceEventAsync(SimulateMaintenanceEventNodeGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsNodeGroupRequest $request, array $optionalArgs = []) */ -final class NodeGroupsClient extends NodeGroupsBaseClient +final class NodeGroupsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see NodeGroupsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.NodeGroups'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/node_groups_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/node_groups_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/node_groups_rest_client_config.php', + ], + ], + 'operationsClientClass' => ZoneOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an ZoneOperationsClient object with the same endpoint as $this. + * + * @return ZoneOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getZone', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Adds specified number of nodes to the node group. + * + * The async variant is {@see NodeGroupsClient::addNodesAsync()} . + * + * @param AddNodesNodeGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addNodes(AddNodesNodeGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddNodes', $request, $callOptions)->wait(); + } + + /** + * Retrieves an aggregated list of node groups. Note: use nodeGroups.listNodes for more details about each group. + * + * The async variant is {@see NodeGroupsClient::aggregatedListAsync()} . + * + * @param AggregatedListNodeGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListNodeGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified NodeGroup resource. + * + * The async variant is {@see NodeGroupsClient::deleteAsync()} . + * + * @param DeleteNodeGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteNodeGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Deletes specified nodes from the node group. + * + * The async variant is {@see NodeGroupsClient::deleteNodesAsync()} . + * + * @param DeleteNodesNodeGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteNodes(DeleteNodesNodeGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteNodes', $request, $callOptions)->wait(); + } + + /** + * Returns the specified NodeGroup. Get a list of available NodeGroups by making a list() request. Note: the "nodes" field should not be used. Use nodeGroups.listNodes instead. + * + * The async variant is {@see NodeGroupsClient::getAsync()} . + * + * @param GetNodeGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NodeGroup + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetNodeGroupRequest $request, array $callOptions = []): NodeGroup + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * The async variant is {@see NodeGroupsClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyNodeGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyNodeGroupRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Creates a NodeGroup resource in the specified project using the data included in the request. + * + * The async variant is {@see NodeGroupsClient::insertAsync()} . + * + * @param InsertNodeGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertNodeGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of node groups available to the specified project. Note: use nodeGroups.listNodes for more details about each group. + * + * The async variant is {@see NodeGroupsClient::listAsync()} . + * + * @param ListNodeGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListNodeGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Lists nodes in the node group. + * + * The async variant is {@see NodeGroupsClient::listNodesAsync()} . + * + * @param ListNodesNodeGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listNodes(ListNodesNodeGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListNodes', $request, $callOptions); + } + + /** + * Updates the specified node group. + * + * The async variant is {@see NodeGroupsClient::patchAsync()} . + * + * @param PatchNodeGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchNodeGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * The async variant is {@see NodeGroupsClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyNodeGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyNodeGroupRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Updates the node template of the node group. + * + * The async variant is {@see NodeGroupsClient::setNodeTemplateAsync()} . + * + * @param SetNodeTemplateNodeGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setNodeTemplate(SetNodeTemplateNodeGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetNodeTemplate', $request, $callOptions)->wait(); + } + + /** + * Simulates maintenance event on specified nodes from the node group. + * + * The async variant is {@see NodeGroupsClient::simulateMaintenanceEventAsync()} . + * + * @param SimulateMaintenanceEventNodeGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function simulateMaintenanceEvent(SimulateMaintenanceEventNodeGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SimulateMaintenanceEvent', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. + * + * The async variant is {@see NodeGroupsClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsNodeGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsNodeGroupRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/NodeTemplatesClient.php b/Compute/src/V1/Client/NodeTemplatesClient.php index d9d4b76bc947..9677801ae2fc 100644 --- a/Compute/src/V1/Client/NodeTemplatesClient.php +++ b/Compute/src/V1/Client/NodeTemplatesClient.php @@ -24,17 +24,413 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\NodeTemplatesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListNodeTemplatesRequest; +use Google\Cloud\Compute\V1\DeleteNodeTemplateRequest; +use Google\Cloud\Compute\V1\GetIamPolicyNodeTemplateRequest; +use Google\Cloud\Compute\V1\GetNodeTemplateRequest; +use Google\Cloud\Compute\V1\InsertNodeTemplateRequest; +use Google\Cloud\Compute\V1\ListNodeTemplatesRequest; +use Google\Cloud\Compute\V1\NodeTemplate; +use Google\Cloud\Compute\V1\Policy; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\SetIamPolicyNodeTemplateRequest; +use Google\Cloud\Compute\V1\TestIamPermissionsNodeTemplateRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The NodeTemplates API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\NodeTemplatesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListNodeTemplatesRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteNodeTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetNodeTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyNodeTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertNodeTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListNodeTemplatesRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyNodeTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsNodeTemplateRequest $request, array $optionalArgs = []) */ -final class NodeTemplatesClient extends NodeTemplatesBaseClient +final class NodeTemplatesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see NodeTemplatesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.NodeTemplates'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/node_templates_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/node_templates_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/node_templates_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves an aggregated list of node templates. + * + * The async variant is {@see NodeTemplatesClient::aggregatedListAsync()} . + * + * @param AggregatedListNodeTemplatesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListNodeTemplatesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified NodeTemplate resource. + * + * The async variant is {@see NodeTemplatesClient::deleteAsync()} . + * + * @param DeleteNodeTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteNodeTemplateRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified node template. + * + * The async variant is {@see NodeTemplatesClient::getAsync()} . + * + * @param GetNodeTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NodeTemplate + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetNodeTemplateRequest $request, array $callOptions = []): NodeTemplate + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * The async variant is {@see NodeTemplatesClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyNodeTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyNodeTemplateRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Creates a NodeTemplate resource in the specified project using the data included in the request. + * + * The async variant is {@see NodeTemplatesClient::insertAsync()} . + * + * @param InsertNodeTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertNodeTemplateRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of node templates available to the specified project. + * + * The async variant is {@see NodeTemplatesClient::listAsync()} . + * + * @param ListNodeTemplatesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListNodeTemplatesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * The async variant is {@see NodeTemplatesClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyNodeTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyNodeTemplateRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. + * + * The async variant is {@see NodeTemplatesClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsNodeTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsNodeTemplateRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/NodeTypesClient.php b/Compute/src/V1/Client/NodeTypesClient.php index 1339e5dde065..0b1e18f81b53 100644 --- a/Compute/src/V1/Client/NodeTypesClient.php +++ b/Compute/src/V1/Client/NodeTypesClient.php @@ -24,17 +24,228 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\NodeTypesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListNodeTypesRequest; +use Google\Cloud\Compute\V1\GetNodeTypeRequest; +use Google\Cloud\Compute\V1\ListNodeTypesRequest; +use Google\Cloud\Compute\V1\NodeType; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The NodeTypes API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\NodeTypesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListNodeTypesRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetNodeTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListNodeTypesRequest $request, array $optionalArgs = []) */ -final class NodeTypesClient extends NodeTypesBaseClient +final class NodeTypesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see NodeTypesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.NodeTypes'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute.readonly', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/node_types_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/node_types_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/node_types_rest_client_config.php', + ], + ], + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves an aggregated list of node types. + * + * The async variant is {@see NodeTypesClient::aggregatedListAsync()} . + * + * @param AggregatedListNodeTypesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListNodeTypesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Returns the specified node type. + * + * The async variant is {@see NodeTypesClient::getAsync()} . + * + * @param GetNodeTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NodeType + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetNodeTypeRequest $request, array $callOptions = []): NodeType + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of node types available to the specified project. + * + * The async variant is {@see NodeTypesClient::listAsync()} . + * + * @param ListNodeTypesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListNodeTypesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } } diff --git a/Compute/src/V1/Client/PacketMirroringsClient.php b/Compute/src/V1/Client/PacketMirroringsClient.php index 52955817b9b4..23d4e96e4230 100644 --- a/Compute/src/V1/Client/PacketMirroringsClient.php +++ b/Compute/src/V1/Client/PacketMirroringsClient.php @@ -24,17 +24,386 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\PacketMirroringsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListPacketMirroringsRequest; +use Google\Cloud\Compute\V1\DeletePacketMirroringRequest; +use Google\Cloud\Compute\V1\GetPacketMirroringRequest; +use Google\Cloud\Compute\V1\InsertPacketMirroringRequest; +use Google\Cloud\Compute\V1\ListPacketMirroringsRequest; +use Google\Cloud\Compute\V1\PacketMirroring; +use Google\Cloud\Compute\V1\PatchPacketMirroringRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\TestIamPermissionsPacketMirroringRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The PacketMirrorings API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\PacketMirroringsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListPacketMirroringsRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeletePacketMirroringRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetPacketMirroringRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertPacketMirroringRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListPacketMirroringsRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchPacketMirroringRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsPacketMirroringRequest $request, array $optionalArgs = []) */ -final class PacketMirroringsClient extends PacketMirroringsBaseClient +final class PacketMirroringsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see PacketMirroringsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.PacketMirrorings'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/packet_mirrorings_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/packet_mirrorings_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/packet_mirrorings_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves an aggregated list of packetMirrorings. + * + * The async variant is {@see PacketMirroringsClient::aggregatedListAsync()} . + * + * @param AggregatedListPacketMirroringsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListPacketMirroringsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified PacketMirroring resource. + * + * The async variant is {@see PacketMirroringsClient::deleteAsync()} . + * + * @param DeletePacketMirroringRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeletePacketMirroringRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified PacketMirroring resource. + * + * The async variant is {@see PacketMirroringsClient::getAsync()} . + * + * @param GetPacketMirroringRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PacketMirroring + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetPacketMirroringRequest $request, array $callOptions = []): PacketMirroring + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a PacketMirroring resource in the specified project and region using the data included in the request. + * + * The async variant is {@see PacketMirroringsClient::insertAsync()} . + * + * @param InsertPacketMirroringRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertPacketMirroringRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of PacketMirroring resources available to the specified project and region. + * + * The async variant is {@see PacketMirroringsClient::listAsync()} . + * + * @param ListPacketMirroringsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListPacketMirroringsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Patches the specified PacketMirroring resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + * + * The async variant is {@see PacketMirroringsClient::patchAsync()} . + * + * @param PatchPacketMirroringRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchPacketMirroringRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. + * + * The async variant is {@see PacketMirroringsClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsPacketMirroringRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsPacketMirroringRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/ProjectsClient.php b/Compute/src/V1/Client/ProjectsClient.php index 7aa921656813..092fb6fc4c0b 100644 --- a/Compute/src/V1/Client/ProjectsClient.php +++ b/Compute/src/V1/Client/ProjectsClient.php @@ -24,17 +24,540 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\ProjectsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DisableXpnHostProjectRequest; +use Google\Cloud\Compute\V1\DisableXpnResourceProjectRequest; +use Google\Cloud\Compute\V1\EnableXpnHostProjectRequest; +use Google\Cloud\Compute\V1\EnableXpnResourceProjectRequest; +use Google\Cloud\Compute\V1\GetProjectRequest; +use Google\Cloud\Compute\V1\GetXpnHostProjectRequest; +use Google\Cloud\Compute\V1\GetXpnResourcesProjectsRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\ListXpnHostsProjectsRequest; +use Google\Cloud\Compute\V1\MoveDiskProjectRequest; +use Google\Cloud\Compute\V1\MoveInstanceProjectRequest; +use Google\Cloud\Compute\V1\Project; +use Google\Cloud\Compute\V1\SetCommonInstanceMetadataProjectRequest; +use Google\Cloud\Compute\V1\SetDefaultNetworkTierProjectRequest; +use Google\Cloud\Compute\V1\SetUsageExportBucketProjectRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Projects API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\ProjectsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface disableXpnHostAsync(DisableXpnHostProjectRequest $request, array $optionalArgs = []) + * @method PromiseInterface disableXpnResourceAsync(DisableXpnResourceProjectRequest $request, array $optionalArgs = []) + * @method PromiseInterface enableXpnHostAsync(EnableXpnHostProjectRequest $request, array $optionalArgs = []) + * @method PromiseInterface enableXpnResourceAsync(EnableXpnResourceProjectRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetProjectRequest $request, array $optionalArgs = []) + * @method PromiseInterface getXpnHostAsync(GetXpnHostProjectRequest $request, array $optionalArgs = []) + * @method PromiseInterface getXpnResourcesAsync(GetXpnResourcesProjectsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listXpnHostsAsync(ListXpnHostsProjectsRequest $request, array $optionalArgs = []) + * @method PromiseInterface moveDiskAsync(MoveDiskProjectRequest $request, array $optionalArgs = []) + * @method PromiseInterface moveInstanceAsync(MoveInstanceProjectRequest $request, array $optionalArgs = []) + * @method PromiseInterface setCommonInstanceMetadataAsync(SetCommonInstanceMetadataProjectRequest $request, array $optionalArgs = []) + * @method PromiseInterface setDefaultNetworkTierAsync(SetDefaultNetworkTierProjectRequest $request, array $optionalArgs = []) + * @method PromiseInterface setUsageExportBucketAsync(SetUsageExportBucketProjectRequest $request, array $optionalArgs = []) */ -final class ProjectsClient extends ProjectsBaseClient +final class ProjectsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ProjectsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.Projects'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/projects_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/projects_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/projects_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Disable this project as a shared VPC host project. + * + * The async variant is {@see ProjectsClient::disableXpnHostAsync()} . + * + * @param DisableXpnHostProjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function disableXpnHost(DisableXpnHostProjectRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DisableXpnHost', $request, $callOptions)->wait(); + } + + /** + * Disable a service resource (also known as service project) associated with this host project. + * + * The async variant is {@see ProjectsClient::disableXpnResourceAsync()} . + * + * @param DisableXpnResourceProjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function disableXpnResource(DisableXpnResourceProjectRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DisableXpnResource', $request, $callOptions)->wait(); + } + + /** + * Enable this project as a shared VPC host project. + * + * The async variant is {@see ProjectsClient::enableXpnHostAsync()} . + * + * @param EnableXpnHostProjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function enableXpnHost(EnableXpnHostProjectRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('EnableXpnHost', $request, $callOptions)->wait(); + } + + /** + * Enable service resource (a.k.a service project) for a host project, so that subnets in the host project can be used by instances in the service project. + * + * The async variant is {@see ProjectsClient::enableXpnResourceAsync()} . + * + * @param EnableXpnResourceProjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function enableXpnResource(EnableXpnResourceProjectRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('EnableXpnResource', $request, $callOptions)->wait(); + } + + /** + * Returns the specified Project resource. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the `quotas` field). To exclude one or more fields, set your request's `fields` query parameter to only include the fields you need. For example, to only include the `id` and `selfLink` fields, add the query parameter `?fields=id,selfLink` to your request. + * + * The async variant is {@see ProjectsClient::getAsync()} . + * + * @param GetProjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Project + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetProjectRequest $request, array $callOptions = []): Project + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Gets the shared VPC host project that this project links to. May be empty if no link exists. + * + * The async variant is {@see ProjectsClient::getXpnHostAsync()} . + * + * @param GetXpnHostProjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Project + * + * @throws ApiException Thrown if the API call fails. + */ + public function getXpnHost(GetXpnHostProjectRequest $request, array $callOptions = []): Project + { + return $this->startApiCall('GetXpnHost', $request, $callOptions)->wait(); + } + + /** + * Gets service resources (a.k.a service project) associated with this host project. + * + * The async variant is {@see ProjectsClient::getXpnResourcesAsync()} . + * + * @param GetXpnResourcesProjectsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function getXpnResources(GetXpnResourcesProjectsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('GetXpnResources', $request, $callOptions); + } + + /** + * Lists all shared VPC host projects visible to the user in an organization. + * + * The async variant is {@see ProjectsClient::listXpnHostsAsync()} . + * + * @param ListXpnHostsProjectsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listXpnHosts(ListXpnHostsProjectsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListXpnHosts', $request, $callOptions); + } + + /** + * Moves a persistent disk from one zone to another. + * + * The async variant is {@see ProjectsClient::moveDiskAsync()} . + * + * @param MoveDiskProjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function moveDisk(MoveDiskProjectRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('MoveDisk', $request, $callOptions)->wait(); + } + + /** + * Moves an instance and its attached persistent disks from one zone to another. *Note*: Moving VMs or disks by using this method might cause unexpected behavior. For more information, see the [known issue](/compute/docs/troubleshooting/known-issues#moving_vms_or_disks_using_the_moveinstance_api_or_the_causes_unexpected_behavior). [Deprecated] This method is deprecated. See [moving instance across zones](https://cloud.google.com/compute/docs/instances/moving-instance-across-zones) instead. + * + * The async variant is {@see ProjectsClient::moveInstanceAsync()} . + * + * @param MoveInstanceProjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function moveInstance(MoveInstanceProjectRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('MoveInstance', $request, $callOptions)->wait(); + } + + /** + * Sets metadata common to all instances within the specified project using the data included in the request. + * + * The async variant is {@see ProjectsClient::setCommonInstanceMetadataAsync()} . + * + * @param SetCommonInstanceMetadataProjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setCommonInstanceMetadata(SetCommonInstanceMetadataProjectRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetCommonInstanceMetadata', $request, $callOptions)->wait(); + } + + /** + * Sets the default network tier of the project. The default network tier is used when an address/forwardingRule/instance is created without specifying the network tier field. + * + * The async variant is {@see ProjectsClient::setDefaultNetworkTierAsync()} . + * + * @param SetDefaultNetworkTierProjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setDefaultNetworkTier(SetDefaultNetworkTierProjectRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetDefaultNetworkTier', $request, $callOptions)->wait(); + } + + /** + * Enables the usage export feature and sets the usage export bucket where reports are stored. If you provide an empty request body using this method, the usage export feature will be disabled. + * + * The async variant is {@see ProjectsClient::setUsageExportBucketAsync()} . + * + * @param SetUsageExportBucketProjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setUsageExportBucket(SetUsageExportBucketProjectRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetUsageExportBucket', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/PublicAdvertisedPrefixesClient.php b/Compute/src/V1/Client/PublicAdvertisedPrefixesClient.php index 8e8906ce57fb..f335e062a3df 100644 --- a/Compute/src/V1/Client/PublicAdvertisedPrefixesClient.php +++ b/Compute/src/V1/Client/PublicAdvertisedPrefixesClient.php @@ -24,17 +24,333 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\PublicAdvertisedPrefixesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeletePublicAdvertisedPrefixeRequest; +use Google\Cloud\Compute\V1\GetPublicAdvertisedPrefixeRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertPublicAdvertisedPrefixeRequest; +use Google\Cloud\Compute\V1\ListPublicAdvertisedPrefixesRequest; +use Google\Cloud\Compute\V1\PatchPublicAdvertisedPrefixeRequest; +use Google\Cloud\Compute\V1\PublicAdvertisedPrefix; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The PublicAdvertisedPrefixes API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\PublicAdvertisedPrefixesClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeletePublicAdvertisedPrefixeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetPublicAdvertisedPrefixeRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertPublicAdvertisedPrefixeRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListPublicAdvertisedPrefixesRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchPublicAdvertisedPrefixeRequest $request, array $optionalArgs = []) */ -final class PublicAdvertisedPrefixesClient extends PublicAdvertisedPrefixesBaseClient +final class PublicAdvertisedPrefixesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see PublicAdvertisedPrefixesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.PublicAdvertisedPrefixes'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/public_advertised_prefixes_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/public_advertised_prefixes_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/public_advertised_prefixes_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified PublicAdvertisedPrefix + * + * The async variant is {@see PublicAdvertisedPrefixesClient::deleteAsync()} . + * + * @param DeletePublicAdvertisedPrefixeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeletePublicAdvertisedPrefixeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified PublicAdvertisedPrefix resource. + * + * The async variant is {@see PublicAdvertisedPrefixesClient::getAsync()} . + * + * @param GetPublicAdvertisedPrefixeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PublicAdvertisedPrefix + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetPublicAdvertisedPrefixeRequest $request, array $callOptions = []): PublicAdvertisedPrefix + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a PublicAdvertisedPrefix in the specified project using the parameters that are included in the request. + * + * The async variant is {@see PublicAdvertisedPrefixesClient::insertAsync()} . + * + * @param InsertPublicAdvertisedPrefixeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertPublicAdvertisedPrefixeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Lists the PublicAdvertisedPrefixes for a project. + * + * The async variant is {@see PublicAdvertisedPrefixesClient::listAsync()} . + * + * @param ListPublicAdvertisedPrefixesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListPublicAdvertisedPrefixesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Patches the specified Router resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + * + * The async variant is {@see PublicAdvertisedPrefixesClient::patchAsync()} . + * + * @param PatchPublicAdvertisedPrefixeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchPublicAdvertisedPrefixeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/PublicDelegatedPrefixesClient.php b/Compute/src/V1/Client/PublicDelegatedPrefixesClient.php index 3e7ec186d521..596057b43a55 100644 --- a/Compute/src/V1/Client/PublicDelegatedPrefixesClient.php +++ b/Compute/src/V1/Client/PublicDelegatedPrefixesClient.php @@ -24,17 +24,361 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\PublicDelegatedPrefixesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListPublicDelegatedPrefixesRequest; +use Google\Cloud\Compute\V1\DeletePublicDelegatedPrefixeRequest; +use Google\Cloud\Compute\V1\GetPublicDelegatedPrefixeRequest; +use Google\Cloud\Compute\V1\InsertPublicDelegatedPrefixeRequest; +use Google\Cloud\Compute\V1\ListPublicDelegatedPrefixesRequest; +use Google\Cloud\Compute\V1\PatchPublicDelegatedPrefixeRequest; +use Google\Cloud\Compute\V1\PublicDelegatedPrefix; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The PublicDelegatedPrefixes API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\PublicDelegatedPrefixesClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListPublicDelegatedPrefixesRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeletePublicDelegatedPrefixeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetPublicDelegatedPrefixeRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertPublicDelegatedPrefixeRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListPublicDelegatedPrefixesRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchPublicDelegatedPrefixeRequest $request, array $optionalArgs = []) */ -final class PublicDelegatedPrefixesClient extends PublicDelegatedPrefixesBaseClient +final class PublicDelegatedPrefixesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see PublicDelegatedPrefixesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.PublicDelegatedPrefixes'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/public_delegated_prefixes_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/public_delegated_prefixes_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/public_delegated_prefixes_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Lists all PublicDelegatedPrefix resources owned by the specific project across all scopes. + * + * The async variant is {@see PublicDelegatedPrefixesClient::aggregatedListAsync()} + * . + * + * @param AggregatedListPublicDelegatedPrefixesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListPublicDelegatedPrefixesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified PublicDelegatedPrefix in the given region. + * + * The async variant is {@see PublicDelegatedPrefixesClient::deleteAsync()} . + * + * @param DeletePublicDelegatedPrefixeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeletePublicDelegatedPrefixeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified PublicDelegatedPrefix resource in the given region. + * + * The async variant is {@see PublicDelegatedPrefixesClient::getAsync()} . + * + * @param GetPublicDelegatedPrefixeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PublicDelegatedPrefix + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetPublicDelegatedPrefixeRequest $request, array $callOptions = []): PublicDelegatedPrefix + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a PublicDelegatedPrefix in the specified project in the given region using the parameters that are included in the request. + * + * The async variant is {@see PublicDelegatedPrefixesClient::insertAsync()} . + * + * @param InsertPublicDelegatedPrefixeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertPublicDelegatedPrefixeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Lists the PublicDelegatedPrefixes for a project in the given region. + * + * The async variant is {@see PublicDelegatedPrefixesClient::listAsync()} . + * + * @param ListPublicDelegatedPrefixesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListPublicDelegatedPrefixesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Patches the specified PublicDelegatedPrefix resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + * + * The async variant is {@see PublicDelegatedPrefixesClient::patchAsync()} . + * + * @param PatchPublicDelegatedPrefixeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchPublicDelegatedPrefixeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/RegionAutoscalersClient.php b/Compute/src/V1/Client/RegionAutoscalersClient.php index 5d9694a5edb0..411f27f70a8c 100644 --- a/Compute/src/V1/Client/RegionAutoscalersClient.php +++ b/Compute/src/V1/Client/RegionAutoscalersClient.php @@ -24,17 +24,359 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionAutoscalersBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\Autoscaler; +use Google\Cloud\Compute\V1\DeleteRegionAutoscalerRequest; +use Google\Cloud\Compute\V1\GetRegionAutoscalerRequest; +use Google\Cloud\Compute\V1\InsertRegionAutoscalerRequest; +use Google\Cloud\Compute\V1\ListRegionAutoscalersRequest; +use Google\Cloud\Compute\V1\PatchRegionAutoscalerRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\UpdateRegionAutoscalerRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The RegionAutoscalers API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionAutoscalersClient} for the stable implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteRegionAutoscalerRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetRegionAutoscalerRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertRegionAutoscalerRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRegionAutoscalersRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchRegionAutoscalerRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAsync(UpdateRegionAutoscalerRequest $request, array $optionalArgs = []) */ -final class RegionAutoscalersClient extends RegionAutoscalersBaseClient +final class RegionAutoscalersClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionAutoscalersBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.RegionAutoscalers'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/region_autoscalers_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/region_autoscalers_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/region_autoscalers_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified autoscaler. + * + * The async variant is {@see RegionAutoscalersClient::deleteAsync()} . + * + * @param DeleteRegionAutoscalerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteRegionAutoscalerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified autoscaler. + * + * The async variant is {@see RegionAutoscalersClient::getAsync()} . + * + * @param GetRegionAutoscalerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Autoscaler + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRegionAutoscalerRequest $request, array $callOptions = []): Autoscaler + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates an autoscaler in the specified project using the data included in the request. + * + * The async variant is {@see RegionAutoscalersClient::insertAsync()} . + * + * @param InsertRegionAutoscalerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertRegionAutoscalerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of autoscalers contained within the specified region. + * + * The async variant is {@see RegionAutoscalersClient::listAsync()} . + * + * @param ListRegionAutoscalersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRegionAutoscalersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Updates an autoscaler in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * The async variant is {@see RegionAutoscalersClient::patchAsync()} . + * + * @param PatchRegionAutoscalerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchRegionAutoscalerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Updates an autoscaler in the specified project using the data included in the request. + * + * The async variant is {@see RegionAutoscalersClient::updateAsync()} . + * + * @param UpdateRegionAutoscalerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function update(UpdateRegionAutoscalerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Update', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/RegionBackendServicesClient.php b/Compute/src/V1/Client/RegionBackendServicesClient.php index f2df8621a608..292868785b2e 100644 --- a/Compute/src/V1/Client/RegionBackendServicesClient.php +++ b/Compute/src/V1/Client/RegionBackendServicesClient.php @@ -24,17 +24,440 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionBackendServicesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\BackendService; +use Google\Cloud\Compute\V1\BackendServiceGroupHealth; +use Google\Cloud\Compute\V1\DeleteRegionBackendServiceRequest; +use Google\Cloud\Compute\V1\GetHealthRegionBackendServiceRequest; +use Google\Cloud\Compute\V1\GetIamPolicyRegionBackendServiceRequest; +use Google\Cloud\Compute\V1\GetRegionBackendServiceRequest; +use Google\Cloud\Compute\V1\InsertRegionBackendServiceRequest; +use Google\Cloud\Compute\V1\ListRegionBackendServicesRequest; +use Google\Cloud\Compute\V1\PatchRegionBackendServiceRequest; +use Google\Cloud\Compute\V1\Policy; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\SetIamPolicyRegionBackendServiceRequest; +use Google\Cloud\Compute\V1\UpdateRegionBackendServiceRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The RegionBackendServices API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionBackendServicesClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteRegionBackendServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetRegionBackendServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getHealthAsync(GetHealthRegionBackendServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRegionBackendServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertRegionBackendServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRegionBackendServicesRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchRegionBackendServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRegionBackendServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAsync(UpdateRegionBackendServiceRequest $request, array $optionalArgs = []) */ -final class RegionBackendServicesClient extends RegionBackendServicesBaseClient +final class RegionBackendServicesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionBackendServicesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.RegionBackendServices'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/region_backend_services_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/region_backend_services_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/region_backend_services_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified regional BackendService resource. + * + * The async variant is {@see RegionBackendServicesClient::deleteAsync()} . + * + * @param DeleteRegionBackendServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteRegionBackendServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified regional BackendService resource. + * + * The async variant is {@see RegionBackendServicesClient::getAsync()} . + * + * @param GetRegionBackendServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BackendService + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRegionBackendServiceRequest $request, array $callOptions = []): BackendService + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Gets the most recent health check results for this regional BackendService. + * + * The async variant is {@see RegionBackendServicesClient::getHealthAsync()} . + * + * @param GetHealthRegionBackendServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BackendServiceGroupHealth + * + * @throws ApiException Thrown if the API call fails. + */ + public function getHealth(GetHealthRegionBackendServiceRequest $request, array $callOptions = []): BackendServiceGroupHealth + { + return $this->startApiCall('GetHealth', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * The async variant is {@see RegionBackendServicesClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRegionBackendServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRegionBackendServiceRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Creates a regional BackendService resource in the specified project using the data included in the request. For more information, see Backend services overview. + * + * The async variant is {@see RegionBackendServicesClient::insertAsync()} . + * + * @param InsertRegionBackendServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertRegionBackendServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of regional BackendService resources available to the specified project in the given region. + * + * The async variant is {@see RegionBackendServicesClient::listAsync()} . + * + * @param ListRegionBackendServicesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRegionBackendServicesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Updates the specified regional BackendService resource with the data included in the request. For more information, see Understanding backend services This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * The async variant is {@see RegionBackendServicesClient::patchAsync()} . + * + * @param PatchRegionBackendServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchRegionBackendServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * The async variant is {@see RegionBackendServicesClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRegionBackendServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRegionBackendServiceRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Updates the specified regional BackendService resource with the data included in the request. For more information, see Backend services overview . + * + * The async variant is {@see RegionBackendServicesClient::updateAsync()} . + * + * @param UpdateRegionBackendServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function update(UpdateRegionBackendServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Update', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/RegionCommitmentsClient.php b/Compute/src/V1/Client/RegionCommitmentsClient.php index 68fb902008f3..b786aaa582a5 100644 --- a/Compute/src/V1/Client/RegionCommitmentsClient.php +++ b/Compute/src/V1/Client/RegionCommitmentsClient.php @@ -24,17 +24,333 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionCommitmentsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListRegionCommitmentsRequest; +use Google\Cloud\Compute\V1\Commitment; +use Google\Cloud\Compute\V1\GetRegionCommitmentRequest; +use Google\Cloud\Compute\V1\InsertRegionCommitmentRequest; +use Google\Cloud\Compute\V1\ListRegionCommitmentsRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\UpdateRegionCommitmentRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The RegionCommitments API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionCommitmentsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListRegionCommitmentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetRegionCommitmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertRegionCommitmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRegionCommitmentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAsync(UpdateRegionCommitmentRequest $request, array $optionalArgs = []) */ -final class RegionCommitmentsClient extends RegionCommitmentsBaseClient +final class RegionCommitmentsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionCommitmentsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.RegionCommitments'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/region_commitments_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/region_commitments_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/region_commitments_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves an aggregated list of commitments by region. + * + * The async variant is {@see RegionCommitmentsClient::aggregatedListAsync()} . + * + * @param AggregatedListRegionCommitmentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListRegionCommitmentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Returns the specified commitment resource. + * + * The async variant is {@see RegionCommitmentsClient::getAsync()} . + * + * @param GetRegionCommitmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Commitment + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRegionCommitmentRequest $request, array $callOptions = []): Commitment + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a commitment in the specified project using the data included in the request. + * + * The async variant is {@see RegionCommitmentsClient::insertAsync()} . + * + * @param InsertRegionCommitmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertRegionCommitmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of commitments contained within the specified region. + * + * The async variant is {@see RegionCommitmentsClient::listAsync()} . + * + * @param ListRegionCommitmentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRegionCommitmentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Updates the specified commitment with the data included in the request. Update is performed only on selected fields included as part of update-mask. Only the following fields can be modified: auto_renew. + * + * The async variant is {@see RegionCommitmentsClient::updateAsync()} . + * + * @param UpdateRegionCommitmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function update(UpdateRegionCommitmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Update', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/RegionDiskTypesClient.php b/Compute/src/V1/Client/RegionDiskTypesClient.php index e6552102c889..67e92910ee0f 100644 --- a/Compute/src/V1/Client/RegionDiskTypesClient.php +++ b/Compute/src/V1/Client/RegionDiskTypesClient.php @@ -24,17 +24,202 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionDiskTypesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DiskType; +use Google\Cloud\Compute\V1\GetRegionDiskTypeRequest; +use Google\Cloud\Compute\V1\ListRegionDiskTypesRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The RegionDiskTypes API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionDiskTypesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface getAsync(GetRegionDiskTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRegionDiskTypesRequest $request, array $optionalArgs = []) */ -final class RegionDiskTypesClient extends RegionDiskTypesBaseClient +final class RegionDiskTypesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionDiskTypesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.RegionDiskTypes'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute.readonly', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/region_disk_types_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/region_disk_types_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/region_disk_types_rest_client_config.php', + ], + ], + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Returns the specified regional disk type. + * + * The async variant is {@see RegionDiskTypesClient::getAsync()} . + * + * @param GetRegionDiskTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DiskType + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRegionDiskTypeRequest $request, array $callOptions = []): DiskType + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of regional disk types available to the specified project. + * + * The async variant is {@see RegionDiskTypesClient::listAsync()} . + * + * @param ListRegionDiskTypesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRegionDiskTypesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } } diff --git a/Compute/src/V1/Client/RegionDisksClient.php b/Compute/src/V1/Client/RegionDisksClient.php index ece5abfe3863..e8eedabdc6aa 100644 --- a/Compute/src/V1/Client/RegionDisksClient.php +++ b/Compute/src/V1/Client/RegionDisksClient.php @@ -24,17 +24,648 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionDisksBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AddResourcePoliciesRegionDiskRequest; +use Google\Cloud\Compute\V1\BulkInsertRegionDiskRequest; +use Google\Cloud\Compute\V1\CreateSnapshotRegionDiskRequest; +use Google\Cloud\Compute\V1\DeleteRegionDiskRequest; +use Google\Cloud\Compute\V1\Disk; +use Google\Cloud\Compute\V1\GetIamPolicyRegionDiskRequest; +use Google\Cloud\Compute\V1\GetRegionDiskRequest; +use Google\Cloud\Compute\V1\InsertRegionDiskRequest; +use Google\Cloud\Compute\V1\ListRegionDisksRequest; +use Google\Cloud\Compute\V1\Policy; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\RemoveResourcePoliciesRegionDiskRequest; +use Google\Cloud\Compute\V1\ResizeRegionDiskRequest; +use Google\Cloud\Compute\V1\SetIamPolicyRegionDiskRequest; +use Google\Cloud\Compute\V1\SetLabelsRegionDiskRequest; +use Google\Cloud\Compute\V1\StartAsyncReplicationRegionDiskRequest; +use Google\Cloud\Compute\V1\StopAsyncReplicationRegionDiskRequest; +use Google\Cloud\Compute\V1\StopGroupAsyncReplicationRegionDiskRequest; +use Google\Cloud\Compute\V1\TestIamPermissionsRegionDiskRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use Google\Cloud\Compute\V1\UpdateRegionDiskRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The RegionDisks API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionDisksClient} for the stable implementation * * @experimental + * + * @method PromiseInterface addResourcePoliciesAsync(AddResourcePoliciesRegionDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface bulkInsertAsync(BulkInsertRegionDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSnapshotAsync(CreateSnapshotRegionDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteRegionDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetRegionDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRegionDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertRegionDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRegionDisksRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeResourcePoliciesAsync(RemoveResourcePoliciesRegionDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface resizeAsync(ResizeRegionDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRegionDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface setLabelsAsync(SetLabelsRegionDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface startAsyncReplicationAsync(StartAsyncReplicationRegionDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface stopAsyncReplicationAsync(StopAsyncReplicationRegionDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface stopGroupAsyncReplicationAsync(StopGroupAsyncReplicationRegionDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRegionDiskRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAsync(UpdateRegionDiskRequest $request, array $optionalArgs = []) */ -final class RegionDisksClient extends RegionDisksBaseClient +final class RegionDisksClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionDisksBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.RegionDisks'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/region_disks_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/region_disks_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/region_disks_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Adds existing resource policies to a regional disk. You can only add one policy which will be applied to this disk for scheduling snapshot creation. + * + * The async variant is {@see RegionDisksClient::addResourcePoliciesAsync()} . + * + * @param AddResourcePoliciesRegionDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addResourcePolicies(AddResourcePoliciesRegionDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddResourcePolicies', $request, $callOptions)->wait(); + } + + /** + * Bulk create a set of disks. + * + * The async variant is {@see RegionDisksClient::bulkInsertAsync()} . + * + * @param BulkInsertRegionDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function bulkInsert(BulkInsertRegionDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BulkInsert', $request, $callOptions)->wait(); + } + + /** + * Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider using snapshots.insert instead, as that method supports more features, such as creating snapshots in a project different from the source disk project. + * + * The async variant is {@see RegionDisksClient::createSnapshotAsync()} . + * + * @param CreateSnapshotRegionDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSnapshot(CreateSnapshotRegionDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateSnapshot', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified regional persistent disk. Deleting a regional disk removes all the replicas of its data permanently and is irreversible. However, deleting a disk does not delete any snapshots previously made from the disk. You must separately delete snapshots. + * + * The async variant is {@see RegionDisksClient::deleteAsync()} . + * + * @param DeleteRegionDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteRegionDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns a specified regional persistent disk. + * + * The async variant is {@see RegionDisksClient::getAsync()} . + * + * @param GetRegionDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Disk + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRegionDiskRequest $request, array $callOptions = []): Disk + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * The async variant is {@see RegionDisksClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRegionDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRegionDiskRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Creates a persistent regional disk in the specified project using the data included in the request. + * + * The async variant is {@see RegionDisksClient::insertAsync()} . + * + * @param InsertRegionDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertRegionDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of persistent disks contained within the specified region. + * + * The async variant is {@see RegionDisksClient::listAsync()} . + * + * @param ListRegionDisksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRegionDisksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Removes resource policies from a regional disk. + * + * The async variant is {@see RegionDisksClient::removeResourcePoliciesAsync()} . + * + * @param RemoveResourcePoliciesRegionDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeResourcePolicies(RemoveResourcePoliciesRegionDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RemoveResourcePolicies', $request, $callOptions)->wait(); + } + + /** + * Resizes the specified regional persistent disk. + * + * The async variant is {@see RegionDisksClient::resizeAsync()} . + * + * @param ResizeRegionDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function resize(ResizeRegionDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Resize', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * The async variant is {@see RegionDisksClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRegionDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRegionDiskRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the labels on the target regional disk. + * + * The async variant is {@see RegionDisksClient::setLabelsAsync()} . + * + * @param SetLabelsRegionDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setLabels(SetLabelsRegionDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); + } + + /** + * Starts asynchronous replication. Must be invoked on the primary disk. + * + * The async variant is {@see RegionDisksClient::startAsyncReplicationAsync()} . + * + * @param StartAsyncReplicationRegionDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function startAsyncReplication(StartAsyncReplicationRegionDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StartAsyncReplication', $request, $callOptions)->wait(); + } + + /** + * Stops asynchronous replication. Can be invoked either on the primary or on the secondary disk. + * + * The async variant is {@see RegionDisksClient::stopAsyncReplicationAsync()} . + * + * @param StopAsyncReplicationRegionDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function stopAsyncReplication(StopAsyncReplicationRegionDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StopAsyncReplication', $request, $callOptions)->wait(); + } + + /** + * Stops asynchronous replication for a consistency group of disks. Can be invoked either in the primary or secondary scope. + * + * The async variant is {@see RegionDisksClient::stopGroupAsyncReplicationAsync()} + * . + * + * @param StopGroupAsyncReplicationRegionDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function stopGroupAsyncReplication(StopGroupAsyncReplicationRegionDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StopGroupAsyncReplication', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. + * + * The async variant is {@see RegionDisksClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRegionDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRegionDiskRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Update the specified disk with the data included in the request. Update is performed only on selected fields included as part of update-mask. Only the following fields can be modified: user_license. + * + * The async variant is {@see RegionDisksClient::updateAsync()} . + * + * @param UpdateRegionDiskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function update(UpdateRegionDiskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Update', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/RegionHealthCheckServicesClient.php b/Compute/src/V1/Client/RegionHealthCheckServicesClient.php index 35ece0176622..baf6254e3299 100644 --- a/Compute/src/V1/Client/RegionHealthCheckServicesClient.php +++ b/Compute/src/V1/Client/RegionHealthCheckServicesClient.php @@ -24,17 +24,334 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionHealthCheckServicesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteRegionHealthCheckServiceRequest; +use Google\Cloud\Compute\V1\GetRegionHealthCheckServiceRequest; +use Google\Cloud\Compute\V1\HealthCheckService; +use Google\Cloud\Compute\V1\InsertRegionHealthCheckServiceRequest; +use Google\Cloud\Compute\V1\ListRegionHealthCheckServicesRequest; +use Google\Cloud\Compute\V1\PatchRegionHealthCheckServiceRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The RegionHealthCheckServices API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionHealthCheckServicesClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteRegionHealthCheckServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetRegionHealthCheckServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertRegionHealthCheckServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRegionHealthCheckServicesRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchRegionHealthCheckServiceRequest $request, array $optionalArgs = []) */ -final class RegionHealthCheckServicesClient extends RegionHealthCheckServicesBaseClient +final class RegionHealthCheckServicesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionHealthCheckServicesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.RegionHealthCheckServices'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/region_health_check_services_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/region_health_check_services_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/region_health_check_services_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified regional HealthCheckService. + * + * The async variant is {@see RegionHealthCheckServicesClient::deleteAsync()} . + * + * @param DeleteRegionHealthCheckServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteRegionHealthCheckServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified regional HealthCheckService resource. + * + * The async variant is {@see RegionHealthCheckServicesClient::getAsync()} . + * + * @param GetRegionHealthCheckServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 HealthCheckService + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRegionHealthCheckServiceRequest $request, array $callOptions = []): HealthCheckService + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a regional HealthCheckService resource in the specified project and region using the data included in the request. + * + * The async variant is {@see RegionHealthCheckServicesClient::insertAsync()} . + * + * @param InsertRegionHealthCheckServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertRegionHealthCheckServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Lists all the HealthCheckService resources that have been configured for the specified project in the given region. + * + * The async variant is {@see RegionHealthCheckServicesClient::listAsync()} . + * + * @param ListRegionHealthCheckServicesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRegionHealthCheckServicesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Updates the specified regional HealthCheckService resource with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * The async variant is {@see RegionHealthCheckServicesClient::patchAsync()} . + * + * @param PatchRegionHealthCheckServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchRegionHealthCheckServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/RegionHealthChecksClient.php b/Compute/src/V1/Client/RegionHealthChecksClient.php index 1bf2faa7589d..998ae69cab37 100644 --- a/Compute/src/V1/Client/RegionHealthChecksClient.php +++ b/Compute/src/V1/Client/RegionHealthChecksClient.php @@ -24,17 +24,359 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionHealthChecksBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteRegionHealthCheckRequest; +use Google\Cloud\Compute\V1\GetRegionHealthCheckRequest; +use Google\Cloud\Compute\V1\HealthCheck; +use Google\Cloud\Compute\V1\InsertRegionHealthCheckRequest; +use Google\Cloud\Compute\V1\ListRegionHealthChecksRequest; +use Google\Cloud\Compute\V1\PatchRegionHealthCheckRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\UpdateRegionHealthCheckRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The RegionHealthChecks API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionHealthChecksClient} for the stable implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteRegionHealthCheckRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetRegionHealthCheckRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertRegionHealthCheckRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRegionHealthChecksRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchRegionHealthCheckRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAsync(UpdateRegionHealthCheckRequest $request, array $optionalArgs = []) */ -final class RegionHealthChecksClient extends RegionHealthChecksBaseClient +final class RegionHealthChecksClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionHealthChecksBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.RegionHealthChecks'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/region_health_checks_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/region_health_checks_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/region_health_checks_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified HealthCheck resource. + * + * The async variant is {@see RegionHealthChecksClient::deleteAsync()} . + * + * @param DeleteRegionHealthCheckRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteRegionHealthCheckRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified HealthCheck resource. + * + * The async variant is {@see RegionHealthChecksClient::getAsync()} . + * + * @param GetRegionHealthCheckRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 HealthCheck + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRegionHealthCheckRequest $request, array $callOptions = []): HealthCheck + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a HealthCheck resource in the specified project using the data included in the request. + * + * The async variant is {@see RegionHealthChecksClient::insertAsync()} . + * + * @param InsertRegionHealthCheckRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertRegionHealthCheckRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of HealthCheck resources available to the specified project. + * + * The async variant is {@see RegionHealthChecksClient::listAsync()} . + * + * @param ListRegionHealthChecksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRegionHealthChecksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Updates a HealthCheck resource in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * The async variant is {@see RegionHealthChecksClient::patchAsync()} . + * + * @param PatchRegionHealthCheckRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchRegionHealthCheckRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Updates a HealthCheck resource in the specified project using the data included in the request. + * + * The async variant is {@see RegionHealthChecksClient::updateAsync()} . + * + * @param UpdateRegionHealthCheckRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function update(UpdateRegionHealthCheckRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Update', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/RegionInstanceGroupManagersClient.php b/Compute/src/V1/Client/RegionInstanceGroupManagersClient.php index 74d3542bbfd2..b7c5ae0058eb 100644 --- a/Compute/src/V1/Client/RegionInstanceGroupManagersClient.php +++ b/Compute/src/V1/Client/RegionInstanceGroupManagersClient.php @@ -24,17 +24,711 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionInstanceGroupManagersBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AbandonInstancesRegionInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\CreateInstancesRegionInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\DeleteInstancesRegionInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\DeletePerInstanceConfigsRegionInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\DeleteRegionInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\GetRegionInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\InsertRegionInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\InstanceGroupManager; +use Google\Cloud\Compute\V1\ListErrorsRegionInstanceGroupManagersRequest; +use Google\Cloud\Compute\V1\ListManagedInstancesRegionInstanceGroupManagersRequest; +use Google\Cloud\Compute\V1\ListPerInstanceConfigsRegionInstanceGroupManagersRequest; +use Google\Cloud\Compute\V1\ListRegionInstanceGroupManagersRequest; +use Google\Cloud\Compute\V1\PatchPerInstanceConfigsRegionInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\PatchRegionInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\RecreateInstancesRegionInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\ResizeRegionInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\SetInstanceTemplateRegionInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\SetTargetPoolsRegionInstanceGroupManagerRequest; +use Google\Cloud\Compute\V1\UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The RegionInstanceGroupManagers API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionInstanceGroupManagersClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface abandonInstancesAsync(AbandonInstancesRegionInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface applyUpdatesToInstancesAsync(ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface createInstancesAsync(CreateInstancesRegionInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteRegionInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteInstancesAsync(DeleteInstancesRegionInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface deletePerInstanceConfigsAsync(DeletePerInstanceConfigsRegionInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetRegionInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertRegionInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRegionInstanceGroupManagersRequest $request, array $optionalArgs = []) + * @method PromiseInterface listErrorsAsync(ListErrorsRegionInstanceGroupManagersRequest $request, array $optionalArgs = []) + * @method PromiseInterface listManagedInstancesAsync(ListManagedInstancesRegionInstanceGroupManagersRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPerInstanceConfigsAsync(ListPerInstanceConfigsRegionInstanceGroupManagersRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchRegionInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchPerInstanceConfigsAsync(PatchPerInstanceConfigsRegionInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface recreateInstancesAsync(RecreateInstancesRegionInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface resizeAsync(ResizeRegionInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface setInstanceTemplateAsync(SetInstanceTemplateRegionInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface setTargetPoolsAsync(SetTargetPoolsRegionInstanceGroupManagerRequest $request, array $optionalArgs = []) + * @method PromiseInterface updatePerInstanceConfigsAsync(UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest $request, array $optionalArgs = []) */ -final class RegionInstanceGroupManagersClient extends RegionInstanceGroupManagersBaseClient +final class RegionInstanceGroupManagersClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionInstanceGroupManagersBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.RegionInstanceGroupManagers'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/region_instance_group_managers_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/region_instance_group_managers_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/region_instance_group_managers_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Flags the specified instances to be immediately removed from the managed instance group. Abandoning an instance does not delete the instance, but it does remove the instance from any target pools that are applied by the managed instance group. This method reduces the targetSize of the managed instance group by the number of instances that you abandon. This operation is marked as DONE when the action is scheduled even if the instances have not yet been removed from the group. You must separately verify the status of the abandoning action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. + * + * The async variant is + * {@see RegionInstanceGroupManagersClient::abandonInstancesAsync()} . + * + * @param AbandonInstancesRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function abandonInstances(AbandonInstancesRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AbandonInstances', $request, $callOptions)->wait(); + } + + /** + * Apply updates to selected instances the managed instance group. + * + * The async variant is + * {@see RegionInstanceGroupManagersClient::applyUpdatesToInstancesAsync()} . + * + * @param ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function applyUpdatesToInstances(ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ApplyUpdatesToInstances', $request, $callOptions)->wait(); + } + + /** + * Creates instances with per-instance configurations in this regional managed instance group. Instances are created using the current instance template. The create instances operation is marked DONE if the createInstances request is successful. The underlying actions take additional time. You must separately verify the status of the creating or actions with the listmanagedinstances method. + * + * The async variant is + * {@see RegionInstanceGroupManagersClient::createInstancesAsync()} . + * + * @param CreateInstancesRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createInstances(CreateInstancesRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateInstances', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified managed instance group and all of the instances in that group. + * + * The async variant is {@see RegionInstanceGroupManagersClient::deleteAsync()} . + * + * @param DeleteRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Flags the specified instances in the managed instance group to be immediately deleted. The instances are also removed from any target pools of which they were a member. This method reduces the targetSize of the managed instance group by the number of instances that you delete. The deleteInstances operation is marked DONE if the deleteInstances request is successful. The underlying actions take additional time. You must separately verify the status of the deleting action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. + * + * The async variant is + * {@see RegionInstanceGroupManagersClient::deleteInstancesAsync()} . + * + * @param DeleteInstancesRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteInstances(DeleteInstancesRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteInstances', $request, $callOptions)->wait(); + } + + /** + * Deletes selected per-instance configurations for the managed instance group. + * + * The async variant is + * {@see RegionInstanceGroupManagersClient::deletePerInstanceConfigsAsync()} . + * + * @param DeletePerInstanceConfigsRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deletePerInstanceConfigs(DeletePerInstanceConfigsRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeletePerInstanceConfigs', $request, $callOptions)->wait(); + } + + /** + * Returns all of the details about the specified managed instance group. + * + * The async variant is {@see RegionInstanceGroupManagersClient::getAsync()} . + * + * @param GetRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InstanceGroupManager + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRegionInstanceGroupManagerRequest $request, array $callOptions = []): InstanceGroupManager + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a managed instance group using the information that you specify in the request. After the group is created, instances in the group are created using the specified instance template. This operation is marked as DONE when the group is created even if the instances in the group have not yet been created. You must separately verify the status of the individual instances with the listmanagedinstances method. A regional managed instance group can contain up to 2000 instances. + * + * The async variant is {@see RegionInstanceGroupManagersClient::insertAsync()} . + * + * @param InsertRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of managed instance groups that are contained within the specified region. + * + * The async variant is {@see RegionInstanceGroupManagersClient::listAsync()} . + * + * @param ListRegionInstanceGroupManagersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRegionInstanceGroupManagersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Lists all errors thrown by actions on instances for a given regional managed instance group. The filter and orderBy query parameters are not supported. + * + * The async variant is {@see RegionInstanceGroupManagersClient::listErrorsAsync()} + * . + * + * @param ListErrorsRegionInstanceGroupManagersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listErrors(ListErrorsRegionInstanceGroupManagersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListErrors', $request, $callOptions); + } + + /** + * Lists the instances in the managed instance group and instances that are scheduled to be created. The list includes any current actions that the group has scheduled for its instances. The orderBy query parameter is not supported. The `pageToken` query parameter is supported only in the alpha and beta API and only if the group's `listManagedInstancesResults` field is set to `PAGINATED`. + * + * The async variant is + * {@see RegionInstanceGroupManagersClient::listManagedInstancesAsync()} . + * + * @param ListManagedInstancesRegionInstanceGroupManagersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listManagedInstances(ListManagedInstancesRegionInstanceGroupManagersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListManagedInstances', $request, $callOptions); + } + + /** + * Lists all of the per-instance configurations defined for the managed instance group. The orderBy query parameter is not supported. + * + * The async variant is + * {@see RegionInstanceGroupManagersClient::listPerInstanceConfigsAsync()} . + * + * @param ListPerInstanceConfigsRegionInstanceGroupManagersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPerInstanceConfigs(ListPerInstanceConfigsRegionInstanceGroupManagersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPerInstanceConfigs', $request, $callOptions); + } + + /** + * Updates a managed instance group using the information that you specify in the request. This operation is marked as DONE when the group is patched even if the instances in the group are still in the process of being patched. You must separately verify the status of the individual instances with the listmanagedinstances method. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. If you update your group to specify a new template or instance configuration, it's possible that your intended specification for each VM in the group is different from the current state of that VM. To learn how to apply an updated configuration to the VMs in a MIG, see Updating instances in a MIG. + * + * The async variant is {@see RegionInstanceGroupManagersClient::patchAsync()} . + * + * @param PatchRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Inserts or patches per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch. + * + * The async variant is + * {@see RegionInstanceGroupManagersClient::patchPerInstanceConfigsAsync()} . + * + * @param PatchPerInstanceConfigsRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patchPerInstanceConfigs(PatchPerInstanceConfigsRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('PatchPerInstanceConfigs', $request, $callOptions)->wait(); + } + + /** + * Flags the specified VM instances in the managed instance group to be immediately recreated. Each instance is recreated using the group's current configuration. This operation is marked as DONE when the flag is set even if the instances have not yet been recreated. You must separately verify the status of each instance by checking its currentAction field; for more information, see Checking the status of managed instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request. + * + * The async variant is + * {@see RegionInstanceGroupManagersClient::recreateInstancesAsync()} . + * + * @param RecreateInstancesRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function recreateInstances(RecreateInstancesRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RecreateInstances', $request, $callOptions)->wait(); + } + + /** + * Changes the intended size of the managed instance group. If you increase the size, the group creates new instances using the current instance template. If you decrease the size, the group deletes one or more instances. The resize operation is marked DONE if the resize request is successful. The underlying actions take additional time. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. + * + * The async variant is {@see RegionInstanceGroupManagersClient::resizeAsync()} . + * + * @param ResizeRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function resize(ResizeRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Resize', $request, $callOptions)->wait(); + } + + /** + * Sets the instance template to use when creating new instances or recreating instances in this group. Existing instances are not affected. + * + * The async variant is + * {@see RegionInstanceGroupManagersClient::setInstanceTemplateAsync()} . + * + * @param SetInstanceTemplateRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setInstanceTemplate(SetInstanceTemplateRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetInstanceTemplate', $request, $callOptions)->wait(); + } + + /** + * Modifies the target pools to which all new instances in this group are assigned. Existing instances in the group are not affected. + * + * The async variant is + * {@see RegionInstanceGroupManagersClient::setTargetPoolsAsync()} . + * + * @param SetTargetPoolsRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setTargetPools(SetTargetPoolsRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetTargetPools', $request, $callOptions)->wait(); + } + + /** + * Inserts or updates per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch. + * + * The async variant is + * {@see RegionInstanceGroupManagersClient::updatePerInstanceConfigsAsync()} . + * + * @param UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updatePerInstanceConfigs(UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdatePerInstanceConfigs', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/RegionInstanceGroupsClient.php b/Compute/src/V1/Client/RegionInstanceGroupsClient.php index 510b76c8b86f..759fdad823a0 100644 --- a/Compute/src/V1/Client/RegionInstanceGroupsClient.php +++ b/Compute/src/V1/Client/RegionInstanceGroupsClient.php @@ -24,17 +24,308 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionInstanceGroupsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\GetRegionInstanceGroupRequest; +use Google\Cloud\Compute\V1\InstanceGroup; +use Google\Cloud\Compute\V1\ListInstancesRegionInstanceGroupsRequest; +use Google\Cloud\Compute\V1\ListRegionInstanceGroupsRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\SetNamedPortsRegionInstanceGroupRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The RegionInstanceGroups API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionInstanceGroupsClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface getAsync(GetRegionInstanceGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRegionInstanceGroupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInstancesAsync(ListInstancesRegionInstanceGroupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface setNamedPortsAsync(SetNamedPortsRegionInstanceGroupRequest $request, array $optionalArgs = []) */ -final class RegionInstanceGroupsClient extends RegionInstanceGroupsBaseClient +final class RegionInstanceGroupsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionInstanceGroupsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.RegionInstanceGroups'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/region_instance_groups_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/region_instance_groups_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/region_instance_groups_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Returns the specified instance group resource. + * + * The async variant is {@see RegionInstanceGroupsClient::getAsync()} . + * + * @param GetRegionInstanceGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InstanceGroup + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRegionInstanceGroupRequest $request, array $callOptions = []): InstanceGroup + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of instance group resources contained within the specified region. + * + * The async variant is {@see RegionInstanceGroupsClient::listAsync()} . + * + * @param ListRegionInstanceGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRegionInstanceGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Lists the instances in the specified instance group and displays information about the named ports. Depending on the specified options, this method can list all instances or only the instances that are running. The orderBy query parameter is not supported. + * + * The async variant is {@see RegionInstanceGroupsClient::listInstancesAsync()} . + * + * @param ListInstancesRegionInstanceGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInstances(ListInstancesRegionInstanceGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInstances', $request, $callOptions); + } + + /** + * Sets the named ports for the specified regional instance group. + * + * The async variant is {@see RegionInstanceGroupsClient::setNamedPortsAsync()} . + * + * @param SetNamedPortsRegionInstanceGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setNamedPorts(SetNamedPortsRegionInstanceGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetNamedPorts', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/RegionInstanceTemplatesClient.php b/Compute/src/V1/Client/RegionInstanceTemplatesClient.php index e8a8745f77ed..c30725b3127f 100644 --- a/Compute/src/V1/Client/RegionInstanceTemplatesClient.php +++ b/Compute/src/V1/Client/RegionInstanceTemplatesClient.php @@ -24,17 +24,308 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionInstanceTemplatesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteRegionInstanceTemplateRequest; +use Google\Cloud\Compute\V1\GetRegionInstanceTemplateRequest; +use Google\Cloud\Compute\V1\InsertRegionInstanceTemplateRequest; +use Google\Cloud\Compute\V1\InstanceTemplate; +use Google\Cloud\Compute\V1\ListRegionInstanceTemplatesRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The RegionInstanceTemplates API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionInstanceTemplatesClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteRegionInstanceTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetRegionInstanceTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertRegionInstanceTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRegionInstanceTemplatesRequest $request, array $optionalArgs = []) */ -final class RegionInstanceTemplatesClient extends RegionInstanceTemplatesBaseClient +final class RegionInstanceTemplatesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionInstanceTemplatesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.RegionInstanceTemplates'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/region_instance_templates_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/region_instance_templates_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/region_instance_templates_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified instance template. Deleting an instance template is permanent and cannot be undone. + * + * The async variant is {@see RegionInstanceTemplatesClient::deleteAsync()} . + * + * @param DeleteRegionInstanceTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteRegionInstanceTemplateRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified instance template. + * + * The async variant is {@see RegionInstanceTemplatesClient::getAsync()} . + * + * @param GetRegionInstanceTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InstanceTemplate + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRegionInstanceTemplateRequest $request, array $callOptions = []): InstanceTemplate + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates an instance template in the specified project and region using the global instance template whose URL is included in the request. + * + * The async variant is {@see RegionInstanceTemplatesClient::insertAsync()} . + * + * @param InsertRegionInstanceTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertRegionInstanceTemplateRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of instance templates that are contained within the specified project and region. + * + * The async variant is {@see RegionInstanceTemplatesClient::listAsync()} . + * + * @param ListRegionInstanceTemplatesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRegionInstanceTemplatesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } } diff --git a/Compute/src/V1/Client/RegionInstancesClient.php b/Compute/src/V1/Client/RegionInstancesClient.php index cb184331db5a..aff49b56de26 100644 --- a/Compute/src/V1/Client/RegionInstancesClient.php +++ b/Compute/src/V1/Client/RegionInstancesClient.php @@ -24,17 +24,227 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionInstancesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\BulkInsertRegionInstanceRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The RegionInstances API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionInstancesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface bulkInsertAsync(BulkInsertRegionInstanceRequest $request, array $optionalArgs = []) */ -final class RegionInstancesClient extends RegionInstancesBaseClient +final class RegionInstancesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionInstancesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.RegionInstances'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/region_instances_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/region_instances_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/region_instances_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates multiple instances in a given region. Count specifies the number of instances to create. + * + * The async variant is {@see RegionInstancesClient::bulkInsertAsync()} . + * + * @param BulkInsertRegionInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function bulkInsert(BulkInsertRegionInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BulkInsert', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/RegionNetworkEndpointGroupsClient.php b/Compute/src/V1/Client/RegionNetworkEndpointGroupsClient.php index 2fe14a862343..5b860ddd46ef 100644 --- a/Compute/src/V1/Client/RegionNetworkEndpointGroupsClient.php +++ b/Compute/src/V1/Client/RegionNetworkEndpointGroupsClient.php @@ -24,17 +24,308 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionNetworkEndpointGroupsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteRegionNetworkEndpointGroupRequest; +use Google\Cloud\Compute\V1\GetRegionNetworkEndpointGroupRequest; +use Google\Cloud\Compute\V1\InsertRegionNetworkEndpointGroupRequest; +use Google\Cloud\Compute\V1\ListRegionNetworkEndpointGroupsRequest; +use Google\Cloud\Compute\V1\NetworkEndpointGroup; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The RegionNetworkEndpointGroups API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionNetworkEndpointGroupsClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteRegionNetworkEndpointGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetRegionNetworkEndpointGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertRegionNetworkEndpointGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRegionNetworkEndpointGroupsRequest $request, array $optionalArgs = []) */ -final class RegionNetworkEndpointGroupsClient extends RegionNetworkEndpointGroupsBaseClient +final class RegionNetworkEndpointGroupsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionNetworkEndpointGroupsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.RegionNetworkEndpointGroups'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/region_network_endpoint_groups_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/region_network_endpoint_groups_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/region_network_endpoint_groups_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified network endpoint group. Note that the NEG cannot be deleted if it is configured as a backend of a backend service. + * + * The async variant is {@see RegionNetworkEndpointGroupsClient::deleteAsync()} . + * + * @param DeleteRegionNetworkEndpointGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteRegionNetworkEndpointGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified network endpoint group. + * + * The async variant is {@see RegionNetworkEndpointGroupsClient::getAsync()} . + * + * @param GetRegionNetworkEndpointGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NetworkEndpointGroup + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRegionNetworkEndpointGroupRequest $request, array $callOptions = []): NetworkEndpointGroup + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a network endpoint group in the specified project using the parameters that are included in the request. + * + * The async variant is {@see RegionNetworkEndpointGroupsClient::insertAsync()} . + * + * @param InsertRegionNetworkEndpointGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertRegionNetworkEndpointGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of regional network endpoint groups available to the specified project in the given region. + * + * The async variant is {@see RegionNetworkEndpointGroupsClient::listAsync()} . + * + * @param ListRegionNetworkEndpointGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRegionNetworkEndpointGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } } diff --git a/Compute/src/V1/Client/RegionNetworkFirewallPoliciesClient.php b/Compute/src/V1/Client/RegionNetworkFirewallPoliciesClient.php index f55e34e4b7e9..570a670c41fd 100644 --- a/Compute/src/V1/Client/RegionNetworkFirewallPoliciesClient.php +++ b/Compute/src/V1/Client/RegionNetworkFirewallPoliciesClient.php @@ -24,17 +24,663 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionNetworkFirewallPoliciesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AddAssociationRegionNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\AddRuleRegionNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\CloneRulesRegionNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\DeleteRegionNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\FirewallPolicy; +use Google\Cloud\Compute\V1\FirewallPolicyAssociation; +use Google\Cloud\Compute\V1\FirewallPolicyRule; +use Google\Cloud\Compute\V1\GetAssociationRegionNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\GetIamPolicyRegionNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\GetRegionNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\GetRuleRegionNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\InsertRegionNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\ListRegionNetworkFirewallPoliciesRequest; +use Google\Cloud\Compute\V1\PatchRegionNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\PatchRuleRegionNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\Policy; +use Google\Cloud\Compute\V1\RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\RemoveAssociationRegionNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\RemoveRuleRegionNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\SetIamPolicyRegionNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\TestIamPermissionsRegionNetworkFirewallPolicyRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The RegionNetworkFirewallPolicies API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionNetworkFirewallPoliciesClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface addAssociationAsync(AddAssociationRegionNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface addRuleAsync(AddRuleRegionNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface cloneRulesAsync(CloneRulesRegionNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteRegionNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetRegionNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAssociationAsync(GetAssociationRegionNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEffectiveFirewallsAsync(GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRegionNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRuleAsync(GetRuleRegionNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertRegionNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRegionNetworkFirewallPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchRegionNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchRuleAsync(PatchRuleRegionNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeAssociationAsync(RemoveAssociationRegionNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeRuleAsync(RemoveRuleRegionNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRegionNetworkFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRegionNetworkFirewallPolicyRequest $request, array $optionalArgs = []) */ -final class RegionNetworkFirewallPoliciesClient extends RegionNetworkFirewallPoliciesBaseClient +final class RegionNetworkFirewallPoliciesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionNetworkFirewallPoliciesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.RegionNetworkFirewallPolicies'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/region_network_firewall_policies_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/region_network_firewall_policies_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/region_network_firewall_policies_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Inserts an association for the specified network firewall policy. + * + * The async variant is + * {@see RegionNetworkFirewallPoliciesClient::addAssociationAsync()} . + * + * @param AddAssociationRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addAssociation(AddAssociationRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddAssociation', $request, $callOptions)->wait(); + } + + /** + * Inserts a rule into a network firewall policy. + * + * The async variant is {@see RegionNetworkFirewallPoliciesClient::addRuleAsync()} + * . + * + * @param AddRuleRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addRule(AddRuleRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddRule', $request, $callOptions)->wait(); + } + + /** + * Copies rules to the specified network firewall policy. + * + * The async variant is + * {@see RegionNetworkFirewallPoliciesClient::cloneRulesAsync()} . + * + * @param CloneRulesRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function cloneRules(CloneRulesRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CloneRules', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified network firewall policy. + * + * The async variant is {@see RegionNetworkFirewallPoliciesClient::deleteAsync()} . + * + * @param DeleteRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified network firewall policy. + * + * The async variant is {@see RegionNetworkFirewallPoliciesClient::getAsync()} . + * + * @param GetRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FirewallPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicy + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Gets an association with the specified name. + * + * The async variant is + * {@see RegionNetworkFirewallPoliciesClient::getAssociationAsync()} . + * + * @param GetAssociationRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FirewallPolicyAssociation + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAssociation(GetAssociationRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicyAssociation + { + return $this->startApiCall('GetAssociation', $request, $callOptions)->wait(); + } + + /** + * Returns the effective firewalls on a given network. + * + * The async variant is + * {@see RegionNetworkFirewallPoliciesClient::getEffectiveFirewallsAsync()} . + * + * @param GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEffectiveFirewalls(GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse + { + return $this->startApiCall('GetEffectiveFirewalls', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * The async variant is + * {@see RegionNetworkFirewallPoliciesClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets a rule of the specified priority. + * + * The async variant is {@see RegionNetworkFirewallPoliciesClient::getRuleAsync()} + * . + * + * @param GetRuleRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FirewallPolicyRule + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRule(GetRuleRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicyRule + { + return $this->startApiCall('GetRule', $request, $callOptions)->wait(); + } + + /** + * Creates a new network firewall policy in the specified project and region. + * + * The async variant is {@see RegionNetworkFirewallPoliciesClient::insertAsync()} . + * + * @param InsertRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Lists all the network firewall policies that have been configured for the specified project in the given region. + * + * The async variant is {@see RegionNetworkFirewallPoliciesClient::listAsync()} . + * + * @param ListRegionNetworkFirewallPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRegionNetworkFirewallPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Patches the specified network firewall policy. + * + * The async variant is {@see RegionNetworkFirewallPoliciesClient::patchAsync()} . + * + * @param PatchRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Patches a rule of the specified priority. + * + * The async variant is + * {@see RegionNetworkFirewallPoliciesClient::patchRuleAsync()} . + * + * @param PatchRuleRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patchRule(PatchRuleRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('PatchRule', $request, $callOptions)->wait(); + } + + /** + * Removes an association for the specified network firewall policy. + * + * The async variant is + * {@see RegionNetworkFirewallPoliciesClient::removeAssociationAsync()} . + * + * @param RemoveAssociationRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeAssociation(RemoveAssociationRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RemoveAssociation', $request, $callOptions)->wait(); + } + + /** + * Deletes a rule of the specified priority. + * + * The async variant is + * {@see RegionNetworkFirewallPoliciesClient::removeRuleAsync()} . + * + * @param RemoveRuleRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeRule(RemoveRuleRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RemoveRule', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * The async variant is + * {@see RegionNetworkFirewallPoliciesClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. + * + * The async variant is + * {@see RegionNetworkFirewallPoliciesClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRegionNetworkFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRegionNetworkFirewallPolicyRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/RegionNotificationEndpointsClient.php b/Compute/src/V1/Client/RegionNotificationEndpointsClient.php index 8cfae3f96ff4..30922113507f 100644 --- a/Compute/src/V1/Client/RegionNotificationEndpointsClient.php +++ b/Compute/src/V1/Client/RegionNotificationEndpointsClient.php @@ -24,17 +24,308 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionNotificationEndpointsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteRegionNotificationEndpointRequest; +use Google\Cloud\Compute\V1\GetRegionNotificationEndpointRequest; +use Google\Cloud\Compute\V1\InsertRegionNotificationEndpointRequest; +use Google\Cloud\Compute\V1\ListRegionNotificationEndpointsRequest; +use Google\Cloud\Compute\V1\NotificationEndpoint; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The RegionNotificationEndpoints API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionNotificationEndpointsClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteRegionNotificationEndpointRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetRegionNotificationEndpointRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertRegionNotificationEndpointRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRegionNotificationEndpointsRequest $request, array $optionalArgs = []) */ -final class RegionNotificationEndpointsClient extends RegionNotificationEndpointsBaseClient +final class RegionNotificationEndpointsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionNotificationEndpointsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.RegionNotificationEndpoints'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/region_notification_endpoints_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/region_notification_endpoints_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/region_notification_endpoints_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified NotificationEndpoint in the given region + * + * The async variant is {@see RegionNotificationEndpointsClient::deleteAsync()} . + * + * @param DeleteRegionNotificationEndpointRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteRegionNotificationEndpointRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified NotificationEndpoint resource in the given region. + * + * The async variant is {@see RegionNotificationEndpointsClient::getAsync()} . + * + * @param GetRegionNotificationEndpointRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NotificationEndpoint + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRegionNotificationEndpointRequest $request, array $callOptions = []): NotificationEndpoint + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Create a NotificationEndpoint in the specified project in the given region using the parameters that are included in the request. + * + * The async variant is {@see RegionNotificationEndpointsClient::insertAsync()} . + * + * @param InsertRegionNotificationEndpointRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertRegionNotificationEndpointRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Lists the NotificationEndpoints for a project in the given region. + * + * The async variant is {@see RegionNotificationEndpointsClient::listAsync()} . + * + * @param ListRegionNotificationEndpointsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRegionNotificationEndpointsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } } diff --git a/Compute/src/V1/Client/RegionOperationsClient.php b/Compute/src/V1/Client/RegionOperationsClient.php index 99b8d58e7ded..9fbb52d7f43a 100644 --- a/Compute/src/V1/Client/RegionOperationsClient.php +++ b/Compute/src/V1/Client/RegionOperationsClient.php @@ -24,17 +24,254 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionOperationsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteRegionOperationRequest; +use Google\Cloud\Compute\V1\DeleteRegionOperationResponse; +use Google\Cloud\Compute\V1\GetRegionOperationRequest; +use Google\Cloud\Compute\V1\ListRegionOperationsRequest; +use Google\Cloud\Compute\V1\Operation; +use Google\Cloud\Compute\V1\WaitRegionOperationRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The RegionOperations API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionOperationsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteRegionOperationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetRegionOperationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRegionOperationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface waitAsync(WaitRegionOperationRequest $request, array $optionalArgs = []) */ -final class RegionOperationsClient extends RegionOperationsBaseClient +final class RegionOperationsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionOperationsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.RegionOperations'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/region_operations_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/region_operations_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/region_operations_rest_client_config.php', + ], + ], + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified region-specific Operations resource. + * + * The async variant is {@see RegionOperationsClient::deleteAsync()} . + * + * @param DeleteRegionOperationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DeleteRegionOperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteRegionOperationRequest $request, array $callOptions = []): DeleteRegionOperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified region-specific Operations resource. + * + * The async variant is {@see RegionOperationsClient::getAsync()} . + * + * @param GetRegionOperationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRegionOperationRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of Operation resources contained within the specified region. + * + * The async variant is {@see RegionOperationsClient::listAsync()} . + * + * @param ListRegionOperationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRegionOperationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method differs from the `GET` method in that it waits for no more than the default deadline (2 minutes) and then returns the current state of the operation, which might be `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`. + * + * The async variant is {@see RegionOperationsClient::waitAsync()} . + * + * @param WaitRegionOperationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function wait(WaitRegionOperationRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Wait', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/RegionSecurityPoliciesClient.php b/Compute/src/V1/Client/RegionSecurityPoliciesClient.php index 493c98d0fc69..805eca518cef 100644 --- a/Compute/src/V1/Client/RegionSecurityPoliciesClient.php +++ b/Compute/src/V1/Client/RegionSecurityPoliciesClient.php @@ -24,17 +24,334 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionSecurityPoliciesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteRegionSecurityPolicyRequest; +use Google\Cloud\Compute\V1\GetRegionSecurityPolicyRequest; +use Google\Cloud\Compute\V1\InsertRegionSecurityPolicyRequest; +use Google\Cloud\Compute\V1\ListRegionSecurityPoliciesRequest; +use Google\Cloud\Compute\V1\PatchRegionSecurityPolicyRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\SecurityPolicy; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The RegionSecurityPolicies API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionSecurityPoliciesClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteRegionSecurityPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetRegionSecurityPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertRegionSecurityPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRegionSecurityPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchRegionSecurityPolicyRequest $request, array $optionalArgs = []) */ -final class RegionSecurityPoliciesClient extends RegionSecurityPoliciesBaseClient +final class RegionSecurityPoliciesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionSecurityPoliciesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.RegionSecurityPolicies'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/region_security_policies_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/region_security_policies_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/region_security_policies_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified policy. + * + * The async variant is {@see RegionSecurityPoliciesClient::deleteAsync()} . + * + * @param DeleteRegionSecurityPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteRegionSecurityPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * List all of the ordered rules present in a single specified policy. + * + * The async variant is {@see RegionSecurityPoliciesClient::getAsync()} . + * + * @param GetRegionSecurityPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SecurityPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRegionSecurityPolicyRequest $request, array $callOptions = []): SecurityPolicy + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a new policy in the specified project using the data included in the request. + * + * The async variant is {@see RegionSecurityPoliciesClient::insertAsync()} . + * + * @param InsertRegionSecurityPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertRegionSecurityPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * List all the policies that have been configured for the specified project and region. + * + * The async variant is {@see RegionSecurityPoliciesClient::listAsync()} . + * + * @param ListRegionSecurityPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRegionSecurityPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Patches the specified policy with the data included in the request. To clear fields in the policy, leave the fields empty and specify them in the updateMask. This cannot be used to be update the rules in the policy. Please use the per rule methods like addRule, patchRule, and removeRule instead. + * + * The async variant is {@see RegionSecurityPoliciesClient::patchAsync()} . + * + * @param PatchRegionSecurityPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchRegionSecurityPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/RegionSslCertificatesClient.php b/Compute/src/V1/Client/RegionSslCertificatesClient.php index bb5293f871b6..e17049661b71 100644 --- a/Compute/src/V1/Client/RegionSslCertificatesClient.php +++ b/Compute/src/V1/Client/RegionSslCertificatesClient.php @@ -24,17 +24,308 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionSslCertificatesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteRegionSslCertificateRequest; +use Google\Cloud\Compute\V1\GetRegionSslCertificateRequest; +use Google\Cloud\Compute\V1\InsertRegionSslCertificateRequest; +use Google\Cloud\Compute\V1\ListRegionSslCertificatesRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\SslCertificate; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The RegionSslCertificates API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionSslCertificatesClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteRegionSslCertificateRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetRegionSslCertificateRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertRegionSslCertificateRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRegionSslCertificatesRequest $request, array $optionalArgs = []) */ -final class RegionSslCertificatesClient extends RegionSslCertificatesBaseClient +final class RegionSslCertificatesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionSslCertificatesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.RegionSslCertificates'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/region_ssl_certificates_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/region_ssl_certificates_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/region_ssl_certificates_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified SslCertificate resource in the region. + * + * The async variant is {@see RegionSslCertificatesClient::deleteAsync()} . + * + * @param DeleteRegionSslCertificateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteRegionSslCertificateRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified SslCertificate resource in the specified region. Get a list of available SSL certificates by making a list() request. + * + * The async variant is {@see RegionSslCertificatesClient::getAsync()} . + * + * @param GetRegionSslCertificateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SslCertificate + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRegionSslCertificateRequest $request, array $callOptions = []): SslCertificate + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a SslCertificate resource in the specified project and region using the data included in the request + * + * The async variant is {@see RegionSslCertificatesClient::insertAsync()} . + * + * @param InsertRegionSslCertificateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertRegionSslCertificateRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of SslCertificate resources available to the specified project in the specified region. + * + * The async variant is {@see RegionSslCertificatesClient::listAsync()} . + * + * @param ListRegionSslCertificatesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRegionSslCertificatesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } } diff --git a/Compute/src/V1/Client/RegionSslPoliciesClient.php b/Compute/src/V1/Client/RegionSslPoliciesClient.php index f9bc8aaf46fa..1d6980315576 100644 --- a/Compute/src/V1/Client/RegionSslPoliciesClient.php +++ b/Compute/src/V1/Client/RegionSslPoliciesClient.php @@ -24,17 +24,361 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionSslPoliciesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteRegionSslPolicyRequest; +use Google\Cloud\Compute\V1\GetRegionSslPolicyRequest; +use Google\Cloud\Compute\V1\InsertRegionSslPolicyRequest; +use Google\Cloud\Compute\V1\ListAvailableFeaturesRegionSslPoliciesRequest; +use Google\Cloud\Compute\V1\ListRegionSslPoliciesRequest; +use Google\Cloud\Compute\V1\PatchRegionSslPolicyRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\SslPoliciesListAvailableFeaturesResponse; +use Google\Cloud\Compute\V1\SslPolicy; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The RegionSslPolicies API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionSslPoliciesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteRegionSslPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetRegionSslPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertRegionSslPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRegionSslPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAvailableFeaturesAsync(ListAvailableFeaturesRegionSslPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchRegionSslPolicyRequest $request, array $optionalArgs = []) */ -final class RegionSslPoliciesClient extends RegionSslPoliciesBaseClient +final class RegionSslPoliciesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionSslPoliciesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.RegionSslPolicies'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/region_ssl_policies_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/region_ssl_policies_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/region_ssl_policies_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified SSL policy. The SSL policy resource can be deleted only if it is not in use by any TargetHttpsProxy or TargetSslProxy resources. + * + * The async variant is {@see RegionSslPoliciesClient::deleteAsync()} . + * + * @param DeleteRegionSslPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteRegionSslPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Lists all of the ordered rules present in a single specified policy. + * + * The async variant is {@see RegionSslPoliciesClient::getAsync()} . + * + * @param GetRegionSslPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SslPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRegionSslPolicyRequest $request, array $callOptions = []): SslPolicy + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a new policy in the specified project and region using the data included in the request. + * + * The async variant is {@see RegionSslPoliciesClient::insertAsync()} . + * + * @param InsertRegionSslPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertRegionSslPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Lists all the SSL policies that have been configured for the specified project and region. + * + * The async variant is {@see RegionSslPoliciesClient::listAsync()} . + * + * @param ListRegionSslPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRegionSslPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Lists all features that can be specified in the SSL policy when using custom profile. + * + * The async variant is + * {@see RegionSslPoliciesClient::listAvailableFeaturesAsync()} . + * + * @param ListAvailableFeaturesRegionSslPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SslPoliciesListAvailableFeaturesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAvailableFeatures(ListAvailableFeaturesRegionSslPoliciesRequest $request, array $callOptions = []): SslPoliciesListAvailableFeaturesResponse + { + return $this->startApiCall('ListAvailableFeatures', $request, $callOptions)->wait(); + } + + /** + * Patches the specified SSL policy with the data included in the request. + * + * The async variant is {@see RegionSslPoliciesClient::patchAsync()} . + * + * @param PatchRegionSslPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchRegionSslPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/RegionTargetHttpProxiesClient.php b/Compute/src/V1/Client/RegionTargetHttpProxiesClient.php index 4b71637fb382..cbc99f5ef9d2 100644 --- a/Compute/src/V1/Client/RegionTargetHttpProxiesClient.php +++ b/Compute/src/V1/Client/RegionTargetHttpProxiesClient.php @@ -24,17 +24,334 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionTargetHttpProxiesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteRegionTargetHttpProxyRequest; +use Google\Cloud\Compute\V1\GetRegionTargetHttpProxyRequest; +use Google\Cloud\Compute\V1\InsertRegionTargetHttpProxyRequest; +use Google\Cloud\Compute\V1\ListRegionTargetHttpProxiesRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\SetUrlMapRegionTargetHttpProxyRequest; +use Google\Cloud\Compute\V1\TargetHttpProxy; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The RegionTargetHttpProxies API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionTargetHttpProxiesClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteRegionTargetHttpProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetRegionTargetHttpProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertRegionTargetHttpProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRegionTargetHttpProxiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface setUrlMapAsync(SetUrlMapRegionTargetHttpProxyRequest $request, array $optionalArgs = []) */ -final class RegionTargetHttpProxiesClient extends RegionTargetHttpProxiesBaseClient +final class RegionTargetHttpProxiesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionTargetHttpProxiesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.RegionTargetHttpProxies'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/region_target_http_proxies_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/region_target_http_proxies_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/region_target_http_proxies_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified TargetHttpProxy resource. + * + * The async variant is {@see RegionTargetHttpProxiesClient::deleteAsync()} . + * + * @param DeleteRegionTargetHttpProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteRegionTargetHttpProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified TargetHttpProxy resource in the specified region. + * + * The async variant is {@see RegionTargetHttpProxiesClient::getAsync()} . + * + * @param GetRegionTargetHttpProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TargetHttpProxy + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRegionTargetHttpProxyRequest $request, array $callOptions = []): TargetHttpProxy + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a TargetHttpProxy resource in the specified project and region using the data included in the request. + * + * The async variant is {@see RegionTargetHttpProxiesClient::insertAsync()} . + * + * @param InsertRegionTargetHttpProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertRegionTargetHttpProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of TargetHttpProxy resources available to the specified project in the specified region. + * + * The async variant is {@see RegionTargetHttpProxiesClient::listAsync()} . + * + * @param ListRegionTargetHttpProxiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRegionTargetHttpProxiesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Changes the URL map for TargetHttpProxy. + * + * The async variant is {@see RegionTargetHttpProxiesClient::setUrlMapAsync()} . + * + * @param SetUrlMapRegionTargetHttpProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setUrlMap(SetUrlMapRegionTargetHttpProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetUrlMap', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/RegionTargetHttpsProxiesClient.php b/Compute/src/V1/Client/RegionTargetHttpsProxiesClient.php index 4fd87a77879d..333827e65d46 100644 --- a/Compute/src/V1/Client/RegionTargetHttpsProxiesClient.php +++ b/Compute/src/V1/Client/RegionTargetHttpsProxiesClient.php @@ -24,17 +24,387 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionTargetHttpsProxiesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteRegionTargetHttpsProxyRequest; +use Google\Cloud\Compute\V1\GetRegionTargetHttpsProxyRequest; +use Google\Cloud\Compute\V1\InsertRegionTargetHttpsProxyRequest; +use Google\Cloud\Compute\V1\ListRegionTargetHttpsProxiesRequest; +use Google\Cloud\Compute\V1\PatchRegionTargetHttpsProxyRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\SetSslCertificatesRegionTargetHttpsProxyRequest; +use Google\Cloud\Compute\V1\SetUrlMapRegionTargetHttpsProxyRequest; +use Google\Cloud\Compute\V1\TargetHttpsProxy; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The RegionTargetHttpsProxies API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionTargetHttpsProxiesClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteRegionTargetHttpsProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetRegionTargetHttpsProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertRegionTargetHttpsProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRegionTargetHttpsProxiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchRegionTargetHttpsProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setSslCertificatesAsync(SetSslCertificatesRegionTargetHttpsProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setUrlMapAsync(SetUrlMapRegionTargetHttpsProxyRequest $request, array $optionalArgs = []) */ -final class RegionTargetHttpsProxiesClient extends RegionTargetHttpsProxiesBaseClient +final class RegionTargetHttpsProxiesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionTargetHttpsProxiesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.RegionTargetHttpsProxies'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/region_target_https_proxies_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/region_target_https_proxies_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/region_target_https_proxies_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified TargetHttpsProxy resource. + * + * The async variant is {@see RegionTargetHttpsProxiesClient::deleteAsync()} . + * + * @param DeleteRegionTargetHttpsProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteRegionTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified TargetHttpsProxy resource in the specified region. + * + * The async variant is {@see RegionTargetHttpsProxiesClient::getAsync()} . + * + * @param GetRegionTargetHttpsProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TargetHttpsProxy + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRegionTargetHttpsProxyRequest $request, array $callOptions = []): TargetHttpsProxy + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a TargetHttpsProxy resource in the specified project and region using the data included in the request. + * + * The async variant is {@see RegionTargetHttpsProxiesClient::insertAsync()} . + * + * @param InsertRegionTargetHttpsProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertRegionTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of TargetHttpsProxy resources available to the specified project in the specified region. + * + * The async variant is {@see RegionTargetHttpsProxiesClient::listAsync()} . + * + * @param ListRegionTargetHttpsProxiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRegionTargetHttpsProxiesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Patches the specified regional TargetHttpsProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + * + * The async variant is {@see RegionTargetHttpsProxiesClient::patchAsync()} . + * + * @param PatchRegionTargetHttpsProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchRegionTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Replaces SslCertificates for TargetHttpsProxy. + * + * The async variant is + * {@see RegionTargetHttpsProxiesClient::setSslCertificatesAsync()} . + * + * @param SetSslCertificatesRegionTargetHttpsProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setSslCertificates(SetSslCertificatesRegionTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetSslCertificates', $request, $callOptions)->wait(); + } + + /** + * Changes the URL map for TargetHttpsProxy. + * + * The async variant is {@see RegionTargetHttpsProxiesClient::setUrlMapAsync()} . + * + * @param SetUrlMapRegionTargetHttpsProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setUrlMap(SetUrlMapRegionTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetUrlMap', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/RegionTargetTcpProxiesClient.php b/Compute/src/V1/Client/RegionTargetTcpProxiesClient.php index 32993c5ff10a..47da5dc03bf7 100644 --- a/Compute/src/V1/Client/RegionTargetTcpProxiesClient.php +++ b/Compute/src/V1/Client/RegionTargetTcpProxiesClient.php @@ -24,17 +24,308 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionTargetTcpProxiesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteRegionTargetTcpProxyRequest; +use Google\Cloud\Compute\V1\GetRegionTargetTcpProxyRequest; +use Google\Cloud\Compute\V1\InsertRegionTargetTcpProxyRequest; +use Google\Cloud\Compute\V1\ListRegionTargetTcpProxiesRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\TargetTcpProxy; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The RegionTargetTcpProxies API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionTargetTcpProxiesClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteRegionTargetTcpProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetRegionTargetTcpProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertRegionTargetTcpProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRegionTargetTcpProxiesRequest $request, array $optionalArgs = []) */ -final class RegionTargetTcpProxiesClient extends RegionTargetTcpProxiesBaseClient +final class RegionTargetTcpProxiesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionTargetTcpProxiesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.RegionTargetTcpProxies'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/region_target_tcp_proxies_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/region_target_tcp_proxies_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/region_target_tcp_proxies_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified TargetTcpProxy resource. + * + * The async variant is {@see RegionTargetTcpProxiesClient::deleteAsync()} . + * + * @param DeleteRegionTargetTcpProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteRegionTargetTcpProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified TargetTcpProxy resource. + * + * The async variant is {@see RegionTargetTcpProxiesClient::getAsync()} . + * + * @param GetRegionTargetTcpProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TargetTcpProxy + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRegionTargetTcpProxyRequest $request, array $callOptions = []): TargetTcpProxy + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a TargetTcpProxy resource in the specified project and region using the data included in the request. + * + * The async variant is {@see RegionTargetTcpProxiesClient::insertAsync()} . + * + * @param InsertRegionTargetTcpProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertRegionTargetTcpProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of TargetTcpProxy resources available to the specified project in a given region. + * + * The async variant is {@see RegionTargetTcpProxiesClient::listAsync()} . + * + * @param ListRegionTargetTcpProxiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRegionTargetTcpProxiesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } } diff --git a/Compute/src/V1/Client/RegionUrlMapsClient.php b/Compute/src/V1/Client/RegionUrlMapsClient.php index 2005c827c6e9..99a6b4f6b76d 100644 --- a/Compute/src/V1/Client/RegionUrlMapsClient.php +++ b/Compute/src/V1/Client/RegionUrlMapsClient.php @@ -24,17 +24,386 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionUrlMapsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteRegionUrlMapRequest; +use Google\Cloud\Compute\V1\GetRegionUrlMapRequest; +use Google\Cloud\Compute\V1\InsertRegionUrlMapRequest; +use Google\Cloud\Compute\V1\ListRegionUrlMapsRequest; +use Google\Cloud\Compute\V1\PatchRegionUrlMapRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\UpdateRegionUrlMapRequest; +use Google\Cloud\Compute\V1\UrlMap; +use Google\Cloud\Compute\V1\UrlMapsValidateResponse; +use Google\Cloud\Compute\V1\ValidateRegionUrlMapRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The RegionUrlMaps API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionUrlMapsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteRegionUrlMapRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetRegionUrlMapRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertRegionUrlMapRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRegionUrlMapsRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchRegionUrlMapRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAsync(UpdateRegionUrlMapRequest $request, array $optionalArgs = []) + * @method PromiseInterface validateAsync(ValidateRegionUrlMapRequest $request, array $optionalArgs = []) */ -final class RegionUrlMapsClient extends RegionUrlMapsBaseClient +final class RegionUrlMapsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionUrlMapsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.RegionUrlMaps'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/region_url_maps_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/region_url_maps_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/region_url_maps_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified UrlMap resource. + * + * The async variant is {@see RegionUrlMapsClient::deleteAsync()} . + * + * @param DeleteRegionUrlMapRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteRegionUrlMapRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified UrlMap resource. + * + * The async variant is {@see RegionUrlMapsClient::getAsync()} . + * + * @param GetRegionUrlMapRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 UrlMap + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRegionUrlMapRequest $request, array $callOptions = []): UrlMap + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a UrlMap resource in the specified project using the data included in the request. + * + * The async variant is {@see RegionUrlMapsClient::insertAsync()} . + * + * @param InsertRegionUrlMapRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertRegionUrlMapRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of UrlMap resources available to the specified project in the specified region. + * + * The async variant is {@see RegionUrlMapsClient::listAsync()} . + * + * @param ListRegionUrlMapsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRegionUrlMapsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Patches the specified UrlMap resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + * + * The async variant is {@see RegionUrlMapsClient::patchAsync()} . + * + * @param PatchRegionUrlMapRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchRegionUrlMapRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Updates the specified UrlMap resource with the data included in the request. + * + * The async variant is {@see RegionUrlMapsClient::updateAsync()} . + * + * @param UpdateRegionUrlMapRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function update(UpdateRegionUrlMapRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Update', $request, $callOptions)->wait(); + } + + /** + * Runs static validation for the UrlMap. In particular, the tests of the provided UrlMap will be run. Calling this method does NOT create the UrlMap. + * + * The async variant is {@see RegionUrlMapsClient::validateAsync()} . + * + * @param ValidateRegionUrlMapRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 UrlMapsValidateResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function validate(ValidateRegionUrlMapRequest $request, array $callOptions = []): UrlMapsValidateResponse + { + return $this->startApiCall('Validate', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/RegionsClient.php b/Compute/src/V1/Client/RegionsClient.php index cb7d4a1b1931..ab6870d365ab 100644 --- a/Compute/src/V1/Client/RegionsClient.php +++ b/Compute/src/V1/Client/RegionsClient.php @@ -24,17 +24,202 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RegionsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\GetRegionRequest; +use Google\Cloud\Compute\V1\ListRegionsRequest; +use Google\Cloud\Compute\V1\Region; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Regions API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RegionsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface getAsync(GetRegionRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRegionsRequest $request, array $optionalArgs = []) */ -final class RegionsClient extends RegionsBaseClient +final class RegionsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegionsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.Regions'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute.readonly', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/regions_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/regions_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/regions_rest_client_config.php', + ], + ], + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Returns the specified Region resource. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the `quotas` field). To exclude one or more fields, set your request's `fields` query parameter to only include the fields you need. For example, to only include the `id` and `selfLink` fields, add the query parameter `?fields=id,selfLink` to your request. + * + * The async variant is {@see RegionsClient::getAsync()} . + * + * @param GetRegionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Region + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRegionRequest $request, array $callOptions = []): Region + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of region resources available to the specified project. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the `items.quotas` field). To exclude one or more fields, set your request's `fields` query parameter to only include the fields you need. For example, to only include the `id` and `selfLink` fields, add the query parameter `?fields=id,selfLink` to your request. + * + * The async variant is {@see RegionsClient::listAsync()} . + * + * @param ListRegionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRegionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } } diff --git a/Compute/src/V1/Client/ReservationsClient.php b/Compute/src/V1/Client/ReservationsClient.php index 6c364333534a..c3eef7a5cad9 100644 --- a/Compute/src/V1/Client/ReservationsClient.php +++ b/Compute/src/V1/Client/ReservationsClient.php @@ -24,17 +24,465 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\ReservationsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListReservationsRequest; +use Google\Cloud\Compute\V1\DeleteReservationRequest; +use Google\Cloud\Compute\V1\GetIamPolicyReservationRequest; +use Google\Cloud\Compute\V1\GetReservationRequest; +use Google\Cloud\Compute\V1\InsertReservationRequest; +use Google\Cloud\Compute\V1\ListReservationsRequest; +use Google\Cloud\Compute\V1\Policy; +use Google\Cloud\Compute\V1\Reservation; +use Google\Cloud\Compute\V1\ResizeReservationRequest; +use Google\Cloud\Compute\V1\SetIamPolicyReservationRequest; +use Google\Cloud\Compute\V1\TestIamPermissionsReservationRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use Google\Cloud\Compute\V1\UpdateReservationRequest; +use Google\Cloud\Compute\V1\ZoneOperationsClient; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Reservations API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\ReservationsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListReservationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteReservationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetReservationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyReservationRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertReservationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListReservationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface resizeAsync(ResizeReservationRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyReservationRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsReservationRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAsync(UpdateReservationRequest $request, array $optionalArgs = []) */ -final class ReservationsClient extends ReservationsBaseClient +final class ReservationsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ReservationsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.Reservations'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/reservations_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/reservations_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/reservations_rest_client_config.php', + ], + ], + 'operationsClientClass' => ZoneOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an ZoneOperationsClient object with the same endpoint as $this. + * + * @return ZoneOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getZone', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves an aggregated list of reservations. + * + * The async variant is {@see ReservationsClient::aggregatedListAsync()} . + * + * @param AggregatedListReservationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListReservationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified reservation. + * + * The async variant is {@see ReservationsClient::deleteAsync()} . + * + * @param DeleteReservationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteReservationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Retrieves information about the specified reservation. + * + * The async variant is {@see ReservationsClient::getAsync()} . + * + * @param GetReservationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Reservation + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetReservationRequest $request, array $callOptions = []): Reservation + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * The async variant is {@see ReservationsClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyReservationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyReservationRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Creates a new reservation. For more information, read Reserving zonal resources. + * + * The async variant is {@see ReservationsClient::insertAsync()} . + * + * @param InsertReservationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertReservationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * A list of all the reservations that have been configured for the specified project in specified zone. + * + * The async variant is {@see ReservationsClient::listAsync()} . + * + * @param ListReservationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListReservationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Resizes the reservation (applicable to standalone reservations only). For more information, read Modifying reservations. + * + * The async variant is {@see ReservationsClient::resizeAsync()} . + * + * @param ResizeReservationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function resize(ResizeReservationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Resize', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * The async variant is {@see ReservationsClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyReservationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyReservationRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. + * + * The async variant is {@see ReservationsClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsReservationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsReservationRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Update share settings of the reservation. + * + * The async variant is {@see ReservationsClient::updateAsync()} . + * + * @param UpdateReservationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function update(UpdateReservationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Update', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/ResourcePoliciesClient.php b/Compute/src/V1/Client/ResourcePoliciesClient.php index 149751446ad5..eaac2b9318e2 100644 --- a/Compute/src/V1/Client/ResourcePoliciesClient.php +++ b/Compute/src/V1/Client/ResourcePoliciesClient.php @@ -24,17 +24,439 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\ResourcePoliciesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListResourcePoliciesRequest; +use Google\Cloud\Compute\V1\DeleteResourcePolicyRequest; +use Google\Cloud\Compute\V1\GetIamPolicyResourcePolicyRequest; +use Google\Cloud\Compute\V1\GetResourcePolicyRequest; +use Google\Cloud\Compute\V1\InsertResourcePolicyRequest; +use Google\Cloud\Compute\V1\ListResourcePoliciesRequest; +use Google\Cloud\Compute\V1\PatchResourcePolicyRequest; +use Google\Cloud\Compute\V1\Policy; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\ResourcePolicy; +use Google\Cloud\Compute\V1\SetIamPolicyResourcePolicyRequest; +use Google\Cloud\Compute\V1\TestIamPermissionsResourcePolicyRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The ResourcePolicies API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\ResourcePoliciesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListResourcePoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteResourcePolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetResourcePolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyResourcePolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertResourcePolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListResourcePoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchResourcePolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyResourcePolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsResourcePolicyRequest $request, array $optionalArgs = []) */ -final class ResourcePoliciesClient extends ResourcePoliciesBaseClient +final class ResourcePoliciesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ResourcePoliciesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.ResourcePolicies'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/resource_policies_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/resource_policies_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/resource_policies_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves an aggregated list of resource policies. + * + * The async variant is {@see ResourcePoliciesClient::aggregatedListAsync()} . + * + * @param AggregatedListResourcePoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListResourcePoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified resource policy. + * + * The async variant is {@see ResourcePoliciesClient::deleteAsync()} . + * + * @param DeleteResourcePolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteResourcePolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Retrieves all information of the specified resource policy. + * + * The async variant is {@see ResourcePoliciesClient::getAsync()} . + * + * @param GetResourcePolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ResourcePolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetResourcePolicyRequest $request, array $callOptions = []): ResourcePolicy + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * The async variant is {@see ResourcePoliciesClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyResourcePolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyResourcePolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Creates a new resource policy. + * + * The async variant is {@see ResourcePoliciesClient::insertAsync()} . + * + * @param InsertResourcePolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertResourcePolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * A list all the resource policies that have been configured for the specified project in specified region. + * + * The async variant is {@see ResourcePoliciesClient::listAsync()} . + * + * @param ListResourcePoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListResourcePoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Modify the specified resource policy. + * + * The async variant is {@see ResourcePoliciesClient::patchAsync()} . + * + * @param PatchResourcePolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchResourcePolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * The async variant is {@see ResourcePoliciesClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyResourcePolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyResourcePolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. + * + * The async variant is {@see ResourcePoliciesClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsResourcePolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsResourcePolicyRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/RoutersClient.php b/Compute/src/V1/Client/RoutersClient.php index 5c6793997467..08cf5d10d790 100644 --- a/Compute/src/V1/Client/RoutersClient.php +++ b/Compute/src/V1/Client/RoutersClient.php @@ -24,17 +24,465 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RoutersBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListRoutersRequest; +use Google\Cloud\Compute\V1\DeleteRouterRequest; +use Google\Cloud\Compute\V1\GetNatMappingInfoRoutersRequest; +use Google\Cloud\Compute\V1\GetRouterRequest; +use Google\Cloud\Compute\V1\GetRouterStatusRouterRequest; +use Google\Cloud\Compute\V1\InsertRouterRequest; +use Google\Cloud\Compute\V1\ListRoutersRequest; +use Google\Cloud\Compute\V1\PatchRouterRequest; +use Google\Cloud\Compute\V1\PreviewRouterRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\Router; +use Google\Cloud\Compute\V1\RouterStatusResponse; +use Google\Cloud\Compute\V1\RoutersPreviewResponse; +use Google\Cloud\Compute\V1\UpdateRouterRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Routers API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RoutersClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListRoutersRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteRouterRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetRouterRequest $request, array $optionalArgs = []) + * @method PromiseInterface getNatMappingInfoAsync(GetNatMappingInfoRoutersRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRouterStatusAsync(GetRouterStatusRouterRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertRouterRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRoutersRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchRouterRequest $request, array $optionalArgs = []) + * @method PromiseInterface previewAsync(PreviewRouterRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAsync(UpdateRouterRequest $request, array $optionalArgs = []) */ -final class RoutersClient extends RoutersBaseClient +final class RoutersClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RoutersBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.Routers'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/routers_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/routers_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/routers_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves an aggregated list of routers. + * + * The async variant is {@see RoutersClient::aggregatedListAsync()} . + * + * @param AggregatedListRoutersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListRoutersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified Router resource. + * + * The async variant is {@see RoutersClient::deleteAsync()} . + * + * @param DeleteRouterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteRouterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified Router resource. + * + * The async variant is {@see RoutersClient::getAsync()} . + * + * @param GetRouterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Router + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRouterRequest $request, array $callOptions = []): Router + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Retrieves runtime Nat mapping information of VM endpoints. + * + * The async variant is {@see RoutersClient::getNatMappingInfoAsync()} . + * + * @param GetNatMappingInfoRoutersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function getNatMappingInfo(GetNatMappingInfoRoutersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('GetNatMappingInfo', $request, $callOptions); + } + + /** + * Retrieves runtime information of the specified router. + * + * The async variant is {@see RoutersClient::getRouterStatusAsync()} . + * + * @param GetRouterStatusRouterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RouterStatusResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRouterStatus(GetRouterStatusRouterRequest $request, array $callOptions = []): RouterStatusResponse + { + return $this->startApiCall('GetRouterStatus', $request, $callOptions)->wait(); + } + + /** + * Creates a Router resource in the specified project and region using the data included in the request. + * + * The async variant is {@see RoutersClient::insertAsync()} . + * + * @param InsertRouterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertRouterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of Router resources available to the specified project. + * + * The async variant is {@see RoutersClient::listAsync()} . + * + * @param ListRoutersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRoutersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Patches the specified Router resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + * + * The async variant is {@see RoutersClient::patchAsync()} . + * + * @param PatchRouterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchRouterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Preview fields auto-generated during router create and update operations. Calling this method does NOT create or update the router. + * + * The async variant is {@see RoutersClient::previewAsync()} . + * + * @param PreviewRouterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RoutersPreviewResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function preview(PreviewRouterRequest $request, array $callOptions = []): RoutersPreviewResponse + { + return $this->startApiCall('Preview', $request, $callOptions)->wait(); + } + + /** + * Updates the specified Router resource with the data included in the request. This method conforms to PUT semantics, which requests that the state of the target resource be created or replaced with the state defined by the representation enclosed in the request message payload. + * + * The async variant is {@see RoutersClient::updateAsync()} . + * + * @param UpdateRouterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function update(UpdateRouterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Update', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/RoutesClient.php b/Compute/src/V1/Client/RoutesClient.php index 94bded5638c5..efb9075d03be 100644 --- a/Compute/src/V1/Client/RoutesClient.php +++ b/Compute/src/V1/Client/RoutesClient.php @@ -24,17 +24,306 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\RoutesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteRouteRequest; +use Google\Cloud\Compute\V1\GetRouteRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertRouteRequest; +use Google\Cloud\Compute\V1\ListRoutesRequest; +use Google\Cloud\Compute\V1\Route; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Routes API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\RoutesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteRouteRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetRouteRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertRouteRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListRoutesRequest $request, array $optionalArgs = []) */ -final class RoutesClient extends RoutesBaseClient +final class RoutesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RoutesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.Routes'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/routes_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/routes_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/routes_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified Route resource. + * + * The async variant is {@see RoutesClient::deleteAsync()} . + * + * @param DeleteRouteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteRouteRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified Route resource. + * + * The async variant is {@see RoutesClient::getAsync()} . + * + * @param GetRouteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Route + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetRouteRequest $request, array $callOptions = []): Route + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a Route resource in the specified project using the data included in the request. + * + * The async variant is {@see RoutesClient::insertAsync()} . + * + * @param InsertRouteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertRouteRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of Route resources available to the specified project. + * + * The async variant is {@see RoutesClient::listAsync()} . + * + * @param ListRoutesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListRoutesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } } diff --git a/Compute/src/V1/Client/SecurityPoliciesClient.php b/Compute/src/V1/Client/SecurityPoliciesClient.php index e017640fc218..94d89d01766f 100644 --- a/Compute/src/V1/Client/SecurityPoliciesClient.php +++ b/Compute/src/V1/Client/SecurityPoliciesClient.php @@ -24,17 +24,517 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\SecurityPoliciesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AddRuleSecurityPolicyRequest; +use Google\Cloud\Compute\V1\AggregatedListSecurityPoliciesRequest; +use Google\Cloud\Compute\V1\DeleteSecurityPolicyRequest; +use Google\Cloud\Compute\V1\GetRuleSecurityPolicyRequest; +use Google\Cloud\Compute\V1\GetSecurityPolicyRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertSecurityPolicyRequest; +use Google\Cloud\Compute\V1\ListPreconfiguredExpressionSetsSecurityPoliciesRequest; +use Google\Cloud\Compute\V1\ListSecurityPoliciesRequest; +use Google\Cloud\Compute\V1\PatchRuleSecurityPolicyRequest; +use Google\Cloud\Compute\V1\PatchSecurityPolicyRequest; +use Google\Cloud\Compute\V1\RemoveRuleSecurityPolicyRequest; +use Google\Cloud\Compute\V1\SecurityPoliciesListPreconfiguredExpressionSetsResponse; +use Google\Cloud\Compute\V1\SecurityPolicy; +use Google\Cloud\Compute\V1\SecurityPolicyRule; +use Google\Cloud\Compute\V1\SetLabelsSecurityPolicyRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The SecurityPolicies API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\SecurityPoliciesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface addRuleAsync(AddRuleSecurityPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface aggregatedListAsync(AggregatedListSecurityPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteSecurityPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetSecurityPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRuleAsync(GetRuleSecurityPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertSecurityPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListSecurityPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPreconfiguredExpressionSetsAsync(ListPreconfiguredExpressionSetsSecurityPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchSecurityPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchRuleAsync(PatchRuleSecurityPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeRuleAsync(RemoveRuleSecurityPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setLabelsAsync(SetLabelsSecurityPolicyRequest $request, array $optionalArgs = []) */ -final class SecurityPoliciesClient extends SecurityPoliciesBaseClient +final class SecurityPoliciesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SecurityPoliciesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.SecurityPolicies'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/security_policies_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/security_policies_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/security_policies_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Inserts a rule into a security policy. + * + * The async variant is {@see SecurityPoliciesClient::addRuleAsync()} . + * + * @param AddRuleSecurityPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addRule(AddRuleSecurityPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddRule', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of all SecurityPolicy resources, regional and global, available to the specified project. + * + * The async variant is {@see SecurityPoliciesClient::aggregatedListAsync()} . + * + * @param AggregatedListSecurityPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListSecurityPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified policy. + * + * The async variant is {@see SecurityPoliciesClient::deleteAsync()} . + * + * @param DeleteSecurityPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteSecurityPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * List all of the ordered rules present in a single specified policy. + * + * The async variant is {@see SecurityPoliciesClient::getAsync()} . + * + * @param GetSecurityPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SecurityPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetSecurityPolicyRequest $request, array $callOptions = []): SecurityPolicy + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Gets a rule at the specified priority. + * + * The async variant is {@see SecurityPoliciesClient::getRuleAsync()} . + * + * @param GetRuleSecurityPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SecurityPolicyRule + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRule(GetRuleSecurityPolicyRequest $request, array $callOptions = []): SecurityPolicyRule + { + return $this->startApiCall('GetRule', $request, $callOptions)->wait(); + } + + /** + * Creates a new policy in the specified project using the data included in the request. + * + * The async variant is {@see SecurityPoliciesClient::insertAsync()} . + * + * @param InsertSecurityPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertSecurityPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * List all the policies that have been configured for the specified project. + * + * The async variant is {@see SecurityPoliciesClient::listAsync()} . + * + * @param ListSecurityPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListSecurityPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Gets the current list of preconfigured Web Application Firewall (WAF) expressions. + * + * The async variant is + * {@see SecurityPoliciesClient::listPreconfiguredExpressionSetsAsync()} . + * + * @param ListPreconfiguredExpressionSetsSecurityPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SecurityPoliciesListPreconfiguredExpressionSetsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPreconfiguredExpressionSets(ListPreconfiguredExpressionSetsSecurityPoliciesRequest $request, array $callOptions = []): SecurityPoliciesListPreconfiguredExpressionSetsResponse + { + return $this->startApiCall('ListPreconfiguredExpressionSets', $request, $callOptions)->wait(); + } + + /** + * Patches the specified policy with the data included in the request. To clear fields in the policy, leave the fields empty and specify them in the updateMask. This cannot be used to be update the rules in the policy. Please use the per rule methods like addRule, patchRule, and removeRule instead. + * + * The async variant is {@see SecurityPoliciesClient::patchAsync()} . + * + * @param PatchSecurityPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchSecurityPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Patches a rule at the specified priority. To clear fields in the rule, leave the fields empty and specify them in the updateMask. + * + * The async variant is {@see SecurityPoliciesClient::patchRuleAsync()} . + * + * @param PatchRuleSecurityPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patchRule(PatchRuleSecurityPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('PatchRule', $request, $callOptions)->wait(); + } + + /** + * Deletes a rule at the specified priority. + * + * The async variant is {@see SecurityPoliciesClient::removeRuleAsync()} . + * + * @param RemoveRuleSecurityPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeRule(RemoveRuleSecurityPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RemoveRule', $request, $callOptions)->wait(); + } + + /** + * Sets the labels on a security policy. To learn more about labels, read the Labeling Resources documentation. + * + * The async variant is {@see SecurityPoliciesClient::setLabelsAsync()} . + * + * @param SetLabelsSecurityPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setLabels(SetLabelsSecurityPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/ServiceAttachmentsClient.php b/Compute/src/V1/Client/ServiceAttachmentsClient.php index 33939eaf5ad7..4e7deab8645a 100644 --- a/Compute/src/V1/Client/ServiceAttachmentsClient.php +++ b/Compute/src/V1/Client/ServiceAttachmentsClient.php @@ -24,17 +24,440 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\ServiceAttachmentsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListServiceAttachmentsRequest; +use Google\Cloud\Compute\V1\DeleteServiceAttachmentRequest; +use Google\Cloud\Compute\V1\GetIamPolicyServiceAttachmentRequest; +use Google\Cloud\Compute\V1\GetServiceAttachmentRequest; +use Google\Cloud\Compute\V1\InsertServiceAttachmentRequest; +use Google\Cloud\Compute\V1\ListServiceAttachmentsRequest; +use Google\Cloud\Compute\V1\PatchServiceAttachmentRequest; +use Google\Cloud\Compute\V1\Policy; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\ServiceAttachment; +use Google\Cloud\Compute\V1\SetIamPolicyServiceAttachmentRequest; +use Google\Cloud\Compute\V1\TestIamPermissionsServiceAttachmentRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The ServiceAttachments API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\ServiceAttachmentsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListServiceAttachmentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteServiceAttachmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetServiceAttachmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyServiceAttachmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertServiceAttachmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListServiceAttachmentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchServiceAttachmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyServiceAttachmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsServiceAttachmentRequest $request, array $optionalArgs = []) */ -final class ServiceAttachmentsClient extends ServiceAttachmentsBaseClient +final class ServiceAttachmentsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ServiceAttachmentsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.ServiceAttachments'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/service_attachments_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/service_attachments_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/service_attachments_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves the list of all ServiceAttachment resources, regional and global, available to the specified project. + * + * The async variant is {@see ServiceAttachmentsClient::aggregatedListAsync()} . + * + * @param AggregatedListServiceAttachmentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListServiceAttachmentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified ServiceAttachment in the given scope + * + * The async variant is {@see ServiceAttachmentsClient::deleteAsync()} . + * + * @param DeleteServiceAttachmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteServiceAttachmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified ServiceAttachment resource in the given scope. + * + * The async variant is {@see ServiceAttachmentsClient::getAsync()} . + * + * @param GetServiceAttachmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ServiceAttachment + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetServiceAttachmentRequest $request, array $callOptions = []): ServiceAttachment + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * The async variant is {@see ServiceAttachmentsClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyServiceAttachmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyServiceAttachmentRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Creates a ServiceAttachment in the specified project in the given scope using the parameters that are included in the request. + * + * The async variant is {@see ServiceAttachmentsClient::insertAsync()} . + * + * @param InsertServiceAttachmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertServiceAttachmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Lists the ServiceAttachments for a project in the given scope. + * + * The async variant is {@see ServiceAttachmentsClient::listAsync()} . + * + * @param ListServiceAttachmentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListServiceAttachmentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Patches the specified ServiceAttachment resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + * + * The async variant is {@see ServiceAttachmentsClient::patchAsync()} . + * + * @param PatchServiceAttachmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchServiceAttachmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * The async variant is {@see ServiceAttachmentsClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyServiceAttachmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyServiceAttachmentRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. + * + * The async variant is {@see ServiceAttachmentsClient::testIamPermissionsAsync()} + * . + * + * @param TestIamPermissionsServiceAttachmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsServiceAttachmentRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/SnapshotsClient.php b/Compute/src/V1/Client/SnapshotsClient.php index bbc6bb9ca47e..f27e9fa4bea1 100644 --- a/Compute/src/V1/Client/SnapshotsClient.php +++ b/Compute/src/V1/Client/SnapshotsClient.php @@ -24,17 +24,412 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\SnapshotsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteSnapshotRequest; +use Google\Cloud\Compute\V1\GetIamPolicySnapshotRequest; +use Google\Cloud\Compute\V1\GetSnapshotRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertSnapshotRequest; +use Google\Cloud\Compute\V1\ListSnapshotsRequest; +use Google\Cloud\Compute\V1\Policy; +use Google\Cloud\Compute\V1\SetIamPolicySnapshotRequest; +use Google\Cloud\Compute\V1\SetLabelsSnapshotRequest; +use Google\Cloud\Compute\V1\Snapshot; +use Google\Cloud\Compute\V1\TestIamPermissionsSnapshotRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Snapshots API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\SnapshotsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicySnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListSnapshotsRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicySnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface setLabelsAsync(SetLabelsSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsSnapshotRequest $request, array $optionalArgs = []) */ -final class SnapshotsClient extends SnapshotsBaseClient +final class SnapshotsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SnapshotsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.Snapshots'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/snapshots_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/snapshots_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/snapshots_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified Snapshot resource. Keep in mind that deleting a single snapshot might not necessarily delete all the data on that snapshot. If any data on the snapshot that is marked for deletion is needed for subsequent snapshots, the data will be moved to the next corresponding snapshot. For more information, see Deleting snapshots. + * + * The async variant is {@see SnapshotsClient::deleteAsync()} . + * + * @param DeleteSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteSnapshotRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified Snapshot resource. + * + * The async variant is {@see SnapshotsClient::getAsync()} . + * + * @param GetSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Snapshot + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetSnapshotRequest $request, array $callOptions = []): Snapshot + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * The async variant is {@see SnapshotsClient::getIamPolicyAsync()} . + * + * @param GetIamPolicySnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicySnapshotRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Creates a snapshot in the specified project using the data included in the request. For regular snapshot creation, consider using this method instead of disks.createSnapshot, as this method supports more features, such as creating snapshots in a project different from the source disk project. + * + * The async variant is {@see SnapshotsClient::insertAsync()} . + * + * @param InsertSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertSnapshotRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of Snapshot resources contained within the specified project. + * + * The async variant is {@see SnapshotsClient::listAsync()} . + * + * @param ListSnapshotsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListSnapshotsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * The async variant is {@see SnapshotsClient::setIamPolicyAsync()} . + * + * @param SetIamPolicySnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicySnapshotRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the labels on a snapshot. To learn more about labels, read the Labeling Resources documentation. + * + * The async variant is {@see SnapshotsClient::setLabelsAsync()} . + * + * @param SetLabelsSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setLabels(SetLabelsSnapshotRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. + * + * The async variant is {@see SnapshotsClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsSnapshotRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/SslCertificatesClient.php b/Compute/src/V1/Client/SslCertificatesClient.php index d83b3326bc03..73b12e5d7429 100644 --- a/Compute/src/V1/Client/SslCertificatesClient.php +++ b/Compute/src/V1/Client/SslCertificatesClient.php @@ -24,17 +24,332 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\SslCertificatesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListSslCertificatesRequest; +use Google\Cloud\Compute\V1\DeleteSslCertificateRequest; +use Google\Cloud\Compute\V1\GetSslCertificateRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertSslCertificateRequest; +use Google\Cloud\Compute\V1\ListSslCertificatesRequest; +use Google\Cloud\Compute\V1\SslCertificate; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The SslCertificates API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\SslCertificatesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListSslCertificatesRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteSslCertificateRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetSslCertificateRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertSslCertificateRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListSslCertificatesRequest $request, array $optionalArgs = []) */ -final class SslCertificatesClient extends SslCertificatesBaseClient +final class SslCertificatesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SslCertificatesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.SslCertificates'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/ssl_certificates_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/ssl_certificates_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/ssl_certificates_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves the list of all SslCertificate resources, regional and global, available to the specified project. + * + * The async variant is {@see SslCertificatesClient::aggregatedListAsync()} . + * + * @param AggregatedListSslCertificatesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListSslCertificatesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified SslCertificate resource. + * + * The async variant is {@see SslCertificatesClient::deleteAsync()} . + * + * @param DeleteSslCertificateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteSslCertificateRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified SslCertificate resource. + * + * The async variant is {@see SslCertificatesClient::getAsync()} . + * + * @param GetSslCertificateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SslCertificate + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetSslCertificateRequest $request, array $callOptions = []): SslCertificate + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a SslCertificate resource in the specified project using the data included in the request. + * + * The async variant is {@see SslCertificatesClient::insertAsync()} . + * + * @param InsertSslCertificateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertSslCertificateRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of SslCertificate resources available to the specified project. + * + * The async variant is {@see SslCertificatesClient::listAsync()} . + * + * @param ListSslCertificatesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListSslCertificatesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } } diff --git a/Compute/src/V1/Client/SslPoliciesClient.php b/Compute/src/V1/Client/SslPoliciesClient.php index a58b3265aeb3..624b820d0c96 100644 --- a/Compute/src/V1/Client/SslPoliciesClient.php +++ b/Compute/src/V1/Client/SslPoliciesClient.php @@ -24,17 +24,385 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\SslPoliciesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListSslPoliciesRequest; +use Google\Cloud\Compute\V1\DeleteSslPolicyRequest; +use Google\Cloud\Compute\V1\GetSslPolicyRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertSslPolicyRequest; +use Google\Cloud\Compute\V1\ListAvailableFeaturesSslPoliciesRequest; +use Google\Cloud\Compute\V1\ListSslPoliciesRequest; +use Google\Cloud\Compute\V1\PatchSslPolicyRequest; +use Google\Cloud\Compute\V1\SslPoliciesListAvailableFeaturesResponse; +use Google\Cloud\Compute\V1\SslPolicy; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The SslPolicies API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\SslPoliciesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListSslPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteSslPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetSslPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertSslPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListSslPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAvailableFeaturesAsync(ListAvailableFeaturesSslPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchSslPolicyRequest $request, array $optionalArgs = []) */ -final class SslPoliciesClient extends SslPoliciesBaseClient +final class SslPoliciesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SslPoliciesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.SslPolicies'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/ssl_policies_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/ssl_policies_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/ssl_policies_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves the list of all SslPolicy resources, regional and global, available to the specified project. + * + * The async variant is {@see SslPoliciesClient::aggregatedListAsync()} . + * + * @param AggregatedListSslPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListSslPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified SSL policy. The SSL policy resource can be deleted only if it is not in use by any TargetHttpsProxy or TargetSslProxy resources. + * + * The async variant is {@see SslPoliciesClient::deleteAsync()} . + * + * @param DeleteSslPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteSslPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Lists all of the ordered rules present in a single specified policy. + * + * The async variant is {@see SslPoliciesClient::getAsync()} . + * + * @param GetSslPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SslPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetSslPolicyRequest $request, array $callOptions = []): SslPolicy + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Returns the specified SSL policy resource. + * + * The async variant is {@see SslPoliciesClient::insertAsync()} . + * + * @param InsertSslPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertSslPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Lists all the SSL policies that have been configured for the specified project. + * + * The async variant is {@see SslPoliciesClient::listAsync()} . + * + * @param ListSslPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListSslPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Lists all features that can be specified in the SSL policy when using custom profile. + * + * The async variant is {@see SslPoliciesClient::listAvailableFeaturesAsync()} . + * + * @param ListAvailableFeaturesSslPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SslPoliciesListAvailableFeaturesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAvailableFeatures(ListAvailableFeaturesSslPoliciesRequest $request, array $callOptions = []): SslPoliciesListAvailableFeaturesResponse + { + return $this->startApiCall('ListAvailableFeatures', $request, $callOptions)->wait(); + } + + /** + * Patches the specified SSL policy with the data included in the request. + * + * The async variant is {@see SslPoliciesClient::patchAsync()} . + * + * @param PatchSslPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchSslPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/SubnetworksClient.php b/Compute/src/V1/Client/SubnetworksClient.php index 8f31b573bbf4..8f4b0e90acd5 100644 --- a/Compute/src/V1/Client/SubnetworksClient.php +++ b/Compute/src/V1/Client/SubnetworksClient.php @@ -24,17 +24,517 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\SubnetworksBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListSubnetworksRequest; +use Google\Cloud\Compute\V1\DeleteSubnetworkRequest; +use Google\Cloud\Compute\V1\ExpandIpCidrRangeSubnetworkRequest; +use Google\Cloud\Compute\V1\GetIamPolicySubnetworkRequest; +use Google\Cloud\Compute\V1\GetSubnetworkRequest; +use Google\Cloud\Compute\V1\InsertSubnetworkRequest; +use Google\Cloud\Compute\V1\ListSubnetworksRequest; +use Google\Cloud\Compute\V1\ListUsableSubnetworksRequest; +use Google\Cloud\Compute\V1\PatchSubnetworkRequest; +use Google\Cloud\Compute\V1\Policy; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\SetIamPolicySubnetworkRequest; +use Google\Cloud\Compute\V1\SetPrivateIpGoogleAccessSubnetworkRequest; +use Google\Cloud\Compute\V1\Subnetwork; +use Google\Cloud\Compute\V1\TestIamPermissionsSubnetworkRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Subnetworks API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\SubnetworksClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListSubnetworksRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteSubnetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface expandIpCidrRangeAsync(ExpandIpCidrRangeSubnetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetSubnetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicySubnetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertSubnetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListSubnetworksRequest $request, array $optionalArgs = []) + * @method PromiseInterface listUsableAsync(ListUsableSubnetworksRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchSubnetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicySubnetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface setPrivateIpGoogleAccessAsync(SetPrivateIpGoogleAccessSubnetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsSubnetworkRequest $request, array $optionalArgs = []) */ -final class SubnetworksClient extends SubnetworksBaseClient +final class SubnetworksClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SubnetworksBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.Subnetworks'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/subnetworks_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/subnetworks_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/subnetworks_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves an aggregated list of subnetworks. + * + * The async variant is {@see SubnetworksClient::aggregatedListAsync()} . + * + * @param AggregatedListSubnetworksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListSubnetworksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified subnetwork. + * + * The async variant is {@see SubnetworksClient::deleteAsync()} . + * + * @param DeleteSubnetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteSubnetworkRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Expands the IP CIDR range of the subnetwork to a specified value. + * + * The async variant is {@see SubnetworksClient::expandIpCidrRangeAsync()} . + * + * @param ExpandIpCidrRangeSubnetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function expandIpCidrRange(ExpandIpCidrRangeSubnetworkRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ExpandIpCidrRange', $request, $callOptions)->wait(); + } + + /** + * Returns the specified subnetwork. + * + * The async variant is {@see SubnetworksClient::getAsync()} . + * + * @param GetSubnetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Subnetwork + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetSubnetworkRequest $request, array $callOptions = []): Subnetwork + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. May be empty if no such policy or resource exists. + * + * The async variant is {@see SubnetworksClient::getIamPolicyAsync()} . + * + * @param GetIamPolicySubnetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicySubnetworkRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Creates a subnetwork in the specified project using the data included in the request. + * + * The async variant is {@see SubnetworksClient::insertAsync()} . + * + * @param InsertSubnetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertSubnetworkRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of subnetworks available to the specified project. + * + * The async variant is {@see SubnetworksClient::listAsync()} . + * + * @param ListSubnetworksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListSubnetworksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Retrieves an aggregated list of all usable subnetworks in the project. + * + * The async variant is {@see SubnetworksClient::listUsableAsync()} . + * + * @param ListUsableSubnetworksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listUsable(ListUsableSubnetworksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListUsable', $request, $callOptions); + } + + /** + * Patches the specified subnetwork with the data included in the request. Only certain fields can be updated with a patch request as indicated in the field descriptions. You must specify the current fingerprint of the subnetwork resource being patched. + * + * The async variant is {@see SubnetworksClient::patchAsync()} . + * + * @param PatchSubnetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchSubnetworkRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces any existing policy. + * + * The async variant is {@see SubnetworksClient::setIamPolicyAsync()} . + * + * @param SetIamPolicySubnetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicySubnetworkRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Set whether VMs in this subnet can access Google services without assigning external IP addresses through Private Google Access. + * + * The async variant is {@see SubnetworksClient::setPrivateIpGoogleAccessAsync()} . + * + * @param SetPrivateIpGoogleAccessSubnetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setPrivateIpGoogleAccess(SetPrivateIpGoogleAccessSubnetworkRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetPrivateIpGoogleAccess', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. + * + * The async variant is {@see SubnetworksClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsSubnetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsSubnetworkRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/TargetGrpcProxiesClient.php b/Compute/src/V1/Client/TargetGrpcProxiesClient.php index 7538d3bcbdfa..cc2aa042a081 100644 --- a/Compute/src/V1/Client/TargetGrpcProxiesClient.php +++ b/Compute/src/V1/Client/TargetGrpcProxiesClient.php @@ -24,17 +24,332 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\TargetGrpcProxiesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteTargetGrpcProxyRequest; +use Google\Cloud\Compute\V1\GetTargetGrpcProxyRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertTargetGrpcProxyRequest; +use Google\Cloud\Compute\V1\ListTargetGrpcProxiesRequest; +use Google\Cloud\Compute\V1\PatchTargetGrpcProxyRequest; +use Google\Cloud\Compute\V1\TargetGrpcProxy; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The TargetGrpcProxies API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\TargetGrpcProxiesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteTargetGrpcProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetTargetGrpcProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertTargetGrpcProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListTargetGrpcProxiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchTargetGrpcProxyRequest $request, array $optionalArgs = []) */ -final class TargetGrpcProxiesClient extends TargetGrpcProxiesBaseClient +final class TargetGrpcProxiesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TargetGrpcProxiesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.TargetGrpcProxies'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/target_grpc_proxies_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/target_grpc_proxies_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/target_grpc_proxies_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified TargetGrpcProxy in the given scope + * + * The async variant is {@see TargetGrpcProxiesClient::deleteAsync()} . + * + * @param DeleteTargetGrpcProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteTargetGrpcProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified TargetGrpcProxy resource in the given scope. + * + * The async variant is {@see TargetGrpcProxiesClient::getAsync()} . + * + * @param GetTargetGrpcProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TargetGrpcProxy + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetTargetGrpcProxyRequest $request, array $callOptions = []): TargetGrpcProxy + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a TargetGrpcProxy in the specified project in the given scope using the parameters that are included in the request. + * + * The async variant is {@see TargetGrpcProxiesClient::insertAsync()} . + * + * @param InsertTargetGrpcProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertTargetGrpcProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Lists the TargetGrpcProxies for a project in the given scope. + * + * The async variant is {@see TargetGrpcProxiesClient::listAsync()} . + * + * @param ListTargetGrpcProxiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListTargetGrpcProxiesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Patches the specified TargetGrpcProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + * + * The async variant is {@see TargetGrpcProxiesClient::patchAsync()} . + * + * @param PatchTargetGrpcProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchTargetGrpcProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/TargetHttpProxiesClient.php b/Compute/src/V1/Client/TargetHttpProxiesClient.php index d055575c1ccc..9cb312a34e57 100644 --- a/Compute/src/V1/Client/TargetHttpProxiesClient.php +++ b/Compute/src/V1/Client/TargetHttpProxiesClient.php @@ -24,17 +24,384 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\TargetHttpProxiesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListTargetHttpProxiesRequest; +use Google\Cloud\Compute\V1\DeleteTargetHttpProxyRequest; +use Google\Cloud\Compute\V1\GetTargetHttpProxyRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertTargetHttpProxyRequest; +use Google\Cloud\Compute\V1\ListTargetHttpProxiesRequest; +use Google\Cloud\Compute\V1\PatchTargetHttpProxyRequest; +use Google\Cloud\Compute\V1\SetUrlMapTargetHttpProxyRequest; +use Google\Cloud\Compute\V1\TargetHttpProxy; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The TargetHttpProxies API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\TargetHttpProxiesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListTargetHttpProxiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteTargetHttpProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetTargetHttpProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertTargetHttpProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListTargetHttpProxiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchTargetHttpProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setUrlMapAsync(SetUrlMapTargetHttpProxyRequest $request, array $optionalArgs = []) */ -final class TargetHttpProxiesClient extends TargetHttpProxiesBaseClient +final class TargetHttpProxiesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TargetHttpProxiesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.TargetHttpProxies'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/target_http_proxies_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/target_http_proxies_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/target_http_proxies_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves the list of all TargetHttpProxy resources, regional and global, available to the specified project. + * + * The async variant is {@see TargetHttpProxiesClient::aggregatedListAsync()} . + * + * @param AggregatedListTargetHttpProxiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListTargetHttpProxiesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified TargetHttpProxy resource. + * + * The async variant is {@see TargetHttpProxiesClient::deleteAsync()} . + * + * @param DeleteTargetHttpProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteTargetHttpProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified TargetHttpProxy resource. + * + * The async variant is {@see TargetHttpProxiesClient::getAsync()} . + * + * @param GetTargetHttpProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TargetHttpProxy + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetTargetHttpProxyRequest $request, array $callOptions = []): TargetHttpProxy + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a TargetHttpProxy resource in the specified project using the data included in the request. + * + * The async variant is {@see TargetHttpProxiesClient::insertAsync()} . + * + * @param InsertTargetHttpProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertTargetHttpProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of TargetHttpProxy resources available to the specified project. + * + * The async variant is {@see TargetHttpProxiesClient::listAsync()} . + * + * @param ListTargetHttpProxiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListTargetHttpProxiesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Patches the specified TargetHttpProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + * + * The async variant is {@see TargetHttpProxiesClient::patchAsync()} . + * + * @param PatchTargetHttpProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchTargetHttpProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Changes the URL map for TargetHttpProxy. + * + * The async variant is {@see TargetHttpProxiesClient::setUrlMapAsync()} . + * + * @param SetUrlMapTargetHttpProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setUrlMap(SetUrlMapTargetHttpProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetUrlMap', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/TargetHttpsProxiesClient.php b/Compute/src/V1/Client/TargetHttpsProxiesClient.php index 281d627bd5b3..6e23853dc3e2 100644 --- a/Compute/src/V1/Client/TargetHttpsProxiesClient.php +++ b/Compute/src/V1/Client/TargetHttpsProxiesClient.php @@ -24,17 +24,489 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\TargetHttpsProxiesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListTargetHttpsProxiesRequest; +use Google\Cloud\Compute\V1\DeleteTargetHttpsProxyRequest; +use Google\Cloud\Compute\V1\GetTargetHttpsProxyRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertTargetHttpsProxyRequest; +use Google\Cloud\Compute\V1\ListTargetHttpsProxiesRequest; +use Google\Cloud\Compute\V1\PatchTargetHttpsProxyRequest; +use Google\Cloud\Compute\V1\SetCertificateMapTargetHttpsProxyRequest; +use Google\Cloud\Compute\V1\SetQuicOverrideTargetHttpsProxyRequest; +use Google\Cloud\Compute\V1\SetSslCertificatesTargetHttpsProxyRequest; +use Google\Cloud\Compute\V1\SetSslPolicyTargetHttpsProxyRequest; +use Google\Cloud\Compute\V1\SetUrlMapTargetHttpsProxyRequest; +use Google\Cloud\Compute\V1\TargetHttpsProxy; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The TargetHttpsProxies API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\TargetHttpsProxiesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListTargetHttpsProxiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteTargetHttpsProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetTargetHttpsProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertTargetHttpsProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListTargetHttpsProxiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchTargetHttpsProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setCertificateMapAsync(SetCertificateMapTargetHttpsProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setQuicOverrideAsync(SetQuicOverrideTargetHttpsProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setSslCertificatesAsync(SetSslCertificatesTargetHttpsProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setSslPolicyAsync(SetSslPolicyTargetHttpsProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setUrlMapAsync(SetUrlMapTargetHttpsProxyRequest $request, array $optionalArgs = []) */ -final class TargetHttpsProxiesClient extends TargetHttpsProxiesBaseClient +final class TargetHttpsProxiesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TargetHttpsProxiesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.TargetHttpsProxies'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/target_https_proxies_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/target_https_proxies_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/target_https_proxies_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves the list of all TargetHttpsProxy resources, regional and global, available to the specified project. + * + * The async variant is {@see TargetHttpsProxiesClient::aggregatedListAsync()} . + * + * @param AggregatedListTargetHttpsProxiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListTargetHttpsProxiesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified TargetHttpsProxy resource. + * + * The async variant is {@see TargetHttpsProxiesClient::deleteAsync()} . + * + * @param DeleteTargetHttpsProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified TargetHttpsProxy resource. + * + * The async variant is {@see TargetHttpsProxiesClient::getAsync()} . + * + * @param GetTargetHttpsProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TargetHttpsProxy + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetTargetHttpsProxyRequest $request, array $callOptions = []): TargetHttpsProxy + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a TargetHttpsProxy resource in the specified project using the data included in the request. + * + * The async variant is {@see TargetHttpsProxiesClient::insertAsync()} . + * + * @param InsertTargetHttpsProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of TargetHttpsProxy resources available to the specified project. + * + * The async variant is {@see TargetHttpsProxiesClient::listAsync()} . + * + * @param ListTargetHttpsProxiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListTargetHttpsProxiesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Patches the specified TargetHttpsProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. + * + * The async variant is {@see TargetHttpsProxiesClient::patchAsync()} . + * + * @param PatchTargetHttpsProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Changes the Certificate Map for TargetHttpsProxy. + * + * The async variant is {@see TargetHttpsProxiesClient::setCertificateMapAsync()} . + * + * @param SetCertificateMapTargetHttpsProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setCertificateMap(SetCertificateMapTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetCertificateMap', $request, $callOptions)->wait(); + } + + /** + * Sets the QUIC override policy for TargetHttpsProxy. + * + * The async variant is {@see TargetHttpsProxiesClient::setQuicOverrideAsync()} . + * + * @param SetQuicOverrideTargetHttpsProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setQuicOverride(SetQuicOverrideTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetQuicOverride', $request, $callOptions)->wait(); + } + + /** + * Replaces SslCertificates for TargetHttpsProxy. + * + * The async variant is {@see TargetHttpsProxiesClient::setSslCertificatesAsync()} + * . + * + * @param SetSslCertificatesTargetHttpsProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setSslCertificates(SetSslCertificatesTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetSslCertificates', $request, $callOptions)->wait(); + } + + /** + * Sets the SSL policy for TargetHttpsProxy. The SSL policy specifies the server-side support for SSL features. This affects connections between clients and the HTTPS proxy load balancer. They do not affect the connection between the load balancer and the backends. + * + * The async variant is {@see TargetHttpsProxiesClient::setSslPolicyAsync()} . + * + * @param SetSslPolicyTargetHttpsProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setSslPolicy(SetSslPolicyTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetSslPolicy', $request, $callOptions)->wait(); + } + + /** + * Changes the URL map for TargetHttpsProxy. + * + * The async variant is {@see TargetHttpsProxiesClient::setUrlMapAsync()} . + * + * @param SetUrlMapTargetHttpsProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setUrlMap(SetUrlMapTargetHttpsProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetUrlMap', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/TargetInstancesClient.php b/Compute/src/V1/Client/TargetInstancesClient.php index 31d57ccab0da..6926cae49cc8 100644 --- a/Compute/src/V1/Client/TargetInstancesClient.php +++ b/Compute/src/V1/Client/TargetInstancesClient.php @@ -24,17 +24,333 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\TargetInstancesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListTargetInstancesRequest; +use Google\Cloud\Compute\V1\DeleteTargetInstanceRequest; +use Google\Cloud\Compute\V1\GetTargetInstanceRequest; +use Google\Cloud\Compute\V1\InsertTargetInstanceRequest; +use Google\Cloud\Compute\V1\ListTargetInstancesRequest; +use Google\Cloud\Compute\V1\TargetInstance; +use Google\Cloud\Compute\V1\ZoneOperationsClient; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The TargetInstances API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\TargetInstancesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListTargetInstancesRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteTargetInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetTargetInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertTargetInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListTargetInstancesRequest $request, array $optionalArgs = []) */ -final class TargetInstancesClient extends TargetInstancesBaseClient +final class TargetInstancesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TargetInstancesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.TargetInstances'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/target_instances_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/target_instances_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/target_instances_rest_client_config.php', + ], + ], + 'operationsClientClass' => ZoneOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an ZoneOperationsClient object with the same endpoint as $this. + * + * @return ZoneOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getZone', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves an aggregated list of target instances. + * + * The async variant is {@see TargetInstancesClient::aggregatedListAsync()} . + * + * @param AggregatedListTargetInstancesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListTargetInstancesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified TargetInstance resource. + * + * The async variant is {@see TargetInstancesClient::deleteAsync()} . + * + * @param DeleteTargetInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteTargetInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified TargetInstance resource. + * + * The async variant is {@see TargetInstancesClient::getAsync()} . + * + * @param GetTargetInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TargetInstance + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetTargetInstanceRequest $request, array $callOptions = []): TargetInstance + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a TargetInstance resource in the specified project and zone using the data included in the request. + * + * The async variant is {@see TargetInstancesClient::insertAsync()} . + * + * @param InsertTargetInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertTargetInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of TargetInstance resources available to the specified project and zone. + * + * The async variant is {@see TargetInstancesClient::listAsync()} . + * + * @param ListTargetInstancesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListTargetInstancesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } } diff --git a/Compute/src/V1/Client/TargetPoolsClient.php b/Compute/src/V1/Client/TargetPoolsClient.php index c9938a99e1d2..48887035e171 100644 --- a/Compute/src/V1/Client/TargetPoolsClient.php +++ b/Compute/src/V1/Client/TargetPoolsClient.php @@ -24,17 +24,490 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\TargetPoolsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AddHealthCheckTargetPoolRequest; +use Google\Cloud\Compute\V1\AddInstanceTargetPoolRequest; +use Google\Cloud\Compute\V1\AggregatedListTargetPoolsRequest; +use Google\Cloud\Compute\V1\DeleteTargetPoolRequest; +use Google\Cloud\Compute\V1\GetHealthTargetPoolRequest; +use Google\Cloud\Compute\V1\GetTargetPoolRequest; +use Google\Cloud\Compute\V1\InsertTargetPoolRequest; +use Google\Cloud\Compute\V1\ListTargetPoolsRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\RemoveHealthCheckTargetPoolRequest; +use Google\Cloud\Compute\V1\RemoveInstanceTargetPoolRequest; +use Google\Cloud\Compute\V1\SetBackupTargetPoolRequest; +use Google\Cloud\Compute\V1\TargetPool; +use Google\Cloud\Compute\V1\TargetPoolInstanceHealth; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The TargetPools API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\TargetPoolsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface addHealthCheckAsync(AddHealthCheckTargetPoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface addInstanceAsync(AddInstanceTargetPoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface aggregatedListAsync(AggregatedListTargetPoolsRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteTargetPoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetTargetPoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface getHealthAsync(GetHealthTargetPoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertTargetPoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListTargetPoolsRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeHealthCheckAsync(RemoveHealthCheckTargetPoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeInstanceAsync(RemoveInstanceTargetPoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface setBackupAsync(SetBackupTargetPoolRequest $request, array $optionalArgs = []) */ -final class TargetPoolsClient extends TargetPoolsBaseClient +final class TargetPoolsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TargetPoolsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.TargetPools'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/target_pools_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/target_pools_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/target_pools_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Adds health check URLs to a target pool. + * + * The async variant is {@see TargetPoolsClient::addHealthCheckAsync()} . + * + * @param AddHealthCheckTargetPoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addHealthCheck(AddHealthCheckTargetPoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddHealthCheck', $request, $callOptions)->wait(); + } + + /** + * Adds an instance to a target pool. + * + * The async variant is {@see TargetPoolsClient::addInstanceAsync()} . + * + * @param AddInstanceTargetPoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addInstance(AddInstanceTargetPoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddInstance', $request, $callOptions)->wait(); + } + + /** + * Retrieves an aggregated list of target pools. + * + * The async variant is {@see TargetPoolsClient::aggregatedListAsync()} . + * + * @param AggregatedListTargetPoolsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListTargetPoolsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified target pool. + * + * The async variant is {@see TargetPoolsClient::deleteAsync()} . + * + * @param DeleteTargetPoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteTargetPoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified target pool. + * + * The async variant is {@see TargetPoolsClient::getAsync()} . + * + * @param GetTargetPoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TargetPool + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetTargetPoolRequest $request, array $callOptions = []): TargetPool + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Gets the most recent health check results for each IP for the instance that is referenced by the given target pool. + * + * The async variant is {@see TargetPoolsClient::getHealthAsync()} . + * + * @param GetHealthTargetPoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TargetPoolInstanceHealth + * + * @throws ApiException Thrown if the API call fails. + */ + public function getHealth(GetHealthTargetPoolRequest $request, array $callOptions = []): TargetPoolInstanceHealth + { + return $this->startApiCall('GetHealth', $request, $callOptions)->wait(); + } + + /** + * Creates a target pool in the specified project and region using the data included in the request. + * + * The async variant is {@see TargetPoolsClient::insertAsync()} . + * + * @param InsertTargetPoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertTargetPoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of target pools available to the specified project and region. + * + * The async variant is {@see TargetPoolsClient::listAsync()} . + * + * @param ListTargetPoolsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListTargetPoolsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Removes health check URL from a target pool. + * + * The async variant is {@see TargetPoolsClient::removeHealthCheckAsync()} . + * + * @param RemoveHealthCheckTargetPoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeHealthCheck(RemoveHealthCheckTargetPoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RemoveHealthCheck', $request, $callOptions)->wait(); + } + + /** + * Removes instance URL from a target pool. + * + * The async variant is {@see TargetPoolsClient::removeInstanceAsync()} . + * + * @param RemoveInstanceTargetPoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeInstance(RemoveInstanceTargetPoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RemoveInstance', $request, $callOptions)->wait(); + } + + /** + * Changes a backup target pool's configurations. + * + * The async variant is {@see TargetPoolsClient::setBackupAsync()} . + * + * @param SetBackupTargetPoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setBackup(SetBackupTargetPoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetBackup', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/TargetSslProxiesClient.php b/Compute/src/V1/Client/TargetSslProxiesClient.php index 558232570dc9..f8c4b2dc2754 100644 --- a/Compute/src/V1/Client/TargetSslProxiesClient.php +++ b/Compute/src/V1/Client/TargetSslProxiesClient.php @@ -24,17 +24,436 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\TargetSslProxiesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteTargetSslProxyRequest; +use Google\Cloud\Compute\V1\GetTargetSslProxyRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertTargetSslProxyRequest; +use Google\Cloud\Compute\V1\ListTargetSslProxiesRequest; +use Google\Cloud\Compute\V1\SetBackendServiceTargetSslProxyRequest; +use Google\Cloud\Compute\V1\SetCertificateMapTargetSslProxyRequest; +use Google\Cloud\Compute\V1\SetProxyHeaderTargetSslProxyRequest; +use Google\Cloud\Compute\V1\SetSslCertificatesTargetSslProxyRequest; +use Google\Cloud\Compute\V1\SetSslPolicyTargetSslProxyRequest; +use Google\Cloud\Compute\V1\TargetSslProxy; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The TargetSslProxies API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\TargetSslProxiesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteTargetSslProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetTargetSslProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertTargetSslProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListTargetSslProxiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface setBackendServiceAsync(SetBackendServiceTargetSslProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setCertificateMapAsync(SetCertificateMapTargetSslProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setProxyHeaderAsync(SetProxyHeaderTargetSslProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setSslCertificatesAsync(SetSslCertificatesTargetSslProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setSslPolicyAsync(SetSslPolicyTargetSslProxyRequest $request, array $optionalArgs = []) */ -final class TargetSslProxiesClient extends TargetSslProxiesBaseClient +final class TargetSslProxiesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TargetSslProxiesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.TargetSslProxies'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/target_ssl_proxies_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/target_ssl_proxies_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/target_ssl_proxies_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified TargetSslProxy resource. + * + * The async variant is {@see TargetSslProxiesClient::deleteAsync()} . + * + * @param DeleteTargetSslProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteTargetSslProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified TargetSslProxy resource. + * + * The async variant is {@see TargetSslProxiesClient::getAsync()} . + * + * @param GetTargetSslProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TargetSslProxy + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetTargetSslProxyRequest $request, array $callOptions = []): TargetSslProxy + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a TargetSslProxy resource in the specified project using the data included in the request. + * + * The async variant is {@see TargetSslProxiesClient::insertAsync()} . + * + * @param InsertTargetSslProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertTargetSslProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of TargetSslProxy resources available to the specified project. + * + * The async variant is {@see TargetSslProxiesClient::listAsync()} . + * + * @param ListTargetSslProxiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListTargetSslProxiesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Changes the BackendService for TargetSslProxy. + * + * The async variant is {@see TargetSslProxiesClient::setBackendServiceAsync()} . + * + * @param SetBackendServiceTargetSslProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setBackendService(SetBackendServiceTargetSslProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetBackendService', $request, $callOptions)->wait(); + } + + /** + * Changes the Certificate Map for TargetSslProxy. + * + * The async variant is {@see TargetSslProxiesClient::setCertificateMapAsync()} . + * + * @param SetCertificateMapTargetSslProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setCertificateMap(SetCertificateMapTargetSslProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetCertificateMap', $request, $callOptions)->wait(); + } + + /** + * Changes the ProxyHeaderType for TargetSslProxy. + * + * The async variant is {@see TargetSslProxiesClient::setProxyHeaderAsync()} . + * + * @param SetProxyHeaderTargetSslProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setProxyHeader(SetProxyHeaderTargetSslProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetProxyHeader', $request, $callOptions)->wait(); + } + + /** + * Changes SslCertificates for TargetSslProxy. + * + * The async variant is {@see TargetSslProxiesClient::setSslCertificatesAsync()} . + * + * @param SetSslCertificatesTargetSslProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setSslCertificates(SetSslCertificatesTargetSslProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetSslCertificates', $request, $callOptions)->wait(); + } + + /** + * Sets the SSL policy for TargetSslProxy. The SSL policy specifies the server-side support for SSL features. This affects connections between clients and the SSL proxy load balancer. They do not affect the connection between the load balancer and the backends. + * + * The async variant is {@see TargetSslProxiesClient::setSslPolicyAsync()} . + * + * @param SetSslPolicyTargetSslProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setSslPolicy(SetSslPolicyTargetSslProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetSslPolicy', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/TargetTcpProxiesClient.php b/Compute/src/V1/Client/TargetTcpProxiesClient.php index 2b7bf36a5bd2..cd0e7f32a9b2 100644 --- a/Compute/src/V1/Client/TargetTcpProxiesClient.php +++ b/Compute/src/V1/Client/TargetTcpProxiesClient.php @@ -24,17 +24,384 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\TargetTcpProxiesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListTargetTcpProxiesRequest; +use Google\Cloud\Compute\V1\DeleteTargetTcpProxyRequest; +use Google\Cloud\Compute\V1\GetTargetTcpProxyRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertTargetTcpProxyRequest; +use Google\Cloud\Compute\V1\ListTargetTcpProxiesRequest; +use Google\Cloud\Compute\V1\SetBackendServiceTargetTcpProxyRequest; +use Google\Cloud\Compute\V1\SetProxyHeaderTargetTcpProxyRequest; +use Google\Cloud\Compute\V1\TargetTcpProxy; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The TargetTcpProxies API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\TargetTcpProxiesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListTargetTcpProxiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteTargetTcpProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetTargetTcpProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertTargetTcpProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListTargetTcpProxiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface setBackendServiceAsync(SetBackendServiceTargetTcpProxyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setProxyHeaderAsync(SetProxyHeaderTargetTcpProxyRequest $request, array $optionalArgs = []) */ -final class TargetTcpProxiesClient extends TargetTcpProxiesBaseClient +final class TargetTcpProxiesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TargetTcpProxiesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.TargetTcpProxies'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/target_tcp_proxies_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/target_tcp_proxies_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/target_tcp_proxies_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves the list of all TargetTcpProxy resources, regional and global, available to the specified project. + * + * The async variant is {@see TargetTcpProxiesClient::aggregatedListAsync()} . + * + * @param AggregatedListTargetTcpProxiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListTargetTcpProxiesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified TargetTcpProxy resource. + * + * The async variant is {@see TargetTcpProxiesClient::deleteAsync()} . + * + * @param DeleteTargetTcpProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteTargetTcpProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified TargetTcpProxy resource. + * + * The async variant is {@see TargetTcpProxiesClient::getAsync()} . + * + * @param GetTargetTcpProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TargetTcpProxy + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetTargetTcpProxyRequest $request, array $callOptions = []): TargetTcpProxy + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a TargetTcpProxy resource in the specified project using the data included in the request. + * + * The async variant is {@see TargetTcpProxiesClient::insertAsync()} . + * + * @param InsertTargetTcpProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertTargetTcpProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of TargetTcpProxy resources available to the specified project. + * + * The async variant is {@see TargetTcpProxiesClient::listAsync()} . + * + * @param ListTargetTcpProxiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListTargetTcpProxiesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Changes the BackendService for TargetTcpProxy. + * + * The async variant is {@see TargetTcpProxiesClient::setBackendServiceAsync()} . + * + * @param SetBackendServiceTargetTcpProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setBackendService(SetBackendServiceTargetTcpProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetBackendService', $request, $callOptions)->wait(); + } + + /** + * Changes the ProxyHeaderType for TargetTcpProxy. + * + * The async variant is {@see TargetTcpProxiesClient::setProxyHeaderAsync()} . + * + * @param SetProxyHeaderTargetTcpProxyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setProxyHeader(SetProxyHeaderTargetTcpProxyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetProxyHeader', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/TargetVpnGatewaysClient.php b/Compute/src/V1/Client/TargetVpnGatewaysClient.php index 50d9901bb847..2c860c20ee4a 100644 --- a/Compute/src/V1/Client/TargetVpnGatewaysClient.php +++ b/Compute/src/V1/Client/TargetVpnGatewaysClient.php @@ -24,17 +24,359 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\TargetVpnGatewaysBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListTargetVpnGatewaysRequest; +use Google\Cloud\Compute\V1\DeleteTargetVpnGatewayRequest; +use Google\Cloud\Compute\V1\GetTargetVpnGatewayRequest; +use Google\Cloud\Compute\V1\InsertTargetVpnGatewayRequest; +use Google\Cloud\Compute\V1\ListTargetVpnGatewaysRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\SetLabelsTargetVpnGatewayRequest; +use Google\Cloud\Compute\V1\TargetVpnGateway; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The TargetVpnGateways API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\TargetVpnGatewaysClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListTargetVpnGatewaysRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteTargetVpnGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetTargetVpnGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertTargetVpnGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListTargetVpnGatewaysRequest $request, array $optionalArgs = []) + * @method PromiseInterface setLabelsAsync(SetLabelsTargetVpnGatewayRequest $request, array $optionalArgs = []) */ -final class TargetVpnGatewaysClient extends TargetVpnGatewaysBaseClient +final class TargetVpnGatewaysClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TargetVpnGatewaysBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.TargetVpnGateways'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/target_vpn_gateways_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/target_vpn_gateways_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/target_vpn_gateways_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves an aggregated list of target VPN gateways. + * + * The async variant is {@see TargetVpnGatewaysClient::aggregatedListAsync()} . + * + * @param AggregatedListTargetVpnGatewaysRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListTargetVpnGatewaysRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified target VPN gateway. + * + * The async variant is {@see TargetVpnGatewaysClient::deleteAsync()} . + * + * @param DeleteTargetVpnGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteTargetVpnGatewayRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified target VPN gateway. + * + * The async variant is {@see TargetVpnGatewaysClient::getAsync()} . + * + * @param GetTargetVpnGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TargetVpnGateway + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetTargetVpnGatewayRequest $request, array $callOptions = []): TargetVpnGateway + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a target VPN gateway in the specified project and region using the data included in the request. + * + * The async variant is {@see TargetVpnGatewaysClient::insertAsync()} . + * + * @param InsertTargetVpnGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertTargetVpnGatewayRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of target VPN gateways available to the specified project and region. + * + * The async variant is {@see TargetVpnGatewaysClient::listAsync()} . + * + * @param ListTargetVpnGatewaysRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListTargetVpnGatewaysRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Sets the labels on a TargetVpnGateway. To learn more about labels, read the Labeling Resources documentation. + * + * The async variant is {@see TargetVpnGatewaysClient::setLabelsAsync()} . + * + * @param SetLabelsTargetVpnGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setLabels(SetLabelsTargetVpnGatewayRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/UrlMapsClient.php b/Compute/src/V1/Client/UrlMapsClient.php index b64ecda13d75..6e4e8f69e5f9 100644 --- a/Compute/src/V1/Client/UrlMapsClient.php +++ b/Compute/src/V1/Client/UrlMapsClient.php @@ -24,17 +24,437 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\UrlMapsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListUrlMapsRequest; +use Google\Cloud\Compute\V1\DeleteUrlMapRequest; +use Google\Cloud\Compute\V1\GetUrlMapRequest; +use Google\Cloud\Compute\V1\GlobalOperationsClient; +use Google\Cloud\Compute\V1\InsertUrlMapRequest; +use Google\Cloud\Compute\V1\InvalidateCacheUrlMapRequest; +use Google\Cloud\Compute\V1\ListUrlMapsRequest; +use Google\Cloud\Compute\V1\PatchUrlMapRequest; +use Google\Cloud\Compute\V1\UpdateUrlMapRequest; +use Google\Cloud\Compute\V1\UrlMap; +use Google\Cloud\Compute\V1\UrlMapsValidateResponse; +use Google\Cloud\Compute\V1\ValidateUrlMapRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The UrlMaps API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\UrlMapsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListUrlMapsRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteUrlMapRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetUrlMapRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertUrlMapRequest $request, array $optionalArgs = []) + * @method PromiseInterface invalidateCacheAsync(InvalidateCacheUrlMapRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListUrlMapsRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(PatchUrlMapRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAsync(UpdateUrlMapRequest $request, array $optionalArgs = []) + * @method PromiseInterface validateAsync(ValidateUrlMapRequest $request, array $optionalArgs = []) */ -final class UrlMapsClient extends UrlMapsBaseClient +final class UrlMapsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see UrlMapsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.UrlMaps'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/url_maps_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/url_maps_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/url_maps_rest_client_config.php', + ], + ], + 'operationsClientClass' => GlobalOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an GlobalOperationsClient object with the same endpoint as $this. + * + * @return GlobalOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves the list of all UrlMap resources, regional and global, available to the specified project. + * + * The async variant is {@see UrlMapsClient::aggregatedListAsync()} . + * + * @param AggregatedListUrlMapsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListUrlMapsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified UrlMap resource. + * + * The async variant is {@see UrlMapsClient::deleteAsync()} . + * + * @param DeleteUrlMapRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteUrlMapRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified UrlMap resource. + * + * The async variant is {@see UrlMapsClient::getAsync()} . + * + * @param GetUrlMapRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 UrlMap + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetUrlMapRequest $request, array $callOptions = []): UrlMap + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a UrlMap resource in the specified project using the data included in the request. + * + * The async variant is {@see UrlMapsClient::insertAsync()} . + * + * @param InsertUrlMapRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertUrlMapRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Initiates a cache invalidation operation, invalidating the specified path, scoped to the specified UrlMap. For more information, see [Invalidating cached content](https://cloud.google.com/cdn/docs/invalidating-cached-content). + * + * The async variant is {@see UrlMapsClient::invalidateCacheAsync()} . + * + * @param InvalidateCacheUrlMapRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function invalidateCache(InvalidateCacheUrlMapRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('InvalidateCache', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of UrlMap resources available to the specified project. + * + * The async variant is {@see UrlMapsClient::listAsync()} . + * + * @param ListUrlMapsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListUrlMapsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Patches the specified UrlMap resource with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. + * + * The async variant is {@see UrlMapsClient::patchAsync()} . + * + * @param PatchUrlMapRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(PatchUrlMapRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Updates the specified UrlMap resource with the data included in the request. + * + * The async variant is {@see UrlMapsClient::updateAsync()} . + * + * @param UpdateUrlMapRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function update(UpdateUrlMapRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Update', $request, $callOptions)->wait(); + } + + /** + * Runs static validation for the UrlMap. In particular, the tests of the provided UrlMap will be run. Calling this method does NOT create the UrlMap. + * + * The async variant is {@see UrlMapsClient::validateAsync()} . + * + * @param ValidateUrlMapRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 UrlMapsValidateResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function validate(ValidateUrlMapRequest $request, array $callOptions = []): UrlMapsValidateResponse + { + return $this->startApiCall('Validate', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/VpnGatewaysClient.php b/Compute/src/V1/Client/VpnGatewaysClient.php index 303d111d6c7a..94962eb020fd 100644 --- a/Compute/src/V1/Client/VpnGatewaysClient.php +++ b/Compute/src/V1/Client/VpnGatewaysClient.php @@ -24,17 +24,413 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\VpnGatewaysBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListVpnGatewaysRequest; +use Google\Cloud\Compute\V1\DeleteVpnGatewayRequest; +use Google\Cloud\Compute\V1\GetStatusVpnGatewayRequest; +use Google\Cloud\Compute\V1\GetVpnGatewayRequest; +use Google\Cloud\Compute\V1\InsertVpnGatewayRequest; +use Google\Cloud\Compute\V1\ListVpnGatewaysRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\SetLabelsVpnGatewayRequest; +use Google\Cloud\Compute\V1\TestIamPermissionsVpnGatewayRequest; +use Google\Cloud\Compute\V1\TestPermissionsResponse; +use Google\Cloud\Compute\V1\VpnGateway; +use Google\Cloud\Compute\V1\VpnGatewaysGetStatusResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The VpnGateways API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\VpnGatewaysClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListVpnGatewaysRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteVpnGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetVpnGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface getStatusAsync(GetStatusVpnGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertVpnGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListVpnGatewaysRequest $request, array $optionalArgs = []) + * @method PromiseInterface setLabelsAsync(SetLabelsVpnGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsVpnGatewayRequest $request, array $optionalArgs = []) */ -final class VpnGatewaysClient extends VpnGatewaysBaseClient +final class VpnGatewaysClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see VpnGatewaysBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.VpnGateways'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/vpn_gateways_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/vpn_gateways_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/vpn_gateways_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves an aggregated list of VPN gateways. + * + * The async variant is {@see VpnGatewaysClient::aggregatedListAsync()} . + * + * @param AggregatedListVpnGatewaysRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListVpnGatewaysRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified VPN gateway. + * + * The async variant is {@see VpnGatewaysClient::deleteAsync()} . + * + * @param DeleteVpnGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteVpnGatewayRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified VPN gateway. + * + * The async variant is {@see VpnGatewaysClient::getAsync()} . + * + * @param GetVpnGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 VpnGateway + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetVpnGatewayRequest $request, array $callOptions = []): VpnGateway + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Returns the status for the specified VPN gateway. + * + * The async variant is {@see VpnGatewaysClient::getStatusAsync()} . + * + * @param GetStatusVpnGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 VpnGatewaysGetStatusResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function getStatus(GetStatusVpnGatewayRequest $request, array $callOptions = []): VpnGatewaysGetStatusResponse + { + return $this->startApiCall('GetStatus', $request, $callOptions)->wait(); + } + + /** + * Creates a VPN gateway in the specified project and region using the data included in the request. + * + * The async variant is {@see VpnGatewaysClient::insertAsync()} . + * + * @param InsertVpnGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertVpnGatewayRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of VPN gateways available to the specified project and region. + * + * The async variant is {@see VpnGatewaysClient::listAsync()} . + * + * @param ListVpnGatewaysRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListVpnGatewaysRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Sets the labels on a VpnGateway. To learn more about labels, read the Labeling Resources documentation. + * + * The async variant is {@see VpnGatewaysClient::setLabelsAsync()} . + * + * @param SetLabelsVpnGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setLabels(SetLabelsVpnGatewayRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. + * + * The async variant is {@see VpnGatewaysClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsVpnGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsVpnGatewayRequest $request, array $callOptions = []): TestPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/VpnTunnelsClient.php b/Compute/src/V1/Client/VpnTunnelsClient.php index 9fe0ab41fbc1..b50e2bb9a2dc 100644 --- a/Compute/src/V1/Client/VpnTunnelsClient.php +++ b/Compute/src/V1/Client/VpnTunnelsClient.php @@ -24,17 +24,359 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\VpnTunnelsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\AggregatedListVpnTunnelsRequest; +use Google\Cloud\Compute\V1\DeleteVpnTunnelRequest; +use Google\Cloud\Compute\V1\GetVpnTunnelRequest; +use Google\Cloud\Compute\V1\InsertVpnTunnelRequest; +use Google\Cloud\Compute\V1\ListVpnTunnelsRequest; +use Google\Cloud\Compute\V1\RegionOperationsClient; +use Google\Cloud\Compute\V1\SetLabelsVpnTunnelRequest; +use Google\Cloud\Compute\V1\VpnTunnel; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The VpnTunnels API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\VpnTunnelsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface aggregatedListAsync(AggregatedListVpnTunnelsRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(DeleteVpnTunnelRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetVpnTunnelRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(InsertVpnTunnelRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListVpnTunnelsRequest $request, array $optionalArgs = []) + * @method PromiseInterface setLabelsAsync(SetLabelsVpnTunnelRequest $request, array $optionalArgs = []) */ -final class VpnTunnelsClient extends VpnTunnelsBaseClient +final class VpnTunnelsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see VpnTunnelsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.VpnTunnels'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/vpn_tunnels_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/vpn_tunnels_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/vpn_tunnels_rest_client_config.php', + ], + ], + 'operationsClientClass' => RegionOperationsClient::class, + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * Return an RegionOperationsClient object with the same endpoint as $this. + * + * @return RegionOperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** Return the default longrunning operation descriptor config. */ + private function getDefaultOperationDescriptor() + { + return [ + 'additionalArgumentMethods' => [ + 'getProject', + 'getRegion', + ], + 'getOperationMethod' => 'get', + 'cancelOperationMethod' => null, + 'deleteOperationMethod' => 'delete', + 'operationErrorCodeMethod' => 'getHttpErrorStatusCode', + 'operationErrorMessageMethod' => 'getHttpErrorMessage', + 'operationNameMethod' => 'getName', + 'operationStatusMethod' => 'getStatus', + 'operationStatusDoneValue' => \Google\Cloud\Compute\V1\Operation\Status::DONE, + ]; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : $this->getDefaultOperationDescriptor(); + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves an aggregated list of VPN tunnels. + * + * The async variant is {@see VpnTunnelsClient::aggregatedListAsync()} . + * + * @param AggregatedListVpnTunnelsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregatedList(AggregatedListVpnTunnelsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedList', $request, $callOptions); + } + + /** + * Deletes the specified VpnTunnel resource. + * + * The async variant is {@see VpnTunnelsClient::deleteAsync()} . + * + * @param DeleteVpnTunnelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteVpnTunnelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Returns the specified VpnTunnel resource. + * + * The async variant is {@see VpnTunnelsClient::getAsync()} . + * + * @param GetVpnTunnelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 VpnTunnel + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetVpnTunnelRequest $request, array $callOptions = []): VpnTunnel + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a VpnTunnel resource in the specified project and region using the data included in the request. + * + * The async variant is {@see VpnTunnelsClient::insertAsync()} . + * + * @param InsertVpnTunnelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(InsertVpnTunnelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of VpnTunnel resources contained in the specified project and region. + * + * The async variant is {@see VpnTunnelsClient::listAsync()} . + * + * @param ListVpnTunnelsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListVpnTunnelsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Sets the labels on a VpnTunnel. To learn more about labels, read the Labeling Resources documentation. + * + * The async variant is {@see VpnTunnelsClient::setLabelsAsync()} . + * + * @param SetLabelsVpnTunnelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setLabels(SetLabelsVpnTunnelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/ZoneOperationsClient.php b/Compute/src/V1/Client/ZoneOperationsClient.php index 69ef338df67c..6e64d9564baa 100644 --- a/Compute/src/V1/Client/ZoneOperationsClient.php +++ b/Compute/src/V1/Client/ZoneOperationsClient.php @@ -24,17 +24,254 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\ZoneOperationsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\DeleteZoneOperationRequest; +use Google\Cloud\Compute\V1\DeleteZoneOperationResponse; +use Google\Cloud\Compute\V1\GetZoneOperationRequest; +use Google\Cloud\Compute\V1\ListZoneOperationsRequest; +use Google\Cloud\Compute\V1\Operation; +use Google\Cloud\Compute\V1\WaitZoneOperationRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The ZoneOperations API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\ZoneOperationsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface deleteAsync(DeleteZoneOperationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(GetZoneOperationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListZoneOperationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface waitAsync(WaitZoneOperationRequest $request, array $optionalArgs = []) */ -final class ZoneOperationsClient extends ZoneOperationsBaseClient +final class ZoneOperationsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ZoneOperationsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.ZoneOperations'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/zone_operations_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/zone_operations_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/zone_operations_rest_client_config.php', + ], + ], + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified zone-specific Operations resource. + * + * The async variant is {@see ZoneOperationsClient::deleteAsync()} . + * + * @param DeleteZoneOperationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DeleteZoneOperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(DeleteZoneOperationRequest $request, array $callOptions = []): DeleteZoneOperationResponse + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified zone-specific Operations resource. + * + * The async variant is {@see ZoneOperationsClient::getAsync()} . + * + * @param GetZoneOperationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetZoneOperationRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of Operation resources contained within the specified zone. + * + * The async variant is {@see ZoneOperationsClient::listAsync()} . + * + * @param ListZoneOperationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListZoneOperationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } + + /** + * Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method waits for no more than the 2 minutes and then returns the current state of the operation, which might be `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`. + * + * The async variant is {@see ZoneOperationsClient::waitAsync()} . + * + * @param WaitZoneOperationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function wait(WaitZoneOperationRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Wait', $request, $callOptions)->wait(); + } } diff --git a/Compute/src/V1/Client/ZonesClient.php b/Compute/src/V1/Client/ZonesClient.php index a03410208b5f..d5e8e4a9c272 100644 --- a/Compute/src/V1/Client/ZonesClient.php +++ b/Compute/src/V1/Client/ZonesClient.php @@ -24,17 +24,202 @@ namespace Google\Cloud\Compute\V1\Client; -use Google\Cloud\Compute\V1\Client\BaseClient\ZonesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Compute\V1\GetZoneRequest; +use Google\Cloud\Compute\V1\ListZonesRequest; +use Google\Cloud\Compute\V1\Zone; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Zones API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Compute\V1\ZonesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface getAsync(GetZoneRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(ListZonesRequest $request, array $optionalArgs = []) */ -final class ZonesClient extends ZonesBaseClient +final class ZonesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ZonesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.compute.v1.Zones'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'compute.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/compute.readonly', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/zones_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/zones_descriptor_config.php', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + 'useJwtAccessWithScope' => false, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/zones_rest_client_config.php', + ], + ], + ]; + } + + /** Implements GapicClientTrait::defaultTransport. */ + private static function defaultTransport() + { + return 'rest'; + } + + /** Implements GapicClientTrait::getSupportedTransports. */ + private static function getSupportedTransports() + { + return [ + 'rest', + ]; + } + + /** + * 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 'compute.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. At the moment, supports only + * `rest`. *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 = [ + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\RestTransport::build()} method 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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Returns the specified Zone resource. + * + * The async variant is {@see ZonesClient::getAsync()} . + * + * @param GetZoneRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Zone + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(GetZoneRequest $request, array $callOptions = []): Zone + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Retrieves the list of Zone resources available to the specified project. + * + * The async variant is {@see ZonesClient::listAsync()} . + * + * @param ListZonesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(ListZonesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('List', $request, $callOptions); + } } diff --git a/ConfidentialComputing/composer.json b/ConfidentialComputing/composer.json index 7d7ee964c9e0..03d769d00d69 100644 --- a/ConfidentialComputing/composer.json +++ b/ConfidentialComputing/composer.json @@ -18,7 +18,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/ConfidentialComputing/src/V1/Client/BaseClient/ConfidentialComputingBaseClient.php b/ConfidentialComputing/src/V1/Client/BaseClient/ConfidentialComputingBaseClient.php deleted file mode 100644 index 3737d6c0332a..000000000000 --- a/ConfidentialComputing/src/V1/Client/BaseClient/ConfidentialComputingBaseClient.php +++ /dev/null @@ -1,345 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/confidential_computing_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/confidential_computing_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/confidential_computing_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/confidential_computing_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a challenge - * resource. - * - * @param string $project - * @param string $location - * @param string $uuid - * - * @return string The formatted challenge resource. - */ - public static function challengeName(string $project, string $location, string $uuid): string - { - return self::getPathTemplate('challenge')->render([ - 'project' => $project, - 'location' => $location, - 'uuid' => $uuid, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - challenge: projects/{project}/locations/{location}/challenges/{uuid} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'confidentialcomputing.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new Challenge in a given project and location. - * - * The async variant is {@see self::createChallengeAsync()} . - * - * @example samples/V1/ConfidentialComputingClient/create_challenge.php - * - * @param CreateChallengeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Challenge - * - * @throws ApiException Thrown if the API call fails. - */ - public function createChallenge(CreateChallengeRequest $request, array $callOptions = []): Challenge - { - return $this->startApiCall('CreateChallenge', $request, $callOptions)->wait(); - } - - /** - * Verifies the provided attestation info, returning a signed OIDC token. - * - * The async variant is {@see self::verifyAttestationAsync()} . - * - * @example samples/V1/ConfidentialComputingClient/verify_attestation.php - * - * @param VerifyAttestationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 VerifyAttestationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function verifyAttestation(VerifyAttestationRequest $request, array $callOptions = []): VerifyAttestationResponse - { - return $this->startApiCall('VerifyAttestation', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/ConfidentialComputingClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/ConfidentialComputingClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/ConfidentialComputing/src/V1/Client/ConfidentialComputingClient.php b/ConfidentialComputing/src/V1/Client/ConfidentialComputingClient.php index 0a044437a9be..930aa31fdf1f 100644 --- a/ConfidentialComputing/src/V1/Client/ConfidentialComputingClient.php +++ b/ConfidentialComputing/src/V1/Client/ConfidentialComputingClient.php @@ -24,17 +24,322 @@ namespace Google\Cloud\ConfidentialComputing\V1\Client; -use Google\Cloud\ConfidentialComputing\V1\Client\BaseClient\ConfidentialComputingBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\ConfidentialComputing\V1\Challenge; +use Google\Cloud\ConfidentialComputing\V1\CreateChallengeRequest; +use Google\Cloud\ConfidentialComputing\V1\VerifyAttestationRequest; +use Google\Cloud\ConfidentialComputing\V1\VerifyAttestationResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service describing handlers for resources * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ConfidentialComputing\V1\ConfidentialComputingClient} for the + * stable implementation * * @experimental + * + * @method PromiseInterface createChallengeAsync(CreateChallengeRequest $request, array $optionalArgs = []) + * @method PromiseInterface verifyAttestationAsync(VerifyAttestationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class ConfidentialComputingClient extends ConfidentialComputingBaseClient +final class ConfidentialComputingClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ConfidentialComputingBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.confidentialcomputing.v1.ConfidentialComputing'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'confidentialcomputing.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/confidential_computing_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/confidential_computing_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/confidential_computing_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/confidential_computing_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a challenge + * resource. + * + * @param string $project + * @param string $location + * @param string $uuid + * + * @return string The formatted challenge resource. + */ + public static function challengeName(string $project, string $location, string $uuid): string + { + return self::getPathTemplate('challenge')->render([ + 'project' => $project, + 'location' => $location, + 'uuid' => $uuid, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - challenge: projects/{project}/locations/{location}/challenges/{uuid} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'confidentialcomputing.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new Challenge in a given project and location. + * + * The async variant is {@see ConfidentialComputingClient::createChallengeAsync()} + * . + * + * @example samples/V1/ConfidentialComputingClient/create_challenge.php + * + * @param CreateChallengeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Challenge + * + * @throws ApiException Thrown if the API call fails. + */ + public function createChallenge(CreateChallengeRequest $request, array $callOptions = []): Challenge + { + return $this->startApiCall('CreateChallenge', $request, $callOptions)->wait(); + } + + /** + * Verifies the provided attestation info, returning a signed OIDC token. + * + * The async variant is + * {@see ConfidentialComputingClient::verifyAttestationAsync()} . + * + * @example samples/V1/ConfidentialComputingClient/verify_attestation.php + * + * @param VerifyAttestationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 VerifyAttestationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function verifyAttestation(VerifyAttestationRequest $request, array $callOptions = []): VerifyAttestationResponse + { + return $this->startApiCall('VerifyAttestation', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see ConfidentialComputingClient::getLocationAsync()} . + * + * @example samples/V1/ConfidentialComputingClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see ConfidentialComputingClient::listLocationsAsync()} . + * + * @example samples/V1/ConfidentialComputingClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Config/composer.json b/Config/composer.json index f2ca51cc16fd..05ce625d7868 100644 --- a/Config/composer.json +++ b/Config/composer.json @@ -18,7 +18,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.22.0" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Config/src/V1/Client/BaseClient/ConfigBaseClient.php b/Config/src/V1/Client/BaseClient/ConfigBaseClient.php deleted file mode 100644 index fff221ff74f2..000000000000 --- a/Config/src/V1/Client/BaseClient/ConfigBaseClient.php +++ /dev/null @@ -1,1098 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . '/../../resources/config_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . '/../../resources/config_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . '/../../resources/config_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../../resources/config_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; - $operation = new OperationResponse( - $operationName, - $this->getOperationsClient(), - $options - ); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a deployment - * resource. - * - * @param string $project - * @param string $location - * @param string $deployment - * - * @return string The formatted deployment resource. - */ - public static function deploymentName( - string $project, - string $location, - string $deployment - ): string { - return self::getPathTemplate('deployment')->render([ - 'project' => $project, - 'location' => $location, - 'deployment' => $deployment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName( - string $project, - string $location - ): string { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a resource - * resource. - * - * @param string $project - * @param string $location - * @param string $deployment - * @param string $revision - * @param string $resource - * - * @return string The formatted resource resource. - */ - public static function resourceName( - string $project, - string $location, - string $deployment, - string $revision, - string $resource - ): string { - return self::getPathTemplate('resource')->render([ - 'project' => $project, - 'location' => $location, - 'deployment' => $deployment, - 'revision' => $revision, - 'resource' => $resource, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a revision - * resource. - * - * @param string $project - * @param string $location - * @param string $deployment - * @param string $revision - * - * @return string The formatted revision resource. - */ - public static function revisionName( - string $project, - string $location, - string $deployment, - string $revision - ): string { - return self::getPathTemplate('revision')->render([ - 'project' => $project, - 'location' => $location, - 'deployment' => $deployment, - 'revision' => $revision, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * service_account resource. - * - * @param string $project - * @param string $serviceAccount - * - * @return string The formatted service_account resource. - */ - public static function serviceAccountName( - string $project, - string $serviceAccount - ): string { - return self::getPathTemplate('serviceAccount')->render([ - 'project' => $project, - 'service_account' => $serviceAccount, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a worker_pool - * resource. - * - * @param string $project - * @param string $location - * @param string $workerPool - * - * @return string The formatted worker_pool resource. - */ - public static function workerPoolName( - string $project, - string $location, - string $workerPool - ): string { - return self::getPathTemplate('workerPool')->render([ - 'project' => $project, - 'location' => $location, - 'worker_pool' => $workerPool, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - deployment: projects/{project}/locations/{location}/deployments/{deployment} - * - location: projects/{project}/locations/{location} - * - resource: projects/{project}/locations/{location}/deployments/{deployment}/revisions/{revision}/resources/{resource} - * - revision: projects/{project}/locations/{location}/deployments/{deployment}/revisions/{revision} - * - serviceAccount: projects/{project}/serviceAccounts/{service_account} - * - workerPool: projects/{project}/locations/{location}/workerPools/{worker_pool} - * - * 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( - string $formattedName, - string $template = null - ): array { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'config.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error( - 'Call to undefined method ' . __CLASS__ . "::$method()", - E_USER_ERROR - ); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a [Deployment][google.cloud.config.v1.Deployment]. - * - * The async variant is {@see self::createDeploymentAsync()} . - * - * @example samples/V1/ConfigClient/create_deployment.php - * - * @param CreateDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDeployment( - CreateDeploymentRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'CreateDeployment', - $request, - $callOptions - )->wait(); - } - - /** - * Deletes a [Deployment][google.cloud.config.v1.Deployment]. - * - * The async variant is {@see self::deleteDeploymentAsync()} . - * - * @example samples/V1/ConfigClient/delete_deployment.php - * - * @param DeleteDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDeployment( - DeleteDeploymentRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'DeleteDeployment', - $request, - $callOptions - )->wait(); - } - - /** - * Deletes Terraform state file in a given deployment. - * - * The async variant is {@see self::deleteStatefileAsync()} . - * - * @example samples/V1/ConfigClient/delete_statefile.php - * - * @param DeleteStatefileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteStatefile( - DeleteStatefileRequest $request, - array $callOptions = [] - ): void { - $this->startApiCall('DeleteStatefile', $request, $callOptions)->wait(); - } - - /** - * Exports Terraform state file from a given deployment. - * - * The async variant is {@see self::exportDeploymentStatefileAsync()} . - * - * @example samples/V1/ConfigClient/export_deployment_statefile.php - * - * @param ExportDeploymentStatefileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Statefile - * - * @throws ApiException Thrown if the API call fails. - */ - public function exportDeploymentStatefile( - ExportDeploymentStatefileRequest $request, - array $callOptions = [] - ): Statefile { - return $this->startApiCall( - 'ExportDeploymentStatefile', - $request, - $callOptions - )->wait(); - } - - /** - * Exports the lock info on a locked deployment. - * - * The async variant is {@see self::exportLockInfoAsync()} . - * - * @example samples/V1/ConfigClient/export_lock_info.php - * - * @param ExportLockInfoRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LockInfo - * - * @throws ApiException Thrown if the API call fails. - */ - public function exportLockInfo( - ExportLockInfoRequest $request, - array $callOptions = [] - ): LockInfo { - return $this->startApiCall( - 'ExportLockInfo', - $request, - $callOptions - )->wait(); - } - - /** - * Exports Terraform state file from a given revision. - * - * The async variant is {@see self::exportRevisionStatefileAsync()} . - * - * @example samples/V1/ConfigClient/export_revision_statefile.php - * - * @param ExportRevisionStatefileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Statefile - * - * @throws ApiException Thrown if the API call fails. - */ - public function exportRevisionStatefile( - ExportRevisionStatefileRequest $request, - array $callOptions = [] - ): Statefile { - return $this->startApiCall( - 'ExportRevisionStatefile', - $request, - $callOptions - )->wait(); - } - - /** - * Gets details about a [Deployment][google.cloud.config.v1.Deployment]. - * - * The async variant is {@see self::getDeploymentAsync()} . - * - * @example samples/V1/ConfigClient/get_deployment.php - * - * @param GetDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Deployment - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDeployment( - GetDeploymentRequest $request, - array $callOptions = [] - ): Deployment { - return $this->startApiCall( - 'GetDeployment', - $request, - $callOptions - )->wait(); - } - - /** - * Gets details about a [Resource][google.cloud.config.v1.Resource] deployed - * by Infra Manager. - * - * The async variant is {@see self::getResourceAsync()} . - * - * @example samples/V1/ConfigClient/get_resource.php - * - * @param GetResourceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Resource - * - * @throws ApiException Thrown if the API call fails. - */ - public function getResource( - GetResourceRequest $request, - array $callOptions = [] - ): Resource { - return $this->startApiCall( - 'GetResource', - $request, - $callOptions - )->wait(); - } - - /** - * Gets details about a [Revision][google.cloud.config.v1.Revision]. - * - * The async variant is {@see self::getRevisionAsync()} . - * - * @example samples/V1/ConfigClient/get_revision.php - * - * @param GetRevisionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Revision - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRevision( - GetRevisionRequest $request, - array $callOptions = [] - ): Revision { - return $this->startApiCall( - 'GetRevision', - $request, - $callOptions - )->wait(); - } - - /** - * Imports Terraform state file in a given deployment. The state file does not - * take effect until the Deployment has been unlocked. - * - * The async variant is {@see self::importStatefileAsync()} . - * - * @example samples/V1/ConfigClient/import_statefile.php - * - * @param ImportStatefileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Statefile - * - * @throws ApiException Thrown if the API call fails. - */ - public function importStatefile( - ImportStatefileRequest $request, - array $callOptions = [] - ): Statefile { - return $this->startApiCall( - 'ImportStatefile', - $request, - $callOptions - )->wait(); - } - - /** - * Lists [Deployment][google.cloud.config.v1.Deployment]s in a given project - * and location. - * - * The async variant is {@see self::listDeploymentsAsync()} . - * - * @example samples/V1/ConfigClient/list_deployments.php - * - * @param ListDeploymentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDeployments( - ListDeploymentsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListDeployments', $request, $callOptions); - } - - /** - * Lists [Resource][google.cloud.config.v1.Resource]s in a given revision. - * - * The async variant is {@see self::listResourcesAsync()} . - * - * @example samples/V1/ConfigClient/list_resources.php - * - * @param ListResourcesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listResources( - ListResourcesRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListResources', $request, $callOptions); - } - - /** - * Lists [Revision][google.cloud.config.v1.Revision]s of a deployment. - * - * The async variant is {@see self::listRevisionsAsync()} . - * - * @example samples/V1/ConfigClient/list_revisions.php - * - * @param ListRevisionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listRevisions( - ListRevisionsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListRevisions', $request, $callOptions); - } - - /** - * Locks a deployment. - * - * The async variant is {@see self::lockDeploymentAsync()} . - * - * @example samples/V1/ConfigClient/lock_deployment.php - * - * @param LockDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function lockDeployment( - LockDeploymentRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'LockDeployment', - $request, - $callOptions - )->wait(); - } - - /** - * Unlocks a locked deployment. - * - * The async variant is {@see self::unlockDeploymentAsync()} . - * - * @example samples/V1/ConfigClient/unlock_deployment.php - * - * @param UnlockDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function unlockDeployment( - UnlockDeploymentRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'UnlockDeployment', - $request, - $callOptions - )->wait(); - } - - /** - * Updates a [Deployment][google.cloud.config.v1.Deployment]. - * - * The async variant is {@see self::updateDeploymentAsync()} . - * - * @example samples/V1/ConfigClient/update_deployment.php - * - * @param UpdateDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDeployment( - UpdateDeploymentRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'UpdateDeployment', - $request, - $callOptions - )->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/ConfigClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation( - GetLocationRequest $request, - array $callOptions = [] - ): Location { - return $this->startApiCall( - 'GetLocation', - $request, - $callOptions - )->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/ConfigClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations( - ListLocationsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/ConfigClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy( - GetIamPolicyRequest $request, - array $callOptions = [] - ): Policy { - return $this->startApiCall( - 'GetIamPolicy', - $request, - $callOptions - )->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/ConfigClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy( - SetIamPolicyRequest $request, - array $callOptions = [] - ): Policy { - return $this->startApiCall( - 'SetIamPolicy', - $request, - $callOptions - )->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/ConfigClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { - return $this->startApiCall( - 'TestIamPermissions', - $request, - $callOptions - )->wait(); - } -} diff --git a/Config/src/V1/Client/ConfigClient.php b/Config/src/V1/Client/ConfigClient.php index 5c9f283aa682..e7fcf54ac680 100644 --- a/Config/src/V1/Client/ConfigClient.php +++ b/Config/src/V1/Client/ConfigClient.php @@ -24,17 +24,931 @@ namespace Google\Cloud\Config\V1\Client; -use Google\Cloud\Config\V1\Client\BaseClient\ConfigBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Config\V1\CreateDeploymentRequest; +use Google\Cloud\Config\V1\DeleteDeploymentRequest; +use Google\Cloud\Config\V1\DeleteStatefileRequest; +use Google\Cloud\Config\V1\Deployment; +use Google\Cloud\Config\V1\ExportDeploymentStatefileRequest; +use Google\Cloud\Config\V1\ExportLockInfoRequest; +use Google\Cloud\Config\V1\ExportRevisionStatefileRequest; +use Google\Cloud\Config\V1\GetDeploymentRequest; +use Google\Cloud\Config\V1\GetResourceRequest; +use Google\Cloud\Config\V1\GetRevisionRequest; +use Google\Cloud\Config\V1\ImportStatefileRequest; +use Google\Cloud\Config\V1\ListDeploymentsRequest; +use Google\Cloud\Config\V1\ListResourcesRequest; +use Google\Cloud\Config\V1\ListRevisionsRequest; +use Google\Cloud\Config\V1\LockDeploymentRequest; +use Google\Cloud\Config\V1\LockInfo; +use Google\Cloud\Config\V1\Resource; +use Google\Cloud\Config\V1\Revision; +use Google\Cloud\Config\V1\Statefile; +use Google\Cloud\Config\V1\UnlockDeploymentRequest; +use Google\Cloud\Config\V1\UpdateDeploymentRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Infrastructure Manager is a managed service that automates the deployment and + * management of Google Cloud infrastructure resources. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createDeploymentAsync(CreateDeploymentRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDeploymentAsync(DeleteDeploymentRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteStatefileAsync(DeleteStatefileRequest $request, array $optionalArgs = []) + * @method PromiseInterface exportDeploymentStatefileAsync(ExportDeploymentStatefileRequest $request, array $optionalArgs = []) + * @method PromiseInterface exportLockInfoAsync(ExportLockInfoRequest $request, array $optionalArgs = []) + * @method PromiseInterface exportRevisionStatefileAsync(ExportRevisionStatefileRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDeploymentAsync(GetDeploymentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getResourceAsync(GetResourceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRevisionAsync(GetRevisionRequest $request, array $optionalArgs = []) + * @method PromiseInterface importStatefileAsync(ImportStatefileRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDeploymentsAsync(ListDeploymentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listResourcesAsync(ListResourcesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listRevisionsAsync(ListRevisionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface lockDeploymentAsync(LockDeploymentRequest $request, array $optionalArgs = []) + * @method PromiseInterface unlockDeploymentAsync(UnlockDeploymentRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDeploymentAsync(UpdateDeploymentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class ConfigClient extends ConfigBaseClient +final class ConfigClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ConfigBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.config.v1.Config'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'config.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/config_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/config_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/config_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/config_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a deployment + * resource. + * + * @param string $project + * @param string $location + * @param string $deployment + * + * @return string The formatted deployment resource. + */ + public static function deploymentName(string $project, string $location, string $deployment): string + { + return self::getPathTemplate('deployment')->render([ + 'project' => $project, + 'location' => $location, + 'deployment' => $deployment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a resource + * resource. + * + * @param string $project + * @param string $location + * @param string $deployment + * @param string $revision + * @param string $resource + * + * @return string The formatted resource resource. + */ + public static function resourceName(string $project, string $location, string $deployment, string $revision, string $resource): string + { + return self::getPathTemplate('resource')->render([ + 'project' => $project, + 'location' => $location, + 'deployment' => $deployment, + 'revision' => $revision, + 'resource' => $resource, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a revision + * resource. + * + * @param string $project + * @param string $location + * @param string $deployment + * @param string $revision + * + * @return string The formatted revision resource. + */ + public static function revisionName(string $project, string $location, string $deployment, string $revision): string + { + return self::getPathTemplate('revision')->render([ + 'project' => $project, + 'location' => $location, + 'deployment' => $deployment, + 'revision' => $revision, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * service_account resource. + * + * @param string $project + * @param string $serviceAccount + * + * @return string The formatted service_account resource. + */ + public static function serviceAccountName(string $project, string $serviceAccount): string + { + return self::getPathTemplate('serviceAccount')->render([ + 'project' => $project, + 'service_account' => $serviceAccount, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a worker_pool + * resource. + * + * @param string $project + * @param string $location + * @param string $workerPool + * + * @return string The formatted worker_pool resource. + */ + public static function workerPoolName(string $project, string $location, string $workerPool): string + { + return self::getPathTemplate('workerPool')->render([ + 'project' => $project, + 'location' => $location, + 'worker_pool' => $workerPool, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - deployment: projects/{project}/locations/{location}/deployments/{deployment} + * - location: projects/{project}/locations/{location} + * - resource: projects/{project}/locations/{location}/deployments/{deployment}/revisions/{revision}/resources/{resource} + * - revision: projects/{project}/locations/{location}/deployments/{deployment}/revisions/{revision} + * - serviceAccount: projects/{project}/serviceAccounts/{service_account} + * - workerPool: projects/{project}/locations/{location}/workerPools/{worker_pool} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'config.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a [Deployment][google.cloud.config.v1.Deployment]. + * + * The async variant is {@see ConfigClient::createDeploymentAsync()} . + * + * @example samples/V1/ConfigClient/create_deployment.php + * + * @param CreateDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDeployment(CreateDeploymentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateDeployment', $request, $callOptions)->wait(); + } + + /** + * Deletes a [Deployment][google.cloud.config.v1.Deployment]. + * + * The async variant is {@see ConfigClient::deleteDeploymentAsync()} . + * + * @example samples/V1/ConfigClient/delete_deployment.php + * + * @param DeleteDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDeployment(DeleteDeploymentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteDeployment', $request, $callOptions)->wait(); + } + + /** + * Deletes Terraform state file in a given deployment. + * + * The async variant is {@see ConfigClient::deleteStatefileAsync()} . + * + * @example samples/V1/ConfigClient/delete_statefile.php + * + * @param DeleteStatefileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteStatefile(DeleteStatefileRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteStatefile', $request, $callOptions)->wait(); + } + + /** + * Exports Terraform state file from a given deployment. + * + * The async variant is {@see ConfigClient::exportDeploymentStatefileAsync()} . + * + * @example samples/V1/ConfigClient/export_deployment_statefile.php + * + * @param ExportDeploymentStatefileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Statefile + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportDeploymentStatefile(ExportDeploymentStatefileRequest $request, array $callOptions = []): Statefile + { + return $this->startApiCall('ExportDeploymentStatefile', $request, $callOptions)->wait(); + } + + /** + * Exports the lock info on a locked deployment. + * + * The async variant is {@see ConfigClient::exportLockInfoAsync()} . + * + * @example samples/V1/ConfigClient/export_lock_info.php + * + * @param ExportLockInfoRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LockInfo + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportLockInfo(ExportLockInfoRequest $request, array $callOptions = []): LockInfo + { + return $this->startApiCall('ExportLockInfo', $request, $callOptions)->wait(); + } + + /** + * Exports Terraform state file from a given revision. + * + * The async variant is {@see ConfigClient::exportRevisionStatefileAsync()} . + * + * @example samples/V1/ConfigClient/export_revision_statefile.php + * + * @param ExportRevisionStatefileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Statefile + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportRevisionStatefile(ExportRevisionStatefileRequest $request, array $callOptions = []): Statefile + { + return $this->startApiCall('ExportRevisionStatefile', $request, $callOptions)->wait(); + } + + /** + * Gets details about a [Deployment][google.cloud.config.v1.Deployment]. + * + * The async variant is {@see ConfigClient::getDeploymentAsync()} . + * + * @example samples/V1/ConfigClient/get_deployment.php + * + * @param GetDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Deployment + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDeployment(GetDeploymentRequest $request, array $callOptions = []): Deployment + { + return $this->startApiCall('GetDeployment', $request, $callOptions)->wait(); + } + + /** + * Gets details about a [Resource][google.cloud.config.v1.Resource] deployed + * by Infra Manager. + * + * The async variant is {@see ConfigClient::getResourceAsync()} . + * + * @example samples/V1/ConfigClient/get_resource.php + * + * @param GetResourceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Resource + * + * @throws ApiException Thrown if the API call fails. + */ + public function getResource(GetResourceRequest $request, array $callOptions = []): Resource + { + return $this->startApiCall('GetResource', $request, $callOptions)->wait(); + } + + /** + * Gets details about a [Revision][google.cloud.config.v1.Revision]. + * + * The async variant is {@see ConfigClient::getRevisionAsync()} . + * + * @example samples/V1/ConfigClient/get_revision.php + * + * @param GetRevisionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Revision + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRevision(GetRevisionRequest $request, array $callOptions = []): Revision + { + return $this->startApiCall('GetRevision', $request, $callOptions)->wait(); + } + + /** + * Imports Terraform state file in a given deployment. The state file does not + * take effect until the Deployment has been unlocked. + * + * The async variant is {@see ConfigClient::importStatefileAsync()} . + * + * @example samples/V1/ConfigClient/import_statefile.php + * + * @param ImportStatefileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Statefile + * + * @throws ApiException Thrown if the API call fails. + */ + public function importStatefile(ImportStatefileRequest $request, array $callOptions = []): Statefile + { + return $this->startApiCall('ImportStatefile', $request, $callOptions)->wait(); + } + + /** + * Lists [Deployment][google.cloud.config.v1.Deployment]s in a given project + * and location. + * + * The async variant is {@see ConfigClient::listDeploymentsAsync()} . + * + * @example samples/V1/ConfigClient/list_deployments.php + * + * @param ListDeploymentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDeployments(ListDeploymentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDeployments', $request, $callOptions); + } + + /** + * Lists [Resource][google.cloud.config.v1.Resource]s in a given revision. + * + * The async variant is {@see ConfigClient::listResourcesAsync()} . + * + * @example samples/V1/ConfigClient/list_resources.php + * + * @param ListResourcesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listResources(ListResourcesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListResources', $request, $callOptions); + } + + /** + * Lists [Revision][google.cloud.config.v1.Revision]s of a deployment. + * + * The async variant is {@see ConfigClient::listRevisionsAsync()} . + * + * @example samples/V1/ConfigClient/list_revisions.php + * + * @param ListRevisionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listRevisions(ListRevisionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListRevisions', $request, $callOptions); + } + + /** + * Locks a deployment. + * + * The async variant is {@see ConfigClient::lockDeploymentAsync()} . + * + * @example samples/V1/ConfigClient/lock_deployment.php + * + * @param LockDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function lockDeployment(LockDeploymentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('LockDeployment', $request, $callOptions)->wait(); + } + + /** + * Unlocks a locked deployment. + * + * The async variant is {@see ConfigClient::unlockDeploymentAsync()} . + * + * @example samples/V1/ConfigClient/unlock_deployment.php + * + * @param UnlockDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function unlockDeployment(UnlockDeploymentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UnlockDeployment', $request, $callOptions)->wait(); + } + + /** + * Updates a [Deployment][google.cloud.config.v1.Deployment]. + * + * The async variant is {@see ConfigClient::updateDeploymentAsync()} . + * + * @example samples/V1/ConfigClient/update_deployment.php + * + * @param UpdateDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDeployment(UpdateDeploymentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateDeployment', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see ConfigClient::getLocationAsync()} . + * + * @example samples/V1/ConfigClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see ConfigClient::listLocationsAsync()} . + * + * @example samples/V1/ConfigClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see ConfigClient::getIamPolicyAsync()} . + * + * @example samples/V1/ConfigClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see ConfigClient::setIamPolicyAsync()} . + * + * @example samples/V1/ConfigClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see ConfigClient::testIamPermissionsAsync()} . + * + * @example samples/V1/ConfigClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/ContactCenterInsights/composer.json b/ContactCenterInsights/composer.json index 18d7e420710b..e4b43fd9939c 100644 --- a/ContactCenterInsights/composer.json +++ b/ContactCenterInsights/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/ContactCenterInsights/src/V1/Client/BaseClient/ContactCenterInsightsBaseClient.php b/ContactCenterInsights/src/V1/Client/BaseClient/ContactCenterInsightsBaseClient.php deleted file mode 100644 index 875c41f5d24e..000000000000 --- a/ContactCenterInsights/src/V1/Client/BaseClient/ContactCenterInsightsBaseClient.php +++ /dev/null @@ -1,1484 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/contact_center_insights_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/contact_center_insights_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/contact_center_insights_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/contact_center_insights_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a analysis - * resource. - * - * @param string $project - * @param string $location - * @param string $conversation - * @param string $analysis - * - * @return string The formatted analysis resource. - */ - public static function analysisName(string $project, string $location, string $conversation, string $analysis): string - { - return self::getPathTemplate('analysis')->render([ - 'project' => $project, - 'location' => $location, - 'conversation' => $conversation, - 'analysis' => $analysis, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a conversation - * resource. - * - * @param string $project - * @param string $location - * @param string $conversation - * - * @return string The formatted conversation resource. - */ - public static function conversationName(string $project, string $location, string $conversation): string - { - return self::getPathTemplate('conversation')->render([ - 'project' => $project, - 'location' => $location, - 'conversation' => $conversation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * conversation_profile resource. - * - * @param string $project - * @param string $location - * @param string $conversationProfile - * - * @return string The formatted conversation_profile resource. - */ - public static function conversationProfileName(string $project, string $location, string $conversationProfile): string - { - return self::getPathTemplate('conversationProfile')->render([ - 'project' => $project, - 'location' => $location, - 'conversation_profile' => $conversationProfile, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a issue - * resource. - * - * @param string $project - * @param string $location - * @param string $issueModel - * @param string $issue - * - * @return string The formatted issue resource. - */ - public static function issueName(string $project, string $location, string $issueModel, string $issue): string - { - return self::getPathTemplate('issue')->render([ - 'project' => $project, - 'location' => $location, - 'issue_model' => $issueModel, - 'issue' => $issue, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a issue_model - * resource. - * - * @param string $project - * @param string $location - * @param string $issueModel - * - * @return string The formatted issue_model resource. - */ - public static function issueModelName(string $project, string $location, string $issueModel): string - { - return self::getPathTemplate('issueModel')->render([ - 'project' => $project, - 'location' => $location, - 'issue_model' => $issueModel, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a participant - * resource. - * - * @param string $project - * @param string $conversation - * @param string $participant - * - * @return string The formatted participant resource. - */ - public static function participantName(string $project, string $conversation, string $participant): string - { - return self::getPathTemplate('participant')->render([ - 'project' => $project, - 'conversation' => $conversation, - 'participant' => $participant, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * phrase_matcher resource. - * - * @param string $project - * @param string $location - * @param string $phraseMatcher - * - * @return string The formatted phrase_matcher resource. - */ - public static function phraseMatcherName(string $project, string $location, string $phraseMatcher): string - { - return self::getPathTemplate('phraseMatcher')->render([ - 'project' => $project, - 'location' => $location, - 'phrase_matcher' => $phraseMatcher, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_conversation_participant resource. - * - * @param string $project - * @param string $conversation - * @param string $participant - * - * @return string The formatted project_conversation_participant resource. - */ - public static function projectConversationParticipantName(string $project, string $conversation, string $participant): string - { - return self::getPathTemplate('projectConversationParticipant')->render([ - 'project' => $project, - 'conversation' => $conversation, - 'participant' => $participant, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_conversation_participant resource. - * - * @param string $project - * @param string $location - * @param string $conversation - * @param string $participant - * - * @return string The formatted project_location_conversation_participant resource. - */ - public static function projectLocationConversationParticipantName(string $project, string $location, string $conversation, string $participant): string - { - return self::getPathTemplate('projectLocationConversationParticipant')->render([ - 'project' => $project, - 'location' => $location, - 'conversation' => $conversation, - 'participant' => $participant, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a recognizer - * resource. - * - * @param string $project - * @param string $location - * @param string $recognizer - * - * @return string The formatted recognizer resource. - */ - public static function recognizerName(string $project, string $location, string $recognizer): string - { - return self::getPathTemplate('recognizer')->render([ - 'project' => $project, - 'location' => $location, - 'recognizer' => $recognizer, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a settings - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted settings resource. - */ - public static function settingsName(string $project, string $location): string - { - return self::getPathTemplate('settings')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a view - * resource. - * - * @param string $project - * @param string $location - * @param string $view - * - * @return string The formatted view resource. - */ - public static function viewName(string $project, string $location, string $view): string - { - return self::getPathTemplate('view')->render([ - 'project' => $project, - 'location' => $location, - 'view' => $view, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - analysis: projects/{project}/locations/{location}/conversations/{conversation}/analyses/{analysis} - * - conversation: projects/{project}/locations/{location}/conversations/{conversation} - * - conversationProfile: projects/{project}/locations/{location}/conversationProfiles/{conversation_profile} - * - issue: projects/{project}/locations/{location}/issueModels/{issue_model}/issues/{issue} - * - issueModel: projects/{project}/locations/{location}/issueModels/{issue_model} - * - location: projects/{project}/locations/{location} - * - participant: projects/{project}/conversations/{conversation}/participants/{participant} - * - phraseMatcher: projects/{project}/locations/{location}/phraseMatchers/{phrase_matcher} - * - projectConversationParticipant: projects/{project}/conversations/{conversation}/participants/{participant} - * - projectLocationConversationParticipant: projects/{project}/locations/{location}/conversations/{conversation}/participants/{participant} - * - recognizer: projects/{project}/locations/{location}/recognizers/{recognizer} - * - settings: projects/{project}/locations/{location}/settings - * - view: projects/{project}/locations/{location}/views/{view} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'contactcenterinsights.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Analyzes multiple conversations in a single request. - * - * The async variant is {@see self::bulkAnalyzeConversationsAsync()} . - * - * @param BulkAnalyzeConversationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function bulkAnalyzeConversations(BulkAnalyzeConversationsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BulkAnalyzeConversations', $request, $callOptions)->wait(); - } - - /** - * Gets an issue model's statistics. - * - * The async variant is {@see self::calculateIssueModelStatsAsync()} . - * - * @param CalculateIssueModelStatsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CalculateIssueModelStatsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function calculateIssueModelStats(CalculateIssueModelStatsRequest $request, array $callOptions = []): CalculateIssueModelStatsResponse - { - return $this->startApiCall('CalculateIssueModelStats', $request, $callOptions)->wait(); - } - - /** - * Gets conversation statistics. - * - * The async variant is {@see self::calculateStatsAsync()} . - * - * @param CalculateStatsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CalculateStatsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function calculateStats(CalculateStatsRequest $request, array $callOptions = []): CalculateStatsResponse - { - return $this->startApiCall('CalculateStats', $request, $callOptions)->wait(); - } - - /** - * Creates an analysis. The long running operation is done when the analysis - * has completed. - * - * The async variant is {@see self::createAnalysisAsync()} . - * - * @param CreateAnalysisRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAnalysis(CreateAnalysisRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateAnalysis', $request, $callOptions)->wait(); - } - - /** - * Creates a conversation. - * - * The async variant is {@see self::createConversationAsync()} . - * - * @param CreateConversationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Conversation - * - * @throws ApiException Thrown if the API call fails. - */ - public function createConversation(CreateConversationRequest $request, array $callOptions = []): Conversation - { - return $this->startApiCall('CreateConversation', $request, $callOptions)->wait(); - } - - /** - * Creates an issue model. - * - * The async variant is {@see self::createIssueModelAsync()} . - * - * @param CreateIssueModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createIssueModel(CreateIssueModelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateIssueModel', $request, $callOptions)->wait(); - } - - /** - * Creates a phrase matcher. - * - * The async variant is {@see self::createPhraseMatcherAsync()} . - * - * @param CreatePhraseMatcherRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PhraseMatcher - * - * @throws ApiException Thrown if the API call fails. - */ - public function createPhraseMatcher(CreatePhraseMatcherRequest $request, array $callOptions = []): PhraseMatcher - { - return $this->startApiCall('CreatePhraseMatcher', $request, $callOptions)->wait(); - } - - /** - * Creates a view. - * - * The async variant is {@see self::createViewAsync()} . - * - * @param CreateViewRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 View - * - * @throws ApiException Thrown if the API call fails. - */ - public function createView(CreateViewRequest $request, array $callOptions = []): View - { - return $this->startApiCall('CreateView', $request, $callOptions)->wait(); - } - - /** - * Deletes an analysis. - * - * The async variant is {@see self::deleteAnalysisAsync()} . - * - * @param DeleteAnalysisRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAnalysis(DeleteAnalysisRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteAnalysis', $request, $callOptions)->wait(); - } - - /** - * Deletes a conversation. - * - * The async variant is {@see self::deleteConversationAsync()} . - * - * @param DeleteConversationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteConversation(DeleteConversationRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteConversation', $request, $callOptions)->wait(); - } - - /** - * Deletes an issue. - * - * The async variant is {@see self::deleteIssueAsync()} . - * - * @param DeleteIssueRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteIssue(DeleteIssueRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteIssue', $request, $callOptions)->wait(); - } - - /** - * Deletes an issue model. - * - * The async variant is {@see self::deleteIssueModelAsync()} . - * - * @param DeleteIssueModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteIssueModel(DeleteIssueModelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteIssueModel', $request, $callOptions)->wait(); - } - - /** - * Deletes a phrase matcher. - * - * The async variant is {@see self::deletePhraseMatcherAsync()} . - * - * @param DeletePhraseMatcherRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deletePhraseMatcher(DeletePhraseMatcherRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeletePhraseMatcher', $request, $callOptions)->wait(); - } - - /** - * Deletes a view. - * - * The async variant is {@see self::deleteViewAsync()} . - * - * @param DeleteViewRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteView(DeleteViewRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteView', $request, $callOptions)->wait(); - } - - /** - * Deploys an issue model. Returns an error if a model is already deployed. - * An issue model can only be used in analysis after it has been deployed. - * - * The async variant is {@see self::deployIssueModelAsync()} . - * - * @param DeployIssueModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deployIssueModel(DeployIssueModelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeployIssueModel', $request, $callOptions)->wait(); - } - - /** - * Export insights data to a destination defined in the request body. - * - * The async variant is {@see self::exportInsightsDataAsync()} . - * - * @param ExportInsightsDataRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function exportInsightsData(ExportInsightsDataRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ExportInsightsData', $request, $callOptions)->wait(); - } - - /** - * Gets an analysis. - * - * The async variant is {@see self::getAnalysisAsync()} . - * - * @param GetAnalysisRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Analysis - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAnalysis(GetAnalysisRequest $request, array $callOptions = []): Analysis - { - return $this->startApiCall('GetAnalysis', $request, $callOptions)->wait(); - } - - /** - * Gets a conversation. - * - * The async variant is {@see self::getConversationAsync()} . - * - * @param GetConversationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Conversation - * - * @throws ApiException Thrown if the API call fails. - */ - public function getConversation(GetConversationRequest $request, array $callOptions = []): Conversation - { - return $this->startApiCall('GetConversation', $request, $callOptions)->wait(); - } - - /** - * Gets an issue. - * - * The async variant is {@see self::getIssueAsync()} . - * - * @param GetIssueRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Issue - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIssue(GetIssueRequest $request, array $callOptions = []): Issue - { - return $this->startApiCall('GetIssue', $request, $callOptions)->wait(); - } - - /** - * Gets an issue model. - * - * The async variant is {@see self::getIssueModelAsync()} . - * - * @param GetIssueModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 IssueModel - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIssueModel(GetIssueModelRequest $request, array $callOptions = []): IssueModel - { - return $this->startApiCall('GetIssueModel', $request, $callOptions)->wait(); - } - - /** - * Gets a phrase matcher. - * - * The async variant is {@see self::getPhraseMatcherAsync()} . - * - * @param GetPhraseMatcherRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PhraseMatcher - * - * @throws ApiException Thrown if the API call fails. - */ - public function getPhraseMatcher(GetPhraseMatcherRequest $request, array $callOptions = []): PhraseMatcher - { - return $this->startApiCall('GetPhraseMatcher', $request, $callOptions)->wait(); - } - - /** - * Gets project-level settings. - * - * The async variant is {@see self::getSettingsAsync()} . - * - * @param GetSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Settings - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSettings(GetSettingsRequest $request, array $callOptions = []): Settings - { - return $this->startApiCall('GetSettings', $request, $callOptions)->wait(); - } - - /** - * Gets a view. - * - * The async variant is {@see self::getViewAsync()} . - * - * @param GetViewRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 View - * - * @throws ApiException Thrown if the API call fails. - */ - public function getView(GetViewRequest $request, array $callOptions = []): View - { - return $this->startApiCall('GetView', $request, $callOptions)->wait(); - } - - /** - * Imports conversations and processes them according to the user's - * configuration. - * - * The async variant is {@see self::ingestConversationsAsync()} . - * - * @param IngestConversationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function ingestConversations(IngestConversationsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('IngestConversations', $request, $callOptions)->wait(); - } - - /** - * Lists analyses. - * - * The async variant is {@see self::listAnalysesAsync()} . - * - * @param ListAnalysesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAnalyses(ListAnalysesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAnalyses', $request, $callOptions); - } - - /** - * Lists conversations. - * - * The async variant is {@see self::listConversationsAsync()} . - * - * @param ListConversationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listConversations(ListConversationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListConversations', $request, $callOptions); - } - - /** - * Lists issue models. - * - * The async variant is {@see self::listIssueModelsAsync()} . - * - * @param ListIssueModelsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ListIssueModelsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listIssueModels(ListIssueModelsRequest $request, array $callOptions = []): ListIssueModelsResponse - { - return $this->startApiCall('ListIssueModels', $request, $callOptions)->wait(); - } - - /** - * Lists issues. - * - * The async variant is {@see self::listIssuesAsync()} . - * - * @param ListIssuesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ListIssuesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listIssues(ListIssuesRequest $request, array $callOptions = []): ListIssuesResponse - { - return $this->startApiCall('ListIssues', $request, $callOptions)->wait(); - } - - /** - * Lists phrase matchers. - * - * The async variant is {@see self::listPhraseMatchersAsync()} . - * - * @param ListPhraseMatchersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPhraseMatchers(ListPhraseMatchersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPhraseMatchers', $request, $callOptions); - } - - /** - * Lists views. - * - * The async variant is {@see self::listViewsAsync()} . - * - * @param ListViewsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listViews(ListViewsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListViews', $request, $callOptions); - } - - /** - * Undeploys an issue model. - * An issue model can not be used in analysis after it has been undeployed. - * - * The async variant is {@see self::undeployIssueModelAsync()} . - * - * @param UndeployIssueModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function undeployIssueModel(UndeployIssueModelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UndeployIssueModel', $request, $callOptions)->wait(); - } - - /** - * Updates a conversation. - * - * The async variant is {@see self::updateConversationAsync()} . - * - * @param UpdateConversationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Conversation - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateConversation(UpdateConversationRequest $request, array $callOptions = []): Conversation - { - return $this->startApiCall('UpdateConversation', $request, $callOptions)->wait(); - } - - /** - * Updates an issue. - * - * The async variant is {@see self::updateIssueAsync()} . - * - * @param UpdateIssueRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Issue - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateIssue(UpdateIssueRequest $request, array $callOptions = []): Issue - { - return $this->startApiCall('UpdateIssue', $request, $callOptions)->wait(); - } - - /** - * Updates an issue model. - * - * The async variant is {@see self::updateIssueModelAsync()} . - * - * @param UpdateIssueModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 IssueModel - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateIssueModel(UpdateIssueModelRequest $request, array $callOptions = []): IssueModel - { - return $this->startApiCall('UpdateIssueModel', $request, $callOptions)->wait(); - } - - /** - * Updates a phrase matcher. - * - * The async variant is {@see self::updatePhraseMatcherAsync()} . - * - * @param UpdatePhraseMatcherRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PhraseMatcher - * - * @throws ApiException Thrown if the API call fails. - */ - public function updatePhraseMatcher(UpdatePhraseMatcherRequest $request, array $callOptions = []): PhraseMatcher - { - return $this->startApiCall('UpdatePhraseMatcher', $request, $callOptions)->wait(); - } - - /** - * Updates project-level settings. - * - * The async variant is {@see self::updateSettingsAsync()} . - * - * @param UpdateSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Settings - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSettings(UpdateSettingsRequest $request, array $callOptions = []): Settings - { - return $this->startApiCall('UpdateSettings', $request, $callOptions)->wait(); - } - - /** - * Updates a view. - * - * The async variant is {@see self::updateViewAsync()} . - * - * @param UpdateViewRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 View - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateView(UpdateViewRequest $request, array $callOptions = []): View - { - return $this->startApiCall('UpdateView', $request, $callOptions)->wait(); - } - - /** - * Create a longrunning conversation upload operation. This method differs - * from CreateConversation by allowing audio transcription and optional DLP - * redaction. - * - * The async variant is {@see self::uploadConversationAsync()} . - * - * @param UploadConversationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function uploadConversation(UploadConversationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UploadConversation', $request, $callOptions)->wait(); - } -} diff --git a/ContactCenterInsights/src/V1/Client/ContactCenterInsightsClient.php b/ContactCenterInsights/src/V1/Client/ContactCenterInsightsClient.php index 2f6821ac06d2..c7a56e495bec 100644 --- a/ContactCenterInsights/src/V1/Client/ContactCenterInsightsClient.php +++ b/ContactCenterInsights/src/V1/Client/ContactCenterInsightsClient.php @@ -24,17 +24,1480 @@ namespace Google\Cloud\ContactCenterInsights\V1\Client; -use Google\Cloud\ContactCenterInsights\V1\Client\BaseClient\ContactCenterInsightsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\ContactCenterInsights\V1\Analysis; +use Google\Cloud\ContactCenterInsights\V1\BulkAnalyzeConversationsRequest; +use Google\Cloud\ContactCenterInsights\V1\CalculateIssueModelStatsRequest; +use Google\Cloud\ContactCenterInsights\V1\CalculateIssueModelStatsResponse; +use Google\Cloud\ContactCenterInsights\V1\CalculateStatsRequest; +use Google\Cloud\ContactCenterInsights\V1\CalculateStatsResponse; +use Google\Cloud\ContactCenterInsights\V1\Conversation; +use Google\Cloud\ContactCenterInsights\V1\CreateAnalysisRequest; +use Google\Cloud\ContactCenterInsights\V1\CreateConversationRequest; +use Google\Cloud\ContactCenterInsights\V1\CreateIssueModelRequest; +use Google\Cloud\ContactCenterInsights\V1\CreatePhraseMatcherRequest; +use Google\Cloud\ContactCenterInsights\V1\CreateViewRequest; +use Google\Cloud\ContactCenterInsights\V1\DeleteAnalysisRequest; +use Google\Cloud\ContactCenterInsights\V1\DeleteConversationRequest; +use Google\Cloud\ContactCenterInsights\V1\DeleteIssueModelRequest; +use Google\Cloud\ContactCenterInsights\V1\DeleteIssueRequest; +use Google\Cloud\ContactCenterInsights\V1\DeletePhraseMatcherRequest; +use Google\Cloud\ContactCenterInsights\V1\DeleteViewRequest; +use Google\Cloud\ContactCenterInsights\V1\DeployIssueModelRequest; +use Google\Cloud\ContactCenterInsights\V1\ExportInsightsDataRequest; +use Google\Cloud\ContactCenterInsights\V1\GetAnalysisRequest; +use Google\Cloud\ContactCenterInsights\V1\GetConversationRequest; +use Google\Cloud\ContactCenterInsights\V1\GetIssueModelRequest; +use Google\Cloud\ContactCenterInsights\V1\GetIssueRequest; +use Google\Cloud\ContactCenterInsights\V1\GetPhraseMatcherRequest; +use Google\Cloud\ContactCenterInsights\V1\GetSettingsRequest; +use Google\Cloud\ContactCenterInsights\V1\GetViewRequest; +use Google\Cloud\ContactCenterInsights\V1\IngestConversationsRequest; +use Google\Cloud\ContactCenterInsights\V1\Issue; +use Google\Cloud\ContactCenterInsights\V1\IssueModel; +use Google\Cloud\ContactCenterInsights\V1\ListAnalysesRequest; +use Google\Cloud\ContactCenterInsights\V1\ListConversationsRequest; +use Google\Cloud\ContactCenterInsights\V1\ListIssueModelsRequest; +use Google\Cloud\ContactCenterInsights\V1\ListIssueModelsResponse; +use Google\Cloud\ContactCenterInsights\V1\ListIssuesRequest; +use Google\Cloud\ContactCenterInsights\V1\ListIssuesResponse; +use Google\Cloud\ContactCenterInsights\V1\ListPhraseMatchersRequest; +use Google\Cloud\ContactCenterInsights\V1\ListViewsRequest; +use Google\Cloud\ContactCenterInsights\V1\PhraseMatcher; +use Google\Cloud\ContactCenterInsights\V1\Settings; +use Google\Cloud\ContactCenterInsights\V1\UndeployIssueModelRequest; +use Google\Cloud\ContactCenterInsights\V1\UpdateConversationRequest; +use Google\Cloud\ContactCenterInsights\V1\UpdateIssueModelRequest; +use Google\Cloud\ContactCenterInsights\V1\UpdateIssueRequest; +use Google\Cloud\ContactCenterInsights\V1\UpdatePhraseMatcherRequest; +use Google\Cloud\ContactCenterInsights\V1\UpdateSettingsRequest; +use Google\Cloud\ContactCenterInsights\V1\UpdateViewRequest; +use Google\Cloud\ContactCenterInsights\V1\UploadConversationRequest; +use Google\Cloud\ContactCenterInsights\V1\View; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: An API that lets users analyze and explore their business conversation data. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ContactCenterInsights\V1\ContactCenterInsightsClient} for the + * stable implementation * * @experimental + * + * @method PromiseInterface bulkAnalyzeConversationsAsync(BulkAnalyzeConversationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface calculateIssueModelStatsAsync(CalculateIssueModelStatsRequest $request, array $optionalArgs = []) + * @method PromiseInterface calculateStatsAsync(CalculateStatsRequest $request, array $optionalArgs = []) + * @method PromiseInterface createAnalysisAsync(CreateAnalysisRequest $request, array $optionalArgs = []) + * @method PromiseInterface createConversationAsync(CreateConversationRequest $request, array $optionalArgs = []) + * @method PromiseInterface createIssueModelAsync(CreateIssueModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface createPhraseMatcherAsync(CreatePhraseMatcherRequest $request, array $optionalArgs = []) + * @method PromiseInterface createViewAsync(CreateViewRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAnalysisAsync(DeleteAnalysisRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteConversationAsync(DeleteConversationRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteIssueAsync(DeleteIssueRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteIssueModelAsync(DeleteIssueModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface deletePhraseMatcherAsync(DeletePhraseMatcherRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteViewAsync(DeleteViewRequest $request, array $optionalArgs = []) + * @method PromiseInterface deployIssueModelAsync(DeployIssueModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface exportInsightsDataAsync(ExportInsightsDataRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAnalysisAsync(GetAnalysisRequest $request, array $optionalArgs = []) + * @method PromiseInterface getConversationAsync(GetConversationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIssueAsync(GetIssueRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIssueModelAsync(GetIssueModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface getPhraseMatcherAsync(GetPhraseMatcherRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSettingsAsync(GetSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getViewAsync(GetViewRequest $request, array $optionalArgs = []) + * @method PromiseInterface ingestConversationsAsync(IngestConversationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAnalysesAsync(ListAnalysesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listConversationsAsync(ListConversationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listIssueModelsAsync(ListIssueModelsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listIssuesAsync(ListIssuesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPhraseMatchersAsync(ListPhraseMatchersRequest $request, array $optionalArgs = []) + * @method PromiseInterface listViewsAsync(ListViewsRequest $request, array $optionalArgs = []) + * @method PromiseInterface undeployIssueModelAsync(UndeployIssueModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateConversationAsync(UpdateConversationRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateIssueAsync(UpdateIssueRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateIssueModelAsync(UpdateIssueModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface updatePhraseMatcherAsync(UpdatePhraseMatcherRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSettingsAsync(UpdateSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateViewAsync(UpdateViewRequest $request, array $optionalArgs = []) + * @method PromiseInterface uploadConversationAsync(UploadConversationRequest $request, array $optionalArgs = []) */ -final class ContactCenterInsightsClient extends ContactCenterInsightsBaseClient +final class ContactCenterInsightsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ContactCenterInsightsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.contactcenterinsights.v1.ContactCenterInsights'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'contactcenterinsights.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/contact_center_insights_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/contact_center_insights_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/contact_center_insights_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/contact_center_insights_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a analysis + * resource. + * + * @param string $project + * @param string $location + * @param string $conversation + * @param string $analysis + * + * @return string The formatted analysis resource. + */ + public static function analysisName(string $project, string $location, string $conversation, string $analysis): string + { + return self::getPathTemplate('analysis')->render([ + 'project' => $project, + 'location' => $location, + 'conversation' => $conversation, + 'analysis' => $analysis, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a conversation + * resource. + * + * @param string $project + * @param string $location + * @param string $conversation + * + * @return string The formatted conversation resource. + */ + public static function conversationName(string $project, string $location, string $conversation): string + { + return self::getPathTemplate('conversation')->render([ + 'project' => $project, + 'location' => $location, + 'conversation' => $conversation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * conversation_profile resource. + * + * @param string $project + * @param string $location + * @param string $conversationProfile + * + * @return string The formatted conversation_profile resource. + */ + public static function conversationProfileName(string $project, string $location, string $conversationProfile): string + { + return self::getPathTemplate('conversationProfile')->render([ + 'project' => $project, + 'location' => $location, + 'conversation_profile' => $conversationProfile, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a issue + * resource. + * + * @param string $project + * @param string $location + * @param string $issueModel + * @param string $issue + * + * @return string The formatted issue resource. + */ + public static function issueName(string $project, string $location, string $issueModel, string $issue): string + { + return self::getPathTemplate('issue')->render([ + 'project' => $project, + 'location' => $location, + 'issue_model' => $issueModel, + 'issue' => $issue, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a issue_model + * resource. + * + * @param string $project + * @param string $location + * @param string $issueModel + * + * @return string The formatted issue_model resource. + */ + public static function issueModelName(string $project, string $location, string $issueModel): string + { + return self::getPathTemplate('issueModel')->render([ + 'project' => $project, + 'location' => $location, + 'issue_model' => $issueModel, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a participant + * resource. + * + * @param string $project + * @param string $conversation + * @param string $participant + * + * @return string The formatted participant resource. + */ + public static function participantName(string $project, string $conversation, string $participant): string + { + return self::getPathTemplate('participant')->render([ + 'project' => $project, + 'conversation' => $conversation, + 'participant' => $participant, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * phrase_matcher resource. + * + * @param string $project + * @param string $location + * @param string $phraseMatcher + * + * @return string The formatted phrase_matcher resource. + */ + public static function phraseMatcherName(string $project, string $location, string $phraseMatcher): string + { + return self::getPathTemplate('phraseMatcher')->render([ + 'project' => $project, + 'location' => $location, + 'phrase_matcher' => $phraseMatcher, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_conversation_participant resource. + * + * @param string $project + * @param string $conversation + * @param string $participant + * + * @return string The formatted project_conversation_participant resource. + */ + public static function projectConversationParticipantName(string $project, string $conversation, string $participant): string + { + return self::getPathTemplate('projectConversationParticipant')->render([ + 'project' => $project, + 'conversation' => $conversation, + 'participant' => $participant, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_conversation_participant resource. + * + * @param string $project + * @param string $location + * @param string $conversation + * @param string $participant + * + * @return string The formatted project_location_conversation_participant resource. + */ + public static function projectLocationConversationParticipantName(string $project, string $location, string $conversation, string $participant): string + { + return self::getPathTemplate('projectLocationConversationParticipant')->render([ + 'project' => $project, + 'location' => $location, + 'conversation' => $conversation, + 'participant' => $participant, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a recognizer + * resource. + * + * @param string $project + * @param string $location + * @param string $recognizer + * + * @return string The formatted recognizer resource. + */ + public static function recognizerName(string $project, string $location, string $recognizer): string + { + return self::getPathTemplate('recognizer')->render([ + 'project' => $project, + 'location' => $location, + 'recognizer' => $recognizer, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a settings + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted settings resource. + */ + public static function settingsName(string $project, string $location): string + { + return self::getPathTemplate('settings')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a view + * resource. + * + * @param string $project + * @param string $location + * @param string $view + * + * @return string The formatted view resource. + */ + public static function viewName(string $project, string $location, string $view): string + { + return self::getPathTemplate('view')->render([ + 'project' => $project, + 'location' => $location, + 'view' => $view, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - analysis: projects/{project}/locations/{location}/conversations/{conversation}/analyses/{analysis} + * - conversation: projects/{project}/locations/{location}/conversations/{conversation} + * - conversationProfile: projects/{project}/locations/{location}/conversationProfiles/{conversation_profile} + * - issue: projects/{project}/locations/{location}/issueModels/{issue_model}/issues/{issue} + * - issueModel: projects/{project}/locations/{location}/issueModels/{issue_model} + * - location: projects/{project}/locations/{location} + * - participant: projects/{project}/conversations/{conversation}/participants/{participant} + * - phraseMatcher: projects/{project}/locations/{location}/phraseMatchers/{phrase_matcher} + * - projectConversationParticipant: projects/{project}/conversations/{conversation}/participants/{participant} + * - projectLocationConversationParticipant: projects/{project}/locations/{location}/conversations/{conversation}/participants/{participant} + * - recognizer: projects/{project}/locations/{location}/recognizers/{recognizer} + * - settings: projects/{project}/locations/{location}/settings + * - view: projects/{project}/locations/{location}/views/{view} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'contactcenterinsights.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Analyzes multiple conversations in a single request. + * + * The async variant is + * {@see ContactCenterInsightsClient::bulkAnalyzeConversationsAsync()} . + * + * @param BulkAnalyzeConversationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function bulkAnalyzeConversations(BulkAnalyzeConversationsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BulkAnalyzeConversations', $request, $callOptions)->wait(); + } + + /** + * Gets an issue model's statistics. + * + * The async variant is + * {@see ContactCenterInsightsClient::calculateIssueModelStatsAsync()} . + * + * @param CalculateIssueModelStatsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CalculateIssueModelStatsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function calculateIssueModelStats(CalculateIssueModelStatsRequest $request, array $callOptions = []): CalculateIssueModelStatsResponse + { + return $this->startApiCall('CalculateIssueModelStats', $request, $callOptions)->wait(); + } + + /** + * Gets conversation statistics. + * + * The async variant is {@see ContactCenterInsightsClient::calculateStatsAsync()} . + * + * @param CalculateStatsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CalculateStatsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function calculateStats(CalculateStatsRequest $request, array $callOptions = []): CalculateStatsResponse + { + return $this->startApiCall('CalculateStats', $request, $callOptions)->wait(); + } + + /** + * Creates an analysis. The long running operation is done when the analysis + * has completed. + * + * The async variant is {@see ContactCenterInsightsClient::createAnalysisAsync()} . + * + * @param CreateAnalysisRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAnalysis(CreateAnalysisRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateAnalysis', $request, $callOptions)->wait(); + } + + /** + * Creates a conversation. + * + * The async variant is + * {@see ContactCenterInsightsClient::createConversationAsync()} . + * + * @param CreateConversationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Conversation + * + * @throws ApiException Thrown if the API call fails. + */ + public function createConversation(CreateConversationRequest $request, array $callOptions = []): Conversation + { + return $this->startApiCall('CreateConversation', $request, $callOptions)->wait(); + } + + /** + * Creates an issue model. + * + * The async variant is {@see ContactCenterInsightsClient::createIssueModelAsync()} + * . + * + * @param CreateIssueModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createIssueModel(CreateIssueModelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateIssueModel', $request, $callOptions)->wait(); + } + + /** + * Creates a phrase matcher. + * + * The async variant is + * {@see ContactCenterInsightsClient::createPhraseMatcherAsync()} . + * + * @param CreatePhraseMatcherRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PhraseMatcher + * + * @throws ApiException Thrown if the API call fails. + */ + public function createPhraseMatcher(CreatePhraseMatcherRequest $request, array $callOptions = []): PhraseMatcher + { + return $this->startApiCall('CreatePhraseMatcher', $request, $callOptions)->wait(); + } + + /** + * Creates a view. + * + * The async variant is {@see ContactCenterInsightsClient::createViewAsync()} . + * + * @param CreateViewRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 View + * + * @throws ApiException Thrown if the API call fails. + */ + public function createView(CreateViewRequest $request, array $callOptions = []): View + { + return $this->startApiCall('CreateView', $request, $callOptions)->wait(); + } + + /** + * Deletes an analysis. + * + * The async variant is {@see ContactCenterInsightsClient::deleteAnalysisAsync()} . + * + * @param DeleteAnalysisRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAnalysis(DeleteAnalysisRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteAnalysis', $request, $callOptions)->wait(); + } + + /** + * Deletes a conversation. + * + * The async variant is + * {@see ContactCenterInsightsClient::deleteConversationAsync()} . + * + * @param DeleteConversationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteConversation(DeleteConversationRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteConversation', $request, $callOptions)->wait(); + } + + /** + * Deletes an issue. + * + * The async variant is {@see ContactCenterInsightsClient::deleteIssueAsync()} . + * + * @param DeleteIssueRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteIssue(DeleteIssueRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteIssue', $request, $callOptions)->wait(); + } + + /** + * Deletes an issue model. + * + * The async variant is {@see ContactCenterInsightsClient::deleteIssueModelAsync()} + * . + * + * @param DeleteIssueModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteIssueModel(DeleteIssueModelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteIssueModel', $request, $callOptions)->wait(); + } + + /** + * Deletes a phrase matcher. + * + * The async variant is + * {@see ContactCenterInsightsClient::deletePhraseMatcherAsync()} . + * + * @param DeletePhraseMatcherRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deletePhraseMatcher(DeletePhraseMatcherRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeletePhraseMatcher', $request, $callOptions)->wait(); + } + + /** + * Deletes a view. + * + * The async variant is {@see ContactCenterInsightsClient::deleteViewAsync()} . + * + * @param DeleteViewRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteView(DeleteViewRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteView', $request, $callOptions)->wait(); + } + + /** + * Deploys an issue model. Returns an error if a model is already deployed. + * An issue model can only be used in analysis after it has been deployed. + * + * The async variant is {@see ContactCenterInsightsClient::deployIssueModelAsync()} + * . + * + * @param DeployIssueModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deployIssueModel(DeployIssueModelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeployIssueModel', $request, $callOptions)->wait(); + } + + /** + * Export insights data to a destination defined in the request body. + * + * The async variant is + * {@see ContactCenterInsightsClient::exportInsightsDataAsync()} . + * + * @param ExportInsightsDataRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportInsightsData(ExportInsightsDataRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ExportInsightsData', $request, $callOptions)->wait(); + } + + /** + * Gets an analysis. + * + * The async variant is {@see ContactCenterInsightsClient::getAnalysisAsync()} . + * + * @param GetAnalysisRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Analysis + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAnalysis(GetAnalysisRequest $request, array $callOptions = []): Analysis + { + return $this->startApiCall('GetAnalysis', $request, $callOptions)->wait(); + } + + /** + * Gets a conversation. + * + * The async variant is {@see ContactCenterInsightsClient::getConversationAsync()} + * . + * + * @param GetConversationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Conversation + * + * @throws ApiException Thrown if the API call fails. + */ + public function getConversation(GetConversationRequest $request, array $callOptions = []): Conversation + { + return $this->startApiCall('GetConversation', $request, $callOptions)->wait(); + } + + /** + * Gets an issue. + * + * The async variant is {@see ContactCenterInsightsClient::getIssueAsync()} . + * + * @param GetIssueRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Issue + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIssue(GetIssueRequest $request, array $callOptions = []): Issue + { + return $this->startApiCall('GetIssue', $request, $callOptions)->wait(); + } + + /** + * Gets an issue model. + * + * The async variant is {@see ContactCenterInsightsClient::getIssueModelAsync()} . + * + * @param GetIssueModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 IssueModel + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIssueModel(GetIssueModelRequest $request, array $callOptions = []): IssueModel + { + return $this->startApiCall('GetIssueModel', $request, $callOptions)->wait(); + } + + /** + * Gets a phrase matcher. + * + * The async variant is {@see ContactCenterInsightsClient::getPhraseMatcherAsync()} + * . + * + * @param GetPhraseMatcherRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PhraseMatcher + * + * @throws ApiException Thrown if the API call fails. + */ + public function getPhraseMatcher(GetPhraseMatcherRequest $request, array $callOptions = []): PhraseMatcher + { + return $this->startApiCall('GetPhraseMatcher', $request, $callOptions)->wait(); + } + + /** + * Gets project-level settings. + * + * The async variant is {@see ContactCenterInsightsClient::getSettingsAsync()} . + * + * @param GetSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Settings + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSettings(GetSettingsRequest $request, array $callOptions = []): Settings + { + return $this->startApiCall('GetSettings', $request, $callOptions)->wait(); + } + + /** + * Gets a view. + * + * The async variant is {@see ContactCenterInsightsClient::getViewAsync()} . + * + * @param GetViewRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 View + * + * @throws ApiException Thrown if the API call fails. + */ + public function getView(GetViewRequest $request, array $callOptions = []): View + { + return $this->startApiCall('GetView', $request, $callOptions)->wait(); + } + + /** + * Imports conversations and processes them according to the user's + * configuration. + * + * The async variant is + * {@see ContactCenterInsightsClient::ingestConversationsAsync()} . + * + * @param IngestConversationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function ingestConversations(IngestConversationsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('IngestConversations', $request, $callOptions)->wait(); + } + + /** + * Lists analyses. + * + * The async variant is {@see ContactCenterInsightsClient::listAnalysesAsync()} . + * + * @param ListAnalysesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAnalyses(ListAnalysesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAnalyses', $request, $callOptions); + } + + /** + * Lists conversations. + * + * The async variant is + * {@see ContactCenterInsightsClient::listConversationsAsync()} . + * + * @param ListConversationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listConversations(ListConversationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListConversations', $request, $callOptions); + } + + /** + * Lists issue models. + * + * The async variant is {@see ContactCenterInsightsClient::listIssueModelsAsync()} + * . + * + * @param ListIssueModelsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ListIssueModelsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listIssueModels(ListIssueModelsRequest $request, array $callOptions = []): ListIssueModelsResponse + { + return $this->startApiCall('ListIssueModels', $request, $callOptions)->wait(); + } + + /** + * Lists issues. + * + * The async variant is {@see ContactCenterInsightsClient::listIssuesAsync()} . + * + * @param ListIssuesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ListIssuesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listIssues(ListIssuesRequest $request, array $callOptions = []): ListIssuesResponse + { + return $this->startApiCall('ListIssues', $request, $callOptions)->wait(); + } + + /** + * Lists phrase matchers. + * + * The async variant is + * {@see ContactCenterInsightsClient::listPhraseMatchersAsync()} . + * + * @param ListPhraseMatchersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPhraseMatchers(ListPhraseMatchersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPhraseMatchers', $request, $callOptions); + } + + /** + * Lists views. + * + * The async variant is {@see ContactCenterInsightsClient::listViewsAsync()} . + * + * @param ListViewsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listViews(ListViewsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListViews', $request, $callOptions); + } + + /** + * Undeploys an issue model. + * An issue model can not be used in analysis after it has been undeployed. + * + * The async variant is + * {@see ContactCenterInsightsClient::undeployIssueModelAsync()} . + * + * @param UndeployIssueModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function undeployIssueModel(UndeployIssueModelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UndeployIssueModel', $request, $callOptions)->wait(); + } + + /** + * Updates a conversation. + * + * The async variant is + * {@see ContactCenterInsightsClient::updateConversationAsync()} . + * + * @param UpdateConversationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Conversation + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateConversation(UpdateConversationRequest $request, array $callOptions = []): Conversation + { + return $this->startApiCall('UpdateConversation', $request, $callOptions)->wait(); + } + + /** + * Updates an issue. + * + * The async variant is {@see ContactCenterInsightsClient::updateIssueAsync()} . + * + * @param UpdateIssueRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Issue + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateIssue(UpdateIssueRequest $request, array $callOptions = []): Issue + { + return $this->startApiCall('UpdateIssue', $request, $callOptions)->wait(); + } + + /** + * Updates an issue model. + * + * The async variant is {@see ContactCenterInsightsClient::updateIssueModelAsync()} + * . + * + * @param UpdateIssueModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 IssueModel + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateIssueModel(UpdateIssueModelRequest $request, array $callOptions = []): IssueModel + { + return $this->startApiCall('UpdateIssueModel', $request, $callOptions)->wait(); + } + + /** + * Updates a phrase matcher. + * + * The async variant is + * {@see ContactCenterInsightsClient::updatePhraseMatcherAsync()} . + * + * @param UpdatePhraseMatcherRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PhraseMatcher + * + * @throws ApiException Thrown if the API call fails. + */ + public function updatePhraseMatcher(UpdatePhraseMatcherRequest $request, array $callOptions = []): PhraseMatcher + { + return $this->startApiCall('UpdatePhraseMatcher', $request, $callOptions)->wait(); + } + + /** + * Updates project-level settings. + * + * The async variant is {@see ContactCenterInsightsClient::updateSettingsAsync()} . + * + * @param UpdateSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Settings + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSettings(UpdateSettingsRequest $request, array $callOptions = []): Settings + { + return $this->startApiCall('UpdateSettings', $request, $callOptions)->wait(); + } + + /** + * Updates a view. + * + * The async variant is {@see ContactCenterInsightsClient::updateViewAsync()} . + * + * @param UpdateViewRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 View + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateView(UpdateViewRequest $request, array $callOptions = []): View + { + return $this->startApiCall('UpdateView', $request, $callOptions)->wait(); + } + + /** + * Create a longrunning conversation upload operation. This method differs + * from CreateConversation by allowing audio transcription and optional DLP + * redaction. + * + * The async variant is + * {@see ContactCenterInsightsClient::uploadConversationAsync()} . + * + * @param UploadConversationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function uploadConversation(UploadConversationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UploadConversation', $request, $callOptions)->wait(); + } } diff --git a/Container/composer.json b/Container/composer.json index 287a02878df9..1ad3baa9d561 100644 --- a/Container/composer.json +++ b/Container/composer.json @@ -19,10 +19,10 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", - "google/cloud-core": "^1.39" + "google/cloud-core": "^1.52.7" } } diff --git a/Container/src/V1/Client/BaseClient/ClusterManagerBaseClient.php b/Container/src/V1/Client/BaseClient/ClusterManagerBaseClient.php deleted file mode 100644 index cc900f7372ba..000000000000 --- a/Container/src/V1/Client/BaseClient/ClusterManagerBaseClient.php +++ /dev/null @@ -1,1135 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/cluster_manager_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/cluster_manager_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/cluster_manager_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/cluster_manager_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a topic - * resource. - * - * @param string $project - * @param string $topic - * - * @return string The formatted topic resource. - */ - public static function topicName(string $project, string $topic): string - { - return self::getPathTemplate('topic')->render([ - 'project' => $project, - 'topic' => $topic, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - topic: projects/{project}/topics/{topic} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'container.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Cancels the specified operation. - * - * The async variant is {@see self::cancelOperationAsync()} . - * - * @param CancelOperationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function cancelOperation(CancelOperationRequest $request, array $callOptions = []): void - { - $this->startApiCall('CancelOperation', $request, $callOptions)->wait(); - } - - /** - * Checks the cluster compatibility with Autopilot mode, and returns a list of - * compatibility issues. - * - * The async variant is {@see self::checkAutopilotCompatibilityAsync()} . - * - * @param CheckAutopilotCompatibilityRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CheckAutopilotCompatibilityResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function checkAutopilotCompatibility(CheckAutopilotCompatibilityRequest $request, array $callOptions = []): CheckAutopilotCompatibilityResponse - { - return $this->startApiCall('CheckAutopilotCompatibility', $request, $callOptions)->wait(); - } - - /** - * Completes master IP rotation. - * - * The async variant is {@see self::completeIPRotationAsync()} . - * - * @param CompleteIPRotationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function completeIPRotation(CompleteIPRotationRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('CompleteIPRotation', $request, $callOptions)->wait(); - } - - /** - * CompleteNodePoolUpgrade will signal an on-going node pool upgrade to - * complete. - * - * The async variant is {@see self::completeNodePoolUpgradeAsync()} . - * - * @param CompleteNodePoolUpgradeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function completeNodePoolUpgrade(CompleteNodePoolUpgradeRequest $request, array $callOptions = []): void - { - $this->startApiCall('CompleteNodePoolUpgrade', $request, $callOptions)->wait(); - } - - /** - * Creates a cluster, consisting of the specified number and type of Google - * Compute Engine instances. - * - * By default, the cluster is created in the project's - * [default - * network](https://cloud.google.com/compute/docs/networks-and-firewalls#networks). - * - * One firewall is added for the cluster. After cluster creation, - * the Kubelet creates routes for each node to allow the containers - * on that node to communicate with all other instances in the - * cluster. - * - * Finally, an entry is added to the project's global metadata indicating - * which CIDR range the cluster is using. - * - * The async variant is {@see self::createClusterAsync()} . - * - * @param CreateClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCluster(CreateClusterRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('CreateCluster', $request, $callOptions)->wait(); - } - - /** - * Creates a node pool for a cluster. - * - * The async variant is {@see self::createNodePoolAsync()} . - * - * @param CreateNodePoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function createNodePool(CreateNodePoolRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('CreateNodePool', $request, $callOptions)->wait(); - } - - /** - * Deletes the cluster, including the Kubernetes endpoint and all worker - * nodes. - * - * Firewalls and routes that were configured during cluster creation - * are also deleted. - * - * Other Google Compute Engine resources that might be in use by the cluster, - * such as load balancer resources, are not deleted if they weren't present - * when the cluster was initially created. - * - * The async variant is {@see self::deleteClusterAsync()} . - * - * @param DeleteClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteCluster(DeleteClusterRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('DeleteCluster', $request, $callOptions)->wait(); - } - - /** - * Deletes a node pool from a cluster. - * - * The async variant is {@see self::deleteNodePoolAsync()} . - * - * @param DeleteNodePoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteNodePool(DeleteNodePoolRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('DeleteNodePool', $request, $callOptions)->wait(); - } - - /** - * Gets the details of a specific cluster. - * - * The async variant is {@see self::getClusterAsync()} . - * - * @param GetClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Cluster - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCluster(GetClusterRequest $request, array $callOptions = []): Cluster - { - return $this->startApiCall('GetCluster', $request, $callOptions)->wait(); - } - - /** - * Gets the public component of the cluster signing keys in - * JSON Web Key format. - * This API is not yet intended for general use, and is not available for all - * clusters. - * - * The async variant is {@see self::getJSONWebKeysAsync()} . - * - * @param GetJSONWebKeysRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GetJSONWebKeysResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function getJSONWebKeys(GetJSONWebKeysRequest $request, array $callOptions = []): GetJSONWebKeysResponse - { - return $this->startApiCall('GetJSONWebKeys', $request, $callOptions)->wait(); - } - - /** - * Retrieves the requested node pool. - * - * The async variant is {@see self::getNodePoolAsync()} . - * - * @param GetNodePoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NodePool - * - * @throws ApiException Thrown if the API call fails. - */ - public function getNodePool(GetNodePoolRequest $request, array $callOptions = []): NodePool - { - return $this->startApiCall('GetNodePool', $request, $callOptions)->wait(); - } - - /** - * Gets the specified operation. - * - * The async variant is {@see self::getOperationAsync()} . - * - * @param GetOperationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function getOperation(GetOperationRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('GetOperation', $request, $callOptions)->wait(); - } - - /** - * Returns configuration info about the Google Kubernetes Engine service. - * - * The async variant is {@see self::getServerConfigAsync()} . - * - * @param GetServerConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ServerConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getServerConfig(GetServerConfigRequest $request, array $callOptions = []): ServerConfig - { - return $this->startApiCall('GetServerConfig', $request, $callOptions)->wait(); - } - - /** - * Lists all clusters owned by a project in either the specified zone or all - * zones. - * - * The async variant is {@see self::listClustersAsync()} . - * - * @param ListClustersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ListClustersResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listClusters(ListClustersRequest $request, array $callOptions = []): ListClustersResponse - { - return $this->startApiCall('ListClusters', $request, $callOptions)->wait(); - } - - /** - * Lists the node pools for a cluster. - * - * The async variant is {@see self::listNodePoolsAsync()} . - * - * @param ListNodePoolsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ListNodePoolsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listNodePools(ListNodePoolsRequest $request, array $callOptions = []): ListNodePoolsResponse - { - return $this->startApiCall('ListNodePools', $request, $callOptions)->wait(); - } - - /** - * Lists all operations in a project in a specific zone or all zones. - * - * The async variant is {@see self::listOperationsAsync()} . - * - * @param ListOperationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ListOperationsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listOperations(ListOperationsRequest $request, array $callOptions = []): ListOperationsResponse - { - return $this->startApiCall('ListOperations', $request, $callOptions)->wait(); - } - - /** - * Lists subnetworks that are usable for creating clusters in a project. - * - * The async variant is {@see self::listUsableSubnetworksAsync()} . - * - * @param ListUsableSubnetworksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listUsableSubnetworks(ListUsableSubnetworksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListUsableSubnetworks', $request, $callOptions); - } - - /** - * Rolls back a previously Aborted or Failed NodePool upgrade. - * This makes no changes if the last upgrade successfully completed. - * - * The async variant is {@see self::rollbackNodePoolUpgradeAsync()} . - * - * @param RollbackNodePoolUpgradeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function rollbackNodePoolUpgrade(RollbackNodePoolUpgradeRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('RollbackNodePoolUpgrade', $request, $callOptions)->wait(); - } - - /** - * Sets the addons for a specific cluster. - * - * The async variant is {@see self::setAddonsConfigAsync()} . - * - * @param SetAddonsConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function setAddonsConfig(SetAddonsConfigRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('SetAddonsConfig', $request, $callOptions)->wait(); - } - - /** - * Sets labels on a cluster. - * - * The async variant is {@see self::setLabelsAsync()} . - * - * @param SetLabelsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function setLabels(SetLabelsRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); - } - - /** - * Enables or disables the ABAC authorization mechanism on a cluster. - * - * The async variant is {@see self::setLegacyAbacAsync()} . - * - * @param SetLegacyAbacRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function setLegacyAbac(SetLegacyAbacRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('SetLegacyAbac', $request, $callOptions)->wait(); - } - - /** - * Sets the locations for a specific cluster. - * Deprecated. Use - * [projects.locations.clusters.update](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1/projects.locations.clusters/update) - * instead. - * - * The async variant is {@see self::setLocationsAsync()} . - * - * @param SetLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - * - * @deprecated This method will be removed in the next major version update. - */ - public function setLocations(SetLocationsRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('SetLocations', $request, $callOptions)->wait(); - } - - /** - * Sets the logging service for a specific cluster. - * - * The async variant is {@see self::setLoggingServiceAsync()} . - * - * @param SetLoggingServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function setLoggingService(SetLoggingServiceRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('SetLoggingService', $request, $callOptions)->wait(); - } - - /** - * Sets the maintenance policy for a cluster. - * - * The async variant is {@see self::setMaintenancePolicyAsync()} . - * - * @param SetMaintenancePolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function setMaintenancePolicy(SetMaintenancePolicyRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('SetMaintenancePolicy', $request, $callOptions)->wait(); - } - - /** - * Sets master auth materials. Currently supports changing the admin password - * or a specific cluster, either via password generation or explicitly setting - * the password. - * - * The async variant is {@see self::setMasterAuthAsync()} . - * - * @param SetMasterAuthRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function setMasterAuth(SetMasterAuthRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('SetMasterAuth', $request, $callOptions)->wait(); - } - - /** - * Sets the monitoring service for a specific cluster. - * - * The async variant is {@see self::setMonitoringServiceAsync()} . - * - * @param SetMonitoringServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function setMonitoringService(SetMonitoringServiceRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('SetMonitoringService', $request, $callOptions)->wait(); - } - - /** - * Enables or disables Network Policy for a cluster. - * - * The async variant is {@see self::setNetworkPolicyAsync()} . - * - * @param SetNetworkPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function setNetworkPolicy(SetNetworkPolicyRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('SetNetworkPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the autoscaling settings for the specified node pool. - * - * The async variant is {@see self::setNodePoolAutoscalingAsync()} . - * - * @param SetNodePoolAutoscalingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function setNodePoolAutoscaling(SetNodePoolAutoscalingRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('SetNodePoolAutoscaling', $request, $callOptions)->wait(); - } - - /** - * Sets the NodeManagement options for a node pool. - * - * The async variant is {@see self::setNodePoolManagementAsync()} . - * - * @param SetNodePoolManagementRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function setNodePoolManagement(SetNodePoolManagementRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('SetNodePoolManagement', $request, $callOptions)->wait(); - } - - /** - * Sets the size for a specific node pool. The new size will be used for all - * replicas, including future replicas created by modifying - * [NodePool.locations][google.container.v1.NodePool.locations]. - * - * The async variant is {@see self::setNodePoolSizeAsync()} . - * - * @param SetNodePoolSizeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function setNodePoolSize(SetNodePoolSizeRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('SetNodePoolSize', $request, $callOptions)->wait(); - } - - /** - * Starts master IP rotation. - * - * The async variant is {@see self::startIPRotationAsync()} . - * - * @param StartIPRotationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function startIPRotation(StartIPRotationRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('StartIPRotation', $request, $callOptions)->wait(); - } - - /** - * Updates the settings of a specific cluster. - * - * The async variant is {@see self::updateClusterAsync()} . - * - * @param UpdateClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCluster(UpdateClusterRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('UpdateCluster', $request, $callOptions)->wait(); - } - - /** - * Updates the master for a specific cluster. - * - * The async variant is {@see self::updateMasterAsync()} . - * - * @param UpdateMasterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateMaster(UpdateMasterRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('UpdateMaster', $request, $callOptions)->wait(); - } - - /** - * Updates the version and/or image type for the specified node pool. - * - * The async variant is {@see self::updateNodePoolAsync()} . - * - * @param UpdateNodePoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateNodePool(UpdateNodePoolRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('UpdateNodePool', $request, $callOptions)->wait(); - } -} diff --git a/Container/src/V1/Client/ClusterManagerClient.php b/Container/src/V1/Client/ClusterManagerClient.php index f5f20ace7098..d742f46fa1a8 100644 --- a/Container/src/V1/Client/ClusterManagerClient.php +++ b/Container/src/V1/Client/ClusterManagerClient.php @@ -24,17 +24,1114 @@ namespace Google\Cloud\Container\V1\Client; -use Google\Cloud\Container\V1\Client\BaseClient\ClusterManagerBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Container\V1\CancelOperationRequest; +use Google\Cloud\Container\V1\CheckAutopilotCompatibilityRequest; +use Google\Cloud\Container\V1\CheckAutopilotCompatibilityResponse; +use Google\Cloud\Container\V1\Cluster; +use Google\Cloud\Container\V1\CompleteIPRotationRequest; +use Google\Cloud\Container\V1\CompleteNodePoolUpgradeRequest; +use Google\Cloud\Container\V1\CreateClusterRequest; +use Google\Cloud\Container\V1\CreateNodePoolRequest; +use Google\Cloud\Container\V1\DeleteClusterRequest; +use Google\Cloud\Container\V1\DeleteNodePoolRequest; +use Google\Cloud\Container\V1\GetClusterRequest; +use Google\Cloud\Container\V1\GetJSONWebKeysRequest; +use Google\Cloud\Container\V1\GetJSONWebKeysResponse; +use Google\Cloud\Container\V1\GetNodePoolRequest; +use Google\Cloud\Container\V1\GetOperationRequest; +use Google\Cloud\Container\V1\GetServerConfigRequest; +use Google\Cloud\Container\V1\ListClustersRequest; +use Google\Cloud\Container\V1\ListClustersResponse; +use Google\Cloud\Container\V1\ListNodePoolsRequest; +use Google\Cloud\Container\V1\ListNodePoolsResponse; +use Google\Cloud\Container\V1\ListOperationsRequest; +use Google\Cloud\Container\V1\ListOperationsResponse; +use Google\Cloud\Container\V1\ListUsableSubnetworksRequest; +use Google\Cloud\Container\V1\NodePool; +use Google\Cloud\Container\V1\Operation; +use Google\Cloud\Container\V1\RollbackNodePoolUpgradeRequest; +use Google\Cloud\Container\V1\ServerConfig; +use Google\Cloud\Container\V1\SetAddonsConfigRequest; +use Google\Cloud\Container\V1\SetLabelsRequest; +use Google\Cloud\Container\V1\SetLegacyAbacRequest; +use Google\Cloud\Container\V1\SetLocationsRequest; +use Google\Cloud\Container\V1\SetLoggingServiceRequest; +use Google\Cloud\Container\V1\SetMaintenancePolicyRequest; +use Google\Cloud\Container\V1\SetMasterAuthRequest; +use Google\Cloud\Container\V1\SetMonitoringServiceRequest; +use Google\Cloud\Container\V1\SetNetworkPolicyRequest; +use Google\Cloud\Container\V1\SetNodePoolAutoscalingRequest; +use Google\Cloud\Container\V1\SetNodePoolManagementRequest; +use Google\Cloud\Container\V1\SetNodePoolSizeRequest; +use Google\Cloud\Container\V1\StartIPRotationRequest; +use Google\Cloud\Container\V1\UpdateClusterRequest; +use Google\Cloud\Container\V1\UpdateMasterRequest; +use Google\Cloud\Container\V1\UpdateNodePoolRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Google Kubernetes Engine Cluster Manager v1 * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Container\V1\ClusterManagerClient} for the stable implementation * * @experimental + * + * @method PromiseInterface cancelOperationAsync(CancelOperationRequest $request, array $optionalArgs = []) + * @method PromiseInterface checkAutopilotCompatibilityAsync(CheckAutopilotCompatibilityRequest $request, array $optionalArgs = []) + * @method PromiseInterface completeIPRotationAsync(CompleteIPRotationRequest $request, array $optionalArgs = []) + * @method PromiseInterface completeNodePoolUpgradeAsync(CompleteNodePoolUpgradeRequest $request, array $optionalArgs = []) + * @method PromiseInterface createClusterAsync(CreateClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface createNodePoolAsync(CreateNodePoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteClusterAsync(DeleteClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteNodePoolAsync(DeleteNodePoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface getClusterAsync(GetClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface getJSONWebKeysAsync(GetJSONWebKeysRequest $request, array $optionalArgs = []) + * @method PromiseInterface getNodePoolAsync(GetNodePoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface getOperationAsync(GetOperationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getServerConfigAsync(GetServerConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface listClustersAsync(ListClustersRequest $request, array $optionalArgs = []) + * @method PromiseInterface listNodePoolsAsync(ListNodePoolsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listOperationsAsync(ListOperationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listUsableSubnetworksAsync(ListUsableSubnetworksRequest $request, array $optionalArgs = []) + * @method PromiseInterface rollbackNodePoolUpgradeAsync(RollbackNodePoolUpgradeRequest $request, array $optionalArgs = []) + * @method PromiseInterface setAddonsConfigAsync(SetAddonsConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface setLabelsAsync(SetLabelsRequest $request, array $optionalArgs = []) + * @method PromiseInterface setLegacyAbacAsync(SetLegacyAbacRequest $request, array $optionalArgs = []) + * @method PromiseInterface setLocationsAsync(SetLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface setLoggingServiceAsync(SetLoggingServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setMaintenancePolicyAsync(SetMaintenancePolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setMasterAuthAsync(SetMasterAuthRequest $request, array $optionalArgs = []) + * @method PromiseInterface setMonitoringServiceAsync(SetMonitoringServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setNetworkPolicyAsync(SetNetworkPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setNodePoolAutoscalingAsync(SetNodePoolAutoscalingRequest $request, array $optionalArgs = []) + * @method PromiseInterface setNodePoolManagementAsync(SetNodePoolManagementRequest $request, array $optionalArgs = []) + * @method PromiseInterface setNodePoolSizeAsync(SetNodePoolSizeRequest $request, array $optionalArgs = []) + * @method PromiseInterface startIPRotationAsync(StartIPRotationRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateClusterAsync(UpdateClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateMasterAsync(UpdateMasterRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateNodePoolAsync(UpdateNodePoolRequest $request, array $optionalArgs = []) */ -final class ClusterManagerClient extends ClusterManagerBaseClient +final class ClusterManagerClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ClusterManagerBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.container.v1.ClusterManager'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'container.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/cluster_manager_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/cluster_manager_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/cluster_manager_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/cluster_manager_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a topic + * resource. + * + * @param string $project + * @param string $topic + * + * @return string The formatted topic resource. + */ + public static function topicName(string $project, string $topic): string + { + return self::getPathTemplate('topic')->render([ + 'project' => $project, + 'topic' => $topic, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - topic: projects/{project}/topics/{topic} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'container.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Cancels the specified operation. + * + * The async variant is {@see ClusterManagerClient::cancelOperationAsync()} . + * + * @param CancelOperationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function cancelOperation(CancelOperationRequest $request, array $callOptions = []): void + { + $this->startApiCall('CancelOperation', $request, $callOptions)->wait(); + } + + /** + * Checks the cluster compatibility with Autopilot mode, and returns a list of + * compatibility issues. + * + * The async variant is + * {@see ClusterManagerClient::checkAutopilotCompatibilityAsync()} . + * + * @param CheckAutopilotCompatibilityRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CheckAutopilotCompatibilityResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function checkAutopilotCompatibility(CheckAutopilotCompatibilityRequest $request, array $callOptions = []): CheckAutopilotCompatibilityResponse + { + return $this->startApiCall('CheckAutopilotCompatibility', $request, $callOptions)->wait(); + } + + /** + * Completes master IP rotation. + * + * The async variant is {@see ClusterManagerClient::completeIPRotationAsync()} . + * + * @param CompleteIPRotationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function completeIPRotation(CompleteIPRotationRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('CompleteIPRotation', $request, $callOptions)->wait(); + } + + /** + * CompleteNodePoolUpgrade will signal an on-going node pool upgrade to + * complete. + * + * The async variant is {@see ClusterManagerClient::completeNodePoolUpgradeAsync()} + * . + * + * @param CompleteNodePoolUpgradeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function completeNodePoolUpgrade(CompleteNodePoolUpgradeRequest $request, array $callOptions = []): void + { + $this->startApiCall('CompleteNodePoolUpgrade', $request, $callOptions)->wait(); + } + + /** + * Creates a cluster, consisting of the specified number and type of Google + * Compute Engine instances. + * + * By default, the cluster is created in the project's + * [default + * network](https://cloud.google.com/compute/docs/networks-and-firewalls#networks). + * + * One firewall is added for the cluster. After cluster creation, + * the Kubelet creates routes for each node to allow the containers + * on that node to communicate with all other instances in the + * cluster. + * + * Finally, an entry is added to the project's global metadata indicating + * which CIDR range the cluster is using. + * + * The async variant is {@see ClusterManagerClient::createClusterAsync()} . + * + * @param CreateClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCluster(CreateClusterRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('CreateCluster', $request, $callOptions)->wait(); + } + + /** + * Creates a node pool for a cluster. + * + * The async variant is {@see ClusterManagerClient::createNodePoolAsync()} . + * + * @param CreateNodePoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function createNodePool(CreateNodePoolRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('CreateNodePool', $request, $callOptions)->wait(); + } + + /** + * Deletes the cluster, including the Kubernetes endpoint and all worker + * nodes. + * + * Firewalls and routes that were configured during cluster creation + * are also deleted. + * + * Other Google Compute Engine resources that might be in use by the cluster, + * such as load balancer resources, are not deleted if they weren't present + * when the cluster was initially created. + * + * The async variant is {@see ClusterManagerClient::deleteClusterAsync()} . + * + * @param DeleteClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteCluster(DeleteClusterRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('DeleteCluster', $request, $callOptions)->wait(); + } + + /** + * Deletes a node pool from a cluster. + * + * The async variant is {@see ClusterManagerClient::deleteNodePoolAsync()} . + * + * @param DeleteNodePoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteNodePool(DeleteNodePoolRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('DeleteNodePool', $request, $callOptions)->wait(); + } + + /** + * Gets the details of a specific cluster. + * + * The async variant is {@see ClusterManagerClient::getClusterAsync()} . + * + * @param GetClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Cluster + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCluster(GetClusterRequest $request, array $callOptions = []): Cluster + { + return $this->startApiCall('GetCluster', $request, $callOptions)->wait(); + } + + /** + * Gets the public component of the cluster signing keys in + * JSON Web Key format. + * This API is not yet intended for general use, and is not available for all + * clusters. + * + * The async variant is {@see ClusterManagerClient::getJSONWebKeysAsync()} . + * + * @param GetJSONWebKeysRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GetJSONWebKeysResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function getJSONWebKeys(GetJSONWebKeysRequest $request, array $callOptions = []): GetJSONWebKeysResponse + { + return $this->startApiCall('GetJSONWebKeys', $request, $callOptions)->wait(); + } + + /** + * Retrieves the requested node pool. + * + * The async variant is {@see ClusterManagerClient::getNodePoolAsync()} . + * + * @param GetNodePoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NodePool + * + * @throws ApiException Thrown if the API call fails. + */ + public function getNodePool(GetNodePoolRequest $request, array $callOptions = []): NodePool + { + return $this->startApiCall('GetNodePool', $request, $callOptions)->wait(); + } + + /** + * Gets the specified operation. + * + * The async variant is {@see ClusterManagerClient::getOperationAsync()} . + * + * @param GetOperationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function getOperation(GetOperationRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('GetOperation', $request, $callOptions)->wait(); + } + + /** + * Returns configuration info about the Google Kubernetes Engine service. + * + * The async variant is {@see ClusterManagerClient::getServerConfigAsync()} . + * + * @param GetServerConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ServerConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getServerConfig(GetServerConfigRequest $request, array $callOptions = []): ServerConfig + { + return $this->startApiCall('GetServerConfig', $request, $callOptions)->wait(); + } + + /** + * Lists all clusters owned by a project in either the specified zone or all + * zones. + * + * The async variant is {@see ClusterManagerClient::listClustersAsync()} . + * + * @param ListClustersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ListClustersResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listClusters(ListClustersRequest $request, array $callOptions = []): ListClustersResponse + { + return $this->startApiCall('ListClusters', $request, $callOptions)->wait(); + } + + /** + * Lists the node pools for a cluster. + * + * The async variant is {@see ClusterManagerClient::listNodePoolsAsync()} . + * + * @param ListNodePoolsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ListNodePoolsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listNodePools(ListNodePoolsRequest $request, array $callOptions = []): ListNodePoolsResponse + { + return $this->startApiCall('ListNodePools', $request, $callOptions)->wait(); + } + + /** + * Lists all operations in a project in a specific zone or all zones. + * + * The async variant is {@see ClusterManagerClient::listOperationsAsync()} . + * + * @param ListOperationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ListOperationsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listOperations(ListOperationsRequest $request, array $callOptions = []): ListOperationsResponse + { + return $this->startApiCall('ListOperations', $request, $callOptions)->wait(); + } + + /** + * Lists subnetworks that are usable for creating clusters in a project. + * + * The async variant is {@see ClusterManagerClient::listUsableSubnetworksAsync()} . + * + * @param ListUsableSubnetworksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listUsableSubnetworks(ListUsableSubnetworksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListUsableSubnetworks', $request, $callOptions); + } + + /** + * Rolls back a previously Aborted or Failed NodePool upgrade. + * This makes no changes if the last upgrade successfully completed. + * + * The async variant is {@see ClusterManagerClient::rollbackNodePoolUpgradeAsync()} + * . + * + * @param RollbackNodePoolUpgradeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function rollbackNodePoolUpgrade(RollbackNodePoolUpgradeRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('RollbackNodePoolUpgrade', $request, $callOptions)->wait(); + } + + /** + * Sets the addons for a specific cluster. + * + * The async variant is {@see ClusterManagerClient::setAddonsConfigAsync()} . + * + * @param SetAddonsConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function setAddonsConfig(SetAddonsConfigRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('SetAddonsConfig', $request, $callOptions)->wait(); + } + + /** + * Sets labels on a cluster. + * + * The async variant is {@see ClusterManagerClient::setLabelsAsync()} . + * + * @param SetLabelsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function setLabels(SetLabelsRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('SetLabels', $request, $callOptions)->wait(); + } + + /** + * Enables or disables the ABAC authorization mechanism on a cluster. + * + * The async variant is {@see ClusterManagerClient::setLegacyAbacAsync()} . + * + * @param SetLegacyAbacRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function setLegacyAbac(SetLegacyAbacRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('SetLegacyAbac', $request, $callOptions)->wait(); + } + + /** + * Sets the locations for a specific cluster. + * Deprecated. Use + * [projects.locations.clusters.update](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1/projects.locations.clusters/update) + * instead. + * + * The async variant is {@see ClusterManagerClient::setLocationsAsync()} . + * + * @param SetLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + * + * @deprecated This method will be removed in the next major version update. + */ + public function setLocations(SetLocationsRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('SetLocations', $request, $callOptions)->wait(); + } + + /** + * Sets the logging service for a specific cluster. + * + * The async variant is {@see ClusterManagerClient::setLoggingServiceAsync()} . + * + * @param SetLoggingServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function setLoggingService(SetLoggingServiceRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('SetLoggingService', $request, $callOptions)->wait(); + } + + /** + * Sets the maintenance policy for a cluster. + * + * The async variant is {@see ClusterManagerClient::setMaintenancePolicyAsync()} . + * + * @param SetMaintenancePolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function setMaintenancePolicy(SetMaintenancePolicyRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('SetMaintenancePolicy', $request, $callOptions)->wait(); + } + + /** + * Sets master auth materials. Currently supports changing the admin password + * or a specific cluster, either via password generation or explicitly setting + * the password. + * + * The async variant is {@see ClusterManagerClient::setMasterAuthAsync()} . + * + * @param SetMasterAuthRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function setMasterAuth(SetMasterAuthRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('SetMasterAuth', $request, $callOptions)->wait(); + } + + /** + * Sets the monitoring service for a specific cluster. + * + * The async variant is {@see ClusterManagerClient::setMonitoringServiceAsync()} . + * + * @param SetMonitoringServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function setMonitoringService(SetMonitoringServiceRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('SetMonitoringService', $request, $callOptions)->wait(); + } + + /** + * Enables or disables Network Policy for a cluster. + * + * The async variant is {@see ClusterManagerClient::setNetworkPolicyAsync()} . + * + * @param SetNetworkPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function setNetworkPolicy(SetNetworkPolicyRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('SetNetworkPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the autoscaling settings for the specified node pool. + * + * The async variant is {@see ClusterManagerClient::setNodePoolAutoscalingAsync()} + * . + * + * @param SetNodePoolAutoscalingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function setNodePoolAutoscaling(SetNodePoolAutoscalingRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('SetNodePoolAutoscaling', $request, $callOptions)->wait(); + } + + /** + * Sets the NodeManagement options for a node pool. + * + * The async variant is {@see ClusterManagerClient::setNodePoolManagementAsync()} . + * + * @param SetNodePoolManagementRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function setNodePoolManagement(SetNodePoolManagementRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('SetNodePoolManagement', $request, $callOptions)->wait(); + } + + /** + * Sets the size for a specific node pool. The new size will be used for all + * replicas, including future replicas created by modifying + * [NodePool.locations][google.container.v1.NodePool.locations]. + * + * The async variant is {@see ClusterManagerClient::setNodePoolSizeAsync()} . + * + * @param SetNodePoolSizeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function setNodePoolSize(SetNodePoolSizeRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('SetNodePoolSize', $request, $callOptions)->wait(); + } + + /** + * Starts master IP rotation. + * + * The async variant is {@see ClusterManagerClient::startIPRotationAsync()} . + * + * @param StartIPRotationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function startIPRotation(StartIPRotationRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('StartIPRotation', $request, $callOptions)->wait(); + } + + /** + * Updates the settings of a specific cluster. + * + * The async variant is {@see ClusterManagerClient::updateClusterAsync()} . + * + * @param UpdateClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCluster(UpdateClusterRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('UpdateCluster', $request, $callOptions)->wait(); + } + + /** + * Updates the master for a specific cluster. + * + * The async variant is {@see ClusterManagerClient::updateMasterAsync()} . + * + * @param UpdateMasterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateMaster(UpdateMasterRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('UpdateMaster', $request, $callOptions)->wait(); + } + + /** + * Updates the version and/or image type for the specified node pool. + * + * The async variant is {@see ClusterManagerClient::updateNodePoolAsync()} . + * + * @param UpdateNodePoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateNodePool(UpdateNodePoolRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('UpdateNodePool', $request, $callOptions)->wait(); + } } diff --git a/ContainerAnalysis/composer.json b/ContainerAnalysis/composer.json index 39d9027e5f64..8cc8c1da0f5d 100644 --- a/ContainerAnalysis/composer.json +++ b/ContainerAnalysis/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1", + "google/gax": "^1.24.0", "google/grafeas": "^0.8.0" }, "require-dev": { diff --git a/ContainerAnalysis/src/V1/Client/BaseClient/ContainerAnalysisBaseClient.php b/ContainerAnalysis/src/V1/Client/BaseClient/ContainerAnalysisBaseClient.php deleted file mode 100644 index 283f66a64b9b..000000000000 --- a/ContainerAnalysis/src/V1/Client/BaseClient/ContainerAnalysisBaseClient.php +++ /dev/null @@ -1,354 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/container_analysis_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/container_analysis_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/container_analysis_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/container_analysis_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->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. - */ - public static function parseName(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'containeranalysis.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Gets the access control policy for a note or an occurrence resource. - * Requires `containeranalysis.notes.setIamPolicy` or - * `containeranalysis.occurrences.setIamPolicy` permission if the resource is - * a note or occurrence, respectively. - * - * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for - * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for - * occurrences. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/ContainerAnalysisClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets a summary of the number and severity of occurrences. - * - * The async variant is {@see self::getVulnerabilityOccurrencesSummaryAsync()} . - * - * @example samples/V1/ContainerAnalysisClient/get_vulnerability_occurrences_summary.php - * - * @param GetVulnerabilityOccurrencesSummaryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 VulnerabilityOccurrencesSummary - * - * @throws ApiException Thrown if the API call fails. - */ - public function getVulnerabilityOccurrencesSummary(GetVulnerabilityOccurrencesSummaryRequest $request, array $callOptions = []): VulnerabilityOccurrencesSummary - { - return $this->startApiCall('GetVulnerabilityOccurrencesSummary', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified note or occurrence. - * Requires `containeranalysis.notes.setIamPolicy` or - * `containeranalysis.occurrences.setIamPolicy` permission if the resource is - * a note or an occurrence, respectively. - * - * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for - * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for - * occurrences. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/ContainerAnalysisClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns the permissions that a caller has on the specified note or - * occurrence. Requires list permission on the project (for example, - * `containeranalysis.notes.list`). - * - * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for - * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for - * occurrences. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/ContainerAnalysisClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/ContainerAnalysis/src/V1/Client/ContainerAnalysisClient.php b/ContainerAnalysis/src/V1/Client/ContainerAnalysisClient.php index a15c4877553d..1191be91fba6 100644 --- a/ContainerAnalysis/src/V1/Client/ContainerAnalysisClient.php +++ b/ContainerAnalysis/src/V1/Client/ContainerAnalysisClient.php @@ -24,17 +24,330 @@ namespace Google\Cloud\ContainerAnalysis\V1\Client; -use Google\Cloud\ContainerAnalysis\V1\Client\BaseClient\ContainerAnalysisBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\ContainerAnalysis\V1\GetVulnerabilityOccurrencesSummaryRequest; +use Google\Cloud\ContainerAnalysis\V1\VulnerabilityOccurrencesSummary; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Retrieves analysis results of Cloud components such as Docker container + * images. The Container Analysis API is an implementation of the + * [Grafeas](https://grafeas.io) API. * - * This class is currently experimental and may be subject to changes. + * Analysis results are stored as a series of occurrences. An `Occurrence` + * contains information about a specific analysis instance on a resource. An + * occurrence refers to a `Note`. A note contains details describing the + * analysis and is generally stored in a separate project, called a `Provider`. + * Multiple occurrences can refer to the same note. + * + * For example, an SSL vulnerability could affect multiple images. In this case, + * there would be one note for the vulnerability and an occurrence for each + * image with the vulnerability referring to that note. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ContainerAnalysis\V1\ContainerAnalysisClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getVulnerabilityOccurrencesSummaryAsync(GetVulnerabilityOccurrencesSummaryRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class ContainerAnalysisClient extends ContainerAnalysisBaseClient +final class ContainerAnalysisClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ContainerAnalysisBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.devtools.containeranalysis.v1.ContainerAnalysis'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'containeranalysis.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/container_analysis_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/container_analysis_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/container_analysis_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/container_analysis_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->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. + */ + public static function parseName(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'containeranalysis.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Gets the access control policy for a note or an occurrence resource. + * Requires `containeranalysis.notes.setIamPolicy` or + * `containeranalysis.occurrences.setIamPolicy` permission if the resource is + * a note or occurrence, respectively. + * + * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for + * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for + * occurrences. + * + * The async variant is {@see ContainerAnalysisClient::getIamPolicyAsync()} . + * + * @example samples/V1/ContainerAnalysisClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets a summary of the number and severity of occurrences. + * + * The async variant is + * {@see ContainerAnalysisClient::getVulnerabilityOccurrencesSummaryAsync()} . + * + * @example samples/V1/ContainerAnalysisClient/get_vulnerability_occurrences_summary.php + * + * @param GetVulnerabilityOccurrencesSummaryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 VulnerabilityOccurrencesSummary + * + * @throws ApiException Thrown if the API call fails. + */ + public function getVulnerabilityOccurrencesSummary(GetVulnerabilityOccurrencesSummaryRequest $request, array $callOptions = []): VulnerabilityOccurrencesSummary + { + return $this->startApiCall('GetVulnerabilityOccurrencesSummary', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified note or occurrence. + * Requires `containeranalysis.notes.setIamPolicy` or + * `containeranalysis.occurrences.setIamPolicy` permission if the resource is + * a note or an occurrence, respectively. + * + * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for + * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for + * occurrences. + * + * The async variant is {@see ContainerAnalysisClient::setIamPolicyAsync()} . + * + * @example samples/V1/ContainerAnalysisClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns the permissions that a caller has on the specified note or + * occurrence. Requires list permission on the project (for example, + * `containeranalysis.notes.list`). + * + * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for + * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for + * occurrences. + * + * The async variant is {@see ContainerAnalysisClient::testIamPermissionsAsync()} . + * + * @example samples/V1/ContainerAnalysisClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Core/VERSION b/Core/VERSION index b9ed8d0449c4..6f6dbbd77198 100644 --- a/Core/VERSION +++ b/Core/VERSION @@ -1 +1 @@ -1.52.5 +1.52.6 diff --git a/Core/composer.json b/Core/composer.json index f9e295c9f1fd..63aff87d114c 100644 --- a/Core/composer.json +++ b/Core/composer.json @@ -19,7 +19,7 @@ "squizlabs/php_codesniffer": "2.*", "phpdocumentor/reflection": "^5.0", "erusev/parsedown": "^1.6", - "google/gax": "^1.19.1", + "google/gax": "^1.24.0", "opis/closure": "^3", "google/cloud-common-protos": "^0.4" }, diff --git a/Core/src/RequestWrapper.php b/Core/src/RequestWrapper.php index 407e03bca874..f45e7a7a568f 100644 --- a/Core/src/RequestWrapper.php +++ b/Core/src/RequestWrapper.php @@ -101,6 +101,7 @@ class RequestWrapper * @type string $componentVersion The current version of the component from * which the request originated. * @type string $accessToken Access token used to sign requests. + * Deprecated: This option is no longer supported. Use the `$credentialsFetcher` option instead. * @type callable $asyncHttpHandler *Experimental* A handler used to * deliver PSR-7 requests asynchronously. Function signature should match: * `function (RequestInterface $request, array $options = []) : PromiseInterface`. diff --git a/DataCatalog/composer.json b/DataCatalog/composer.json index 84ebe7f943f8..cb14d9668dff 100644 --- a/DataCatalog/composer.json +++ b/DataCatalog/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/DataCatalog/src/V1/Client/BaseClient/DataCatalogBaseClient.php b/DataCatalog/src/V1/Client/BaseClient/DataCatalogBaseClient.php deleted file mode 100644 index f9619db55d46..000000000000 --- a/DataCatalog/src/V1/Client/BaseClient/DataCatalogBaseClient.php +++ /dev/null @@ -1,1486 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/data_catalog_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/data_catalog_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/data_catalog_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/data_catalog_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a entry - * resource. - * - * @param string $project - * @param string $location - * @param string $entryGroup - * @param string $entry - * - * @return string The formatted entry resource. - */ - public static function entryName(string $project, string $location, string $entryGroup, string $entry): string - { - return self::getPathTemplate('entry')->render([ - 'project' => $project, - 'location' => $location, - 'entry_group' => $entryGroup, - 'entry' => $entry, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a entry_group - * resource. - * - * @param string $project - * @param string $location - * @param string $entryGroup - * - * @return string The formatted entry_group resource. - */ - public static function entryGroupName(string $project, string $location, string $entryGroup): string - { - return self::getPathTemplate('entryGroup')->render([ - 'project' => $project, - 'location' => $location, - 'entry_group' => $entryGroup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a tag - * resource. - * - * @param string $project - * @param string $location - * @param string $entryGroup - * @param string $entry - * @param string $tag - * - * @return string The formatted tag resource. - */ - public static function tagName(string $project, string $location, string $entryGroup, string $entry, string $tag): string - { - return self::getPathTemplate('tag')->render([ - 'project' => $project, - 'location' => $location, - 'entry_group' => $entryGroup, - 'entry' => $entry, - 'tag' => $tag, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a tag_template - * resource. - * - * @param string $project - * @param string $location - * @param string $tagTemplate - * - * @return string The formatted tag_template resource. - */ - public static function tagTemplateName(string $project, string $location, string $tagTemplate): string - { - return self::getPathTemplate('tagTemplate')->render([ - 'project' => $project, - 'location' => $location, - 'tag_template' => $tagTemplate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * tag_template_field resource. - * - * @param string $project - * @param string $location - * @param string $tagTemplate - * @param string $field - * - * @return string The formatted tag_template_field resource. - */ - public static function tagTemplateFieldName(string $project, string $location, string $tagTemplate, string $field): string - { - return self::getPathTemplate('tagTemplateField')->render([ - 'project' => $project, - 'location' => $location, - 'tag_template' => $tagTemplate, - 'field' => $field, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * tag_template_field_enum_value resource. - * - * @param string $project - * @param string $location - * @param string $tagTemplate - * @param string $tagTemplateFieldId - * @param string $enumValueDisplayName - * - * @return string The formatted tag_template_field_enum_value resource. - */ - public static function tagTemplateFieldEnumValueName(string $project, string $location, string $tagTemplate, string $tagTemplateFieldId, string $enumValueDisplayName): string - { - return self::getPathTemplate('tagTemplateFieldEnumValue')->render([ - 'project' => $project, - 'location' => $location, - 'tag_template' => $tagTemplate, - 'tag_template_field_id' => $tagTemplateFieldId, - 'enum_value_display_name' => $enumValueDisplayName, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - entry: projects/{project}/locations/{location}/entryGroups/{entry_group}/entries/{entry} - * - entryGroup: projects/{project}/locations/{location}/entryGroups/{entry_group} - * - location: projects/{project}/locations/{location} - * - tag: projects/{project}/locations/{location}/entryGroups/{entry_group}/entries/{entry}/tags/{tag} - * - tagTemplate: projects/{project}/locations/{location}/tagTemplates/{tag_template} - * - tagTemplateField: projects/{project}/locations/{location}/tagTemplates/{tag_template}/fields/{field} - * - tagTemplateFieldEnumValue: projects/{project}/locations/{location}/tagTemplates/{tag_template}/fields/{tag_template_field_id}/enumValues/{enum_value_display_name} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'datacatalog.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates an entry. - * - * You can create entries only with 'FILESET', 'CLUSTER', 'DATA_STREAM', - * or custom types. Data Catalog automatically creates entries with other - * types during metadata ingestion from integrated systems. - * - * You must enable the Data Catalog API in the project identified by - * the `parent` parameter. For more information, see [Data Catalog resource - * project](https://cloud.google.com/data-catalog/docs/concepts/resource-project). - * - * An entry group can have a maximum of 100,000 entries. - * - * The async variant is {@see self::createEntryAsync()} . - * - * @param CreateEntryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Entry - * - * @throws ApiException Thrown if the API call fails. - */ - public function createEntry(CreateEntryRequest $request, array $callOptions = []): Entry - { - return $this->startApiCall('CreateEntry', $request, $callOptions)->wait(); - } - - /** - * Creates an entry group. - * - * An entry group contains logically related entries together with [Cloud - * Identity and Access Management](https://cloud.google.com/data-catalog/docs/concepts/iam) policies. - * These policies specify users who can create, edit, and view entries - * within entry groups. - * - * Data Catalog automatically creates entry groups with names that start with - * the `@` symbol for the following resources: - * - * * BigQuery entries (`@bigquery`) - * * Pub/Sub topics (`@pubsub`) - * * Dataproc Metastore services (`@dataproc_metastore_{SERVICE_NAME_HASH}`) - * - * You can create your own entry groups for Cloud Storage fileset entries - * and custom entries together with the corresponding IAM policies. - * User-created entry groups can't contain the `@` symbol, it is reserved - * for automatically created groups. - * - * Entry groups, like entries, can be searched. - * - * A maximum of 10,000 entry groups may be created per organization across all - * locations. - * - * You must enable the Data Catalog API in the project identified by - * the `parent` parameter. For more information, see [Data Catalog resource - * project](https://cloud.google.com/data-catalog/docs/concepts/resource-project). - * - * The async variant is {@see self::createEntryGroupAsync()} . - * - * @param CreateEntryGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 EntryGroup - * - * @throws ApiException Thrown if the API call fails. - */ - public function createEntryGroup(CreateEntryGroupRequest $request, array $callOptions = []): EntryGroup - { - return $this->startApiCall('CreateEntryGroup', $request, $callOptions)->wait(); - } - - /** - * Creates a tag and assigns it to: - * - * * An [Entry][google.cloud.datacatalog.v1.Entry] if the method name is - * `projects.locations.entryGroups.entries.tags.create`. - * * Or [EntryGroup][google.cloud.datacatalog.v1.EntryGroup]if the method - * name is `projects.locations.entryGroups.tags.create`. - * - * Note: The project identified by the `parent` parameter for the [tag] - * (https://cloud.google.com/data-catalog/docs/reference/rest/v1/projects.locations.entryGroups.entries.tags/create#path-parameters) - * and the [tag template] - * (https://cloud.google.com/data-catalog/docs/reference/rest/v1/projects.locations.tagTemplates/create#path-parameters) - * used to create the tag must be in the same organization. - * - * The async variant is {@see self::createTagAsync()} . - * - * @param CreateTagRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Tag - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTag(CreateTagRequest $request, array $callOptions = []): Tag - { - return $this->startApiCall('CreateTag', $request, $callOptions)->wait(); - } - - /** - * Creates a tag template. - * - * You must enable the Data Catalog API in the project identified by the - * `parent` parameter. - * For more information, see [Data Catalog resource project] - * (https://cloud.google.com/data-catalog/docs/concepts/resource-project). - * - * The async variant is {@see self::createTagTemplateAsync()} . - * - * @param CreateTagTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TagTemplate - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTagTemplate(CreateTagTemplateRequest $request, array $callOptions = []): TagTemplate - { - return $this->startApiCall('CreateTagTemplate', $request, $callOptions)->wait(); - } - - /** - * Creates a field in a tag template. - * - * You must enable the Data Catalog API in the project identified by - * the `parent` parameter. For more information, see [Data Catalog resource - * project](https://cloud.google.com/data-catalog/docs/concepts/resource-project). - * - * The async variant is {@see self::createTagTemplateFieldAsync()} . - * - * @param CreateTagTemplateFieldRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TagTemplateField - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTagTemplateField(CreateTagTemplateFieldRequest $request, array $callOptions = []): TagTemplateField - { - return $this->startApiCall('CreateTagTemplateField', $request, $callOptions)->wait(); - } - - /** - * Deletes an existing entry. - * - * You can delete only the entries created by the - * [CreateEntry][google.cloud.datacatalog.v1.DataCatalog.CreateEntry] - * method. - * - * You must enable the Data Catalog API in the project identified by - * the `name` parameter. For more information, see [Data Catalog - * resource - * project](https://cloud.google.com/data-catalog/docs/concepts/resource-project). - * - * The async variant is {@see self::deleteEntryAsync()} . - * - * @param DeleteEntryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteEntry(DeleteEntryRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteEntry', $request, $callOptions)->wait(); - } - - /** - * Deletes an entry group. - * - * You must enable the Data Catalog API in the project - * identified by the `name` parameter. For more information, see [Data Catalog - * resource - * project](https://cloud.google.com/data-catalog/docs/concepts/resource-project). - * - * The async variant is {@see self::deleteEntryGroupAsync()} . - * - * @param DeleteEntryGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteEntryGroup(DeleteEntryGroupRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteEntryGroup', $request, $callOptions)->wait(); - } - - /** - * Deletes a tag. - * - * The async variant is {@see self::deleteTagAsync()} . - * - * @param DeleteTagRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTag(DeleteTagRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteTag', $request, $callOptions)->wait(); - } - - /** - * Deletes a tag template and all tags that use it. - * - * You must enable the Data Catalog API in the project identified by - * the `name` parameter. For more information, see [Data Catalog resource - * project](https://cloud.google.com/data-catalog/docs/concepts/resource-project). - * - * The async variant is {@see self::deleteTagTemplateAsync()} . - * - * @param DeleteTagTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTagTemplate(DeleteTagTemplateRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteTagTemplate', $request, $callOptions)->wait(); - } - - /** - * Deletes a field in a tag template and all uses of this field from the tags - * based on this template. - * - * You must enable the Data Catalog API in the project identified by - * the `name` parameter. For more information, see [Data Catalog resource - * project](https://cloud.google.com/data-catalog/docs/concepts/resource-project). - * - * The async variant is {@see self::deleteTagTemplateFieldAsync()} . - * - * @param DeleteTagTemplateFieldRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTagTemplateField(DeleteTagTemplateFieldRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteTagTemplateField', $request, $callOptions)->wait(); - } - - /** - * Gets an entry. - * - * The async variant is {@see self::getEntryAsync()} . - * - * @param GetEntryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Entry - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEntry(GetEntryRequest $request, array $callOptions = []): Entry - { - return $this->startApiCall('GetEntry', $request, $callOptions)->wait(); - } - - /** - * Gets an entry group. - * - * The async variant is {@see self::getEntryGroupAsync()} . - * - * @param GetEntryGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 EntryGroup - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEntryGroup(GetEntryGroupRequest $request, array $callOptions = []): EntryGroup - { - return $this->startApiCall('GetEntryGroup', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. - * - * May return: - * - * * A`NOT_FOUND` error if the resource doesn't exist or you don't have the - * permission to view it. - * * An empty policy if the resource exists but doesn't have a set policy. - * - * Supported resources are: - * - * - Tag templates - * - Entry groups - * - * Note: This method doesn't get policies from Google Cloud Platform - * resources ingested into Data Catalog. - * - * To call this method, you must have the following Google IAM permissions: - * - * - `datacatalog.tagTemplates.getIamPolicy` to get policies on tag - * templates. - * - `datacatalog.entryGroups.getIamPolicy` to get policies on entry groups. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets a tag template. - * - * The async variant is {@see self::getTagTemplateAsync()} . - * - * @param GetTagTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TagTemplate - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTagTemplate(GetTagTemplateRequest $request, array $callOptions = []): TagTemplate - { - return $this->startApiCall('GetTagTemplate', $request, $callOptions)->wait(); - } - - /** - * Imports entries from a source, such as data previously dumped into a - * Cloud Storage bucket, into Data Catalog. Import of entries - * is a sync operation that reconciles the state of the third-party system - * with the Data Catalog. - * - * `ImportEntries` accepts source data snapshots of a third-party system. - * Snapshot should be delivered as a .wire or base65-encoded .txt file - * containing a sequence of Protocol Buffer messages of - * [DumpItem][google.cloud.datacatalog.v1.DumpItem] type. - * - * `ImportEntries` returns a [long-running operation] - * [google.longrunning.Operation] resource that can be queried with - * [Operations.GetOperation][google.longrunning.Operations.GetOperation] - * to return - * [ImportEntriesMetadata][google.cloud.datacatalog.v1.ImportEntriesMetadata] - * and an - * [ImportEntriesResponse][google.cloud.datacatalog.v1.ImportEntriesResponse] - * message. - * - * The async variant is {@see self::importEntriesAsync()} . - * - * @param ImportEntriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function importEntries(ImportEntriesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ImportEntries', $request, $callOptions)->wait(); - } - - /** - * Lists entries. - * - * Note: Currently, this method can list only custom entries. - * To get a list of both custom and automatically created entries, use - * [SearchCatalog][google.cloud.datacatalog.v1.DataCatalog.SearchCatalog]. - * - * The async variant is {@see self::listEntriesAsync()} . - * - * @param ListEntriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listEntries(ListEntriesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListEntries', $request, $callOptions); - } - - /** - * Lists entry groups. - * - * The async variant is {@see self::listEntryGroupsAsync()} . - * - * @param ListEntryGroupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listEntryGroups(ListEntryGroupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListEntryGroups', $request, $callOptions); - } - - /** - * Lists tags assigned to an [Entry][google.cloud.datacatalog.v1.Entry]. - * The [columns][google.cloud.datacatalog.v1.Tag.column] in the response are - * lowercased. - * - * The async variant is {@see self::listTagsAsync()} . - * - * @param ListTagsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTags(ListTagsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTags', $request, $callOptions); - } - - /** - * Gets an entry by its target resource name. - * - * The resource name comes from the source Google Cloud Platform service. - * - * The async variant is {@see self::lookupEntryAsync()} . - * - * @param LookupEntryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Entry - * - * @throws ApiException Thrown if the API call fails. - */ - public function lookupEntry(LookupEntryRequest $request, array $callOptions = []): Entry - { - return $this->startApiCall('LookupEntry', $request, $callOptions)->wait(); - } - - /** - * Modifies contacts, part of the business context of an - * [Entry][google.cloud.datacatalog.v1.Entry]. - * - * To call this method, you must have the `datacatalog.entries.updateContacts` - * IAM permission on the corresponding project. - * - * The async variant is {@see self::modifyEntryContactsAsync()} . - * - * @param ModifyEntryContactsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Contacts - * - * @throws ApiException Thrown if the API call fails. - */ - public function modifyEntryContacts(ModifyEntryContactsRequest $request, array $callOptions = []): Contacts - { - return $this->startApiCall('ModifyEntryContacts', $request, $callOptions)->wait(); - } - - /** - * Modifies entry overview, part of the business context of an - * [Entry][google.cloud.datacatalog.v1.Entry]. - * - * To call this method, you must have the `datacatalog.entries.updateOverview` - * IAM permission on the corresponding project. - * - * The async variant is {@see self::modifyEntryOverviewAsync()} . - * - * @param ModifyEntryOverviewRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 EntryOverview - * - * @throws ApiException Thrown if the API call fails. - */ - public function modifyEntryOverview(ModifyEntryOverviewRequest $request, array $callOptions = []): EntryOverview - { - return $this->startApiCall('ModifyEntryOverview', $request, $callOptions)->wait(); - } - - /** - * `ReconcileTags` creates or updates a list of tags on the entry. - * If the - * [ReconcileTagsRequest.force_delete_missing][google.cloud.datacatalog.v1.ReconcileTagsRequest.force_delete_missing] - * parameter is set, the operation deletes tags not included in the input tag - * list. - * - * `ReconcileTags` returns a [long-running operation] - * [google.longrunning.Operation] resource that can be queried with - * [Operations.GetOperation][google.longrunning.Operations.GetOperation] - * to return [ReconcileTagsMetadata] - * [google.cloud.datacatalog.v1.ReconcileTagsMetadata] and - * a [ReconcileTagsResponse] - * [google.cloud.datacatalog.v1.ReconcileTagsResponse] message. - * - * The async variant is {@see self::reconcileTagsAsync()} . - * - * @param ReconcileTagsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function reconcileTags(ReconcileTagsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ReconcileTags', $request, $callOptions)->wait(); - } - - /** - * Renames a field in a tag template. - * - * You must enable the Data Catalog API in the project identified by the - * `name` parameter. For more information, see [Data Catalog resource project] - * (https://cloud.google.com/data-catalog/docs/concepts/resource-project). - * - * The async variant is {@see self::renameTagTemplateFieldAsync()} . - * - * @param RenameTagTemplateFieldRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TagTemplateField - * - * @throws ApiException Thrown if the API call fails. - */ - public function renameTagTemplateField(RenameTagTemplateFieldRequest $request, array $callOptions = []): TagTemplateField - { - return $this->startApiCall('RenameTagTemplateField', $request, $callOptions)->wait(); - } - - /** - * Renames an enum value in a tag template. - * - * Within a single enum field, enum values must be unique. - * - * The async variant is {@see self::renameTagTemplateFieldEnumValueAsync()} . - * - * @param RenameTagTemplateFieldEnumValueRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TagTemplateField - * - * @throws ApiException Thrown if the API call fails. - */ - public function renameTagTemplateFieldEnumValue(RenameTagTemplateFieldEnumValueRequest $request, array $callOptions = []): TagTemplateField - { - return $this->startApiCall('RenameTagTemplateFieldEnumValue', $request, $callOptions)->wait(); - } - - /** - * Searches Data Catalog for multiple resources like entries and tags that - * match a query. - * - * This is a [Custom Method] - * (https://cloud.google.com/apis/design/custom_methods) that doesn't return - * all information on a resource, only its ID and high level fields. To get - * more information, you can subsequently call specific get methods. - * - * Note: Data Catalog search queries don't guarantee full recall. Results - * that match your query might not be returned, even in subsequent - * result pages. Additionally, returned (and not returned) results can vary - * if you repeat search queries. - * - * For more information, see [Data Catalog search syntax] - * (https://cloud.google.com/data-catalog/docs/how-to/search-reference). - * - * The async variant is {@see self::searchCatalogAsync()} . - * - * @param SearchCatalogRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchCatalog(SearchCatalogRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchCatalog', $request, $callOptions); - } - - /** - * Sets an access control policy for a resource. Replaces any existing - * policy. - * - * Supported resources are: - * - * - Tag templates - * - Entry groups - * - * Note: This method sets policies only within Data Catalog and can't be - * used to manage policies in BigQuery, Pub/Sub, Dataproc Metastore, and any - * external Google Cloud Platform resources synced with the Data Catalog. - * - * To call this method, you must have the following Google IAM permissions: - * - * - `datacatalog.tagTemplates.setIamPolicy` to set policies on tag - * templates. - * - `datacatalog.entryGroups.setIamPolicy` to set policies on entry groups. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Marks an [Entry][google.cloud.datacatalog.v1.Entry] as starred by - * the current user. Starring information is private to each user. - * - * The async variant is {@see self::starEntryAsync()} . - * - * @param StarEntryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 StarEntryResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function starEntry(StarEntryRequest $request, array $callOptions = []): StarEntryResponse - { - return $this->startApiCall('StarEntry', $request, $callOptions)->wait(); - } - - /** - * Gets your permissions on a resource. - * - * Returns an empty set of permissions if the resource doesn't exist. - * - * Supported resources are: - * - * - Tag templates - * - Entry groups - * - * Note: This method gets policies only within Data Catalog and can't be - * used to get policies from BigQuery, Pub/Sub, Dataproc Metastore, and any - * external Google Cloud Platform resources ingested into Data Catalog. - * - * No Google IAM permissions are required to call this method. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Marks an [Entry][google.cloud.datacatalog.v1.Entry] as NOT starred by - * the current user. Starring information is private to each user. - * - * The async variant is {@see self::unstarEntryAsync()} . - * - * @param UnstarEntryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 UnstarEntryResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function unstarEntry(UnstarEntryRequest $request, array $callOptions = []): UnstarEntryResponse - { - return $this->startApiCall('UnstarEntry', $request, $callOptions)->wait(); - } - - /** - * Updates an existing entry. - * - * You must enable the Data Catalog API in the project identified by - * the `entry.name` parameter. For more information, see [Data Catalog - * resource - * project](https://cloud.google.com/data-catalog/docs/concepts/resource-project). - * - * The async variant is {@see self::updateEntryAsync()} . - * - * @param UpdateEntryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Entry - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateEntry(UpdateEntryRequest $request, array $callOptions = []): Entry - { - return $this->startApiCall('UpdateEntry', $request, $callOptions)->wait(); - } - - /** - * Updates an entry group. - * - * You must enable the Data Catalog API in the project identified by - * the `entry_group.name` parameter. For more information, see [Data Catalog - * resource - * project](https://cloud.google.com/data-catalog/docs/concepts/resource-project). - * - * The async variant is {@see self::updateEntryGroupAsync()} . - * - * @param UpdateEntryGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 EntryGroup - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateEntryGroup(UpdateEntryGroupRequest $request, array $callOptions = []): EntryGroup - { - return $this->startApiCall('UpdateEntryGroup', $request, $callOptions)->wait(); - } - - /** - * Updates an existing tag. - * - * The async variant is {@see self::updateTagAsync()} . - * - * @param UpdateTagRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Tag - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateTag(UpdateTagRequest $request, array $callOptions = []): Tag - { - return $this->startApiCall('UpdateTag', $request, $callOptions)->wait(); - } - - /** - * Updates a tag template. - * - * You can't update template fields with this method. These fields are - * separate resources with their own create, update, and delete methods. - * - * You must enable the Data Catalog API in the project identified by - * the `tag_template.name` parameter. For more information, see [Data Catalog - * resource - * project](https://cloud.google.com/data-catalog/docs/concepts/resource-project). - * - * The async variant is {@see self::updateTagTemplateAsync()} . - * - * @param UpdateTagTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TagTemplate - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateTagTemplate(UpdateTagTemplateRequest $request, array $callOptions = []): TagTemplate - { - return $this->startApiCall('UpdateTagTemplate', $request, $callOptions)->wait(); - } - - /** - * Updates a field in a tag template. - * - * You can't update the field type with this method. - * - * You must enable the Data Catalog API in the project - * identified by the `name` parameter. For more information, see [Data Catalog - * resource - * project](https://cloud.google.com/data-catalog/docs/concepts/resource-project). - * - * The async variant is {@see self::updateTagTemplateFieldAsync()} . - * - * @param UpdateTagTemplateFieldRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TagTemplateField - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateTagTemplateField(UpdateTagTemplateFieldRequest $request, array $callOptions = []): TagTemplateField - { - return $this->startApiCall('UpdateTagTemplateField', $request, $callOptions)->wait(); - } -} diff --git a/DataCatalog/src/V1/Client/BaseClient/PolicyTagManagerBaseClient.php b/DataCatalog/src/V1/Client/BaseClient/PolicyTagManagerBaseClient.php deleted file mode 100644 index 6d3d6f53bdd9..000000000000 --- a/DataCatalog/src/V1/Client/BaseClient/PolicyTagManagerBaseClient.php +++ /dev/null @@ -1,608 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/policy_tag_manager_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/policy_tag_manager_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/policy_tag_manager_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/policy_tag_manager_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a policy_tag - * resource. - * - * @param string $project - * @param string $location - * @param string $taxonomy - * @param string $policyTag - * - * @return string The formatted policy_tag resource. - */ - public static function policyTagName(string $project, string $location, string $taxonomy, string $policyTag): string - { - return self::getPathTemplate('policyTag')->render([ - 'project' => $project, - 'location' => $location, - 'taxonomy' => $taxonomy, - 'policy_tag' => $policyTag, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a taxonomy - * resource. - * - * @param string $project - * @param string $location - * @param string $taxonomy - * - * @return string The formatted taxonomy resource. - */ - public static function taxonomyName(string $project, string $location, string $taxonomy): string - { - return self::getPathTemplate('taxonomy')->render([ - 'project' => $project, - 'location' => $location, - 'taxonomy' => $taxonomy, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - location: projects/{project}/locations/{location} - * - policyTag: projects/{project}/locations/{location}/taxonomies/{taxonomy}/policyTags/{policy_tag} - * - taxonomy: projects/{project}/locations/{location}/taxonomies/{taxonomy} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'datacatalog.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a policy tag in a taxonomy. - * - * The async variant is {@see self::createPolicyTagAsync()} . - * - * @param CreatePolicyTagRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PolicyTag - * - * @throws ApiException Thrown if the API call fails. - */ - public function createPolicyTag(CreatePolicyTagRequest $request, array $callOptions = []): PolicyTag - { - return $this->startApiCall('CreatePolicyTag', $request, $callOptions)->wait(); - } - - /** - * Creates a taxonomy in a specified project. - * - * The taxonomy is initially empty, that is, it doesn't contain policy tags. - * - * The async variant is {@see self::createTaxonomyAsync()} . - * - * @param CreateTaxonomyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Taxonomy - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTaxonomy(CreateTaxonomyRequest $request, array $callOptions = []): Taxonomy - { - return $this->startApiCall('CreateTaxonomy', $request, $callOptions)->wait(); - } - - /** - * Deletes a policy tag together with the following: - * - * * All of its descendant policy tags, if any - * * Policies associated with the policy tag and its descendants - * * References from BigQuery table schema of the policy tag and its - * descendants - * - * The async variant is {@see self::deletePolicyTagAsync()} . - * - * @param DeletePolicyTagRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deletePolicyTag(DeletePolicyTagRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeletePolicyTag', $request, $callOptions)->wait(); - } - - /** - * Deletes a taxonomy, including all policy tags in this - * taxonomy, their associated policies, and the policy tags references from - * BigQuery columns. - * - * The async variant is {@see self::deleteTaxonomyAsync()} . - * - * @param DeleteTaxonomyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTaxonomy(DeleteTaxonomyRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteTaxonomy', $request, $callOptions)->wait(); - } - - /** - * Gets the IAM policy for a policy tag or a taxonomy. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets a policy tag. - * - * The async variant is {@see self::getPolicyTagAsync()} . - * - * @param GetPolicyTagRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PolicyTag - * - * @throws ApiException Thrown if the API call fails. - */ - public function getPolicyTag(GetPolicyTagRequest $request, array $callOptions = []): PolicyTag - { - return $this->startApiCall('GetPolicyTag', $request, $callOptions)->wait(); - } - - /** - * Gets a taxonomy. - * - * The async variant is {@see self::getTaxonomyAsync()} . - * - * @param GetTaxonomyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Taxonomy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTaxonomy(GetTaxonomyRequest $request, array $callOptions = []): Taxonomy - { - return $this->startApiCall('GetTaxonomy', $request, $callOptions)->wait(); - } - - /** - * Lists all policy tags in a taxonomy. - * - * The async variant is {@see self::listPolicyTagsAsync()} . - * - * @param ListPolicyTagsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPolicyTags(ListPolicyTagsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPolicyTags', $request, $callOptions); - } - - /** - * Lists all taxonomies in a project in a particular location that you - * have a permission to view. - * - * The async variant is {@see self::listTaxonomiesAsync()} . - * - * @param ListTaxonomiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTaxonomies(ListTaxonomiesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTaxonomies', $request, $callOptions); - } - - /** - * Sets the IAM policy for a policy tag or a taxonomy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns your permissions on a specified policy tag or - * taxonomy. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Updates a policy tag, including its display - * name, description, and parent policy tag. - * - * The async variant is {@see self::updatePolicyTagAsync()} . - * - * @param UpdatePolicyTagRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PolicyTag - * - * @throws ApiException Thrown if the API call fails. - */ - public function updatePolicyTag(UpdatePolicyTagRequest $request, array $callOptions = []): PolicyTag - { - return $this->startApiCall('UpdatePolicyTag', $request, $callOptions)->wait(); - } - - /** - * Updates a taxonomy, including its display name, - * description, and activated policy types. - * - * The async variant is {@see self::updateTaxonomyAsync()} . - * - * @param UpdateTaxonomyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Taxonomy - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateTaxonomy(UpdateTaxonomyRequest $request, array $callOptions = []): Taxonomy - { - return $this->startApiCall('UpdateTaxonomy', $request, $callOptions)->wait(); - } -} diff --git a/DataCatalog/src/V1/Client/BaseClient/PolicyTagManagerSerializationBaseClient.php b/DataCatalog/src/V1/Client/BaseClient/PolicyTagManagerSerializationBaseClient.php deleted file mode 100644 index 4b73e10d1806..000000000000 --- a/DataCatalog/src/V1/Client/BaseClient/PolicyTagManagerSerializationBaseClient.php +++ /dev/null @@ -1,337 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/policy_tag_manager_serialization_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/policy_tag_manager_serialization_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/policy_tag_manager_serialization_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/policy_tag_manager_serialization_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a taxonomy - * resource. - * - * @param string $project - * @param string $location - * @param string $taxonomy - * - * @return string The formatted taxonomy resource. - */ - public static function taxonomyName(string $project, string $location, string $taxonomy): string - { - return self::getPathTemplate('taxonomy')->render([ - 'project' => $project, - 'location' => $location, - 'taxonomy' => $taxonomy, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - location: projects/{project}/locations/{location} - * - taxonomy: projects/{project}/locations/{location}/taxonomies/{taxonomy} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'datacatalog.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Exports taxonomies in the requested type and returns them, - * including their policy tags. The requested taxonomies must belong to the - * same project. - * - * This method generates `SerializedTaxonomy` protocol buffers with nested - * policy tags that can be used as input for `ImportTaxonomies` calls. - * - * The async variant is {@see self::exportTaxonomiesAsync()} . - * - * @param ExportTaxonomiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ExportTaxonomiesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function exportTaxonomies(ExportTaxonomiesRequest $request, array $callOptions = []): ExportTaxonomiesResponse - { - return $this->startApiCall('ExportTaxonomies', $request, $callOptions)->wait(); - } - - /** - * Creates new taxonomies (including their policy tags) in a given project - * by importing from inlined or cross-regional sources. - * - * For a cross-regional source, new taxonomies are created by copying - * from a source in another region. - * - * For an inlined source, taxonomies and policy tags are created in bulk using - * nested protocol buffer structures. - * - * The async variant is {@see self::importTaxonomiesAsync()} . - * - * @param ImportTaxonomiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ImportTaxonomiesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function importTaxonomies(ImportTaxonomiesRequest $request, array $callOptions = []): ImportTaxonomiesResponse - { - return $this->startApiCall('ImportTaxonomies', $request, $callOptions)->wait(); - } - - /** - * Replaces (updates) a taxonomy and all its policy tags. - * - * The taxonomy and its entire hierarchy of policy tags must be - * represented literally by `SerializedTaxonomy` and the nested - * `SerializedPolicyTag` messages. - * - * This operation automatically does the following: - * - * - Deletes the existing policy tags that are missing from the - * `SerializedPolicyTag`. - * - Creates policy tags that don't have resource names. They are considered - * new. - * - Updates policy tags with valid resources names accordingly. - * - * The async variant is {@see self::replaceTaxonomyAsync()} . - * - * @param ReplaceTaxonomyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Taxonomy - * - * @throws ApiException Thrown if the API call fails. - */ - public function replaceTaxonomy(ReplaceTaxonomyRequest $request, array $callOptions = []): Taxonomy - { - return $this->startApiCall('ReplaceTaxonomy', $request, $callOptions)->wait(); - } -} diff --git a/DataCatalog/src/V1/Client/DataCatalogClient.php b/DataCatalog/src/V1/Client/DataCatalogClient.php index 04907de0eb1e..aecbbb39581d 100644 --- a/DataCatalog/src/V1/Client/DataCatalogClient.php +++ b/DataCatalog/src/V1/Client/DataCatalogClient.php @@ -24,17 +24,1462 @@ namespace Google\Cloud\DataCatalog\V1\Client; -use Google\Cloud\DataCatalog\V1\Client\BaseClient\DataCatalogBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\DataCatalog\V1\Contacts; +use Google\Cloud\DataCatalog\V1\CreateEntryGroupRequest; +use Google\Cloud\DataCatalog\V1\CreateEntryRequest; +use Google\Cloud\DataCatalog\V1\CreateTagRequest; +use Google\Cloud\DataCatalog\V1\CreateTagTemplateFieldRequest; +use Google\Cloud\DataCatalog\V1\CreateTagTemplateRequest; +use Google\Cloud\DataCatalog\V1\DeleteEntryGroupRequest; +use Google\Cloud\DataCatalog\V1\DeleteEntryRequest; +use Google\Cloud\DataCatalog\V1\DeleteTagRequest; +use Google\Cloud\DataCatalog\V1\DeleteTagTemplateFieldRequest; +use Google\Cloud\DataCatalog\V1\DeleteTagTemplateRequest; +use Google\Cloud\DataCatalog\V1\Entry; +use Google\Cloud\DataCatalog\V1\EntryGroup; +use Google\Cloud\DataCatalog\V1\EntryOverview; +use Google\Cloud\DataCatalog\V1\GetEntryGroupRequest; +use Google\Cloud\DataCatalog\V1\GetEntryRequest; +use Google\Cloud\DataCatalog\V1\GetTagTemplateRequest; +use Google\Cloud\DataCatalog\V1\ImportEntriesMetadata; +use Google\Cloud\DataCatalog\V1\ImportEntriesRequest; +use Google\Cloud\DataCatalog\V1\ImportEntriesResponse; +use Google\Cloud\DataCatalog\V1\ListEntriesRequest; +use Google\Cloud\DataCatalog\V1\ListEntryGroupsRequest; +use Google\Cloud\DataCatalog\V1\ListTagsRequest; +use Google\Cloud\DataCatalog\V1\LookupEntryRequest; +use Google\Cloud\DataCatalog\V1\ModifyEntryContactsRequest; +use Google\Cloud\DataCatalog\V1\ModifyEntryOverviewRequest; +use Google\Cloud\DataCatalog\V1\ReconcileTagsMetadata; +use Google\Cloud\DataCatalog\V1\ReconcileTagsRequest; +use Google\Cloud\DataCatalog\V1\ReconcileTagsResponse; +use Google\Cloud\DataCatalog\V1\RenameTagTemplateFieldEnumValueRequest; +use Google\Cloud\DataCatalog\V1\RenameTagTemplateFieldRequest; +use Google\Cloud\DataCatalog\V1\SearchCatalogRequest; +use Google\Cloud\DataCatalog\V1\StarEntryRequest; +use Google\Cloud\DataCatalog\V1\StarEntryResponse; +use Google\Cloud\DataCatalog\V1\Tag; +use Google\Cloud\DataCatalog\V1\TagTemplate; +use Google\Cloud\DataCatalog\V1\TagTemplateField; +use Google\Cloud\DataCatalog\V1\UnstarEntryRequest; +use Google\Cloud\DataCatalog\V1\UnstarEntryResponse; +use Google\Cloud\DataCatalog\V1\UpdateEntryGroupRequest; +use Google\Cloud\DataCatalog\V1\UpdateEntryRequest; +use Google\Cloud\DataCatalog\V1\UpdateTagRequest; +use Google\Cloud\DataCatalog\V1\UpdateTagTemplateFieldRequest; +use Google\Cloud\DataCatalog\V1\UpdateTagTemplateRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Data Catalog API service allows you to discover, understand, and manage + * your data. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\DataCatalog\V1\DataCatalogClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createEntryAsync(CreateEntryRequest $request, array $optionalArgs = []) + * @method PromiseInterface createEntryGroupAsync(CreateEntryGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface createTagAsync(CreateTagRequest $request, array $optionalArgs = []) + * @method PromiseInterface createTagTemplateAsync(CreateTagTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface createTagTemplateFieldAsync(CreateTagTemplateFieldRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteEntryAsync(DeleteEntryRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteEntryGroupAsync(DeleteEntryGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTagAsync(DeleteTagRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTagTemplateAsync(DeleteTagTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTagTemplateFieldAsync(DeleteTagTemplateFieldRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEntryAsync(GetEntryRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEntryGroupAsync(GetEntryGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTagTemplateAsync(GetTagTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface importEntriesAsync(ImportEntriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listEntriesAsync(ListEntriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listEntryGroupsAsync(ListEntryGroupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTagsAsync(ListTagsRequest $request, array $optionalArgs = []) + * @method PromiseInterface lookupEntryAsync(LookupEntryRequest $request, array $optionalArgs = []) + * @method PromiseInterface modifyEntryContactsAsync(ModifyEntryContactsRequest $request, array $optionalArgs = []) + * @method PromiseInterface modifyEntryOverviewAsync(ModifyEntryOverviewRequest $request, array $optionalArgs = []) + * @method PromiseInterface reconcileTagsAsync(ReconcileTagsRequest $request, array $optionalArgs = []) + * @method PromiseInterface renameTagTemplateFieldAsync(RenameTagTemplateFieldRequest $request, array $optionalArgs = []) + * @method PromiseInterface renameTagTemplateFieldEnumValueAsync(RenameTagTemplateFieldEnumValueRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchCatalogAsync(SearchCatalogRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface starEntryAsync(StarEntryRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface unstarEntryAsync(UnstarEntryRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateEntryAsync(UpdateEntryRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateEntryGroupAsync(UpdateEntryGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateTagAsync(UpdateTagRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateTagTemplateAsync(UpdateTagTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateTagTemplateFieldAsync(UpdateTagTemplateFieldRequest $request, array $optionalArgs = []) */ -final class DataCatalogClient extends DataCatalogBaseClient +final class DataCatalogClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DataCatalogBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.datacatalog.v1.DataCatalog'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'datacatalog.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/data_catalog_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/data_catalog_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/data_catalog_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/data_catalog_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a entry + * resource. + * + * @param string $project + * @param string $location + * @param string $entryGroup + * @param string $entry + * + * @return string The formatted entry resource. + */ + public static function entryName(string $project, string $location, string $entryGroup, string $entry): string + { + return self::getPathTemplate('entry')->render([ + 'project' => $project, + 'location' => $location, + 'entry_group' => $entryGroup, + 'entry' => $entry, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a entry_group + * resource. + * + * @param string $project + * @param string $location + * @param string $entryGroup + * + * @return string The formatted entry_group resource. + */ + public static function entryGroupName(string $project, string $location, string $entryGroup): string + { + return self::getPathTemplate('entryGroup')->render([ + 'project' => $project, + 'location' => $location, + 'entry_group' => $entryGroup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a tag + * resource. + * + * @param string $project + * @param string $location + * @param string $entryGroup + * @param string $entry + * @param string $tag + * + * @return string The formatted tag resource. + */ + public static function tagName(string $project, string $location, string $entryGroup, string $entry, string $tag): string + { + return self::getPathTemplate('tag')->render([ + 'project' => $project, + 'location' => $location, + 'entry_group' => $entryGroup, + 'entry' => $entry, + 'tag' => $tag, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a tag_template + * resource. + * + * @param string $project + * @param string $location + * @param string $tagTemplate + * + * @return string The formatted tag_template resource. + */ + public static function tagTemplateName(string $project, string $location, string $tagTemplate): string + { + return self::getPathTemplate('tagTemplate')->render([ + 'project' => $project, + 'location' => $location, + 'tag_template' => $tagTemplate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * tag_template_field resource. + * + * @param string $project + * @param string $location + * @param string $tagTemplate + * @param string $field + * + * @return string The formatted tag_template_field resource. + */ + public static function tagTemplateFieldName(string $project, string $location, string $tagTemplate, string $field): string + { + return self::getPathTemplate('tagTemplateField')->render([ + 'project' => $project, + 'location' => $location, + 'tag_template' => $tagTemplate, + 'field' => $field, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * tag_template_field_enum_value resource. + * + * @param string $project + * @param string $location + * @param string $tagTemplate + * @param string $tagTemplateFieldId + * @param string $enumValueDisplayName + * + * @return string The formatted tag_template_field_enum_value resource. + */ + public static function tagTemplateFieldEnumValueName(string $project, string $location, string $tagTemplate, string $tagTemplateFieldId, string $enumValueDisplayName): string + { + return self::getPathTemplate('tagTemplateFieldEnumValue')->render([ + 'project' => $project, + 'location' => $location, + 'tag_template' => $tagTemplate, + 'tag_template_field_id' => $tagTemplateFieldId, + 'enum_value_display_name' => $enumValueDisplayName, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - entry: projects/{project}/locations/{location}/entryGroups/{entry_group}/entries/{entry} + * - entryGroup: projects/{project}/locations/{location}/entryGroups/{entry_group} + * - location: projects/{project}/locations/{location} + * - tag: projects/{project}/locations/{location}/entryGroups/{entry_group}/entries/{entry}/tags/{tag} + * - tagTemplate: projects/{project}/locations/{location}/tagTemplates/{tag_template} + * - tagTemplateField: projects/{project}/locations/{location}/tagTemplates/{tag_template}/fields/{field} + * - tagTemplateFieldEnumValue: projects/{project}/locations/{location}/tagTemplates/{tag_template}/fields/{tag_template_field_id}/enumValues/{enum_value_display_name} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'datacatalog.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates an entry. + * + * You can create entries only with 'FILESET', 'CLUSTER', 'DATA_STREAM', + * or custom types. Data Catalog automatically creates entries with other + * types during metadata ingestion from integrated systems. + * + * You must enable the Data Catalog API in the project identified by + * the `parent` parameter. For more information, see [Data Catalog resource + * project](https://cloud.google.com/data-catalog/docs/concepts/resource-project). + * + * An entry group can have a maximum of 100,000 entries. + * + * The async variant is {@see DataCatalogClient::createEntryAsync()} . + * + * @param CreateEntryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Entry + * + * @throws ApiException Thrown if the API call fails. + */ + public function createEntry(CreateEntryRequest $request, array $callOptions = []): Entry + { + return $this->startApiCall('CreateEntry', $request, $callOptions)->wait(); + } + + /** + * Creates an entry group. + * + * An entry group contains logically related entries together with [Cloud + * Identity and Access Management](https://cloud.google.com/data-catalog/docs/concepts/iam) policies. + * These policies specify users who can create, edit, and view entries + * within entry groups. + * + * Data Catalog automatically creates entry groups with names that start with + * the `@` symbol for the following resources: + * + * * BigQuery entries (`@bigquery`) + * * Pub/Sub topics (`@pubsub`) + * * Dataproc Metastore services (`@dataproc_metastore_{SERVICE_NAME_HASH}`) + * + * You can create your own entry groups for Cloud Storage fileset entries + * and custom entries together with the corresponding IAM policies. + * User-created entry groups can't contain the `@` symbol, it is reserved + * for automatically created groups. + * + * Entry groups, like entries, can be searched. + * + * A maximum of 10,000 entry groups may be created per organization across all + * locations. + * + * You must enable the Data Catalog API in the project identified by + * the `parent` parameter. For more information, see [Data Catalog resource + * project](https://cloud.google.com/data-catalog/docs/concepts/resource-project). + * + * The async variant is {@see DataCatalogClient::createEntryGroupAsync()} . + * + * @param CreateEntryGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 EntryGroup + * + * @throws ApiException Thrown if the API call fails. + */ + public function createEntryGroup(CreateEntryGroupRequest $request, array $callOptions = []): EntryGroup + { + return $this->startApiCall('CreateEntryGroup', $request, $callOptions)->wait(); + } + + /** + * Creates a tag and assigns it to: + * + * * An [Entry][google.cloud.datacatalog.v1.Entry] if the method name is + * `projects.locations.entryGroups.entries.tags.create`. + * * Or [EntryGroup][google.cloud.datacatalog.v1.EntryGroup]if the method + * name is `projects.locations.entryGroups.tags.create`. + * + * Note: The project identified by the `parent` parameter for the [tag] + * (https://cloud.google.com/data-catalog/docs/reference/rest/v1/projects.locations.entryGroups.entries.tags/create#path-parameters) + * and the [tag template] + * (https://cloud.google.com/data-catalog/docs/reference/rest/v1/projects.locations.tagTemplates/create#path-parameters) + * used to create the tag must be in the same organization. + * + * The async variant is {@see DataCatalogClient::createTagAsync()} . + * + * @param CreateTagRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Tag + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTag(CreateTagRequest $request, array $callOptions = []): Tag + { + return $this->startApiCall('CreateTag', $request, $callOptions)->wait(); + } + + /** + * Creates a tag template. + * + * You must enable the Data Catalog API in the project identified by the + * `parent` parameter. + * For more information, see [Data Catalog resource project] + * (https://cloud.google.com/data-catalog/docs/concepts/resource-project). + * + * The async variant is {@see DataCatalogClient::createTagTemplateAsync()} . + * + * @param CreateTagTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TagTemplate + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTagTemplate(CreateTagTemplateRequest $request, array $callOptions = []): TagTemplate + { + return $this->startApiCall('CreateTagTemplate', $request, $callOptions)->wait(); + } + + /** + * Creates a field in a tag template. + * + * You must enable the Data Catalog API in the project identified by + * the `parent` parameter. For more information, see [Data Catalog resource + * project](https://cloud.google.com/data-catalog/docs/concepts/resource-project). + * + * The async variant is {@see DataCatalogClient::createTagTemplateFieldAsync()} . + * + * @param CreateTagTemplateFieldRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TagTemplateField + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTagTemplateField(CreateTagTemplateFieldRequest $request, array $callOptions = []): TagTemplateField + { + return $this->startApiCall('CreateTagTemplateField', $request, $callOptions)->wait(); + } + + /** + * Deletes an existing entry. + * + * You can delete only the entries created by the + * [CreateEntry][google.cloud.datacatalog.v1.DataCatalog.CreateEntry] + * method. + * + * You must enable the Data Catalog API in the project identified by + * the `name` parameter. For more information, see [Data Catalog + * resource + * project](https://cloud.google.com/data-catalog/docs/concepts/resource-project). + * + * The async variant is {@see DataCatalogClient::deleteEntryAsync()} . + * + * @param DeleteEntryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteEntry(DeleteEntryRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteEntry', $request, $callOptions)->wait(); + } + + /** + * Deletes an entry group. + * + * You must enable the Data Catalog API in the project + * identified by the `name` parameter. For more information, see [Data Catalog + * resource + * project](https://cloud.google.com/data-catalog/docs/concepts/resource-project). + * + * The async variant is {@see DataCatalogClient::deleteEntryGroupAsync()} . + * + * @param DeleteEntryGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteEntryGroup(DeleteEntryGroupRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteEntryGroup', $request, $callOptions)->wait(); + } + + /** + * Deletes a tag. + * + * The async variant is {@see DataCatalogClient::deleteTagAsync()} . + * + * @param DeleteTagRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTag(DeleteTagRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteTag', $request, $callOptions)->wait(); + } + + /** + * Deletes a tag template and all tags that use it. + * + * You must enable the Data Catalog API in the project identified by + * the `name` parameter. For more information, see [Data Catalog resource + * project](https://cloud.google.com/data-catalog/docs/concepts/resource-project). + * + * The async variant is {@see DataCatalogClient::deleteTagTemplateAsync()} . + * + * @param DeleteTagTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTagTemplate(DeleteTagTemplateRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteTagTemplate', $request, $callOptions)->wait(); + } + + /** + * Deletes a field in a tag template and all uses of this field from the tags + * based on this template. + * + * You must enable the Data Catalog API in the project identified by + * the `name` parameter. For more information, see [Data Catalog resource + * project](https://cloud.google.com/data-catalog/docs/concepts/resource-project). + * + * The async variant is {@see DataCatalogClient::deleteTagTemplateFieldAsync()} . + * + * @param DeleteTagTemplateFieldRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTagTemplateField(DeleteTagTemplateFieldRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteTagTemplateField', $request, $callOptions)->wait(); + } + + /** + * Gets an entry. + * + * The async variant is {@see DataCatalogClient::getEntryAsync()} . + * + * @param GetEntryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Entry + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEntry(GetEntryRequest $request, array $callOptions = []): Entry + { + return $this->startApiCall('GetEntry', $request, $callOptions)->wait(); + } + + /** + * Gets an entry group. + * + * The async variant is {@see DataCatalogClient::getEntryGroupAsync()} . + * + * @param GetEntryGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 EntryGroup + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEntryGroup(GetEntryGroupRequest $request, array $callOptions = []): EntryGroup + { + return $this->startApiCall('GetEntryGroup', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. + * + * May return: + * + * * A`NOT_FOUND` error if the resource doesn't exist or you don't have the + * permission to view it. + * * An empty policy if the resource exists but doesn't have a set policy. + * + * Supported resources are: + * + * - Tag templates + * - Entry groups + * + * Note: This method doesn't get policies from Google Cloud Platform + * resources ingested into Data Catalog. + * + * To call this method, you must have the following Google IAM permissions: + * + * - `datacatalog.tagTemplates.getIamPolicy` to get policies on tag + * templates. + * - `datacatalog.entryGroups.getIamPolicy` to get policies on entry groups. + * + * The async variant is {@see DataCatalogClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets a tag template. + * + * The async variant is {@see DataCatalogClient::getTagTemplateAsync()} . + * + * @param GetTagTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TagTemplate + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTagTemplate(GetTagTemplateRequest $request, array $callOptions = []): TagTemplate + { + return $this->startApiCall('GetTagTemplate', $request, $callOptions)->wait(); + } + + /** + * Imports entries from a source, such as data previously dumped into a + * Cloud Storage bucket, into Data Catalog. Import of entries + * is a sync operation that reconciles the state of the third-party system + * with the Data Catalog. + * + * `ImportEntries` accepts source data snapshots of a third-party system. + * Snapshot should be delivered as a .wire or base65-encoded .txt file + * containing a sequence of Protocol Buffer messages of + * [DumpItem][google.cloud.datacatalog.v1.DumpItem] type. + * + * `ImportEntries` returns a [long-running operation] + * [google.longrunning.Operation] resource that can be queried with + * [Operations.GetOperation][google.longrunning.Operations.GetOperation] + * to return + * [ImportEntriesMetadata][google.cloud.datacatalog.v1.ImportEntriesMetadata] + * and an + * [ImportEntriesResponse][google.cloud.datacatalog.v1.ImportEntriesResponse] + * message. + * + * The async variant is {@see DataCatalogClient::importEntriesAsync()} . + * + * @param ImportEntriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importEntries(ImportEntriesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportEntries', $request, $callOptions)->wait(); + } + + /** + * Lists entries. + * + * Note: Currently, this method can list only custom entries. + * To get a list of both custom and automatically created entries, use + * [SearchCatalog][google.cloud.datacatalog.v1.DataCatalog.SearchCatalog]. + * + * The async variant is {@see DataCatalogClient::listEntriesAsync()} . + * + * @param ListEntriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listEntries(ListEntriesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEntries', $request, $callOptions); + } + + /** + * Lists entry groups. + * + * The async variant is {@see DataCatalogClient::listEntryGroupsAsync()} . + * + * @param ListEntryGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listEntryGroups(ListEntryGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEntryGroups', $request, $callOptions); + } + + /** + * Lists tags assigned to an [Entry][google.cloud.datacatalog.v1.Entry]. + * The [columns][google.cloud.datacatalog.v1.Tag.column] in the response are + * lowercased. + * + * The async variant is {@see DataCatalogClient::listTagsAsync()} . + * + * @param ListTagsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTags(ListTagsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTags', $request, $callOptions); + } + + /** + * Gets an entry by its target resource name. + * + * The resource name comes from the source Google Cloud Platform service. + * + * The async variant is {@see DataCatalogClient::lookupEntryAsync()} . + * + * @param LookupEntryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Entry + * + * @throws ApiException Thrown if the API call fails. + */ + public function lookupEntry(LookupEntryRequest $request, array $callOptions = []): Entry + { + return $this->startApiCall('LookupEntry', $request, $callOptions)->wait(); + } + + /** + * Modifies contacts, part of the business context of an + * [Entry][google.cloud.datacatalog.v1.Entry]. + * + * To call this method, you must have the `datacatalog.entries.updateContacts` + * IAM permission on the corresponding project. + * + * The async variant is {@see DataCatalogClient::modifyEntryContactsAsync()} . + * + * @param ModifyEntryContactsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Contacts + * + * @throws ApiException Thrown if the API call fails. + */ + public function modifyEntryContacts(ModifyEntryContactsRequest $request, array $callOptions = []): Contacts + { + return $this->startApiCall('ModifyEntryContacts', $request, $callOptions)->wait(); + } + + /** + * Modifies entry overview, part of the business context of an + * [Entry][google.cloud.datacatalog.v1.Entry]. + * + * To call this method, you must have the `datacatalog.entries.updateOverview` + * IAM permission on the corresponding project. + * + * The async variant is {@see DataCatalogClient::modifyEntryOverviewAsync()} . + * + * @param ModifyEntryOverviewRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 EntryOverview + * + * @throws ApiException Thrown if the API call fails. + */ + public function modifyEntryOverview(ModifyEntryOverviewRequest $request, array $callOptions = []): EntryOverview + { + return $this->startApiCall('ModifyEntryOverview', $request, $callOptions)->wait(); + } + + /** + * `ReconcileTags` creates or updates a list of tags on the entry. + * If the + * [ReconcileTagsRequest.force_delete_missing][google.cloud.datacatalog.v1.ReconcileTagsRequest.force_delete_missing] + * parameter is set, the operation deletes tags not included in the input tag + * list. + * + * `ReconcileTags` returns a [long-running operation] + * [google.longrunning.Operation] resource that can be queried with + * [Operations.GetOperation][google.longrunning.Operations.GetOperation] + * to return [ReconcileTagsMetadata] + * [google.cloud.datacatalog.v1.ReconcileTagsMetadata] and + * a [ReconcileTagsResponse] + * [google.cloud.datacatalog.v1.ReconcileTagsResponse] message. + * + * The async variant is {@see DataCatalogClient::reconcileTagsAsync()} . + * + * @param ReconcileTagsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function reconcileTags(ReconcileTagsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ReconcileTags', $request, $callOptions)->wait(); + } + + /** + * Renames a field in a tag template. + * + * You must enable the Data Catalog API in the project identified by the + * `name` parameter. For more information, see [Data Catalog resource project] + * (https://cloud.google.com/data-catalog/docs/concepts/resource-project). + * + * The async variant is {@see DataCatalogClient::renameTagTemplateFieldAsync()} . + * + * @param RenameTagTemplateFieldRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TagTemplateField + * + * @throws ApiException Thrown if the API call fails. + */ + public function renameTagTemplateField(RenameTagTemplateFieldRequest $request, array $callOptions = []): TagTemplateField + { + return $this->startApiCall('RenameTagTemplateField', $request, $callOptions)->wait(); + } + + /** + * Renames an enum value in a tag template. + * + * Within a single enum field, enum values must be unique. + * + * The async variant is + * {@see DataCatalogClient::renameTagTemplateFieldEnumValueAsync()} . + * + * @param RenameTagTemplateFieldEnumValueRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TagTemplateField + * + * @throws ApiException Thrown if the API call fails. + */ + public function renameTagTemplateFieldEnumValue(RenameTagTemplateFieldEnumValueRequest $request, array $callOptions = []): TagTemplateField + { + return $this->startApiCall('RenameTagTemplateFieldEnumValue', $request, $callOptions)->wait(); + } + + /** + * Searches Data Catalog for multiple resources like entries and tags that + * match a query. + * + * This is a [Custom Method] + * (https://cloud.google.com/apis/design/custom_methods) that doesn't return + * all information on a resource, only its ID and high level fields. To get + * more information, you can subsequently call specific get methods. + * + * Note: Data Catalog search queries don't guarantee full recall. Results + * that match your query might not be returned, even in subsequent + * result pages. Additionally, returned (and not returned) results can vary + * if you repeat search queries. + * + * For more information, see [Data Catalog search syntax] + * (https://cloud.google.com/data-catalog/docs/how-to/search-reference). + * + * The async variant is {@see DataCatalogClient::searchCatalogAsync()} . + * + * @param SearchCatalogRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchCatalog(SearchCatalogRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchCatalog', $request, $callOptions); + } + + /** + * Sets an access control policy for a resource. Replaces any existing + * policy. + * + * Supported resources are: + * + * - Tag templates + * - Entry groups + * + * Note: This method sets policies only within Data Catalog and can't be + * used to manage policies in BigQuery, Pub/Sub, Dataproc Metastore, and any + * external Google Cloud Platform resources synced with the Data Catalog. + * + * To call this method, you must have the following Google IAM permissions: + * + * - `datacatalog.tagTemplates.setIamPolicy` to set policies on tag + * templates. + * - `datacatalog.entryGroups.setIamPolicy` to set policies on entry groups. + * + * The async variant is {@see DataCatalogClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Marks an [Entry][google.cloud.datacatalog.v1.Entry] as starred by + * the current user. Starring information is private to each user. + * + * The async variant is {@see DataCatalogClient::starEntryAsync()} . + * + * @param StarEntryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 StarEntryResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function starEntry(StarEntryRequest $request, array $callOptions = []): StarEntryResponse + { + return $this->startApiCall('StarEntry', $request, $callOptions)->wait(); + } + + /** + * Gets your permissions on a resource. + * + * Returns an empty set of permissions if the resource doesn't exist. + * + * Supported resources are: + * + * - Tag templates + * - Entry groups + * + * Note: This method gets policies only within Data Catalog and can't be + * used to get policies from BigQuery, Pub/Sub, Dataproc Metastore, and any + * external Google Cloud Platform resources ingested into Data Catalog. + * + * No Google IAM permissions are required to call this method. + * + * The async variant is {@see DataCatalogClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Marks an [Entry][google.cloud.datacatalog.v1.Entry] as NOT starred by + * the current user. Starring information is private to each user. + * + * The async variant is {@see DataCatalogClient::unstarEntryAsync()} . + * + * @param UnstarEntryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 UnstarEntryResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function unstarEntry(UnstarEntryRequest $request, array $callOptions = []): UnstarEntryResponse + { + return $this->startApiCall('UnstarEntry', $request, $callOptions)->wait(); + } + + /** + * Updates an existing entry. + * + * You must enable the Data Catalog API in the project identified by + * the `entry.name` parameter. For more information, see [Data Catalog + * resource + * project](https://cloud.google.com/data-catalog/docs/concepts/resource-project). + * + * The async variant is {@see DataCatalogClient::updateEntryAsync()} . + * + * @param UpdateEntryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Entry + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateEntry(UpdateEntryRequest $request, array $callOptions = []): Entry + { + return $this->startApiCall('UpdateEntry', $request, $callOptions)->wait(); + } + + /** + * Updates an entry group. + * + * You must enable the Data Catalog API in the project identified by + * the `entry_group.name` parameter. For more information, see [Data Catalog + * resource + * project](https://cloud.google.com/data-catalog/docs/concepts/resource-project). + * + * The async variant is {@see DataCatalogClient::updateEntryGroupAsync()} . + * + * @param UpdateEntryGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 EntryGroup + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateEntryGroup(UpdateEntryGroupRequest $request, array $callOptions = []): EntryGroup + { + return $this->startApiCall('UpdateEntryGroup', $request, $callOptions)->wait(); + } + + /** + * Updates an existing tag. + * + * The async variant is {@see DataCatalogClient::updateTagAsync()} . + * + * @param UpdateTagRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Tag + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTag(UpdateTagRequest $request, array $callOptions = []): Tag + { + return $this->startApiCall('UpdateTag', $request, $callOptions)->wait(); + } + + /** + * Updates a tag template. + * + * You can't update template fields with this method. These fields are + * separate resources with their own create, update, and delete methods. + * + * You must enable the Data Catalog API in the project identified by + * the `tag_template.name` parameter. For more information, see [Data Catalog + * resource + * project](https://cloud.google.com/data-catalog/docs/concepts/resource-project). + * + * The async variant is {@see DataCatalogClient::updateTagTemplateAsync()} . + * + * @param UpdateTagTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TagTemplate + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTagTemplate(UpdateTagTemplateRequest $request, array $callOptions = []): TagTemplate + { + return $this->startApiCall('UpdateTagTemplate', $request, $callOptions)->wait(); + } + + /** + * Updates a field in a tag template. + * + * You can't update the field type with this method. + * + * You must enable the Data Catalog API in the project + * identified by the `name` parameter. For more information, see [Data Catalog + * resource + * project](https://cloud.google.com/data-catalog/docs/concepts/resource-project). + * + * The async variant is {@see DataCatalogClient::updateTagTemplateFieldAsync()} . + * + * @param UpdateTagTemplateFieldRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TagTemplateField + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTagTemplateField(UpdateTagTemplateFieldRequest $request, array $callOptions = []): TagTemplateField + { + return $this->startApiCall('UpdateTagTemplateField', $request, $callOptions)->wait(); + } } diff --git a/DataCatalog/src/V1/Client/PolicyTagManagerClient.php b/DataCatalog/src/V1/Client/PolicyTagManagerClient.php index 84675c7c6153..797ef09edd41 100644 --- a/DataCatalog/src/V1/Client/PolicyTagManagerClient.php +++ b/DataCatalog/src/V1/Client/PolicyTagManagerClient.php @@ -24,17 +24,583 @@ namespace Google\Cloud\DataCatalog\V1\Client; -use Google\Cloud\DataCatalog\V1\Client\BaseClient\PolicyTagManagerBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\DataCatalog\V1\CreatePolicyTagRequest; +use Google\Cloud\DataCatalog\V1\CreateTaxonomyRequest; +use Google\Cloud\DataCatalog\V1\DeletePolicyTagRequest; +use Google\Cloud\DataCatalog\V1\DeleteTaxonomyRequest; +use Google\Cloud\DataCatalog\V1\GetPolicyTagRequest; +use Google\Cloud\DataCatalog\V1\GetTaxonomyRequest; +use Google\Cloud\DataCatalog\V1\ListPolicyTagsRequest; +use Google\Cloud\DataCatalog\V1\ListTaxonomiesRequest; +use Google\Cloud\DataCatalog\V1\PolicyTag; +use Google\Cloud\DataCatalog\V1\Taxonomy; +use Google\Cloud\DataCatalog\V1\UpdatePolicyTagRequest; +use Google\Cloud\DataCatalog\V1\UpdateTaxonomyRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Policy Tag Manager API service allows you to manage your policy tags and + * taxonomies. * - * This class is currently experimental and may be subject to changes. + * Policy tags are used to tag BigQuery columns and apply additional access + * control policies. A taxonomy is a hierarchical grouping of policy tags that + * classify data along a common axis. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\DataCatalog\V1\PolicyTagManagerClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createPolicyTagAsync(CreatePolicyTagRequest $request, array $optionalArgs = []) + * @method PromiseInterface createTaxonomyAsync(CreateTaxonomyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deletePolicyTagAsync(DeletePolicyTagRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTaxonomyAsync(DeleteTaxonomyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getPolicyTagAsync(GetPolicyTagRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTaxonomyAsync(GetTaxonomyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPolicyTagsAsync(ListPolicyTagsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTaxonomiesAsync(ListTaxonomiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updatePolicyTagAsync(UpdatePolicyTagRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateTaxonomyAsync(UpdateTaxonomyRequest $request, array $optionalArgs = []) */ -final class PolicyTagManagerClient extends PolicyTagManagerBaseClient +final class PolicyTagManagerClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see PolicyTagManagerBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.datacatalog.v1.PolicyTagManager'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'datacatalog.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/policy_tag_manager_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/policy_tag_manager_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/policy_tag_manager_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/policy_tag_manager_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a policy_tag + * resource. + * + * @param string $project + * @param string $location + * @param string $taxonomy + * @param string $policyTag + * + * @return string The formatted policy_tag resource. + */ + public static function policyTagName(string $project, string $location, string $taxonomy, string $policyTag): string + { + return self::getPathTemplate('policyTag')->render([ + 'project' => $project, + 'location' => $location, + 'taxonomy' => $taxonomy, + 'policy_tag' => $policyTag, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a taxonomy + * resource. + * + * @param string $project + * @param string $location + * @param string $taxonomy + * + * @return string The formatted taxonomy resource. + */ + public static function taxonomyName(string $project, string $location, string $taxonomy): string + { + return self::getPathTemplate('taxonomy')->render([ + 'project' => $project, + 'location' => $location, + 'taxonomy' => $taxonomy, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - location: projects/{project}/locations/{location} + * - policyTag: projects/{project}/locations/{location}/taxonomies/{taxonomy}/policyTags/{policy_tag} + * - taxonomy: projects/{project}/locations/{location}/taxonomies/{taxonomy} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'datacatalog.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a policy tag in a taxonomy. + * + * The async variant is {@see PolicyTagManagerClient::createPolicyTagAsync()} . + * + * @param CreatePolicyTagRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PolicyTag + * + * @throws ApiException Thrown if the API call fails. + */ + public function createPolicyTag(CreatePolicyTagRequest $request, array $callOptions = []): PolicyTag + { + return $this->startApiCall('CreatePolicyTag', $request, $callOptions)->wait(); + } + + /** + * Creates a taxonomy in a specified project. + * + * The taxonomy is initially empty, that is, it doesn't contain policy tags. + * + * The async variant is {@see PolicyTagManagerClient::createTaxonomyAsync()} . + * + * @param CreateTaxonomyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Taxonomy + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTaxonomy(CreateTaxonomyRequest $request, array $callOptions = []): Taxonomy + { + return $this->startApiCall('CreateTaxonomy', $request, $callOptions)->wait(); + } + + /** + * Deletes a policy tag together with the following: + * + * * All of its descendant policy tags, if any + * * Policies associated with the policy tag and its descendants + * * References from BigQuery table schema of the policy tag and its + * descendants + * + * The async variant is {@see PolicyTagManagerClient::deletePolicyTagAsync()} . + * + * @param DeletePolicyTagRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deletePolicyTag(DeletePolicyTagRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeletePolicyTag', $request, $callOptions)->wait(); + } + + /** + * Deletes a taxonomy, including all policy tags in this + * taxonomy, their associated policies, and the policy tags references from + * BigQuery columns. + * + * The async variant is {@see PolicyTagManagerClient::deleteTaxonomyAsync()} . + * + * @param DeleteTaxonomyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTaxonomy(DeleteTaxonomyRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteTaxonomy', $request, $callOptions)->wait(); + } + + /** + * Gets the IAM policy for a policy tag or a taxonomy. + * + * The async variant is {@see PolicyTagManagerClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets a policy tag. + * + * The async variant is {@see PolicyTagManagerClient::getPolicyTagAsync()} . + * + * @param GetPolicyTagRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PolicyTag + * + * @throws ApiException Thrown if the API call fails. + */ + public function getPolicyTag(GetPolicyTagRequest $request, array $callOptions = []): PolicyTag + { + return $this->startApiCall('GetPolicyTag', $request, $callOptions)->wait(); + } + + /** + * Gets a taxonomy. + * + * The async variant is {@see PolicyTagManagerClient::getTaxonomyAsync()} . + * + * @param GetTaxonomyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Taxonomy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTaxonomy(GetTaxonomyRequest $request, array $callOptions = []): Taxonomy + { + return $this->startApiCall('GetTaxonomy', $request, $callOptions)->wait(); + } + + /** + * Lists all policy tags in a taxonomy. + * + * The async variant is {@see PolicyTagManagerClient::listPolicyTagsAsync()} . + * + * @param ListPolicyTagsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPolicyTags(ListPolicyTagsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPolicyTags', $request, $callOptions); + } + + /** + * Lists all taxonomies in a project in a particular location that you + * have a permission to view. + * + * The async variant is {@see PolicyTagManagerClient::listTaxonomiesAsync()} . + * + * @param ListTaxonomiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTaxonomies(ListTaxonomiesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTaxonomies', $request, $callOptions); + } + + /** + * Sets the IAM policy for a policy tag or a taxonomy. + * + * The async variant is {@see PolicyTagManagerClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns your permissions on a specified policy tag or + * taxonomy. + * + * The async variant is {@see PolicyTagManagerClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates a policy tag, including its display + * name, description, and parent policy tag. + * + * The async variant is {@see PolicyTagManagerClient::updatePolicyTagAsync()} . + * + * @param UpdatePolicyTagRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PolicyTag + * + * @throws ApiException Thrown if the API call fails. + */ + public function updatePolicyTag(UpdatePolicyTagRequest $request, array $callOptions = []): PolicyTag + { + return $this->startApiCall('UpdatePolicyTag', $request, $callOptions)->wait(); + } + + /** + * Updates a taxonomy, including its display name, + * description, and activated policy types. + * + * The async variant is {@see PolicyTagManagerClient::updateTaxonomyAsync()} . + * + * @param UpdateTaxonomyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Taxonomy + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTaxonomy(UpdateTaxonomyRequest $request, array $callOptions = []): Taxonomy + { + return $this->startApiCall('UpdateTaxonomy', $request, $callOptions)->wait(); + } } diff --git a/DataCatalog/src/V1/Client/PolicyTagManagerSerializationClient.php b/DataCatalog/src/V1/Client/PolicyTagManagerSerializationClient.php index 2502b956b242..e70ee4f7af7d 100644 --- a/DataCatalog/src/V1/Client/PolicyTagManagerSerializationClient.php +++ b/DataCatalog/src/V1/Client/PolicyTagManagerSerializationClient.php @@ -24,17 +24,315 @@ namespace Google\Cloud\DataCatalog\V1\Client; -use Google\Cloud\DataCatalog\V1\Client\BaseClient\PolicyTagManagerSerializationBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\DataCatalog\V1\ExportTaxonomiesRequest; +use Google\Cloud\DataCatalog\V1\ExportTaxonomiesResponse; +use Google\Cloud\DataCatalog\V1\ImportTaxonomiesRequest; +use Google\Cloud\DataCatalog\V1\ImportTaxonomiesResponse; +use Google\Cloud\DataCatalog\V1\ReplaceTaxonomyRequest; +use Google\Cloud\DataCatalog\V1\Taxonomy; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Policy Tag Manager Serialization API service allows you to manipulate + * your policy tags and taxonomies in a serialized format. * - * This class is currently experimental and may be subject to changes. + * Taxonomy is a hierarchical group of policy tags. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\DataCatalog\V1\PolicyTagManagerSerializationClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface exportTaxonomiesAsync(ExportTaxonomiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface importTaxonomiesAsync(ImportTaxonomiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface replaceTaxonomyAsync(ReplaceTaxonomyRequest $request, array $optionalArgs = []) */ -final class PolicyTagManagerSerializationClient extends PolicyTagManagerSerializationBaseClient +final class PolicyTagManagerSerializationClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see PolicyTagManagerSerializationBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.datacatalog.v1.PolicyTagManagerSerialization'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'datacatalog.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/policy_tag_manager_serialization_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/policy_tag_manager_serialization_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/policy_tag_manager_serialization_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/policy_tag_manager_serialization_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a taxonomy + * resource. + * + * @param string $project + * @param string $location + * @param string $taxonomy + * + * @return string The formatted taxonomy resource. + */ + public static function taxonomyName(string $project, string $location, string $taxonomy): string + { + return self::getPathTemplate('taxonomy')->render([ + 'project' => $project, + 'location' => $location, + 'taxonomy' => $taxonomy, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - location: projects/{project}/locations/{location} + * - taxonomy: projects/{project}/locations/{location}/taxonomies/{taxonomy} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'datacatalog.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Exports taxonomies in the requested type and returns them, + * including their policy tags. The requested taxonomies must belong to the + * same project. + * + * This method generates `SerializedTaxonomy` protocol buffers with nested + * policy tags that can be used as input for `ImportTaxonomies` calls. + * + * The async variant is + * {@see PolicyTagManagerSerializationClient::exportTaxonomiesAsync()} . + * + * @param ExportTaxonomiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ExportTaxonomiesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportTaxonomies(ExportTaxonomiesRequest $request, array $callOptions = []): ExportTaxonomiesResponse + { + return $this->startApiCall('ExportTaxonomies', $request, $callOptions)->wait(); + } + + /** + * Creates new taxonomies (including their policy tags) in a given project + * by importing from inlined or cross-regional sources. + * + * For a cross-regional source, new taxonomies are created by copying + * from a source in another region. + * + * For an inlined source, taxonomies and policy tags are created in bulk using + * nested protocol buffer structures. + * + * The async variant is + * {@see PolicyTagManagerSerializationClient::importTaxonomiesAsync()} . + * + * @param ImportTaxonomiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ImportTaxonomiesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importTaxonomies(ImportTaxonomiesRequest $request, array $callOptions = []): ImportTaxonomiesResponse + { + return $this->startApiCall('ImportTaxonomies', $request, $callOptions)->wait(); + } + + /** + * Replaces (updates) a taxonomy and all its policy tags. + * + * The taxonomy and its entire hierarchy of policy tags must be + * represented literally by `SerializedTaxonomy` and the nested + * `SerializedPolicyTag` messages. + * + * This operation automatically does the following: + * + * - Deletes the existing policy tags that are missing from the + * `SerializedPolicyTag`. + * - Creates policy tags that don't have resource names. They are considered + * new. + * - Updates policy tags with valid resources names accordingly. + * + * The async variant is + * {@see PolicyTagManagerSerializationClient::replaceTaxonomyAsync()} . + * + * @param ReplaceTaxonomyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Taxonomy + * + * @throws ApiException Thrown if the API call fails. + */ + public function replaceTaxonomy(ReplaceTaxonomyRequest $request, array $callOptions = []): Taxonomy + { + return $this->startApiCall('ReplaceTaxonomy', $request, $callOptions)->wait(); + } } diff --git a/DataCatalogLineage/composer.json b/DataCatalogLineage/composer.json index cab187dce897..30e4e3779974 100644 --- a/DataCatalogLineage/composer.json +++ b/DataCatalogLineage/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/DataCatalogLineage/src/V1/Client/BaseClient/LineageBaseClient.php b/DataCatalogLineage/src/V1/Client/BaseClient/LineageBaseClient.php deleted file mode 100644 index 48c2a9806386..000000000000 --- a/DataCatalogLineage/src/V1/Client/BaseClient/LineageBaseClient.php +++ /dev/null @@ -1,787 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/lineage_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/lineage_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/lineage_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/lineage_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * lineage_event resource. - * - * @param string $project - * @param string $location - * @param string $process - * @param string $run - * @param string $lineageEvent - * - * @return string The formatted lineage_event resource. - */ - public static function lineageEventName(string $project, string $location, string $process, string $run, string $lineageEvent): string - { - return self::getPathTemplate('lineageEvent')->render([ - 'project' => $project, - 'location' => $location, - 'process' => $process, - 'run' => $run, - 'lineage_event' => $lineageEvent, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a process - * resource. - * - * @param string $project - * @param string $location - * @param string $process - * - * @return string The formatted process resource. - */ - public static function processName(string $project, string $location, string $process): string - { - return self::getPathTemplate('process')->render([ - 'project' => $project, - 'location' => $location, - 'process' => $process, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a run - * resource. - * - * @param string $project - * @param string $location - * @param string $process - * @param string $run - * - * @return string The formatted run resource. - */ - public static function runName(string $project, string $location, string $process, string $run): string - { - return self::getPathTemplate('run')->render([ - 'project' => $project, - 'location' => $location, - 'process' => $process, - 'run' => $run, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - lineageEvent: projects/{project}/locations/{location}/processes/{process}/runs/{run}/lineageEvents/{lineage_event} - * - location: projects/{project}/locations/{location} - * - process: projects/{project}/locations/{location}/processes/{process} - * - run: projects/{project}/locations/{location}/processes/{process}/runs/{run} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'datalineage.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieve information about LineageProcesses associated with specific - * links. LineageProcesses are transformation pipelines that result in data - * flowing from **source** to **target** assets. Links between assets - * represent this operation. - * - * If you have specific link names, you can use this method to - * verify which LineageProcesses contribute to creating those links. - * See the - * [SearchLinks][google.cloud.datacatalog.lineage.v1.Lineage.SearchLinks] - * method for more information on how to retrieve link name. - * - * You can retrieve the LineageProcess information in every project where you - * have the `datalineage.events.get` permission. The project provided in the - * URL is used for Billing and Quota. - * - * The async variant is {@see self::batchSearchLinkProcessesAsync()} . - * - * @example samples/V1/LineageClient/batch_search_link_processes.php - * - * @param BatchSearchLinkProcessesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchSearchLinkProcesses(BatchSearchLinkProcessesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('BatchSearchLinkProcesses', $request, $callOptions); - } - - /** - * Creates a new lineage event. - * - * The async variant is {@see self::createLineageEventAsync()} . - * - * @example samples/V1/LineageClient/create_lineage_event.php - * - * @param CreateLineageEventRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LineageEvent - * - * @throws ApiException Thrown if the API call fails. - */ - public function createLineageEvent(CreateLineageEventRequest $request, array $callOptions = []): LineageEvent - { - return $this->startApiCall('CreateLineageEvent', $request, $callOptions)->wait(); - } - - /** - * Creates a new process. - * - * The async variant is {@see self::createProcessAsync()} . - * - * @example samples/V1/LineageClient/create_process.php - * - * @param CreateProcessRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Process - * - * @throws ApiException Thrown if the API call fails. - */ - public function createProcess(CreateProcessRequest $request, array $callOptions = []): Process - { - return $this->startApiCall('CreateProcess', $request, $callOptions)->wait(); - } - - /** - * Creates a new run. - * - * The async variant is {@see self::createRunAsync()} . - * - * @example samples/V1/LineageClient/create_run.php - * - * @param CreateRunRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Run - * - * @throws ApiException Thrown if the API call fails. - */ - public function createRun(CreateRunRequest $request, array $callOptions = []): Run - { - return $this->startApiCall('CreateRun', $request, $callOptions)->wait(); - } - - /** - * Deletes the lineage event with the specified name. - * - * The async variant is {@see self::deleteLineageEventAsync()} . - * - * @example samples/V1/LineageClient/delete_lineage_event.php - * - * @param DeleteLineageEventRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteLineageEvent(DeleteLineageEventRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteLineageEvent', $request, $callOptions)->wait(); - } - - /** - * Deletes the process with the specified name. - * - * The async variant is {@see self::deleteProcessAsync()} . - * - * @example samples/V1/LineageClient/delete_process.php - * - * @param DeleteProcessRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteProcess(DeleteProcessRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteProcess', $request, $callOptions)->wait(); - } - - /** - * Deletes the run with the specified name. - * - * The async variant is {@see self::deleteRunAsync()} . - * - * @example samples/V1/LineageClient/delete_run.php - * - * @param DeleteRunRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteRun(DeleteRunRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteRun', $request, $callOptions)->wait(); - } - - /** - * Gets details of a specified lineage event. - * - * The async variant is {@see self::getLineageEventAsync()} . - * - * @example samples/V1/LineageClient/get_lineage_event.php - * - * @param GetLineageEventRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LineageEvent - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLineageEvent(GetLineageEventRequest $request, array $callOptions = []): LineageEvent - { - return $this->startApiCall('GetLineageEvent', $request, $callOptions)->wait(); - } - - /** - * Gets the details of the specified process. - * - * The async variant is {@see self::getProcessAsync()} . - * - * @example samples/V1/LineageClient/get_process.php - * - * @param GetProcessRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Process - * - * @throws ApiException Thrown if the API call fails. - */ - public function getProcess(GetProcessRequest $request, array $callOptions = []): Process - { - return $this->startApiCall('GetProcess', $request, $callOptions)->wait(); - } - - /** - * Gets the details of the specified run. - * - * The async variant is {@see self::getRunAsync()} . - * - * @example samples/V1/LineageClient/get_run.php - * - * @param GetRunRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Run - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRun(GetRunRequest $request, array $callOptions = []): Run - { - return $this->startApiCall('GetRun', $request, $callOptions)->wait(); - } - - /** - * Lists lineage events in the given project and location. The list order is - * not defined. - * - * The async variant is {@see self::listLineageEventsAsync()} . - * - * @example samples/V1/LineageClient/list_lineage_events.php - * - * @param ListLineageEventsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLineageEvents(ListLineageEventsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLineageEvents', $request, $callOptions); - } - - /** - * List processes in the given project and location. List order is descending - * by insertion time. - * - * The async variant is {@see self::listProcessesAsync()} . - * - * @example samples/V1/LineageClient/list_processes.php - * - * @param ListProcessesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listProcesses(ListProcessesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListProcesses', $request, $callOptions); - } - - /** - * Lists runs in the given project and location. List order is descending by - * `start_time`. - * - * The async variant is {@see self::listRunsAsync()} . - * - * @example samples/V1/LineageClient/list_runs.php - * - * @param ListRunsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listRuns(ListRunsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListRuns', $request, $callOptions); - } - - /** - * Retrieve a list of links connected to a specific asset. - * Links represent the data flow between **source** (upstream) - * and **target** (downstream) assets in transformation pipelines. - * Links are stored in the same project as the Lineage Events that create - * them. - * - * You can retrieve links in every project where you have the - * `datalineage.events.get` permission. The project provided in the URL - * is used for Billing and Quota. - * - * The async variant is {@see self::searchLinksAsync()} . - * - * @example samples/V1/LineageClient/search_links.php - * - * @param SearchLinksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchLinks(SearchLinksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchLinks', $request, $callOptions); - } - - /** - * Updates a process. - * - * The async variant is {@see self::updateProcessAsync()} . - * - * @example samples/V1/LineageClient/update_process.php - * - * @param UpdateProcessRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Process - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateProcess(UpdateProcessRequest $request, array $callOptions = []): Process - { - return $this->startApiCall('UpdateProcess', $request, $callOptions)->wait(); - } - - /** - * Updates a run. - * - * The async variant is {@see self::updateRunAsync()} . - * - * @example samples/V1/LineageClient/update_run.php - * - * @param UpdateRunRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Run - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateRun(UpdateRunRequest $request, array $callOptions = []): Run - { - return $this->startApiCall('UpdateRun', $request, $callOptions)->wait(); - } -} diff --git a/DataCatalogLineage/src/V1/Client/LineageClient.php b/DataCatalogLineage/src/V1/Client/LineageClient.php index 83eefbbcfb29..e4d33148af22 100644 --- a/DataCatalogLineage/src/V1/Client/LineageClient.php +++ b/DataCatalogLineage/src/V1/Client/LineageClient.php @@ -24,17 +24,762 @@ namespace Google\Cloud\DataCatalog\Lineage\V1\Client; -use Google\Cloud\DataCatalog\Lineage\V1\Client\BaseClient\LineageBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\DataCatalog\Lineage\V1\BatchSearchLinkProcessesRequest; +use Google\Cloud\DataCatalog\Lineage\V1\CreateLineageEventRequest; +use Google\Cloud\DataCatalog\Lineage\V1\CreateProcessRequest; +use Google\Cloud\DataCatalog\Lineage\V1\CreateRunRequest; +use Google\Cloud\DataCatalog\Lineage\V1\DeleteLineageEventRequest; +use Google\Cloud\DataCatalog\Lineage\V1\DeleteProcessRequest; +use Google\Cloud\DataCatalog\Lineage\V1\DeleteRunRequest; +use Google\Cloud\DataCatalog\Lineage\V1\GetLineageEventRequest; +use Google\Cloud\DataCatalog\Lineage\V1\GetProcessRequest; +use Google\Cloud\DataCatalog\Lineage\V1\GetRunRequest; +use Google\Cloud\DataCatalog\Lineage\V1\LineageEvent; +use Google\Cloud\DataCatalog\Lineage\V1\ListLineageEventsRequest; +use Google\Cloud\DataCatalog\Lineage\V1\ListProcessesRequest; +use Google\Cloud\DataCatalog\Lineage\V1\ListRunsRequest; +use Google\Cloud\DataCatalog\Lineage\V1\Process; +use Google\Cloud\DataCatalog\Lineage\V1\Run; +use Google\Cloud\DataCatalog\Lineage\V1\SearchLinksRequest; +use Google\Cloud\DataCatalog\Lineage\V1\UpdateProcessRequest; +use Google\Cloud\DataCatalog\Lineage\V1\UpdateRunRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Lineage is used to track data flows between assets over time. You can + * create [LineageEvents][google.cloud.datacatalog.lineage.v1.LineageEvent] + * to record lineage between multiple sources and a single target, for + * example, when table data is based on data from multiple tables. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\DataCatalog\Lineage\V1\LineageClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface batchSearchLinkProcessesAsync(BatchSearchLinkProcessesRequest $request, array $optionalArgs = []) + * @method PromiseInterface createLineageEventAsync(CreateLineageEventRequest $request, array $optionalArgs = []) + * @method PromiseInterface createProcessAsync(CreateProcessRequest $request, array $optionalArgs = []) + * @method PromiseInterface createRunAsync(CreateRunRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteLineageEventAsync(DeleteLineageEventRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteProcessAsync(DeleteProcessRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteRunAsync(DeleteRunRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLineageEventAsync(GetLineageEventRequest $request, array $optionalArgs = []) + * @method PromiseInterface getProcessAsync(GetProcessRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRunAsync(GetRunRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLineageEventsAsync(ListLineageEventsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listProcessesAsync(ListProcessesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listRunsAsync(ListRunsRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchLinksAsync(SearchLinksRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateProcessAsync(UpdateProcessRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateRunAsync(UpdateRunRequest $request, array $optionalArgs = []) */ -final class LineageClient extends LineageBaseClient +final class LineageClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see LineageBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.datacatalog.lineage.v1.Lineage'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'datalineage.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/lineage_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/lineage_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/lineage_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/lineage_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * lineage_event resource. + * + * @param string $project + * @param string $location + * @param string $process + * @param string $run + * @param string $lineageEvent + * + * @return string The formatted lineage_event resource. + */ + public static function lineageEventName(string $project, string $location, string $process, string $run, string $lineageEvent): string + { + return self::getPathTemplate('lineageEvent')->render([ + 'project' => $project, + 'location' => $location, + 'process' => $process, + 'run' => $run, + 'lineage_event' => $lineageEvent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a process + * resource. + * + * @param string $project + * @param string $location + * @param string $process + * + * @return string The formatted process resource. + */ + public static function processName(string $project, string $location, string $process): string + { + return self::getPathTemplate('process')->render([ + 'project' => $project, + 'location' => $location, + 'process' => $process, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a run + * resource. + * + * @param string $project + * @param string $location + * @param string $process + * @param string $run + * + * @return string The formatted run resource. + */ + public static function runName(string $project, string $location, string $process, string $run): string + { + return self::getPathTemplate('run')->render([ + 'project' => $project, + 'location' => $location, + 'process' => $process, + 'run' => $run, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - lineageEvent: projects/{project}/locations/{location}/processes/{process}/runs/{run}/lineageEvents/{lineage_event} + * - location: projects/{project}/locations/{location} + * - process: projects/{project}/locations/{location}/processes/{process} + * - run: projects/{project}/locations/{location}/processes/{process}/runs/{run} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'datalineage.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieve information about LineageProcesses associated with specific + * links. LineageProcesses are transformation pipelines that result in data + * flowing from **source** to **target** assets. Links between assets + * represent this operation. + * + * If you have specific link names, you can use this method to + * verify which LineageProcesses contribute to creating those links. + * See the + * [SearchLinks][google.cloud.datacatalog.lineage.v1.Lineage.SearchLinks] + * method for more information on how to retrieve link name. + * + * You can retrieve the LineageProcess information in every project where you + * have the `datalineage.events.get` permission. The project provided in the + * URL is used for Billing and Quota. + * + * The async variant is {@see LineageClient::batchSearchLinkProcessesAsync()} . + * + * @example samples/V1/LineageClient/batch_search_link_processes.php + * + * @param BatchSearchLinkProcessesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchSearchLinkProcesses(BatchSearchLinkProcessesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('BatchSearchLinkProcesses', $request, $callOptions); + } + + /** + * Creates a new lineage event. + * + * The async variant is {@see LineageClient::createLineageEventAsync()} . + * + * @example samples/V1/LineageClient/create_lineage_event.php + * + * @param CreateLineageEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LineageEvent + * + * @throws ApiException Thrown if the API call fails. + */ + public function createLineageEvent(CreateLineageEventRequest $request, array $callOptions = []): LineageEvent + { + return $this->startApiCall('CreateLineageEvent', $request, $callOptions)->wait(); + } + + /** + * Creates a new process. + * + * The async variant is {@see LineageClient::createProcessAsync()} . + * + * @example samples/V1/LineageClient/create_process.php + * + * @param CreateProcessRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Process + * + * @throws ApiException Thrown if the API call fails. + */ + public function createProcess(CreateProcessRequest $request, array $callOptions = []): Process + { + return $this->startApiCall('CreateProcess', $request, $callOptions)->wait(); + } + + /** + * Creates a new run. + * + * The async variant is {@see LineageClient::createRunAsync()} . + * + * @example samples/V1/LineageClient/create_run.php + * + * @param CreateRunRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Run + * + * @throws ApiException Thrown if the API call fails. + */ + public function createRun(CreateRunRequest $request, array $callOptions = []): Run + { + return $this->startApiCall('CreateRun', $request, $callOptions)->wait(); + } + + /** + * Deletes the lineage event with the specified name. + * + * The async variant is {@see LineageClient::deleteLineageEventAsync()} . + * + * @example samples/V1/LineageClient/delete_lineage_event.php + * + * @param DeleteLineageEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteLineageEvent(DeleteLineageEventRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteLineageEvent', $request, $callOptions)->wait(); + } + + /** + * Deletes the process with the specified name. + * + * The async variant is {@see LineageClient::deleteProcessAsync()} . + * + * @example samples/V1/LineageClient/delete_process.php + * + * @param DeleteProcessRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteProcess(DeleteProcessRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteProcess', $request, $callOptions)->wait(); + } + + /** + * Deletes the run with the specified name. + * + * The async variant is {@see LineageClient::deleteRunAsync()} . + * + * @example samples/V1/LineageClient/delete_run.php + * + * @param DeleteRunRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteRun(DeleteRunRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteRun', $request, $callOptions)->wait(); + } + + /** + * Gets details of a specified lineage event. + * + * The async variant is {@see LineageClient::getLineageEventAsync()} . + * + * @example samples/V1/LineageClient/get_lineage_event.php + * + * @param GetLineageEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LineageEvent + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLineageEvent(GetLineageEventRequest $request, array $callOptions = []): LineageEvent + { + return $this->startApiCall('GetLineageEvent', $request, $callOptions)->wait(); + } + + /** + * Gets the details of the specified process. + * + * The async variant is {@see LineageClient::getProcessAsync()} . + * + * @example samples/V1/LineageClient/get_process.php + * + * @param GetProcessRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Process + * + * @throws ApiException Thrown if the API call fails. + */ + public function getProcess(GetProcessRequest $request, array $callOptions = []): Process + { + return $this->startApiCall('GetProcess', $request, $callOptions)->wait(); + } + + /** + * Gets the details of the specified run. + * + * The async variant is {@see LineageClient::getRunAsync()} . + * + * @example samples/V1/LineageClient/get_run.php + * + * @param GetRunRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Run + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRun(GetRunRequest $request, array $callOptions = []): Run + { + return $this->startApiCall('GetRun', $request, $callOptions)->wait(); + } + + /** + * Lists lineage events in the given project and location. The list order is + * not defined. + * + * The async variant is {@see LineageClient::listLineageEventsAsync()} . + * + * @example samples/V1/LineageClient/list_lineage_events.php + * + * @param ListLineageEventsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLineageEvents(ListLineageEventsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLineageEvents', $request, $callOptions); + } + + /** + * List processes in the given project and location. List order is descending + * by insertion time. + * + * The async variant is {@see LineageClient::listProcessesAsync()} . + * + * @example samples/V1/LineageClient/list_processes.php + * + * @param ListProcessesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listProcesses(ListProcessesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListProcesses', $request, $callOptions); + } + + /** + * Lists runs in the given project and location. List order is descending by + * `start_time`. + * + * The async variant is {@see LineageClient::listRunsAsync()} . + * + * @example samples/V1/LineageClient/list_runs.php + * + * @param ListRunsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listRuns(ListRunsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListRuns', $request, $callOptions); + } + + /** + * Retrieve a list of links connected to a specific asset. + * Links represent the data flow between **source** (upstream) + * and **target** (downstream) assets in transformation pipelines. + * Links are stored in the same project as the Lineage Events that create + * them. + * + * You can retrieve links in every project where you have the + * `datalineage.events.get` permission. The project provided in the URL + * is used for Billing and Quota. + * + * The async variant is {@see LineageClient::searchLinksAsync()} . + * + * @example samples/V1/LineageClient/search_links.php + * + * @param SearchLinksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchLinks(SearchLinksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchLinks', $request, $callOptions); + } + + /** + * Updates a process. + * + * The async variant is {@see LineageClient::updateProcessAsync()} . + * + * @example samples/V1/LineageClient/update_process.php + * + * @param UpdateProcessRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Process + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateProcess(UpdateProcessRequest $request, array $callOptions = []): Process + { + return $this->startApiCall('UpdateProcess', $request, $callOptions)->wait(); + } + + /** + * Updates a run. + * + * The async variant is {@see LineageClient::updateRunAsync()} . + * + * @example samples/V1/LineageClient/update_run.php + * + * @param UpdateRunRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Run + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateRun(UpdateRunRequest $request, array $callOptions = []): Run + { + return $this->startApiCall('UpdateRun', $request, $callOptions)->wait(); + } } diff --git a/DataFusion/composer.json b/DataFusion/composer.json index 19f88b9f1419..c9d429d2db74 100644 --- a/DataFusion/composer.json +++ b/DataFusion/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/DataFusion/src/V1/Client/BaseClient/DataFusionBaseClient.php b/DataFusion/src/V1/Client/BaseClient/DataFusionBaseClient.php deleted file mode 100644 index 006dfdbc624d..000000000000 --- a/DataFusion/src/V1/Client/BaseClient/DataFusionBaseClient.php +++ /dev/null @@ -1,487 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/data_fusion_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/data_fusion_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/data_fusion_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/data_fusion_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a crypto_key - * resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * @param string $cryptoKey - * - * @return string The formatted crypto_key resource. - */ - public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string - { - return self::getPathTemplate('cryptoKey')->render([ - 'project' => $project, - 'location' => $location, - 'key_ring' => $keyRing, - 'crypto_key' => $cryptoKey, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a instance - * resource. - * - * @param string $project - * @param string $location - * @param string $instance - * - * @return string The formatted instance resource. - */ - public static function instanceName(string $project, string $location, string $instance): string - { - return self::getPathTemplate('instance')->render([ - 'project' => $project, - 'location' => $location, - 'instance' => $instance, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} - * - instance: projects/{project}/locations/{location}/instances/{instance} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'datafusion.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new Data Fusion instance in the specified project and location. - * - * The async variant is {@see self::createInstanceAsync()} . - * - * @example samples/V1/DataFusionClient/create_instance.php - * - * @param CreateInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createInstance(CreateInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateInstance', $request, $callOptions)->wait(); - } - - /** - * Deletes a single Date Fusion instance. - * - * The async variant is {@see self::deleteInstanceAsync()} . - * - * @example samples/V1/DataFusionClient/delete_instance.php - * - * @param DeleteInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single Data Fusion instance. - * - * The async variant is {@see self::getInstanceAsync()} . - * - * @example samples/V1/DataFusionClient/get_instance.php - * - * @param GetInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Instance - * - * @throws ApiException Thrown if the API call fails. - */ - public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance - { - return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); - } - - /** - * Lists possible versions for Data Fusion instances in the specified project - * and location. - * - * The async variant is {@see self::listAvailableVersionsAsync()} . - * - * @example samples/V1/DataFusionClient/list_available_versions.php - * - * @param ListAvailableVersionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAvailableVersions(ListAvailableVersionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAvailableVersions', $request, $callOptions); - } - - /** - * Lists Data Fusion instances in the specified project and location. - * - * The async variant is {@see self::listInstancesAsync()} . - * - * @example samples/V1/DataFusionClient/list_instances.php - * - * @param ListInstancesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listInstances(ListInstancesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListInstances', $request, $callOptions); - } - - /** - * Restart a single Data Fusion instance. - * At the end of an operation instance is fully restarted. - * - * The async variant is {@see self::restartInstanceAsync()} . - * - * @example samples/V1/DataFusionClient/restart_instance.php - * - * @param RestartInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function restartInstance(RestartInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RestartInstance', $request, $callOptions)->wait(); - } - - /** - * Updates a single Data Fusion instance. - * - * The async variant is {@see self::updateInstanceAsync()} . - * - * @example samples/V1/DataFusionClient/update_instance.php - * - * @param UpdateInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateInstance(UpdateInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateInstance', $request, $callOptions)->wait(); - } -} diff --git a/DataFusion/src/V1/Client/DataFusionClient.php b/DataFusion/src/V1/Client/DataFusionClient.php index 0952b882198e..834a79c7c365 100644 --- a/DataFusion/src/V1/Client/DataFusionClient.php +++ b/DataFusion/src/V1/Client/DataFusionClient.php @@ -24,17 +24,462 @@ namespace Google\Cloud\DataFusion\V1\Client; -use Google\Cloud\DataFusion\V1\Client\BaseClient\DataFusionBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\DataFusion\V1\CreateInstanceRequest; +use Google\Cloud\DataFusion\V1\DeleteInstanceRequest; +use Google\Cloud\DataFusion\V1\GetInstanceRequest; +use Google\Cloud\DataFusion\V1\Instance; +use Google\Cloud\DataFusion\V1\ListAvailableVersionsRequest; +use Google\Cloud\DataFusion\V1\ListInstancesRequest; +use Google\Cloud\DataFusion\V1\RestartInstanceRequest; +use Google\Cloud\DataFusion\V1\UpdateInstanceRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for creating and managing Data Fusion instances. + * Data Fusion enables ETL developers to build code-free, data integration + * pipelines via a point-and-click UI. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\DataFusion\V1\DataFusionClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createInstanceAsync(CreateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteInstanceAsync(DeleteInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInstanceAsync(GetInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAvailableVersionsAsync(ListAvailableVersionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInstancesAsync(ListInstancesRequest $request, array $optionalArgs = []) + * @method PromiseInterface restartInstanceAsync(RestartInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateInstanceAsync(UpdateInstanceRequest $request, array $optionalArgs = []) */ -final class DataFusionClient extends DataFusionBaseClient +final class DataFusionClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DataFusionBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.datafusion.v1.DataFusion'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'datafusion.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/data_fusion_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/data_fusion_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/data_fusion_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/data_fusion_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a crypto_key + * resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * + * @return string The formatted crypto_key resource. + */ + public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string + { + return self::getPathTemplate('cryptoKey')->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'crypto_key' => $cryptoKey, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a instance + * resource. + * + * @param string $project + * @param string $location + * @param string $instance + * + * @return string The formatted instance resource. + */ + public static function instanceName(string $project, string $location, string $instance): string + { + return self::getPathTemplate('instance')->render([ + 'project' => $project, + 'location' => $location, + 'instance' => $instance, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} + * - instance: projects/{project}/locations/{location}/instances/{instance} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'datafusion.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new Data Fusion instance in the specified project and location. + * + * The async variant is {@see DataFusionClient::createInstanceAsync()} . + * + * @example samples/V1/DataFusionClient/create_instance.php + * + * @param CreateInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createInstance(CreateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateInstance', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Date Fusion instance. + * + * The async variant is {@see DataFusionClient::deleteInstanceAsync()} . + * + * @example samples/V1/DataFusionClient/delete_instance.php + * + * @param DeleteInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Data Fusion instance. + * + * The async variant is {@see DataFusionClient::getInstanceAsync()} . + * + * @example samples/V1/DataFusionClient/get_instance.php + * + * @param GetInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Instance + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance + { + return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); + } + + /** + * Lists possible versions for Data Fusion instances in the specified project + * and location. + * + * The async variant is {@see DataFusionClient::listAvailableVersionsAsync()} . + * + * @example samples/V1/DataFusionClient/list_available_versions.php + * + * @param ListAvailableVersionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAvailableVersions(ListAvailableVersionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAvailableVersions', $request, $callOptions); + } + + /** + * Lists Data Fusion instances in the specified project and location. + * + * The async variant is {@see DataFusionClient::listInstancesAsync()} . + * + * @example samples/V1/DataFusionClient/list_instances.php + * + * @param ListInstancesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInstances(ListInstancesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInstances', $request, $callOptions); + } + + /** + * Restart a single Data Fusion instance. + * At the end of an operation instance is fully restarted. + * + * The async variant is {@see DataFusionClient::restartInstanceAsync()} . + * + * @example samples/V1/DataFusionClient/restart_instance.php + * + * @param RestartInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function restartInstance(RestartInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RestartInstance', $request, $callOptions)->wait(); + } + + /** + * Updates a single Data Fusion instance. + * + * The async variant is {@see DataFusionClient::updateInstanceAsync()} . + * + * @example samples/V1/DataFusionClient/update_instance.php + * + * @param UpdateInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateInstance(UpdateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateInstance', $request, $callOptions)->wait(); + } } diff --git a/DataLabeling/composer.json b/DataLabeling/composer.json index d5375a31f9bc..bd9cb5c14726 100644 --- a/DataLabeling/composer.json +++ b/DataLabeling/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/DataLabeling/src/V1beta1/Client/BaseClient/DataLabelingServiceBaseClient.php b/DataLabeling/src/V1beta1/Client/BaseClient/DataLabelingServiceBaseClient.php deleted file mode 100644 index ea489aa2ef31..000000000000 --- a/DataLabeling/src/V1beta1/Client/BaseClient/DataLabelingServiceBaseClient.php +++ /dev/null @@ -1,1457 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/data_labeling_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/data_labeling_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/data_labeling_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/data_labeling_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - * - * @experimental - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - * - * @experimental - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * annotated_dataset resource. - * - * @param string $project - * @param string $dataset - * @param string $annotatedDataset - * - * @return string The formatted annotated_dataset resource. - * - * @experimental - */ - public static function annotatedDatasetName(string $project, string $dataset, string $annotatedDataset): string - { - return self::getPathTemplate('annotatedDataset')->render([ - 'project' => $project, - 'dataset' => $dataset, - 'annotated_dataset' => $annotatedDataset, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * annotation_spec_set resource. - * - * @param string $project - * @param string $annotationSpecSet - * - * @return string The formatted annotation_spec_set resource. - * - * @experimental - */ - public static function annotationSpecSetName(string $project, string $annotationSpecSet): string - { - return self::getPathTemplate('annotationSpecSet')->render([ - 'project' => $project, - 'annotation_spec_set' => $annotationSpecSet, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a data_item - * resource. - * - * @param string $project - * @param string $dataset - * @param string $dataItem - * - * @return string The formatted data_item resource. - * - * @experimental - */ - public static function dataItemName(string $project, string $dataset, string $dataItem): string - { - return self::getPathTemplate('dataItem')->render([ - 'project' => $project, - 'dataset' => $dataset, - 'data_item' => $dataItem, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a dataset - * resource. - * - * @param string $project - * @param string $dataset - * - * @return string The formatted dataset resource. - * - * @experimental - */ - public static function datasetName(string $project, string $dataset): string - { - return self::getPathTemplate('dataset')->render([ - 'project' => $project, - 'dataset' => $dataset, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a evaluation - * resource. - * - * @param string $project - * @param string $dataset - * @param string $evaluation - * - * @return string The formatted evaluation resource. - * - * @experimental - */ - public static function evaluationName(string $project, string $dataset, string $evaluation): string - { - return self::getPathTemplate('evaluation')->render([ - 'project' => $project, - 'dataset' => $dataset, - 'evaluation' => $evaluation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * evaluation_job resource. - * - * @param string $project - * @param string $evaluationJob - * - * @return string The formatted evaluation_job resource. - * - * @experimental - */ - public static function evaluationJobName(string $project, string $evaluationJob): string - { - return self::getPathTemplate('evaluationJob')->render([ - 'project' => $project, - 'evaluation_job' => $evaluationJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a example - * resource. - * - * @param string $project - * @param string $dataset - * @param string $annotatedDataset - * @param string $example - * - * @return string The formatted example resource. - * - * @experimental - */ - public static function exampleName(string $project, string $dataset, string $annotatedDataset, string $example): string - { - return self::getPathTemplate('example')->render([ - 'project' => $project, - 'dataset' => $dataset, - 'annotated_dataset' => $annotatedDataset, - 'example' => $example, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a instruction - * resource. - * - * @param string $project - * @param string $instruction - * - * @return string The formatted instruction resource. - * - * @experimental - */ - public static function instructionName(string $project, string $instruction): string - { - return self::getPathTemplate('instruction')->render([ - 'project' => $project, - 'instruction' => $instruction, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->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 - * - annotatedDataset: projects/{project}/datasets/{dataset}/annotatedDatasets/{annotated_dataset} - * - annotationSpecSet: projects/{project}/annotationSpecSets/{annotation_spec_set} - * - dataItem: projects/{project}/datasets/{dataset}/dataItems/{data_item} - * - dataset: projects/{project}/datasets/{dataset} - * - evaluation: projects/{project}/datasets/{dataset}/evaluations/{evaluation} - * - evaluationJob: projects/{project}/evaluationJobs/{evaluation_job} - * - example: projects/{project}/datasets/{dataset}/annotatedDatasets/{annotated_dataset}/examples/{example} - * - instruction: projects/{project}/instructions/{instruction} - * - 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'datalabeling.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); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates an annotation spec set by providing a set of labels. - * - * The async variant is {@see self::createAnnotationSpecSetAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/create_annotation_spec_set.php - * - * @param CreateAnnotationSpecSetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AnnotationSpecSet - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createAnnotationSpecSet(CreateAnnotationSpecSetRequest $request, array $callOptions = []): AnnotationSpecSet - { - return $this->startApiCall('CreateAnnotationSpecSet', $request, $callOptions)->wait(); - } - - /** - * Creates dataset. If success return a Dataset resource. - * - * The async variant is {@see self::createDatasetAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/create_dataset.php - * - * @param CreateDatasetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Dataset - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createDataset(CreateDatasetRequest $request, array $callOptions = []): Dataset - { - return $this->startApiCall('CreateDataset', $request, $callOptions)->wait(); - } - - /** - * Creates an evaluation job. - * - * The async variant is {@see self::createEvaluationJobAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/create_evaluation_job.php - * - * @param CreateEvaluationJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 EvaluationJob - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createEvaluationJob(CreateEvaluationJobRequest $request, array $callOptions = []): EvaluationJob - { - return $this->startApiCall('CreateEvaluationJob', $request, $callOptions)->wait(); - } - - /** - * Creates an instruction for how data should be labeled. - * - * The async variant is {@see self::createInstructionAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/create_instruction.php - * - * @param CreateInstructionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createInstruction(CreateInstructionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateInstruction', $request, $callOptions)->wait(); - } - - /** - * Deletes an annotated dataset by resource name. - * - * The async variant is {@see self::deleteAnnotatedDatasetAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/delete_annotated_dataset.php - * - * @param DeleteAnnotatedDatasetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteAnnotatedDataset(DeleteAnnotatedDatasetRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteAnnotatedDataset', $request, $callOptions)->wait(); - } - - /** - * Deletes an annotation spec set by resource name. - * - * The async variant is {@see self::deleteAnnotationSpecSetAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/delete_annotation_spec_set.php - * - * @param DeleteAnnotationSpecSetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteAnnotationSpecSet(DeleteAnnotationSpecSetRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteAnnotationSpecSet', $request, $callOptions)->wait(); - } - - /** - * Deletes a dataset by resource name. - * - * The async variant is {@see self::deleteDatasetAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/delete_dataset.php - * - * @param DeleteDatasetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteDataset(DeleteDatasetRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteDataset', $request, $callOptions)->wait(); - } - - /** - * Stops and deletes an evaluation job. - * - * The async variant is {@see self::deleteEvaluationJobAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/delete_evaluation_job.php - * - * @param DeleteEvaluationJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteEvaluationJob(DeleteEvaluationJobRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteEvaluationJob', $request, $callOptions)->wait(); - } - - /** - * Deletes an instruction object by resource name. - * - * The async variant is {@see self::deleteInstructionAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/delete_instruction.php - * - * @param DeleteInstructionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteInstruction(DeleteInstructionRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteInstruction', $request, $callOptions)->wait(); - } - - /** - * Exports data and annotations from dataset. - * - * The async variant is {@see self::exportDataAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/export_data.php - * - * @param ExportDataRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function exportData(ExportDataRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ExportData', $request, $callOptions)->wait(); - } - - /** - * Gets an annotated dataset by resource name. - * - * The async variant is {@see self::getAnnotatedDatasetAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/get_annotated_dataset.php - * - * @param GetAnnotatedDatasetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AnnotatedDataset - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getAnnotatedDataset(GetAnnotatedDatasetRequest $request, array $callOptions = []): AnnotatedDataset - { - return $this->startApiCall('GetAnnotatedDataset', $request, $callOptions)->wait(); - } - - /** - * Gets an annotation spec set by resource name. - * - * The async variant is {@see self::getAnnotationSpecSetAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/get_annotation_spec_set.php - * - * @param GetAnnotationSpecSetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AnnotationSpecSet - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getAnnotationSpecSet(GetAnnotationSpecSetRequest $request, array $callOptions = []): AnnotationSpecSet - { - return $this->startApiCall('GetAnnotationSpecSet', $request, $callOptions)->wait(); - } - - /** - * Gets a data item in a dataset by resource name. This API can be - * called after data are imported into dataset. - * - * The async variant is {@see self::getDataItemAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/get_data_item.php - * - * @param GetDataItemRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataItem - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getDataItem(GetDataItemRequest $request, array $callOptions = []): DataItem - { - return $this->startApiCall('GetDataItem', $request, $callOptions)->wait(); - } - - /** - * Gets dataset by resource name. - * - * The async variant is {@see self::getDatasetAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/get_dataset.php - * - * @param GetDatasetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Dataset - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getDataset(GetDatasetRequest $request, array $callOptions = []): Dataset - { - return $this->startApiCall('GetDataset', $request, $callOptions)->wait(); - } - - /** - * Gets an evaluation by resource name (to search, use - * [projects.evaluations.search][google.cloud.datalabeling.v1beta1.DataLabelingService.SearchEvaluations]). - * - * The async variant is {@see self::getEvaluationAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/get_evaluation.php - * - * @param GetEvaluationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Evaluation - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getEvaluation(GetEvaluationRequest $request, array $callOptions = []): Evaluation - { - return $this->startApiCall('GetEvaluation', $request, $callOptions)->wait(); - } - - /** - * Gets an evaluation job by resource name. - * - * The async variant is {@see self::getEvaluationJobAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/get_evaluation_job.php - * - * @param GetEvaluationJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 EvaluationJob - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getEvaluationJob(GetEvaluationJobRequest $request, array $callOptions = []): EvaluationJob - { - return $this->startApiCall('GetEvaluationJob', $request, $callOptions)->wait(); - } - - /** - * Gets an example by resource name, including both data and annotation. - * - * The async variant is {@see self::getExampleAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/get_example.php - * - * @param GetExampleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Example - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getExample(GetExampleRequest $request, array $callOptions = []): Example - { - return $this->startApiCall('GetExample', $request, $callOptions)->wait(); - } - - /** - * Gets an instruction by resource name. - * - * The async variant is {@see self::getInstructionAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/get_instruction.php - * - * @param GetInstructionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Instruction - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getInstruction(GetInstructionRequest $request, array $callOptions = []): Instruction - { - return $this->startApiCall('GetInstruction', $request, $callOptions)->wait(); - } - - /** - * Imports data into dataset based on source locations defined in request. - * It can be called multiple times for the same dataset. Each dataset can - * only have one long running operation running on it. For example, no - * labeling task (also long running operation) can be started while - * importing is still ongoing. Vice versa. - * - * The async variant is {@see self::importDataAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/import_data.php - * - * @param ImportDataRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function importData(ImportDataRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ImportData', $request, $callOptions)->wait(); - } - - /** - * Starts a labeling task for image. The type of image labeling task is - * configured by feature in the request. - * - * The async variant is {@see self::labelImageAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/label_image.php - * - * @param LabelImageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function labelImage(LabelImageRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('LabelImage', $request, $callOptions)->wait(); - } - - /** - * Starts a labeling task for text. The type of text labeling task is - * configured by feature in the request. - * - * The async variant is {@see self::labelTextAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/label_text.php - * - * @param LabelTextRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function labelText(LabelTextRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('LabelText', $request, $callOptions)->wait(); - } - - /** - * Starts a labeling task for video. The type of video labeling task is - * configured by feature in the request. - * - * The async variant is {@see self::labelVideoAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/label_video.php - * - * @param LabelVideoRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function labelVideo(LabelVideoRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('LabelVideo', $request, $callOptions)->wait(); - } - - /** - * Lists annotated datasets for a dataset. Pagination is supported. - * - * The async variant is {@see self::listAnnotatedDatasetsAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/list_annotated_datasets.php - * - * @param ListAnnotatedDatasetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listAnnotatedDatasets(ListAnnotatedDatasetsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAnnotatedDatasets', $request, $callOptions); - } - - /** - * Lists annotation spec sets for a project. Pagination is supported. - * - * The async variant is {@see self::listAnnotationSpecSetsAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/list_annotation_spec_sets.php - * - * @param ListAnnotationSpecSetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listAnnotationSpecSets(ListAnnotationSpecSetsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAnnotationSpecSets', $request, $callOptions); - } - - /** - * Lists data items in a dataset. This API can be called after data - * are imported into dataset. Pagination is supported. - * - * The async variant is {@see self::listDataItemsAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/list_data_items.php - * - * @param ListDataItemsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listDataItems(ListDataItemsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDataItems', $request, $callOptions); - } - - /** - * Lists datasets under a project. Pagination is supported. - * - * The async variant is {@see self::listDatasetsAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/list_datasets.php - * - * @param ListDatasetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listDatasets(ListDatasetsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDatasets', $request, $callOptions); - } - - /** - * Lists all evaluation jobs within a project with possible filters. - * Pagination is supported. - * - * The async variant is {@see self::listEvaluationJobsAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/list_evaluation_jobs.php - * - * @param ListEvaluationJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listEvaluationJobs(ListEvaluationJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListEvaluationJobs', $request, $callOptions); - } - - /** - * Lists examples in an annotated dataset. Pagination is supported. - * - * The async variant is {@see self::listExamplesAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/list_examples.php - * - * @param ListExamplesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listExamples(ListExamplesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListExamples', $request, $callOptions); - } - - /** - * Lists instructions for a project. Pagination is supported. - * - * The async variant is {@see self::listInstructionsAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/list_instructions.php - * - * @param ListInstructionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listInstructions(ListInstructionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListInstructions', $request, $callOptions); - } - - /** - * Pauses an evaluation job. Pausing an evaluation job that is already in a - * `PAUSED` state is a no-op. - * - * The async variant is {@see self::pauseEvaluationJobAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/pause_evaluation_job.php - * - * @param PauseEvaluationJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function pauseEvaluationJob(PauseEvaluationJobRequest $request, array $callOptions = []): void - { - $this->startApiCall('PauseEvaluationJob', $request, $callOptions)->wait(); - } - - /** - * Resumes a paused evaluation job. A deleted evaluation job can't be resumed. - * Resuming a running or scheduled evaluation job is a no-op. - * - * The async variant is {@see self::resumeEvaluationJobAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/resume_evaluation_job.php - * - * @param ResumeEvaluationJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function resumeEvaluationJob(ResumeEvaluationJobRequest $request, array $callOptions = []): void - { - $this->startApiCall('ResumeEvaluationJob', $request, $callOptions)->wait(); - } - - /** - * Searches [evaluations][google.cloud.datalabeling.v1beta1.Evaluation] within a project. - * - * The async variant is {@see self::searchEvaluationsAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/search_evaluations.php - * - * @param SearchEvaluationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function searchEvaluations(SearchEvaluationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchEvaluations', $request, $callOptions); - } - - /** - * Searches example comparisons from an evaluation. The return format is a - * list of example comparisons that show ground truth and prediction(s) for - * a single input. Search by providing an evaluation ID. - * - * The async variant is {@see self::searchExampleComparisonsAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/search_example_comparisons.php - * - * @param SearchExampleComparisonsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function searchExampleComparisons(SearchExampleComparisonsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchExampleComparisons', $request, $callOptions); - } - - /** - * Updates an evaluation job. You can only update certain fields of the job's - * [EvaluationJobConfig][google.cloud.datalabeling.v1beta1.EvaluationJobConfig]: `humanAnnotationConfig.instruction`, - * `exampleCount`, and `exampleSamplePercentage`. - * - * If you want to change any other aspect of the evaluation job, you must - * delete the job and create a new one. - * - * The async variant is {@see self::updateEvaluationJobAsync()} . - * - * @example samples/V1beta1/DataLabelingServiceClient/update_evaluation_job.php - * - * @param UpdateEvaluationJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 EvaluationJob - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function updateEvaluationJob(UpdateEvaluationJobRequest $request, array $callOptions = []): EvaluationJob - { - return $this->startApiCall('UpdateEvaluationJob', $request, $callOptions)->wait(); - } -} diff --git a/DataLabeling/src/V1beta1/Client/DataLabelingServiceClient.php b/DataLabeling/src/V1beta1/Client/DataLabelingServiceClient.php index bf1534d105d7..fa7a22ec7427 100644 --- a/DataLabeling/src/V1beta1/Client/DataLabelingServiceClient.php +++ b/DataLabeling/src/V1beta1/Client/DataLabelingServiceClient.php @@ -26,17 +26,1447 @@ namespace Google\Cloud\DataLabeling\V1beta1\Client; -use Google\Cloud\DataLabeling\V1beta1\Client\BaseClient\DataLabelingServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\DataLabeling\V1beta1\AnnotatedDataset; +use Google\Cloud\DataLabeling\V1beta1\AnnotationSpecSet; +use Google\Cloud\DataLabeling\V1beta1\CreateAnnotationSpecSetRequest; +use Google\Cloud\DataLabeling\V1beta1\CreateDatasetRequest; +use Google\Cloud\DataLabeling\V1beta1\CreateEvaluationJobRequest; +use Google\Cloud\DataLabeling\V1beta1\CreateInstructionRequest; +use Google\Cloud\DataLabeling\V1beta1\DataItem; +use Google\Cloud\DataLabeling\V1beta1\Dataset; +use Google\Cloud\DataLabeling\V1beta1\DeleteAnnotatedDatasetRequest; +use Google\Cloud\DataLabeling\V1beta1\DeleteAnnotationSpecSetRequest; +use Google\Cloud\DataLabeling\V1beta1\DeleteDatasetRequest; +use Google\Cloud\DataLabeling\V1beta1\DeleteEvaluationJobRequest; +use Google\Cloud\DataLabeling\V1beta1\DeleteInstructionRequest; +use Google\Cloud\DataLabeling\V1beta1\Evaluation; +use Google\Cloud\DataLabeling\V1beta1\EvaluationJob; +use Google\Cloud\DataLabeling\V1beta1\Example; +use Google\Cloud\DataLabeling\V1beta1\ExportDataRequest; +use Google\Cloud\DataLabeling\V1beta1\GetAnnotatedDatasetRequest; +use Google\Cloud\DataLabeling\V1beta1\GetAnnotationSpecSetRequest; +use Google\Cloud\DataLabeling\V1beta1\GetDataItemRequest; +use Google\Cloud\DataLabeling\V1beta1\GetDatasetRequest; +use Google\Cloud\DataLabeling\V1beta1\GetEvaluationJobRequest; +use Google\Cloud\DataLabeling\V1beta1\GetEvaluationRequest; +use Google\Cloud\DataLabeling\V1beta1\GetExampleRequest; +use Google\Cloud\DataLabeling\V1beta1\GetInstructionRequest; +use Google\Cloud\DataLabeling\V1beta1\ImportDataRequest; +use Google\Cloud\DataLabeling\V1beta1\Instruction; +use Google\Cloud\DataLabeling\V1beta1\LabelImageRequest; +use Google\Cloud\DataLabeling\V1beta1\LabelTextRequest; +use Google\Cloud\DataLabeling\V1beta1\LabelVideoRequest; +use Google\Cloud\DataLabeling\V1beta1\ListAnnotatedDatasetsRequest; +use Google\Cloud\DataLabeling\V1beta1\ListAnnotationSpecSetsRequest; +use Google\Cloud\DataLabeling\V1beta1\ListDataItemsRequest; +use Google\Cloud\DataLabeling\V1beta1\ListDatasetsRequest; +use Google\Cloud\DataLabeling\V1beta1\ListEvaluationJobsRequest; +use Google\Cloud\DataLabeling\V1beta1\ListExamplesRequest; +use Google\Cloud\DataLabeling\V1beta1\ListInstructionsRequest; +use Google\Cloud\DataLabeling\V1beta1\PauseEvaluationJobRequest; +use Google\Cloud\DataLabeling\V1beta1\ResumeEvaluationJobRequest; +use Google\Cloud\DataLabeling\V1beta1\SearchEvaluationsRequest; +use Google\Cloud\DataLabeling\V1beta1\SearchExampleComparisonsRequest; +use Google\Cloud\DataLabeling\V1beta1\UpdateEvaluationJobRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for the AI Platform Data Labeling API. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createAnnotationSpecSetAsync(CreateAnnotationSpecSetRequest $request, array $optionalArgs = []) + * @method PromiseInterface createDatasetAsync(CreateDatasetRequest $request, array $optionalArgs = []) + * @method PromiseInterface createEvaluationJobAsync(CreateEvaluationJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface createInstructionAsync(CreateInstructionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAnnotatedDatasetAsync(DeleteAnnotatedDatasetRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAnnotationSpecSetAsync(DeleteAnnotationSpecSetRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDatasetAsync(DeleteDatasetRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteEvaluationJobAsync(DeleteEvaluationJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteInstructionAsync(DeleteInstructionRequest $request, array $optionalArgs = []) + * @method PromiseInterface exportDataAsync(ExportDataRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAnnotatedDatasetAsync(GetAnnotatedDatasetRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAnnotationSpecSetAsync(GetAnnotationSpecSetRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDataItemAsync(GetDataItemRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDatasetAsync(GetDatasetRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEvaluationAsync(GetEvaluationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEvaluationJobAsync(GetEvaluationJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getExampleAsync(GetExampleRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInstructionAsync(GetInstructionRequest $request, array $optionalArgs = []) + * @method PromiseInterface importDataAsync(ImportDataRequest $request, array $optionalArgs = []) + * @method PromiseInterface labelImageAsync(LabelImageRequest $request, array $optionalArgs = []) + * @method PromiseInterface labelTextAsync(LabelTextRequest $request, array $optionalArgs = []) + * @method PromiseInterface labelVideoAsync(LabelVideoRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAnnotatedDatasetsAsync(ListAnnotatedDatasetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAnnotationSpecSetsAsync(ListAnnotationSpecSetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDataItemsAsync(ListDataItemsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDatasetsAsync(ListDatasetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listEvaluationJobsAsync(ListEvaluationJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listExamplesAsync(ListExamplesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInstructionsAsync(ListInstructionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface pauseEvaluationJobAsync(PauseEvaluationJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface resumeEvaluationJobAsync(ResumeEvaluationJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchEvaluationsAsync(SearchEvaluationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchExampleComparisonsAsync(SearchExampleComparisonsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateEvaluationJobAsync(UpdateEvaluationJobRequest $request, array $optionalArgs = []) */ -final class DataLabelingServiceClient extends DataLabelingServiceBaseClient +final class DataLabelingServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DataLabelingServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.datalabeling.v1beta1.DataLabelingService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'datalabeling.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/data_labeling_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/data_labeling_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/data_labeling_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/data_labeling_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + * + * @experimental + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + * + * @experimental + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * annotated_dataset resource. + * + * @param string $project + * @param string $dataset + * @param string $annotatedDataset + * + * @return string The formatted annotated_dataset resource. + * + * @experimental + */ + public static function annotatedDatasetName(string $project, string $dataset, string $annotatedDataset): string + { + return self::getPathTemplate('annotatedDataset')->render([ + 'project' => $project, + 'dataset' => $dataset, + 'annotated_dataset' => $annotatedDataset, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * annotation_spec_set resource. + * + * @param string $project + * @param string $annotationSpecSet + * + * @return string The formatted annotation_spec_set resource. + * + * @experimental + */ + public static function annotationSpecSetName(string $project, string $annotationSpecSet): string + { + return self::getPathTemplate('annotationSpecSet')->render([ + 'project' => $project, + 'annotation_spec_set' => $annotationSpecSet, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a data_item + * resource. + * + * @param string $project + * @param string $dataset + * @param string $dataItem + * + * @return string The formatted data_item resource. + * + * @experimental + */ + public static function dataItemName(string $project, string $dataset, string $dataItem): string + { + return self::getPathTemplate('dataItem')->render([ + 'project' => $project, + 'dataset' => $dataset, + 'data_item' => $dataItem, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a dataset + * resource. + * + * @param string $project + * @param string $dataset + * + * @return string The formatted dataset resource. + * + * @experimental + */ + public static function datasetName(string $project, string $dataset): string + { + return self::getPathTemplate('dataset')->render([ + 'project' => $project, + 'dataset' => $dataset, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a evaluation + * resource. + * + * @param string $project + * @param string $dataset + * @param string $evaluation + * + * @return string The formatted evaluation resource. + * + * @experimental + */ + public static function evaluationName(string $project, string $dataset, string $evaluation): string + { + return self::getPathTemplate('evaluation')->render([ + 'project' => $project, + 'dataset' => $dataset, + 'evaluation' => $evaluation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * evaluation_job resource. + * + * @param string $project + * @param string $evaluationJob + * + * @return string The formatted evaluation_job resource. + * + * @experimental + */ + public static function evaluationJobName(string $project, string $evaluationJob): string + { + return self::getPathTemplate('evaluationJob')->render([ + 'project' => $project, + 'evaluation_job' => $evaluationJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a example + * resource. + * + * @param string $project + * @param string $dataset + * @param string $annotatedDataset + * @param string $example + * + * @return string The formatted example resource. + * + * @experimental + */ + public static function exampleName(string $project, string $dataset, string $annotatedDataset, string $example): string + { + return self::getPathTemplate('example')->render([ + 'project' => $project, + 'dataset' => $dataset, + 'annotated_dataset' => $annotatedDataset, + 'example' => $example, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a instruction + * resource. + * + * @param string $project + * @param string $instruction + * + * @return string The formatted instruction resource. + * + * @experimental + */ + public static function instructionName(string $project, string $instruction): string + { + return self::getPathTemplate('instruction')->render([ + 'project' => $project, + 'instruction' => $instruction, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->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 + * - annotatedDataset: projects/{project}/datasets/{dataset}/annotatedDatasets/{annotated_dataset} + * - annotationSpecSet: projects/{project}/annotationSpecSets/{annotation_spec_set} + * - dataItem: projects/{project}/datasets/{dataset}/dataItems/{data_item} + * - dataset: projects/{project}/datasets/{dataset} + * - evaluation: projects/{project}/datasets/{dataset}/evaluations/{evaluation} + * - evaluationJob: projects/{project}/evaluationJobs/{evaluation_job} + * - example: projects/{project}/datasets/{dataset}/annotatedDatasets/{annotated_dataset}/examples/{example} + * - instruction: projects/{project}/instructions/{instruction} + * - 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'datalabeling.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); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates an annotation spec set by providing a set of labels. + * + * The async variant is + * {@see DataLabelingServiceClient::createAnnotationSpecSetAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/create_annotation_spec_set.php + * + * @param CreateAnnotationSpecSetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AnnotationSpecSet + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createAnnotationSpecSet(CreateAnnotationSpecSetRequest $request, array $callOptions = []): AnnotationSpecSet + { + return $this->startApiCall('CreateAnnotationSpecSet', $request, $callOptions)->wait(); + } + + /** + * Creates dataset. If success return a Dataset resource. + * + * The async variant is {@see DataLabelingServiceClient::createDatasetAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/create_dataset.php + * + * @param CreateDatasetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Dataset + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createDataset(CreateDatasetRequest $request, array $callOptions = []): Dataset + { + return $this->startApiCall('CreateDataset', $request, $callOptions)->wait(); + } + + /** + * Creates an evaluation job. + * + * The async variant is + * {@see DataLabelingServiceClient::createEvaluationJobAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/create_evaluation_job.php + * + * @param CreateEvaluationJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 EvaluationJob + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createEvaluationJob(CreateEvaluationJobRequest $request, array $callOptions = []): EvaluationJob + { + return $this->startApiCall('CreateEvaluationJob', $request, $callOptions)->wait(); + } + + /** + * Creates an instruction for how data should be labeled. + * + * The async variant is {@see DataLabelingServiceClient::createInstructionAsync()} + * . + * + * @example samples/V1beta1/DataLabelingServiceClient/create_instruction.php + * + * @param CreateInstructionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createInstruction(CreateInstructionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateInstruction', $request, $callOptions)->wait(); + } + + /** + * Deletes an annotated dataset by resource name. + * + * The async variant is + * {@see DataLabelingServiceClient::deleteAnnotatedDatasetAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/delete_annotated_dataset.php + * + * @param DeleteAnnotatedDatasetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteAnnotatedDataset(DeleteAnnotatedDatasetRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteAnnotatedDataset', $request, $callOptions)->wait(); + } + + /** + * Deletes an annotation spec set by resource name. + * + * The async variant is + * {@see DataLabelingServiceClient::deleteAnnotationSpecSetAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/delete_annotation_spec_set.php + * + * @param DeleteAnnotationSpecSetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteAnnotationSpecSet(DeleteAnnotationSpecSetRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteAnnotationSpecSet', $request, $callOptions)->wait(); + } + + /** + * Deletes a dataset by resource name. + * + * The async variant is {@see DataLabelingServiceClient::deleteDatasetAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/delete_dataset.php + * + * @param DeleteDatasetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteDataset(DeleteDatasetRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteDataset', $request, $callOptions)->wait(); + } + + /** + * Stops and deletes an evaluation job. + * + * The async variant is + * {@see DataLabelingServiceClient::deleteEvaluationJobAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/delete_evaluation_job.php + * + * @param DeleteEvaluationJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteEvaluationJob(DeleteEvaluationJobRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteEvaluationJob', $request, $callOptions)->wait(); + } + + /** + * Deletes an instruction object by resource name. + * + * The async variant is {@see DataLabelingServiceClient::deleteInstructionAsync()} + * . + * + * @example samples/V1beta1/DataLabelingServiceClient/delete_instruction.php + * + * @param DeleteInstructionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteInstruction(DeleteInstructionRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteInstruction', $request, $callOptions)->wait(); + } + + /** + * Exports data and annotations from dataset. + * + * The async variant is {@see DataLabelingServiceClient::exportDataAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/export_data.php + * + * @param ExportDataRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function exportData(ExportDataRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ExportData', $request, $callOptions)->wait(); + } + + /** + * Gets an annotated dataset by resource name. + * + * The async variant is + * {@see DataLabelingServiceClient::getAnnotatedDatasetAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/get_annotated_dataset.php + * + * @param GetAnnotatedDatasetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AnnotatedDataset + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getAnnotatedDataset(GetAnnotatedDatasetRequest $request, array $callOptions = []): AnnotatedDataset + { + return $this->startApiCall('GetAnnotatedDataset', $request, $callOptions)->wait(); + } + + /** + * Gets an annotation spec set by resource name. + * + * The async variant is + * {@see DataLabelingServiceClient::getAnnotationSpecSetAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/get_annotation_spec_set.php + * + * @param GetAnnotationSpecSetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AnnotationSpecSet + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getAnnotationSpecSet(GetAnnotationSpecSetRequest $request, array $callOptions = []): AnnotationSpecSet + { + return $this->startApiCall('GetAnnotationSpecSet', $request, $callOptions)->wait(); + } + + /** + * Gets a data item in a dataset by resource name. This API can be + * called after data are imported into dataset. + * + * The async variant is {@see DataLabelingServiceClient::getDataItemAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/get_data_item.php + * + * @param GetDataItemRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataItem + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getDataItem(GetDataItemRequest $request, array $callOptions = []): DataItem + { + return $this->startApiCall('GetDataItem', $request, $callOptions)->wait(); + } + + /** + * Gets dataset by resource name. + * + * The async variant is {@see DataLabelingServiceClient::getDatasetAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/get_dataset.php + * + * @param GetDatasetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Dataset + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getDataset(GetDatasetRequest $request, array $callOptions = []): Dataset + { + return $this->startApiCall('GetDataset', $request, $callOptions)->wait(); + } + + /** + * Gets an evaluation by resource name (to search, use + * [projects.evaluations.search][google.cloud.datalabeling.v1beta1.DataLabelingService.SearchEvaluations]). + * + * The async variant is {@see DataLabelingServiceClient::getEvaluationAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/get_evaluation.php + * + * @param GetEvaluationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Evaluation + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getEvaluation(GetEvaluationRequest $request, array $callOptions = []): Evaluation + { + return $this->startApiCall('GetEvaluation', $request, $callOptions)->wait(); + } + + /** + * Gets an evaluation job by resource name. + * + * The async variant is {@see DataLabelingServiceClient::getEvaluationJobAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/get_evaluation_job.php + * + * @param GetEvaluationJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 EvaluationJob + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getEvaluationJob(GetEvaluationJobRequest $request, array $callOptions = []): EvaluationJob + { + return $this->startApiCall('GetEvaluationJob', $request, $callOptions)->wait(); + } + + /** + * Gets an example by resource name, including both data and annotation. + * + * The async variant is {@see DataLabelingServiceClient::getExampleAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/get_example.php + * + * @param GetExampleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Example + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getExample(GetExampleRequest $request, array $callOptions = []): Example + { + return $this->startApiCall('GetExample', $request, $callOptions)->wait(); + } + + /** + * Gets an instruction by resource name. + * + * The async variant is {@see DataLabelingServiceClient::getInstructionAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/get_instruction.php + * + * @param GetInstructionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Instruction + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getInstruction(GetInstructionRequest $request, array $callOptions = []): Instruction + { + return $this->startApiCall('GetInstruction', $request, $callOptions)->wait(); + } + + /** + * Imports data into dataset based on source locations defined in request. + * It can be called multiple times for the same dataset. Each dataset can + * only have one long running operation running on it. For example, no + * labeling task (also long running operation) can be started while + * importing is still ongoing. Vice versa. + * + * The async variant is {@see DataLabelingServiceClient::importDataAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/import_data.php + * + * @param ImportDataRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function importData(ImportDataRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportData', $request, $callOptions)->wait(); + } + + /** + * Starts a labeling task for image. The type of image labeling task is + * configured by feature in the request. + * + * The async variant is {@see DataLabelingServiceClient::labelImageAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/label_image.php + * + * @param LabelImageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function labelImage(LabelImageRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('LabelImage', $request, $callOptions)->wait(); + } + + /** + * Starts a labeling task for text. The type of text labeling task is + * configured by feature in the request. + * + * The async variant is {@see DataLabelingServiceClient::labelTextAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/label_text.php + * + * @param LabelTextRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function labelText(LabelTextRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('LabelText', $request, $callOptions)->wait(); + } + + /** + * Starts a labeling task for video. The type of video labeling task is + * configured by feature in the request. + * + * The async variant is {@see DataLabelingServiceClient::labelVideoAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/label_video.php + * + * @param LabelVideoRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function labelVideo(LabelVideoRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('LabelVideo', $request, $callOptions)->wait(); + } + + /** + * Lists annotated datasets for a dataset. Pagination is supported. + * + * The async variant is + * {@see DataLabelingServiceClient::listAnnotatedDatasetsAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/list_annotated_datasets.php + * + * @param ListAnnotatedDatasetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listAnnotatedDatasets(ListAnnotatedDatasetsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAnnotatedDatasets', $request, $callOptions); + } + + /** + * Lists annotation spec sets for a project. Pagination is supported. + * + * The async variant is + * {@see DataLabelingServiceClient::listAnnotationSpecSetsAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/list_annotation_spec_sets.php + * + * @param ListAnnotationSpecSetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listAnnotationSpecSets(ListAnnotationSpecSetsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAnnotationSpecSets', $request, $callOptions); + } + + /** + * Lists data items in a dataset. This API can be called after data + * are imported into dataset. Pagination is supported. + * + * The async variant is {@see DataLabelingServiceClient::listDataItemsAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/list_data_items.php + * + * @param ListDataItemsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listDataItems(ListDataItemsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDataItems', $request, $callOptions); + } + + /** + * Lists datasets under a project. Pagination is supported. + * + * The async variant is {@see DataLabelingServiceClient::listDatasetsAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/list_datasets.php + * + * @param ListDatasetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listDatasets(ListDatasetsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDatasets', $request, $callOptions); + } + + /** + * Lists all evaluation jobs within a project with possible filters. + * Pagination is supported. + * + * The async variant is {@see DataLabelingServiceClient::listEvaluationJobsAsync()} + * . + * + * @example samples/V1beta1/DataLabelingServiceClient/list_evaluation_jobs.php + * + * @param ListEvaluationJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listEvaluationJobs(ListEvaluationJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEvaluationJobs', $request, $callOptions); + } + + /** + * Lists examples in an annotated dataset. Pagination is supported. + * + * The async variant is {@see DataLabelingServiceClient::listExamplesAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/list_examples.php + * + * @param ListExamplesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listExamples(ListExamplesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListExamples', $request, $callOptions); + } + + /** + * Lists instructions for a project. Pagination is supported. + * + * The async variant is {@see DataLabelingServiceClient::listInstructionsAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/list_instructions.php + * + * @param ListInstructionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listInstructions(ListInstructionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInstructions', $request, $callOptions); + } + + /** + * Pauses an evaluation job. Pausing an evaluation job that is already in a + * `PAUSED` state is a no-op. + * + * The async variant is {@see DataLabelingServiceClient::pauseEvaluationJobAsync()} + * . + * + * @example samples/V1beta1/DataLabelingServiceClient/pause_evaluation_job.php + * + * @param PauseEvaluationJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function pauseEvaluationJob(PauseEvaluationJobRequest $request, array $callOptions = []): void + { + $this->startApiCall('PauseEvaluationJob', $request, $callOptions)->wait(); + } + + /** + * Resumes a paused evaluation job. A deleted evaluation job can't be resumed. + * Resuming a running or scheduled evaluation job is a no-op. + * + * The async variant is + * {@see DataLabelingServiceClient::resumeEvaluationJobAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/resume_evaluation_job.php + * + * @param ResumeEvaluationJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function resumeEvaluationJob(ResumeEvaluationJobRequest $request, array $callOptions = []): void + { + $this->startApiCall('ResumeEvaluationJob', $request, $callOptions)->wait(); + } + + /** + * Searches [evaluations][google.cloud.datalabeling.v1beta1.Evaluation] within a project. + * + * The async variant is {@see DataLabelingServiceClient::searchEvaluationsAsync()} + * . + * + * @example samples/V1beta1/DataLabelingServiceClient/search_evaluations.php + * + * @param SearchEvaluationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function searchEvaluations(SearchEvaluationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchEvaluations', $request, $callOptions); + } + + /** + * Searches example comparisons from an evaluation. The return format is a + * list of example comparisons that show ground truth and prediction(s) for + * a single input. Search by providing an evaluation ID. + * + * The async variant is + * {@see DataLabelingServiceClient::searchExampleComparisonsAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/search_example_comparisons.php + * + * @param SearchExampleComparisonsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function searchExampleComparisons(SearchExampleComparisonsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchExampleComparisons', $request, $callOptions); + } + + /** + * Updates an evaluation job. You can only update certain fields of the job's + * [EvaluationJobConfig][google.cloud.datalabeling.v1beta1.EvaluationJobConfig]: `humanAnnotationConfig.instruction`, + * `exampleCount`, and `exampleSamplePercentage`. + * + * If you want to change any other aspect of the evaluation job, you must + * delete the job and create a new one. + * + * The async variant is + * {@see DataLabelingServiceClient::updateEvaluationJobAsync()} . + * + * @example samples/V1beta1/DataLabelingServiceClient/update_evaluation_job.php + * + * @param UpdateEvaluationJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 EvaluationJob + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function updateEvaluationJob(UpdateEvaluationJobRequest $request, array $callOptions = []): EvaluationJob + { + return $this->startApiCall('UpdateEvaluationJob', $request, $callOptions)->wait(); + } } diff --git a/Dataflow/composer.json b/Dataflow/composer.json index 78dc07234221..c2449d8ee3ec 100644 --- a/Dataflow/composer.json +++ b/Dataflow/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Dataflow/src/V1beta3/Client/BaseClient/FlexTemplatesServiceBaseClient.php b/Dataflow/src/V1beta3/Client/BaseClient/FlexTemplatesServiceBaseClient.php deleted file mode 100644 index 2bbaec3e0b0a..000000000000 --- a/Dataflow/src/V1beta3/Client/BaseClient/FlexTemplatesServiceBaseClient.php +++ /dev/null @@ -1,197 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/flex_templates_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/flex_templates_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/flex_templates_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/flex_templates_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'dataflow.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); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Launch a job with a FlexTemplate. - * - * The async variant is {@see self::launchFlexTemplateAsync()} . - * - * @example samples/V1beta3/FlexTemplatesServiceClient/launch_flex_template.php - * - * @param LaunchFlexTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LaunchFlexTemplateResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function launchFlexTemplate(LaunchFlexTemplateRequest $request, array $callOptions = []): LaunchFlexTemplateResponse - { - return $this->startApiCall('LaunchFlexTemplate', $request, $callOptions)->wait(); - } -} diff --git a/Dataflow/src/V1beta3/Client/BaseClient/JobsV1Beta3BaseClient.php b/Dataflow/src/V1beta3/Client/BaseClient/JobsV1Beta3BaseClient.php deleted file mode 100644 index 30dc0d7a05d2..000000000000 --- a/Dataflow/src/V1beta3/Client/BaseClient/JobsV1Beta3BaseClient.php +++ /dev/null @@ -1,405 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/jobs_v1_beta3_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/jobs_v1_beta3_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/jobs_v1_beta3_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/jobs_v1_beta3_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'dataflow.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); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * List the jobs of a project across all regions. - * - * The async variant is {@see self::aggregatedListJobsAsync()} . - * - * @example samples/V1beta3/JobsV1Beta3Client/aggregated_list_jobs.php - * - * @param ListJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function aggregatedListJobs(ListJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('AggregatedListJobs', $request, $callOptions); - } - - /** - * Check for existence of active jobs in the given project across all regions. - * - * The async variant is {@see self::checkActiveJobsAsync()} . - * - * @example samples/V1beta3/JobsV1Beta3Client/check_active_jobs.php - * - * @param CheckActiveJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CheckActiveJobsResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function checkActiveJobs(CheckActiveJobsRequest $request, array $callOptions = []): CheckActiveJobsResponse - { - return $this->startApiCall('CheckActiveJobs', $request, $callOptions)->wait(); - } - - /** - * Creates a Cloud Dataflow job. - * - * To create a job, we recommend using `projects.locations.jobs.create` with a - * [regional endpoint] - * (https://cloud.google.com/dataflow/docs/concepts/regional-endpoints). Using - * `projects.jobs.create` is not recommended, as your job will always start - * in `us-central1`. - * - * The async variant is {@see self::createJobAsync()} . - * - * @example samples/V1beta3/JobsV1Beta3Client/create_job.php - * - * @param CreateJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createJob(CreateJobRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('CreateJob', $request, $callOptions)->wait(); - } - - /** - * Gets the state of the specified Cloud Dataflow job. - * - * To get the state of a job, we recommend using `projects.locations.jobs.get` - * with a [regional endpoint] - * (https://cloud.google.com/dataflow/docs/concepts/regional-endpoints). Using - * `projects.jobs.get` is not recommended, as you can only get the state of - * jobs that are running in `us-central1`. - * - * The async variant is {@see self::getJobAsync()} . - * - * @example samples/V1beta3/JobsV1Beta3Client/get_job.php - * - * @param GetJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getJob(GetJobRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('GetJob', $request, $callOptions)->wait(); - } - - /** - * List the jobs of a project. - * - * To list the jobs of a project in a region, we recommend using - * `projects.locations.jobs.list` with a [regional endpoint] - * (https://cloud.google.com/dataflow/docs/concepts/regional-endpoints). To - * list the all jobs across all regions, use `projects.jobs.aggregated`. Using - * `projects.jobs.list` is not recommended, as you can only get the list of - * jobs that are running in `us-central1`. - * - * The async variant is {@see self::listJobsAsync()} . - * - * @example samples/V1beta3/JobsV1Beta3Client/list_jobs.php - * - * @param ListJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listJobs(ListJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListJobs', $request, $callOptions); - } - - /** - * Snapshot the state of a streaming job. - * - * The async variant is {@see self::snapshotJobAsync()} . - * - * @example samples/V1beta3/JobsV1Beta3Client/snapshot_job.php - * - * @param SnapshotJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Snapshot - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function snapshotJob(SnapshotJobRequest $request, array $callOptions = []): Snapshot - { - return $this->startApiCall('SnapshotJob', $request, $callOptions)->wait(); - } - - /** - * Updates the state of an existing Cloud Dataflow job. - * - * To update the state of an existing job, we recommend using - * `projects.locations.jobs.update` with a [regional endpoint] - * (https://cloud.google.com/dataflow/docs/concepts/regional-endpoints). Using - * `projects.jobs.update` is not recommended, as you can only update the state - * of jobs that are running in `us-central1`. - * - * The async variant is {@see self::updateJobAsync()} . - * - * @example samples/V1beta3/JobsV1Beta3Client/update_job.php - * - * @param UpdateJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function updateJob(UpdateJobRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('UpdateJob', $request, $callOptions)->wait(); - } -} diff --git a/Dataflow/src/V1beta3/Client/BaseClient/MessagesV1Beta3BaseClient.php b/Dataflow/src/V1beta3/Client/BaseClient/MessagesV1Beta3BaseClient.php deleted file mode 100644 index 0c5ea213f4f1..000000000000 --- a/Dataflow/src/V1beta3/Client/BaseClient/MessagesV1Beta3BaseClient.php +++ /dev/null @@ -1,204 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/messages_v1_beta3_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/messages_v1_beta3_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/messages_v1_beta3_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/messages_v1_beta3_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'dataflow.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); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Request the job status. - * - * To request the status of a job, we recommend using - * `projects.locations.jobs.messages.list` with a [regional endpoint] - * (https://cloud.google.com/dataflow/docs/concepts/regional-endpoints). Using - * `projects.jobs.messages.list` is not recommended, as you can only request - * the status of jobs that are running in `us-central1`. - * - * The async variant is {@see self::listJobMessagesAsync()} . - * - * @example samples/V1beta3/MessagesV1Beta3Client/list_job_messages.php - * - * @param ListJobMessagesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listJobMessages(ListJobMessagesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListJobMessages', $request, $callOptions); - } -} diff --git a/Dataflow/src/V1beta3/Client/BaseClient/MetricsV1Beta3BaseClient.php b/Dataflow/src/V1beta3/Client/BaseClient/MetricsV1Beta3BaseClient.php deleted file mode 100644 index 23642ca0ed88..000000000000 --- a/Dataflow/src/V1beta3/Client/BaseClient/MetricsV1Beta3BaseClient.php +++ /dev/null @@ -1,270 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/metrics_v1_beta3_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/metrics_v1_beta3_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/metrics_v1_beta3_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/metrics_v1_beta3_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'dataflow.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); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Request detailed information about the execution status of the job. - * - * EXPERIMENTAL. This API is subject to change or removal without notice. - * - * The async variant is {@see self::getJobExecutionDetailsAsync()} . - * - * @example samples/V1beta3/MetricsV1Beta3Client/get_job_execution_details.php - * - * @param GetJobExecutionDetailsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getJobExecutionDetails(GetJobExecutionDetailsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('GetJobExecutionDetails', $request, $callOptions); - } - - /** - * Request the job status. - * - * To request the status of a job, we recommend using - * `projects.locations.jobs.getMetrics` with a [regional endpoint] - * (https://cloud.google.com/dataflow/docs/concepts/regional-endpoints). Using - * `projects.jobs.getMetrics` is not recommended, as you can only request the - * status of jobs that are running in `us-central1`. - * - * The async variant is {@see self::getJobMetricsAsync()} . - * - * @example samples/V1beta3/MetricsV1Beta3Client/get_job_metrics.php - * - * @param GetJobMetricsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 JobMetrics - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getJobMetrics(GetJobMetricsRequest $request, array $callOptions = []): JobMetrics - { - return $this->startApiCall('GetJobMetrics', $request, $callOptions)->wait(); - } - - /** - * Request detailed information about the execution status of a stage of the - * job. - * - * EXPERIMENTAL. This API is subject to change or removal without notice. - * - * The async variant is {@see self::getStageExecutionDetailsAsync()} . - * - * @example samples/V1beta3/MetricsV1Beta3Client/get_stage_execution_details.php - * - * @param GetStageExecutionDetailsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getStageExecutionDetails(GetStageExecutionDetailsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('GetStageExecutionDetails', $request, $callOptions); - } -} diff --git a/Dataflow/src/V1beta3/Client/BaseClient/SnapshotsV1Beta3BaseClient.php b/Dataflow/src/V1beta3/Client/BaseClient/SnapshotsV1Beta3BaseClient.php deleted file mode 100644 index bdee1e778489..000000000000 --- a/Dataflow/src/V1beta3/Client/BaseClient/SnapshotsV1Beta3BaseClient.php +++ /dev/null @@ -1,259 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/snapshots_v1_beta3_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/snapshots_v1_beta3_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/snapshots_v1_beta3_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/snapshots_v1_beta3_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'dataflow.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); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes a snapshot. - * - * The async variant is {@see self::deleteSnapshotAsync()} . - * - * @example samples/V1beta3/SnapshotsV1Beta3Client/delete_snapshot.php - * - * @param DeleteSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DeleteSnapshotResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteSnapshot(DeleteSnapshotRequest $request, array $callOptions = []): DeleteSnapshotResponse - { - return $this->startApiCall('DeleteSnapshot', $request, $callOptions)->wait(); - } - - /** - * Gets information about a snapshot. - * - * The async variant is {@see self::getSnapshotAsync()} . - * - * @example samples/V1beta3/SnapshotsV1Beta3Client/get_snapshot.php - * - * @param GetSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Snapshot - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getSnapshot(GetSnapshotRequest $request, array $callOptions = []): Snapshot - { - return $this->startApiCall('GetSnapshot', $request, $callOptions)->wait(); - } - - /** - * Lists snapshots. - * - * The async variant is {@see self::listSnapshotsAsync()} . - * - * @example samples/V1beta3/SnapshotsV1Beta3Client/list_snapshots.php - * - * @param ListSnapshotsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ListSnapshotsResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listSnapshots(ListSnapshotsRequest $request, array $callOptions = []): ListSnapshotsResponse - { - return $this->startApiCall('ListSnapshots', $request, $callOptions)->wait(); - } -} diff --git a/Dataflow/src/V1beta3/Client/BaseClient/TemplatesServiceBaseClient.php b/Dataflow/src/V1beta3/Client/BaseClient/TemplatesServiceBaseClient.php deleted file mode 100644 index b750937279cc..000000000000 --- a/Dataflow/src/V1beta3/Client/BaseClient/TemplatesServiceBaseClient.php +++ /dev/null @@ -1,259 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/templates_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/templates_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/templates_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/templates_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'dataflow.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); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a Cloud Dataflow job from a template. - * - * The async variant is {@see self::createJobFromTemplateAsync()} . - * - * @example samples/V1beta3/TemplatesServiceClient/create_job_from_template.php - * - * @param CreateJobFromTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createJobFromTemplate(CreateJobFromTemplateRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('CreateJobFromTemplate', $request, $callOptions)->wait(); - } - - /** - * Get the template associated with a template. - * - * The async variant is {@see self::getTemplateAsync()} . - * - * @example samples/V1beta3/TemplatesServiceClient/get_template.php - * - * @param GetTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GetTemplateResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getTemplate(GetTemplateRequest $request, array $callOptions = []): GetTemplateResponse - { - return $this->startApiCall('GetTemplate', $request, $callOptions)->wait(); - } - - /** - * Launch a template. - * - * The async variant is {@see self::launchTemplateAsync()} . - * - * @example samples/V1beta3/TemplatesServiceClient/launch_template.php - * - * @param LaunchTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LaunchTemplateResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function launchTemplate(LaunchTemplateRequest $request, array $callOptions = []): LaunchTemplateResponse - { - return $this->startApiCall('LaunchTemplate', $request, $callOptions)->wait(); - } -} diff --git a/Dataflow/src/V1beta3/Client/FlexTemplatesServiceClient.php b/Dataflow/src/V1beta3/Client/FlexTemplatesServiceClient.php index f4d935444254..63a319ec4dec 100644 --- a/Dataflow/src/V1beta3/Client/FlexTemplatesServiceClient.php +++ b/Dataflow/src/V1beta3/Client/FlexTemplatesServiceClient.php @@ -26,17 +26,171 @@ namespace Google\Cloud\Dataflow\V1beta3\Client; -use Google\Cloud\Dataflow\V1beta3\Client\BaseClient\FlexTemplatesServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dataflow\V1beta3\LaunchFlexTemplateRequest; +use Google\Cloud\Dataflow\V1beta3\LaunchFlexTemplateResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Provides a service for Flex templates. This feature is not ready yet. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface launchFlexTemplateAsync(LaunchFlexTemplateRequest $request, array $optionalArgs = []) */ -final class FlexTemplatesServiceClient extends FlexTemplatesServiceBaseClient +final class FlexTemplatesServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see FlexTemplatesServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.dataflow.v1beta3.FlexTemplatesService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dataflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/compute.readonly', + 'https://www.googleapis.com/auth/userinfo.email', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/flex_templates_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/flex_templates_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/flex_templates_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/flex_templates_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'dataflow.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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Launch a job with a FlexTemplate. + * + * The async variant is + * {@see FlexTemplatesServiceClient::launchFlexTemplateAsync()} . + * + * @example samples/V1beta3/FlexTemplatesServiceClient/launch_flex_template.php + * + * @param LaunchFlexTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LaunchFlexTemplateResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function launchFlexTemplate(LaunchFlexTemplateRequest $request, array $callOptions = []): LaunchFlexTemplateResponse + { + return $this->startApiCall('LaunchFlexTemplate', $request, $callOptions)->wait(); + } } diff --git a/Dataflow/src/V1beta3/Client/JobsV1Beta3Client.php b/Dataflow/src/V1beta3/Client/JobsV1Beta3Client.php index 71d1fb710085..41901a910421 100644 --- a/Dataflow/src/V1beta3/Client/JobsV1Beta3Client.php +++ b/Dataflow/src/V1beta3/Client/JobsV1Beta3Client.php @@ -26,17 +26,378 @@ namespace Google\Cloud\Dataflow\V1beta3\Client; -use Google\Cloud\Dataflow\V1beta3\Client\BaseClient\JobsV1Beta3BaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dataflow\V1beta3\CheckActiveJobsRequest; +use Google\Cloud\Dataflow\V1beta3\CheckActiveJobsResponse; +use Google\Cloud\Dataflow\V1beta3\CreateJobRequest; +use Google\Cloud\Dataflow\V1beta3\GetJobRequest; +use Google\Cloud\Dataflow\V1beta3\Job; +use Google\Cloud\Dataflow\V1beta3\ListJobsRequest; +use Google\Cloud\Dataflow\V1beta3\Snapshot; +use Google\Cloud\Dataflow\V1beta3\SnapshotJobRequest; +use Google\Cloud\Dataflow\V1beta3\UpdateJobRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Provides a method to create and modify Google Cloud Dataflow jobs. + * A Job is a multi-stage computation graph run by the Cloud Dataflow service. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface aggregatedListJobsAsync(ListJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface checkActiveJobsAsync(CheckActiveJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface createJobAsync(CreateJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getJobAsync(GetJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface listJobsAsync(ListJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface snapshotJobAsync(SnapshotJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateJobAsync(UpdateJobRequest $request, array $optionalArgs = []) */ -final class JobsV1Beta3Client extends JobsV1Beta3BaseClient +final class JobsV1Beta3Client { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see JobsV1Beta3BaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.dataflow.v1beta3.JobsV1Beta3'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dataflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/compute.readonly', + 'https://www.googleapis.com/auth/userinfo.email', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/jobs_v1_beta3_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/jobs_v1_beta3_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/jobs_v1_beta3_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/jobs_v1_beta3_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'dataflow.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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * List the jobs of a project across all regions. + * + * The async variant is {@see JobsV1Beta3Client::aggregatedListJobsAsync()} . + * + * @example samples/V1beta3/JobsV1Beta3Client/aggregated_list_jobs.php + * + * @param ListJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function aggregatedListJobs(ListJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('AggregatedListJobs', $request, $callOptions); + } + + /** + * Check for existence of active jobs in the given project across all regions. + * + * The async variant is {@see JobsV1Beta3Client::checkActiveJobsAsync()} . + * + * @example samples/V1beta3/JobsV1Beta3Client/check_active_jobs.php + * + * @param CheckActiveJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CheckActiveJobsResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function checkActiveJobs(CheckActiveJobsRequest $request, array $callOptions = []): CheckActiveJobsResponse + { + return $this->startApiCall('CheckActiveJobs', $request, $callOptions)->wait(); + } + + /** + * Creates a Cloud Dataflow job. + * + * To create a job, we recommend using `projects.locations.jobs.create` with a + * [regional endpoint] + * (https://cloud.google.com/dataflow/docs/concepts/regional-endpoints). Using + * `projects.jobs.create` is not recommended, as your job will always start + * in `us-central1`. + * + * The async variant is {@see JobsV1Beta3Client::createJobAsync()} . + * + * @example samples/V1beta3/JobsV1Beta3Client/create_job.php + * + * @param CreateJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createJob(CreateJobRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('CreateJob', $request, $callOptions)->wait(); + } + + /** + * Gets the state of the specified Cloud Dataflow job. + * + * To get the state of a job, we recommend using `projects.locations.jobs.get` + * with a [regional endpoint] + * (https://cloud.google.com/dataflow/docs/concepts/regional-endpoints). Using + * `projects.jobs.get` is not recommended, as you can only get the state of + * jobs that are running in `us-central1`. + * + * The async variant is {@see JobsV1Beta3Client::getJobAsync()} . + * + * @example samples/V1beta3/JobsV1Beta3Client/get_job.php + * + * @param GetJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getJob(GetJobRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('GetJob', $request, $callOptions)->wait(); + } + + /** + * List the jobs of a project. + * + * To list the jobs of a project in a region, we recommend using + * `projects.locations.jobs.list` with a [regional endpoint] + * (https://cloud.google.com/dataflow/docs/concepts/regional-endpoints). To + * list the all jobs across all regions, use `projects.jobs.aggregated`. Using + * `projects.jobs.list` is not recommended, as you can only get the list of + * jobs that are running in `us-central1`. + * + * The async variant is {@see JobsV1Beta3Client::listJobsAsync()} . + * + * @example samples/V1beta3/JobsV1Beta3Client/list_jobs.php + * + * @param ListJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listJobs(ListJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListJobs', $request, $callOptions); + } + + /** + * Snapshot the state of a streaming job. + * + * The async variant is {@see JobsV1Beta3Client::snapshotJobAsync()} . + * + * @example samples/V1beta3/JobsV1Beta3Client/snapshot_job.php + * + * @param SnapshotJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Snapshot + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function snapshotJob(SnapshotJobRequest $request, array $callOptions = []): Snapshot + { + return $this->startApiCall('SnapshotJob', $request, $callOptions)->wait(); + } + + /** + * Updates the state of an existing Cloud Dataflow job. + * + * To update the state of an existing job, we recommend using + * `projects.locations.jobs.update` with a [regional endpoint] + * (https://cloud.google.com/dataflow/docs/concepts/regional-endpoints). Using + * `projects.jobs.update` is not recommended, as you can only update the state + * of jobs that are running in `us-central1`. + * + * The async variant is {@see JobsV1Beta3Client::updateJobAsync()} . + * + * @example samples/V1beta3/JobsV1Beta3Client/update_job.php + * + * @param UpdateJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function updateJob(UpdateJobRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('UpdateJob', $request, $callOptions)->wait(); + } } diff --git a/Dataflow/src/V1beta3/Client/MessagesV1Beta3Client.php b/Dataflow/src/V1beta3/Client/MessagesV1Beta3Client.php index 00ad863ff408..ddac42936227 100644 --- a/Dataflow/src/V1beta3/Client/MessagesV1Beta3Client.php +++ b/Dataflow/src/V1beta3/Client/MessagesV1Beta3Client.php @@ -26,17 +26,177 @@ namespace Google\Cloud\Dataflow\V1beta3\Client; -use Google\Cloud\Dataflow\V1beta3\Client\BaseClient\MessagesV1Beta3BaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dataflow\V1beta3\ListJobMessagesRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Dataflow Messages API is used for monitoring the progress of + * Dataflow jobs. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface listJobMessagesAsync(ListJobMessagesRequest $request, array $optionalArgs = []) */ -final class MessagesV1Beta3Client extends MessagesV1Beta3BaseClient +final class MessagesV1Beta3Client { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see MessagesV1Beta3BaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.dataflow.v1beta3.MessagesV1Beta3'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dataflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/compute.readonly', + 'https://www.googleapis.com/auth/userinfo.email', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/messages_v1_beta3_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/messages_v1_beta3_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/messages_v1_beta3_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/messages_v1_beta3_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'dataflow.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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Request the job status. + * + * To request the status of a job, we recommend using + * `projects.locations.jobs.messages.list` with a [regional endpoint] + * (https://cloud.google.com/dataflow/docs/concepts/regional-endpoints). Using + * `projects.jobs.messages.list` is not recommended, as you can only request + * the status of jobs that are running in `us-central1`. + * + * The async variant is {@see MessagesV1Beta3Client::listJobMessagesAsync()} . + * + * @example samples/V1beta3/MessagesV1Beta3Client/list_job_messages.php + * + * @param ListJobMessagesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listJobMessages(ListJobMessagesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListJobMessages', $request, $callOptions); + } } diff --git a/Dataflow/src/V1beta3/Client/MetricsV1Beta3Client.php b/Dataflow/src/V1beta3/Client/MetricsV1Beta3Client.php index 52cb622a04ab..2fee08c37779 100644 --- a/Dataflow/src/V1beta3/Client/MetricsV1Beta3Client.php +++ b/Dataflow/src/V1beta3/Client/MetricsV1Beta3Client.php @@ -26,17 +26,245 @@ namespace Google\Cloud\Dataflow\V1beta3\Client; -use Google\Cloud\Dataflow\V1beta3\Client\BaseClient\MetricsV1Beta3BaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dataflow\V1beta3\GetJobExecutionDetailsRequest; +use Google\Cloud\Dataflow\V1beta3\GetJobMetricsRequest; +use Google\Cloud\Dataflow\V1beta3\GetStageExecutionDetailsRequest; +use Google\Cloud\Dataflow\V1beta3\JobMetrics; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Dataflow Metrics API lets you monitor the progress of Dataflow + * jobs. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface getJobExecutionDetailsAsync(GetJobExecutionDetailsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getJobMetricsAsync(GetJobMetricsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getStageExecutionDetailsAsync(GetStageExecutionDetailsRequest $request, array $optionalArgs = []) */ -final class MetricsV1Beta3Client extends MetricsV1Beta3BaseClient +final class MetricsV1Beta3Client { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see MetricsV1Beta3BaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.dataflow.v1beta3.MetricsV1Beta3'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dataflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/compute.readonly', + 'https://www.googleapis.com/auth/userinfo.email', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/metrics_v1_beta3_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/metrics_v1_beta3_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/metrics_v1_beta3_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/metrics_v1_beta3_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'dataflow.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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Request detailed information about the execution status of the job. + * + * EXPERIMENTAL. This API is subject to change or removal without notice. + * + * The async variant is {@see MetricsV1Beta3Client::getJobExecutionDetailsAsync()} + * . + * + * @example samples/V1beta3/MetricsV1Beta3Client/get_job_execution_details.php + * + * @param GetJobExecutionDetailsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getJobExecutionDetails(GetJobExecutionDetailsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('GetJobExecutionDetails', $request, $callOptions); + } + + /** + * Request the job status. + * + * To request the status of a job, we recommend using + * `projects.locations.jobs.getMetrics` with a [regional endpoint] + * (https://cloud.google.com/dataflow/docs/concepts/regional-endpoints). Using + * `projects.jobs.getMetrics` is not recommended, as you can only request the + * status of jobs that are running in `us-central1`. + * + * The async variant is {@see MetricsV1Beta3Client::getJobMetricsAsync()} . + * + * @example samples/V1beta3/MetricsV1Beta3Client/get_job_metrics.php + * + * @param GetJobMetricsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 JobMetrics + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getJobMetrics(GetJobMetricsRequest $request, array $callOptions = []): JobMetrics + { + return $this->startApiCall('GetJobMetrics', $request, $callOptions)->wait(); + } + + /** + * Request detailed information about the execution status of a stage of the + * job. + * + * EXPERIMENTAL. This API is subject to change or removal without notice. + * + * The async variant is + * {@see MetricsV1Beta3Client::getStageExecutionDetailsAsync()} . + * + * @example samples/V1beta3/MetricsV1Beta3Client/get_stage_execution_details.php + * + * @param GetStageExecutionDetailsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getStageExecutionDetails(GetStageExecutionDetailsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('GetStageExecutionDetails', $request, $callOptions); + } } diff --git a/Dataflow/src/V1beta3/Client/SnapshotsV1Beta3Client.php b/Dataflow/src/V1beta3/Client/SnapshotsV1Beta3Client.php index edf4aeaf917d..23f37adf2a6a 100644 --- a/Dataflow/src/V1beta3/Client/SnapshotsV1Beta3Client.php +++ b/Dataflow/src/V1beta3/Client/SnapshotsV1Beta3Client.php @@ -26,17 +26,232 @@ namespace Google\Cloud\Dataflow\V1beta3\Client; -use Google\Cloud\Dataflow\V1beta3\Client\BaseClient\SnapshotsV1Beta3BaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dataflow\V1beta3\DeleteSnapshotRequest; +use Google\Cloud\Dataflow\V1beta3\DeleteSnapshotResponse; +use Google\Cloud\Dataflow\V1beta3\GetSnapshotRequest; +use Google\Cloud\Dataflow\V1beta3\ListSnapshotsRequest; +use Google\Cloud\Dataflow\V1beta3\ListSnapshotsResponse; +use Google\Cloud\Dataflow\V1beta3\Snapshot; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Provides methods to manage snapshots of Google Cloud Dataflow jobs. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface deleteSnapshotAsync(DeleteSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSnapshotAsync(GetSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSnapshotsAsync(ListSnapshotsRequest $request, array $optionalArgs = []) */ -final class SnapshotsV1Beta3Client extends SnapshotsV1Beta3BaseClient +final class SnapshotsV1Beta3Client { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SnapshotsV1Beta3BaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.dataflow.v1beta3.SnapshotsV1Beta3'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dataflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/compute.readonly', + 'https://www.googleapis.com/auth/userinfo.email', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/snapshots_v1_beta3_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/snapshots_v1_beta3_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/snapshots_v1_beta3_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/snapshots_v1_beta3_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'dataflow.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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes a snapshot. + * + * The async variant is {@see SnapshotsV1Beta3Client::deleteSnapshotAsync()} . + * + * @example samples/V1beta3/SnapshotsV1Beta3Client/delete_snapshot.php + * + * @param DeleteSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DeleteSnapshotResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteSnapshot(DeleteSnapshotRequest $request, array $callOptions = []): DeleteSnapshotResponse + { + return $this->startApiCall('DeleteSnapshot', $request, $callOptions)->wait(); + } + + /** + * Gets information about a snapshot. + * + * The async variant is {@see SnapshotsV1Beta3Client::getSnapshotAsync()} . + * + * @example samples/V1beta3/SnapshotsV1Beta3Client/get_snapshot.php + * + * @param GetSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Snapshot + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getSnapshot(GetSnapshotRequest $request, array $callOptions = []): Snapshot + { + return $this->startApiCall('GetSnapshot', $request, $callOptions)->wait(); + } + + /** + * Lists snapshots. + * + * The async variant is {@see SnapshotsV1Beta3Client::listSnapshotsAsync()} . + * + * @example samples/V1beta3/SnapshotsV1Beta3Client/list_snapshots.php + * + * @param ListSnapshotsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ListSnapshotsResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listSnapshots(ListSnapshotsRequest $request, array $callOptions = []): ListSnapshotsResponse + { + return $this->startApiCall('ListSnapshots', $request, $callOptions)->wait(); + } } diff --git a/Dataflow/src/V1beta3/Client/TemplatesServiceClient.php b/Dataflow/src/V1beta3/Client/TemplatesServiceClient.php index a8f53d812f10..f949707ce3ff 100644 --- a/Dataflow/src/V1beta3/Client/TemplatesServiceClient.php +++ b/Dataflow/src/V1beta3/Client/TemplatesServiceClient.php @@ -26,17 +26,233 @@ namespace Google\Cloud\Dataflow\V1beta3\Client; -use Google\Cloud\Dataflow\V1beta3\Client\BaseClient\TemplatesServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dataflow\V1beta3\CreateJobFromTemplateRequest; +use Google\Cloud\Dataflow\V1beta3\GetTemplateRequest; +use Google\Cloud\Dataflow\V1beta3\GetTemplateResponse; +use Google\Cloud\Dataflow\V1beta3\Job; +use Google\Cloud\Dataflow\V1beta3\LaunchTemplateRequest; +use Google\Cloud\Dataflow\V1beta3\LaunchTemplateResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Provides a method to create Cloud Dataflow jobs from templates. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createJobFromTemplateAsync(CreateJobFromTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTemplateAsync(GetTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface launchTemplateAsync(LaunchTemplateRequest $request, array $optionalArgs = []) */ -final class TemplatesServiceClient extends TemplatesServiceBaseClient +final class TemplatesServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TemplatesServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.dataflow.v1beta3.TemplatesService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dataflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/compute.readonly', + 'https://www.googleapis.com/auth/userinfo.email', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/templates_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/templates_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/templates_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/templates_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'dataflow.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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a Cloud Dataflow job from a template. + * + * The async variant is {@see TemplatesServiceClient::createJobFromTemplateAsync()} + * . + * + * @example samples/V1beta3/TemplatesServiceClient/create_job_from_template.php + * + * @param CreateJobFromTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createJobFromTemplate(CreateJobFromTemplateRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('CreateJobFromTemplate', $request, $callOptions)->wait(); + } + + /** + * Get the template associated with a template. + * + * The async variant is {@see TemplatesServiceClient::getTemplateAsync()} . + * + * @example samples/V1beta3/TemplatesServiceClient/get_template.php + * + * @param GetTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GetTemplateResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getTemplate(GetTemplateRequest $request, array $callOptions = []): GetTemplateResponse + { + return $this->startApiCall('GetTemplate', $request, $callOptions)->wait(); + } + + /** + * Launch a template. + * + * The async variant is {@see TemplatesServiceClient::launchTemplateAsync()} . + * + * @example samples/V1beta3/TemplatesServiceClient/launch_template.php + * + * @param LaunchTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LaunchTemplateResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function launchTemplate(LaunchTemplateRequest $request, array $callOptions = []): LaunchTemplateResponse + { + return $this->startApiCall('LaunchTemplate', $request, $callOptions)->wait(); + } } diff --git a/Dataform/composer.json b/Dataform/composer.json index 8a5917137394..2fcba4e51437 100644 --- a/Dataform/composer.json +++ b/Dataform/composer.json @@ -19,7 +19,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Dataform/src/V1beta1/Client/BaseClient/DataformBaseClient.php b/Dataform/src/V1beta1/Client/BaseClient/DataformBaseClient.php deleted file mode 100644 index 9a946096d4ab..000000000000 --- a/Dataform/src/V1beta1/Client/BaseClient/DataformBaseClient.php +++ /dev/null @@ -1,1469 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/dataform_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/dataform_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/dataform_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/dataform_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * compilation_result resource. - * - * @param string $project - * @param string $location - * @param string $repository - * @param string $compilationResult - * - * @return string The formatted compilation_result resource. - * - * @experimental - */ - public static function compilationResultName(string $project, string $location, string $repository, string $compilationResult): string - { - return self::getPathTemplate('compilationResult')->render([ - 'project' => $project, - 'location' => $location, - 'repository' => $repository, - 'compilation_result' => $compilationResult, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - * - * @experimental - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a repository - * resource. - * - * @param string $project - * @param string $location - * @param string $repository - * - * @return string The formatted repository resource. - * - * @experimental - */ - public static function repositoryName(string $project, string $location, string $repository): string - { - return self::getPathTemplate('repository')->render([ - 'project' => $project, - 'location' => $location, - 'repository' => $repository, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * secret_version resource. - * - * @param string $project - * @param string $secret - * @param string $version - * - * @return string The formatted secret_version resource. - * - * @experimental - */ - public static function secretVersionName(string $project, string $secret, string $version): string - { - return self::getPathTemplate('secretVersion')->render([ - 'project' => $project, - 'secret' => $secret, - 'version' => $version, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * workflow_invocation resource. - * - * @param string $project - * @param string $location - * @param string $repository - * @param string $workflowInvocation - * - * @return string The formatted workflow_invocation resource. - * - * @experimental - */ - public static function workflowInvocationName(string $project, string $location, string $repository, string $workflowInvocation): string - { - return self::getPathTemplate('workflowInvocation')->render([ - 'project' => $project, - 'location' => $location, - 'repository' => $repository, - 'workflow_invocation' => $workflowInvocation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a workspace - * resource. - * - * @param string $project - * @param string $location - * @param string $repository - * @param string $workspace - * - * @return string The formatted workspace resource. - * - * @experimental - */ - public static function workspaceName(string $project, string $location, string $repository, string $workspace): string - { - return self::getPathTemplate('workspace')->render([ - 'project' => $project, - 'location' => $location, - 'repository' => $repository, - 'workspace' => $workspace, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - compilationResult: projects/{project}/locations/{location}/repositories/{repository}/compilationResults/{compilation_result} - * - location: projects/{project}/locations/{location} - * - repository: projects/{project}/locations/{location}/repositories/{repository} - * - secretVersion: projects/{project}/secrets/{secret}/versions/{version} - * - workflowInvocation: projects/{project}/locations/{location}/repositories/{repository}/workflowInvocations/{workflow_invocation} - * - workspace: projects/{project}/locations/{location}/repositories/{repository}/workspaces/{workspace} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dataform.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); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Requests cancellation of a running WorkflowInvocation. - * - * The async variant is {@see self::cancelWorkflowInvocationAsync()} . - * - * @example samples/V1beta1/DataformClient/cancel_workflow_invocation.php - * - * @param CancelWorkflowInvocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function cancelWorkflowInvocation(CancelWorkflowInvocationRequest $request, array $callOptions = []): void - { - $this->startApiCall('CancelWorkflowInvocation', $request, $callOptions)->wait(); - } - - /** - * Applies a Git commit for uncommitted files in a Workspace. - * - * The async variant is {@see self::commitWorkspaceChangesAsync()} . - * - * @example samples/V1beta1/DataformClient/commit_workspace_changes.php - * - * @param CommitWorkspaceChangesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function commitWorkspaceChanges(CommitWorkspaceChangesRequest $request, array $callOptions = []): void - { - $this->startApiCall('CommitWorkspaceChanges', $request, $callOptions)->wait(); - } - - /** - * Creates a new CompilationResult in a given project and location. - * - * The async variant is {@see self::createCompilationResultAsync()} . - * - * @example samples/V1beta1/DataformClient/create_compilation_result.php - * - * @param CreateCompilationResultRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CompilationResult - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createCompilationResult(CreateCompilationResultRequest $request, array $callOptions = []): CompilationResult - { - return $this->startApiCall('CreateCompilationResult', $request, $callOptions)->wait(); - } - - /** - * Creates a new Repository in a given project and location. - * - * The async variant is {@see self::createRepositoryAsync()} . - * - * @example samples/V1beta1/DataformClient/create_repository.php - * - * @param CreateRepositoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Repository - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createRepository(CreateRepositoryRequest $request, array $callOptions = []): Repository - { - return $this->startApiCall('CreateRepository', $request, $callOptions)->wait(); - } - - /** - * Creates a new WorkflowInvocation in a given Repository. - * - * The async variant is {@see self::createWorkflowInvocationAsync()} . - * - * @example samples/V1beta1/DataformClient/create_workflow_invocation.php - * - * @param CreateWorkflowInvocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 WorkflowInvocation - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createWorkflowInvocation(CreateWorkflowInvocationRequest $request, array $callOptions = []): WorkflowInvocation - { - return $this->startApiCall('CreateWorkflowInvocation', $request, $callOptions)->wait(); - } - - /** - * Creates a new Workspace in a given Repository. - * - * The async variant is {@see self::createWorkspaceAsync()} . - * - * @example samples/V1beta1/DataformClient/create_workspace.php - * - * @param CreateWorkspaceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Workspace - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createWorkspace(CreateWorkspaceRequest $request, array $callOptions = []): Workspace - { - return $this->startApiCall('CreateWorkspace', $request, $callOptions)->wait(); - } - - /** - * Deletes a single Repository. - * - * The async variant is {@see self::deleteRepositoryAsync()} . - * - * @example samples/V1beta1/DataformClient/delete_repository.php - * - * @param DeleteRepositoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteRepository(DeleteRepositoryRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteRepository', $request, $callOptions)->wait(); - } - - /** - * Deletes a single WorkflowInvocation. - * - * The async variant is {@see self::deleteWorkflowInvocationAsync()} . - * - * @example samples/V1beta1/DataformClient/delete_workflow_invocation.php - * - * @param DeleteWorkflowInvocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteWorkflowInvocation(DeleteWorkflowInvocationRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteWorkflowInvocation', $request, $callOptions)->wait(); - } - - /** - * Deletes a single Workspace. - * - * The async variant is {@see self::deleteWorkspaceAsync()} . - * - * @example samples/V1beta1/DataformClient/delete_workspace.php - * - * @param DeleteWorkspaceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteWorkspace(DeleteWorkspaceRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteWorkspace', $request, $callOptions)->wait(); - } - - /** - * Fetches Git diff for an uncommitted file in a Workspace. - * - * The async variant is {@see self::fetchFileDiffAsync()} . - * - * @example samples/V1beta1/DataformClient/fetch_file_diff.php - * - * @param FetchFileDiffRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FetchFileDiffResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function fetchFileDiff(FetchFileDiffRequest $request, array $callOptions = []): FetchFileDiffResponse - { - return $this->startApiCall('FetchFileDiff', $request, $callOptions)->wait(); - } - - /** - * Fetches Git statuses for the files in a Workspace. - * - * The async variant is {@see self::fetchFileGitStatusesAsync()} . - * - * @example samples/V1beta1/DataformClient/fetch_file_git_statuses.php - * - * @param FetchFileGitStatusesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FetchFileGitStatusesResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function fetchFileGitStatuses(FetchFileGitStatusesRequest $request, array $callOptions = []): FetchFileGitStatusesResponse - { - return $this->startApiCall('FetchFileGitStatuses', $request, $callOptions)->wait(); - } - - /** - * Fetches Git ahead/behind against a remote branch. - * - * The async variant is {@see self::fetchGitAheadBehindAsync()} . - * - * @example samples/V1beta1/DataformClient/fetch_git_ahead_behind.php - * - * @param FetchGitAheadBehindRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FetchGitAheadBehindResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function fetchGitAheadBehind(FetchGitAheadBehindRequest $request, array $callOptions = []): FetchGitAheadBehindResponse - { - return $this->startApiCall('FetchGitAheadBehind', $request, $callOptions)->wait(); - } - - /** - * Fetches a Repository's remote branches. - * - * The async variant is {@see self::fetchRemoteBranchesAsync()} . - * - * @example samples/V1beta1/DataformClient/fetch_remote_branches.php - * - * @param FetchRemoteBranchesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FetchRemoteBranchesResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function fetchRemoteBranches(FetchRemoteBranchesRequest $request, array $callOptions = []): FetchRemoteBranchesResponse - { - return $this->startApiCall('FetchRemoteBranches', $request, $callOptions)->wait(); - } - - /** - * Fetches a single CompilationResult. - * - * The async variant is {@see self::getCompilationResultAsync()} . - * - * @example samples/V1beta1/DataformClient/get_compilation_result.php - * - * @param GetCompilationResultRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CompilationResult - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getCompilationResult(GetCompilationResultRequest $request, array $callOptions = []): CompilationResult - { - return $this->startApiCall('GetCompilationResult', $request, $callOptions)->wait(); - } - - /** - * Fetches a single Repository. - * - * The async variant is {@see self::getRepositoryAsync()} . - * - * @example samples/V1beta1/DataformClient/get_repository.php - * - * @param GetRepositoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Repository - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getRepository(GetRepositoryRequest $request, array $callOptions = []): Repository - { - return $this->startApiCall('GetRepository', $request, $callOptions)->wait(); - } - - /** - * Fetches a single WorkflowInvocation. - * - * The async variant is {@see self::getWorkflowInvocationAsync()} . - * - * @example samples/V1beta1/DataformClient/get_workflow_invocation.php - * - * @param GetWorkflowInvocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 WorkflowInvocation - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getWorkflowInvocation(GetWorkflowInvocationRequest $request, array $callOptions = []): WorkflowInvocation - { - return $this->startApiCall('GetWorkflowInvocation', $request, $callOptions)->wait(); - } - - /** - * Fetches a single Workspace. - * - * The async variant is {@see self::getWorkspaceAsync()} . - * - * @example samples/V1beta1/DataformClient/get_workspace.php - * - * @param GetWorkspaceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Workspace - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getWorkspace(GetWorkspaceRequest $request, array $callOptions = []): Workspace - { - return $this->startApiCall('GetWorkspace', $request, $callOptions)->wait(); - } - - /** - * Installs dependency NPM packages (inside a Workspace). - * - * The async variant is {@see self::installNpmPackagesAsync()} . - * - * @example samples/V1beta1/DataformClient/install_npm_packages.php - * - * @param InstallNpmPackagesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InstallNpmPackagesResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function installNpmPackages(InstallNpmPackagesRequest $request, array $callOptions = []): InstallNpmPackagesResponse - { - return $this->startApiCall('InstallNpmPackages', $request, $callOptions)->wait(); - } - - /** - * Lists CompilationResults in a given Repository. - * - * The async variant is {@see self::listCompilationResultsAsync()} . - * - * @example samples/V1beta1/DataformClient/list_compilation_results.php - * - * @param ListCompilationResultsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listCompilationResults(ListCompilationResultsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCompilationResults', $request, $callOptions); - } - - /** - * Lists Repositories in a given project and location. - * - * The async variant is {@see self::listRepositoriesAsync()} . - * - * @example samples/V1beta1/DataformClient/list_repositories.php - * - * @param ListRepositoriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listRepositories(ListRepositoriesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListRepositories', $request, $callOptions); - } - - /** - * Lists WorkflowInvocations in a given Repository. - * - * The async variant is {@see self::listWorkflowInvocationsAsync()} . - * - * @example samples/V1beta1/DataformClient/list_workflow_invocations.php - * - * @param ListWorkflowInvocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listWorkflowInvocations(ListWorkflowInvocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListWorkflowInvocations', $request, $callOptions); - } - - /** - * Lists Workspaces in a given Repository. - * - * The async variant is {@see self::listWorkspacesAsync()} . - * - * @example samples/V1beta1/DataformClient/list_workspaces.php - * - * @param ListWorkspacesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listWorkspaces(ListWorkspacesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListWorkspaces', $request, $callOptions); - } - - /** - * Creates a directory inside a Workspace. - * - * The async variant is {@see self::makeDirectoryAsync()} . - * - * @example samples/V1beta1/DataformClient/make_directory.php - * - * @param MakeDirectoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MakeDirectoryResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function makeDirectory(MakeDirectoryRequest $request, array $callOptions = []): MakeDirectoryResponse - { - return $this->startApiCall('MakeDirectory', $request, $callOptions)->wait(); - } - - /** - * Moves a directory (inside a Workspace), and all of its contents, to a new - * location. - * - * The async variant is {@see self::moveDirectoryAsync()} . - * - * @example samples/V1beta1/DataformClient/move_directory.php - * - * @param MoveDirectoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MoveDirectoryResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function moveDirectory(MoveDirectoryRequest $request, array $callOptions = []): MoveDirectoryResponse - { - return $this->startApiCall('MoveDirectory', $request, $callOptions)->wait(); - } - - /** - * Moves a file (inside a Workspace) to a new location. - * - * The async variant is {@see self::moveFileAsync()} . - * - * @example samples/V1beta1/DataformClient/move_file.php - * - * @param MoveFileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MoveFileResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function moveFile(MoveFileRequest $request, array $callOptions = []): MoveFileResponse - { - return $this->startApiCall('MoveFile', $request, $callOptions)->wait(); - } - - /** - * Pulls Git commits from the Repository's remote into a Workspace. - * - * The async variant is {@see self::pullGitCommitsAsync()} . - * - * @example samples/V1beta1/DataformClient/pull_git_commits.php - * - * @param PullGitCommitsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function pullGitCommits(PullGitCommitsRequest $request, array $callOptions = []): void - { - $this->startApiCall('PullGitCommits', $request, $callOptions)->wait(); - } - - /** - * Pushes Git commits from a Workspace to the Repository's remote. - * - * The async variant is {@see self::pushGitCommitsAsync()} . - * - * @example samples/V1beta1/DataformClient/push_git_commits.php - * - * @param PushGitCommitsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function pushGitCommits(PushGitCommitsRequest $request, array $callOptions = []): void - { - $this->startApiCall('PushGitCommits', $request, $callOptions)->wait(); - } - - /** - * Returns CompilationResultActions in a given CompilationResult. - * - * The async variant is {@see self::queryCompilationResultActionsAsync()} . - * - * @example samples/V1beta1/DataformClient/query_compilation_result_actions.php - * - * @param QueryCompilationResultActionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function queryCompilationResultActions(QueryCompilationResultActionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('QueryCompilationResultActions', $request, $callOptions); - } - - /** - * Returns the contents of a given Workspace directory. - * - * The async variant is {@see self::queryDirectoryContentsAsync()} . - * - * @example samples/V1beta1/DataformClient/query_directory_contents.php - * - * @param QueryDirectoryContentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function queryDirectoryContents(QueryDirectoryContentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('QueryDirectoryContents', $request, $callOptions); - } - - /** - * Returns WorkflowInvocationActions in a given WorkflowInvocation. - * - * The async variant is {@see self::queryWorkflowInvocationActionsAsync()} . - * - * @example samples/V1beta1/DataformClient/query_workflow_invocation_actions.php - * - * @param QueryWorkflowInvocationActionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function queryWorkflowInvocationActions(QueryWorkflowInvocationActionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('QueryWorkflowInvocationActions', $request, $callOptions); - } - - /** - * Returns the contents of a file (inside a Workspace). - * - * The async variant is {@see self::readFileAsync()} . - * - * @example samples/V1beta1/DataformClient/read_file.php - * - * @param ReadFileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ReadFileResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function readFile(ReadFileRequest $request, array $callOptions = []): ReadFileResponse - { - return $this->startApiCall('ReadFile', $request, $callOptions)->wait(); - } - - /** - * Deletes a directory (inside a Workspace) and all of its contents. - * - * The async variant is {@see self::removeDirectoryAsync()} . - * - * @example samples/V1beta1/DataformClient/remove_directory.php - * - * @param RemoveDirectoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function removeDirectory(RemoveDirectoryRequest $request, array $callOptions = []): void - { - $this->startApiCall('RemoveDirectory', $request, $callOptions)->wait(); - } - - /** - * Deletes a file (inside a Workspace). - * - * The async variant is {@see self::removeFileAsync()} . - * - * @example samples/V1beta1/DataformClient/remove_file.php - * - * @param RemoveFileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function removeFile(RemoveFileRequest $request, array $callOptions = []): void - { - $this->startApiCall('RemoveFile', $request, $callOptions)->wait(); - } - - /** - * Performs a Git reset for uncommitted files in a Workspace. - * - * The async variant is {@see self::resetWorkspaceChangesAsync()} . - * - * @example samples/V1beta1/DataformClient/reset_workspace_changes.php - * - * @param ResetWorkspaceChangesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function resetWorkspaceChanges(ResetWorkspaceChangesRequest $request, array $callOptions = []): void - { - $this->startApiCall('ResetWorkspaceChanges', $request, $callOptions)->wait(); - } - - /** - * Updates a single Repository. - * - * The async variant is {@see self::updateRepositoryAsync()} . - * - * @example samples/V1beta1/DataformClient/update_repository.php - * - * @param UpdateRepositoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Repository - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function updateRepository(UpdateRepositoryRequest $request, array $callOptions = []): Repository - { - return $this->startApiCall('UpdateRepository', $request, $callOptions)->wait(); - } - - /** - * Writes to a file (inside a Workspace). - * - * The async variant is {@see self::writeFileAsync()} . - * - * @example samples/V1beta1/DataformClient/write_file.php - * - * @param WriteFileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 WriteFileResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function writeFile(WriteFileRequest $request, array $callOptions = []): WriteFileResponse - { - return $this->startApiCall('WriteFile', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1beta1/DataformClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1beta1/DataformClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dataform/src/V1beta1/Client/DataformClient.php b/Dataform/src/V1beta1/Client/DataformClient.php index 7346334af3fe..f405178ca6b8 100644 --- a/Dataform/src/V1beta1/Client/DataformClient.php +++ b/Dataform/src/V1beta1/Client/DataformClient.php @@ -26,17 +26,1444 @@ namespace Google\Cloud\Dataform\V1beta1\Client; -use Google\Cloud\Dataform\V1beta1\Client\BaseClient\DataformBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dataform\V1beta1\CancelWorkflowInvocationRequest; +use Google\Cloud\Dataform\V1beta1\CommitWorkspaceChangesRequest; +use Google\Cloud\Dataform\V1beta1\CompilationResult; +use Google\Cloud\Dataform\V1beta1\CreateCompilationResultRequest; +use Google\Cloud\Dataform\V1beta1\CreateRepositoryRequest; +use Google\Cloud\Dataform\V1beta1\CreateWorkflowInvocationRequest; +use Google\Cloud\Dataform\V1beta1\CreateWorkspaceRequest; +use Google\Cloud\Dataform\V1beta1\DeleteRepositoryRequest; +use Google\Cloud\Dataform\V1beta1\DeleteWorkflowInvocationRequest; +use Google\Cloud\Dataform\V1beta1\DeleteWorkspaceRequest; +use Google\Cloud\Dataform\V1beta1\FetchFileDiffRequest; +use Google\Cloud\Dataform\V1beta1\FetchFileDiffResponse; +use Google\Cloud\Dataform\V1beta1\FetchFileGitStatusesRequest; +use Google\Cloud\Dataform\V1beta1\FetchFileGitStatusesResponse; +use Google\Cloud\Dataform\V1beta1\FetchGitAheadBehindRequest; +use Google\Cloud\Dataform\V1beta1\FetchGitAheadBehindResponse; +use Google\Cloud\Dataform\V1beta1\FetchRemoteBranchesRequest; +use Google\Cloud\Dataform\V1beta1\FetchRemoteBranchesResponse; +use Google\Cloud\Dataform\V1beta1\GetCompilationResultRequest; +use Google\Cloud\Dataform\V1beta1\GetRepositoryRequest; +use Google\Cloud\Dataform\V1beta1\GetWorkflowInvocationRequest; +use Google\Cloud\Dataform\V1beta1\GetWorkspaceRequest; +use Google\Cloud\Dataform\V1beta1\InstallNpmPackagesRequest; +use Google\Cloud\Dataform\V1beta1\InstallNpmPackagesResponse; +use Google\Cloud\Dataform\V1beta1\ListCompilationResultsRequest; +use Google\Cloud\Dataform\V1beta1\ListRepositoriesRequest; +use Google\Cloud\Dataform\V1beta1\ListWorkflowInvocationsRequest; +use Google\Cloud\Dataform\V1beta1\ListWorkspacesRequest; +use Google\Cloud\Dataform\V1beta1\MakeDirectoryRequest; +use Google\Cloud\Dataform\V1beta1\MakeDirectoryResponse; +use Google\Cloud\Dataform\V1beta1\MoveDirectoryRequest; +use Google\Cloud\Dataform\V1beta1\MoveDirectoryResponse; +use Google\Cloud\Dataform\V1beta1\MoveFileRequest; +use Google\Cloud\Dataform\V1beta1\MoveFileResponse; +use Google\Cloud\Dataform\V1beta1\PullGitCommitsRequest; +use Google\Cloud\Dataform\V1beta1\PushGitCommitsRequest; +use Google\Cloud\Dataform\V1beta1\QueryCompilationResultActionsRequest; +use Google\Cloud\Dataform\V1beta1\QueryDirectoryContentsRequest; +use Google\Cloud\Dataform\V1beta1\QueryWorkflowInvocationActionsRequest; +use Google\Cloud\Dataform\V1beta1\ReadFileRequest; +use Google\Cloud\Dataform\V1beta1\ReadFileResponse; +use Google\Cloud\Dataform\V1beta1\RemoveDirectoryRequest; +use Google\Cloud\Dataform\V1beta1\RemoveFileRequest; +use Google\Cloud\Dataform\V1beta1\Repository; +use Google\Cloud\Dataform\V1beta1\ResetWorkspaceChangesRequest; +use Google\Cloud\Dataform\V1beta1\UpdateRepositoryRequest; +use Google\Cloud\Dataform\V1beta1\WorkflowInvocation; +use Google\Cloud\Dataform\V1beta1\Workspace; +use Google\Cloud\Dataform\V1beta1\WriteFileRequest; +use Google\Cloud\Dataform\V1beta1\WriteFileResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Dataform is a service to develop, create, document, test, and update curated + * tables in BigQuery. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface cancelWorkflowInvocationAsync(CancelWorkflowInvocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface commitWorkspaceChangesAsync(CommitWorkspaceChangesRequest $request, array $optionalArgs = []) + * @method PromiseInterface createCompilationResultAsync(CreateCompilationResultRequest $request, array $optionalArgs = []) + * @method PromiseInterface createRepositoryAsync(CreateRepositoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface createWorkflowInvocationAsync(CreateWorkflowInvocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface createWorkspaceAsync(CreateWorkspaceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteRepositoryAsync(DeleteRepositoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteWorkflowInvocationAsync(DeleteWorkflowInvocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteWorkspaceAsync(DeleteWorkspaceRequest $request, array $optionalArgs = []) + * @method PromiseInterface fetchFileDiffAsync(FetchFileDiffRequest $request, array $optionalArgs = []) + * @method PromiseInterface fetchFileGitStatusesAsync(FetchFileGitStatusesRequest $request, array $optionalArgs = []) + * @method PromiseInterface fetchGitAheadBehindAsync(FetchGitAheadBehindRequest $request, array $optionalArgs = []) + * @method PromiseInterface fetchRemoteBranchesAsync(FetchRemoteBranchesRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCompilationResultAsync(GetCompilationResultRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRepositoryAsync(GetRepositoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface getWorkflowInvocationAsync(GetWorkflowInvocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getWorkspaceAsync(GetWorkspaceRequest $request, array $optionalArgs = []) + * @method PromiseInterface installNpmPackagesAsync(InstallNpmPackagesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCompilationResultsAsync(ListCompilationResultsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listRepositoriesAsync(ListRepositoriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listWorkflowInvocationsAsync(ListWorkflowInvocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listWorkspacesAsync(ListWorkspacesRequest $request, array $optionalArgs = []) + * @method PromiseInterface makeDirectoryAsync(MakeDirectoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface moveDirectoryAsync(MoveDirectoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface moveFileAsync(MoveFileRequest $request, array $optionalArgs = []) + * @method PromiseInterface pullGitCommitsAsync(PullGitCommitsRequest $request, array $optionalArgs = []) + * @method PromiseInterface pushGitCommitsAsync(PushGitCommitsRequest $request, array $optionalArgs = []) + * @method PromiseInterface queryCompilationResultActionsAsync(QueryCompilationResultActionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface queryDirectoryContentsAsync(QueryDirectoryContentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface queryWorkflowInvocationActionsAsync(QueryWorkflowInvocationActionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface readFileAsync(ReadFileRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeDirectoryAsync(RemoveDirectoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeFileAsync(RemoveFileRequest $request, array $optionalArgs = []) + * @method PromiseInterface resetWorkspaceChangesAsync(ResetWorkspaceChangesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateRepositoryAsync(UpdateRepositoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface writeFileAsync(WriteFileRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class DataformClient extends DataformBaseClient +final class DataformClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DataformBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dataform.v1beta1.Dataform'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dataform.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/dataform_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/dataform_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/dataform_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/dataform_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * compilation_result resource. + * + * @param string $project + * @param string $location + * @param string $repository + * @param string $compilationResult + * + * @return string The formatted compilation_result resource. + * + * @experimental + */ + public static function compilationResultName(string $project, string $location, string $repository, string $compilationResult): string + { + return self::getPathTemplate('compilationResult')->render([ + 'project' => $project, + 'location' => $location, + 'repository' => $repository, + 'compilation_result' => $compilationResult, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + * + * @experimental + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a repository + * resource. + * + * @param string $project + * @param string $location + * @param string $repository + * + * @return string The formatted repository resource. + * + * @experimental + */ + public static function repositoryName(string $project, string $location, string $repository): string + { + return self::getPathTemplate('repository')->render([ + 'project' => $project, + 'location' => $location, + 'repository' => $repository, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * secret_version resource. + * + * @param string $project + * @param string $secret + * @param string $version + * + * @return string The formatted secret_version resource. + * + * @experimental + */ + public static function secretVersionName(string $project, string $secret, string $version): string + { + return self::getPathTemplate('secretVersion')->render([ + 'project' => $project, + 'secret' => $secret, + 'version' => $version, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * workflow_invocation resource. + * + * @param string $project + * @param string $location + * @param string $repository + * @param string $workflowInvocation + * + * @return string The formatted workflow_invocation resource. + * + * @experimental + */ + public static function workflowInvocationName(string $project, string $location, string $repository, string $workflowInvocation): string + { + return self::getPathTemplate('workflowInvocation')->render([ + 'project' => $project, + 'location' => $location, + 'repository' => $repository, + 'workflow_invocation' => $workflowInvocation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a workspace + * resource. + * + * @param string $project + * @param string $location + * @param string $repository + * @param string $workspace + * + * @return string The formatted workspace resource. + * + * @experimental + */ + public static function workspaceName(string $project, string $location, string $repository, string $workspace): string + { + return self::getPathTemplate('workspace')->render([ + 'project' => $project, + 'location' => $location, + 'repository' => $repository, + 'workspace' => $workspace, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - compilationResult: projects/{project}/locations/{location}/repositories/{repository}/compilationResults/{compilation_result} + * - location: projects/{project}/locations/{location} + * - repository: projects/{project}/locations/{location}/repositories/{repository} + * - secretVersion: projects/{project}/secrets/{secret}/versions/{version} + * - workflowInvocation: projects/{project}/locations/{location}/repositories/{repository}/workflowInvocations/{workflow_invocation} + * - workspace: projects/{project}/locations/{location}/repositories/{repository}/workspaces/{workspace} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dataform.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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Requests cancellation of a running WorkflowInvocation. + * + * The async variant is {@see DataformClient::cancelWorkflowInvocationAsync()} . + * + * @example samples/V1beta1/DataformClient/cancel_workflow_invocation.php + * + * @param CancelWorkflowInvocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function cancelWorkflowInvocation(CancelWorkflowInvocationRequest $request, array $callOptions = []): void + { + $this->startApiCall('CancelWorkflowInvocation', $request, $callOptions)->wait(); + } + + /** + * Applies a Git commit for uncommitted files in a Workspace. + * + * The async variant is {@see DataformClient::commitWorkspaceChangesAsync()} . + * + * @example samples/V1beta1/DataformClient/commit_workspace_changes.php + * + * @param CommitWorkspaceChangesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function commitWorkspaceChanges(CommitWorkspaceChangesRequest $request, array $callOptions = []): void + { + $this->startApiCall('CommitWorkspaceChanges', $request, $callOptions)->wait(); + } + + /** + * Creates a new CompilationResult in a given project and location. + * + * The async variant is {@see DataformClient::createCompilationResultAsync()} . + * + * @example samples/V1beta1/DataformClient/create_compilation_result.php + * + * @param CreateCompilationResultRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CompilationResult + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createCompilationResult(CreateCompilationResultRequest $request, array $callOptions = []): CompilationResult + { + return $this->startApiCall('CreateCompilationResult', $request, $callOptions)->wait(); + } + + /** + * Creates a new Repository in a given project and location. + * + * The async variant is {@see DataformClient::createRepositoryAsync()} . + * + * @example samples/V1beta1/DataformClient/create_repository.php + * + * @param CreateRepositoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Repository + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createRepository(CreateRepositoryRequest $request, array $callOptions = []): Repository + { + return $this->startApiCall('CreateRepository', $request, $callOptions)->wait(); + } + + /** + * Creates a new WorkflowInvocation in a given Repository. + * + * The async variant is {@see DataformClient::createWorkflowInvocationAsync()} . + * + * @example samples/V1beta1/DataformClient/create_workflow_invocation.php + * + * @param CreateWorkflowInvocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 WorkflowInvocation + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createWorkflowInvocation(CreateWorkflowInvocationRequest $request, array $callOptions = []): WorkflowInvocation + { + return $this->startApiCall('CreateWorkflowInvocation', $request, $callOptions)->wait(); + } + + /** + * Creates a new Workspace in a given Repository. + * + * The async variant is {@see DataformClient::createWorkspaceAsync()} . + * + * @example samples/V1beta1/DataformClient/create_workspace.php + * + * @param CreateWorkspaceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Workspace + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createWorkspace(CreateWorkspaceRequest $request, array $callOptions = []): Workspace + { + return $this->startApiCall('CreateWorkspace', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Repository. + * + * The async variant is {@see DataformClient::deleteRepositoryAsync()} . + * + * @example samples/V1beta1/DataformClient/delete_repository.php + * + * @param DeleteRepositoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteRepository(DeleteRepositoryRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteRepository', $request, $callOptions)->wait(); + } + + /** + * Deletes a single WorkflowInvocation. + * + * The async variant is {@see DataformClient::deleteWorkflowInvocationAsync()} . + * + * @example samples/V1beta1/DataformClient/delete_workflow_invocation.php + * + * @param DeleteWorkflowInvocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteWorkflowInvocation(DeleteWorkflowInvocationRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteWorkflowInvocation', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Workspace. + * + * The async variant is {@see DataformClient::deleteWorkspaceAsync()} . + * + * @example samples/V1beta1/DataformClient/delete_workspace.php + * + * @param DeleteWorkspaceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteWorkspace(DeleteWorkspaceRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteWorkspace', $request, $callOptions)->wait(); + } + + /** + * Fetches Git diff for an uncommitted file in a Workspace. + * + * The async variant is {@see DataformClient::fetchFileDiffAsync()} . + * + * @example samples/V1beta1/DataformClient/fetch_file_diff.php + * + * @param FetchFileDiffRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FetchFileDiffResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function fetchFileDiff(FetchFileDiffRequest $request, array $callOptions = []): FetchFileDiffResponse + { + return $this->startApiCall('FetchFileDiff', $request, $callOptions)->wait(); + } + + /** + * Fetches Git statuses for the files in a Workspace. + * + * The async variant is {@see DataformClient::fetchFileGitStatusesAsync()} . + * + * @example samples/V1beta1/DataformClient/fetch_file_git_statuses.php + * + * @param FetchFileGitStatusesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FetchFileGitStatusesResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function fetchFileGitStatuses(FetchFileGitStatusesRequest $request, array $callOptions = []): FetchFileGitStatusesResponse + { + return $this->startApiCall('FetchFileGitStatuses', $request, $callOptions)->wait(); + } + + /** + * Fetches Git ahead/behind against a remote branch. + * + * The async variant is {@see DataformClient::fetchGitAheadBehindAsync()} . + * + * @example samples/V1beta1/DataformClient/fetch_git_ahead_behind.php + * + * @param FetchGitAheadBehindRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FetchGitAheadBehindResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function fetchGitAheadBehind(FetchGitAheadBehindRequest $request, array $callOptions = []): FetchGitAheadBehindResponse + { + return $this->startApiCall('FetchGitAheadBehind', $request, $callOptions)->wait(); + } + + /** + * Fetches a Repository's remote branches. + * + * The async variant is {@see DataformClient::fetchRemoteBranchesAsync()} . + * + * @example samples/V1beta1/DataformClient/fetch_remote_branches.php + * + * @param FetchRemoteBranchesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FetchRemoteBranchesResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function fetchRemoteBranches(FetchRemoteBranchesRequest $request, array $callOptions = []): FetchRemoteBranchesResponse + { + return $this->startApiCall('FetchRemoteBranches', $request, $callOptions)->wait(); + } + + /** + * Fetches a single CompilationResult. + * + * The async variant is {@see DataformClient::getCompilationResultAsync()} . + * + * @example samples/V1beta1/DataformClient/get_compilation_result.php + * + * @param GetCompilationResultRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CompilationResult + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getCompilationResult(GetCompilationResultRequest $request, array $callOptions = []): CompilationResult + { + return $this->startApiCall('GetCompilationResult', $request, $callOptions)->wait(); + } + + /** + * Fetches a single Repository. + * + * The async variant is {@see DataformClient::getRepositoryAsync()} . + * + * @example samples/V1beta1/DataformClient/get_repository.php + * + * @param GetRepositoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Repository + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getRepository(GetRepositoryRequest $request, array $callOptions = []): Repository + { + return $this->startApiCall('GetRepository', $request, $callOptions)->wait(); + } + + /** + * Fetches a single WorkflowInvocation. + * + * The async variant is {@see DataformClient::getWorkflowInvocationAsync()} . + * + * @example samples/V1beta1/DataformClient/get_workflow_invocation.php + * + * @param GetWorkflowInvocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 WorkflowInvocation + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getWorkflowInvocation(GetWorkflowInvocationRequest $request, array $callOptions = []): WorkflowInvocation + { + return $this->startApiCall('GetWorkflowInvocation', $request, $callOptions)->wait(); + } + + /** + * Fetches a single Workspace. + * + * The async variant is {@see DataformClient::getWorkspaceAsync()} . + * + * @example samples/V1beta1/DataformClient/get_workspace.php + * + * @param GetWorkspaceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Workspace + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getWorkspace(GetWorkspaceRequest $request, array $callOptions = []): Workspace + { + return $this->startApiCall('GetWorkspace', $request, $callOptions)->wait(); + } + + /** + * Installs dependency NPM packages (inside a Workspace). + * + * The async variant is {@see DataformClient::installNpmPackagesAsync()} . + * + * @example samples/V1beta1/DataformClient/install_npm_packages.php + * + * @param InstallNpmPackagesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InstallNpmPackagesResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function installNpmPackages(InstallNpmPackagesRequest $request, array $callOptions = []): InstallNpmPackagesResponse + { + return $this->startApiCall('InstallNpmPackages', $request, $callOptions)->wait(); + } + + /** + * Lists CompilationResults in a given Repository. + * + * The async variant is {@see DataformClient::listCompilationResultsAsync()} . + * + * @example samples/V1beta1/DataformClient/list_compilation_results.php + * + * @param ListCompilationResultsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listCompilationResults(ListCompilationResultsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCompilationResults', $request, $callOptions); + } + + /** + * Lists Repositories in a given project and location. + * + * The async variant is {@see DataformClient::listRepositoriesAsync()} . + * + * @example samples/V1beta1/DataformClient/list_repositories.php + * + * @param ListRepositoriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listRepositories(ListRepositoriesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListRepositories', $request, $callOptions); + } + + /** + * Lists WorkflowInvocations in a given Repository. + * + * The async variant is {@see DataformClient::listWorkflowInvocationsAsync()} . + * + * @example samples/V1beta1/DataformClient/list_workflow_invocations.php + * + * @param ListWorkflowInvocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listWorkflowInvocations(ListWorkflowInvocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListWorkflowInvocations', $request, $callOptions); + } + + /** + * Lists Workspaces in a given Repository. + * + * The async variant is {@see DataformClient::listWorkspacesAsync()} . + * + * @example samples/V1beta1/DataformClient/list_workspaces.php + * + * @param ListWorkspacesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listWorkspaces(ListWorkspacesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListWorkspaces', $request, $callOptions); + } + + /** + * Creates a directory inside a Workspace. + * + * The async variant is {@see DataformClient::makeDirectoryAsync()} . + * + * @example samples/V1beta1/DataformClient/make_directory.php + * + * @param MakeDirectoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MakeDirectoryResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function makeDirectory(MakeDirectoryRequest $request, array $callOptions = []): MakeDirectoryResponse + { + return $this->startApiCall('MakeDirectory', $request, $callOptions)->wait(); + } + + /** + * Moves a directory (inside a Workspace), and all of its contents, to a new + * location. + * + * The async variant is {@see DataformClient::moveDirectoryAsync()} . + * + * @example samples/V1beta1/DataformClient/move_directory.php + * + * @param MoveDirectoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MoveDirectoryResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function moveDirectory(MoveDirectoryRequest $request, array $callOptions = []): MoveDirectoryResponse + { + return $this->startApiCall('MoveDirectory', $request, $callOptions)->wait(); + } + + /** + * Moves a file (inside a Workspace) to a new location. + * + * The async variant is {@see DataformClient::moveFileAsync()} . + * + * @example samples/V1beta1/DataformClient/move_file.php + * + * @param MoveFileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MoveFileResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function moveFile(MoveFileRequest $request, array $callOptions = []): MoveFileResponse + { + return $this->startApiCall('MoveFile', $request, $callOptions)->wait(); + } + + /** + * Pulls Git commits from the Repository's remote into a Workspace. + * + * The async variant is {@see DataformClient::pullGitCommitsAsync()} . + * + * @example samples/V1beta1/DataformClient/pull_git_commits.php + * + * @param PullGitCommitsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function pullGitCommits(PullGitCommitsRequest $request, array $callOptions = []): void + { + $this->startApiCall('PullGitCommits', $request, $callOptions)->wait(); + } + + /** + * Pushes Git commits from a Workspace to the Repository's remote. + * + * The async variant is {@see DataformClient::pushGitCommitsAsync()} . + * + * @example samples/V1beta1/DataformClient/push_git_commits.php + * + * @param PushGitCommitsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function pushGitCommits(PushGitCommitsRequest $request, array $callOptions = []): void + { + $this->startApiCall('PushGitCommits', $request, $callOptions)->wait(); + } + + /** + * Returns CompilationResultActions in a given CompilationResult. + * + * The async variant is {@see DataformClient::queryCompilationResultActionsAsync()} + * . + * + * @example samples/V1beta1/DataformClient/query_compilation_result_actions.php + * + * @param QueryCompilationResultActionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function queryCompilationResultActions(QueryCompilationResultActionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('QueryCompilationResultActions', $request, $callOptions); + } + + /** + * Returns the contents of a given Workspace directory. + * + * The async variant is {@see DataformClient::queryDirectoryContentsAsync()} . + * + * @example samples/V1beta1/DataformClient/query_directory_contents.php + * + * @param QueryDirectoryContentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function queryDirectoryContents(QueryDirectoryContentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('QueryDirectoryContents', $request, $callOptions); + } + + /** + * Returns WorkflowInvocationActions in a given WorkflowInvocation. + * + * The async variant is + * {@see DataformClient::queryWorkflowInvocationActionsAsync()} . + * + * @example samples/V1beta1/DataformClient/query_workflow_invocation_actions.php + * + * @param QueryWorkflowInvocationActionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function queryWorkflowInvocationActions(QueryWorkflowInvocationActionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('QueryWorkflowInvocationActions', $request, $callOptions); + } + + /** + * Returns the contents of a file (inside a Workspace). + * + * The async variant is {@see DataformClient::readFileAsync()} . + * + * @example samples/V1beta1/DataformClient/read_file.php + * + * @param ReadFileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ReadFileResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function readFile(ReadFileRequest $request, array $callOptions = []): ReadFileResponse + { + return $this->startApiCall('ReadFile', $request, $callOptions)->wait(); + } + + /** + * Deletes a directory (inside a Workspace) and all of its contents. + * + * The async variant is {@see DataformClient::removeDirectoryAsync()} . + * + * @example samples/V1beta1/DataformClient/remove_directory.php + * + * @param RemoveDirectoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function removeDirectory(RemoveDirectoryRequest $request, array $callOptions = []): void + { + $this->startApiCall('RemoveDirectory', $request, $callOptions)->wait(); + } + + /** + * Deletes a file (inside a Workspace). + * + * The async variant is {@see DataformClient::removeFileAsync()} . + * + * @example samples/V1beta1/DataformClient/remove_file.php + * + * @param RemoveFileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function removeFile(RemoveFileRequest $request, array $callOptions = []): void + { + $this->startApiCall('RemoveFile', $request, $callOptions)->wait(); + } + + /** + * Performs a Git reset for uncommitted files in a Workspace. + * + * The async variant is {@see DataformClient::resetWorkspaceChangesAsync()} . + * + * @example samples/V1beta1/DataformClient/reset_workspace_changes.php + * + * @param ResetWorkspaceChangesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function resetWorkspaceChanges(ResetWorkspaceChangesRequest $request, array $callOptions = []): void + { + $this->startApiCall('ResetWorkspaceChanges', $request, $callOptions)->wait(); + } + + /** + * Updates a single Repository. + * + * The async variant is {@see DataformClient::updateRepositoryAsync()} . + * + * @example samples/V1beta1/DataformClient/update_repository.php + * + * @param UpdateRepositoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Repository + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function updateRepository(UpdateRepositoryRequest $request, array $callOptions = []): Repository + { + return $this->startApiCall('UpdateRepository', $request, $callOptions)->wait(); + } + + /** + * Writes to a file (inside a Workspace). + * + * The async variant is {@see DataformClient::writeFileAsync()} . + * + * @example samples/V1beta1/DataformClient/write_file.php + * + * @param WriteFileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 WriteFileResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function writeFile(WriteFileRequest $request, array $callOptions = []): WriteFileResponse + { + return $this->startApiCall('WriteFile', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see DataformClient::getLocationAsync()} . + * + * @example samples/V1beta1/DataformClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see DataformClient::listLocationsAsync()} . + * + * @example samples/V1beta1/DataformClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Dataplex/composer.json b/Dataplex/composer.json index 6765fbb927fd..b15d8260a7c5 100644 --- a/Dataplex/composer.json +++ b/Dataplex/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Dataplex/metadata/V1/DataQuality.php b/Dataplex/metadata/V1/DataQuality.php index c9051dac7828..d0ba14beaf9d 100644 Binary files a/Dataplex/metadata/V1/DataQuality.php and b/Dataplex/metadata/V1/DataQuality.php differ diff --git a/Dataplex/src/V1/Client/BaseClient/ContentServiceBaseClient.php b/Dataplex/src/V1/Client/BaseClient/ContentServiceBaseClient.php deleted file mode 100644 index 0d8186deecc2..000000000000 --- a/Dataplex/src/V1/Client/BaseClient/ContentServiceBaseClient.php +++ /dev/null @@ -1,533 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/content_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/content_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/content_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/content_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a content - * resource. - * - * @param string $project - * @param string $location - * @param string $lake - * @param string $content - * - * @return string The formatted content resource. - */ - public static function contentName(string $project, string $location, string $lake, string $content): string - { - return self::getPathTemplate('content')->render([ - 'project' => $project, - 'location' => $location, - 'lake' => $lake, - 'content' => $content, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a lake - * resource. - * - * @param string $project - * @param string $location - * @param string $lake - * - * @return string The formatted lake resource. - */ - public static function lakeName(string $project, string $location, string $lake): string - { - return self::getPathTemplate('lake')->render([ - 'project' => $project, - 'location' => $location, - 'lake' => $lake, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - content: projects/{project}/locations/{location}/lakes/{lake}/content/{content} - * - lake: projects/{project}/locations/{location}/lakes/{lake} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dataplex.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Create a content. - * - * The async variant is {@see self::createContentAsync()} . - * - * @example samples/V1/ContentServiceClient/create_content.php - * - * @param CreateContentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Content - * - * @throws ApiException Thrown if the API call fails. - */ - public function createContent(CreateContentRequest $request, array $callOptions = []): Content - { - return $this->startApiCall('CreateContent', $request, $callOptions)->wait(); - } - - /** - * Delete a content. - * - * The async variant is {@see self::deleteContentAsync()} . - * - * @example samples/V1/ContentServiceClient/delete_content.php - * - * @param DeleteContentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteContent(DeleteContentRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteContent', $request, $callOptions)->wait(); - } - - /** - * Get a content resource. - * - * The async variant is {@see self::getContentAsync()} . - * - * @example samples/V1/ContentServiceClient/get_content.php - * - * @param GetContentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Content - * - * @throws ApiException Thrown if the API call fails. - */ - public function getContent(GetContentRequest $request, array $callOptions = []): Content - { - return $this->startApiCall('GetContent', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a contentitem resource. A `NOT_FOUND` - * error is returned if the resource does not exist. An empty policy is - * returned if the resource exists but does not have a policy set on it. - * - * Caller must have Google IAM `dataplex.content.getIamPolicy` permission - * on the resource. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/ContentServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * List content. - * - * The async variant is {@see self::listContentAsync()} . - * - * @example samples/V1/ContentServiceClient/list_content.php - * - * @param ListContentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listContent(ListContentRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListContent', $request, $callOptions); - } - - /** - * Sets the access control policy on the specified contentitem resource. - * Replaces any existing policy. - * - * Caller must have Google IAM `dataplex.content.setIamPolicy` permission - * on the resource. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/ContentServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns the caller's permissions on a resource. - * If the resource does not exist, an empty set of - * permissions is returned (a `NOT_FOUND` error is not returned). - * - * A caller is not required to have Google IAM permission to make this - * request. - * - * Note: This operation is designed to be used for building permission-aware - * UIs and command-line tools, not for authorization checking. This operation - * may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/ContentServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Update a content. Only supports full resource update. - * - * The async variant is {@see self::updateContentAsync()} . - * - * @example samples/V1/ContentServiceClient/update_content.php - * - * @param UpdateContentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Content - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateContent(UpdateContentRequest $request, array $callOptions = []): Content - { - return $this->startApiCall('UpdateContent', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/ContentServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/ContentServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dataplex/src/V1/Client/BaseClient/DataScanServiceBaseClient.php b/Dataplex/src/V1/Client/BaseClient/DataScanServiceBaseClient.php deleted file mode 100644 index aa72e4013c9c..000000000000 --- a/Dataplex/src/V1/Client/BaseClient/DataScanServiceBaseClient.php +++ /dev/null @@ -1,693 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/data_scan_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/data_scan_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/data_scan_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/data_scan_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a data_scan - * resource. - * - * @param string $project - * @param string $location - * @param string $dataScan - * - * @return string The formatted data_scan resource. - */ - public static function dataScanName(string $project, string $location, string $dataScan): string - { - return self::getPathTemplate('dataScan')->render([ - 'project' => $project, - 'location' => $location, - 'dataScan' => $dataScan, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * data_scan_job resource. - * - * @param string $project - * @param string $location - * @param string $dataScan - * @param string $job - * - * @return string The formatted data_scan_job resource. - */ - public static function dataScanJobName(string $project, string $location, string $dataScan, string $job): string - { - return self::getPathTemplate('dataScanJob')->render([ - 'project' => $project, - 'location' => $location, - 'dataScan' => $dataScan, - 'job' => $job, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a entity - * resource. - * - * @param string $project - * @param string $location - * @param string $lake - * @param string $zone - * @param string $entity - * - * @return string The formatted entity resource. - */ - public static function entityName(string $project, string $location, string $lake, string $zone, string $entity): string - { - return self::getPathTemplate('entity')->render([ - 'project' => $project, - 'location' => $location, - 'lake' => $lake, - 'zone' => $zone, - 'entity' => $entity, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - dataScan: projects/{project}/locations/{location}/dataScans/{dataScan} - * - dataScanJob: projects/{project}/locations/{location}/dataScans/{dataScan}/jobs/{job} - * - entity: projects/{project}/locations/{location}/lakes/{lake}/zones/{zone}/entities/{entity} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dataplex.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a DataScan resource. - * - * The async variant is {@see self::createDataScanAsync()} . - * - * @example samples/V1/DataScanServiceClient/create_data_scan.php - * - * @param CreateDataScanRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDataScan(CreateDataScanRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateDataScan', $request, $callOptions)->wait(); - } - - /** - * Deletes a DataScan resource. - * - * The async variant is {@see self::deleteDataScanAsync()} . - * - * @example samples/V1/DataScanServiceClient/delete_data_scan.php - * - * @param DeleteDataScanRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDataScan(DeleteDataScanRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteDataScan', $request, $callOptions)->wait(); - } - - /** - * Gets a DataScan resource. - * - * The async variant is {@see self::getDataScanAsync()} . - * - * @example samples/V1/DataScanServiceClient/get_data_scan.php - * - * @param GetDataScanRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataScan - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDataScan(GetDataScanRequest $request, array $callOptions = []): DataScan - { - return $this->startApiCall('GetDataScan', $request, $callOptions)->wait(); - } - - /** - * Gets a DataScanJob resource. - * - * The async variant is {@see self::getDataScanJobAsync()} . - * - * @example samples/V1/DataScanServiceClient/get_data_scan_job.php - * - * @param GetDataScanJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataScanJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDataScanJob(GetDataScanJobRequest $request, array $callOptions = []): DataScanJob - { - return $this->startApiCall('GetDataScanJob', $request, $callOptions)->wait(); - } - - /** - * Lists DataScanJobs under the given DataScan. - * - * The async variant is {@see self::listDataScanJobsAsync()} . - * - * @example samples/V1/DataScanServiceClient/list_data_scan_jobs.php - * - * @param ListDataScanJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDataScanJobs(ListDataScanJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDataScanJobs', $request, $callOptions); - } - - /** - * Lists DataScans. - * - * The async variant is {@see self::listDataScansAsync()} . - * - * @example samples/V1/DataScanServiceClient/list_data_scans.php - * - * @param ListDataScansRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDataScans(ListDataScansRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDataScans', $request, $callOptions); - } - - /** - * Runs an on-demand execution of a DataScan - * - * The async variant is {@see self::runDataScanAsync()} . - * - * @example samples/V1/DataScanServiceClient/run_data_scan.php - * - * @param RunDataScanRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RunDataScanResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function runDataScan(RunDataScanRequest $request, array $callOptions = []): RunDataScanResponse - { - return $this->startApiCall('RunDataScan', $request, $callOptions)->wait(); - } - - /** - * Updates a DataScan resource. - * - * The async variant is {@see self::updateDataScanAsync()} . - * - * @example samples/V1/DataScanServiceClient/update_data_scan.php - * - * @param UpdateDataScanRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDataScan(UpdateDataScanRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateDataScan', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/DataScanServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/DataScanServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/DataScanServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/DataScanServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/DataScanServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dataplex/src/V1/Client/BaseClient/DataTaxonomyServiceBaseClient.php b/Dataplex/src/V1/Client/BaseClient/DataTaxonomyServiceBaseClient.php deleted file mode 100644 index 911b7402a850..000000000000 --- a/Dataplex/src/V1/Client/BaseClient/DataTaxonomyServiceBaseClient.php +++ /dev/null @@ -1,888 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/data_taxonomy_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/data_taxonomy_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/data_taxonomy_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/data_taxonomy_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * data_attribute resource. - * - * @param string $project - * @param string $location - * @param string $dataTaxonomy - * @param string $dataAttributeId - * - * @return string The formatted data_attribute resource. - */ - public static function dataAttributeName(string $project, string $location, string $dataTaxonomy, string $dataAttributeId): string - { - return self::getPathTemplate('dataAttribute')->render([ - 'project' => $project, - 'location' => $location, - 'dataTaxonomy' => $dataTaxonomy, - 'data_attribute_id' => $dataAttributeId, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * data_attribute_binding resource. - * - * @param string $project - * @param string $location - * @param string $dataAttributeBindingId - * - * @return string The formatted data_attribute_binding resource. - */ - public static function dataAttributeBindingName(string $project, string $location, string $dataAttributeBindingId): string - { - return self::getPathTemplate('dataAttributeBinding')->render([ - 'project' => $project, - 'location' => $location, - 'data_attribute_binding_id' => $dataAttributeBindingId, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * data_taxonomy resource. - * - * @param string $project - * @param string $location - * @param string $dataTaxonomyId - * - * @return string The formatted data_taxonomy resource. - */ - public static function dataTaxonomyName(string $project, string $location, string $dataTaxonomyId): string - { - return self::getPathTemplate('dataTaxonomy')->render([ - 'project' => $project, - 'location' => $location, - 'data_taxonomy_id' => $dataTaxonomyId, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - dataAttribute: projects/{project}/locations/{location}/dataTaxonomies/{dataTaxonomy}/attributes/{data_attribute_id} - * - dataAttributeBinding: projects/{project}/locations/{location}/dataAttributeBindings/{data_attribute_binding_id} - * - dataTaxonomy: projects/{project}/locations/{location}/dataTaxonomies/{data_taxonomy_id} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dataplex.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Create a DataAttribute resource. - * - * The async variant is {@see self::createDataAttributeAsync()} . - * - * @example samples/V1/DataTaxonomyServiceClient/create_data_attribute.php - * - * @param CreateDataAttributeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDataAttribute(CreateDataAttributeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateDataAttribute', $request, $callOptions)->wait(); - } - - /** - * Create a DataAttributeBinding resource. - * - * The async variant is {@see self::createDataAttributeBindingAsync()} . - * - * @example samples/V1/DataTaxonomyServiceClient/create_data_attribute_binding.php - * - * @param CreateDataAttributeBindingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDataAttributeBinding(CreateDataAttributeBindingRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateDataAttributeBinding', $request, $callOptions)->wait(); - } - - /** - * Create a DataTaxonomy resource. - * - * The async variant is {@see self::createDataTaxonomyAsync()} . - * - * @example samples/V1/DataTaxonomyServiceClient/create_data_taxonomy.php - * - * @param CreateDataTaxonomyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDataTaxonomy(CreateDataTaxonomyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateDataTaxonomy', $request, $callOptions)->wait(); - } - - /** - * Deletes a Data Attribute resource. - * - * The async variant is {@see self::deleteDataAttributeAsync()} . - * - * @example samples/V1/DataTaxonomyServiceClient/delete_data_attribute.php - * - * @param DeleteDataAttributeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDataAttribute(DeleteDataAttributeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteDataAttribute', $request, $callOptions)->wait(); - } - - /** - * Deletes a DataAttributeBinding resource. All attributes within the - * DataAttributeBinding must be deleted before the DataAttributeBinding can be - * deleted. - * - * The async variant is {@see self::deleteDataAttributeBindingAsync()} . - * - * @example samples/V1/DataTaxonomyServiceClient/delete_data_attribute_binding.php - * - * @param DeleteDataAttributeBindingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDataAttributeBinding(DeleteDataAttributeBindingRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteDataAttributeBinding', $request, $callOptions)->wait(); - } - - /** - * Deletes a DataTaxonomy resource. All attributes within the DataTaxonomy - * must be deleted before the DataTaxonomy can be deleted. - * - * The async variant is {@see self::deleteDataTaxonomyAsync()} . - * - * @example samples/V1/DataTaxonomyServiceClient/delete_data_taxonomy.php - * - * @param DeleteDataTaxonomyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDataTaxonomy(DeleteDataTaxonomyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteDataTaxonomy', $request, $callOptions)->wait(); - } - - /** - * Retrieves a Data Attribute resource. - * - * The async variant is {@see self::getDataAttributeAsync()} . - * - * @example samples/V1/DataTaxonomyServiceClient/get_data_attribute.php - * - * @param GetDataAttributeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataAttribute - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDataAttribute(GetDataAttributeRequest $request, array $callOptions = []): DataAttribute - { - return $this->startApiCall('GetDataAttribute', $request, $callOptions)->wait(); - } - - /** - * Retrieves a DataAttributeBinding resource. - * - * The async variant is {@see self::getDataAttributeBindingAsync()} . - * - * @example samples/V1/DataTaxonomyServiceClient/get_data_attribute_binding.php - * - * @param GetDataAttributeBindingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataAttributeBinding - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDataAttributeBinding(GetDataAttributeBindingRequest $request, array $callOptions = []): DataAttributeBinding - { - return $this->startApiCall('GetDataAttributeBinding', $request, $callOptions)->wait(); - } - - /** - * Retrieves a DataTaxonomy resource. - * - * The async variant is {@see self::getDataTaxonomyAsync()} . - * - * @example samples/V1/DataTaxonomyServiceClient/get_data_taxonomy.php - * - * @param GetDataTaxonomyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DataTaxonomy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDataTaxonomy(GetDataTaxonomyRequest $request, array $callOptions = []): DataTaxonomy - { - return $this->startApiCall('GetDataTaxonomy', $request, $callOptions)->wait(); - } - - /** - * Lists DataAttributeBinding resources in a project and location. - * - * The async variant is {@see self::listDataAttributeBindingsAsync()} . - * - * @example samples/V1/DataTaxonomyServiceClient/list_data_attribute_bindings.php - * - * @param ListDataAttributeBindingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDataAttributeBindings(ListDataAttributeBindingsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDataAttributeBindings', $request, $callOptions); - } - - /** - * Lists Data Attribute resources in a DataTaxonomy. - * - * The async variant is {@see self::listDataAttributesAsync()} . - * - * @example samples/V1/DataTaxonomyServiceClient/list_data_attributes.php - * - * @param ListDataAttributesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDataAttributes(ListDataAttributesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDataAttributes', $request, $callOptions); - } - - /** - * Lists DataTaxonomy resources in a project and location. - * - * The async variant is {@see self::listDataTaxonomiesAsync()} . - * - * @example samples/V1/DataTaxonomyServiceClient/list_data_taxonomies.php - * - * @param ListDataTaxonomiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDataTaxonomies(ListDataTaxonomiesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDataTaxonomies', $request, $callOptions); - } - - /** - * Updates a DataAttribute resource. - * - * The async variant is {@see self::updateDataAttributeAsync()} . - * - * @example samples/V1/DataTaxonomyServiceClient/update_data_attribute.php - * - * @param UpdateDataAttributeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDataAttribute(UpdateDataAttributeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateDataAttribute', $request, $callOptions)->wait(); - } - - /** - * Updates a DataAttributeBinding resource. - * - * The async variant is {@see self::updateDataAttributeBindingAsync()} . - * - * @example samples/V1/DataTaxonomyServiceClient/update_data_attribute_binding.php - * - * @param UpdateDataAttributeBindingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDataAttributeBinding(UpdateDataAttributeBindingRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateDataAttributeBinding', $request, $callOptions)->wait(); - } - - /** - * Updates a DataTaxonomy resource. - * - * The async variant is {@see self::updateDataTaxonomyAsync()} . - * - * @example samples/V1/DataTaxonomyServiceClient/update_data_taxonomy.php - * - * @param UpdateDataTaxonomyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDataTaxonomy(UpdateDataTaxonomyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateDataTaxonomy', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/DataTaxonomyServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/DataTaxonomyServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/DataTaxonomyServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/DataTaxonomyServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/DataTaxonomyServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dataplex/src/V1/Client/BaseClient/DataplexServiceBaseClient.php b/Dataplex/src/V1/Client/BaseClient/DataplexServiceBaseClient.php deleted file mode 100644 index 766f7eee283a..000000000000 --- a/Dataplex/src/V1/Client/BaseClient/DataplexServiceBaseClient.php +++ /dev/null @@ -1,1469 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/dataplex_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/dataplex_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/dataplex_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/dataplex_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a asset - * resource. - * - * @param string $project - * @param string $location - * @param string $lake - * @param string $zone - * @param string $asset - * - * @return string The formatted asset resource. - */ - public static function assetName(string $project, string $location, string $lake, string $zone, string $asset): string - { - return self::getPathTemplate('asset')->render([ - 'project' => $project, - 'location' => $location, - 'lake' => $lake, - 'zone' => $zone, - 'asset' => $asset, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a environment - * resource. - * - * @param string $project - * @param string $location - * @param string $lake - * @param string $environment - * - * @return string The formatted environment resource. - */ - public static function environmentName(string $project, string $location, string $lake, string $environment): string - { - return self::getPathTemplate('environment')->render([ - 'project' => $project, - 'location' => $location, - 'lake' => $lake, - 'environment' => $environment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a job - * resource. - * - * @param string $project - * @param string $location - * @param string $lake - * @param string $task - * @param string $job - * - * @return string The formatted job resource. - */ - public static function jobName(string $project, string $location, string $lake, string $task, string $job): string - { - return self::getPathTemplate('job')->render([ - 'project' => $project, - 'location' => $location, - 'lake' => $lake, - 'task' => $task, - 'job' => $job, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a lake - * resource. - * - * @param string $project - * @param string $location - * @param string $lake - * - * @return string The formatted lake resource. - */ - public static function lakeName(string $project, string $location, string $lake): string - { - return self::getPathTemplate('lake')->render([ - 'project' => $project, - 'location' => $location, - 'lake' => $lake, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a task - * resource. - * - * @param string $project - * @param string $location - * @param string $lake - * @param string $task - * - * @return string The formatted task resource. - */ - public static function taskName(string $project, string $location, string $lake, string $task): string - { - return self::getPathTemplate('task')->render([ - 'project' => $project, - 'location' => $location, - 'lake' => $lake, - 'task' => $task, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a zone - * resource. - * - * @param string $project - * @param string $location - * @param string $lake - * @param string $zone - * - * @return string The formatted zone resource. - */ - public static function zoneName(string $project, string $location, string $lake, string $zone): string - { - return self::getPathTemplate('zone')->render([ - 'project' => $project, - 'location' => $location, - 'lake' => $lake, - 'zone' => $zone, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - asset: projects/{project}/locations/{location}/lakes/{lake}/zones/{zone}/assets/{asset} - * - environment: projects/{project}/locations/{location}/lakes/{lake}/environments/{environment} - * - job: projects/{project}/locations/{location}/lakes/{lake}/tasks/{task}/jobs/{job} - * - lake: projects/{project}/locations/{location}/lakes/{lake} - * - location: projects/{project}/locations/{location} - * - task: projects/{project}/locations/{location}/lakes/{lake}/tasks/{task} - * - zone: projects/{project}/locations/{location}/lakes/{lake}/zones/{zone} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dataplex.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Cancel jobs running for the task resource. - * - * The async variant is {@see self::cancelJobAsync()} . - * - * @example samples/V1/DataplexServiceClient/cancel_job.php - * - * @param CancelJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function cancelJob(CancelJobRequest $request, array $callOptions = []): void - { - $this->startApiCall('CancelJob', $request, $callOptions)->wait(); - } - - /** - * Creates an asset resource. - * - * The async variant is {@see self::createAssetAsync()} . - * - * @example samples/V1/DataplexServiceClient/create_asset.php - * - * @param CreateAssetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAsset(CreateAssetRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateAsset', $request, $callOptions)->wait(); - } - - /** - * Create an environment resource. - * - * The async variant is {@see self::createEnvironmentAsync()} . - * - * @example samples/V1/DataplexServiceClient/create_environment.php - * - * @param CreateEnvironmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createEnvironment(CreateEnvironmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateEnvironment', $request, $callOptions)->wait(); - } - - /** - * Creates a lake resource. - * - * The async variant is {@see self::createLakeAsync()} . - * - * @example samples/V1/DataplexServiceClient/create_lake.php - * - * @param CreateLakeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createLake(CreateLakeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateLake', $request, $callOptions)->wait(); - } - - /** - * Creates a task resource within a lake. - * - * The async variant is {@see self::createTaskAsync()} . - * - * @example samples/V1/DataplexServiceClient/create_task.php - * - * @param CreateTaskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTask(CreateTaskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateTask', $request, $callOptions)->wait(); - } - - /** - * Creates a zone resource within a lake. - * - * The async variant is {@see self::createZoneAsync()} . - * - * @example samples/V1/DataplexServiceClient/create_zone.php - * - * @param CreateZoneRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createZone(CreateZoneRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateZone', $request, $callOptions)->wait(); - } - - /** - * Deletes an asset resource. The referenced storage resource is detached - * (default) or deleted based on the associated Lifecycle policy. - * - * The async variant is {@see self::deleteAssetAsync()} . - * - * @example samples/V1/DataplexServiceClient/delete_asset.php - * - * @param DeleteAssetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAsset(DeleteAssetRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteAsset', $request, $callOptions)->wait(); - } - - /** - * Delete the environment resource. All the child resources must have been - * deleted before environment deletion can be initiated. - * - * The async variant is {@see self::deleteEnvironmentAsync()} . - * - * @example samples/V1/DataplexServiceClient/delete_environment.php - * - * @param DeleteEnvironmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteEnvironment(DeleteEnvironmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteEnvironment', $request, $callOptions)->wait(); - } - - /** - * Deletes a lake resource. All zones within the lake must be deleted before - * the lake can be deleted. - * - * The async variant is {@see self::deleteLakeAsync()} . - * - * @example samples/V1/DataplexServiceClient/delete_lake.php - * - * @param DeleteLakeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteLake(DeleteLakeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteLake', $request, $callOptions)->wait(); - } - - /** - * Delete the task resource. - * - * The async variant is {@see self::deleteTaskAsync()} . - * - * @example samples/V1/DataplexServiceClient/delete_task.php - * - * @param DeleteTaskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTask(DeleteTaskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteTask', $request, $callOptions)->wait(); - } - - /** - * Deletes a zone resource. All assets within a zone must be deleted before - * the zone can be deleted. - * - * The async variant is {@see self::deleteZoneAsync()} . - * - * @example samples/V1/DataplexServiceClient/delete_zone.php - * - * @param DeleteZoneRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteZone(DeleteZoneRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteZone', $request, $callOptions)->wait(); - } - - /** - * Retrieves an asset resource. - * - * The async variant is {@see self::getAssetAsync()} . - * - * @example samples/V1/DataplexServiceClient/get_asset.php - * - * @param GetAssetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Asset - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAsset(GetAssetRequest $request, array $callOptions = []): Asset - { - return $this->startApiCall('GetAsset', $request, $callOptions)->wait(); - } - - /** - * Get environment resource. - * - * The async variant is {@see self::getEnvironmentAsync()} . - * - * @example samples/V1/DataplexServiceClient/get_environment.php - * - * @param GetEnvironmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Environment - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEnvironment(GetEnvironmentRequest $request, array $callOptions = []): Environment - { - return $this->startApiCall('GetEnvironment', $request, $callOptions)->wait(); - } - - /** - * Get job resource. - * - * The async variant is {@see self::getJobAsync()} . - * - * @example samples/V1/DataplexServiceClient/get_job.php - * - * @param GetJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - */ - public function getJob(GetJobRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('GetJob', $request, $callOptions)->wait(); - } - - /** - * Retrieves a lake resource. - * - * The async variant is {@see self::getLakeAsync()} . - * - * @example samples/V1/DataplexServiceClient/get_lake.php - * - * @param GetLakeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Lake - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLake(GetLakeRequest $request, array $callOptions = []): Lake - { - return $this->startApiCall('GetLake', $request, $callOptions)->wait(); - } - - /** - * Get task resource. - * - * The async variant is {@see self::getTaskAsync()} . - * - * @example samples/V1/DataplexServiceClient/get_task.php - * - * @param GetTaskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Task - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTask(GetTaskRequest $request, array $callOptions = []): Task - { - return $this->startApiCall('GetTask', $request, $callOptions)->wait(); - } - - /** - * Retrieves a zone resource. - * - * The async variant is {@see self::getZoneAsync()} . - * - * @example samples/V1/DataplexServiceClient/get_zone.php - * - * @param GetZoneRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Zone - * - * @throws ApiException Thrown if the API call fails. - */ - public function getZone(GetZoneRequest $request, array $callOptions = []): Zone - { - return $this->startApiCall('GetZone', $request, $callOptions)->wait(); - } - - /** - * Lists action resources in an asset. - * - * The async variant is {@see self::listAssetActionsAsync()} . - * - * @example samples/V1/DataplexServiceClient/list_asset_actions.php - * - * @param ListAssetActionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAssetActions(ListAssetActionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAssetActions', $request, $callOptions); - } - - /** - * Lists asset resources in a zone. - * - * The async variant is {@see self::listAssetsAsync()} . - * - * @example samples/V1/DataplexServiceClient/list_assets.php - * - * @param ListAssetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAssets(ListAssetsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAssets', $request, $callOptions); - } - - /** - * Lists environments under the given lake. - * - * The async variant is {@see self::listEnvironmentsAsync()} . - * - * @example samples/V1/DataplexServiceClient/list_environments.php - * - * @param ListEnvironmentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listEnvironments(ListEnvironmentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListEnvironments', $request, $callOptions); - } - - /** - * Lists Jobs under the given task. - * - * The async variant is {@see self::listJobsAsync()} . - * - * @example samples/V1/DataplexServiceClient/list_jobs.php - * - * @param ListJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listJobs(ListJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListJobs', $request, $callOptions); - } - - /** - * Lists action resources in a lake. - * - * The async variant is {@see self::listLakeActionsAsync()} . - * - * @example samples/V1/DataplexServiceClient/list_lake_actions.php - * - * @param ListLakeActionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLakeActions(ListLakeActionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLakeActions', $request, $callOptions); - } - - /** - * Lists lake resources in a project and location. - * - * The async variant is {@see self::listLakesAsync()} . - * - * @example samples/V1/DataplexServiceClient/list_lakes.php - * - * @param ListLakesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLakes(ListLakesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLakes', $request, $callOptions); - } - - /** - * Lists session resources in an environment. - * - * The async variant is {@see self::listSessionsAsync()} . - * - * @example samples/V1/DataplexServiceClient/list_sessions.php - * - * @param ListSessionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSessions(ListSessionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSessions', $request, $callOptions); - } - - /** - * Lists tasks under the given lake. - * - * The async variant is {@see self::listTasksAsync()} . - * - * @example samples/V1/DataplexServiceClient/list_tasks.php - * - * @param ListTasksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTasks(ListTasksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTasks', $request, $callOptions); - } - - /** - * Lists action resources in a zone. - * - * The async variant is {@see self::listZoneActionsAsync()} . - * - * @example samples/V1/DataplexServiceClient/list_zone_actions.php - * - * @param ListZoneActionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listZoneActions(ListZoneActionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListZoneActions', $request, $callOptions); - } - - /** - * Lists zone resources in a lake. - * - * The async variant is {@see self::listZonesAsync()} . - * - * @example samples/V1/DataplexServiceClient/list_zones.php - * - * @param ListZonesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listZones(ListZonesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListZones', $request, $callOptions); - } - - /** - * Run an on demand execution of a Task. - * - * The async variant is {@see self::runTaskAsync()} . - * - * @example samples/V1/DataplexServiceClient/run_task.php - * - * @param RunTaskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RunTaskResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function runTask(RunTaskRequest $request, array $callOptions = []): RunTaskResponse - { - return $this->startApiCall('RunTask', $request, $callOptions)->wait(); - } - - /** - * Updates an asset resource. - * - * The async variant is {@see self::updateAssetAsync()} . - * - * @example samples/V1/DataplexServiceClient/update_asset.php - * - * @param UpdateAssetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAsset(UpdateAssetRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateAsset', $request, $callOptions)->wait(); - } - - /** - * Update the environment resource. - * - * The async variant is {@see self::updateEnvironmentAsync()} . - * - * @example samples/V1/DataplexServiceClient/update_environment.php - * - * @param UpdateEnvironmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateEnvironment(UpdateEnvironmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateEnvironment', $request, $callOptions)->wait(); - } - - /** - * Updates a lake resource. - * - * The async variant is {@see self::updateLakeAsync()} . - * - * @example samples/V1/DataplexServiceClient/update_lake.php - * - * @param UpdateLakeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateLake(UpdateLakeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateLake', $request, $callOptions)->wait(); - } - - /** - * Update the task resource. - * - * The async variant is {@see self::updateTaskAsync()} . - * - * @example samples/V1/DataplexServiceClient/update_task.php - * - * @param UpdateTaskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateTask(UpdateTaskRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateTask', $request, $callOptions)->wait(); - } - - /** - * Updates a zone resource. - * - * The async variant is {@see self::updateZoneAsync()} . - * - * @example samples/V1/DataplexServiceClient/update_zone.php - * - * @param UpdateZoneRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateZone(UpdateZoneRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateZone', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/DataplexServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/DataplexServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/DataplexServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/DataplexServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/DataplexServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dataplex/src/V1/Client/BaseClient/MetadataServiceBaseClient.php b/Dataplex/src/V1/Client/BaseClient/MetadataServiceBaseClient.php deleted file mode 100644 index 27ab01a8e83c..000000000000 --- a/Dataplex/src/V1/Client/BaseClient/MetadataServiceBaseClient.php +++ /dev/null @@ -1,668 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/metadata_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/metadata_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/metadata_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/metadata_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a entity - * resource. - * - * @param string $project - * @param string $location - * @param string $lake - * @param string $zone - * @param string $entity - * - * @return string The formatted entity resource. - */ - public static function entityName(string $project, string $location, string $lake, string $zone, string $entity): string - { - return self::getPathTemplate('entity')->render([ - 'project' => $project, - 'location' => $location, - 'lake' => $lake, - 'zone' => $zone, - 'entity' => $entity, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a partition - * resource. - * - * @param string $project - * @param string $location - * @param string $lake - * @param string $zone - * @param string $entity - * @param string $partition - * - * @return string The formatted partition resource. - */ - public static function partitionName(string $project, string $location, string $lake, string $zone, string $entity, string $partition): string - { - return self::getPathTemplate('partition')->render([ - 'project' => $project, - 'location' => $location, - 'lake' => $lake, - 'zone' => $zone, - 'entity' => $entity, - 'partition' => $partition, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a zone - * resource. - * - * @param string $project - * @param string $location - * @param string $lake - * @param string $zone - * - * @return string The formatted zone resource. - */ - public static function zoneName(string $project, string $location, string $lake, string $zone): string - { - return self::getPathTemplate('zone')->render([ - 'project' => $project, - 'location' => $location, - 'lake' => $lake, - 'zone' => $zone, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - entity: projects/{project}/locations/{location}/lakes/{lake}/zones/{zone}/entities/{entity} - * - partition: projects/{project}/locations/{location}/lakes/{lake}/zones/{zone}/entities/{entity}/partitions/{partition} - * - zone: projects/{project}/locations/{location}/lakes/{lake}/zones/{zone} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dataplex.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Create a metadata entity. - * - * The async variant is {@see self::createEntityAsync()} . - * - * @example samples/V1/MetadataServiceClient/create_entity.php - * - * @param CreateEntityRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Entity - * - * @throws ApiException Thrown if the API call fails. - */ - public function createEntity(CreateEntityRequest $request, array $callOptions = []): Entity - { - return $this->startApiCall('CreateEntity', $request, $callOptions)->wait(); - } - - /** - * Create a metadata partition. - * - * The async variant is {@see self::createPartitionAsync()} . - * - * @example samples/V1/MetadataServiceClient/create_partition.php - * - * @param CreatePartitionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Partition - * - * @throws ApiException Thrown if the API call fails. - */ - public function createPartition(CreatePartitionRequest $request, array $callOptions = []): Partition - { - return $this->startApiCall('CreatePartition', $request, $callOptions)->wait(); - } - - /** - * Delete a metadata entity. - * - * The async variant is {@see self::deleteEntityAsync()} . - * - * @example samples/V1/MetadataServiceClient/delete_entity.php - * - * @param DeleteEntityRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteEntity(DeleteEntityRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteEntity', $request, $callOptions)->wait(); - } - - /** - * Delete a metadata partition. - * - * The async variant is {@see self::deletePartitionAsync()} . - * - * @example samples/V1/MetadataServiceClient/delete_partition.php - * - * @param DeletePartitionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deletePartition(DeletePartitionRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeletePartition', $request, $callOptions)->wait(); - } - - /** - * Get a metadata entity. - * - * The async variant is {@see self::getEntityAsync()} . - * - * @example samples/V1/MetadataServiceClient/get_entity.php - * - * @param GetEntityRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Entity - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEntity(GetEntityRequest $request, array $callOptions = []): Entity - { - return $this->startApiCall('GetEntity', $request, $callOptions)->wait(); - } - - /** - * Get a metadata partition of an entity. - * - * The async variant is {@see self::getPartitionAsync()} . - * - * @example samples/V1/MetadataServiceClient/get_partition.php - * - * @param GetPartitionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Partition - * - * @throws ApiException Thrown if the API call fails. - */ - public function getPartition(GetPartitionRequest $request, array $callOptions = []): Partition - { - return $this->startApiCall('GetPartition', $request, $callOptions)->wait(); - } - - /** - * List metadata entities in a zone. - * - * The async variant is {@see self::listEntitiesAsync()} . - * - * @example samples/V1/MetadataServiceClient/list_entities.php - * - * @param ListEntitiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listEntities(ListEntitiesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListEntities', $request, $callOptions); - } - - /** - * List metadata partitions of an entity. - * - * The async variant is {@see self::listPartitionsAsync()} . - * - * @example samples/V1/MetadataServiceClient/list_partitions.php - * - * @param ListPartitionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPartitions(ListPartitionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPartitions', $request, $callOptions); - } - - /** - * Update a metadata entity. Only supports full resource update. - * - * The async variant is {@see self::updateEntityAsync()} . - * - * @example samples/V1/MetadataServiceClient/update_entity.php - * - * @param UpdateEntityRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Entity - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateEntity(UpdateEntityRequest $request, array $callOptions = []): Entity - { - return $this->startApiCall('UpdateEntity', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/MetadataServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/MetadataServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/MetadataServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/MetadataServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/MetadataServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dataplex/src/V1/Client/ContentServiceClient.php b/Dataplex/src/V1/Client/ContentServiceClient.php index 6163761dc617..79febaef815a 100644 --- a/Dataplex/src/V1/Client/ContentServiceClient.php +++ b/Dataplex/src/V1/Client/ContentServiceClient.php @@ -24,17 +24,508 @@ namespace Google\Cloud\Dataplex\V1\Client; -use Google\Cloud\Dataplex\V1\Client\BaseClient\ContentServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dataplex\V1\Content; +use Google\Cloud\Dataplex\V1\CreateContentRequest; +use Google\Cloud\Dataplex\V1\DeleteContentRequest; +use Google\Cloud\Dataplex\V1\GetContentRequest; +use Google\Cloud\Dataplex\V1\ListContentRequest; +use Google\Cloud\Dataplex\V1\UpdateContentRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: ContentService manages Notebook and SQL Scripts for Dataplex. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dataplex\V1\ContentServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createContentAsync(CreateContentRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteContentAsync(DeleteContentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getContentAsync(GetContentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listContentAsync(ListContentRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateContentAsync(UpdateContentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class ContentServiceClient extends ContentServiceBaseClient +final class ContentServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ContentServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dataplex.v1.ContentService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dataplex.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/content_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/content_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/content_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/content_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a content + * resource. + * + * @param string $project + * @param string $location + * @param string $lake + * @param string $content + * + * @return string The formatted content resource. + */ + public static function contentName(string $project, string $location, string $lake, string $content): string + { + return self::getPathTemplate('content')->render([ + 'project' => $project, + 'location' => $location, + 'lake' => $lake, + 'content' => $content, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a lake + * resource. + * + * @param string $project + * @param string $location + * @param string $lake + * + * @return string The formatted lake resource. + */ + public static function lakeName(string $project, string $location, string $lake): string + { + return self::getPathTemplate('lake')->render([ + 'project' => $project, + 'location' => $location, + 'lake' => $lake, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - content: projects/{project}/locations/{location}/lakes/{lake}/content/{content} + * - lake: projects/{project}/locations/{location}/lakes/{lake} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dataplex.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Create a content. + * + * The async variant is {@see ContentServiceClient::createContentAsync()} . + * + * @example samples/V1/ContentServiceClient/create_content.php + * + * @param CreateContentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Content + * + * @throws ApiException Thrown if the API call fails. + */ + public function createContent(CreateContentRequest $request, array $callOptions = []): Content + { + return $this->startApiCall('CreateContent', $request, $callOptions)->wait(); + } + + /** + * Delete a content. + * + * The async variant is {@see ContentServiceClient::deleteContentAsync()} . + * + * @example samples/V1/ContentServiceClient/delete_content.php + * + * @param DeleteContentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteContent(DeleteContentRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteContent', $request, $callOptions)->wait(); + } + + /** + * Get a content resource. + * + * The async variant is {@see ContentServiceClient::getContentAsync()} . + * + * @example samples/V1/ContentServiceClient/get_content.php + * + * @param GetContentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Content + * + * @throws ApiException Thrown if the API call fails. + */ + public function getContent(GetContentRequest $request, array $callOptions = []): Content + { + return $this->startApiCall('GetContent', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a contentitem resource. A `NOT_FOUND` + * error is returned if the resource does not exist. An empty policy is + * returned if the resource exists but does not have a policy set on it. + * + * Caller must have Google IAM `dataplex.content.getIamPolicy` permission + * on the resource. + * + * The async variant is {@see ContentServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/ContentServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * List content. + * + * The async variant is {@see ContentServiceClient::listContentAsync()} . + * + * @example samples/V1/ContentServiceClient/list_content.php + * + * @param ListContentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listContent(ListContentRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListContent', $request, $callOptions); + } + + /** + * Sets the access control policy on the specified contentitem resource. + * Replaces any existing policy. + * + * Caller must have Google IAM `dataplex.content.setIamPolicy` permission + * on the resource. + * + * The async variant is {@see ContentServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/ContentServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns the caller's permissions on a resource. + * If the resource does not exist, an empty set of + * permissions is returned (a `NOT_FOUND` error is not returned). + * + * A caller is not required to have Google IAM permission to make this + * request. + * + * Note: This operation is designed to be used for building permission-aware + * UIs and command-line tools, not for authorization checking. This operation + * may "fail open" without warning. + * + * The async variant is {@see ContentServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/ContentServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Update a content. Only supports full resource update. + * + * The async variant is {@see ContentServiceClient::updateContentAsync()} . + * + * @example samples/V1/ContentServiceClient/update_content.php + * + * @param UpdateContentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Content + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateContent(UpdateContentRequest $request, array $callOptions = []): Content + { + return $this->startApiCall('UpdateContent', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see ContentServiceClient::getLocationAsync()} . + * + * @example samples/V1/ContentServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see ContentServiceClient::listLocationsAsync()} . + * + * @example samples/V1/ContentServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Dataplex/src/V1/Client/DataScanServiceClient.php b/Dataplex/src/V1/Client/DataScanServiceClient.php index 66ecac34f1e0..bb4f769a7dd8 100644 --- a/Dataplex/src/V1/Client/DataScanServiceClient.php +++ b/Dataplex/src/V1/Client/DataScanServiceClient.php @@ -24,17 +24,668 @@ namespace Google\Cloud\Dataplex\V1\Client; -use Google\Cloud\Dataplex\V1\Client\BaseClient\DataScanServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dataplex\V1\CreateDataScanRequest; +use Google\Cloud\Dataplex\V1\DataScan; +use Google\Cloud\Dataplex\V1\DataScanJob; +use Google\Cloud\Dataplex\V1\DeleteDataScanRequest; +use Google\Cloud\Dataplex\V1\GetDataScanJobRequest; +use Google\Cloud\Dataplex\V1\GetDataScanRequest; +use Google\Cloud\Dataplex\V1\ListDataScanJobsRequest; +use Google\Cloud\Dataplex\V1\ListDataScansRequest; +use Google\Cloud\Dataplex\V1\RunDataScanRequest; +use Google\Cloud\Dataplex\V1\RunDataScanResponse; +use Google\Cloud\Dataplex\V1\UpdateDataScanRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: DataScanService manages DataScan resources which can be configured to run + * various types of data scanning workload and generate enriched metadata (e.g. + * Data Profile, Data Quality) for the data source. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dataplex\V1\DataScanServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createDataScanAsync(CreateDataScanRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDataScanAsync(DeleteDataScanRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDataScanAsync(GetDataScanRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDataScanJobAsync(GetDataScanJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDataScanJobsAsync(ListDataScanJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDataScansAsync(ListDataScansRequest $request, array $optionalArgs = []) + * @method PromiseInterface runDataScanAsync(RunDataScanRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDataScanAsync(UpdateDataScanRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class DataScanServiceClient extends DataScanServiceBaseClient +final class DataScanServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DataScanServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dataplex.v1.DataScanService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dataplex.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/data_scan_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/data_scan_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/data_scan_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/data_scan_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a data_scan + * resource. + * + * @param string $project + * @param string $location + * @param string $dataScan + * + * @return string The formatted data_scan resource. + */ + public static function dataScanName(string $project, string $location, string $dataScan): string + { + return self::getPathTemplate('dataScan')->render([ + 'project' => $project, + 'location' => $location, + 'dataScan' => $dataScan, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * data_scan_job resource. + * + * @param string $project + * @param string $location + * @param string $dataScan + * @param string $job + * + * @return string The formatted data_scan_job resource. + */ + public static function dataScanJobName(string $project, string $location, string $dataScan, string $job): string + { + return self::getPathTemplate('dataScanJob')->render([ + 'project' => $project, + 'location' => $location, + 'dataScan' => $dataScan, + 'job' => $job, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a entity + * resource. + * + * @param string $project + * @param string $location + * @param string $lake + * @param string $zone + * @param string $entity + * + * @return string The formatted entity resource. + */ + public static function entityName(string $project, string $location, string $lake, string $zone, string $entity): string + { + return self::getPathTemplate('entity')->render([ + 'project' => $project, + 'location' => $location, + 'lake' => $lake, + 'zone' => $zone, + 'entity' => $entity, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - dataScan: projects/{project}/locations/{location}/dataScans/{dataScan} + * - dataScanJob: projects/{project}/locations/{location}/dataScans/{dataScan}/jobs/{job} + * - entity: projects/{project}/locations/{location}/lakes/{lake}/zones/{zone}/entities/{entity} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dataplex.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a DataScan resource. + * + * The async variant is {@see DataScanServiceClient::createDataScanAsync()} . + * + * @example samples/V1/DataScanServiceClient/create_data_scan.php + * + * @param CreateDataScanRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDataScan(CreateDataScanRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateDataScan', $request, $callOptions)->wait(); + } + + /** + * Deletes a DataScan resource. + * + * The async variant is {@see DataScanServiceClient::deleteDataScanAsync()} . + * + * @example samples/V1/DataScanServiceClient/delete_data_scan.php + * + * @param DeleteDataScanRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDataScan(DeleteDataScanRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteDataScan', $request, $callOptions)->wait(); + } + + /** + * Gets a DataScan resource. + * + * The async variant is {@see DataScanServiceClient::getDataScanAsync()} . + * + * @example samples/V1/DataScanServiceClient/get_data_scan.php + * + * @param GetDataScanRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataScan + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDataScan(GetDataScanRequest $request, array $callOptions = []): DataScan + { + return $this->startApiCall('GetDataScan', $request, $callOptions)->wait(); + } + + /** + * Gets a DataScanJob resource. + * + * The async variant is {@see DataScanServiceClient::getDataScanJobAsync()} . + * + * @example samples/V1/DataScanServiceClient/get_data_scan_job.php + * + * @param GetDataScanJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataScanJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDataScanJob(GetDataScanJobRequest $request, array $callOptions = []): DataScanJob + { + return $this->startApiCall('GetDataScanJob', $request, $callOptions)->wait(); + } + + /** + * Lists DataScanJobs under the given DataScan. + * + * The async variant is {@see DataScanServiceClient::listDataScanJobsAsync()} . + * + * @example samples/V1/DataScanServiceClient/list_data_scan_jobs.php + * + * @param ListDataScanJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDataScanJobs(ListDataScanJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDataScanJobs', $request, $callOptions); + } + + /** + * Lists DataScans. + * + * The async variant is {@see DataScanServiceClient::listDataScansAsync()} . + * + * @example samples/V1/DataScanServiceClient/list_data_scans.php + * + * @param ListDataScansRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDataScans(ListDataScansRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDataScans', $request, $callOptions); + } + + /** + * Runs an on-demand execution of a DataScan + * + * The async variant is {@see DataScanServiceClient::runDataScanAsync()} . + * + * @example samples/V1/DataScanServiceClient/run_data_scan.php + * + * @param RunDataScanRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RunDataScanResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function runDataScan(RunDataScanRequest $request, array $callOptions = []): RunDataScanResponse + { + return $this->startApiCall('RunDataScan', $request, $callOptions)->wait(); + } + + /** + * Updates a DataScan resource. + * + * The async variant is {@see DataScanServiceClient::updateDataScanAsync()} . + * + * @example samples/V1/DataScanServiceClient/update_data_scan.php + * + * @param UpdateDataScanRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDataScan(UpdateDataScanRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateDataScan', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see DataScanServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/DataScanServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see DataScanServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/DataScanServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see DataScanServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/DataScanServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see DataScanServiceClient::getLocationAsync()} . + * + * @example samples/V1/DataScanServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see DataScanServiceClient::listLocationsAsync()} . + * + * @example samples/V1/DataScanServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Dataplex/src/V1/Client/DataTaxonomyServiceClient.php b/Dataplex/src/V1/Client/DataTaxonomyServiceClient.php index 533ce1c13131..b33e44f5c5fe 100644 --- a/Dataplex/src/V1/Client/DataTaxonomyServiceClient.php +++ b/Dataplex/src/V1/Client/DataTaxonomyServiceClient.php @@ -24,17 +24,877 @@ namespace Google\Cloud\Dataplex\V1\Client; -use Google\Cloud\Dataplex\V1\Client\BaseClient\DataTaxonomyServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dataplex\V1\CreateDataAttributeBindingRequest; +use Google\Cloud\Dataplex\V1\CreateDataAttributeRequest; +use Google\Cloud\Dataplex\V1\CreateDataTaxonomyRequest; +use Google\Cloud\Dataplex\V1\DataAttribute; +use Google\Cloud\Dataplex\V1\DataAttributeBinding; +use Google\Cloud\Dataplex\V1\DataTaxonomy; +use Google\Cloud\Dataplex\V1\DeleteDataAttributeBindingRequest; +use Google\Cloud\Dataplex\V1\DeleteDataAttributeRequest; +use Google\Cloud\Dataplex\V1\DeleteDataTaxonomyRequest; +use Google\Cloud\Dataplex\V1\GetDataAttributeBindingRequest; +use Google\Cloud\Dataplex\V1\GetDataAttributeRequest; +use Google\Cloud\Dataplex\V1\GetDataTaxonomyRequest; +use Google\Cloud\Dataplex\V1\ListDataAttributeBindingsRequest; +use Google\Cloud\Dataplex\V1\ListDataAttributesRequest; +use Google\Cloud\Dataplex\V1\ListDataTaxonomiesRequest; +use Google\Cloud\Dataplex\V1\UpdateDataAttributeBindingRequest; +use Google\Cloud\Dataplex\V1\UpdateDataAttributeRequest; +use Google\Cloud\Dataplex\V1\UpdateDataTaxonomyRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: DataTaxonomyService enables attribute-based governance. The resources + * currently offered include DataTaxonomy and DataAttribute. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dataplex\V1\DataTaxonomyServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createDataAttributeAsync(CreateDataAttributeRequest $request, array $optionalArgs = []) + * @method PromiseInterface createDataAttributeBindingAsync(CreateDataAttributeBindingRequest $request, array $optionalArgs = []) + * @method PromiseInterface createDataTaxonomyAsync(CreateDataTaxonomyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDataAttributeAsync(DeleteDataAttributeRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDataAttributeBindingAsync(DeleteDataAttributeBindingRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDataTaxonomyAsync(DeleteDataTaxonomyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDataAttributeAsync(GetDataAttributeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDataAttributeBindingAsync(GetDataAttributeBindingRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDataTaxonomyAsync(GetDataTaxonomyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDataAttributeBindingsAsync(ListDataAttributeBindingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDataAttributesAsync(ListDataAttributesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDataTaxonomiesAsync(ListDataTaxonomiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDataAttributeAsync(UpdateDataAttributeRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDataAttributeBindingAsync(UpdateDataAttributeBindingRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDataTaxonomyAsync(UpdateDataTaxonomyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class DataTaxonomyServiceClient extends DataTaxonomyServiceBaseClient +final class DataTaxonomyServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DataTaxonomyServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dataplex.v1.DataTaxonomyService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dataplex.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/data_taxonomy_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/data_taxonomy_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/data_taxonomy_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/data_taxonomy_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * data_attribute resource. + * + * @param string $project + * @param string $location + * @param string $dataTaxonomy + * @param string $dataAttributeId + * + * @return string The formatted data_attribute resource. + */ + public static function dataAttributeName(string $project, string $location, string $dataTaxonomy, string $dataAttributeId): string + { + return self::getPathTemplate('dataAttribute')->render([ + 'project' => $project, + 'location' => $location, + 'dataTaxonomy' => $dataTaxonomy, + 'data_attribute_id' => $dataAttributeId, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * data_attribute_binding resource. + * + * @param string $project + * @param string $location + * @param string $dataAttributeBindingId + * + * @return string The formatted data_attribute_binding resource. + */ + public static function dataAttributeBindingName(string $project, string $location, string $dataAttributeBindingId): string + { + return self::getPathTemplate('dataAttributeBinding')->render([ + 'project' => $project, + 'location' => $location, + 'data_attribute_binding_id' => $dataAttributeBindingId, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * data_taxonomy resource. + * + * @param string $project + * @param string $location + * @param string $dataTaxonomyId + * + * @return string The formatted data_taxonomy resource. + */ + public static function dataTaxonomyName(string $project, string $location, string $dataTaxonomyId): string + { + return self::getPathTemplate('dataTaxonomy')->render([ + 'project' => $project, + 'location' => $location, + 'data_taxonomy_id' => $dataTaxonomyId, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - dataAttribute: projects/{project}/locations/{location}/dataTaxonomies/{dataTaxonomy}/attributes/{data_attribute_id} + * - dataAttributeBinding: projects/{project}/locations/{location}/dataAttributeBindings/{data_attribute_binding_id} + * - dataTaxonomy: projects/{project}/locations/{location}/dataTaxonomies/{data_taxonomy_id} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dataplex.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Create a DataAttribute resource. + * + * The async variant is + * {@see DataTaxonomyServiceClient::createDataAttributeAsync()} . + * + * @example samples/V1/DataTaxonomyServiceClient/create_data_attribute.php + * + * @param CreateDataAttributeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDataAttribute(CreateDataAttributeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateDataAttribute', $request, $callOptions)->wait(); + } + + /** + * Create a DataAttributeBinding resource. + * + * The async variant is + * {@see DataTaxonomyServiceClient::createDataAttributeBindingAsync()} . + * + * @example samples/V1/DataTaxonomyServiceClient/create_data_attribute_binding.php + * + * @param CreateDataAttributeBindingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDataAttributeBinding(CreateDataAttributeBindingRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateDataAttributeBinding', $request, $callOptions)->wait(); + } + + /** + * Create a DataTaxonomy resource. + * + * The async variant is {@see DataTaxonomyServiceClient::createDataTaxonomyAsync()} + * . + * + * @example samples/V1/DataTaxonomyServiceClient/create_data_taxonomy.php + * + * @param CreateDataTaxonomyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDataTaxonomy(CreateDataTaxonomyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateDataTaxonomy', $request, $callOptions)->wait(); + } + + /** + * Deletes a Data Attribute resource. + * + * The async variant is + * {@see DataTaxonomyServiceClient::deleteDataAttributeAsync()} . + * + * @example samples/V1/DataTaxonomyServiceClient/delete_data_attribute.php + * + * @param DeleteDataAttributeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDataAttribute(DeleteDataAttributeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteDataAttribute', $request, $callOptions)->wait(); + } + + /** + * Deletes a DataAttributeBinding resource. All attributes within the + * DataAttributeBinding must be deleted before the DataAttributeBinding can be + * deleted. + * + * The async variant is + * {@see DataTaxonomyServiceClient::deleteDataAttributeBindingAsync()} . + * + * @example samples/V1/DataTaxonomyServiceClient/delete_data_attribute_binding.php + * + * @param DeleteDataAttributeBindingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDataAttributeBinding(DeleteDataAttributeBindingRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteDataAttributeBinding', $request, $callOptions)->wait(); + } + + /** + * Deletes a DataTaxonomy resource. All attributes within the DataTaxonomy + * must be deleted before the DataTaxonomy can be deleted. + * + * The async variant is {@see DataTaxonomyServiceClient::deleteDataTaxonomyAsync()} + * . + * + * @example samples/V1/DataTaxonomyServiceClient/delete_data_taxonomy.php + * + * @param DeleteDataTaxonomyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDataTaxonomy(DeleteDataTaxonomyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteDataTaxonomy', $request, $callOptions)->wait(); + } + + /** + * Retrieves a Data Attribute resource. + * + * The async variant is {@see DataTaxonomyServiceClient::getDataAttributeAsync()} . + * + * @example samples/V1/DataTaxonomyServiceClient/get_data_attribute.php + * + * @param GetDataAttributeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataAttribute + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDataAttribute(GetDataAttributeRequest $request, array $callOptions = []): DataAttribute + { + return $this->startApiCall('GetDataAttribute', $request, $callOptions)->wait(); + } + + /** + * Retrieves a DataAttributeBinding resource. + * + * The async variant is + * {@see DataTaxonomyServiceClient::getDataAttributeBindingAsync()} . + * + * @example samples/V1/DataTaxonomyServiceClient/get_data_attribute_binding.php + * + * @param GetDataAttributeBindingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataAttributeBinding + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDataAttributeBinding(GetDataAttributeBindingRequest $request, array $callOptions = []): DataAttributeBinding + { + return $this->startApiCall('GetDataAttributeBinding', $request, $callOptions)->wait(); + } + + /** + * Retrieves a DataTaxonomy resource. + * + * The async variant is {@see DataTaxonomyServiceClient::getDataTaxonomyAsync()} . + * + * @example samples/V1/DataTaxonomyServiceClient/get_data_taxonomy.php + * + * @param GetDataTaxonomyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DataTaxonomy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDataTaxonomy(GetDataTaxonomyRequest $request, array $callOptions = []): DataTaxonomy + { + return $this->startApiCall('GetDataTaxonomy', $request, $callOptions)->wait(); + } + + /** + * Lists DataAttributeBinding resources in a project and location. + * + * The async variant is + * {@see DataTaxonomyServiceClient::listDataAttributeBindingsAsync()} . + * + * @example samples/V1/DataTaxonomyServiceClient/list_data_attribute_bindings.php + * + * @param ListDataAttributeBindingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDataAttributeBindings(ListDataAttributeBindingsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDataAttributeBindings', $request, $callOptions); + } + + /** + * Lists Data Attribute resources in a DataTaxonomy. + * + * The async variant is {@see DataTaxonomyServiceClient::listDataAttributesAsync()} + * . + * + * @example samples/V1/DataTaxonomyServiceClient/list_data_attributes.php + * + * @param ListDataAttributesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDataAttributes(ListDataAttributesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDataAttributes', $request, $callOptions); + } + + /** + * Lists DataTaxonomy resources in a project and location. + * + * The async variant is {@see DataTaxonomyServiceClient::listDataTaxonomiesAsync()} + * . + * + * @example samples/V1/DataTaxonomyServiceClient/list_data_taxonomies.php + * + * @param ListDataTaxonomiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDataTaxonomies(ListDataTaxonomiesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDataTaxonomies', $request, $callOptions); + } + + /** + * Updates a DataAttribute resource. + * + * The async variant is + * {@see DataTaxonomyServiceClient::updateDataAttributeAsync()} . + * + * @example samples/V1/DataTaxonomyServiceClient/update_data_attribute.php + * + * @param UpdateDataAttributeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDataAttribute(UpdateDataAttributeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateDataAttribute', $request, $callOptions)->wait(); + } + + /** + * Updates a DataAttributeBinding resource. + * + * The async variant is + * {@see DataTaxonomyServiceClient::updateDataAttributeBindingAsync()} . + * + * @example samples/V1/DataTaxonomyServiceClient/update_data_attribute_binding.php + * + * @param UpdateDataAttributeBindingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDataAttributeBinding(UpdateDataAttributeBindingRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateDataAttributeBinding', $request, $callOptions)->wait(); + } + + /** + * Updates a DataTaxonomy resource. + * + * The async variant is {@see DataTaxonomyServiceClient::updateDataTaxonomyAsync()} + * . + * + * @example samples/V1/DataTaxonomyServiceClient/update_data_taxonomy.php + * + * @param UpdateDataTaxonomyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDataTaxonomy(UpdateDataTaxonomyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateDataTaxonomy', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see DataTaxonomyServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/DataTaxonomyServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see DataTaxonomyServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/DataTaxonomyServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see DataTaxonomyServiceClient::testIamPermissionsAsync()} + * . + * + * @example samples/V1/DataTaxonomyServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see DataTaxonomyServiceClient::getLocationAsync()} . + * + * @example samples/V1/DataTaxonomyServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see DataTaxonomyServiceClient::listLocationsAsync()} . + * + * @example samples/V1/DataTaxonomyServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Dataplex/src/V1/Client/DataplexServiceClient.php b/Dataplex/src/V1/Client/DataplexServiceClient.php index b04e25af5362..6ec4d7337b9c 100644 --- a/Dataplex/src/V1/Client/DataplexServiceClient.php +++ b/Dataplex/src/V1/Client/DataplexServiceClient.php @@ -24,17 +24,1444 @@ namespace Google\Cloud\Dataplex\V1\Client; -use Google\Cloud\Dataplex\V1\Client\BaseClient\DataplexServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dataplex\V1\Asset; +use Google\Cloud\Dataplex\V1\CancelJobRequest; +use Google\Cloud\Dataplex\V1\CreateAssetRequest; +use Google\Cloud\Dataplex\V1\CreateEnvironmentRequest; +use Google\Cloud\Dataplex\V1\CreateLakeRequest; +use Google\Cloud\Dataplex\V1\CreateTaskRequest; +use Google\Cloud\Dataplex\V1\CreateZoneRequest; +use Google\Cloud\Dataplex\V1\DeleteAssetRequest; +use Google\Cloud\Dataplex\V1\DeleteEnvironmentRequest; +use Google\Cloud\Dataplex\V1\DeleteLakeRequest; +use Google\Cloud\Dataplex\V1\DeleteTaskRequest; +use Google\Cloud\Dataplex\V1\DeleteZoneRequest; +use Google\Cloud\Dataplex\V1\Environment; +use Google\Cloud\Dataplex\V1\GetAssetRequest; +use Google\Cloud\Dataplex\V1\GetEnvironmentRequest; +use Google\Cloud\Dataplex\V1\GetJobRequest; +use Google\Cloud\Dataplex\V1\GetLakeRequest; +use Google\Cloud\Dataplex\V1\GetTaskRequest; +use Google\Cloud\Dataplex\V1\GetZoneRequest; +use Google\Cloud\Dataplex\V1\Job; +use Google\Cloud\Dataplex\V1\Lake; +use Google\Cloud\Dataplex\V1\ListAssetActionsRequest; +use Google\Cloud\Dataplex\V1\ListAssetsRequest; +use Google\Cloud\Dataplex\V1\ListEnvironmentsRequest; +use Google\Cloud\Dataplex\V1\ListJobsRequest; +use Google\Cloud\Dataplex\V1\ListLakeActionsRequest; +use Google\Cloud\Dataplex\V1\ListLakesRequest; +use Google\Cloud\Dataplex\V1\ListSessionsRequest; +use Google\Cloud\Dataplex\V1\ListTasksRequest; +use Google\Cloud\Dataplex\V1\ListZoneActionsRequest; +use Google\Cloud\Dataplex\V1\ListZonesRequest; +use Google\Cloud\Dataplex\V1\RunTaskRequest; +use Google\Cloud\Dataplex\V1\RunTaskResponse; +use Google\Cloud\Dataplex\V1\Task; +use Google\Cloud\Dataplex\V1\UpdateAssetRequest; +use Google\Cloud\Dataplex\V1\UpdateEnvironmentRequest; +use Google\Cloud\Dataplex\V1\UpdateLakeRequest; +use Google\Cloud\Dataplex\V1\UpdateTaskRequest; +use Google\Cloud\Dataplex\V1\UpdateZoneRequest; +use Google\Cloud\Dataplex\V1\Zone; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Dataplex service provides data lakes as a service. The primary resources + * offered by this service are Lakes, Zones and Assets which collectively allow + * a data administrator to organize, manage, secure and catalog data across + * their organization located across cloud projects in a variety of storage + * systems including Cloud Storage and BigQuery. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dataplex\V1\DataplexServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface cancelJobAsync(CancelJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface createAssetAsync(CreateAssetRequest $request, array $optionalArgs = []) + * @method PromiseInterface createEnvironmentAsync(CreateEnvironmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface createLakeAsync(CreateLakeRequest $request, array $optionalArgs = []) + * @method PromiseInterface createTaskAsync(CreateTaskRequest $request, array $optionalArgs = []) + * @method PromiseInterface createZoneAsync(CreateZoneRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAssetAsync(DeleteAssetRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteEnvironmentAsync(DeleteEnvironmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteLakeAsync(DeleteLakeRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTaskAsync(DeleteTaskRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteZoneAsync(DeleteZoneRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAssetAsync(GetAssetRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEnvironmentAsync(GetEnvironmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getJobAsync(GetJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLakeAsync(GetLakeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTaskAsync(GetTaskRequest $request, array $optionalArgs = []) + * @method PromiseInterface getZoneAsync(GetZoneRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAssetActionsAsync(ListAssetActionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAssetsAsync(ListAssetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listEnvironmentsAsync(ListEnvironmentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listJobsAsync(ListJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLakeActionsAsync(ListLakeActionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLakesAsync(ListLakesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSessionsAsync(ListSessionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTasksAsync(ListTasksRequest $request, array $optionalArgs = []) + * @method PromiseInterface listZoneActionsAsync(ListZoneActionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listZonesAsync(ListZonesRequest $request, array $optionalArgs = []) + * @method PromiseInterface runTaskAsync(RunTaskRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAssetAsync(UpdateAssetRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateEnvironmentAsync(UpdateEnvironmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateLakeAsync(UpdateLakeRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateTaskAsync(UpdateTaskRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateZoneAsync(UpdateZoneRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class DataplexServiceClient extends DataplexServiceBaseClient +final class DataplexServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DataplexServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dataplex.v1.DataplexService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dataplex.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/dataplex_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/dataplex_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/dataplex_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/dataplex_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a asset + * resource. + * + * @param string $project + * @param string $location + * @param string $lake + * @param string $zone + * @param string $asset + * + * @return string The formatted asset resource. + */ + public static function assetName(string $project, string $location, string $lake, string $zone, string $asset): string + { + return self::getPathTemplate('asset')->render([ + 'project' => $project, + 'location' => $location, + 'lake' => $lake, + 'zone' => $zone, + 'asset' => $asset, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a environment + * resource. + * + * @param string $project + * @param string $location + * @param string $lake + * @param string $environment + * + * @return string The formatted environment resource. + */ + public static function environmentName(string $project, string $location, string $lake, string $environment): string + { + return self::getPathTemplate('environment')->render([ + 'project' => $project, + 'location' => $location, + 'lake' => $lake, + 'environment' => $environment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a job + * resource. + * + * @param string $project + * @param string $location + * @param string $lake + * @param string $task + * @param string $job + * + * @return string The formatted job resource. + */ + public static function jobName(string $project, string $location, string $lake, string $task, string $job): string + { + return self::getPathTemplate('job')->render([ + 'project' => $project, + 'location' => $location, + 'lake' => $lake, + 'task' => $task, + 'job' => $job, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a lake + * resource. + * + * @param string $project + * @param string $location + * @param string $lake + * + * @return string The formatted lake resource. + */ + public static function lakeName(string $project, string $location, string $lake): string + { + return self::getPathTemplate('lake')->render([ + 'project' => $project, + 'location' => $location, + 'lake' => $lake, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a task + * resource. + * + * @param string $project + * @param string $location + * @param string $lake + * @param string $task + * + * @return string The formatted task resource. + */ + public static function taskName(string $project, string $location, string $lake, string $task): string + { + return self::getPathTemplate('task')->render([ + 'project' => $project, + 'location' => $location, + 'lake' => $lake, + 'task' => $task, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a zone + * resource. + * + * @param string $project + * @param string $location + * @param string $lake + * @param string $zone + * + * @return string The formatted zone resource. + */ + public static function zoneName(string $project, string $location, string $lake, string $zone): string + { + return self::getPathTemplate('zone')->render([ + 'project' => $project, + 'location' => $location, + 'lake' => $lake, + 'zone' => $zone, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - asset: projects/{project}/locations/{location}/lakes/{lake}/zones/{zone}/assets/{asset} + * - environment: projects/{project}/locations/{location}/lakes/{lake}/environments/{environment} + * - job: projects/{project}/locations/{location}/lakes/{lake}/tasks/{task}/jobs/{job} + * - lake: projects/{project}/locations/{location}/lakes/{lake} + * - location: projects/{project}/locations/{location} + * - task: projects/{project}/locations/{location}/lakes/{lake}/tasks/{task} + * - zone: projects/{project}/locations/{location}/lakes/{lake}/zones/{zone} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dataplex.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Cancel jobs running for the task resource. + * + * The async variant is {@see DataplexServiceClient::cancelJobAsync()} . + * + * @example samples/V1/DataplexServiceClient/cancel_job.php + * + * @param CancelJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function cancelJob(CancelJobRequest $request, array $callOptions = []): void + { + $this->startApiCall('CancelJob', $request, $callOptions)->wait(); + } + + /** + * Creates an asset resource. + * + * The async variant is {@see DataplexServiceClient::createAssetAsync()} . + * + * @example samples/V1/DataplexServiceClient/create_asset.php + * + * @param CreateAssetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAsset(CreateAssetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateAsset', $request, $callOptions)->wait(); + } + + /** + * Create an environment resource. + * + * The async variant is {@see DataplexServiceClient::createEnvironmentAsync()} . + * + * @example samples/V1/DataplexServiceClient/create_environment.php + * + * @param CreateEnvironmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createEnvironment(CreateEnvironmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateEnvironment', $request, $callOptions)->wait(); + } + + /** + * Creates a lake resource. + * + * The async variant is {@see DataplexServiceClient::createLakeAsync()} . + * + * @example samples/V1/DataplexServiceClient/create_lake.php + * + * @param CreateLakeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createLake(CreateLakeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateLake', $request, $callOptions)->wait(); + } + + /** + * Creates a task resource within a lake. + * + * The async variant is {@see DataplexServiceClient::createTaskAsync()} . + * + * @example samples/V1/DataplexServiceClient/create_task.php + * + * @param CreateTaskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTask(CreateTaskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateTask', $request, $callOptions)->wait(); + } + + /** + * Creates a zone resource within a lake. + * + * The async variant is {@see DataplexServiceClient::createZoneAsync()} . + * + * @example samples/V1/DataplexServiceClient/create_zone.php + * + * @param CreateZoneRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createZone(CreateZoneRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateZone', $request, $callOptions)->wait(); + } + + /** + * Deletes an asset resource. The referenced storage resource is detached + * (default) or deleted based on the associated Lifecycle policy. + * + * The async variant is {@see DataplexServiceClient::deleteAssetAsync()} . + * + * @example samples/V1/DataplexServiceClient/delete_asset.php + * + * @param DeleteAssetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAsset(DeleteAssetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteAsset', $request, $callOptions)->wait(); + } + + /** + * Delete the environment resource. All the child resources must have been + * deleted before environment deletion can be initiated. + * + * The async variant is {@see DataplexServiceClient::deleteEnvironmentAsync()} . + * + * @example samples/V1/DataplexServiceClient/delete_environment.php + * + * @param DeleteEnvironmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteEnvironment(DeleteEnvironmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteEnvironment', $request, $callOptions)->wait(); + } + + /** + * Deletes a lake resource. All zones within the lake must be deleted before + * the lake can be deleted. + * + * The async variant is {@see DataplexServiceClient::deleteLakeAsync()} . + * + * @example samples/V1/DataplexServiceClient/delete_lake.php + * + * @param DeleteLakeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteLake(DeleteLakeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteLake', $request, $callOptions)->wait(); + } + + /** + * Delete the task resource. + * + * The async variant is {@see DataplexServiceClient::deleteTaskAsync()} . + * + * @example samples/V1/DataplexServiceClient/delete_task.php + * + * @param DeleteTaskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTask(DeleteTaskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteTask', $request, $callOptions)->wait(); + } + + /** + * Deletes a zone resource. All assets within a zone must be deleted before + * the zone can be deleted. + * + * The async variant is {@see DataplexServiceClient::deleteZoneAsync()} . + * + * @example samples/V1/DataplexServiceClient/delete_zone.php + * + * @param DeleteZoneRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteZone(DeleteZoneRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteZone', $request, $callOptions)->wait(); + } + + /** + * Retrieves an asset resource. + * + * The async variant is {@see DataplexServiceClient::getAssetAsync()} . + * + * @example samples/V1/DataplexServiceClient/get_asset.php + * + * @param GetAssetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Asset + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAsset(GetAssetRequest $request, array $callOptions = []): Asset + { + return $this->startApiCall('GetAsset', $request, $callOptions)->wait(); + } + + /** + * Get environment resource. + * + * The async variant is {@see DataplexServiceClient::getEnvironmentAsync()} . + * + * @example samples/V1/DataplexServiceClient/get_environment.php + * + * @param GetEnvironmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Environment + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEnvironment(GetEnvironmentRequest $request, array $callOptions = []): Environment + { + return $this->startApiCall('GetEnvironment', $request, $callOptions)->wait(); + } + + /** + * Get job resource. + * + * The async variant is {@see DataplexServiceClient::getJobAsync()} . + * + * @example samples/V1/DataplexServiceClient/get_job.php + * + * @param GetJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + */ + public function getJob(GetJobRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('GetJob', $request, $callOptions)->wait(); + } + + /** + * Retrieves a lake resource. + * + * The async variant is {@see DataplexServiceClient::getLakeAsync()} . + * + * @example samples/V1/DataplexServiceClient/get_lake.php + * + * @param GetLakeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Lake + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLake(GetLakeRequest $request, array $callOptions = []): Lake + { + return $this->startApiCall('GetLake', $request, $callOptions)->wait(); + } + + /** + * Get task resource. + * + * The async variant is {@see DataplexServiceClient::getTaskAsync()} . + * + * @example samples/V1/DataplexServiceClient/get_task.php + * + * @param GetTaskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Task + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTask(GetTaskRequest $request, array $callOptions = []): Task + { + return $this->startApiCall('GetTask', $request, $callOptions)->wait(); + } + + /** + * Retrieves a zone resource. + * + * The async variant is {@see DataplexServiceClient::getZoneAsync()} . + * + * @example samples/V1/DataplexServiceClient/get_zone.php + * + * @param GetZoneRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Zone + * + * @throws ApiException Thrown if the API call fails. + */ + public function getZone(GetZoneRequest $request, array $callOptions = []): Zone + { + return $this->startApiCall('GetZone', $request, $callOptions)->wait(); + } + + /** + * Lists action resources in an asset. + * + * The async variant is {@see DataplexServiceClient::listAssetActionsAsync()} . + * + * @example samples/V1/DataplexServiceClient/list_asset_actions.php + * + * @param ListAssetActionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAssetActions(ListAssetActionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAssetActions', $request, $callOptions); + } + + /** + * Lists asset resources in a zone. + * + * The async variant is {@see DataplexServiceClient::listAssetsAsync()} . + * + * @example samples/V1/DataplexServiceClient/list_assets.php + * + * @param ListAssetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAssets(ListAssetsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAssets', $request, $callOptions); + } + + /** + * Lists environments under the given lake. + * + * The async variant is {@see DataplexServiceClient::listEnvironmentsAsync()} . + * + * @example samples/V1/DataplexServiceClient/list_environments.php + * + * @param ListEnvironmentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listEnvironments(ListEnvironmentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEnvironments', $request, $callOptions); + } + + /** + * Lists Jobs under the given task. + * + * The async variant is {@see DataplexServiceClient::listJobsAsync()} . + * + * @example samples/V1/DataplexServiceClient/list_jobs.php + * + * @param ListJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listJobs(ListJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListJobs', $request, $callOptions); + } + + /** + * Lists action resources in a lake. + * + * The async variant is {@see DataplexServiceClient::listLakeActionsAsync()} . + * + * @example samples/V1/DataplexServiceClient/list_lake_actions.php + * + * @param ListLakeActionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLakeActions(ListLakeActionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLakeActions', $request, $callOptions); + } + + /** + * Lists lake resources in a project and location. + * + * The async variant is {@see DataplexServiceClient::listLakesAsync()} . + * + * @example samples/V1/DataplexServiceClient/list_lakes.php + * + * @param ListLakesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLakes(ListLakesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLakes', $request, $callOptions); + } + + /** + * Lists session resources in an environment. + * + * The async variant is {@see DataplexServiceClient::listSessionsAsync()} . + * + * @example samples/V1/DataplexServiceClient/list_sessions.php + * + * @param ListSessionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSessions(ListSessionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSessions', $request, $callOptions); + } + + /** + * Lists tasks under the given lake. + * + * The async variant is {@see DataplexServiceClient::listTasksAsync()} . + * + * @example samples/V1/DataplexServiceClient/list_tasks.php + * + * @param ListTasksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTasks(ListTasksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTasks', $request, $callOptions); + } + + /** + * Lists action resources in a zone. + * + * The async variant is {@see DataplexServiceClient::listZoneActionsAsync()} . + * + * @example samples/V1/DataplexServiceClient/list_zone_actions.php + * + * @param ListZoneActionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listZoneActions(ListZoneActionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListZoneActions', $request, $callOptions); + } + + /** + * Lists zone resources in a lake. + * + * The async variant is {@see DataplexServiceClient::listZonesAsync()} . + * + * @example samples/V1/DataplexServiceClient/list_zones.php + * + * @param ListZonesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listZones(ListZonesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListZones', $request, $callOptions); + } + + /** + * Run an on demand execution of a Task. + * + * The async variant is {@see DataplexServiceClient::runTaskAsync()} . + * + * @example samples/V1/DataplexServiceClient/run_task.php + * + * @param RunTaskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RunTaskResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function runTask(RunTaskRequest $request, array $callOptions = []): RunTaskResponse + { + return $this->startApiCall('RunTask', $request, $callOptions)->wait(); + } + + /** + * Updates an asset resource. + * + * The async variant is {@see DataplexServiceClient::updateAssetAsync()} . + * + * @example samples/V1/DataplexServiceClient/update_asset.php + * + * @param UpdateAssetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAsset(UpdateAssetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateAsset', $request, $callOptions)->wait(); + } + + /** + * Update the environment resource. + * + * The async variant is {@see DataplexServiceClient::updateEnvironmentAsync()} . + * + * @example samples/V1/DataplexServiceClient/update_environment.php + * + * @param UpdateEnvironmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateEnvironment(UpdateEnvironmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateEnvironment', $request, $callOptions)->wait(); + } + + /** + * Updates a lake resource. + * + * The async variant is {@see DataplexServiceClient::updateLakeAsync()} . + * + * @example samples/V1/DataplexServiceClient/update_lake.php + * + * @param UpdateLakeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateLake(UpdateLakeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateLake', $request, $callOptions)->wait(); + } + + /** + * Update the task resource. + * + * The async variant is {@see DataplexServiceClient::updateTaskAsync()} . + * + * @example samples/V1/DataplexServiceClient/update_task.php + * + * @param UpdateTaskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTask(UpdateTaskRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateTask', $request, $callOptions)->wait(); + } + + /** + * Updates a zone resource. + * + * The async variant is {@see DataplexServiceClient::updateZoneAsync()} . + * + * @example samples/V1/DataplexServiceClient/update_zone.php + * + * @param UpdateZoneRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateZone(UpdateZoneRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateZone', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see DataplexServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/DataplexServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see DataplexServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/DataplexServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see DataplexServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/DataplexServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see DataplexServiceClient::getLocationAsync()} . + * + * @example samples/V1/DataplexServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see DataplexServiceClient::listLocationsAsync()} . + * + * @example samples/V1/DataplexServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Dataplex/src/V1/Client/MetadataServiceClient.php b/Dataplex/src/V1/Client/MetadataServiceClient.php index b060943ee15c..f3c0d5cf22fa 100644 --- a/Dataplex/src/V1/Client/MetadataServiceClient.php +++ b/Dataplex/src/V1/Client/MetadataServiceClient.php @@ -24,17 +24,643 @@ namespace Google\Cloud\Dataplex\V1\Client; -use Google\Cloud\Dataplex\V1\Client\BaseClient\MetadataServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dataplex\V1\CreateEntityRequest; +use Google\Cloud\Dataplex\V1\CreatePartitionRequest; +use Google\Cloud\Dataplex\V1\DeleteEntityRequest; +use Google\Cloud\Dataplex\V1\DeletePartitionRequest; +use Google\Cloud\Dataplex\V1\Entity; +use Google\Cloud\Dataplex\V1\GetEntityRequest; +use Google\Cloud\Dataplex\V1\GetPartitionRequest; +use Google\Cloud\Dataplex\V1\ListEntitiesRequest; +use Google\Cloud\Dataplex\V1\ListPartitionsRequest; +use Google\Cloud\Dataplex\V1\Partition; +use Google\Cloud\Dataplex\V1\UpdateEntityRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Metadata service manages metadata resources such as tables, filesets and + * partitions. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dataplex\V1\MetadataServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createEntityAsync(CreateEntityRequest $request, array $optionalArgs = []) + * @method PromiseInterface createPartitionAsync(CreatePartitionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteEntityAsync(DeleteEntityRequest $request, array $optionalArgs = []) + * @method PromiseInterface deletePartitionAsync(DeletePartitionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEntityAsync(GetEntityRequest $request, array $optionalArgs = []) + * @method PromiseInterface getPartitionAsync(GetPartitionRequest $request, array $optionalArgs = []) + * @method PromiseInterface listEntitiesAsync(ListEntitiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPartitionsAsync(ListPartitionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateEntityAsync(UpdateEntityRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class MetadataServiceClient extends MetadataServiceBaseClient +final class MetadataServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see MetadataServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dataplex.v1.MetadataService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dataplex.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/metadata_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/metadata_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/metadata_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/metadata_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a entity + * resource. + * + * @param string $project + * @param string $location + * @param string $lake + * @param string $zone + * @param string $entity + * + * @return string The formatted entity resource. + */ + public static function entityName(string $project, string $location, string $lake, string $zone, string $entity): string + { + return self::getPathTemplate('entity')->render([ + 'project' => $project, + 'location' => $location, + 'lake' => $lake, + 'zone' => $zone, + 'entity' => $entity, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a partition + * resource. + * + * @param string $project + * @param string $location + * @param string $lake + * @param string $zone + * @param string $entity + * @param string $partition + * + * @return string The formatted partition resource. + */ + public static function partitionName(string $project, string $location, string $lake, string $zone, string $entity, string $partition): string + { + return self::getPathTemplate('partition')->render([ + 'project' => $project, + 'location' => $location, + 'lake' => $lake, + 'zone' => $zone, + 'entity' => $entity, + 'partition' => $partition, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a zone + * resource. + * + * @param string $project + * @param string $location + * @param string $lake + * @param string $zone + * + * @return string The formatted zone resource. + */ + public static function zoneName(string $project, string $location, string $lake, string $zone): string + { + return self::getPathTemplate('zone')->render([ + 'project' => $project, + 'location' => $location, + 'lake' => $lake, + 'zone' => $zone, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - entity: projects/{project}/locations/{location}/lakes/{lake}/zones/{zone}/entities/{entity} + * - partition: projects/{project}/locations/{location}/lakes/{lake}/zones/{zone}/entities/{entity}/partitions/{partition} + * - zone: projects/{project}/locations/{location}/lakes/{lake}/zones/{zone} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dataplex.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Create a metadata entity. + * + * The async variant is {@see MetadataServiceClient::createEntityAsync()} . + * + * @example samples/V1/MetadataServiceClient/create_entity.php + * + * @param CreateEntityRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Entity + * + * @throws ApiException Thrown if the API call fails. + */ + public function createEntity(CreateEntityRequest $request, array $callOptions = []): Entity + { + return $this->startApiCall('CreateEntity', $request, $callOptions)->wait(); + } + + /** + * Create a metadata partition. + * + * The async variant is {@see MetadataServiceClient::createPartitionAsync()} . + * + * @example samples/V1/MetadataServiceClient/create_partition.php + * + * @param CreatePartitionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Partition + * + * @throws ApiException Thrown if the API call fails. + */ + public function createPartition(CreatePartitionRequest $request, array $callOptions = []): Partition + { + return $this->startApiCall('CreatePartition', $request, $callOptions)->wait(); + } + + /** + * Delete a metadata entity. + * + * The async variant is {@see MetadataServiceClient::deleteEntityAsync()} . + * + * @example samples/V1/MetadataServiceClient/delete_entity.php + * + * @param DeleteEntityRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteEntity(DeleteEntityRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteEntity', $request, $callOptions)->wait(); + } + + /** + * Delete a metadata partition. + * + * The async variant is {@see MetadataServiceClient::deletePartitionAsync()} . + * + * @example samples/V1/MetadataServiceClient/delete_partition.php + * + * @param DeletePartitionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deletePartition(DeletePartitionRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeletePartition', $request, $callOptions)->wait(); + } + + /** + * Get a metadata entity. + * + * The async variant is {@see MetadataServiceClient::getEntityAsync()} . + * + * @example samples/V1/MetadataServiceClient/get_entity.php + * + * @param GetEntityRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Entity + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEntity(GetEntityRequest $request, array $callOptions = []): Entity + { + return $this->startApiCall('GetEntity', $request, $callOptions)->wait(); + } + + /** + * Get a metadata partition of an entity. + * + * The async variant is {@see MetadataServiceClient::getPartitionAsync()} . + * + * @example samples/V1/MetadataServiceClient/get_partition.php + * + * @param GetPartitionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Partition + * + * @throws ApiException Thrown if the API call fails. + */ + public function getPartition(GetPartitionRequest $request, array $callOptions = []): Partition + { + return $this->startApiCall('GetPartition', $request, $callOptions)->wait(); + } + + /** + * List metadata entities in a zone. + * + * The async variant is {@see MetadataServiceClient::listEntitiesAsync()} . + * + * @example samples/V1/MetadataServiceClient/list_entities.php + * + * @param ListEntitiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listEntities(ListEntitiesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEntities', $request, $callOptions); + } + + /** + * List metadata partitions of an entity. + * + * The async variant is {@see MetadataServiceClient::listPartitionsAsync()} . + * + * @example samples/V1/MetadataServiceClient/list_partitions.php + * + * @param ListPartitionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPartitions(ListPartitionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPartitions', $request, $callOptions); + } + + /** + * Update a metadata entity. Only supports full resource update. + * + * The async variant is {@see MetadataServiceClient::updateEntityAsync()} . + * + * @example samples/V1/MetadataServiceClient/update_entity.php + * + * @param UpdateEntityRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Entity + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateEntity(UpdateEntityRequest $request, array $callOptions = []): Entity + { + return $this->startApiCall('UpdateEntity', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see MetadataServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/MetadataServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see MetadataServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/MetadataServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see MetadataServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/MetadataServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see MetadataServiceClient::getLocationAsync()} . + * + * @example samples/V1/MetadataServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see MetadataServiceClient::listLocationsAsync()} . + * + * @example samples/V1/MetadataServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Dataplex/src/V1/DataQualityDimension.php b/Dataplex/src/V1/DataQualityDimension.php new file mode 100644 index 000000000000..cce04568241c --- /dev/null +++ b/Dataplex/src/V1/DataQualityDimension.php @@ -0,0 +1,76 @@ +google.cloud.dataplex.v1.DataQualityDimension + */ +class DataQualityDimension extends \Google\Protobuf\Internal\Message +{ + /** + * The dimension name a rule belongs to. Supported dimensions are + * ["COMPLETENESS", "ACCURACY", "CONSISTENCY", "VALIDITY", "UNIQUENESS", + * "INTEGRITY"] + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * The dimension name a rule belongs to. Supported dimensions are + * ["COMPLETENESS", "ACCURACY", "CONSISTENCY", "VALIDITY", "UNIQUENESS", + * "INTEGRITY"] + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Dataplex\V1\DataQuality::initOnce(); + parent::__construct($data); + } + + /** + * The dimension name a rule belongs to. Supported dimensions are + * ["COMPLETENESS", "ACCURACY", "CONSISTENCY", "VALIDITY", "UNIQUENESS", + * "INTEGRITY"] + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * The dimension name a rule belongs to. Supported dimensions are + * ["COMPLETENESS", "ACCURACY", "CONSISTENCY", "VALIDITY", "UNIQUENESS", + * "INTEGRITY"] + * + * 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; + } + +} + diff --git a/Dataplex/src/V1/DataQualityDimensionResult.php b/Dataplex/src/V1/DataQualityDimensionResult.php index 22172600650b..2b46cd07c939 100644 --- a/Dataplex/src/V1/DataQualityDimensionResult.php +++ b/Dataplex/src/V1/DataQualityDimensionResult.php @@ -16,6 +16,12 @@ */ class DataQualityDimensionResult extends \Google\Protobuf\Internal\Message { + /** + * Output only. The dimension config specified in the DataQualitySpec, as is. + * + * Generated from protobuf field .google.cloud.dataplex.v1.DataQualityDimension dimension = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $dimension = null; /** * Whether the dimension passed or failed. * @@ -29,6 +35,8 @@ class DataQualityDimensionResult extends \Google\Protobuf\Internal\Message * @param array $data { * Optional. Data for populating the Message object. * + * @type \Google\Cloud\Dataplex\V1\DataQualityDimension $dimension + * Output only. The dimension config specified in the DataQualitySpec, as is. * @type bool $passed * Whether the dimension passed or failed. * } @@ -38,6 +46,42 @@ public function __construct($data = NULL) { parent::__construct($data); } + /** + * Output only. The dimension config specified in the DataQualitySpec, as is. + * + * Generated from protobuf field .google.cloud.dataplex.v1.DataQualityDimension dimension = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Cloud\Dataplex\V1\DataQualityDimension|null + */ + public function getDimension() + { + return $this->dimension; + } + + public function hasDimension() + { + return isset($this->dimension); + } + + public function clearDimension() + { + unset($this->dimension); + } + + /** + * Output only. The dimension config specified in the DataQualitySpec, as is. + * + * Generated from protobuf field .google.cloud.dataplex.v1.DataQualityDimension dimension = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Cloud\Dataplex\V1\DataQualityDimension $var + * @return $this + */ + public function setDimension($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Dataplex\V1\DataQualityDimension::class); + $this->dimension = $var; + + return $this; + } + /** * Whether the dimension passed or failed. * diff --git a/Dataproc/composer.json b/Dataproc/composer.json index d67efef12aa4..aa86195de0d3 100644 --- a/Dataproc/composer.json +++ b/Dataproc/composer.json @@ -19,11 +19,11 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", - "google/cloud-core": "^1.39" + "google/cloud-core": "^1.52.7" }, "suggest": { "ext-protobuf": "Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions." diff --git a/Dataproc/src/V1/Client/AutoscalingPolicyServiceClient.php b/Dataproc/src/V1/Client/AutoscalingPolicyServiceClient.php index d410c7e35c4d..21f9d04af1c9 100644 --- a/Dataproc/src/V1/Client/AutoscalingPolicyServiceClient.php +++ b/Dataproc/src/V1/Client/AutoscalingPolicyServiceClient.php @@ -24,17 +24,496 @@ namespace Google\Cloud\Dataproc\V1\Client; -use Google\Cloud\Dataproc\V1\Client\BaseClient\AutoscalingPolicyServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dataproc\V1\AutoscalingPolicy; +use Google\Cloud\Dataproc\V1\CreateAutoscalingPolicyRequest; +use Google\Cloud\Dataproc\V1\DeleteAutoscalingPolicyRequest; +use Google\Cloud\Dataproc\V1\GetAutoscalingPolicyRequest; +use Google\Cloud\Dataproc\V1\ListAutoscalingPoliciesRequest; +use Google\Cloud\Dataproc\V1\UpdateAutoscalingPolicyRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The API interface for managing autoscaling policies in the + * Dataproc API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dataproc\V1\AutoscalingPolicyServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createAutoscalingPolicyAsync(CreateAutoscalingPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAutoscalingPolicyAsync(DeleteAutoscalingPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAutoscalingPolicyAsync(GetAutoscalingPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAutoscalingPoliciesAsync(ListAutoscalingPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAutoscalingPolicyAsync(UpdateAutoscalingPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class AutoscalingPolicyServiceClient extends AutoscalingPolicyServiceBaseClient +final class AutoscalingPolicyServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AutoscalingPolicyServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dataproc.v1.AutoscalingPolicyService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dataproc.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/autoscaling_policy_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/autoscaling_policy_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/autoscaling_policy_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/autoscaling_policy_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * autoscaling_policy resource. + * + * @param string $project + * @param string $location + * @param string $autoscalingPolicy + * + * @return string The formatted autoscaling_policy resource. + */ + public static function autoscalingPolicyName(string $project, string $location, string $autoscalingPolicy): string + { + return self::getPathTemplate('autoscalingPolicy')->render([ + 'project' => $project, + 'location' => $location, + 'autoscaling_policy' => $autoscalingPolicy, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_autoscaling_policy resource. + * + * @param string $project + * @param string $location + * @param string $autoscalingPolicy + * + * @return string The formatted project_location_autoscaling_policy resource. + */ + public static function projectLocationAutoscalingPolicyName(string $project, string $location, string $autoscalingPolicy): string + { + return self::getPathTemplate('projectLocationAutoscalingPolicy')->render([ + 'project' => $project, + 'location' => $location, + 'autoscaling_policy' => $autoscalingPolicy, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_region_autoscaling_policy resource. + * + * @param string $project + * @param string $region + * @param string $autoscalingPolicy + * + * @return string The formatted project_region_autoscaling_policy resource. + */ + public static function projectRegionAutoscalingPolicyName(string $project, string $region, string $autoscalingPolicy): string + { + return self::getPathTemplate('projectRegionAutoscalingPolicy')->render([ + 'project' => $project, + 'region' => $region, + 'autoscaling_policy' => $autoscalingPolicy, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a region + * resource. + * + * @param string $project + * @param string $region + * + * @return string The formatted region resource. + */ + public static function regionName(string $project, string $region): string + { + return self::getPathTemplate('region')->render([ + 'project' => $project, + 'region' => $region, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - autoscalingPolicy: projects/{project}/locations/{location}/autoscalingPolicies/{autoscaling_policy} + * - location: projects/{project}/locations/{location} + * - projectLocationAutoscalingPolicy: projects/{project}/locations/{location}/autoscalingPolicies/{autoscaling_policy} + * - projectRegionAutoscalingPolicy: projects/{project}/regions/{region}/autoscalingPolicies/{autoscaling_policy} + * - region: projects/{project}/regions/{region} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dataproc.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates new autoscaling policy. + * + * The async variant is + * {@see AutoscalingPolicyServiceClient::createAutoscalingPolicyAsync()} . + * + * @param CreateAutoscalingPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AutoscalingPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAutoscalingPolicy(CreateAutoscalingPolicyRequest $request, array $callOptions = []): AutoscalingPolicy + { + return $this->startApiCall('CreateAutoscalingPolicy', $request, $callOptions)->wait(); + } + + /** + * Deletes an autoscaling policy. It is an error to delete an autoscaling + * policy that is in use by one or more clusters. + * + * The async variant is + * {@see AutoscalingPolicyServiceClient::deleteAutoscalingPolicyAsync()} . + * + * @param DeleteAutoscalingPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAutoscalingPolicy(DeleteAutoscalingPolicyRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteAutoscalingPolicy', $request, $callOptions)->wait(); + } + + /** + * Retrieves autoscaling policy. + * + * The async variant is + * {@see AutoscalingPolicyServiceClient::getAutoscalingPolicyAsync()} . + * + * @param GetAutoscalingPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AutoscalingPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAutoscalingPolicy(GetAutoscalingPolicyRequest $request, array $callOptions = []): AutoscalingPolicy + { + return $this->startApiCall('GetAutoscalingPolicy', $request, $callOptions)->wait(); + } + + /** + * Lists autoscaling policies in the project. + * + * The async variant is + * {@see AutoscalingPolicyServiceClient::listAutoscalingPoliciesAsync()} . + * + * @param ListAutoscalingPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAutoscalingPolicies(ListAutoscalingPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAutoscalingPolicies', $request, $callOptions); + } + + /** + * Updates (replaces) autoscaling policy. + * + * Disabled check for update_mask, because all updates will be full + * replacements. + * + * The async variant is + * {@see AutoscalingPolicyServiceClient::updateAutoscalingPolicyAsync()} . + * + * @param UpdateAutoscalingPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AutoscalingPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAutoscalingPolicy(UpdateAutoscalingPolicyRequest $request, array $callOptions = []): AutoscalingPolicy + { + return $this->startApiCall('UpdateAutoscalingPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see AutoscalingPolicyServiceClient::getIamPolicyAsync()} + * . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see AutoscalingPolicyServiceClient::setIamPolicyAsync()} + * . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is + * {@see AutoscalingPolicyServiceClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Dataproc/src/V1/Client/BaseClient/AutoscalingPolicyServiceBaseClient.php b/Dataproc/src/V1/Client/BaseClient/AutoscalingPolicyServiceBaseClient.php deleted file mode 100644 index e3113c4422e8..000000000000 --- a/Dataproc/src/V1/Client/BaseClient/AutoscalingPolicyServiceBaseClient.php +++ /dev/null @@ -1,513 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/autoscaling_policy_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/autoscaling_policy_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/autoscaling_policy_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/autoscaling_policy_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * autoscaling_policy resource. - * - * @param string $project - * @param string $location - * @param string $autoscalingPolicy - * - * @return string The formatted autoscaling_policy resource. - */ - public static function autoscalingPolicyName(string $project, string $location, string $autoscalingPolicy): string - { - return self::getPathTemplate('autoscalingPolicy')->render([ - 'project' => $project, - 'location' => $location, - 'autoscaling_policy' => $autoscalingPolicy, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_autoscaling_policy resource. - * - * @param string $project - * @param string $location - * @param string $autoscalingPolicy - * - * @return string The formatted project_location_autoscaling_policy resource. - */ - public static function projectLocationAutoscalingPolicyName(string $project, string $location, string $autoscalingPolicy): string - { - return self::getPathTemplate('projectLocationAutoscalingPolicy')->render([ - 'project' => $project, - 'location' => $location, - 'autoscaling_policy' => $autoscalingPolicy, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_region_autoscaling_policy resource. - * - * @param string $project - * @param string $region - * @param string $autoscalingPolicy - * - * @return string The formatted project_region_autoscaling_policy resource. - */ - public static function projectRegionAutoscalingPolicyName(string $project, string $region, string $autoscalingPolicy): string - { - return self::getPathTemplate('projectRegionAutoscalingPolicy')->render([ - 'project' => $project, - 'region' => $region, - 'autoscaling_policy' => $autoscalingPolicy, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a region - * resource. - * - * @param string $project - * @param string $region - * - * @return string The formatted region resource. - */ - public static function regionName(string $project, string $region): string - { - return self::getPathTemplate('region')->render([ - 'project' => $project, - 'region' => $region, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - autoscalingPolicy: projects/{project}/locations/{location}/autoscalingPolicies/{autoscaling_policy} - * - location: projects/{project}/locations/{location} - * - projectLocationAutoscalingPolicy: projects/{project}/locations/{location}/autoscalingPolicies/{autoscaling_policy} - * - projectRegionAutoscalingPolicy: projects/{project}/regions/{region}/autoscalingPolicies/{autoscaling_policy} - * - region: projects/{project}/regions/{region} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dataproc.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates new autoscaling policy. - * - * The async variant is {@see self::createAutoscalingPolicyAsync()} . - * - * @param CreateAutoscalingPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AutoscalingPolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAutoscalingPolicy(CreateAutoscalingPolicyRequest $request, array $callOptions = []): AutoscalingPolicy - { - return $this->startApiCall('CreateAutoscalingPolicy', $request, $callOptions)->wait(); - } - - /** - * Deletes an autoscaling policy. It is an error to delete an autoscaling - * policy that is in use by one or more clusters. - * - * The async variant is {@see self::deleteAutoscalingPolicyAsync()} . - * - * @param DeleteAutoscalingPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAutoscalingPolicy(DeleteAutoscalingPolicyRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteAutoscalingPolicy', $request, $callOptions)->wait(); - } - - /** - * Retrieves autoscaling policy. - * - * The async variant is {@see self::getAutoscalingPolicyAsync()} . - * - * @param GetAutoscalingPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AutoscalingPolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAutoscalingPolicy(GetAutoscalingPolicyRequest $request, array $callOptions = []): AutoscalingPolicy - { - return $this->startApiCall('GetAutoscalingPolicy', $request, $callOptions)->wait(); - } - - /** - * Lists autoscaling policies in the project. - * - * The async variant is {@see self::listAutoscalingPoliciesAsync()} . - * - * @param ListAutoscalingPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAutoscalingPolicies(ListAutoscalingPoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAutoscalingPolicies', $request, $callOptions); - } - - /** - * Updates (replaces) autoscaling policy. - * - * Disabled check for update_mask, because all updates will be full - * replacements. - * - * The async variant is {@see self::updateAutoscalingPolicyAsync()} . - * - * @param UpdateAutoscalingPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AutoscalingPolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAutoscalingPolicy(UpdateAutoscalingPolicyRequest $request, array $callOptions = []): AutoscalingPolicy - { - return $this->startApiCall('UpdateAutoscalingPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Dataproc/src/V1/Client/BaseClient/BatchControllerBaseClient.php b/Dataproc/src/V1/Client/BaseClient/BatchControllerBaseClient.php deleted file mode 100644 index 5de0c19d85f4..000000000000 --- a/Dataproc/src/V1/Client/BaseClient/BatchControllerBaseClient.php +++ /dev/null @@ -1,479 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/batch_controller_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/batch_controller_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/batch_controller_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/batch_controller_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a batch - * resource. - * - * @param string $project - * @param string $location - * @param string $batch - * - * @return string The formatted batch resource. - */ - public static function batchName(string $project, string $location, string $batch): string - { - return self::getPathTemplate('batch')->render([ - 'project' => $project, - 'location' => $location, - 'batch' => $batch, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a service - * resource. - * - * @param string $project - * @param string $location - * @param string $service - * - * @return string The formatted service resource. - */ - public static function serviceName(string $project, string $location, string $service): string - { - return self::getPathTemplate('service')->render([ - 'project' => $project, - 'location' => $location, - 'service' => $service, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - batch: projects/{project}/locations/{location}/batches/{batch} - * - location: projects/{project}/locations/{location} - * - service: projects/{project}/locations/{location}/services/{service} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dataproc.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a batch workload that executes asynchronously. - * - * The async variant is {@see self::createBatchAsync()} . - * - * @param CreateBatchRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createBatch(CreateBatchRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateBatch', $request, $callOptions)->wait(); - } - - /** - * Deletes the batch workload resource. If the batch is not in terminal state, - * the delete fails and the response returns `FAILED_PRECONDITION`. - * - * The async variant is {@see self::deleteBatchAsync()} . - * - * @param DeleteBatchRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteBatch(DeleteBatchRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteBatch', $request, $callOptions)->wait(); - } - - /** - * Gets the batch workload resource representation. - * - * The async variant is {@see self::getBatchAsync()} . - * - * @param GetBatchRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Batch - * - * @throws ApiException Thrown if the API call fails. - */ - public function getBatch(GetBatchRequest $request, array $callOptions = []): Batch - { - return $this->startApiCall('GetBatch', $request, $callOptions)->wait(); - } - - /** - * Lists batch workloads. - * - * The async variant is {@see self::listBatchesAsync()} . - * - * @param ListBatchesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listBatches(ListBatchesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListBatches', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Dataproc/src/V1/Client/BaseClient/ClusterControllerBaseClient.php b/Dataproc/src/V1/Client/BaseClient/ClusterControllerBaseClient.php deleted file mode 100644 index c554a07f3264..000000000000 --- a/Dataproc/src/V1/Client/BaseClient/ClusterControllerBaseClient.php +++ /dev/null @@ -1,626 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/cluster_controller_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/cluster_controller_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/cluster_controller_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/cluster_controller_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a cluster - * resource. - * - * @param string $project - * @param string $location - * @param string $cluster - * - * @return string The formatted cluster resource. - */ - public static function clusterName(string $project, string $location, string $cluster): string - { - return self::getPathTemplate('cluster')->render([ - 'project' => $project, - 'location' => $location, - 'cluster' => $cluster, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * cluster_region resource. - * - * @param string $project - * @param string $region - * @param string $cluster - * - * @return string The formatted cluster_region resource. - */ - public static function clusterRegionName(string $project, string $region, string $cluster): string - { - return self::getPathTemplate('clusterRegion')->render([ - 'project' => $project, - 'region' => $region, - 'cluster' => $cluster, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a node_group - * resource. - * - * @param string $project - * @param string $region - * @param string $cluster - * @param string $nodeGroup - * - * @return string The formatted node_group resource. - */ - public static function nodeGroupName(string $project, string $region, string $cluster, string $nodeGroup): string - { - return self::getPathTemplate('nodeGroup')->render([ - 'project' => $project, - 'region' => $region, - 'cluster' => $cluster, - 'node_group' => $nodeGroup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a service - * resource. - * - * @param string $project - * @param string $location - * @param string $service - * - * @return string The formatted service resource. - */ - public static function serviceName(string $project, string $location, string $service): string - { - return self::getPathTemplate('service')->render([ - 'project' => $project, - 'location' => $location, - 'service' => $service, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - cluster: projects/{project}/locations/{location}/clusters/{cluster} - * - clusterRegion: projects/{project}/regions/{region}/clusters/{cluster} - * - nodeGroup: projects/{project}/regions/{region}/clusters/{cluster}/nodeGroups/{node_group} - * - service: projects/{project}/locations/{location}/services/{service} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dataproc.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a cluster in a project. The returned - * [Operation.metadata][google.longrunning.Operation.metadata] will be - * [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata). - * - * The async variant is {@see self::createClusterAsync()} . - * - * @param CreateClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCluster(CreateClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateCluster', $request, $callOptions)->wait(); - } - - /** - * Deletes a cluster in a project. The returned - * [Operation.metadata][google.longrunning.Operation.metadata] will be - * [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata). - * - * The async variant is {@see self::deleteClusterAsync()} . - * - * @param DeleteClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteCluster(DeleteClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteCluster', $request, $callOptions)->wait(); - } - - /** - * Gets cluster diagnostic information. The returned - * [Operation.metadata][google.longrunning.Operation.metadata] will be - * [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata). - * After the operation completes, - * [Operation.response][google.longrunning.Operation.response] - * contains - * [DiagnoseClusterResults](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#diagnoseclusterresults). - * - * The async variant is {@see self::diagnoseClusterAsync()} . - * - * @param DiagnoseClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function diagnoseCluster(DiagnoseClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DiagnoseCluster', $request, $callOptions)->wait(); - } - - /** - * Gets the resource representation for a cluster in a project. - * - * The async variant is {@see self::getClusterAsync()} . - * - * @param GetClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Cluster - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCluster(GetClusterRequest $request, array $callOptions = []): Cluster - { - return $this->startApiCall('GetCluster', $request, $callOptions)->wait(); - } - - /** - * Lists all regions/{region}/clusters in a project alphabetically. - * - * The async variant is {@see self::listClustersAsync()} . - * - * @param ListClustersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listClusters(ListClustersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListClusters', $request, $callOptions); - } - - /** - * Starts a cluster in a project. - * - * The async variant is {@see self::startClusterAsync()} . - * - * @param StartClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function startCluster(StartClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StartCluster', $request, $callOptions)->wait(); - } - - /** - * Stops a cluster in a project. - * - * The async variant is {@see self::stopClusterAsync()} . - * - * @param StopClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function stopCluster(StopClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StopCluster', $request, $callOptions)->wait(); - } - - /** - * Updates a cluster in a project. The returned - * [Operation.metadata][google.longrunning.Operation.metadata] will be - * [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata). - * The cluster must be in a - * [`RUNNING`][google.cloud.dataproc.v1.ClusterStatus.State] state or an error - * is returned. - * - * The async variant is {@see self::updateClusterAsync()} . - * - * @param UpdateClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCluster(UpdateClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateCluster', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Dataproc/src/V1/Client/BaseClient/JobControllerBaseClient.php b/Dataproc/src/V1/Client/BaseClient/JobControllerBaseClient.php deleted file mode 100644 index 6f2112135248..000000000000 --- a/Dataproc/src/V1/Client/BaseClient/JobControllerBaseClient.php +++ /dev/null @@ -1,472 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/job_controller_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/job_controller_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/job_controller_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/job_controller_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'dataproc.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Starts a job cancellation request. To access the job resource - * after cancellation, call - * [regions/{region}/jobs.list](https://cloud.google.com/dataproc/docs/reference/rest/v1/projects.regions.jobs/list) - * or - * [regions/{region}/jobs.get](https://cloud.google.com/dataproc/docs/reference/rest/v1/projects.regions.jobs/get). - * - * The async variant is {@see self::cancelJobAsync()} . - * - * @param CancelJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - */ - public function cancelJob(CancelJobRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('CancelJob', $request, $callOptions)->wait(); - } - - /** - * Deletes the job from the project. If the job is active, the delete fails, - * and the response returns `FAILED_PRECONDITION`. - * - * The async variant is {@see self::deleteJobAsync()} . - * - * @param DeleteJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteJob(DeleteJobRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteJob', $request, $callOptions)->wait(); - } - - /** - * Gets the resource representation for a job in a project. - * - * The async variant is {@see self::getJobAsync()} . - * - * @param GetJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - */ - public function getJob(GetJobRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('GetJob', $request, $callOptions)->wait(); - } - - /** - * Lists regions/{region}/jobs in a project. - * - * The async variant is {@see self::listJobsAsync()} . - * - * @param ListJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listJobs(ListJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListJobs', $request, $callOptions); - } - - /** - * Submits a job to a cluster. - * - * The async variant is {@see self::submitJobAsync()} . - * - * @param SubmitJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - */ - public function submitJob(SubmitJobRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('SubmitJob', $request, $callOptions)->wait(); - } - - /** - * Submits job to a cluster. - * - * The async variant is {@see self::submitJobAsOperationAsync()} . - * - * @param SubmitJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function submitJobAsOperation(SubmitJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SubmitJobAsOperation', $request, $callOptions)->wait(); - } - - /** - * Updates a job in a project. - * - * The async variant is {@see self::updateJobAsync()} . - * - * @param UpdateJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateJob(UpdateJobRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('UpdateJob', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Dataproc/src/V1/Client/BaseClient/NodeGroupControllerBaseClient.php b/Dataproc/src/V1/Client/BaseClient/NodeGroupControllerBaseClient.php deleted file mode 100644 index ec1a6c3ff3bb..000000000000 --- a/Dataproc/src/V1/Client/BaseClient/NodeGroupControllerBaseClient.php +++ /dev/null @@ -1,445 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/node_group_controller_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/node_group_controller_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/node_group_controller_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/node_group_controller_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * cluster_region resource. - * - * @param string $project - * @param string $region - * @param string $cluster - * - * @return string The formatted cluster_region resource. - */ - public static function clusterRegionName(string $project, string $region, string $cluster): string - { - return self::getPathTemplate('clusterRegion')->render([ - 'project' => $project, - 'region' => $region, - 'cluster' => $cluster, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a node_group - * resource. - * - * @param string $project - * @param string $region - * @param string $cluster - * @param string $nodeGroup - * - * @return string The formatted node_group resource. - */ - public static function nodeGroupName(string $project, string $region, string $cluster, string $nodeGroup): string - { - return self::getPathTemplate('nodeGroup')->render([ - 'project' => $project, - 'region' => $region, - 'cluster' => $cluster, - 'node_group' => $nodeGroup, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - clusterRegion: projects/{project}/regions/{region}/clusters/{cluster} - * - nodeGroup: projects/{project}/regions/{region}/clusters/{cluster}/nodeGroups/{node_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. - */ - public static function parseName(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dataproc.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a node group in a cluster. The returned - * [Operation.metadata][google.longrunning.Operation.metadata] is - * [NodeGroupOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#nodegroupoperationmetadata). - * - * The async variant is {@see self::createNodeGroupAsync()} . - * - * @param CreateNodeGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createNodeGroup(CreateNodeGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateNodeGroup', $request, $callOptions)->wait(); - } - - /** - * Gets the resource representation for a node group in a - * cluster. - * - * The async variant is {@see self::getNodeGroupAsync()} . - * - * @param GetNodeGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NodeGroup - * - * @throws ApiException Thrown if the API call fails. - */ - public function getNodeGroup(GetNodeGroupRequest $request, array $callOptions = []): NodeGroup - { - return $this->startApiCall('GetNodeGroup', $request, $callOptions)->wait(); - } - - /** - * Resizes a node group in a cluster. The returned - * [Operation.metadata][google.longrunning.Operation.metadata] is - * [NodeGroupOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#nodegroupoperationmetadata). - * - * The async variant is {@see self::resizeNodeGroupAsync()} . - * - * @param ResizeNodeGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function resizeNodeGroup(ResizeNodeGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ResizeNodeGroup', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Dataproc/src/V1/Client/BaseClient/WorkflowTemplateServiceBaseClient.php b/Dataproc/src/V1/Client/BaseClient/WorkflowTemplateServiceBaseClient.php deleted file mode 100644 index 81c722386940..000000000000 --- a/Dataproc/src/V1/Client/BaseClient/WorkflowTemplateServiceBaseClient.php +++ /dev/null @@ -1,706 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/workflow_template_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/workflow_template_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/workflow_template_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/workflow_template_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * cluster_region resource. - * - * @param string $project - * @param string $region - * @param string $cluster - * - * @return string The formatted cluster_region resource. - */ - public static function clusterRegionName(string $project, string $region, string $cluster): string - { - return self::getPathTemplate('clusterRegion')->render([ - 'project' => $project, - 'region' => $region, - 'cluster' => $cluster, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a node_group - * resource. - * - * @param string $project - * @param string $region - * @param string $cluster - * @param string $nodeGroup - * - * @return string The formatted node_group resource. - */ - public static function nodeGroupName(string $project, string $region, string $cluster, string $nodeGroup): string - { - return self::getPathTemplate('nodeGroup')->render([ - 'project' => $project, - 'region' => $region, - 'cluster' => $cluster, - 'node_group' => $nodeGroup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_workflow_template resource. - * - * @param string $project - * @param string $location - * @param string $workflowTemplate - * - * @return string The formatted project_location_workflow_template resource. - */ - public static function projectLocationWorkflowTemplateName(string $project, string $location, string $workflowTemplate): string - { - return self::getPathTemplate('projectLocationWorkflowTemplate')->render([ - 'project' => $project, - 'location' => $location, - 'workflow_template' => $workflowTemplate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_region_workflow_template resource. - * - * @param string $project - * @param string $region - * @param string $workflowTemplate - * - * @return string The formatted project_region_workflow_template resource. - */ - public static function projectRegionWorkflowTemplateName(string $project, string $region, string $workflowTemplate): string - { - return self::getPathTemplate('projectRegionWorkflowTemplate')->render([ - 'project' => $project, - 'region' => $region, - 'workflow_template' => $workflowTemplate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a region - * resource. - * - * @param string $project - * @param string $region - * - * @return string The formatted region resource. - */ - public static function regionName(string $project, string $region): string - { - return self::getPathTemplate('region')->render([ - 'project' => $project, - 'region' => $region, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a service - * resource. - * - * @param string $project - * @param string $location - * @param string $service - * - * @return string The formatted service resource. - */ - public static function serviceName(string $project, string $location, string $service): string - { - return self::getPathTemplate('service')->render([ - 'project' => $project, - 'location' => $location, - 'service' => $service, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * workflow_template resource. - * - * @param string $project - * @param string $region - * @param string $workflowTemplate - * - * @return string The formatted workflow_template resource. - */ - public static function workflowTemplateName(string $project, string $region, string $workflowTemplate): string - { - return self::getPathTemplate('workflowTemplate')->render([ - 'project' => $project, - 'region' => $region, - 'workflow_template' => $workflowTemplate, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - clusterRegion: projects/{project}/regions/{region}/clusters/{cluster} - * - location: projects/{project}/locations/{location} - * - nodeGroup: projects/{project}/regions/{region}/clusters/{cluster}/nodeGroups/{node_group} - * - projectLocationWorkflowTemplate: projects/{project}/locations/{location}/workflowTemplates/{workflow_template} - * - projectRegionWorkflowTemplate: projects/{project}/regions/{region}/workflowTemplates/{workflow_template} - * - region: projects/{project}/regions/{region} - * - service: projects/{project}/locations/{location}/services/{service} - * - workflowTemplate: projects/{project}/regions/{region}/workflowTemplates/{workflow_template} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dataproc.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates new workflow template. - * - * The async variant is {@see self::createWorkflowTemplateAsync()} . - * - * @param CreateWorkflowTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 WorkflowTemplate - * - * @throws ApiException Thrown if the API call fails. - */ - public function createWorkflowTemplate(CreateWorkflowTemplateRequest $request, array $callOptions = []): WorkflowTemplate - { - return $this->startApiCall('CreateWorkflowTemplate', $request, $callOptions)->wait(); - } - - /** - * Deletes a workflow template. It does not cancel in-progress workflows. - * - * The async variant is {@see self::deleteWorkflowTemplateAsync()} . - * - * @param DeleteWorkflowTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteWorkflowTemplate(DeleteWorkflowTemplateRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteWorkflowTemplate', $request, $callOptions)->wait(); - } - - /** - * Retrieves the latest workflow template. - * - * Can retrieve previously instantiated template by specifying optional - * version parameter. - * - * The async variant is {@see self::getWorkflowTemplateAsync()} . - * - * @param GetWorkflowTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 WorkflowTemplate - * - * @throws ApiException Thrown if the API call fails. - */ - public function getWorkflowTemplate(GetWorkflowTemplateRequest $request, array $callOptions = []): WorkflowTemplate - { - return $this->startApiCall('GetWorkflowTemplate', $request, $callOptions)->wait(); - } - - /** - * Instantiates a template and begins execution. - * - * This method is equivalent to executing the sequence - * [CreateWorkflowTemplate][google.cloud.dataproc.v1.WorkflowTemplateService.CreateWorkflowTemplate], - * [InstantiateWorkflowTemplate][google.cloud.dataproc.v1.WorkflowTemplateService.InstantiateWorkflowTemplate], - * [DeleteWorkflowTemplate][google.cloud.dataproc.v1.WorkflowTemplateService.DeleteWorkflowTemplate]. - * - * The returned Operation can be used to track execution of - * workflow by polling - * [operations.get][google.longrunning.Operations.GetOperation]. - * The Operation will complete when entire workflow is finished. - * - * The running workflow can be aborted via - * [operations.cancel][google.longrunning.Operations.CancelOperation]. - * This will cause any inflight jobs to be cancelled and workflow-owned - * clusters to be deleted. - * - * The [Operation.metadata][google.longrunning.Operation.metadata] will be - * [WorkflowMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#workflowmetadata). - * Also see [Using - * WorkflowMetadata](https://cloud.google.com/dataproc/docs/concepts/workflows/debugging#using_workflowmetadata). - * - * On successful completion, - * [Operation.response][google.longrunning.Operation.response] will be - * [Empty][google.protobuf.Empty]. - * - * The async variant is {@see self::instantiateInlineWorkflowTemplateAsync()} . - * - * @param InstantiateInlineWorkflowTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function instantiateInlineWorkflowTemplate(InstantiateInlineWorkflowTemplateRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('InstantiateInlineWorkflowTemplate', $request, $callOptions)->wait(); - } - - /** - * Instantiates a template and begins execution. - * - * The returned Operation can be used to track execution of - * workflow by polling - * [operations.get][google.longrunning.Operations.GetOperation]. - * The Operation will complete when entire workflow is finished. - * - * The running workflow can be aborted via - * [operations.cancel][google.longrunning.Operations.CancelOperation]. - * This will cause any inflight jobs to be cancelled and workflow-owned - * clusters to be deleted. - * - * The [Operation.metadata][google.longrunning.Operation.metadata] will be - * [WorkflowMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#workflowmetadata). - * Also see [Using - * WorkflowMetadata](https://cloud.google.com/dataproc/docs/concepts/workflows/debugging#using_workflowmetadata). - * - * On successful completion, - * [Operation.response][google.longrunning.Operation.response] will be - * [Empty][google.protobuf.Empty]. - * - * The async variant is {@see self::instantiateWorkflowTemplateAsync()} . - * - * @param InstantiateWorkflowTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function instantiateWorkflowTemplate(InstantiateWorkflowTemplateRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('InstantiateWorkflowTemplate', $request, $callOptions)->wait(); - } - - /** - * Lists workflows that match the specified filter in the request. - * - * The async variant is {@see self::listWorkflowTemplatesAsync()} . - * - * @param ListWorkflowTemplatesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listWorkflowTemplates(ListWorkflowTemplatesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListWorkflowTemplates', $request, $callOptions); - } - - /** - * Updates (replaces) workflow template. The updated template - * must contain version that matches the current server version. - * - * The async variant is {@see self::updateWorkflowTemplateAsync()} . - * - * @param UpdateWorkflowTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 WorkflowTemplate - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateWorkflowTemplate(UpdateWorkflowTemplateRequest $request, array $callOptions = []): WorkflowTemplate - { - return $this->startApiCall('UpdateWorkflowTemplate', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Dataproc/src/V1/Client/BatchControllerClient.php b/Dataproc/src/V1/Client/BatchControllerClient.php index 893119340f75..12861d745207 100644 --- a/Dataproc/src/V1/Client/BatchControllerClient.php +++ b/Dataproc/src/V1/Client/BatchControllerClient.php @@ -24,17 +24,454 @@ namespace Google\Cloud\Dataproc\V1\Client; -use Google\Cloud\Dataproc\V1\Client\BaseClient\BatchControllerBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dataproc\V1\Batch; +use Google\Cloud\Dataproc\V1\CreateBatchRequest; +use Google\Cloud\Dataproc\V1\DeleteBatchRequest; +use Google\Cloud\Dataproc\V1\GetBatchRequest; +use Google\Cloud\Dataproc\V1\ListBatchesRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The BatchController provides methods to manage batch workloads. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dataproc\V1\BatchControllerClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createBatchAsync(CreateBatchRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteBatchAsync(DeleteBatchRequest $request, array $optionalArgs = []) + * @method PromiseInterface getBatchAsync(GetBatchRequest $request, array $optionalArgs = []) + * @method PromiseInterface listBatchesAsync(ListBatchesRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class BatchControllerClient extends BatchControllerBaseClient +final class BatchControllerClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see BatchControllerBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dataproc.v1.BatchController'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dataproc.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/batch_controller_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/batch_controller_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/batch_controller_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/batch_controller_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a batch + * resource. + * + * @param string $project + * @param string $location + * @param string $batch + * + * @return string The formatted batch resource. + */ + public static function batchName(string $project, string $location, string $batch): string + { + return self::getPathTemplate('batch')->render([ + 'project' => $project, + 'location' => $location, + 'batch' => $batch, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a service + * resource. + * + * @param string $project + * @param string $location + * @param string $service + * + * @return string The formatted service resource. + */ + public static function serviceName(string $project, string $location, string $service): string + { + return self::getPathTemplate('service')->render([ + 'project' => $project, + 'location' => $location, + 'service' => $service, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - batch: projects/{project}/locations/{location}/batches/{batch} + * - location: projects/{project}/locations/{location} + * - service: projects/{project}/locations/{location}/services/{service} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dataproc.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a batch workload that executes asynchronously. + * + * The async variant is {@see BatchControllerClient::createBatchAsync()} . + * + * @param CreateBatchRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createBatch(CreateBatchRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateBatch', $request, $callOptions)->wait(); + } + + /** + * Deletes the batch workload resource. If the batch is not in terminal state, + * the delete fails and the response returns `FAILED_PRECONDITION`. + * + * The async variant is {@see BatchControllerClient::deleteBatchAsync()} . + * + * @param DeleteBatchRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteBatch(DeleteBatchRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteBatch', $request, $callOptions)->wait(); + } + + /** + * Gets the batch workload resource representation. + * + * The async variant is {@see BatchControllerClient::getBatchAsync()} . + * + * @param GetBatchRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Batch + * + * @throws ApiException Thrown if the API call fails. + */ + public function getBatch(GetBatchRequest $request, array $callOptions = []): Batch + { + return $this->startApiCall('GetBatch', $request, $callOptions)->wait(); + } + + /** + * Lists batch workloads. + * + * The async variant is {@see BatchControllerClient::listBatchesAsync()} . + * + * @param ListBatchesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listBatches(ListBatchesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListBatches', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see BatchControllerClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see BatchControllerClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see BatchControllerClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Dataproc/src/V1/Client/ClusterControllerClient.php b/Dataproc/src/V1/Client/ClusterControllerClient.php index 4f913d3a80ef..b6c0a4c6e5cd 100644 --- a/Dataproc/src/V1/Client/ClusterControllerClient.php +++ b/Dataproc/src/V1/Client/ClusterControllerClient.php @@ -24,17 +24,601 @@ namespace Google\Cloud\Dataproc\V1\Client; -use Google\Cloud\Dataproc\V1\Client\BaseClient\ClusterControllerBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dataproc\V1\Cluster; +use Google\Cloud\Dataproc\V1\ClusterOperationMetadata; +use Google\Cloud\Dataproc\V1\CreateClusterRequest; +use Google\Cloud\Dataproc\V1\DeleteClusterRequest; +use Google\Cloud\Dataproc\V1\DiagnoseClusterRequest; +use Google\Cloud\Dataproc\V1\DiagnoseClusterResults; +use Google\Cloud\Dataproc\V1\GetClusterRequest; +use Google\Cloud\Dataproc\V1\ListClustersRequest; +use Google\Cloud\Dataproc\V1\StartClusterRequest; +use Google\Cloud\Dataproc\V1\StopClusterRequest; +use Google\Cloud\Dataproc\V1\UpdateClusterRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The ClusterControllerService provides methods to manage clusters + * of Compute Engine instances. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dataproc\V1\ClusterControllerClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createClusterAsync(CreateClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteClusterAsync(DeleteClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface diagnoseClusterAsync(DiagnoseClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface getClusterAsync(GetClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface listClustersAsync(ListClustersRequest $request, array $optionalArgs = []) + * @method PromiseInterface startClusterAsync(StartClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface stopClusterAsync(StopClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateClusterAsync(UpdateClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class ClusterControllerClient extends ClusterControllerBaseClient +final class ClusterControllerClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ClusterControllerBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dataproc.v1.ClusterController'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dataproc.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/cluster_controller_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/cluster_controller_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/cluster_controller_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/cluster_controller_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a cluster + * resource. + * + * @param string $project + * @param string $location + * @param string $cluster + * + * @return string The formatted cluster resource. + */ + public static function clusterName(string $project, string $location, string $cluster): string + { + return self::getPathTemplate('cluster')->render([ + 'project' => $project, + 'location' => $location, + 'cluster' => $cluster, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * cluster_region resource. + * + * @param string $project + * @param string $region + * @param string $cluster + * + * @return string The formatted cluster_region resource. + */ + public static function clusterRegionName(string $project, string $region, string $cluster): string + { + return self::getPathTemplate('clusterRegion')->render([ + 'project' => $project, + 'region' => $region, + 'cluster' => $cluster, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a node_group + * resource. + * + * @param string $project + * @param string $region + * @param string $cluster + * @param string $nodeGroup + * + * @return string The formatted node_group resource. + */ + public static function nodeGroupName(string $project, string $region, string $cluster, string $nodeGroup): string + { + return self::getPathTemplate('nodeGroup')->render([ + 'project' => $project, + 'region' => $region, + 'cluster' => $cluster, + 'node_group' => $nodeGroup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a service + * resource. + * + * @param string $project + * @param string $location + * @param string $service + * + * @return string The formatted service resource. + */ + public static function serviceName(string $project, string $location, string $service): string + { + return self::getPathTemplate('service')->render([ + 'project' => $project, + 'location' => $location, + 'service' => $service, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - cluster: projects/{project}/locations/{location}/clusters/{cluster} + * - clusterRegion: projects/{project}/regions/{region}/clusters/{cluster} + * - nodeGroup: projects/{project}/regions/{region}/clusters/{cluster}/nodeGroups/{node_group} + * - service: projects/{project}/locations/{location}/services/{service} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dataproc.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a cluster in a project. The returned + * [Operation.metadata][google.longrunning.Operation.metadata] will be + * [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata). + * + * The async variant is {@see ClusterControllerClient::createClusterAsync()} . + * + * @param CreateClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCluster(CreateClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateCluster', $request, $callOptions)->wait(); + } + + /** + * Deletes a cluster in a project. The returned + * [Operation.metadata][google.longrunning.Operation.metadata] will be + * [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata). + * + * The async variant is {@see ClusterControllerClient::deleteClusterAsync()} . + * + * @param DeleteClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteCluster(DeleteClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteCluster', $request, $callOptions)->wait(); + } + + /** + * Gets cluster diagnostic information. The returned + * [Operation.metadata][google.longrunning.Operation.metadata] will be + * [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata). + * After the operation completes, + * [Operation.response][google.longrunning.Operation.response] + * contains + * [DiagnoseClusterResults](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#diagnoseclusterresults). + * + * The async variant is {@see ClusterControllerClient::diagnoseClusterAsync()} . + * + * @param DiagnoseClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function diagnoseCluster(DiagnoseClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DiagnoseCluster', $request, $callOptions)->wait(); + } + + /** + * Gets the resource representation for a cluster in a project. + * + * The async variant is {@see ClusterControllerClient::getClusterAsync()} . + * + * @param GetClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Cluster + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCluster(GetClusterRequest $request, array $callOptions = []): Cluster + { + return $this->startApiCall('GetCluster', $request, $callOptions)->wait(); + } + + /** + * Lists all regions/{region}/clusters in a project alphabetically. + * + * The async variant is {@see ClusterControllerClient::listClustersAsync()} . + * + * @param ListClustersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listClusters(ListClustersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListClusters', $request, $callOptions); + } + + /** + * Starts a cluster in a project. + * + * The async variant is {@see ClusterControllerClient::startClusterAsync()} . + * + * @param StartClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function startCluster(StartClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StartCluster', $request, $callOptions)->wait(); + } + + /** + * Stops a cluster in a project. + * + * The async variant is {@see ClusterControllerClient::stopClusterAsync()} . + * + * @param StopClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function stopCluster(StopClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StopCluster', $request, $callOptions)->wait(); + } + + /** + * Updates a cluster in a project. The returned + * [Operation.metadata][google.longrunning.Operation.metadata] will be + * [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata). + * The cluster must be in a + * [`RUNNING`][google.cloud.dataproc.v1.ClusterStatus.State] state or an error + * is returned. + * + * The async variant is {@see ClusterControllerClient::updateClusterAsync()} . + * + * @param UpdateClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCluster(UpdateClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateCluster', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see ClusterControllerClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see ClusterControllerClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see ClusterControllerClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Dataproc/src/V1/Client/JobControllerClient.php b/Dataproc/src/V1/Client/JobControllerClient.php index c33c28121f8d..26183b31aa58 100644 --- a/Dataproc/src/V1/Client/JobControllerClient.php +++ b/Dataproc/src/V1/Client/JobControllerClient.php @@ -24,17 +24,447 @@ namespace Google\Cloud\Dataproc\V1\Client; -use Google\Cloud\Dataproc\V1\Client\BaseClient\JobControllerBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dataproc\V1\CancelJobRequest; +use Google\Cloud\Dataproc\V1\DeleteJobRequest; +use Google\Cloud\Dataproc\V1\GetJobRequest; +use Google\Cloud\Dataproc\V1\Job; +use Google\Cloud\Dataproc\V1\ListJobsRequest; +use Google\Cloud\Dataproc\V1\SubmitJobRequest; +use Google\Cloud\Dataproc\V1\UpdateJobRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The JobController provides methods to manage jobs. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dataproc\V1\JobControllerClient} for the stable implementation * * @experimental + * + * @method PromiseInterface cancelJobAsync(CancelJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteJobAsync(DeleteJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getJobAsync(GetJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface listJobsAsync(ListJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface submitJobAsync(SubmitJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface submitJobAsOperationAsync(SubmitJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateJobAsync(UpdateJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class JobControllerClient extends JobControllerBaseClient +final class JobControllerClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see JobControllerBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dataproc.v1.JobController'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dataproc.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/job_controller_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/job_controller_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/job_controller_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/job_controller_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'dataproc.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Starts a job cancellation request. To access the job resource + * after cancellation, call + * [regions/{region}/jobs.list](https://cloud.google.com/dataproc/docs/reference/rest/v1/projects.regions.jobs/list) + * or + * [regions/{region}/jobs.get](https://cloud.google.com/dataproc/docs/reference/rest/v1/projects.regions.jobs/get). + * + * The async variant is {@see JobControllerClient::cancelJobAsync()} . + * + * @param CancelJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + */ + public function cancelJob(CancelJobRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('CancelJob', $request, $callOptions)->wait(); + } + + /** + * Deletes the job from the project. If the job is active, the delete fails, + * and the response returns `FAILED_PRECONDITION`. + * + * The async variant is {@see JobControllerClient::deleteJobAsync()} . + * + * @param DeleteJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteJob(DeleteJobRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteJob', $request, $callOptions)->wait(); + } + + /** + * Gets the resource representation for a job in a project. + * + * The async variant is {@see JobControllerClient::getJobAsync()} . + * + * @param GetJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + */ + public function getJob(GetJobRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('GetJob', $request, $callOptions)->wait(); + } + + /** + * Lists regions/{region}/jobs in a project. + * + * The async variant is {@see JobControllerClient::listJobsAsync()} . + * + * @param ListJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listJobs(ListJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListJobs', $request, $callOptions); + } + + /** + * Submits a job to a cluster. + * + * The async variant is {@see JobControllerClient::submitJobAsync()} . + * + * @param SubmitJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + */ + public function submitJob(SubmitJobRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('SubmitJob', $request, $callOptions)->wait(); + } + + /** + * Submits job to a cluster. + * + * The async variant is {@see JobControllerClient::submitJobAsOperationAsync()} . + * + * @param SubmitJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function submitJobAsOperation(SubmitJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SubmitJobAsOperation', $request, $callOptions)->wait(); + } + + /** + * Updates a job in a project. + * + * The async variant is {@see JobControllerClient::updateJobAsync()} . + * + * @param UpdateJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateJob(UpdateJobRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('UpdateJob', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see JobControllerClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see JobControllerClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see JobControllerClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Dataproc/src/V1/Client/NodeGroupControllerClient.php b/Dataproc/src/V1/Client/NodeGroupControllerClient.php index 6f55ad2e28ff..f38a3f0d9212 100644 --- a/Dataproc/src/V1/Client/NodeGroupControllerClient.php +++ b/Dataproc/src/V1/Client/NodeGroupControllerClient.php @@ -24,17 +24,421 @@ namespace Google\Cloud\Dataproc\V1\Client; -use Google\Cloud\Dataproc\V1\Client\BaseClient\NodeGroupControllerBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dataproc\V1\CreateNodeGroupRequest; +use Google\Cloud\Dataproc\V1\GetNodeGroupRequest; +use Google\Cloud\Dataproc\V1\NodeGroup; +use Google\Cloud\Dataproc\V1\NodeGroupOperationMetadata; +use Google\Cloud\Dataproc\V1\ResizeNodeGroupRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The `NodeGroupControllerService` provides methods to manage node groups + * of Compute Engine managed instances. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dataproc\V1\NodeGroupControllerClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createNodeGroupAsync(CreateNodeGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface getNodeGroupAsync(GetNodeGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface resizeNodeGroupAsync(ResizeNodeGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class NodeGroupControllerClient extends NodeGroupControllerBaseClient +final class NodeGroupControllerClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see NodeGroupControllerBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dataproc.v1.NodeGroupController'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dataproc.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/node_group_controller_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/node_group_controller_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/node_group_controller_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/node_group_controller_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * cluster_region resource. + * + * @param string $project + * @param string $region + * @param string $cluster + * + * @return string The formatted cluster_region resource. + */ + public static function clusterRegionName(string $project, string $region, string $cluster): string + { + return self::getPathTemplate('clusterRegion')->render([ + 'project' => $project, + 'region' => $region, + 'cluster' => $cluster, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a node_group + * resource. + * + * @param string $project + * @param string $region + * @param string $cluster + * @param string $nodeGroup + * + * @return string The formatted node_group resource. + */ + public static function nodeGroupName(string $project, string $region, string $cluster, string $nodeGroup): string + { + return self::getPathTemplate('nodeGroup')->render([ + 'project' => $project, + 'region' => $region, + 'cluster' => $cluster, + 'node_group' => $nodeGroup, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - clusterRegion: projects/{project}/regions/{region}/clusters/{cluster} + * - nodeGroup: projects/{project}/regions/{region}/clusters/{cluster}/nodeGroups/{node_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. + */ + public static function parseName(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dataproc.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a node group in a cluster. The returned + * [Operation.metadata][google.longrunning.Operation.metadata] is + * [NodeGroupOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#nodegroupoperationmetadata). + * + * The async variant is {@see NodeGroupControllerClient::createNodeGroupAsync()} . + * + * @param CreateNodeGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createNodeGroup(CreateNodeGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateNodeGroup', $request, $callOptions)->wait(); + } + + /** + * Gets the resource representation for a node group in a + * cluster. + * + * The async variant is {@see NodeGroupControllerClient::getNodeGroupAsync()} . + * + * @param GetNodeGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NodeGroup + * + * @throws ApiException Thrown if the API call fails. + */ + public function getNodeGroup(GetNodeGroupRequest $request, array $callOptions = []): NodeGroup + { + return $this->startApiCall('GetNodeGroup', $request, $callOptions)->wait(); + } + + /** + * Resizes a node group in a cluster. The returned + * [Operation.metadata][google.longrunning.Operation.metadata] is + * [NodeGroupOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#nodegroupoperationmetadata). + * + * The async variant is {@see NodeGroupControllerClient::resizeNodeGroupAsync()} . + * + * @param ResizeNodeGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function resizeNodeGroup(ResizeNodeGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ResizeNodeGroup', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see NodeGroupControllerClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see NodeGroupControllerClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see NodeGroupControllerClient::testIamPermissionsAsync()} + * . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Dataproc/src/V1/Client/WorkflowTemplateServiceClient.php b/Dataproc/src/V1/Client/WorkflowTemplateServiceClient.php index 053369b0773c..a63de5bf99cf 100644 --- a/Dataproc/src/V1/Client/WorkflowTemplateServiceClient.php +++ b/Dataproc/src/V1/Client/WorkflowTemplateServiceClient.php @@ -24,17 +24,689 @@ namespace Google\Cloud\Dataproc\V1\Client; -use Google\Cloud\Dataproc\V1\Client\BaseClient\WorkflowTemplateServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dataproc\V1\CreateWorkflowTemplateRequest; +use Google\Cloud\Dataproc\V1\DeleteWorkflowTemplateRequest; +use Google\Cloud\Dataproc\V1\GetWorkflowTemplateRequest; +use Google\Cloud\Dataproc\V1\InstantiateInlineWorkflowTemplateRequest; +use Google\Cloud\Dataproc\V1\InstantiateWorkflowTemplateRequest; +use Google\Cloud\Dataproc\V1\ListWorkflowTemplatesRequest; +use Google\Cloud\Dataproc\V1\UpdateWorkflowTemplateRequest; +use Google\Cloud\Dataproc\V1\WorkflowMetadata; +use Google\Cloud\Dataproc\V1\WorkflowTemplate; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The API interface for managing Workflow Templates in the + * Dataproc API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dataproc\V1\WorkflowTemplateServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createWorkflowTemplateAsync(CreateWorkflowTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteWorkflowTemplateAsync(DeleteWorkflowTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface getWorkflowTemplateAsync(GetWorkflowTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface instantiateInlineWorkflowTemplateAsync(InstantiateInlineWorkflowTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface instantiateWorkflowTemplateAsync(InstantiateWorkflowTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface listWorkflowTemplatesAsync(ListWorkflowTemplatesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateWorkflowTemplateAsync(UpdateWorkflowTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class WorkflowTemplateServiceClient extends WorkflowTemplateServiceBaseClient +final class WorkflowTemplateServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see WorkflowTemplateServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dataproc.v1.WorkflowTemplateService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dataproc.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/workflow_template_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/workflow_template_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/workflow_template_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/workflow_template_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * cluster_region resource. + * + * @param string $project + * @param string $region + * @param string $cluster + * + * @return string The formatted cluster_region resource. + */ + public static function clusterRegionName(string $project, string $region, string $cluster): string + { + return self::getPathTemplate('clusterRegion')->render([ + 'project' => $project, + 'region' => $region, + 'cluster' => $cluster, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a node_group + * resource. + * + * @param string $project + * @param string $region + * @param string $cluster + * @param string $nodeGroup + * + * @return string The formatted node_group resource. + */ + public static function nodeGroupName(string $project, string $region, string $cluster, string $nodeGroup): string + { + return self::getPathTemplate('nodeGroup')->render([ + 'project' => $project, + 'region' => $region, + 'cluster' => $cluster, + 'node_group' => $nodeGroup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_workflow_template resource. + * + * @param string $project + * @param string $location + * @param string $workflowTemplate + * + * @return string The formatted project_location_workflow_template resource. + */ + public static function projectLocationWorkflowTemplateName(string $project, string $location, string $workflowTemplate): string + { + return self::getPathTemplate('projectLocationWorkflowTemplate')->render([ + 'project' => $project, + 'location' => $location, + 'workflow_template' => $workflowTemplate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_region_workflow_template resource. + * + * @param string $project + * @param string $region + * @param string $workflowTemplate + * + * @return string The formatted project_region_workflow_template resource. + */ + public static function projectRegionWorkflowTemplateName(string $project, string $region, string $workflowTemplate): string + { + return self::getPathTemplate('projectRegionWorkflowTemplate')->render([ + 'project' => $project, + 'region' => $region, + 'workflow_template' => $workflowTemplate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a region + * resource. + * + * @param string $project + * @param string $region + * + * @return string The formatted region resource. + */ + public static function regionName(string $project, string $region): string + { + return self::getPathTemplate('region')->render([ + 'project' => $project, + 'region' => $region, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a service + * resource. + * + * @param string $project + * @param string $location + * @param string $service + * + * @return string The formatted service resource. + */ + public static function serviceName(string $project, string $location, string $service): string + { + return self::getPathTemplate('service')->render([ + 'project' => $project, + 'location' => $location, + 'service' => $service, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * workflow_template resource. + * + * @param string $project + * @param string $region + * @param string $workflowTemplate + * + * @return string The formatted workflow_template resource. + */ + public static function workflowTemplateName(string $project, string $region, string $workflowTemplate): string + { + return self::getPathTemplate('workflowTemplate')->render([ + 'project' => $project, + 'region' => $region, + 'workflow_template' => $workflowTemplate, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - clusterRegion: projects/{project}/regions/{region}/clusters/{cluster} + * - location: projects/{project}/locations/{location} + * - nodeGroup: projects/{project}/regions/{region}/clusters/{cluster}/nodeGroups/{node_group} + * - projectLocationWorkflowTemplate: projects/{project}/locations/{location}/workflowTemplates/{workflow_template} + * - projectRegionWorkflowTemplate: projects/{project}/regions/{region}/workflowTemplates/{workflow_template} + * - region: projects/{project}/regions/{region} + * - service: projects/{project}/locations/{location}/services/{service} + * - workflowTemplate: projects/{project}/regions/{region}/workflowTemplates/{workflow_template} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dataproc.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates new workflow template. + * + * The async variant is + * {@see WorkflowTemplateServiceClient::createWorkflowTemplateAsync()} . + * + * @param CreateWorkflowTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 WorkflowTemplate + * + * @throws ApiException Thrown if the API call fails. + */ + public function createWorkflowTemplate(CreateWorkflowTemplateRequest $request, array $callOptions = []): WorkflowTemplate + { + return $this->startApiCall('CreateWorkflowTemplate', $request, $callOptions)->wait(); + } + + /** + * Deletes a workflow template. It does not cancel in-progress workflows. + * + * The async variant is + * {@see WorkflowTemplateServiceClient::deleteWorkflowTemplateAsync()} . + * + * @param DeleteWorkflowTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteWorkflowTemplate(DeleteWorkflowTemplateRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteWorkflowTemplate', $request, $callOptions)->wait(); + } + + /** + * Retrieves the latest workflow template. + * + * Can retrieve previously instantiated template by specifying optional + * version parameter. + * + * The async variant is + * {@see WorkflowTemplateServiceClient::getWorkflowTemplateAsync()} . + * + * @param GetWorkflowTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 WorkflowTemplate + * + * @throws ApiException Thrown if the API call fails. + */ + public function getWorkflowTemplate(GetWorkflowTemplateRequest $request, array $callOptions = []): WorkflowTemplate + { + return $this->startApiCall('GetWorkflowTemplate', $request, $callOptions)->wait(); + } + + /** + * Instantiates a template and begins execution. + * + * This method is equivalent to executing the sequence + * [CreateWorkflowTemplate][google.cloud.dataproc.v1.WorkflowTemplateService.CreateWorkflowTemplate], + * [InstantiateWorkflowTemplate][google.cloud.dataproc.v1.WorkflowTemplateService.InstantiateWorkflowTemplate], + * [DeleteWorkflowTemplate][google.cloud.dataproc.v1.WorkflowTemplateService.DeleteWorkflowTemplate]. + * + * The returned Operation can be used to track execution of + * workflow by polling + * [operations.get][google.longrunning.Operations.GetOperation]. + * The Operation will complete when entire workflow is finished. + * + * The running workflow can be aborted via + * [operations.cancel][google.longrunning.Operations.CancelOperation]. + * This will cause any inflight jobs to be cancelled and workflow-owned + * clusters to be deleted. + * + * The [Operation.metadata][google.longrunning.Operation.metadata] will be + * [WorkflowMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#workflowmetadata). + * Also see [Using + * WorkflowMetadata](https://cloud.google.com/dataproc/docs/concepts/workflows/debugging#using_workflowmetadata). + * + * On successful completion, + * [Operation.response][google.longrunning.Operation.response] will be + * [Empty][google.protobuf.Empty]. + * + * The async variant is + * {@see WorkflowTemplateServiceClient::instantiateInlineWorkflowTemplateAsync()} . + * + * @param InstantiateInlineWorkflowTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function instantiateInlineWorkflowTemplate(InstantiateInlineWorkflowTemplateRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('InstantiateInlineWorkflowTemplate', $request, $callOptions)->wait(); + } + + /** + * Instantiates a template and begins execution. + * + * The returned Operation can be used to track execution of + * workflow by polling + * [operations.get][google.longrunning.Operations.GetOperation]. + * The Operation will complete when entire workflow is finished. + * + * The running workflow can be aborted via + * [operations.cancel][google.longrunning.Operations.CancelOperation]. + * This will cause any inflight jobs to be cancelled and workflow-owned + * clusters to be deleted. + * + * The [Operation.metadata][google.longrunning.Operation.metadata] will be + * [WorkflowMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#workflowmetadata). + * Also see [Using + * WorkflowMetadata](https://cloud.google.com/dataproc/docs/concepts/workflows/debugging#using_workflowmetadata). + * + * On successful completion, + * [Operation.response][google.longrunning.Operation.response] will be + * [Empty][google.protobuf.Empty]. + * + * The async variant is + * {@see WorkflowTemplateServiceClient::instantiateWorkflowTemplateAsync()} . + * + * @param InstantiateWorkflowTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function instantiateWorkflowTemplate(InstantiateWorkflowTemplateRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('InstantiateWorkflowTemplate', $request, $callOptions)->wait(); + } + + /** + * Lists workflows that match the specified filter in the request. + * + * The async variant is + * {@see WorkflowTemplateServiceClient::listWorkflowTemplatesAsync()} . + * + * @param ListWorkflowTemplatesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listWorkflowTemplates(ListWorkflowTemplatesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListWorkflowTemplates', $request, $callOptions); + } + + /** + * Updates (replaces) workflow template. The updated template + * must contain version that matches the current server version. + * + * The async variant is + * {@see WorkflowTemplateServiceClient::updateWorkflowTemplateAsync()} . + * + * @param UpdateWorkflowTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 WorkflowTemplate + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateWorkflowTemplate(UpdateWorkflowTemplateRequest $request, array $callOptions = []): WorkflowTemplate + { + return $this->startApiCall('UpdateWorkflowTemplate', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see WorkflowTemplateServiceClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see WorkflowTemplateServiceClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is + * {@see WorkflowTemplateServiceClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/DataprocMetastore/composer.json b/DataprocMetastore/composer.json index e06f7992f518..f974ef0c7cd2 100644 --- a/DataprocMetastore/composer.json +++ b/DataprocMetastore/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/DataprocMetastore/src/V1/Client/BaseClient/DataprocMetastoreBaseClient.php b/DataprocMetastore/src/V1/Client/BaseClient/DataprocMetastoreBaseClient.php deleted file mode 100644 index 33f48bb1219d..000000000000 --- a/DataprocMetastore/src/V1/Client/BaseClient/DataprocMetastoreBaseClient.php +++ /dev/null @@ -1,1029 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/dataproc_metastore_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/dataproc_metastore_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/dataproc_metastore_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/dataproc_metastore_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a backup - * resource. - * - * @param string $project - * @param string $location - * @param string $service - * @param string $backup - * - * @return string The formatted backup resource. - */ - public static function backupName(string $project, string $location, string $service, string $backup): string - { - return self::getPathTemplate('backup')->render([ - 'project' => $project, - 'location' => $location, - 'service' => $service, - 'backup' => $backup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * metadata_import resource. - * - * @param string $project - * @param string $location - * @param string $service - * @param string $metadataImport - * - * @return string The formatted metadata_import resource. - */ - public static function metadataImportName(string $project, string $location, string $service, string $metadataImport): string - { - return self::getPathTemplate('metadataImport')->render([ - 'project' => $project, - 'location' => $location, - 'service' => $service, - 'metadata_import' => $metadataImport, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a network - * resource. - * - * @param string $project - * @param string $network - * - * @return string The formatted network resource. - */ - public static function networkName(string $project, string $network): string - { - return self::getPathTemplate('network')->render([ - 'project' => $project, - 'network' => $network, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a service - * resource. - * - * @param string $project - * @param string $location - * @param string $service - * - * @return string The formatted service resource. - */ - public static function serviceName(string $project, string $location, string $service): string - { - return self::getPathTemplate('service')->render([ - 'project' => $project, - 'location' => $location, - 'service' => $service, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a subnetwork - * resource. - * - * @param string $project - * @param string $region - * @param string $subnetwork - * - * @return string The formatted subnetwork resource. - */ - public static function subnetworkName(string $project, string $region, string $subnetwork): string - { - return self::getPathTemplate('subnetwork')->render([ - 'project' => $project, - 'region' => $region, - 'subnetwork' => $subnetwork, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - backup: projects/{project}/locations/{location}/services/{service}/backups/{backup} - * - location: projects/{project}/locations/{location} - * - metadataImport: projects/{project}/locations/{location}/services/{service}/metadataImports/{metadata_import} - * - network: projects/{project}/global/networks/{network} - * - service: projects/{project}/locations/{location}/services/{service} - * - subnetwork: projects/{project}/regions/{region}/subnetworks/{subnetwork} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'metastore.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Alter metadata resource location. The metadata resource can be a database, - * table, or partition. This functionality only updates the parent directory - * for the respective metadata resource and does not transfer any existing - * data to the new location. - * - * The async variant is {@see self::alterMetadataResourceLocationAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/alter_metadata_resource_location.php - * - * @param AlterMetadataResourceLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function alterMetadataResourceLocation(AlterMetadataResourceLocationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AlterMetadataResourceLocation', $request, $callOptions)->wait(); - } - - /** - * Creates a new backup in a given project and location. - * - * The async variant is {@see self::createBackupAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/create_backup.php - * - * @param CreateBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createBackup(CreateBackupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateBackup', $request, $callOptions)->wait(); - } - - /** - * Creates a new MetadataImport in a given project and location. - * - * The async variant is {@see self::createMetadataImportAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/create_metadata_import.php - * - * @param CreateMetadataImportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createMetadataImport(CreateMetadataImportRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateMetadataImport', $request, $callOptions)->wait(); - } - - /** - * Creates a metastore service in a project and location. - * - * The async variant is {@see self::createServiceAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/create_service.php - * - * @param CreateServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createService(CreateServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateService', $request, $callOptions)->wait(); - } - - /** - * Deletes a single backup. - * - * The async variant is {@see self::deleteBackupAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/delete_backup.php - * - * @param DeleteBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteBackup(DeleteBackupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteBackup', $request, $callOptions)->wait(); - } - - /** - * Deletes a single service. - * - * The async variant is {@see self::deleteServiceAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/delete_service.php - * - * @param DeleteServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteService(DeleteServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteService', $request, $callOptions)->wait(); - } - - /** - * Exports metadata from a service. - * - * The async variant is {@see self::exportMetadataAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/export_metadata.php - * - * @param ExportMetadataRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function exportMetadata(ExportMetadataRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ExportMetadata', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single backup. - * - * The async variant is {@see self::getBackupAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/get_backup.php - * - * @param GetBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Backup - * - * @throws ApiException Thrown if the API call fails. - */ - public function getBackup(GetBackupRequest $request, array $callOptions = []): Backup - { - return $this->startApiCall('GetBackup', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single import. - * - * The async variant is {@see self::getMetadataImportAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/get_metadata_import.php - * - * @param GetMetadataImportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MetadataImport - * - * @throws ApiException Thrown if the API call fails. - */ - public function getMetadataImport(GetMetadataImportRequest $request, array $callOptions = []): MetadataImport - { - return $this->startApiCall('GetMetadataImport', $request, $callOptions)->wait(); - } - - /** - * Gets the details of a single service. - * - * The async variant is {@see self::getServiceAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/get_service.php - * - * @param GetServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Service - * - * @throws ApiException Thrown if the API call fails. - */ - public function getService(GetServiceRequest $request, array $callOptions = []): Service - { - return $this->startApiCall('GetService', $request, $callOptions)->wait(); - } - - /** - * Lists backups in a service. - * - * The async variant is {@see self::listBackupsAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/list_backups.php - * - * @param ListBackupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listBackups(ListBackupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListBackups', $request, $callOptions); - } - - /** - * Lists imports in a service. - * - * The async variant is {@see self::listMetadataImportsAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/list_metadata_imports.php - * - * @param ListMetadataImportsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listMetadataImports(ListMetadataImportsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListMetadataImports', $request, $callOptions); - } - - /** - * Lists services in a project and location. - * - * The async variant is {@see self::listServicesAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/list_services.php - * - * @param ListServicesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listServices(ListServicesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListServices', $request, $callOptions); - } - - /** - * Move a table to another database. - * - * The async variant is {@see self::moveTableToDatabaseAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/move_table_to_database.php - * - * @param MoveTableToDatabaseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function moveTableToDatabase(MoveTableToDatabaseRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('MoveTableToDatabase', $request, $callOptions)->wait(); - } - - /** - * Query DPMS metadata. - * - * The async variant is {@see self::queryMetadataAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/query_metadata.php - * - * @param QueryMetadataRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function queryMetadata(QueryMetadataRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('QueryMetadata', $request, $callOptions)->wait(); - } - - /** - * Restores a service from a backup. - * - * The async variant is {@see self::restoreServiceAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/restore_service.php - * - * @param RestoreServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function restoreService(RestoreServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RestoreService', $request, $callOptions)->wait(); - } - - /** - * Updates a single import. - * Only the description field of MetadataImport is supported to be updated. - * - * The async variant is {@see self::updateMetadataImportAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/update_metadata_import.php - * - * @param UpdateMetadataImportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateMetadataImport(UpdateMetadataImportRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateMetadataImport', $request, $callOptions)->wait(); - } - - /** - * Updates the parameters of a single service. - * - * The async variant is {@see self::updateServiceAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/update_service.php - * - * @param UpdateServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateService(UpdateServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateService', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/DataprocMetastoreClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/DataprocMetastore/src/V1/Client/BaseClient/DataprocMetastoreFederationBaseClient.php b/DataprocMetastore/src/V1/Client/BaseClient/DataprocMetastoreFederationBaseClient.php deleted file mode 100644 index 1ad077e22239..000000000000 --- a/DataprocMetastore/src/V1/Client/BaseClient/DataprocMetastoreFederationBaseClient.php +++ /dev/null @@ -1,572 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/dataproc_metastore_federation_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/dataproc_metastore_federation_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/dataproc_metastore_federation_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/dataproc_metastore_federation_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a federation - * resource. - * - * @param string $project - * @param string $location - * @param string $federation - * - * @return string The formatted federation resource. - */ - public static function federationName(string $project, string $location, string $federation): string - { - return self::getPathTemplate('federation')->render([ - 'project' => $project, - 'location' => $location, - 'federation' => $federation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - federation: projects/{project}/locations/{location}/federations/{federation} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'metastore.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a metastore federation in a project and location. - * - * The async variant is {@see self::createFederationAsync()} . - * - * @example samples/V1/DataprocMetastoreFederationClient/create_federation.php - * - * @param CreateFederationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createFederation(CreateFederationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateFederation', $request, $callOptions)->wait(); - } - - /** - * Deletes a single federation. - * - * The async variant is {@see self::deleteFederationAsync()} . - * - * @example samples/V1/DataprocMetastoreFederationClient/delete_federation.php - * - * @param DeleteFederationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteFederation(DeleteFederationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteFederation', $request, $callOptions)->wait(); - } - - /** - * Gets the details of a single federation. - * - * The async variant is {@see self::getFederationAsync()} . - * - * @example samples/V1/DataprocMetastoreFederationClient/get_federation.php - * - * @param GetFederationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Federation - * - * @throws ApiException Thrown if the API call fails. - */ - public function getFederation(GetFederationRequest $request, array $callOptions = []): Federation - { - return $this->startApiCall('GetFederation', $request, $callOptions)->wait(); - } - - /** - * Lists federations in a project and location. - * - * The async variant is {@see self::listFederationsAsync()} . - * - * @example samples/V1/DataprocMetastoreFederationClient/list_federations.php - * - * @param ListFederationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listFederations(ListFederationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListFederations', $request, $callOptions); - } - - /** - * Updates the fields of a federation. - * - * The async variant is {@see self::updateFederationAsync()} . - * - * @example samples/V1/DataprocMetastoreFederationClient/update_federation.php - * - * @param UpdateFederationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateFederation(UpdateFederationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateFederation', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/DataprocMetastoreFederationClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/DataprocMetastoreFederationClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/DataprocMetastoreFederationClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/DataprocMetastoreFederationClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/DataprocMetastoreFederationClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/DataprocMetastore/src/V1/Client/DataprocMetastoreClient.php b/DataprocMetastore/src/V1/Client/DataprocMetastoreClient.php index 6b5a5912c86c..f72f8f2ad14a 100644 --- a/DataprocMetastore/src/V1/Client/DataprocMetastoreClient.php +++ b/DataprocMetastore/src/V1/Client/DataprocMetastoreClient.php @@ -24,17 +24,1009 @@ namespace Google\Cloud\Metastore\V1\Client; -use Google\Cloud\Metastore\V1\Client\BaseClient\DataprocMetastoreBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\Metastore\V1\AlterMetadataResourceLocationRequest; +use Google\Cloud\Metastore\V1\Backup; +use Google\Cloud\Metastore\V1\CreateBackupRequest; +use Google\Cloud\Metastore\V1\CreateMetadataImportRequest; +use Google\Cloud\Metastore\V1\CreateServiceRequest; +use Google\Cloud\Metastore\V1\DeleteBackupRequest; +use Google\Cloud\Metastore\V1\DeleteServiceRequest; +use Google\Cloud\Metastore\V1\ExportMetadataRequest; +use Google\Cloud\Metastore\V1\GetBackupRequest; +use Google\Cloud\Metastore\V1\GetMetadataImportRequest; +use Google\Cloud\Metastore\V1\GetServiceRequest; +use Google\Cloud\Metastore\V1\ListBackupsRequest; +use Google\Cloud\Metastore\V1\ListMetadataImportsRequest; +use Google\Cloud\Metastore\V1\ListServicesRequest; +use Google\Cloud\Metastore\V1\MetadataImport; +use Google\Cloud\Metastore\V1\MoveTableToDatabaseRequest; +use Google\Cloud\Metastore\V1\QueryMetadataRequest; +use Google\Cloud\Metastore\V1\Restore; +use Google\Cloud\Metastore\V1\RestoreServiceRequest; +use Google\Cloud\Metastore\V1\Service; +use Google\Cloud\Metastore\V1\UpdateMetadataImportRequest; +use Google\Cloud\Metastore\V1\UpdateServiceRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Configures and manages metastore services. + * Metastore services are fully managed, highly available, autoscaled, + * autohealing, OSS-native deployments of technical metadata management + * software. Each metastore service exposes a network endpoint through which + * metadata queries are served. Metadata queries can originate from a variety + * of sources, including Apache Hive, Apache Presto, and Apache Spark. * - * This class is currently experimental and may be subject to changes. + * The Dataproc Metastore API defines the following resource model: + * + * * The service works with a collection of Google Cloud projects, named: + * `/projects/*` + * * Each project has a collection of available locations, named: `/locations/*` + * (a location must refer to a Google Cloud `region`) + * * Each location has a collection of services, named: `/services/*` + * * Dataproc Metastore services are resources with names of the form: + * + * `/projects/{project_number}/locations/{location_id}/services/{service_id}`. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Metastore\V1\DataprocMetastoreClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface alterMetadataResourceLocationAsync(AlterMetadataResourceLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface createBackupAsync(CreateBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface createMetadataImportAsync(CreateMetadataImportRequest $request, array $optionalArgs = []) + * @method PromiseInterface createServiceAsync(CreateServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteBackupAsync(DeleteBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteServiceAsync(DeleteServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface exportMetadataAsync(ExportMetadataRequest $request, array $optionalArgs = []) + * @method PromiseInterface getBackupAsync(GetBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface getMetadataImportAsync(GetMetadataImportRequest $request, array $optionalArgs = []) + * @method PromiseInterface getServiceAsync(GetServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface listBackupsAsync(ListBackupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listMetadataImportsAsync(ListMetadataImportsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listServicesAsync(ListServicesRequest $request, array $optionalArgs = []) + * @method PromiseInterface moveTableToDatabaseAsync(MoveTableToDatabaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface queryMetadataAsync(QueryMetadataRequest $request, array $optionalArgs = []) + * @method PromiseInterface restoreServiceAsync(RestoreServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateMetadataImportAsync(UpdateMetadataImportRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateServiceAsync(UpdateServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class DataprocMetastoreClient extends DataprocMetastoreBaseClient +final class DataprocMetastoreClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DataprocMetastoreBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.metastore.v1.DataprocMetastore'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'metastore.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/dataproc_metastore_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/dataproc_metastore_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/dataproc_metastore_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/dataproc_metastore_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a backup + * resource. + * + * @param string $project + * @param string $location + * @param string $service + * @param string $backup + * + * @return string The formatted backup resource. + */ + public static function backupName(string $project, string $location, string $service, string $backup): string + { + return self::getPathTemplate('backup')->render([ + 'project' => $project, + 'location' => $location, + 'service' => $service, + 'backup' => $backup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * metadata_import resource. + * + * @param string $project + * @param string $location + * @param string $service + * @param string $metadataImport + * + * @return string The formatted metadata_import resource. + */ + public static function metadataImportName(string $project, string $location, string $service, string $metadataImport): string + { + return self::getPathTemplate('metadataImport')->render([ + 'project' => $project, + 'location' => $location, + 'service' => $service, + 'metadata_import' => $metadataImport, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a network + * resource. + * + * @param string $project + * @param string $network + * + * @return string The formatted network resource. + */ + public static function networkName(string $project, string $network): string + { + return self::getPathTemplate('network')->render([ + 'project' => $project, + 'network' => $network, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a service + * resource. + * + * @param string $project + * @param string $location + * @param string $service + * + * @return string The formatted service resource. + */ + public static function serviceName(string $project, string $location, string $service): string + { + return self::getPathTemplate('service')->render([ + 'project' => $project, + 'location' => $location, + 'service' => $service, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a subnetwork + * resource. + * + * @param string $project + * @param string $region + * @param string $subnetwork + * + * @return string The formatted subnetwork resource. + */ + public static function subnetworkName(string $project, string $region, string $subnetwork): string + { + return self::getPathTemplate('subnetwork')->render([ + 'project' => $project, + 'region' => $region, + 'subnetwork' => $subnetwork, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - backup: projects/{project}/locations/{location}/services/{service}/backups/{backup} + * - location: projects/{project}/locations/{location} + * - metadataImport: projects/{project}/locations/{location}/services/{service}/metadataImports/{metadata_import} + * - network: projects/{project}/global/networks/{network} + * - service: projects/{project}/locations/{location}/services/{service} + * - subnetwork: projects/{project}/regions/{region}/subnetworks/{subnetwork} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'metastore.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Alter metadata resource location. The metadata resource can be a database, + * table, or partition. This functionality only updates the parent directory + * for the respective metadata resource and does not transfer any existing + * data to the new location. + * + * The async variant is + * {@see DataprocMetastoreClient::alterMetadataResourceLocationAsync()} . + * + * @example samples/V1/DataprocMetastoreClient/alter_metadata_resource_location.php + * + * @param AlterMetadataResourceLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function alterMetadataResourceLocation(AlterMetadataResourceLocationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AlterMetadataResourceLocation', $request, $callOptions)->wait(); + } + + /** + * Creates a new backup in a given project and location. + * + * The async variant is {@see DataprocMetastoreClient::createBackupAsync()} . + * + * @example samples/V1/DataprocMetastoreClient/create_backup.php + * + * @param CreateBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createBackup(CreateBackupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateBackup', $request, $callOptions)->wait(); + } + + /** + * Creates a new MetadataImport in a given project and location. + * + * The async variant is {@see DataprocMetastoreClient::createMetadataImportAsync()} + * . + * + * @example samples/V1/DataprocMetastoreClient/create_metadata_import.php + * + * @param CreateMetadataImportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createMetadataImport(CreateMetadataImportRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateMetadataImport', $request, $callOptions)->wait(); + } + + /** + * Creates a metastore service in a project and location. + * + * The async variant is {@see DataprocMetastoreClient::createServiceAsync()} . + * + * @example samples/V1/DataprocMetastoreClient/create_service.php + * + * @param CreateServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createService(CreateServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateService', $request, $callOptions)->wait(); + } + + /** + * Deletes a single backup. + * + * The async variant is {@see DataprocMetastoreClient::deleteBackupAsync()} . + * + * @example samples/V1/DataprocMetastoreClient/delete_backup.php + * + * @param DeleteBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteBackup(DeleteBackupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteBackup', $request, $callOptions)->wait(); + } + + /** + * Deletes a single service. + * + * The async variant is {@see DataprocMetastoreClient::deleteServiceAsync()} . + * + * @example samples/V1/DataprocMetastoreClient/delete_service.php + * + * @param DeleteServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteService(DeleteServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteService', $request, $callOptions)->wait(); + } + + /** + * Exports metadata from a service. + * + * The async variant is {@see DataprocMetastoreClient::exportMetadataAsync()} . + * + * @example samples/V1/DataprocMetastoreClient/export_metadata.php + * + * @param ExportMetadataRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportMetadata(ExportMetadataRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ExportMetadata', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single backup. + * + * The async variant is {@see DataprocMetastoreClient::getBackupAsync()} . + * + * @example samples/V1/DataprocMetastoreClient/get_backup.php + * + * @param GetBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Backup + * + * @throws ApiException Thrown if the API call fails. + */ + public function getBackup(GetBackupRequest $request, array $callOptions = []): Backup + { + return $this->startApiCall('GetBackup', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single import. + * + * The async variant is {@see DataprocMetastoreClient::getMetadataImportAsync()} . + * + * @example samples/V1/DataprocMetastoreClient/get_metadata_import.php + * + * @param GetMetadataImportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MetadataImport + * + * @throws ApiException Thrown if the API call fails. + */ + public function getMetadataImport(GetMetadataImportRequest $request, array $callOptions = []): MetadataImport + { + return $this->startApiCall('GetMetadataImport', $request, $callOptions)->wait(); + } + + /** + * Gets the details of a single service. + * + * The async variant is {@see DataprocMetastoreClient::getServiceAsync()} . + * + * @example samples/V1/DataprocMetastoreClient/get_service.php + * + * @param GetServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Service + * + * @throws ApiException Thrown if the API call fails. + */ + public function getService(GetServiceRequest $request, array $callOptions = []): Service + { + return $this->startApiCall('GetService', $request, $callOptions)->wait(); + } + + /** + * Lists backups in a service. + * + * The async variant is {@see DataprocMetastoreClient::listBackupsAsync()} . + * + * @example samples/V1/DataprocMetastoreClient/list_backups.php + * + * @param ListBackupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listBackups(ListBackupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListBackups', $request, $callOptions); + } + + /** + * Lists imports in a service. + * + * The async variant is {@see DataprocMetastoreClient::listMetadataImportsAsync()} + * . + * + * @example samples/V1/DataprocMetastoreClient/list_metadata_imports.php + * + * @param ListMetadataImportsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listMetadataImports(ListMetadataImportsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListMetadataImports', $request, $callOptions); + } + + /** + * Lists services in a project and location. + * + * The async variant is {@see DataprocMetastoreClient::listServicesAsync()} . + * + * @example samples/V1/DataprocMetastoreClient/list_services.php + * + * @param ListServicesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listServices(ListServicesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListServices', $request, $callOptions); + } + + /** + * Move a table to another database. + * + * The async variant is {@see DataprocMetastoreClient::moveTableToDatabaseAsync()} + * . + * + * @example samples/V1/DataprocMetastoreClient/move_table_to_database.php + * + * @param MoveTableToDatabaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function moveTableToDatabase(MoveTableToDatabaseRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('MoveTableToDatabase', $request, $callOptions)->wait(); + } + + /** + * Query DPMS metadata. + * + * The async variant is {@see DataprocMetastoreClient::queryMetadataAsync()} . + * + * @example samples/V1/DataprocMetastoreClient/query_metadata.php + * + * @param QueryMetadataRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function queryMetadata(QueryMetadataRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('QueryMetadata', $request, $callOptions)->wait(); + } + + /** + * Restores a service from a backup. + * + * The async variant is {@see DataprocMetastoreClient::restoreServiceAsync()} . + * + * @example samples/V1/DataprocMetastoreClient/restore_service.php + * + * @param RestoreServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function restoreService(RestoreServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RestoreService', $request, $callOptions)->wait(); + } + + /** + * Updates a single import. + * Only the description field of MetadataImport is supported to be updated. + * + * The async variant is {@see DataprocMetastoreClient::updateMetadataImportAsync()} + * . + * + * @example samples/V1/DataprocMetastoreClient/update_metadata_import.php + * + * @param UpdateMetadataImportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateMetadataImport(UpdateMetadataImportRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateMetadataImport', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single service. + * + * The async variant is {@see DataprocMetastoreClient::updateServiceAsync()} . + * + * @example samples/V1/DataprocMetastoreClient/update_service.php + * + * @param UpdateServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateService(UpdateServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateService', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see DataprocMetastoreClient::getLocationAsync()} . + * + * @example samples/V1/DataprocMetastoreClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see DataprocMetastoreClient::listLocationsAsync()} . + * + * @example samples/V1/DataprocMetastoreClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see DataprocMetastoreClient::getIamPolicyAsync()} . + * + * @example samples/V1/DataprocMetastoreClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see DataprocMetastoreClient::setIamPolicyAsync()} . + * + * @example samples/V1/DataprocMetastoreClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see DataprocMetastoreClient::testIamPermissionsAsync()} . + * + * @example samples/V1/DataprocMetastoreClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/DataprocMetastore/src/V1/Client/DataprocMetastoreFederationClient.php b/DataprocMetastore/src/V1/Client/DataprocMetastoreFederationClient.php index 590bc879880f..6f2cd1727216 100644 --- a/DataprocMetastore/src/V1/Client/DataprocMetastoreFederationClient.php +++ b/DataprocMetastore/src/V1/Client/DataprocMetastoreFederationClient.php @@ -24,17 +24,557 @@ namespace Google\Cloud\Metastore\V1\Client; -use Google\Cloud\Metastore\V1\Client\BaseClient\DataprocMetastoreFederationBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\Metastore\V1\CreateFederationRequest; +use Google\Cloud\Metastore\V1\DeleteFederationRequest; +use Google\Cloud\Metastore\V1\Federation; +use Google\Cloud\Metastore\V1\GetFederationRequest; +use Google\Cloud\Metastore\V1\ListFederationsRequest; +use Google\Cloud\Metastore\V1\UpdateFederationRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Configures and manages metastore federation services. + * Dataproc Metastore Federation Service allows federating a collection of + * backend metastores like BigQuery, Dataplex Lakes, and other Dataproc + * Metastores. The Federation Service exposes a gRPC URL through which metadata + * from the backend metastores are served at query time. * - * This class is currently experimental and may be subject to changes. + * The Dataproc Metastore Federation API defines the following resource model: + * * The service works with a collection of Google Cloud projects. + * * Each project has a collection of available locations. + * * Each location has a collection of federations. + * * Dataproc Metastore Federations are resources with names of the + * form: + * `projects/{project_number}/locations/{location_id}/federations/{federation_id}`. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Metastore\V1\DataprocMetastoreFederationClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createFederationAsync(CreateFederationRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteFederationAsync(DeleteFederationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getFederationAsync(GetFederationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listFederationsAsync(ListFederationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateFederationAsync(UpdateFederationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class DataprocMetastoreFederationClient extends DataprocMetastoreFederationBaseClient +final class DataprocMetastoreFederationClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DataprocMetastoreFederationBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.metastore.v1.DataprocMetastoreFederation'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'metastore.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/dataproc_metastore_federation_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/dataproc_metastore_federation_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/dataproc_metastore_federation_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/dataproc_metastore_federation_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a federation + * resource. + * + * @param string $project + * @param string $location + * @param string $federation + * + * @return string The formatted federation resource. + */ + public static function federationName(string $project, string $location, string $federation): string + { + return self::getPathTemplate('federation')->render([ + 'project' => $project, + 'location' => $location, + 'federation' => $federation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - federation: projects/{project}/locations/{location}/federations/{federation} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'metastore.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a metastore federation in a project and location. + * + * The async variant is + * {@see DataprocMetastoreFederationClient::createFederationAsync()} . + * + * @example samples/V1/DataprocMetastoreFederationClient/create_federation.php + * + * @param CreateFederationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createFederation(CreateFederationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateFederation', $request, $callOptions)->wait(); + } + + /** + * Deletes a single federation. + * + * The async variant is + * {@see DataprocMetastoreFederationClient::deleteFederationAsync()} . + * + * @example samples/V1/DataprocMetastoreFederationClient/delete_federation.php + * + * @param DeleteFederationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteFederation(DeleteFederationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteFederation', $request, $callOptions)->wait(); + } + + /** + * Gets the details of a single federation. + * + * The async variant is + * {@see DataprocMetastoreFederationClient::getFederationAsync()} . + * + * @example samples/V1/DataprocMetastoreFederationClient/get_federation.php + * + * @param GetFederationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Federation + * + * @throws ApiException Thrown if the API call fails. + */ + public function getFederation(GetFederationRequest $request, array $callOptions = []): Federation + { + return $this->startApiCall('GetFederation', $request, $callOptions)->wait(); + } + + /** + * Lists federations in a project and location. + * + * The async variant is + * {@see DataprocMetastoreFederationClient::listFederationsAsync()} . + * + * @example samples/V1/DataprocMetastoreFederationClient/list_federations.php + * + * @param ListFederationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listFederations(ListFederationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListFederations', $request, $callOptions); + } + + /** + * Updates the fields of a federation. + * + * The async variant is + * {@see DataprocMetastoreFederationClient::updateFederationAsync()} . + * + * @example samples/V1/DataprocMetastoreFederationClient/update_federation.php + * + * @param UpdateFederationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateFederation(UpdateFederationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateFederation', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is + * {@see DataprocMetastoreFederationClient::getLocationAsync()} . + * + * @example samples/V1/DataprocMetastoreFederationClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is + * {@see DataprocMetastoreFederationClient::listLocationsAsync()} . + * + * @example samples/V1/DataprocMetastoreFederationClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is + * {@see DataprocMetastoreFederationClient::getIamPolicyAsync()} . + * + * @example samples/V1/DataprocMetastoreFederationClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is + * {@see DataprocMetastoreFederationClient::setIamPolicyAsync()} . + * + * @example samples/V1/DataprocMetastoreFederationClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is + * {@see DataprocMetastoreFederationClient::testIamPermissionsAsync()} . + * + * @example samples/V1/DataprocMetastoreFederationClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Datastore/composer.json b/Datastore/composer.json index 39f97f4ed0f8..73fab4abd097 100644 --- a/Datastore/composer.json +++ b/Datastore/composer.json @@ -5,8 +5,8 @@ "minimum-stability": "stable", "require": { "php": ">=7.4", - "google/cloud-core": "^1.49.4", - "google/gax": "^1.19.1" + "google/cloud-core": "^1.52.7", + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", diff --git a/Datastore/src/V1/Client/BaseClient/DatastoreBaseClient.php b/Datastore/src/V1/Client/BaseClient/DatastoreBaseClient.php deleted file mode 100644 index d22a41fbefdc..000000000000 --- a/Datastore/src/V1/Client/BaseClient/DatastoreBaseClient.php +++ /dev/null @@ -1,387 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/datastore_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/datastore_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/datastore_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/datastore_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'datastore.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Allocates IDs for the given keys, which is useful for referencing an entity - * before it is inserted. - * - * The async variant is {@see self::allocateIdsAsync()} . - * - * @param AllocateIdsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AllocateIdsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function allocateIds(AllocateIdsRequest $request, array $callOptions = []): AllocateIdsResponse - { - return $this->startApiCall('AllocateIds', $request, $callOptions)->wait(); - } - - /** - * Begins a new transaction. - * - * The async variant is {@see self::beginTransactionAsync()} . - * - * @param BeginTransactionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BeginTransactionResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function beginTransaction(BeginTransactionRequest $request, array $callOptions = []): BeginTransactionResponse - { - return $this->startApiCall('BeginTransaction', $request, $callOptions)->wait(); - } - - /** - * Commits a transaction, optionally creating, deleting or modifying some - * entities. - * - * The async variant is {@see self::commitAsync()} . - * - * @param CommitRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CommitResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function commit(CommitRequest $request, array $callOptions = []): CommitResponse - { - return $this->startApiCall('Commit', $request, $callOptions)->wait(); - } - - /** - * Looks up entities by key. - * - * The async variant is {@see self::lookupAsync()} . - * - * @param LookupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LookupResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function lookup(LookupRequest $request, array $callOptions = []): LookupResponse - { - return $this->startApiCall('Lookup', $request, $callOptions)->wait(); - } - - /** - * Prevents the supplied keys' IDs from being auto-allocated by Cloud - * Datastore. - * - * The async variant is {@see self::reserveIdsAsync()} . - * - * @param ReserveIdsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ReserveIdsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function reserveIds(ReserveIdsRequest $request, array $callOptions = []): ReserveIdsResponse - { - return $this->startApiCall('ReserveIds', $request, $callOptions)->wait(); - } - - /** - * Rolls back a transaction. - * - * The async variant is {@see self::rollbackAsync()} . - * - * @param RollbackRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RollbackResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function rollback(RollbackRequest $request, array $callOptions = []): RollbackResponse - { - return $this->startApiCall('Rollback', $request, $callOptions)->wait(); - } - - /** - * Runs an aggregation query. - * - * The async variant is {@see self::runAggregationQueryAsync()} . - * - * @param RunAggregationQueryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RunAggregationQueryResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function runAggregationQuery(RunAggregationQueryRequest $request, array $callOptions = []): RunAggregationQueryResponse - { - return $this->startApiCall('RunAggregationQuery', $request, $callOptions)->wait(); - } - - /** - * Queries for entities. - * - * The async variant is {@see self::runQueryAsync()} . - * - * @param RunQueryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RunQueryResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function runQuery(RunQueryRequest $request, array $callOptions = []): RunQueryResponse - { - return $this->startApiCall('RunQuery', $request, $callOptions)->wait(); - } -} diff --git a/Datastore/src/V1/Client/DatastoreClient.php b/Datastore/src/V1/Client/DatastoreClient.php index 0203b89ff235..75e999aa5eb6 100644 --- a/Datastore/src/V1/Client/DatastoreClient.php +++ b/Datastore/src/V1/Client/DatastoreClient.php @@ -24,17 +24,362 @@ namespace Google\Cloud\Datastore\V1\Client; -use Google\Cloud\Datastore\V1\Client\BaseClient\DatastoreBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Datastore\V1\AllocateIdsRequest; +use Google\Cloud\Datastore\V1\AllocateIdsResponse; +use Google\Cloud\Datastore\V1\BeginTransactionRequest; +use Google\Cloud\Datastore\V1\BeginTransactionResponse; +use Google\Cloud\Datastore\V1\CommitRequest; +use Google\Cloud\Datastore\V1\CommitResponse; +use Google\Cloud\Datastore\V1\Key; +use Google\Cloud\Datastore\V1\LookupRequest; +use Google\Cloud\Datastore\V1\LookupResponse; +use Google\Cloud\Datastore\V1\ReserveIdsRequest; +use Google\Cloud\Datastore\V1\ReserveIdsResponse; +use Google\Cloud\Datastore\V1\RollbackRequest; +use Google\Cloud\Datastore\V1\RollbackResponse; +use Google\Cloud\Datastore\V1\RunAggregationQueryRequest; +use Google\Cloud\Datastore\V1\RunAggregationQueryResponse; +use Google\Cloud\Datastore\V1\RunQueryRequest; +use Google\Cloud\Datastore\V1\RunQueryResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Each RPC normalizes the partition IDs of the keys in its input entities, + * and always returns entities with keys with normalized partition IDs. + * This applies to all keys and entities, including those in values, except keys + * with both an empty path and an empty or unset partition ID. Normalization of + * input keys sets the project ID (if not already set) to the project ID from + * the request. * - * This class is currently experimental and may be subject to changes. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Datastore\V1\DatastoreClient} for the stable implementation * * @experimental + * + * @method PromiseInterface allocateIdsAsync(AllocateIdsRequest $request, array $optionalArgs = []) + * @method PromiseInterface beginTransactionAsync(BeginTransactionRequest $request, array $optionalArgs = []) + * @method PromiseInterface commitAsync(CommitRequest $request, array $optionalArgs = []) + * @method PromiseInterface lookupAsync(LookupRequest $request, array $optionalArgs = []) + * @method PromiseInterface reserveIdsAsync(ReserveIdsRequest $request, array $optionalArgs = []) + * @method PromiseInterface rollbackAsync(RollbackRequest $request, array $optionalArgs = []) + * @method PromiseInterface runAggregationQueryAsync(RunAggregationQueryRequest $request, array $optionalArgs = []) + * @method PromiseInterface runQueryAsync(RunQueryRequest $request, array $optionalArgs = []) */ -final class DatastoreClient extends DatastoreBaseClient +final class DatastoreClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DatastoreBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.datastore.v1.Datastore'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'datastore.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/datastore', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/datastore_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/datastore_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/datastore_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/datastore_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'datastore.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Allocates IDs for the given keys, which is useful for referencing an entity + * before it is inserted. + * + * The async variant is {@see DatastoreClient::allocateIdsAsync()} . + * + * @param AllocateIdsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AllocateIdsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function allocateIds(AllocateIdsRequest $request, array $callOptions = []): AllocateIdsResponse + { + return $this->startApiCall('AllocateIds', $request, $callOptions)->wait(); + } + + /** + * Begins a new transaction. + * + * The async variant is {@see DatastoreClient::beginTransactionAsync()} . + * + * @param BeginTransactionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BeginTransactionResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function beginTransaction(BeginTransactionRequest $request, array $callOptions = []): BeginTransactionResponse + { + return $this->startApiCall('BeginTransaction', $request, $callOptions)->wait(); + } + + /** + * Commits a transaction, optionally creating, deleting or modifying some + * entities. + * + * The async variant is {@see DatastoreClient::commitAsync()} . + * + * @param CommitRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CommitResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function commit(CommitRequest $request, array $callOptions = []): CommitResponse + { + return $this->startApiCall('Commit', $request, $callOptions)->wait(); + } + + /** + * Looks up entities by key. + * + * The async variant is {@see DatastoreClient::lookupAsync()} . + * + * @param LookupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LookupResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function lookup(LookupRequest $request, array $callOptions = []): LookupResponse + { + return $this->startApiCall('Lookup', $request, $callOptions)->wait(); + } + + /** + * Prevents the supplied keys' IDs from being auto-allocated by Cloud + * Datastore. + * + * The async variant is {@see DatastoreClient::reserveIdsAsync()} . + * + * @param ReserveIdsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ReserveIdsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function reserveIds(ReserveIdsRequest $request, array $callOptions = []): ReserveIdsResponse + { + return $this->startApiCall('ReserveIds', $request, $callOptions)->wait(); + } + + /** + * Rolls back a transaction. + * + * The async variant is {@see DatastoreClient::rollbackAsync()} . + * + * @param RollbackRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RollbackResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function rollback(RollbackRequest $request, array $callOptions = []): RollbackResponse + { + return $this->startApiCall('Rollback', $request, $callOptions)->wait(); + } + + /** + * Runs an aggregation query. + * + * The async variant is {@see DatastoreClient::runAggregationQueryAsync()} . + * + * @param RunAggregationQueryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RunAggregationQueryResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function runAggregationQuery(RunAggregationQueryRequest $request, array $callOptions = []): RunAggregationQueryResponse + { + return $this->startApiCall('RunAggregationQuery', $request, $callOptions)->wait(); + } + + /** + * Queries for entities. + * + * The async variant is {@see DatastoreClient::runQueryAsync()} . + * + * @param RunQueryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RunQueryResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function runQuery(RunQueryRequest $request, array $callOptions = []): RunQueryResponse + { + return $this->startApiCall('RunQuery', $request, $callOptions)->wait(); + } } diff --git a/DatastoreAdmin/composer.json b/DatastoreAdmin/composer.json index a33164fc0faa..f590d76bf590 100644 --- a/DatastoreAdmin/composer.json +++ b/DatastoreAdmin/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/DatastoreAdmin/src/V1/Client/BaseClient/DatastoreAdminBaseClient.php b/DatastoreAdmin/src/V1/Client/BaseClient/DatastoreAdminBaseClient.php deleted file mode 100644 index 7a3be504fdcf..000000000000 --- a/DatastoreAdmin/src/V1/Client/BaseClient/DatastoreAdminBaseClient.php +++ /dev/null @@ -1,449 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/datastore_admin_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/datastore_admin_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/datastore_admin_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/datastore_admin_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'datastore.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates the specified index. - * A newly created index's initial state is `CREATING`. On completion of the - * returned [google.longrunning.Operation][google.longrunning.Operation], the - * state will be `READY`. If the index already exists, the call will return an - * `ALREADY_EXISTS` status. - * - * During index creation, the process could result in an error, in which - * case the index will move to the `ERROR` state. The process can be recovered - * by fixing the data that caused the error, removing the index with - * [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], then - * re-creating the index with [create] - * [google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. - * - * Indexes with a single property cannot be created. - * - * The async variant is {@see self::createIndexAsync()} . - * - * @example samples/V1/DatastoreAdminClient/create_index.php - * - * @param CreateIndexRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createIndex(CreateIndexRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateIndex', $request, $callOptions)->wait(); - } - - /** - * Deletes an existing index. - * An index can only be deleted if it is in a `READY` or `ERROR` state. On - * successful execution of the request, the index will be in a `DELETING` - * [state][google.datastore.admin.v1.Index.State]. And on completion of the - * returned [google.longrunning.Operation][google.longrunning.Operation], the - * index will be removed. - * - * During index deletion, the process could result in an error, in which - * case the index will move to the `ERROR` state. The process can be recovered - * by fixing the data that caused the error, followed by calling - * [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] again. - * - * The async variant is {@see self::deleteIndexAsync()} . - * - * @example samples/V1/DatastoreAdminClient/delete_index.php - * - * @param DeleteIndexRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteIndex(DeleteIndexRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteIndex', $request, $callOptions)->wait(); - } - - /** - * Exports a copy of all or a subset of entities from Google Cloud Datastore - * to another storage system, such as Google Cloud Storage. Recent updates to - * entities may not be reflected in the export. The export occurs in the - * background and its progress can be monitored and managed via the - * Operation resource that is created. The output of an export may only be - * used once the associated operation is done. If an export operation is - * cancelled before completion it may leave partial data behind in Google - * Cloud Storage. - * - * The async variant is {@see self::exportEntitiesAsync()} . - * - * @example samples/V1/DatastoreAdminClient/export_entities.php - * - * @param ExportEntitiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function exportEntities(ExportEntitiesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ExportEntities', $request, $callOptions)->wait(); - } - - /** - * Gets an index. - * - * The async variant is {@see self::getIndexAsync()} . - * - * @example samples/V1/DatastoreAdminClient/get_index.php - * - * @param GetIndexRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Index - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIndex(GetIndexRequest $request, array $callOptions = []): Index - { - return $this->startApiCall('GetIndex', $request, $callOptions)->wait(); - } - - /** - * Imports entities into Google Cloud Datastore. Existing entities with the - * same key are overwritten. The import occurs in the background and its - * progress can be monitored and managed via the Operation resource that is - * created. If an ImportEntities operation is cancelled, it is possible - * that a subset of the data has already been imported to Cloud Datastore. - * - * The async variant is {@see self::importEntitiesAsync()} . - * - * @example samples/V1/DatastoreAdminClient/import_entities.php - * - * @param ImportEntitiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function importEntities(ImportEntitiesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ImportEntities', $request, $callOptions)->wait(); - } - - /** - * Lists the indexes that match the specified filters. Datastore uses an - * eventually consistent query to fetch the list of indexes and may - * occasionally return stale results. - * - * The async variant is {@see self::listIndexesAsync()} . - * - * @example samples/V1/DatastoreAdminClient/list_indexes.php - * - * @param ListIndexesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listIndexes(ListIndexesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListIndexes', $request, $callOptions); - } -} diff --git a/DatastoreAdmin/src/V1/Client/DatastoreAdminClient.php b/DatastoreAdmin/src/V1/Client/DatastoreAdminClient.php index 7b6254c8a128..ef162970c3a0 100644 --- a/DatastoreAdmin/src/V1/Client/DatastoreAdminClient.php +++ b/DatastoreAdmin/src/V1/Client/DatastoreAdminClient.php @@ -24,17 +24,424 @@ namespace Google\Cloud\Datastore\Admin\V1\Client; -use Google\Cloud\Datastore\Admin\V1\Client\BaseClient\DatastoreAdminBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Datastore\Admin\V1\CreateIndexRequest; +use Google\Cloud\Datastore\Admin\V1\DeleteIndexRequest; +use Google\Cloud\Datastore\Admin\V1\ExportEntitiesRequest; +use Google\Cloud\Datastore\Admin\V1\GetIndexRequest; +use Google\Cloud\Datastore\Admin\V1\ImportEntitiesRequest; +use Google\Cloud\Datastore\Admin\V1\Index; +use Google\Cloud\Datastore\Admin\V1\ListIndexesRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Google Cloud Datastore Admin API * - * This class is currently experimental and may be subject to changes. + * The Datastore Admin API provides several admin services for Cloud Datastore. + * + * Concepts: Project, namespace, kind, and entity as defined in the Google Cloud + * Datastore API. + * + * Operation: An Operation represents work being performed in the background. + * + * EntityFilter: Allows specifying a subset of entities in a project. This is + * specified as a combination of kinds and namespaces (either or both of which + * may be all). + * + * Export/Import Service: + * + * - The Export/Import service provides the ability to copy all or a subset of + * entities to/from Google Cloud Storage. + * - Exported data may be imported into Cloud Datastore for any Google Cloud + * Platform project. It is not restricted to the export source project. It is + * possible to export from one project and then import into another. + * - Exported data can also be loaded into Google BigQuery for analysis. + * - Exports and imports are performed asynchronously. An Operation resource is + * created for each export/import. The state (including any errors encountered) + * of the export/import may be queried via the Operation resource. + * + * Index Service: + * + * - The index service manages Cloud Datastore composite indexes. + * - Index creation and deletion are performed asynchronously. + * An Operation resource is created for each such asynchronous operation. + * The state of the operation (including any errors encountered) + * may be queried via the Operation resource. + * + * Operation Service: + * + * - The Operations collection provides a record of actions performed for the + * specified project (including any operations in progress). Operations are not + * created directly but through calls on other collections or resources. + * - An operation that is not yet done may be cancelled. The request to cancel + * is asynchronous and the operation may continue to run for some time after the + * request to cancel is made. + * - An operation that is done may be deleted so that it is no longer listed as + * part of the Operation collection. + * - ListOperations returns all pending operations, but not completed + * operations. + * - Operations are created by service DatastoreAdmin, but are accessed via + * service google.longrunning.Operations. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Datastore\Admin\V1\DatastoreAdminClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createIndexAsync(CreateIndexRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteIndexAsync(DeleteIndexRequest $request, array $optionalArgs = []) + * @method PromiseInterface exportEntitiesAsync(ExportEntitiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIndexAsync(GetIndexRequest $request, array $optionalArgs = []) + * @method PromiseInterface importEntitiesAsync(ImportEntitiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listIndexesAsync(ListIndexesRequest $request, array $optionalArgs = []) */ -final class DatastoreAdminClient extends DatastoreAdminBaseClient +final class DatastoreAdminClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DatastoreAdminBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.datastore.admin.v1.DatastoreAdmin'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'datastore.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/datastore', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/datastore_admin_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/datastore_admin_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/datastore_admin_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/datastore_admin_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'datastore.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates the specified index. + * A newly created index's initial state is `CREATING`. On completion of the + * returned [google.longrunning.Operation][google.longrunning.Operation], the + * state will be `READY`. If the index already exists, the call will return an + * `ALREADY_EXISTS` status. + * + * During index creation, the process could result in an error, in which + * case the index will move to the `ERROR` state. The process can be recovered + * by fixing the data that caused the error, removing the index with + * [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], then + * re-creating the index with [create] + * [google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. + * + * Indexes with a single property cannot be created. + * + * The async variant is {@see DatastoreAdminClient::createIndexAsync()} . + * + * @example samples/V1/DatastoreAdminClient/create_index.php + * + * @param CreateIndexRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createIndex(CreateIndexRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateIndex', $request, $callOptions)->wait(); + } + + /** + * Deletes an existing index. + * An index can only be deleted if it is in a `READY` or `ERROR` state. On + * successful execution of the request, the index will be in a `DELETING` + * [state][google.datastore.admin.v1.Index.State]. And on completion of the + * returned [google.longrunning.Operation][google.longrunning.Operation], the + * index will be removed. + * + * During index deletion, the process could result in an error, in which + * case the index will move to the `ERROR` state. The process can be recovered + * by fixing the data that caused the error, followed by calling + * [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] again. + * + * The async variant is {@see DatastoreAdminClient::deleteIndexAsync()} . + * + * @example samples/V1/DatastoreAdminClient/delete_index.php + * + * @param DeleteIndexRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteIndex(DeleteIndexRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteIndex', $request, $callOptions)->wait(); + } + + /** + * Exports a copy of all or a subset of entities from Google Cloud Datastore + * to another storage system, such as Google Cloud Storage. Recent updates to + * entities may not be reflected in the export. The export occurs in the + * background and its progress can be monitored and managed via the + * Operation resource that is created. The output of an export may only be + * used once the associated operation is done. If an export operation is + * cancelled before completion it may leave partial data behind in Google + * Cloud Storage. + * + * The async variant is {@see DatastoreAdminClient::exportEntitiesAsync()} . + * + * @example samples/V1/DatastoreAdminClient/export_entities.php + * + * @param ExportEntitiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportEntities(ExportEntitiesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ExportEntities', $request, $callOptions)->wait(); + } + + /** + * Gets an index. + * + * The async variant is {@see DatastoreAdminClient::getIndexAsync()} . + * + * @example samples/V1/DatastoreAdminClient/get_index.php + * + * @param GetIndexRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Index + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIndex(GetIndexRequest $request, array $callOptions = []): Index + { + return $this->startApiCall('GetIndex', $request, $callOptions)->wait(); + } + + /** + * Imports entities into Google Cloud Datastore. Existing entities with the + * same key are overwritten. The import occurs in the background and its + * progress can be monitored and managed via the Operation resource that is + * created. If an ImportEntities operation is cancelled, it is possible + * that a subset of the data has already been imported to Cloud Datastore. + * + * The async variant is {@see DatastoreAdminClient::importEntitiesAsync()} . + * + * @example samples/V1/DatastoreAdminClient/import_entities.php + * + * @param ImportEntitiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importEntities(ImportEntitiesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportEntities', $request, $callOptions)->wait(); + } + + /** + * Lists the indexes that match the specified filters. Datastore uses an + * eventually consistent query to fetch the list of indexes and may + * occasionally return stale results. + * + * The async variant is {@see DatastoreAdminClient::listIndexesAsync()} . + * + * @example samples/V1/DatastoreAdminClient/list_indexes.php + * + * @param ListIndexesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listIndexes(ListIndexesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListIndexes', $request, $callOptions); + } } diff --git a/Datastream/composer.json b/Datastream/composer.json index 3de6d1f703b9..7a400372575b 100644 --- a/Datastream/composer.json +++ b/Datastream/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Datastream/src/V1/Client/BaseClient/DatastreamBaseClient.php b/Datastream/src/V1/Client/BaseClient/DatastreamBaseClient.php deleted file mode 100644 index ae0ad5a60816..000000000000 --- a/Datastream/src/V1/Client/BaseClient/DatastreamBaseClient.php +++ /dev/null @@ -1,1085 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/datastream_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/datastream_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/datastream_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/datastream_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * connection_profile resource. - * - * @param string $project - * @param string $location - * @param string $connectionProfile - * - * @return string The formatted connection_profile resource. - */ - public static function connectionProfileName(string $project, string $location, string $connectionProfile): string - { - return self::getPathTemplate('connectionProfile')->render([ - 'project' => $project, - 'location' => $location, - 'connection_profile' => $connectionProfile, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a networks - * resource. - * - * @param string $project - * @param string $network - * - * @return string The formatted networks resource. - */ - public static function networksName(string $project, string $network): string - { - return self::getPathTemplate('networks')->render([ - 'project' => $project, - 'network' => $network, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * private_connection resource. - * - * @param string $project - * @param string $location - * @param string $privateConnection - * - * @return string The formatted private_connection resource. - */ - public static function privateConnectionName(string $project, string $location, string $privateConnection): string - { - return self::getPathTemplate('privateConnection')->render([ - 'project' => $project, - 'location' => $location, - 'private_connection' => $privateConnection, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a route - * resource. - * - * @param string $project - * @param string $location - * @param string $privateConnection - * @param string $route - * - * @return string The formatted route resource. - */ - public static function routeName(string $project, string $location, string $privateConnection, string $route): string - { - return self::getPathTemplate('route')->render([ - 'project' => $project, - 'location' => $location, - 'private_connection' => $privateConnection, - 'route' => $route, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a stream - * resource. - * - * @param string $project - * @param string $location - * @param string $stream - * - * @return string The formatted stream resource. - */ - public static function streamName(string $project, string $location, string $stream): string - { - return self::getPathTemplate('stream')->render([ - 'project' => $project, - 'location' => $location, - 'stream' => $stream, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * stream_object resource. - * - * @param string $project - * @param string $location - * @param string $stream - * @param string $object - * - * @return string The formatted stream_object resource. - */ - public static function streamObjectName(string $project, string $location, string $stream, string $object): string - { - return self::getPathTemplate('streamObject')->render([ - 'project' => $project, - 'location' => $location, - 'stream' => $stream, - 'object' => $object, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - connectionProfile: projects/{project}/locations/{location}/connectionProfiles/{connection_profile} - * - location: projects/{project}/locations/{location} - * - networks: projects/{project}/global/networks/{network} - * - privateConnection: projects/{project}/locations/{location}/privateConnections/{private_connection} - * - route: projects/{project}/locations/{location}/privateConnections/{private_connection}/routes/{route} - * - stream: projects/{project}/locations/{location}/streams/{stream} - * - streamObject: projects/{project}/locations/{location}/streams/{stream}/objects/{object} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'datastream.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Use this method to create a connection profile in a project and location. - * - * The async variant is {@see self::createConnectionProfileAsync()} . - * - * @param CreateConnectionProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createConnectionProfile(CreateConnectionProfileRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateConnectionProfile', $request, $callOptions)->wait(); - } - - /** - * Use this method to create a private connectivity configuration. - * - * The async variant is {@see self::createPrivateConnectionAsync()} . - * - * @param CreatePrivateConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createPrivateConnection(CreatePrivateConnectionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreatePrivateConnection', $request, $callOptions)->wait(); - } - - /** - * Use this method to create a route for a private connectivity configuration - * in a project and location. - * - * The async variant is {@see self::createRouteAsync()} . - * - * @param CreateRouteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createRoute(CreateRouteRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateRoute', $request, $callOptions)->wait(); - } - - /** - * Use this method to create a stream. - * - * The async variant is {@see self::createStreamAsync()} . - * - * @param CreateStreamRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createStream(CreateStreamRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateStream', $request, $callOptions)->wait(); - } - - /** - * Use this method to delete a connection profile. - * - * The async variant is {@see self::deleteConnectionProfileAsync()} . - * - * @param DeleteConnectionProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteConnectionProfile(DeleteConnectionProfileRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteConnectionProfile', $request, $callOptions)->wait(); - } - - /** - * Use this method to delete a private connectivity configuration. - * - * The async variant is {@see self::deletePrivateConnectionAsync()} . - * - * @param DeletePrivateConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deletePrivateConnection(DeletePrivateConnectionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeletePrivateConnection', $request, $callOptions)->wait(); - } - - /** - * Use this method to delete a route. - * - * The async variant is {@see self::deleteRouteAsync()} . - * - * @param DeleteRouteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteRoute(DeleteRouteRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteRoute', $request, $callOptions)->wait(); - } - - /** - * Use this method to delete a stream. - * - * The async variant is {@see self::deleteStreamAsync()} . - * - * @param DeleteStreamRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteStream(DeleteStreamRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteStream', $request, $callOptions)->wait(); - } - - /** - * Use this method to discover a connection profile. - * The discover API call exposes the data objects and metadata belonging to - * the profile. Typically, a request returns children data objects of a - * parent data object that's optionally supplied in the request. - * - * The async variant is {@see self::discoverConnectionProfileAsync()} . - * - * @param DiscoverConnectionProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DiscoverConnectionProfileResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function discoverConnectionProfile(DiscoverConnectionProfileRequest $request, array $callOptions = []): DiscoverConnectionProfileResponse - { - return $this->startApiCall('DiscoverConnectionProfile', $request, $callOptions)->wait(); - } - - /** - * The FetchStaticIps API call exposes the static IP addresses used by - * Datastream. - * - * The async variant is {@see self::fetchStaticIpsAsync()} . - * - * @param FetchStaticIpsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function fetchStaticIps(FetchStaticIpsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('FetchStaticIps', $request, $callOptions); - } - - /** - * Use this method to get details about a connection profile. - * - * The async variant is {@see self::getConnectionProfileAsync()} . - * - * @param GetConnectionProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ConnectionProfile - * - * @throws ApiException Thrown if the API call fails. - */ - public function getConnectionProfile(GetConnectionProfileRequest $request, array $callOptions = []): ConnectionProfile - { - return $this->startApiCall('GetConnectionProfile', $request, $callOptions)->wait(); - } - - /** - * Use this method to get details about a private connectivity configuration. - * - * The async variant is {@see self::getPrivateConnectionAsync()} . - * - * @param GetPrivateConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PrivateConnection - * - * @throws ApiException Thrown if the API call fails. - */ - public function getPrivateConnection(GetPrivateConnectionRequest $request, array $callOptions = []): PrivateConnection - { - return $this->startApiCall('GetPrivateConnection', $request, $callOptions)->wait(); - } - - /** - * Use this method to get details about a route. - * - * The async variant is {@see self::getRouteAsync()} . - * - * @param GetRouteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Route - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRoute(GetRouteRequest $request, array $callOptions = []): Route - { - return $this->startApiCall('GetRoute', $request, $callOptions)->wait(); - } - - /** - * Use this method to get details about a stream. - * - * The async variant is {@see self::getStreamAsync()} . - * - * @param GetStreamRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Stream - * - * @throws ApiException Thrown if the API call fails. - */ - public function getStream(GetStreamRequest $request, array $callOptions = []): Stream - { - return $this->startApiCall('GetStream', $request, $callOptions)->wait(); - } - - /** - * Use this method to get details about a stream object. - * - * The async variant is {@see self::getStreamObjectAsync()} . - * - * @param GetStreamObjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 StreamObject - * - * @throws ApiException Thrown if the API call fails. - */ - public function getStreamObject(GetStreamObjectRequest $request, array $callOptions = []): StreamObject - { - return $this->startApiCall('GetStreamObject', $request, $callOptions)->wait(); - } - - /** - * Use this method to list connection profiles created in a project and - * location. - * - * The async variant is {@see self::listConnectionProfilesAsync()} . - * - * @param ListConnectionProfilesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listConnectionProfiles(ListConnectionProfilesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListConnectionProfiles', $request, $callOptions); - } - - /** - * Use this method to list private connectivity configurations in a project - * and location. - * - * The async variant is {@see self::listPrivateConnectionsAsync()} . - * - * @param ListPrivateConnectionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPrivateConnections(ListPrivateConnectionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPrivateConnections', $request, $callOptions); - } - - /** - * Use this method to list routes created for a private connectivity - * configuration in a project and location. - * - * The async variant is {@see self::listRoutesAsync()} . - * - * @param ListRoutesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listRoutes(ListRoutesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListRoutes', $request, $callOptions); - } - - /** - * Use this method to list the objects of a specific stream. - * - * The async variant is {@see self::listStreamObjectsAsync()} . - * - * @param ListStreamObjectsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listStreamObjects(ListStreamObjectsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListStreamObjects', $request, $callOptions); - } - - /** - * Use this method to list streams in a project and location. - * - * The async variant is {@see self::listStreamsAsync()} . - * - * @param ListStreamsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listStreams(ListStreamsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListStreams', $request, $callOptions); - } - - /** - * Use this method to look up a stream object by its source object identifier. - * - * The async variant is {@see self::lookupStreamObjectAsync()} . - * - * @param LookupStreamObjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 StreamObject - * - * @throws ApiException Thrown if the API call fails. - */ - public function lookupStreamObject(LookupStreamObjectRequest $request, array $callOptions = []): StreamObject - { - return $this->startApiCall('LookupStreamObject', $request, $callOptions)->wait(); - } - - /** - * Use this method to start a backfill job for the specified stream object. - * - * The async variant is {@see self::startBackfillJobAsync()} . - * - * @param StartBackfillJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 StartBackfillJobResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function startBackfillJob(StartBackfillJobRequest $request, array $callOptions = []): StartBackfillJobResponse - { - return $this->startApiCall('StartBackfillJob', $request, $callOptions)->wait(); - } - - /** - * Use this method to stop a backfill job for the specified stream object. - * - * The async variant is {@see self::stopBackfillJobAsync()} . - * - * @param StopBackfillJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 StopBackfillJobResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function stopBackfillJob(StopBackfillJobRequest $request, array $callOptions = []): StopBackfillJobResponse - { - return $this->startApiCall('StopBackfillJob', $request, $callOptions)->wait(); - } - - /** - * Use this method to update the parameters of a connection profile. - * - * The async variant is {@see self::updateConnectionProfileAsync()} . - * - * @param UpdateConnectionProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateConnectionProfile(UpdateConnectionProfileRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateConnectionProfile', $request, $callOptions)->wait(); - } - - /** - * Use this method to update the configuration of a stream. - * - * The async variant is {@see self::updateStreamAsync()} . - * - * @param UpdateStreamRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateStream(UpdateStreamRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateStream', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Datastream/src/V1/Client/DatastreamClient.php b/Datastream/src/V1/Client/DatastreamClient.php index 778bc308d34c..b85dcb7a5405 100644 --- a/Datastream/src/V1/Client/DatastreamClient.php +++ b/Datastream/src/V1/Client/DatastreamClient.php @@ -24,17 +24,1060 @@ namespace Google\Cloud\Datastream\V1\Client; -use Google\Cloud\Datastream\V1\Client\BaseClient\DatastreamBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Datastream\V1\ConnectionProfile; +use Google\Cloud\Datastream\V1\CreateConnectionProfileRequest; +use Google\Cloud\Datastream\V1\CreatePrivateConnectionRequest; +use Google\Cloud\Datastream\V1\CreateRouteRequest; +use Google\Cloud\Datastream\V1\CreateStreamRequest; +use Google\Cloud\Datastream\V1\DeleteConnectionProfileRequest; +use Google\Cloud\Datastream\V1\DeletePrivateConnectionRequest; +use Google\Cloud\Datastream\V1\DeleteRouteRequest; +use Google\Cloud\Datastream\V1\DeleteStreamRequest; +use Google\Cloud\Datastream\V1\DiscoverConnectionProfileRequest; +use Google\Cloud\Datastream\V1\DiscoverConnectionProfileResponse; +use Google\Cloud\Datastream\V1\FetchStaticIpsRequest; +use Google\Cloud\Datastream\V1\GetConnectionProfileRequest; +use Google\Cloud\Datastream\V1\GetPrivateConnectionRequest; +use Google\Cloud\Datastream\V1\GetRouteRequest; +use Google\Cloud\Datastream\V1\GetStreamObjectRequest; +use Google\Cloud\Datastream\V1\GetStreamRequest; +use Google\Cloud\Datastream\V1\ListConnectionProfilesRequest; +use Google\Cloud\Datastream\V1\ListPrivateConnectionsRequest; +use Google\Cloud\Datastream\V1\ListRoutesRequest; +use Google\Cloud\Datastream\V1\ListStreamObjectsRequest; +use Google\Cloud\Datastream\V1\ListStreamsRequest; +use Google\Cloud\Datastream\V1\LookupStreamObjectRequest; +use Google\Cloud\Datastream\V1\PrivateConnection; +use Google\Cloud\Datastream\V1\Route; +use Google\Cloud\Datastream\V1\StartBackfillJobRequest; +use Google\Cloud\Datastream\V1\StartBackfillJobResponse; +use Google\Cloud\Datastream\V1\StopBackfillJobRequest; +use Google\Cloud\Datastream\V1\StopBackfillJobResponse; +use Google\Cloud\Datastream\V1\Stream; +use Google\Cloud\Datastream\V1\StreamObject; +use Google\Cloud\Datastream\V1\UpdateConnectionProfileRequest; +use Google\Cloud\Datastream\V1\UpdateStreamRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Datastream service * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Datastream\V1\DatastreamClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createConnectionProfileAsync(CreateConnectionProfileRequest $request, array $optionalArgs = []) + * @method PromiseInterface createPrivateConnectionAsync(CreatePrivateConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface createRouteAsync(CreateRouteRequest $request, array $optionalArgs = []) + * @method PromiseInterface createStreamAsync(CreateStreamRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteConnectionProfileAsync(DeleteConnectionProfileRequest $request, array $optionalArgs = []) + * @method PromiseInterface deletePrivateConnectionAsync(DeletePrivateConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteRouteAsync(DeleteRouteRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteStreamAsync(DeleteStreamRequest $request, array $optionalArgs = []) + * @method PromiseInterface discoverConnectionProfileAsync(DiscoverConnectionProfileRequest $request, array $optionalArgs = []) + * @method PromiseInterface fetchStaticIpsAsync(FetchStaticIpsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getConnectionProfileAsync(GetConnectionProfileRequest $request, array $optionalArgs = []) + * @method PromiseInterface getPrivateConnectionAsync(GetPrivateConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRouteAsync(GetRouteRequest $request, array $optionalArgs = []) + * @method PromiseInterface getStreamAsync(GetStreamRequest $request, array $optionalArgs = []) + * @method PromiseInterface getStreamObjectAsync(GetStreamObjectRequest $request, array $optionalArgs = []) + * @method PromiseInterface listConnectionProfilesAsync(ListConnectionProfilesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPrivateConnectionsAsync(ListPrivateConnectionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listRoutesAsync(ListRoutesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listStreamObjectsAsync(ListStreamObjectsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listStreamsAsync(ListStreamsRequest $request, array $optionalArgs = []) + * @method PromiseInterface lookupStreamObjectAsync(LookupStreamObjectRequest $request, array $optionalArgs = []) + * @method PromiseInterface startBackfillJobAsync(StartBackfillJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface stopBackfillJobAsync(StopBackfillJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateConnectionProfileAsync(UpdateConnectionProfileRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateStreamAsync(UpdateStreamRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class DatastreamClient extends DatastreamBaseClient +final class DatastreamClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DatastreamBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.datastream.v1.Datastream'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'datastream.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/datastream_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/datastream_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/datastream_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/datastream_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * connection_profile resource. + * + * @param string $project + * @param string $location + * @param string $connectionProfile + * + * @return string The formatted connection_profile resource. + */ + public static function connectionProfileName(string $project, string $location, string $connectionProfile): string + { + return self::getPathTemplate('connectionProfile')->render([ + 'project' => $project, + 'location' => $location, + 'connection_profile' => $connectionProfile, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a networks + * resource. + * + * @param string $project + * @param string $network + * + * @return string The formatted networks resource. + */ + public static function networksName(string $project, string $network): string + { + return self::getPathTemplate('networks')->render([ + 'project' => $project, + 'network' => $network, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * private_connection resource. + * + * @param string $project + * @param string $location + * @param string $privateConnection + * + * @return string The formatted private_connection resource. + */ + public static function privateConnectionName(string $project, string $location, string $privateConnection): string + { + return self::getPathTemplate('privateConnection')->render([ + 'project' => $project, + 'location' => $location, + 'private_connection' => $privateConnection, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a route + * resource. + * + * @param string $project + * @param string $location + * @param string $privateConnection + * @param string $route + * + * @return string The formatted route resource. + */ + public static function routeName(string $project, string $location, string $privateConnection, string $route): string + { + return self::getPathTemplate('route')->render([ + 'project' => $project, + 'location' => $location, + 'private_connection' => $privateConnection, + 'route' => $route, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a stream + * resource. + * + * @param string $project + * @param string $location + * @param string $stream + * + * @return string The formatted stream resource. + */ + public static function streamName(string $project, string $location, string $stream): string + { + return self::getPathTemplate('stream')->render([ + 'project' => $project, + 'location' => $location, + 'stream' => $stream, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * stream_object resource. + * + * @param string $project + * @param string $location + * @param string $stream + * @param string $object + * + * @return string The formatted stream_object resource. + */ + public static function streamObjectName(string $project, string $location, string $stream, string $object): string + { + return self::getPathTemplate('streamObject')->render([ + 'project' => $project, + 'location' => $location, + 'stream' => $stream, + 'object' => $object, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - connectionProfile: projects/{project}/locations/{location}/connectionProfiles/{connection_profile} + * - location: projects/{project}/locations/{location} + * - networks: projects/{project}/global/networks/{network} + * - privateConnection: projects/{project}/locations/{location}/privateConnections/{private_connection} + * - route: projects/{project}/locations/{location}/privateConnections/{private_connection}/routes/{route} + * - stream: projects/{project}/locations/{location}/streams/{stream} + * - streamObject: projects/{project}/locations/{location}/streams/{stream}/objects/{object} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'datastream.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Use this method to create a connection profile in a project and location. + * + * The async variant is {@see DatastreamClient::createConnectionProfileAsync()} . + * + * @param CreateConnectionProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createConnectionProfile(CreateConnectionProfileRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateConnectionProfile', $request, $callOptions)->wait(); + } + + /** + * Use this method to create a private connectivity configuration. + * + * The async variant is {@see DatastreamClient::createPrivateConnectionAsync()} . + * + * @param CreatePrivateConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createPrivateConnection(CreatePrivateConnectionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreatePrivateConnection', $request, $callOptions)->wait(); + } + + /** + * Use this method to create a route for a private connectivity configuration + * in a project and location. + * + * The async variant is {@see DatastreamClient::createRouteAsync()} . + * + * @param CreateRouteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createRoute(CreateRouteRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateRoute', $request, $callOptions)->wait(); + } + + /** + * Use this method to create a stream. + * + * The async variant is {@see DatastreamClient::createStreamAsync()} . + * + * @param CreateStreamRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createStream(CreateStreamRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateStream', $request, $callOptions)->wait(); + } + + /** + * Use this method to delete a connection profile. + * + * The async variant is {@see DatastreamClient::deleteConnectionProfileAsync()} . + * + * @param DeleteConnectionProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteConnectionProfile(DeleteConnectionProfileRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteConnectionProfile', $request, $callOptions)->wait(); + } + + /** + * Use this method to delete a private connectivity configuration. + * + * The async variant is {@see DatastreamClient::deletePrivateConnectionAsync()} . + * + * @param DeletePrivateConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deletePrivateConnection(DeletePrivateConnectionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeletePrivateConnection', $request, $callOptions)->wait(); + } + + /** + * Use this method to delete a route. + * + * The async variant is {@see DatastreamClient::deleteRouteAsync()} . + * + * @param DeleteRouteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteRoute(DeleteRouteRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteRoute', $request, $callOptions)->wait(); + } + + /** + * Use this method to delete a stream. + * + * The async variant is {@see DatastreamClient::deleteStreamAsync()} . + * + * @param DeleteStreamRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteStream(DeleteStreamRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteStream', $request, $callOptions)->wait(); + } + + /** + * Use this method to discover a connection profile. + * The discover API call exposes the data objects and metadata belonging to + * the profile. Typically, a request returns children data objects of a + * parent data object that's optionally supplied in the request. + * + * The async variant is {@see DatastreamClient::discoverConnectionProfileAsync()} . + * + * @param DiscoverConnectionProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DiscoverConnectionProfileResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function discoverConnectionProfile(DiscoverConnectionProfileRequest $request, array $callOptions = []): DiscoverConnectionProfileResponse + { + return $this->startApiCall('DiscoverConnectionProfile', $request, $callOptions)->wait(); + } + + /** + * The FetchStaticIps API call exposes the static IP addresses used by + * Datastream. + * + * The async variant is {@see DatastreamClient::fetchStaticIpsAsync()} . + * + * @param FetchStaticIpsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function fetchStaticIps(FetchStaticIpsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('FetchStaticIps', $request, $callOptions); + } + + /** + * Use this method to get details about a connection profile. + * + * The async variant is {@see DatastreamClient::getConnectionProfileAsync()} . + * + * @param GetConnectionProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ConnectionProfile + * + * @throws ApiException Thrown if the API call fails. + */ + public function getConnectionProfile(GetConnectionProfileRequest $request, array $callOptions = []): ConnectionProfile + { + return $this->startApiCall('GetConnectionProfile', $request, $callOptions)->wait(); + } + + /** + * Use this method to get details about a private connectivity configuration. + * + * The async variant is {@see DatastreamClient::getPrivateConnectionAsync()} . + * + * @param GetPrivateConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PrivateConnection + * + * @throws ApiException Thrown if the API call fails. + */ + public function getPrivateConnection(GetPrivateConnectionRequest $request, array $callOptions = []): PrivateConnection + { + return $this->startApiCall('GetPrivateConnection', $request, $callOptions)->wait(); + } + + /** + * Use this method to get details about a route. + * + * The async variant is {@see DatastreamClient::getRouteAsync()} . + * + * @param GetRouteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Route + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRoute(GetRouteRequest $request, array $callOptions = []): Route + { + return $this->startApiCall('GetRoute', $request, $callOptions)->wait(); + } + + /** + * Use this method to get details about a stream. + * + * The async variant is {@see DatastreamClient::getStreamAsync()} . + * + * @param GetStreamRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Stream + * + * @throws ApiException Thrown if the API call fails. + */ + public function getStream(GetStreamRequest $request, array $callOptions = []): Stream + { + return $this->startApiCall('GetStream', $request, $callOptions)->wait(); + } + + /** + * Use this method to get details about a stream object. + * + * The async variant is {@see DatastreamClient::getStreamObjectAsync()} . + * + * @param GetStreamObjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 StreamObject + * + * @throws ApiException Thrown if the API call fails. + */ + public function getStreamObject(GetStreamObjectRequest $request, array $callOptions = []): StreamObject + { + return $this->startApiCall('GetStreamObject', $request, $callOptions)->wait(); + } + + /** + * Use this method to list connection profiles created in a project and + * location. + * + * The async variant is {@see DatastreamClient::listConnectionProfilesAsync()} . + * + * @param ListConnectionProfilesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listConnectionProfiles(ListConnectionProfilesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListConnectionProfiles', $request, $callOptions); + } + + /** + * Use this method to list private connectivity configurations in a project + * and location. + * + * The async variant is {@see DatastreamClient::listPrivateConnectionsAsync()} . + * + * @param ListPrivateConnectionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPrivateConnections(ListPrivateConnectionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPrivateConnections', $request, $callOptions); + } + + /** + * Use this method to list routes created for a private connectivity + * configuration in a project and location. + * + * The async variant is {@see DatastreamClient::listRoutesAsync()} . + * + * @param ListRoutesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listRoutes(ListRoutesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListRoutes', $request, $callOptions); + } + + /** + * Use this method to list the objects of a specific stream. + * + * The async variant is {@see DatastreamClient::listStreamObjectsAsync()} . + * + * @param ListStreamObjectsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listStreamObjects(ListStreamObjectsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListStreamObjects', $request, $callOptions); + } + + /** + * Use this method to list streams in a project and location. + * + * The async variant is {@see DatastreamClient::listStreamsAsync()} . + * + * @param ListStreamsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listStreams(ListStreamsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListStreams', $request, $callOptions); + } + + /** + * Use this method to look up a stream object by its source object identifier. + * + * The async variant is {@see DatastreamClient::lookupStreamObjectAsync()} . + * + * @param LookupStreamObjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 StreamObject + * + * @throws ApiException Thrown if the API call fails. + */ + public function lookupStreamObject(LookupStreamObjectRequest $request, array $callOptions = []): StreamObject + { + return $this->startApiCall('LookupStreamObject', $request, $callOptions)->wait(); + } + + /** + * Use this method to start a backfill job for the specified stream object. + * + * The async variant is {@see DatastreamClient::startBackfillJobAsync()} . + * + * @param StartBackfillJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 StartBackfillJobResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function startBackfillJob(StartBackfillJobRequest $request, array $callOptions = []): StartBackfillJobResponse + { + return $this->startApiCall('StartBackfillJob', $request, $callOptions)->wait(); + } + + /** + * Use this method to stop a backfill job for the specified stream object. + * + * The async variant is {@see DatastreamClient::stopBackfillJobAsync()} . + * + * @param StopBackfillJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 StopBackfillJobResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function stopBackfillJob(StopBackfillJobRequest $request, array $callOptions = []): StopBackfillJobResponse + { + return $this->startApiCall('StopBackfillJob', $request, $callOptions)->wait(); + } + + /** + * Use this method to update the parameters of a connection profile. + * + * The async variant is {@see DatastreamClient::updateConnectionProfileAsync()} . + * + * @param UpdateConnectionProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateConnectionProfile(UpdateConnectionProfileRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateConnectionProfile', $request, $callOptions)->wait(); + } + + /** + * Use this method to update the configuration of a stream. + * + * The async variant is {@see DatastreamClient::updateStreamAsync()} . + * + * @param UpdateStreamRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateStream(UpdateStreamRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateStream', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see DatastreamClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see DatastreamClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Debugger/composer.json b/Debugger/composer.json index a31690208b00..2b5b577e59d4 100644 --- a/Debugger/composer.json +++ b/Debugger/composer.json @@ -5,9 +5,9 @@ "minimum-stability": "stable", "require": { "php": ">=7.4", - "google/cloud-core": "^1.39", + "google/cloud-core": "^1.52.7", "google/cloud-logging": "^1.16", - "google/gax": "^1.19.1", + "google/gax": "^1.24.0", "google/cloud-common-protos": "^0.4", "psr/log": "^1.0||^2.0" }, diff --git a/Debugger/src/V2/Client/BaseClient/Controller2BaseClient.php b/Debugger/src/V2/Client/BaseClient/Controller2BaseClient.php deleted file mode 100644 index 0ce6bad268c0..000000000000 --- a/Debugger/src/V2/Client/BaseClient/Controller2BaseClient.php +++ /dev/null @@ -1,289 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/controller2_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/controller2_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/controller2_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/controller2_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'clouddebugger.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Returns the list of all active breakpoints for the debuggee. - * - * The breakpoint specification (`location`, `condition`, and `expressions` - * fields) is semantically immutable, although the field values may - * change. For example, an agent may update the location line number - * to reflect the actual line where the breakpoint was set, but this - * doesn't change the breakpoint semantics. - * - * This means that an agent does not need to check if a breakpoint has changed - * when it encounters the same breakpoint on a successive call. - * Moreover, an agent should remember the breakpoints that are completed - * until the controller removes them from the active list to avoid - * setting those breakpoints again. - * - * The async variant is {@see self::listActiveBreakpointsAsync()} . - * - * @param ListActiveBreakpointsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ListActiveBreakpointsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listActiveBreakpoints(ListActiveBreakpointsRequest $request, array $callOptions = []): ListActiveBreakpointsResponse - { - return $this->startApiCall('ListActiveBreakpoints', $request, $callOptions)->wait(); - } - - /** - * Registers the debuggee with the controller service. - * - * All agents attached to the same application must call this method with - * exactly the same request content to get back the same stable `debuggee_id`. - * Agents should call this method again whenever `google.rpc.Code.NOT_FOUND` - * is returned from any controller method. - * - * This protocol allows the controller service to disable debuggees, recover - * from data loss, or change the `debuggee_id` format. Agents must handle - * `debuggee_id` value changing upon re-registration. - * - * The async variant is {@see self::registerDebuggeeAsync()} . - * - * @param RegisterDebuggeeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RegisterDebuggeeResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function registerDebuggee(RegisterDebuggeeRequest $request, array $callOptions = []): RegisterDebuggeeResponse - { - return $this->startApiCall('RegisterDebuggee', $request, $callOptions)->wait(); - } - - /** - * Updates the breakpoint state or mutable fields. - * The entire Breakpoint message must be sent back to the controller service. - * - * Updates to active breakpoint fields are only allowed if the new value - * does not change the breakpoint specification. Updates to the `location`, - * `condition` and `expressions` fields should not alter the breakpoint - * semantics. These may only make changes such as canonicalizing a value - * or snapping the location to the correct line of code. - * - * The async variant is {@see self::updateActiveBreakpointAsync()} . - * - * @param UpdateActiveBreakpointRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 UpdateActiveBreakpointResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateActiveBreakpoint(UpdateActiveBreakpointRequest $request, array $callOptions = []): UpdateActiveBreakpointResponse - { - return $this->startApiCall('UpdateActiveBreakpoint', $request, $callOptions)->wait(); - } -} diff --git a/Debugger/src/V2/Client/BaseClient/Debugger2BaseClient.php b/Debugger/src/V2/Client/BaseClient/Debugger2BaseClient.php deleted file mode 100644 index 2a718335de2e..000000000000 --- a/Debugger/src/V2/Client/BaseClient/Debugger2BaseClient.php +++ /dev/null @@ -1,304 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/debugger2_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/debugger2_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/debugger2_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/debugger2_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'clouddebugger.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the breakpoint from the debuggee. - * - * The async variant is {@see self::deleteBreakpointAsync()} . - * - * @param DeleteBreakpointRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteBreakpoint(DeleteBreakpointRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteBreakpoint', $request, $callOptions)->wait(); - } - - /** - * Gets breakpoint information. - * - * The async variant is {@see self::getBreakpointAsync()} . - * - * @param GetBreakpointRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GetBreakpointResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function getBreakpoint(GetBreakpointRequest $request, array $callOptions = []): GetBreakpointResponse - { - return $this->startApiCall('GetBreakpoint', $request, $callOptions)->wait(); - } - - /** - * Lists all breakpoints for the debuggee. - * - * The async variant is {@see self::listBreakpointsAsync()} . - * - * @param ListBreakpointsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ListBreakpointsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listBreakpoints(ListBreakpointsRequest $request, array $callOptions = []): ListBreakpointsResponse - { - return $this->startApiCall('ListBreakpoints', $request, $callOptions)->wait(); - } - - /** - * Lists all the debuggees that the user has access to. - * - * The async variant is {@see self::listDebuggeesAsync()} . - * - * @param ListDebuggeesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ListDebuggeesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDebuggees(ListDebuggeesRequest $request, array $callOptions = []): ListDebuggeesResponse - { - return $this->startApiCall('ListDebuggees', $request, $callOptions)->wait(); - } - - /** - * Sets the breakpoint to the debuggee. - * - * The async variant is {@see self::setBreakpointAsync()} . - * - * @param SetBreakpointRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SetBreakpointResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setBreakpoint(SetBreakpointRequest $request, array $callOptions = []): SetBreakpointResponse - { - return $this->startApiCall('SetBreakpoint', $request, $callOptions)->wait(); - } -} diff --git a/Debugger/src/V2/Client/Controller2Client.php b/Debugger/src/V2/Client/Controller2Client.php index 83a303cd8f13..dac4b3fa28eb 100644 --- a/Debugger/src/V2/Client/Controller2Client.php +++ b/Debugger/src/V2/Client/Controller2Client.php @@ -24,17 +24,264 @@ namespace Google\Cloud\Debugger\V2\Client; -use Google\Cloud\Debugger\V2\Client\BaseClient\Controller2BaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Debugger\V2\ListActiveBreakpointsRequest; +use Google\Cloud\Debugger\V2\ListActiveBreakpointsResponse; +use Google\Cloud\Debugger\V2\RegisterDebuggeeRequest; +use Google\Cloud\Debugger\V2\RegisterDebuggeeResponse; +use Google\Cloud\Debugger\V2\UpdateActiveBreakpointRequest; +use Google\Cloud\Debugger\V2\UpdateActiveBreakpointResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Controller service provides the API for orchestrating a collection of + * debugger agents to perform debugging tasks. These agents are each attached + * to a process of an application which may include one or more replicas. * - * This class is currently experimental and may be subject to changes. + * The debugger agents register with the Controller to identify the application + * being debugged, the Debuggee. All agents that register with the same data, + * represent the same Debuggee, and are assigned the same `debuggee_id`. + * + * The debugger agents call the Controller to retrieve the list of active + * Breakpoints. Agents with the same `debuggee_id` get the same breakpoints + * list. An agent that can fulfill the breakpoint request updates the + * Controller with the breakpoint result. The controller selects the first + * result received and discards the rest of the results. + * Agents that poll again for active breakpoints will no longer have + * the completed breakpoint in the list and should remove that breakpoint from + * their attached process. + * + * The Controller service does not provide a way to retrieve the results of + * a completed breakpoint. This functionality is available using the Debugger + * service. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Debugger\V2\Controller2Client} for the stable implementation * * @experimental + * + * @method PromiseInterface listActiveBreakpointsAsync(ListActiveBreakpointsRequest $request, array $optionalArgs = []) + * @method PromiseInterface registerDebuggeeAsync(RegisterDebuggeeRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateActiveBreakpointAsync(UpdateActiveBreakpointRequest $request, array $optionalArgs = []) */ -final class Controller2Client extends Controller2BaseClient +final class Controller2Client { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see Controller2BaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.devtools.clouddebugger.v2.Controller2'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'clouddebugger.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud_debugger', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/controller2_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/controller2_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/controller2_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/controller2_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'clouddebugger.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Returns the list of all active breakpoints for the debuggee. + * + * The breakpoint specification (`location`, `condition`, and `expressions` + * fields) is semantically immutable, although the field values may + * change. For example, an agent may update the location line number + * to reflect the actual line where the breakpoint was set, but this + * doesn't change the breakpoint semantics. + * + * This means that an agent does not need to check if a breakpoint has changed + * when it encounters the same breakpoint on a successive call. + * Moreover, an agent should remember the breakpoints that are completed + * until the controller removes them from the active list to avoid + * setting those breakpoints again. + * + * The async variant is {@see Controller2Client::listActiveBreakpointsAsync()} . + * + * @param ListActiveBreakpointsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ListActiveBreakpointsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listActiveBreakpoints(ListActiveBreakpointsRequest $request, array $callOptions = []): ListActiveBreakpointsResponse + { + return $this->startApiCall('ListActiveBreakpoints', $request, $callOptions)->wait(); + } + + /** + * Registers the debuggee with the controller service. + * + * All agents attached to the same application must call this method with + * exactly the same request content to get back the same stable `debuggee_id`. + * Agents should call this method again whenever `google.rpc.Code.NOT_FOUND` + * is returned from any controller method. + * + * This protocol allows the controller service to disable debuggees, recover + * from data loss, or change the `debuggee_id` format. Agents must handle + * `debuggee_id` value changing upon re-registration. + * + * The async variant is {@see Controller2Client::registerDebuggeeAsync()} . + * + * @param RegisterDebuggeeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RegisterDebuggeeResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function registerDebuggee(RegisterDebuggeeRequest $request, array $callOptions = []): RegisterDebuggeeResponse + { + return $this->startApiCall('RegisterDebuggee', $request, $callOptions)->wait(); + } + + /** + * Updates the breakpoint state or mutable fields. + * The entire Breakpoint message must be sent back to the controller service. + * + * Updates to active breakpoint fields are only allowed if the new value + * does not change the breakpoint specification. Updates to the `location`, + * `condition` and `expressions` fields should not alter the breakpoint + * semantics. These may only make changes such as canonicalizing a value + * or snapping the location to the correct line of code. + * + * The async variant is {@see Controller2Client::updateActiveBreakpointAsync()} . + * + * @param UpdateActiveBreakpointRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 UpdateActiveBreakpointResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateActiveBreakpoint(UpdateActiveBreakpointRequest $request, array $callOptions = []): UpdateActiveBreakpointResponse + { + return $this->startApiCall('UpdateActiveBreakpoint', $request, $callOptions)->wait(); + } } diff --git a/Debugger/src/V2/Client/Debugger2Client.php b/Debugger/src/V2/Client/Debugger2Client.php index 8ca4f808519b..177083c67f00 100644 --- a/Debugger/src/V2/Client/Debugger2Client.php +++ b/Debugger/src/V2/Client/Debugger2Client.php @@ -24,17 +24,279 @@ namespace Google\Cloud\Debugger\V2\Client; -use Google\Cloud\Debugger\V2\Client\BaseClient\Debugger2BaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Debugger\V2\DeleteBreakpointRequest; +use Google\Cloud\Debugger\V2\GetBreakpointRequest; +use Google\Cloud\Debugger\V2\GetBreakpointResponse; +use Google\Cloud\Debugger\V2\ListBreakpointsRequest; +use Google\Cloud\Debugger\V2\ListBreakpointsResponse; +use Google\Cloud\Debugger\V2\ListDebuggeesRequest; +use Google\Cloud\Debugger\V2\ListDebuggeesResponse; +use Google\Cloud\Debugger\V2\SetBreakpointRequest; +use Google\Cloud\Debugger\V2\SetBreakpointResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Debugger service provides the API that allows users to collect run-time + * information from a running application, without stopping or slowing it down + * and without modifying its state. An application may include one or + * more replicated processes performing the same work. * - * This class is currently experimental and may be subject to changes. + * A debugged application is represented using the Debuggee concept. The + * Debugger service provides a way to query for available debuggees, but does + * not provide a way to create one. A debuggee is created using the Controller + * service, usually by running a debugger agent with the application. + * + * The Debugger service enables the client to set one or more Breakpoints on a + * Debuggee and collect the results of the set Breakpoints. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Debugger\V2\Debugger2Client} for the stable implementation * * @experimental + * + * @method PromiseInterface deleteBreakpointAsync(DeleteBreakpointRequest $request, array $optionalArgs = []) + * @method PromiseInterface getBreakpointAsync(GetBreakpointRequest $request, array $optionalArgs = []) + * @method PromiseInterface listBreakpointsAsync(ListBreakpointsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDebuggeesAsync(ListDebuggeesRequest $request, array $optionalArgs = []) + * @method PromiseInterface setBreakpointAsync(SetBreakpointRequest $request, array $optionalArgs = []) */ -final class Debugger2Client extends Debugger2BaseClient +final class Debugger2Client { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see Debugger2BaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.devtools.clouddebugger.v2.Debugger2'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'clouddebugger.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud_debugger', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/debugger2_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/debugger2_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/debugger2_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/debugger2_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'clouddebugger.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the breakpoint from the debuggee. + * + * The async variant is {@see Debugger2Client::deleteBreakpointAsync()} . + * + * @param DeleteBreakpointRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteBreakpoint(DeleteBreakpointRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteBreakpoint', $request, $callOptions)->wait(); + } + + /** + * Gets breakpoint information. + * + * The async variant is {@see Debugger2Client::getBreakpointAsync()} . + * + * @param GetBreakpointRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GetBreakpointResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function getBreakpoint(GetBreakpointRequest $request, array $callOptions = []): GetBreakpointResponse + { + return $this->startApiCall('GetBreakpoint', $request, $callOptions)->wait(); + } + + /** + * Lists all breakpoints for the debuggee. + * + * The async variant is {@see Debugger2Client::listBreakpointsAsync()} . + * + * @param ListBreakpointsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ListBreakpointsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listBreakpoints(ListBreakpointsRequest $request, array $callOptions = []): ListBreakpointsResponse + { + return $this->startApiCall('ListBreakpoints', $request, $callOptions)->wait(); + } + + /** + * Lists all the debuggees that the user has access to. + * + * The async variant is {@see Debugger2Client::listDebuggeesAsync()} . + * + * @param ListDebuggeesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ListDebuggeesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDebuggees(ListDebuggeesRequest $request, array $callOptions = []): ListDebuggeesResponse + { + return $this->startApiCall('ListDebuggees', $request, $callOptions)->wait(); + } + + /** + * Sets the breakpoint to the debuggee. + * + * The async variant is {@see Debugger2Client::setBreakpointAsync()} . + * + * @param SetBreakpointRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SetBreakpointResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setBreakpoint(SetBreakpointRequest $request, array $callOptions = []): SetBreakpointResponse + { + return $this->startApiCall('SetBreakpoint', $request, $callOptions)->wait(); + } } diff --git a/Deploy/composer.json b/Deploy/composer.json index bd1d8d115b9f..cd5d47312a77 100644 --- a/Deploy/composer.json +++ b/Deploy/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Deploy/src/V1/Client/BaseClient/CloudDeployBaseClient.php b/Deploy/src/V1/Client/BaseClient/CloudDeployBaseClient.php deleted file mode 100644 index ed3ef9af5ad7..000000000000 --- a/Deploy/src/V1/Client/BaseClient/CloudDeployBaseClient.php +++ /dev/null @@ -1,1370 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/cloud_deploy_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/cloud_deploy_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/cloud_deploy_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/cloud_deploy_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a build - * resource. - * - * @param string $project - * @param string $location - * @param string $build - * - * @return string The formatted build resource. - */ - public static function buildName(string $project, string $location, string $build): string - { - return self::getPathTemplate('build')->render([ - 'project' => $project, - 'location' => $location, - 'build' => $build, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a cluster - * resource. - * - * @param string $project - * @param string $location - * @param string $cluster - * - * @return string The formatted cluster resource. - */ - public static function clusterName(string $project, string $location, string $cluster): string - { - return self::getPathTemplate('cluster')->render([ - 'project' => $project, - 'location' => $location, - 'cluster' => $cluster, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a config - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted config resource. - */ - public static function configName(string $project, string $location): string - { - return self::getPathTemplate('config')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * delivery_pipeline resource. - * - * @param string $project - * @param string $location - * @param string $deliveryPipeline - * - * @return string The formatted delivery_pipeline resource. - */ - public static function deliveryPipelineName(string $project, string $location, string $deliveryPipeline): string - { - return self::getPathTemplate('deliveryPipeline')->render([ - 'project' => $project, - 'location' => $location, - 'delivery_pipeline' => $deliveryPipeline, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a job_run - * resource. - * - * @param string $project - * @param string $location - * @param string $deliveryPipeline - * @param string $release - * @param string $rollout - * @param string $jobRun - * - * @return string The formatted job_run resource. - */ - public static function jobRunName(string $project, string $location, string $deliveryPipeline, string $release, string $rollout, string $jobRun): string - { - return self::getPathTemplate('jobRun')->render([ - 'project' => $project, - 'location' => $location, - 'delivery_pipeline' => $deliveryPipeline, - 'release' => $release, - 'rollout' => $rollout, - 'job_run' => $jobRun, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a membership - * resource. - * - * @param string $project - * @param string $location - * @param string $membership - * - * @return string The formatted membership resource. - */ - public static function membershipName(string $project, string $location, string $membership): string - { - return self::getPathTemplate('membership')->render([ - 'project' => $project, - 'location' => $location, - 'membership' => $membership, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a release - * resource. - * - * @param string $project - * @param string $location - * @param string $deliveryPipeline - * @param string $release - * - * @return string The formatted release resource. - */ - public static function releaseName(string $project, string $location, string $deliveryPipeline, string $release): string - { - return self::getPathTemplate('release')->render([ - 'project' => $project, - 'location' => $location, - 'delivery_pipeline' => $deliveryPipeline, - 'release' => $release, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a rollout - * resource. - * - * @param string $project - * @param string $location - * @param string $deliveryPipeline - * @param string $release - * @param string $rollout - * - * @return string The formatted rollout resource. - */ - public static function rolloutName(string $project, string $location, string $deliveryPipeline, string $release, string $rollout): string - { - return self::getPathTemplate('rollout')->render([ - 'project' => $project, - 'location' => $location, - 'delivery_pipeline' => $deliveryPipeline, - 'release' => $release, - 'rollout' => $rollout, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a service - * resource. - * - * @param string $project - * @param string $location - * @param string $service - * - * @return string The formatted service resource. - */ - public static function serviceName(string $project, string $location, string $service): string - { - return self::getPathTemplate('service')->render([ - 'project' => $project, - 'location' => $location, - 'service' => $service, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a target - * resource. - * - * @param string $project - * @param string $location - * @param string $target - * - * @return string The formatted target resource. - */ - public static function targetName(string $project, string $location, string $target): string - { - return self::getPathTemplate('target')->render([ - 'project' => $project, - 'location' => $location, - 'target' => $target, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a worker_pool - * resource. - * - * @param string $project - * @param string $location - * @param string $workerPool - * - * @return string The formatted worker_pool resource. - */ - public static function workerPoolName(string $project, string $location, string $workerPool): string - { - return self::getPathTemplate('workerPool')->render([ - 'project' => $project, - 'location' => $location, - 'worker_pool' => $workerPool, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - build: projects/{project}/locations/{location}/builds/{build} - * - cluster: projects/{project}/locations/{location}/clusters/{cluster} - * - config: projects/{project}/locations/{location}/config - * - deliveryPipeline: projects/{project}/locations/{location}/deliveryPipelines/{delivery_pipeline} - * - jobRun: projects/{project}/locations/{location}/deliveryPipelines/{delivery_pipeline}/releases/{release}/rollouts/{rollout}/jobRuns/{job_run} - * - location: projects/{project}/locations/{location} - * - membership: projects/{project}/locations/{location}/memberships/{membership} - * - release: projects/{project}/locations/{location}/deliveryPipelines/{delivery_pipeline}/releases/{release} - * - rollout: projects/{project}/locations/{location}/deliveryPipelines/{delivery_pipeline}/releases/{release}/rollouts/{rollout} - * - service: projects/{project}/locations/{location}/services/{service} - * - target: projects/{project}/locations/{location}/targets/{target} - * - workerPool: projects/{project}/locations/{location}/workerPools/{worker_pool} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'clouddeploy.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Abandons a Release in the Delivery Pipeline. - * - * The async variant is {@see self::abandonReleaseAsync()} . - * - * @example samples/V1/CloudDeployClient/abandon_release.php - * - * @param AbandonReleaseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AbandonReleaseResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function abandonRelease(AbandonReleaseRequest $request, array $callOptions = []): AbandonReleaseResponse - { - return $this->startApiCall('AbandonRelease', $request, $callOptions)->wait(); - } - - /** - * Advances a Rollout in a given project and location. - * - * The async variant is {@see self::advanceRolloutAsync()} . - * - * @example samples/V1/CloudDeployClient/advance_rollout.php - * - * @param AdvanceRolloutRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AdvanceRolloutResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function advanceRollout(AdvanceRolloutRequest $request, array $callOptions = []): AdvanceRolloutResponse - { - return $this->startApiCall('AdvanceRollout', $request, $callOptions)->wait(); - } - - /** - * Approves a Rollout. - * - * The async variant is {@see self::approveRolloutAsync()} . - * - * @example samples/V1/CloudDeployClient/approve_rollout.php - * - * @param ApproveRolloutRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ApproveRolloutResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function approveRollout(ApproveRolloutRequest $request, array $callOptions = []): ApproveRolloutResponse - { - return $this->startApiCall('ApproveRollout', $request, $callOptions)->wait(); - } - - /** - * Cancels a Rollout in a given project and location. - * - * The async variant is {@see self::cancelRolloutAsync()} . - * - * @example samples/V1/CloudDeployClient/cancel_rollout.php - * - * @param CancelRolloutRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CancelRolloutResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function cancelRollout(CancelRolloutRequest $request, array $callOptions = []): CancelRolloutResponse - { - return $this->startApiCall('CancelRollout', $request, $callOptions)->wait(); - } - - /** - * Creates a new DeliveryPipeline in a given project and location. - * - * The async variant is {@see self::createDeliveryPipelineAsync()} . - * - * @example samples/V1/CloudDeployClient/create_delivery_pipeline.php - * - * @param CreateDeliveryPipelineRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDeliveryPipeline(CreateDeliveryPipelineRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateDeliveryPipeline', $request, $callOptions)->wait(); - } - - /** - * Creates a new Release in a given project and location. - * - * The async variant is {@see self::createReleaseAsync()} . - * - * @example samples/V1/CloudDeployClient/create_release.php - * - * @param CreateReleaseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createRelease(CreateReleaseRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateRelease', $request, $callOptions)->wait(); - } - - /** - * Creates a new Rollout in a given project and location. - * - * The async variant is {@see self::createRolloutAsync()} . - * - * @example samples/V1/CloudDeployClient/create_rollout.php - * - * @param CreateRolloutRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createRollout(CreateRolloutRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateRollout', $request, $callOptions)->wait(); - } - - /** - * Creates a new Target in a given project and location. - * - * The async variant is {@see self::createTargetAsync()} . - * - * @example samples/V1/CloudDeployClient/create_target.php - * - * @param CreateTargetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTarget(CreateTargetRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateTarget', $request, $callOptions)->wait(); - } - - /** - * Deletes a single DeliveryPipeline. - * - * The async variant is {@see self::deleteDeliveryPipelineAsync()} . - * - * @example samples/V1/CloudDeployClient/delete_delivery_pipeline.php - * - * @param DeleteDeliveryPipelineRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDeliveryPipeline(DeleteDeliveryPipelineRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteDeliveryPipeline', $request, $callOptions)->wait(); - } - - /** - * Deletes a single Target. - * - * The async variant is {@see self::deleteTargetAsync()} . - * - * @example samples/V1/CloudDeployClient/delete_target.php - * - * @param DeleteTargetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTarget(DeleteTargetRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteTarget', $request, $callOptions)->wait(); - } - - /** - * Gets the configuration for a location. - * - * The async variant is {@see self::getConfigAsync()} . - * - * @example samples/V1/CloudDeployClient/get_config.php - * - * @param GetConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Config - * - * @throws ApiException Thrown if the API call fails. - */ - public function getConfig(GetConfigRequest $request, array $callOptions = []): Config - { - return $this->startApiCall('GetConfig', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single DeliveryPipeline. - * - * The async variant is {@see self::getDeliveryPipelineAsync()} . - * - * @example samples/V1/CloudDeployClient/get_delivery_pipeline.php - * - * @param GetDeliveryPipelineRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DeliveryPipeline - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDeliveryPipeline(GetDeliveryPipelineRequest $request, array $callOptions = []): DeliveryPipeline - { - return $this->startApiCall('GetDeliveryPipeline', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single JobRun. - * - * The async variant is {@see self::getJobRunAsync()} . - * - * @example samples/V1/CloudDeployClient/get_job_run.php - * - * @param GetJobRunRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 JobRun - * - * @throws ApiException Thrown if the API call fails. - */ - public function getJobRun(GetJobRunRequest $request, array $callOptions = []): JobRun - { - return $this->startApiCall('GetJobRun', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single Release. - * - * The async variant is {@see self::getReleaseAsync()} . - * - * @example samples/V1/CloudDeployClient/get_release.php - * - * @param GetReleaseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Release - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRelease(GetReleaseRequest $request, array $callOptions = []): Release - { - return $this->startApiCall('GetRelease', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single Rollout. - * - * The async variant is {@see self::getRolloutAsync()} . - * - * @example samples/V1/CloudDeployClient/get_rollout.php - * - * @param GetRolloutRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Rollout - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRollout(GetRolloutRequest $request, array $callOptions = []): Rollout - { - return $this->startApiCall('GetRollout', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single Target. - * - * The async variant is {@see self::getTargetAsync()} . - * - * @example samples/V1/CloudDeployClient/get_target.php - * - * @param GetTargetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Target - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTarget(GetTargetRequest $request, array $callOptions = []): Target - { - return $this->startApiCall('GetTarget', $request, $callOptions)->wait(); - } - - /** - * Ignores the specified Job in a Rollout. - * - * The async variant is {@see self::ignoreJobAsync()} . - * - * @example samples/V1/CloudDeployClient/ignore_job.php - * - * @param IgnoreJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 IgnoreJobResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function ignoreJob(IgnoreJobRequest $request, array $callOptions = []): IgnoreJobResponse - { - return $this->startApiCall('IgnoreJob', $request, $callOptions)->wait(); - } - - /** - * Lists DeliveryPipelines in a given project and location. - * - * The async variant is {@see self::listDeliveryPipelinesAsync()} . - * - * @example samples/V1/CloudDeployClient/list_delivery_pipelines.php - * - * @param ListDeliveryPipelinesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDeliveryPipelines(ListDeliveryPipelinesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDeliveryPipelines', $request, $callOptions); - } - - /** - * Lists JobRuns in a given project and location. - * - * The async variant is {@see self::listJobRunsAsync()} . - * - * @example samples/V1/CloudDeployClient/list_job_runs.php - * - * @param ListJobRunsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listJobRuns(ListJobRunsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListJobRuns', $request, $callOptions); - } - - /** - * Lists Releases in a given project and location. - * - * The async variant is {@see self::listReleasesAsync()} . - * - * @example samples/V1/CloudDeployClient/list_releases.php - * - * @param ListReleasesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listReleases(ListReleasesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListReleases', $request, $callOptions); - } - - /** - * Lists Rollouts in a given project and location. - * - * The async variant is {@see self::listRolloutsAsync()} . - * - * @example samples/V1/CloudDeployClient/list_rollouts.php - * - * @param ListRolloutsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listRollouts(ListRolloutsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListRollouts', $request, $callOptions); - } - - /** - * Lists Targets in a given project and location. - * - * The async variant is {@see self::listTargetsAsync()} . - * - * @example samples/V1/CloudDeployClient/list_targets.php - * - * @param ListTargetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTargets(ListTargetsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTargets', $request, $callOptions); - } - - /** - * Retries the specified Job in a Rollout. - * - * The async variant is {@see self::retryJobAsync()} . - * - * @example samples/V1/CloudDeployClient/retry_job.php - * - * @param RetryJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RetryJobResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function retryJob(RetryJobRequest $request, array $callOptions = []): RetryJobResponse - { - return $this->startApiCall('RetryJob', $request, $callOptions)->wait(); - } - - /** - * Terminates a Job Run in a given project and location. - * - * The async variant is {@see self::terminateJobRunAsync()} . - * - * @example samples/V1/CloudDeployClient/terminate_job_run.php - * - * @param TerminateJobRunRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TerminateJobRunResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function terminateJobRun(TerminateJobRunRequest $request, array $callOptions = []): TerminateJobRunResponse - { - return $this->startApiCall('TerminateJobRun', $request, $callOptions)->wait(); - } - - /** - * Updates the parameters of a single DeliveryPipeline. - * - * The async variant is {@see self::updateDeliveryPipelineAsync()} . - * - * @example samples/V1/CloudDeployClient/update_delivery_pipeline.php - * - * @param UpdateDeliveryPipelineRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDeliveryPipeline(UpdateDeliveryPipelineRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateDeliveryPipeline', $request, $callOptions)->wait(); - } - - /** - * Updates the parameters of a single Target. - * - * The async variant is {@see self::updateTargetAsync()} . - * - * @example samples/V1/CloudDeployClient/update_target.php - * - * @param UpdateTargetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateTarget(UpdateTargetRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateTarget', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/CloudDeployClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/CloudDeployClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/CloudDeployClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/CloudDeployClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/CloudDeployClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Deploy/src/V1/Client/CloudDeployClient.php b/Deploy/src/V1/Client/CloudDeployClient.php index 56001b0b4c94..ce6e1cee3483 100644 --- a/Deploy/src/V1/Client/CloudDeployClient.php +++ b/Deploy/src/V1/Client/CloudDeployClient.php @@ -24,17 +24,1345 @@ namespace Google\Cloud\Deploy\V1\Client; -use Google\Cloud\Deploy\V1\Client\BaseClient\CloudDeployBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Deploy\V1\AbandonReleaseRequest; +use Google\Cloud\Deploy\V1\AbandonReleaseResponse; +use Google\Cloud\Deploy\V1\AdvanceRolloutRequest; +use Google\Cloud\Deploy\V1\AdvanceRolloutResponse; +use Google\Cloud\Deploy\V1\ApproveRolloutRequest; +use Google\Cloud\Deploy\V1\ApproveRolloutResponse; +use Google\Cloud\Deploy\V1\CancelRolloutRequest; +use Google\Cloud\Deploy\V1\CancelRolloutResponse; +use Google\Cloud\Deploy\V1\Config; +use Google\Cloud\Deploy\V1\CreateDeliveryPipelineRequest; +use Google\Cloud\Deploy\V1\CreateReleaseRequest; +use Google\Cloud\Deploy\V1\CreateRolloutRequest; +use Google\Cloud\Deploy\V1\CreateTargetRequest; +use Google\Cloud\Deploy\V1\DeleteDeliveryPipelineRequest; +use Google\Cloud\Deploy\V1\DeleteTargetRequest; +use Google\Cloud\Deploy\V1\DeliveryPipeline; +use Google\Cloud\Deploy\V1\GetConfigRequest; +use Google\Cloud\Deploy\V1\GetDeliveryPipelineRequest; +use Google\Cloud\Deploy\V1\GetJobRunRequest; +use Google\Cloud\Deploy\V1\GetReleaseRequest; +use Google\Cloud\Deploy\V1\GetRolloutRequest; +use Google\Cloud\Deploy\V1\GetTargetRequest; +use Google\Cloud\Deploy\V1\IgnoreJobRequest; +use Google\Cloud\Deploy\V1\IgnoreJobResponse; +use Google\Cloud\Deploy\V1\JobRun; +use Google\Cloud\Deploy\V1\ListDeliveryPipelinesRequest; +use Google\Cloud\Deploy\V1\ListJobRunsRequest; +use Google\Cloud\Deploy\V1\ListReleasesRequest; +use Google\Cloud\Deploy\V1\ListRolloutsRequest; +use Google\Cloud\Deploy\V1\ListTargetsRequest; +use Google\Cloud\Deploy\V1\Release; +use Google\Cloud\Deploy\V1\RetryJobRequest; +use Google\Cloud\Deploy\V1\RetryJobResponse; +use Google\Cloud\Deploy\V1\Rollout; +use Google\Cloud\Deploy\V1\Target; +use Google\Cloud\Deploy\V1\TerminateJobRunRequest; +use Google\Cloud\Deploy\V1\TerminateJobRunResponse; +use Google\Cloud\Deploy\V1\UpdateDeliveryPipelineRequest; +use Google\Cloud\Deploy\V1\UpdateTargetRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: CloudDeploy service creates and manages Continuous Delivery operations + * on Google Cloud Platform via Skaffold (https://skaffold.dev). * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Deploy\V1\CloudDeployClient} for the stable implementation * * @experimental + * + * @method PromiseInterface abandonReleaseAsync(AbandonReleaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface advanceRolloutAsync(AdvanceRolloutRequest $request, array $optionalArgs = []) + * @method PromiseInterface approveRolloutAsync(ApproveRolloutRequest $request, array $optionalArgs = []) + * @method PromiseInterface cancelRolloutAsync(CancelRolloutRequest $request, array $optionalArgs = []) + * @method PromiseInterface createDeliveryPipelineAsync(CreateDeliveryPipelineRequest $request, array $optionalArgs = []) + * @method PromiseInterface createReleaseAsync(CreateReleaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface createRolloutAsync(CreateRolloutRequest $request, array $optionalArgs = []) + * @method PromiseInterface createTargetAsync(CreateTargetRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDeliveryPipelineAsync(DeleteDeliveryPipelineRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTargetAsync(DeleteTargetRequest $request, array $optionalArgs = []) + * @method PromiseInterface getConfigAsync(GetConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDeliveryPipelineAsync(GetDeliveryPipelineRequest $request, array $optionalArgs = []) + * @method PromiseInterface getJobRunAsync(GetJobRunRequest $request, array $optionalArgs = []) + * @method PromiseInterface getReleaseAsync(GetReleaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRolloutAsync(GetRolloutRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTargetAsync(GetTargetRequest $request, array $optionalArgs = []) + * @method PromiseInterface ignoreJobAsync(IgnoreJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDeliveryPipelinesAsync(ListDeliveryPipelinesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listJobRunsAsync(ListJobRunsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listReleasesAsync(ListReleasesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listRolloutsAsync(ListRolloutsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTargetsAsync(ListTargetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface retryJobAsync(RetryJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface terminateJobRunAsync(TerminateJobRunRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDeliveryPipelineAsync(UpdateDeliveryPipelineRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateTargetAsync(UpdateTargetRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class CloudDeployClient extends CloudDeployBaseClient +final class CloudDeployClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CloudDeployBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.deploy.v1.CloudDeploy'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'clouddeploy.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/cloud_deploy_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/cloud_deploy_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/cloud_deploy_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/cloud_deploy_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a build + * resource. + * + * @param string $project + * @param string $location + * @param string $build + * + * @return string The formatted build resource. + */ + public static function buildName(string $project, string $location, string $build): string + { + return self::getPathTemplate('build')->render([ + 'project' => $project, + 'location' => $location, + 'build' => $build, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a cluster + * resource. + * + * @param string $project + * @param string $location + * @param string $cluster + * + * @return string The formatted cluster resource. + */ + public static function clusterName(string $project, string $location, string $cluster): string + { + return self::getPathTemplate('cluster')->render([ + 'project' => $project, + 'location' => $location, + 'cluster' => $cluster, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a config + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted config resource. + */ + public static function configName(string $project, string $location): string + { + return self::getPathTemplate('config')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * delivery_pipeline resource. + * + * @param string $project + * @param string $location + * @param string $deliveryPipeline + * + * @return string The formatted delivery_pipeline resource. + */ + public static function deliveryPipelineName(string $project, string $location, string $deliveryPipeline): string + { + return self::getPathTemplate('deliveryPipeline')->render([ + 'project' => $project, + 'location' => $location, + 'delivery_pipeline' => $deliveryPipeline, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a job_run + * resource. + * + * @param string $project + * @param string $location + * @param string $deliveryPipeline + * @param string $release + * @param string $rollout + * @param string $jobRun + * + * @return string The formatted job_run resource. + */ + public static function jobRunName(string $project, string $location, string $deliveryPipeline, string $release, string $rollout, string $jobRun): string + { + return self::getPathTemplate('jobRun')->render([ + 'project' => $project, + 'location' => $location, + 'delivery_pipeline' => $deliveryPipeline, + 'release' => $release, + 'rollout' => $rollout, + 'job_run' => $jobRun, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a membership + * resource. + * + * @param string $project + * @param string $location + * @param string $membership + * + * @return string The formatted membership resource. + */ + public static function membershipName(string $project, string $location, string $membership): string + { + return self::getPathTemplate('membership')->render([ + 'project' => $project, + 'location' => $location, + 'membership' => $membership, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a release + * resource. + * + * @param string $project + * @param string $location + * @param string $deliveryPipeline + * @param string $release + * + * @return string The formatted release resource. + */ + public static function releaseName(string $project, string $location, string $deliveryPipeline, string $release): string + { + return self::getPathTemplate('release')->render([ + 'project' => $project, + 'location' => $location, + 'delivery_pipeline' => $deliveryPipeline, + 'release' => $release, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a rollout + * resource. + * + * @param string $project + * @param string $location + * @param string $deliveryPipeline + * @param string $release + * @param string $rollout + * + * @return string The formatted rollout resource. + */ + public static function rolloutName(string $project, string $location, string $deliveryPipeline, string $release, string $rollout): string + { + return self::getPathTemplate('rollout')->render([ + 'project' => $project, + 'location' => $location, + 'delivery_pipeline' => $deliveryPipeline, + 'release' => $release, + 'rollout' => $rollout, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a service + * resource. + * + * @param string $project + * @param string $location + * @param string $service + * + * @return string The formatted service resource. + */ + public static function serviceName(string $project, string $location, string $service): string + { + return self::getPathTemplate('service')->render([ + 'project' => $project, + 'location' => $location, + 'service' => $service, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a target + * resource. + * + * @param string $project + * @param string $location + * @param string $target + * + * @return string The formatted target resource. + */ + public static function targetName(string $project, string $location, string $target): string + { + return self::getPathTemplate('target')->render([ + 'project' => $project, + 'location' => $location, + 'target' => $target, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a worker_pool + * resource. + * + * @param string $project + * @param string $location + * @param string $workerPool + * + * @return string The formatted worker_pool resource. + */ + public static function workerPoolName(string $project, string $location, string $workerPool): string + { + return self::getPathTemplate('workerPool')->render([ + 'project' => $project, + 'location' => $location, + 'worker_pool' => $workerPool, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - build: projects/{project}/locations/{location}/builds/{build} + * - cluster: projects/{project}/locations/{location}/clusters/{cluster} + * - config: projects/{project}/locations/{location}/config + * - deliveryPipeline: projects/{project}/locations/{location}/deliveryPipelines/{delivery_pipeline} + * - jobRun: projects/{project}/locations/{location}/deliveryPipelines/{delivery_pipeline}/releases/{release}/rollouts/{rollout}/jobRuns/{job_run} + * - location: projects/{project}/locations/{location} + * - membership: projects/{project}/locations/{location}/memberships/{membership} + * - release: projects/{project}/locations/{location}/deliveryPipelines/{delivery_pipeline}/releases/{release} + * - rollout: projects/{project}/locations/{location}/deliveryPipelines/{delivery_pipeline}/releases/{release}/rollouts/{rollout} + * - service: projects/{project}/locations/{location}/services/{service} + * - target: projects/{project}/locations/{location}/targets/{target} + * - workerPool: projects/{project}/locations/{location}/workerPools/{worker_pool} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'clouddeploy.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Abandons a Release in the Delivery Pipeline. + * + * The async variant is {@see CloudDeployClient::abandonReleaseAsync()} . + * + * @example samples/V1/CloudDeployClient/abandon_release.php + * + * @param AbandonReleaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AbandonReleaseResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function abandonRelease(AbandonReleaseRequest $request, array $callOptions = []): AbandonReleaseResponse + { + return $this->startApiCall('AbandonRelease', $request, $callOptions)->wait(); + } + + /** + * Advances a Rollout in a given project and location. + * + * The async variant is {@see CloudDeployClient::advanceRolloutAsync()} . + * + * @example samples/V1/CloudDeployClient/advance_rollout.php + * + * @param AdvanceRolloutRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AdvanceRolloutResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function advanceRollout(AdvanceRolloutRequest $request, array $callOptions = []): AdvanceRolloutResponse + { + return $this->startApiCall('AdvanceRollout', $request, $callOptions)->wait(); + } + + /** + * Approves a Rollout. + * + * The async variant is {@see CloudDeployClient::approveRolloutAsync()} . + * + * @example samples/V1/CloudDeployClient/approve_rollout.php + * + * @param ApproveRolloutRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ApproveRolloutResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function approveRollout(ApproveRolloutRequest $request, array $callOptions = []): ApproveRolloutResponse + { + return $this->startApiCall('ApproveRollout', $request, $callOptions)->wait(); + } + + /** + * Cancels a Rollout in a given project and location. + * + * The async variant is {@see CloudDeployClient::cancelRolloutAsync()} . + * + * @example samples/V1/CloudDeployClient/cancel_rollout.php + * + * @param CancelRolloutRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CancelRolloutResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function cancelRollout(CancelRolloutRequest $request, array $callOptions = []): CancelRolloutResponse + { + return $this->startApiCall('CancelRollout', $request, $callOptions)->wait(); + } + + /** + * Creates a new DeliveryPipeline in a given project and location. + * + * The async variant is {@see CloudDeployClient::createDeliveryPipelineAsync()} . + * + * @example samples/V1/CloudDeployClient/create_delivery_pipeline.php + * + * @param CreateDeliveryPipelineRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDeliveryPipeline(CreateDeliveryPipelineRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateDeliveryPipeline', $request, $callOptions)->wait(); + } + + /** + * Creates a new Release in a given project and location. + * + * The async variant is {@see CloudDeployClient::createReleaseAsync()} . + * + * @example samples/V1/CloudDeployClient/create_release.php + * + * @param CreateReleaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createRelease(CreateReleaseRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateRelease', $request, $callOptions)->wait(); + } + + /** + * Creates a new Rollout in a given project and location. + * + * The async variant is {@see CloudDeployClient::createRolloutAsync()} . + * + * @example samples/V1/CloudDeployClient/create_rollout.php + * + * @param CreateRolloutRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createRollout(CreateRolloutRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateRollout', $request, $callOptions)->wait(); + } + + /** + * Creates a new Target in a given project and location. + * + * The async variant is {@see CloudDeployClient::createTargetAsync()} . + * + * @example samples/V1/CloudDeployClient/create_target.php + * + * @param CreateTargetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTarget(CreateTargetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateTarget', $request, $callOptions)->wait(); + } + + /** + * Deletes a single DeliveryPipeline. + * + * The async variant is {@see CloudDeployClient::deleteDeliveryPipelineAsync()} . + * + * @example samples/V1/CloudDeployClient/delete_delivery_pipeline.php + * + * @param DeleteDeliveryPipelineRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDeliveryPipeline(DeleteDeliveryPipelineRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteDeliveryPipeline', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Target. + * + * The async variant is {@see CloudDeployClient::deleteTargetAsync()} . + * + * @example samples/V1/CloudDeployClient/delete_target.php + * + * @param DeleteTargetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTarget(DeleteTargetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteTarget', $request, $callOptions)->wait(); + } + + /** + * Gets the configuration for a location. + * + * The async variant is {@see CloudDeployClient::getConfigAsync()} . + * + * @example samples/V1/CloudDeployClient/get_config.php + * + * @param GetConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Config + * + * @throws ApiException Thrown if the API call fails. + */ + public function getConfig(GetConfigRequest $request, array $callOptions = []): Config + { + return $this->startApiCall('GetConfig', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single DeliveryPipeline. + * + * The async variant is {@see CloudDeployClient::getDeliveryPipelineAsync()} . + * + * @example samples/V1/CloudDeployClient/get_delivery_pipeline.php + * + * @param GetDeliveryPipelineRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DeliveryPipeline + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDeliveryPipeline(GetDeliveryPipelineRequest $request, array $callOptions = []): DeliveryPipeline + { + return $this->startApiCall('GetDeliveryPipeline', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single JobRun. + * + * The async variant is {@see CloudDeployClient::getJobRunAsync()} . + * + * @example samples/V1/CloudDeployClient/get_job_run.php + * + * @param GetJobRunRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 JobRun + * + * @throws ApiException Thrown if the API call fails. + */ + public function getJobRun(GetJobRunRequest $request, array $callOptions = []): JobRun + { + return $this->startApiCall('GetJobRun', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Release. + * + * The async variant is {@see CloudDeployClient::getReleaseAsync()} . + * + * @example samples/V1/CloudDeployClient/get_release.php + * + * @param GetReleaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Release + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRelease(GetReleaseRequest $request, array $callOptions = []): Release + { + return $this->startApiCall('GetRelease', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Rollout. + * + * The async variant is {@see CloudDeployClient::getRolloutAsync()} . + * + * @example samples/V1/CloudDeployClient/get_rollout.php + * + * @param GetRolloutRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Rollout + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRollout(GetRolloutRequest $request, array $callOptions = []): Rollout + { + return $this->startApiCall('GetRollout', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Target. + * + * The async variant is {@see CloudDeployClient::getTargetAsync()} . + * + * @example samples/V1/CloudDeployClient/get_target.php + * + * @param GetTargetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Target + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTarget(GetTargetRequest $request, array $callOptions = []): Target + { + return $this->startApiCall('GetTarget', $request, $callOptions)->wait(); + } + + /** + * Ignores the specified Job in a Rollout. + * + * The async variant is {@see CloudDeployClient::ignoreJobAsync()} . + * + * @example samples/V1/CloudDeployClient/ignore_job.php + * + * @param IgnoreJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 IgnoreJobResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function ignoreJob(IgnoreJobRequest $request, array $callOptions = []): IgnoreJobResponse + { + return $this->startApiCall('IgnoreJob', $request, $callOptions)->wait(); + } + + /** + * Lists DeliveryPipelines in a given project and location. + * + * The async variant is {@see CloudDeployClient::listDeliveryPipelinesAsync()} . + * + * @example samples/V1/CloudDeployClient/list_delivery_pipelines.php + * + * @param ListDeliveryPipelinesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDeliveryPipelines(ListDeliveryPipelinesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDeliveryPipelines', $request, $callOptions); + } + + /** + * Lists JobRuns in a given project and location. + * + * The async variant is {@see CloudDeployClient::listJobRunsAsync()} . + * + * @example samples/V1/CloudDeployClient/list_job_runs.php + * + * @param ListJobRunsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listJobRuns(ListJobRunsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListJobRuns', $request, $callOptions); + } + + /** + * Lists Releases in a given project and location. + * + * The async variant is {@see CloudDeployClient::listReleasesAsync()} . + * + * @example samples/V1/CloudDeployClient/list_releases.php + * + * @param ListReleasesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listReleases(ListReleasesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListReleases', $request, $callOptions); + } + + /** + * Lists Rollouts in a given project and location. + * + * The async variant is {@see CloudDeployClient::listRolloutsAsync()} . + * + * @example samples/V1/CloudDeployClient/list_rollouts.php + * + * @param ListRolloutsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listRollouts(ListRolloutsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListRollouts', $request, $callOptions); + } + + /** + * Lists Targets in a given project and location. + * + * The async variant is {@see CloudDeployClient::listTargetsAsync()} . + * + * @example samples/V1/CloudDeployClient/list_targets.php + * + * @param ListTargetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTargets(ListTargetsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTargets', $request, $callOptions); + } + + /** + * Retries the specified Job in a Rollout. + * + * The async variant is {@see CloudDeployClient::retryJobAsync()} . + * + * @example samples/V1/CloudDeployClient/retry_job.php + * + * @param RetryJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RetryJobResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function retryJob(RetryJobRequest $request, array $callOptions = []): RetryJobResponse + { + return $this->startApiCall('RetryJob', $request, $callOptions)->wait(); + } + + /** + * Terminates a Job Run in a given project and location. + * + * The async variant is {@see CloudDeployClient::terminateJobRunAsync()} . + * + * @example samples/V1/CloudDeployClient/terminate_job_run.php + * + * @param TerminateJobRunRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TerminateJobRunResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function terminateJobRun(TerminateJobRunRequest $request, array $callOptions = []): TerminateJobRunResponse + { + return $this->startApiCall('TerminateJobRun', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single DeliveryPipeline. + * + * The async variant is {@see CloudDeployClient::updateDeliveryPipelineAsync()} . + * + * @example samples/V1/CloudDeployClient/update_delivery_pipeline.php + * + * @param UpdateDeliveryPipelineRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDeliveryPipeline(UpdateDeliveryPipelineRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateDeliveryPipeline', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single Target. + * + * The async variant is {@see CloudDeployClient::updateTargetAsync()} . + * + * @example samples/V1/CloudDeployClient/update_target.php + * + * @param UpdateTargetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTarget(UpdateTargetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateTarget', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see CloudDeployClient::getLocationAsync()} . + * + * @example samples/V1/CloudDeployClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see CloudDeployClient::listLocationsAsync()} . + * + * @example samples/V1/CloudDeployClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see CloudDeployClient::getIamPolicyAsync()} . + * + * @example samples/V1/CloudDeployClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see CloudDeployClient::setIamPolicyAsync()} . + * + * @example samples/V1/CloudDeployClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see CloudDeployClient::testIamPermissionsAsync()} . + * + * @example samples/V1/CloudDeployClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Dialogflow/composer.json b/Dialogflow/composer.json index 1d759bb4319d..afed536b13a6 100644 --- a/Dialogflow/composer.json +++ b/Dialogflow/composer.json @@ -19,11 +19,11 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", - "google/cloud-core": "^1.39" + "google/cloud-core": "^1.52.7" }, "suggest": { "ext-grpc": "Enables use of gRPC, a universal high-performance RPC framework created by Google." diff --git a/Dialogflow/src/V2/Client/AgentsClient.php b/Dialogflow/src/V2/Client/AgentsClient.php index 82966d1dd253..8ac7b18e5da7 100644 --- a/Dialogflow/src/V2/Client/AgentsClient.php +++ b/Dialogflow/src/V2/Client/AgentsClient.php @@ -24,17 +24,658 @@ namespace Google\Cloud\Dialogflow\V2\Client; -use Google\Cloud\Dialogflow\V2\Client\BaseClient\AgentsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dialogflow\V2\Agent; +use Google\Cloud\Dialogflow\V2\DeleteAgentRequest; +use Google\Cloud\Dialogflow\V2\ExportAgentRequest; +use Google\Cloud\Dialogflow\V2\ExportAgentResponse; +use Google\Cloud\Dialogflow\V2\GetAgentRequest; +use Google\Cloud\Dialogflow\V2\GetValidationResultRequest; +use Google\Cloud\Dialogflow\V2\ImportAgentRequest; +use Google\Cloud\Dialogflow\V2\RestoreAgentRequest; +use Google\Cloud\Dialogflow\V2\SearchAgentsRequest; +use Google\Cloud\Dialogflow\V2\SetAgentRequest; +use Google\Cloud\Dialogflow\V2\TrainAgentRequest; +use Google\Cloud\Dialogflow\V2\ValidationResult; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use Google\Protobuf\Struct; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for managing [Agents][google.cloud.dialogflow.v2.Agent]. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dialogflow\V2\AgentsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface deleteAgentAsync(DeleteAgentRequest $request, array $optionalArgs = []) + * @method PromiseInterface exportAgentAsync(ExportAgentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAgentAsync(GetAgentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getValidationResultAsync(GetValidationResultRequest $request, array $optionalArgs = []) + * @method PromiseInterface importAgentAsync(ImportAgentRequest $request, array $optionalArgs = []) + * @method PromiseInterface restoreAgentAsync(RestoreAgentRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchAgentsAsync(SearchAgentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface setAgentAsync(SetAgentRequest $request, array $optionalArgs = []) + * @method PromiseInterface trainAgentAsync(TrainAgentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class AgentsClient extends AgentsBaseClient +final class AgentsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AgentsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dialogflow.v2.Agents'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/dialogflow', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/agents_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/agents_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/agents_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/agents_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a agent + * resource. + * + * @param string $project + * + * @return string The formatted agent resource. + */ + public static function agentName(string $project): string + { + return self::getPathTemplate('agent')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_agent resource. + * + * @param string $project + * + * @return string The formatted project_agent resource. + */ + public static function projectAgentName(string $project): string + { + return self::getPathTemplate('projectAgent')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted project_location_agent resource. + */ + public static function projectLocationAgentName(string $project, string $location): string + { + return self::getPathTemplate('projectLocationAgent')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - agent: projects/{project}/agent + * - location: projects/{project}/locations/{location} + * - project: projects/{project} + * - projectAgent: projects/{project}/agent + * - projectLocationAgent: projects/{project}/locations/{location}/agent + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dialogflow.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the specified agent. + * + * The async variant is {@see AgentsClient::deleteAgentAsync()} . + * + * @param DeleteAgentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAgent(DeleteAgentRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteAgent', $request, $callOptions)->wait(); + } + + /** + * Exports the specified agent to a ZIP file. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: An empty [Struct + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) + * - `response`: + * [ExportAgentResponse][google.cloud.dialogflow.v2.ExportAgentResponse] + * + * The async variant is {@see AgentsClient::exportAgentAsync()} . + * + * @param ExportAgentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportAgent(ExportAgentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ExportAgent', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified agent. + * + * The async variant is {@see AgentsClient::getAgentAsync()} . + * + * @param GetAgentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Agent + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAgent(GetAgentRequest $request, array $callOptions = []): Agent + { + return $this->startApiCall('GetAgent', $request, $callOptions)->wait(); + } + + /** + * Gets agent validation result. Agent validation is performed during + * training time and is updated automatically when training is completed. + * + * The async variant is {@see AgentsClient::getValidationResultAsync()} . + * + * @param GetValidationResultRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ValidationResult + * + * @throws ApiException Thrown if the API call fails. + */ + public function getValidationResult(GetValidationResultRequest $request, array $callOptions = []): ValidationResult + { + return $this->startApiCall('GetValidationResult', $request, $callOptions)->wait(); + } + + /** + * Imports the specified agent from a ZIP file. + * + * Uploads new intents and entity types without deleting the existing ones. + * Intents and entity types with the same name are replaced with the new + * versions from + * [ImportAgentRequest][google.cloud.dialogflow.v2.ImportAgentRequest]. After + * the import, the imported draft agent will be trained automatically (unless + * disabled in agent settings). However, once the import is done, training may + * not be completed yet. Please call + * [TrainAgent][google.cloud.dialogflow.v2.Agents.TrainAgent] and wait for the + * operation it returns in order to train explicitly. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: An empty [Struct + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) + * - `response`: An [Empty + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) + * + * The operation only tracks when importing is complete, not when it is done + * training. + * + * Note: You should always train an agent prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/es/docs/training). + * + * The async variant is {@see AgentsClient::importAgentAsync()} . + * + * @param ImportAgentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importAgent(ImportAgentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportAgent', $request, $callOptions)->wait(); + } + + /** + * Restores the specified agent from a ZIP file. + * + * Replaces the current agent version with a new one. All the intents and + * entity types in the older version are deleted. After the restore, the + * restored draft agent will be trained automatically (unless disabled in + * agent settings). However, once the restore is done, training may not be + * completed yet. Please call + * [TrainAgent][google.cloud.dialogflow.v2.Agents.TrainAgent] and wait for the + * operation it returns in order to train explicitly. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: An empty [Struct + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) + * - `response`: An [Empty + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) + * + * The operation only tracks when restoring is complete, not when it is done + * training. + * + * Note: You should always train an agent prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/es/docs/training). + * + * The async variant is {@see AgentsClient::restoreAgentAsync()} . + * + * @param RestoreAgentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function restoreAgent(RestoreAgentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RestoreAgent', $request, $callOptions)->wait(); + } + + /** + * Returns the list of agents. + * + * Since there is at most one conversational agent per project, this method is + * useful primarily for listing all agents across projects the caller has + * access to. One can achieve that with a wildcard project collection id "-". + * Refer to [List + * Sub-Collections](https://cloud.google.com/apis/design/design_patterns#list_sub-collections). + * + * The async variant is {@see AgentsClient::searchAgentsAsync()} . + * + * @param SearchAgentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchAgents(SearchAgentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchAgents', $request, $callOptions); + } + + /** + * Creates/updates the specified agent. + * + * Note: You should always train an agent prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/es/docs/training). + * + * The async variant is {@see AgentsClient::setAgentAsync()} . + * + * @param SetAgentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Agent + * + * @throws ApiException Thrown if the API call fails. + */ + public function setAgent(SetAgentRequest $request, array $callOptions = []): Agent + { + return $this->startApiCall('SetAgent', $request, $callOptions)->wait(); + } + + /** + * Trains the specified agent. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: An empty [Struct + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) + * - `response`: An [Empty + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) + * + * Note: You should always train an agent prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/es/docs/training). + * + * The async variant is {@see AgentsClient::trainAgentAsync()} . + * + * @param TrainAgentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function trainAgent(TrainAgentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('TrainAgent', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see AgentsClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see AgentsClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Dialogflow/src/V2/Client/AnswerRecordsClient.php b/Dialogflow/src/V2/Client/AnswerRecordsClient.php index 431ec7321ed4..fd5649965090 100644 --- a/Dialogflow/src/V2/Client/AnswerRecordsClient.php +++ b/Dialogflow/src/V2/Client/AnswerRecordsClient.php @@ -24,17 +24,685 @@ namespace Google\Cloud\Dialogflow\V2\Client; -use Google\Cloud\Dialogflow\V2\Client\BaseClient\AnswerRecordsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dialogflow\V2\AnswerRecord; +use Google\Cloud\Dialogflow\V2\ListAnswerRecordsRequest; +use Google\Cloud\Dialogflow\V2\UpdateAnswerRecordRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for managing + * [AnswerRecords][google.cloud.dialogflow.v2.AnswerRecord]. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dialogflow\V2\AnswerRecordsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface listAnswerRecordsAsync(ListAnswerRecordsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAnswerRecordAsync(UpdateAnswerRecordRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class AnswerRecordsClient extends AnswerRecordsBaseClient +final class AnswerRecordsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AnswerRecordsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dialogflow.v2.AnswerRecords'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/dialogflow', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/answer_records_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/answer_records_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/answer_records_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/answer_records_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a agent + * resource. + * + * @param string $project + * + * @return string The formatted agent resource. + */ + public static function agentName(string $project): string + { + return self::getPathTemplate('agent')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * answer_record resource. + * + * @param string $project + * @param string $answerRecord + * + * @return string The formatted answer_record resource. + */ + public static function answerRecordName(string $project, string $answerRecord): string + { + return self::getPathTemplate('answerRecord')->render([ + 'project' => $project, + 'answer_record' => $answerRecord, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a context + * resource. + * + * @param string $project + * @param string $session + * @param string $context + * + * @return string The formatted context resource. + */ + public static function contextName(string $project, string $session, string $context): string + { + return self::getPathTemplate('context')->render([ + 'project' => $project, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a intent + * resource. + * + * @param string $project + * @param string $intent + * + * @return string The formatted intent resource. + */ + public static function intentName(string $project, string $intent): string + { + return self::getPathTemplate('intent')->render([ + 'project' => $project, + 'intent' => $intent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_agent resource. + * + * @param string $project + * + * @return string The formatted project_agent resource. + */ + public static function projectAgentName(string $project): string + { + return self::getPathTemplate('projectAgent')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_answer_record resource. + * + * @param string $project + * @param string $answerRecord + * + * @return string The formatted project_answer_record resource. + */ + public static function projectAnswerRecordName(string $project, string $answerRecord): string + { + return self::getPathTemplate('projectAnswerRecord')->render([ + 'project' => $project, + 'answer_record' => $answerRecord, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_environment_user_session resource. + * + * @param string $project + * @param string $environment + * @param string $user + * @param string $session + * + * @return string The formatted project_environment_user_session resource. + */ + public static function projectEnvironmentUserSessionName(string $project, string $environment, string $user, string $session): string + { + return self::getPathTemplate('projectEnvironmentUserSession')->render([ + 'project' => $project, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_environment_user_session_context resource. + * + * @param string $project + * @param string $environment + * @param string $user + * @param string $session + * @param string $context + * + * @return string The formatted project_environment_user_session_context resource. + */ + public static function projectEnvironmentUserSessionContextName(string $project, string $environment, string $user, string $session, string $context): string + { + return self::getPathTemplate('projectEnvironmentUserSessionContext')->render([ + 'project' => $project, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_intent resource. + * + * @param string $project + * @param string $intent + * + * @return string The formatted project_intent resource. + */ + public static function projectIntentName(string $project, string $intent): string + { + return self::getPathTemplate('projectIntent')->render([ + 'project' => $project, + 'intent' => $intent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted project_location_agent resource. + */ + public static function projectLocationAgentName(string $project, string $location): string + { + return self::getPathTemplate('projectLocationAgent')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_answer_record resource. + * + * @param string $project + * @param string $location + * @param string $answerRecord + * + * @return string The formatted project_location_answer_record resource. + */ + public static function projectLocationAnswerRecordName(string $project, string $location, string $answerRecord): string + { + return self::getPathTemplate('projectLocationAnswerRecord')->render([ + 'project' => $project, + 'location' => $location, + 'answer_record' => $answerRecord, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_environment_user_session resource. + * + * @param string $project + * @param string $location + * @param string $environment + * @param string $user + * @param string $session + * + * @return string The formatted project_location_environment_user_session resource. + */ + public static function projectLocationEnvironmentUserSessionName(string $project, string $location, string $environment, string $user, string $session): string + { + return self::getPathTemplate('projectLocationEnvironmentUserSession')->render([ + 'project' => $project, + 'location' => $location, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_environment_user_session_context resource. + * + * @param string $project + * @param string $location + * @param string $environment + * @param string $user + * @param string $session + * @param string $context + * + * @return string The formatted project_location_environment_user_session_context resource. + */ + public static function projectLocationEnvironmentUserSessionContextName(string $project, string $location, string $environment, string $user, string $session, string $context): string + { + return self::getPathTemplate('projectLocationEnvironmentUserSessionContext')->render([ + 'project' => $project, + 'location' => $location, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_intent resource. + * + * @param string $project + * @param string $location + * @param string $intent + * + * @return string The formatted project_location_intent resource. + */ + public static function projectLocationIntentName(string $project, string $location, string $intent): string + { + return self::getPathTemplate('projectLocationIntent')->render([ + 'project' => $project, + 'location' => $location, + 'intent' => $intent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_session resource. + * + * @param string $project + * @param string $location + * @param string $session + * + * @return string The formatted project_location_session resource. + */ + public static function projectLocationSessionName(string $project, string $location, string $session): string + { + return self::getPathTemplate('projectLocationSession')->render([ + 'project' => $project, + 'location' => $location, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_session_context resource. + * + * @param string $project + * @param string $location + * @param string $session + * @param string $context + * + * @return string The formatted project_location_session_context resource. + */ + public static function projectLocationSessionContextName(string $project, string $location, string $session, string $context): string + { + return self::getPathTemplate('projectLocationSessionContext')->render([ + 'project' => $project, + 'location' => $location, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_session resource. + * + * @param string $project + * @param string $session + * + * @return string The formatted project_session resource. + */ + public static function projectSessionName(string $project, string $session): string + { + return self::getPathTemplate('projectSession')->render([ + 'project' => $project, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_session_context resource. + * + * @param string $project + * @param string $session + * @param string $context + * + * @return string The formatted project_session_context resource. + */ + public static function projectSessionContextName(string $project, string $session, string $context): string + { + return self::getPathTemplate('projectSessionContext')->render([ + 'project' => $project, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a session + * resource. + * + * @param string $project + * @param string $session + * + * @return string The formatted session resource. + */ + public static function sessionName(string $project, string $session): string + { + return self::getPathTemplate('session')->render([ + 'project' => $project, + 'session' => $session, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - agent: projects/{project}/agent + * - answerRecord: projects/{project}/answerRecords/{answer_record} + * - context: projects/{project}/agent/sessions/{session}/contexts/{context} + * - intent: projects/{project}/agent/intents/{intent} + * - location: projects/{project}/locations/{location} + * - project: projects/{project} + * - projectAgent: projects/{project}/agent + * - projectAnswerRecord: projects/{project}/answerRecords/{answer_record} + * - projectEnvironmentUserSession: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session} + * - projectEnvironmentUserSessionContext: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context} + * - projectIntent: projects/{project}/agent/intents/{intent} + * - projectLocationAgent: projects/{project}/locations/{location}/agent + * - projectLocationAnswerRecord: projects/{project}/locations/{location}/answerRecords/{answer_record} + * - projectLocationEnvironmentUserSession: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session} + * - projectLocationEnvironmentUserSessionContext: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context} + * - projectLocationIntent: projects/{project}/locations/{location}/agent/intents/{intent} + * - projectLocationSession: projects/{project}/locations/{location}/agent/sessions/{session} + * - projectLocationSessionContext: projects/{project}/locations/{location}/agent/sessions/{session}/contexts/{context} + * - projectSession: projects/{project}/agent/sessions/{session} + * - projectSessionContext: projects/{project}/agent/sessions/{session}/contexts/{context} + * - session: projects/{project}/agent/sessions/{session} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dialogflow.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Returns the list of all answer records in the specified project in reverse + * chronological order. + * + * The async variant is {@see AnswerRecordsClient::listAnswerRecordsAsync()} . + * + * @param ListAnswerRecordsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAnswerRecords(ListAnswerRecordsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAnswerRecords', $request, $callOptions); + } + + /** + * Updates the specified answer record. + * + * The async variant is {@see AnswerRecordsClient::updateAnswerRecordAsync()} . + * + * @param UpdateAnswerRecordRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AnswerRecord + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAnswerRecord(UpdateAnswerRecordRequest $request, array $callOptions = []): AnswerRecord + { + return $this->startApiCall('UpdateAnswerRecord', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see AnswerRecordsClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see AnswerRecordsClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Dialogflow/src/V2/Client/BaseClient/AgentsBaseClient.php b/Dialogflow/src/V2/Client/BaseClient/AgentsBaseClient.php deleted file mode 100644 index 2e0086d1c7ef..000000000000 --- a/Dialogflow/src/V2/Client/BaseClient/AgentsBaseClient.php +++ /dev/null @@ -1,683 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/agents_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/agents_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/agents_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/agents_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a agent - * resource. - * - * @param string $project - * - * @return string The formatted agent resource. - */ - public static function agentName(string $project): string - { - return self::getPathTemplate('agent')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_agent resource. - * - * @param string $project - * - * @return string The formatted project_agent resource. - */ - public static function projectAgentName(string $project): string - { - return self::getPathTemplate('projectAgent')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted project_location_agent resource. - */ - public static function projectLocationAgentName(string $project, string $location): string - { - return self::getPathTemplate('projectLocationAgent')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - agent: projects/{project}/agent - * - location: projects/{project}/locations/{location} - * - project: projects/{project} - * - projectAgent: projects/{project}/agent - * - projectLocationAgent: projects/{project}/locations/{location}/agent - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dialogflow.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the specified agent. - * - * The async variant is {@see self::deleteAgentAsync()} . - * - * @param DeleteAgentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAgent(DeleteAgentRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteAgent', $request, $callOptions)->wait(); - } - - /** - * Exports the specified agent to a ZIP file. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: An empty [Struct - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - * - `response`: - * [ExportAgentResponse][google.cloud.dialogflow.v2.ExportAgentResponse] - * - * The async variant is {@see self::exportAgentAsync()} . - * - * @param ExportAgentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function exportAgent(ExportAgentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ExportAgent', $request, $callOptions)->wait(); - } - - /** - * Retrieves the specified agent. - * - * The async variant is {@see self::getAgentAsync()} . - * - * @param GetAgentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Agent - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAgent(GetAgentRequest $request, array $callOptions = []): Agent - { - return $this->startApiCall('GetAgent', $request, $callOptions)->wait(); - } - - /** - * Gets agent validation result. Agent validation is performed during - * training time and is updated automatically when training is completed. - * - * The async variant is {@see self::getValidationResultAsync()} . - * - * @param GetValidationResultRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ValidationResult - * - * @throws ApiException Thrown if the API call fails. - */ - public function getValidationResult(GetValidationResultRequest $request, array $callOptions = []): ValidationResult - { - return $this->startApiCall('GetValidationResult', $request, $callOptions)->wait(); - } - - /** - * Imports the specified agent from a ZIP file. - * - * Uploads new intents and entity types without deleting the existing ones. - * Intents and entity types with the same name are replaced with the new - * versions from - * [ImportAgentRequest][google.cloud.dialogflow.v2.ImportAgentRequest]. After - * the import, the imported draft agent will be trained automatically (unless - * disabled in agent settings). However, once the import is done, training may - * not be completed yet. Please call - * [TrainAgent][google.cloud.dialogflow.v2.Agents.TrainAgent] and wait for the - * operation it returns in order to train explicitly. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: An empty [Struct - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - * - `response`: An [Empty - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) - * - * The operation only tracks when importing is complete, not when it is done - * training. - * - * Note: You should always train an agent prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/es/docs/training). - * - * The async variant is {@see self::importAgentAsync()} . - * - * @param ImportAgentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function importAgent(ImportAgentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ImportAgent', $request, $callOptions)->wait(); - } - - /** - * Restores the specified agent from a ZIP file. - * - * Replaces the current agent version with a new one. All the intents and - * entity types in the older version are deleted. After the restore, the - * restored draft agent will be trained automatically (unless disabled in - * agent settings). However, once the restore is done, training may not be - * completed yet. Please call - * [TrainAgent][google.cloud.dialogflow.v2.Agents.TrainAgent] and wait for the - * operation it returns in order to train explicitly. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: An empty [Struct - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - * - `response`: An [Empty - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) - * - * The operation only tracks when restoring is complete, not when it is done - * training. - * - * Note: You should always train an agent prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/es/docs/training). - * - * The async variant is {@see self::restoreAgentAsync()} . - * - * @param RestoreAgentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function restoreAgent(RestoreAgentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RestoreAgent', $request, $callOptions)->wait(); - } - - /** - * Returns the list of agents. - * - * Since there is at most one conversational agent per project, this method is - * useful primarily for listing all agents across projects the caller has - * access to. One can achieve that with a wildcard project collection id "-". - * Refer to [List - * Sub-Collections](https://cloud.google.com/apis/design/design_patterns#list_sub-collections). - * - * The async variant is {@see self::searchAgentsAsync()} . - * - * @param SearchAgentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchAgents(SearchAgentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchAgents', $request, $callOptions); - } - - /** - * Creates/updates the specified agent. - * - * Note: You should always train an agent prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/es/docs/training). - * - * The async variant is {@see self::setAgentAsync()} . - * - * @param SetAgentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Agent - * - * @throws ApiException Thrown if the API call fails. - */ - public function setAgent(SetAgentRequest $request, array $callOptions = []): Agent - { - return $this->startApiCall('SetAgent', $request, $callOptions)->wait(); - } - - /** - * Trains the specified agent. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: An empty [Struct - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - * - `response`: An [Empty - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) - * - * Note: You should always train an agent prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/es/docs/training). - * - * The async variant is {@see self::trainAgentAsync()} . - * - * @param TrainAgentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function trainAgent(TrainAgentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('TrainAgent', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dialogflow/src/V2/Client/BaseClient/AnswerRecordsBaseClient.php b/Dialogflow/src/V2/Client/BaseClient/AnswerRecordsBaseClient.php deleted file mode 100644 index f54b6f6ed2ba..000000000000 --- a/Dialogflow/src/V2/Client/BaseClient/AnswerRecordsBaseClient.php +++ /dev/null @@ -1,710 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/answer_records_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/answer_records_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/answer_records_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/answer_records_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a agent - * resource. - * - * @param string $project - * - * @return string The formatted agent resource. - */ - public static function agentName(string $project): string - { - return self::getPathTemplate('agent')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * answer_record resource. - * - * @param string $project - * @param string $answerRecord - * - * @return string The formatted answer_record resource. - */ - public static function answerRecordName(string $project, string $answerRecord): string - { - return self::getPathTemplate('answerRecord')->render([ - 'project' => $project, - 'answer_record' => $answerRecord, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a context - * resource. - * - * @param string $project - * @param string $session - * @param string $context - * - * @return string The formatted context resource. - */ - public static function contextName(string $project, string $session, string $context): string - { - return self::getPathTemplate('context')->render([ - 'project' => $project, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a intent - * resource. - * - * @param string $project - * @param string $intent - * - * @return string The formatted intent resource. - */ - public static function intentName(string $project, string $intent): string - { - return self::getPathTemplate('intent')->render([ - 'project' => $project, - 'intent' => $intent, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_agent resource. - * - * @param string $project - * - * @return string The formatted project_agent resource. - */ - public static function projectAgentName(string $project): string - { - return self::getPathTemplate('projectAgent')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_answer_record resource. - * - * @param string $project - * @param string $answerRecord - * - * @return string The formatted project_answer_record resource. - */ - public static function projectAnswerRecordName(string $project, string $answerRecord): string - { - return self::getPathTemplate('projectAnswerRecord')->render([ - 'project' => $project, - 'answer_record' => $answerRecord, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_environment_user_session resource. - * - * @param string $project - * @param string $environment - * @param string $user - * @param string $session - * - * @return string The formatted project_environment_user_session resource. - */ - public static function projectEnvironmentUserSessionName(string $project, string $environment, string $user, string $session): string - { - return self::getPathTemplate('projectEnvironmentUserSession')->render([ - 'project' => $project, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_environment_user_session_context resource. - * - * @param string $project - * @param string $environment - * @param string $user - * @param string $session - * @param string $context - * - * @return string The formatted project_environment_user_session_context resource. - */ - public static function projectEnvironmentUserSessionContextName(string $project, string $environment, string $user, string $session, string $context): string - { - return self::getPathTemplate('projectEnvironmentUserSessionContext')->render([ - 'project' => $project, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_intent resource. - * - * @param string $project - * @param string $intent - * - * @return string The formatted project_intent resource. - */ - public static function projectIntentName(string $project, string $intent): string - { - return self::getPathTemplate('projectIntent')->render([ - 'project' => $project, - 'intent' => $intent, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted project_location_agent resource. - */ - public static function projectLocationAgentName(string $project, string $location): string - { - return self::getPathTemplate('projectLocationAgent')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_answer_record resource. - * - * @param string $project - * @param string $location - * @param string $answerRecord - * - * @return string The formatted project_location_answer_record resource. - */ - public static function projectLocationAnswerRecordName(string $project, string $location, string $answerRecord): string - { - return self::getPathTemplate('projectLocationAnswerRecord')->render([ - 'project' => $project, - 'location' => $location, - 'answer_record' => $answerRecord, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_environment_user_session resource. - * - * @param string $project - * @param string $location - * @param string $environment - * @param string $user - * @param string $session - * - * @return string The formatted project_location_environment_user_session resource. - */ - public static function projectLocationEnvironmentUserSessionName(string $project, string $location, string $environment, string $user, string $session): string - { - return self::getPathTemplate('projectLocationEnvironmentUserSession')->render([ - 'project' => $project, - 'location' => $location, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_environment_user_session_context resource. - * - * @param string $project - * @param string $location - * @param string $environment - * @param string $user - * @param string $session - * @param string $context - * - * @return string The formatted project_location_environment_user_session_context resource. - */ - public static function projectLocationEnvironmentUserSessionContextName(string $project, string $location, string $environment, string $user, string $session, string $context): string - { - return self::getPathTemplate('projectLocationEnvironmentUserSessionContext')->render([ - 'project' => $project, - 'location' => $location, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_intent resource. - * - * @param string $project - * @param string $location - * @param string $intent - * - * @return string The formatted project_location_intent resource. - */ - public static function projectLocationIntentName(string $project, string $location, string $intent): string - { - return self::getPathTemplate('projectLocationIntent')->render([ - 'project' => $project, - 'location' => $location, - 'intent' => $intent, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_session resource. - * - * @param string $project - * @param string $location - * @param string $session - * - * @return string The formatted project_location_session resource. - */ - public static function projectLocationSessionName(string $project, string $location, string $session): string - { - return self::getPathTemplate('projectLocationSession')->render([ - 'project' => $project, - 'location' => $location, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_session_context resource. - * - * @param string $project - * @param string $location - * @param string $session - * @param string $context - * - * @return string The formatted project_location_session_context resource. - */ - public static function projectLocationSessionContextName(string $project, string $location, string $session, string $context): string - { - return self::getPathTemplate('projectLocationSessionContext')->render([ - 'project' => $project, - 'location' => $location, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_session resource. - * - * @param string $project - * @param string $session - * - * @return string The formatted project_session resource. - */ - public static function projectSessionName(string $project, string $session): string - { - return self::getPathTemplate('projectSession')->render([ - 'project' => $project, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_session_context resource. - * - * @param string $project - * @param string $session - * @param string $context - * - * @return string The formatted project_session_context resource. - */ - public static function projectSessionContextName(string $project, string $session, string $context): string - { - return self::getPathTemplate('projectSessionContext')->render([ - 'project' => $project, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a session - * resource. - * - * @param string $project - * @param string $session - * - * @return string The formatted session resource. - */ - public static function sessionName(string $project, string $session): string - { - return self::getPathTemplate('session')->render([ - 'project' => $project, - 'session' => $session, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - agent: projects/{project}/agent - * - answerRecord: projects/{project}/answerRecords/{answer_record} - * - context: projects/{project}/agent/sessions/{session}/contexts/{context} - * - intent: projects/{project}/agent/intents/{intent} - * - location: projects/{project}/locations/{location} - * - project: projects/{project} - * - projectAgent: projects/{project}/agent - * - projectAnswerRecord: projects/{project}/answerRecords/{answer_record} - * - projectEnvironmentUserSession: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session} - * - projectEnvironmentUserSessionContext: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context} - * - projectIntent: projects/{project}/agent/intents/{intent} - * - projectLocationAgent: projects/{project}/locations/{location}/agent - * - projectLocationAnswerRecord: projects/{project}/locations/{location}/answerRecords/{answer_record} - * - projectLocationEnvironmentUserSession: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session} - * - projectLocationEnvironmentUserSessionContext: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context} - * - projectLocationIntent: projects/{project}/locations/{location}/agent/intents/{intent} - * - projectLocationSession: projects/{project}/locations/{location}/agent/sessions/{session} - * - projectLocationSessionContext: projects/{project}/locations/{location}/agent/sessions/{session}/contexts/{context} - * - projectSession: projects/{project}/agent/sessions/{session} - * - projectSessionContext: projects/{project}/agent/sessions/{session}/contexts/{context} - * - session: projects/{project}/agent/sessions/{session} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dialogflow.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Returns the list of all answer records in the specified project in reverse - * chronological order. - * - * The async variant is {@see self::listAnswerRecordsAsync()} . - * - * @param ListAnswerRecordsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAnswerRecords(ListAnswerRecordsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAnswerRecords', $request, $callOptions); - } - - /** - * Updates the specified answer record. - * - * The async variant is {@see self::updateAnswerRecordAsync()} . - * - * @param UpdateAnswerRecordRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AnswerRecord - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAnswerRecord(UpdateAnswerRecordRequest $request, array $callOptions = []): AnswerRecord - { - return $this->startApiCall('UpdateAnswerRecord', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dialogflow/src/V2/Client/BaseClient/ContextsBaseClient.php b/Dialogflow/src/V2/Client/BaseClient/ContextsBaseClient.php deleted file mode 100644 index 5e0517939266..000000000000 --- a/Dialogflow/src/V2/Client/BaseClient/ContextsBaseClient.php +++ /dev/null @@ -1,614 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/contexts_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/contexts_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/contexts_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/contexts_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a context - * resource. - * - * @param string $project - * @param string $session - * @param string $context - * - * @return string The formatted context resource. - */ - public static function contextName(string $project, string $session, string $context): string - { - return self::getPathTemplate('context')->render([ - 'project' => $project, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_environment_user_session resource. - * - * @param string $project - * @param string $environment - * @param string $user - * @param string $session - * - * @return string The formatted project_environment_user_session resource. - */ - public static function projectEnvironmentUserSessionName(string $project, string $environment, string $user, string $session): string - { - return self::getPathTemplate('projectEnvironmentUserSession')->render([ - 'project' => $project, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_environment_user_session_context resource. - * - * @param string $project - * @param string $environment - * @param string $user - * @param string $session - * @param string $context - * - * @return string The formatted project_environment_user_session_context resource. - */ - public static function projectEnvironmentUserSessionContextName(string $project, string $environment, string $user, string $session, string $context): string - { - return self::getPathTemplate('projectEnvironmentUserSessionContext')->render([ - 'project' => $project, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_environment_user_session resource. - * - * @param string $project - * @param string $location - * @param string $environment - * @param string $user - * @param string $session - * - * @return string The formatted project_location_environment_user_session resource. - */ - public static function projectLocationEnvironmentUserSessionName(string $project, string $location, string $environment, string $user, string $session): string - { - return self::getPathTemplate('projectLocationEnvironmentUserSession')->render([ - 'project' => $project, - 'location' => $location, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_environment_user_session_context resource. - * - * @param string $project - * @param string $location - * @param string $environment - * @param string $user - * @param string $session - * @param string $context - * - * @return string The formatted project_location_environment_user_session_context resource. - */ - public static function projectLocationEnvironmentUserSessionContextName(string $project, string $location, string $environment, string $user, string $session, string $context): string - { - return self::getPathTemplate('projectLocationEnvironmentUserSessionContext')->render([ - 'project' => $project, - 'location' => $location, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_session resource. - * - * @param string $project - * @param string $location - * @param string $session - * - * @return string The formatted project_location_session resource. - */ - public static function projectLocationSessionName(string $project, string $location, string $session): string - { - return self::getPathTemplate('projectLocationSession')->render([ - 'project' => $project, - 'location' => $location, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_session_context resource. - * - * @param string $project - * @param string $location - * @param string $session - * @param string $context - * - * @return string The formatted project_location_session_context resource. - */ - public static function projectLocationSessionContextName(string $project, string $location, string $session, string $context): string - { - return self::getPathTemplate('projectLocationSessionContext')->render([ - 'project' => $project, - 'location' => $location, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_session resource. - * - * @param string $project - * @param string $session - * - * @return string The formatted project_session resource. - */ - public static function projectSessionName(string $project, string $session): string - { - return self::getPathTemplate('projectSession')->render([ - 'project' => $project, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_session_context resource. - * - * @param string $project - * @param string $session - * @param string $context - * - * @return string The formatted project_session_context resource. - */ - public static function projectSessionContextName(string $project, string $session, string $context): string - { - return self::getPathTemplate('projectSessionContext')->render([ - 'project' => $project, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a session - * resource. - * - * @param string $project - * @param string $session - * - * @return string The formatted session resource. - */ - public static function sessionName(string $project, string $session): string - { - return self::getPathTemplate('session')->render([ - 'project' => $project, - 'session' => $session, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - context: projects/{project}/agent/sessions/{session}/contexts/{context} - * - projectEnvironmentUserSession: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session} - * - projectEnvironmentUserSessionContext: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context} - * - projectLocationEnvironmentUserSession: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session} - * - projectLocationEnvironmentUserSessionContext: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context} - * - projectLocationSession: projects/{project}/locations/{location}/agent/sessions/{session} - * - projectLocationSessionContext: projects/{project}/locations/{location}/agent/sessions/{session}/contexts/{context} - * - projectSession: projects/{project}/agent/sessions/{session} - * - projectSessionContext: projects/{project}/agent/sessions/{session}/contexts/{context} - * - session: projects/{project}/agent/sessions/{session} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dialogflow.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a context. - * - * If the specified context already exists, overrides the context. - * - * The async variant is {@see self::createContextAsync()} . - * - * @param CreateContextRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Context - * - * @throws ApiException Thrown if the API call fails. - */ - public function createContext(CreateContextRequest $request, array $callOptions = []): Context - { - return $this->startApiCall('CreateContext', $request, $callOptions)->wait(); - } - - /** - * Deletes all active contexts in the specified session. - * - * The async variant is {@see self::deleteAllContextsAsync()} . - * - * @param DeleteAllContextsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAllContexts(DeleteAllContextsRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteAllContexts', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified context. - * - * The async variant is {@see self::deleteContextAsync()} . - * - * @param DeleteContextRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteContext(DeleteContextRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteContext', $request, $callOptions)->wait(); - } - - /** - * Retrieves the specified context. - * - * The async variant is {@see self::getContextAsync()} . - * - * @param GetContextRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Context - * - * @throws ApiException Thrown if the API call fails. - */ - public function getContext(GetContextRequest $request, array $callOptions = []): Context - { - return $this->startApiCall('GetContext', $request, $callOptions)->wait(); - } - - /** - * Returns the list of all contexts in the specified session. - * - * The async variant is {@see self::listContextsAsync()} . - * - * @param ListContextsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listContexts(ListContextsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListContexts', $request, $callOptions); - } - - /** - * Updates the specified context. - * - * The async variant is {@see self::updateContextAsync()} . - * - * @param UpdateContextRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Context - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateContext(UpdateContextRequest $request, array $callOptions = []): Context - { - return $this->startApiCall('UpdateContext', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dialogflow/src/V2/Client/BaseClient/ConversationDatasetsBaseClient.php b/Dialogflow/src/V2/Client/BaseClient/ConversationDatasetsBaseClient.php deleted file mode 100644 index 000c7bae45c6..000000000000 --- a/Dialogflow/src/V2/Client/BaseClient/ConversationDatasetsBaseClient.php +++ /dev/null @@ -1,487 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/conversation_datasets_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/conversation_datasets_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/conversation_datasets_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/conversation_datasets_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * conversation_dataset resource. - * - * @param string $project - * @param string $location - * @param string $conversationDataset - * - * @return string The formatted conversation_dataset resource. - */ - public static function conversationDatasetName(string $project, string $location, string $conversationDataset): string - { - return self::getPathTemplate('conversationDataset')->render([ - 'project' => $project, - 'location' => $location, - 'conversation_dataset' => $conversationDataset, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - conversationDataset: projects/{project}/locations/{location}/conversationDatasets/{conversation_dataset} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dialogflow.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new conversation dataset. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [CreateConversationDatasetOperationMetadata][google.cloud.dialogflow.v2.CreateConversationDatasetOperationMetadata] - * - `response`: - * [ConversationDataset][google.cloud.dialogflow.v2.ConversationDataset] - * - * The async variant is {@see self::createConversationDatasetAsync()} . - * - * @param CreateConversationDatasetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createConversationDataset(CreateConversationDatasetRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateConversationDataset', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified conversation dataset. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [DeleteConversationDatasetOperationMetadata][google.cloud.dialogflow.v2.DeleteConversationDatasetOperationMetadata] - * - `response`: An [Empty - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) - * - * The async variant is {@see self::deleteConversationDatasetAsync()} . - * - * @param DeleteConversationDatasetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteConversationDataset(DeleteConversationDatasetRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteConversationDataset', $request, $callOptions)->wait(); - } - - /** - * Retrieves the specified conversation dataset. - * - * The async variant is {@see self::getConversationDatasetAsync()} . - * - * @param GetConversationDatasetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ConversationDataset - * - * @throws ApiException Thrown if the API call fails. - */ - public function getConversationDataset(GetConversationDatasetRequest $request, array $callOptions = []): ConversationDataset - { - return $this->startApiCall('GetConversationDataset', $request, $callOptions)->wait(); - } - - /** - * Import data into the specified conversation dataset. Note that it - * is not allowed to import data to a conversation dataset that - * already has data in it. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [ImportConversationDataOperationMetadata][google.cloud.dialogflow.v2.ImportConversationDataOperationMetadata] - * - `response`: - * [ImportConversationDataOperationResponse][google.cloud.dialogflow.v2.ImportConversationDataOperationResponse] - * - * The async variant is {@see self::importConversationDataAsync()} . - * - * @param ImportConversationDataRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function importConversationData(ImportConversationDataRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ImportConversationData', $request, $callOptions)->wait(); - } - - /** - * Returns the list of all conversation datasets in the specified - * project and location. - * - * The async variant is {@see self::listConversationDatasetsAsync()} . - * - * @param ListConversationDatasetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listConversationDatasets(ListConversationDatasetsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListConversationDatasets', $request, $callOptions); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dialogflow/src/V2/Client/BaseClient/ConversationModelsBaseClient.php b/Dialogflow/src/V2/Client/BaseClient/ConversationModelsBaseClient.php deleted file mode 100644 index 9b5bcc80f5a9..000000000000 --- a/Dialogflow/src/V2/Client/BaseClient/ConversationModelsBaseClient.php +++ /dev/null @@ -1,765 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/conversation_models_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/conversation_models_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/conversation_models_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/conversation_models_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * conversation_dataset resource. - * - * @param string $project - * @param string $location - * @param string $conversationDataset - * - * @return string The formatted conversation_dataset resource. - */ - public static function conversationDatasetName(string $project, string $location, string $conversationDataset): string - { - return self::getPathTemplate('conversationDataset')->render([ - 'project' => $project, - 'location' => $location, - 'conversation_dataset' => $conversationDataset, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * conversation_model resource. - * - * @param string $project - * @param string $location - * @param string $conversationModel - * - * @return string The formatted conversation_model resource. - */ - public static function conversationModelName(string $project, string $location, string $conversationModel): string - { - return self::getPathTemplate('conversationModel')->render([ - 'project' => $project, - 'location' => $location, - 'conversation_model' => $conversationModel, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * conversation_model_evaluation resource. - * - * @param string $project - * @param string $conversationModel - * @param string $evaluation - * - * @return string The formatted conversation_model_evaluation resource. - */ - public static function conversationModelEvaluationName(string $project, string $conversationModel, string $evaluation): string - { - return self::getPathTemplate('conversationModelEvaluation')->render([ - 'project' => $project, - 'conversation_model' => $conversationModel, - 'evaluation' => $evaluation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a document - * resource. - * - * @param string $project - * @param string $knowledgeBase - * @param string $document - * - * @return string The formatted document resource. - */ - public static function documentName(string $project, string $knowledgeBase, string $document): string - { - return self::getPathTemplate('document')->render([ - 'project' => $project, - 'knowledge_base' => $knowledgeBase, - 'document' => $document, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_conversation_model resource. - * - * @param string $project - * @param string $conversationModel - * - * @return string The formatted project_conversation_model resource. - */ - public static function projectConversationModelName(string $project, string $conversationModel): string - { - return self::getPathTemplate('projectConversationModel')->render([ - 'project' => $project, - 'conversation_model' => $conversationModel, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_conversation_model_evaluation resource. - * - * @param string $project - * @param string $conversationModel - * @param string $evaluation - * - * @return string The formatted project_conversation_model_evaluation resource. - */ - public static function projectConversationModelEvaluationName(string $project, string $conversationModel, string $evaluation): string - { - return self::getPathTemplate('projectConversationModelEvaluation')->render([ - 'project' => $project, - 'conversation_model' => $conversationModel, - 'evaluation' => $evaluation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_knowledge_base_document resource. - * - * @param string $project - * @param string $knowledgeBase - * @param string $document - * - * @return string The formatted project_knowledge_base_document resource. - */ - public static function projectKnowledgeBaseDocumentName(string $project, string $knowledgeBase, string $document): string - { - return self::getPathTemplate('projectKnowledgeBaseDocument')->render([ - 'project' => $project, - 'knowledge_base' => $knowledgeBase, - 'document' => $document, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_conversation_model resource. - * - * @param string $project - * @param string $location - * @param string $conversationModel - * - * @return string The formatted project_location_conversation_model resource. - */ - public static function projectLocationConversationModelName(string $project, string $location, string $conversationModel): string - { - return self::getPathTemplate('projectLocationConversationModel')->render([ - 'project' => $project, - 'location' => $location, - 'conversation_model' => $conversationModel, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_conversation_model_evaluation resource. - * - * @param string $project - * @param string $location - * @param string $conversationModel - * @param string $evaluation - * - * @return string The formatted project_location_conversation_model_evaluation resource. - */ - public static function projectLocationConversationModelEvaluationName(string $project, string $location, string $conversationModel, string $evaluation): string - { - return self::getPathTemplate('projectLocationConversationModelEvaluation')->render([ - 'project' => $project, - 'location' => $location, - 'conversation_model' => $conversationModel, - 'evaluation' => $evaluation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_knowledge_base_document resource. - * - * @param string $project - * @param string $location - * @param string $knowledgeBase - * @param string $document - * - * @return string The formatted project_location_knowledge_base_document resource. - */ - public static function projectLocationKnowledgeBaseDocumentName(string $project, string $location, string $knowledgeBase, string $document): string - { - return self::getPathTemplate('projectLocationKnowledgeBaseDocument')->render([ - 'project' => $project, - 'location' => $location, - 'knowledge_base' => $knowledgeBase, - 'document' => $document, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - conversationDataset: projects/{project}/locations/{location}/conversationDatasets/{conversation_dataset} - * - conversationModel: projects/{project}/locations/{location}/conversationModels/{conversation_model} - * - conversationModelEvaluation: projects/{project}/conversationModels/{conversation_model}/evaluations/{evaluation} - * - document: projects/{project}/knowledgeBases/{knowledge_base}/documents/{document} - * - projectConversationModel: projects/{project}/conversationModels/{conversation_model} - * - projectConversationModelEvaluation: projects/{project}/conversationModels/{conversation_model}/evaluations/{evaluation} - * - projectKnowledgeBaseDocument: projects/{project}/knowledgeBases/{knowledge_base}/documents/{document} - * - projectLocationConversationModel: projects/{project}/locations/{location}/conversationModels/{conversation_model} - * - projectLocationConversationModelEvaluation: projects/{project}/locations/{location}/conversationModels/{conversation_model}/evaluations/{evaluation} - * - projectLocationKnowledgeBaseDocument: projects/{project}/locations/{location}/knowledgeBases/{knowledge_base}/documents/{document} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dialogflow.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a model. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [CreateConversationModelOperationMetadata][google.cloud.dialogflow.v2.CreateConversationModelOperationMetadata] - * - `response`: - * [ConversationModel][google.cloud.dialogflow.v2.ConversationModel] - * - * The async variant is {@see self::createConversationModelAsync()} . - * - * @param CreateConversationModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createConversationModel(CreateConversationModelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateConversationModel', $request, $callOptions)->wait(); - } - - /** - * Creates evaluation of a conversation model. - * - * The async variant is {@see self::createConversationModelEvaluationAsync()} . - * - * @param CreateConversationModelEvaluationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createConversationModelEvaluation(CreateConversationModelEvaluationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateConversationModelEvaluation', $request, $callOptions)->wait(); - } - - /** - * Deletes a model. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [DeleteConversationModelOperationMetadata][google.cloud.dialogflow.v2.DeleteConversationModelOperationMetadata] - * - `response`: An [Empty - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) - * - * The async variant is {@see self::deleteConversationModelAsync()} . - * - * @param DeleteConversationModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteConversationModel(DeleteConversationModelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteConversationModel', $request, $callOptions)->wait(); - } - - /** - * Deploys a model. If a model is already deployed, deploying it - * has no effect. A model can only serve prediction requests after it gets - * deployed. For article suggestion, custom model will not be used unless - * it is deployed. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [DeployConversationModelOperationMetadata][google.cloud.dialogflow.v2.DeployConversationModelOperationMetadata] - * - `response`: An [Empty - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) - * - * The async variant is {@see self::deployConversationModelAsync()} . - * - * @param DeployConversationModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deployConversationModel(DeployConversationModelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeployConversationModel', $request, $callOptions)->wait(); - } - - /** - * Gets conversation model. - * - * The async variant is {@see self::getConversationModelAsync()} . - * - * @param GetConversationModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ConversationModel - * - * @throws ApiException Thrown if the API call fails. - */ - public function getConversationModel(GetConversationModelRequest $request, array $callOptions = []): ConversationModel - { - return $this->startApiCall('GetConversationModel', $request, $callOptions)->wait(); - } - - /** - * Gets an evaluation of conversation model. - * - * The async variant is {@see self::getConversationModelEvaluationAsync()} . - * - * @param GetConversationModelEvaluationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ConversationModelEvaluation - * - * @throws ApiException Thrown if the API call fails. - */ - public function getConversationModelEvaluation(GetConversationModelEvaluationRequest $request, array $callOptions = []): ConversationModelEvaluation - { - return $this->startApiCall('GetConversationModelEvaluation', $request, $callOptions)->wait(); - } - - /** - * Lists evaluations of a conversation model. - * - * The async variant is {@see self::listConversationModelEvaluationsAsync()} . - * - * @param ListConversationModelEvaluationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listConversationModelEvaluations(ListConversationModelEvaluationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListConversationModelEvaluations', $request, $callOptions); - } - - /** - * Lists conversation models. - * - * The async variant is {@see self::listConversationModelsAsync()} . - * - * @param ListConversationModelsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listConversationModels(ListConversationModelsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListConversationModels', $request, $callOptions); - } - - /** - * Undeploys a model. If the model is not deployed this method has no effect. - * If the model is currently being used: - * - For article suggestion, article suggestion will fallback to the default - * model if model is undeployed. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [UndeployConversationModelOperationMetadata][google.cloud.dialogflow.v2.UndeployConversationModelOperationMetadata] - * - `response`: An [Empty - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) - * - * The async variant is {@see self::undeployConversationModelAsync()} . - * - * @param UndeployConversationModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function undeployConversationModel(UndeployConversationModelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UndeployConversationModel', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dialogflow/src/V2/Client/BaseClient/ConversationProfilesBaseClient.php b/Dialogflow/src/V2/Client/BaseClient/ConversationProfilesBaseClient.php deleted file mode 100644 index f6bfdf228752..000000000000 --- a/Dialogflow/src/V2/Client/BaseClient/ConversationProfilesBaseClient.php +++ /dev/null @@ -1,838 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/conversation_profiles_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/conversation_profiles_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/conversation_profiles_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/conversation_profiles_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a agent - * resource. - * - * @param string $project - * - * @return string The formatted agent resource. - */ - public static function agentName(string $project): string - { - return self::getPathTemplate('agent')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * cx_security_settings resource. - * - * @param string $project - * @param string $location - * @param string $securitySettings - * - * @return string The formatted cx_security_settings resource. - */ - public static function cXSecuritySettingsName(string $project, string $location, string $securitySettings): string - { - return self::getPathTemplate('cXSecuritySettings')->render([ - 'project' => $project, - 'location' => $location, - 'security_settings' => $securitySettings, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * conversation_model resource. - * - * @param string $project - * @param string $location - * @param string $conversationModel - * - * @return string The formatted conversation_model resource. - */ - public static function conversationModelName(string $project, string $location, string $conversationModel): string - { - return self::getPathTemplate('conversationModel')->render([ - 'project' => $project, - 'location' => $location, - 'conversation_model' => $conversationModel, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * conversation_profile resource. - * - * @param string $project - * @param string $conversationProfile - * - * @return string The formatted conversation_profile resource. - */ - public static function conversationProfileName(string $project, string $conversationProfile): string - { - return self::getPathTemplate('conversationProfile')->render([ - 'project' => $project, - 'conversation_profile' => $conversationProfile, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a document - * resource. - * - * @param string $project - * @param string $knowledgeBase - * @param string $document - * - * @return string The formatted document resource. - */ - public static function documentName(string $project, string $knowledgeBase, string $document): string - { - return self::getPathTemplate('document')->render([ - 'project' => $project, - 'knowledge_base' => $knowledgeBase, - 'document' => $document, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * knowledge_base resource. - * - * @param string $project - * @param string $knowledgeBase - * - * @return string The formatted knowledge_base resource. - */ - public static function knowledgeBaseName(string $project, string $knowledgeBase): string - { - return self::getPathTemplate('knowledgeBase')->render([ - 'project' => $project, - 'knowledge_base' => $knowledgeBase, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_agent resource. - * - * @param string $project - * - * @return string The formatted project_agent resource. - */ - public static function projectAgentName(string $project): string - { - return self::getPathTemplate('projectAgent')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_conversation_model resource. - * - * @param string $project - * @param string $conversationModel - * - * @return string The formatted project_conversation_model resource. - */ - public static function projectConversationModelName(string $project, string $conversationModel): string - { - return self::getPathTemplate('projectConversationModel')->render([ - 'project' => $project, - 'conversation_model' => $conversationModel, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_conversation_profile resource. - * - * @param string $project - * @param string $conversationProfile - * - * @return string The formatted project_conversation_profile resource. - */ - public static function projectConversationProfileName(string $project, string $conversationProfile): string - { - return self::getPathTemplate('projectConversationProfile')->render([ - 'project' => $project, - 'conversation_profile' => $conversationProfile, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_knowledge_base resource. - * - * @param string $project - * @param string $knowledgeBase - * - * @return string The formatted project_knowledge_base resource. - */ - public static function projectKnowledgeBaseName(string $project, string $knowledgeBase): string - { - return self::getPathTemplate('projectKnowledgeBase')->render([ - 'project' => $project, - 'knowledge_base' => $knowledgeBase, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_knowledge_base_document resource. - * - * @param string $project - * @param string $knowledgeBase - * @param string $document - * - * @return string The formatted project_knowledge_base_document resource. - */ - public static function projectKnowledgeBaseDocumentName(string $project, string $knowledgeBase, string $document): string - { - return self::getPathTemplate('projectKnowledgeBaseDocument')->render([ - 'project' => $project, - 'knowledge_base' => $knowledgeBase, - 'document' => $document, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted project_location_agent resource. - */ - public static function projectLocationAgentName(string $project, string $location): string - { - return self::getPathTemplate('projectLocationAgent')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_conversation_model resource. - * - * @param string $project - * @param string $location - * @param string $conversationModel - * - * @return string The formatted project_location_conversation_model resource. - */ - public static function projectLocationConversationModelName(string $project, string $location, string $conversationModel): string - { - return self::getPathTemplate('projectLocationConversationModel')->render([ - 'project' => $project, - 'location' => $location, - 'conversation_model' => $conversationModel, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_conversation_profile resource. - * - * @param string $project - * @param string $location - * @param string $conversationProfile - * - * @return string The formatted project_location_conversation_profile resource. - */ - public static function projectLocationConversationProfileName(string $project, string $location, string $conversationProfile): string - { - return self::getPathTemplate('projectLocationConversationProfile')->render([ - 'project' => $project, - 'location' => $location, - 'conversation_profile' => $conversationProfile, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_knowledge_base resource. - * - * @param string $project - * @param string $location - * @param string $knowledgeBase - * - * @return string The formatted project_location_knowledge_base resource. - */ - public static function projectLocationKnowledgeBaseName(string $project, string $location, string $knowledgeBase): string - { - return self::getPathTemplate('projectLocationKnowledgeBase')->render([ - 'project' => $project, - 'location' => $location, - 'knowledge_base' => $knowledgeBase, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_knowledge_base_document resource. - * - * @param string $project - * @param string $location - * @param string $knowledgeBase - * @param string $document - * - * @return string The formatted project_location_knowledge_base_document resource. - */ - public static function projectLocationKnowledgeBaseDocumentName(string $project, string $location, string $knowledgeBase, string $document): string - { - return self::getPathTemplate('projectLocationKnowledgeBaseDocument')->render([ - 'project' => $project, - 'location' => $location, - 'knowledge_base' => $knowledgeBase, - 'document' => $document, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - agent: projects/{project}/agent - * - cXSecuritySettings: projects/{project}/locations/{location}/securitySettings/{security_settings} - * - conversationModel: projects/{project}/locations/{location}/conversationModels/{conversation_model} - * - conversationProfile: projects/{project}/conversationProfiles/{conversation_profile} - * - document: projects/{project}/knowledgeBases/{knowledge_base}/documents/{document} - * - knowledgeBase: projects/{project}/knowledgeBases/{knowledge_base} - * - location: projects/{project}/locations/{location} - * - project: projects/{project} - * - projectAgent: projects/{project}/agent - * - projectConversationModel: projects/{project}/conversationModels/{conversation_model} - * - projectConversationProfile: projects/{project}/conversationProfiles/{conversation_profile} - * - projectKnowledgeBase: projects/{project}/knowledgeBases/{knowledge_base} - * - projectKnowledgeBaseDocument: projects/{project}/knowledgeBases/{knowledge_base}/documents/{document} - * - projectLocationAgent: projects/{project}/locations/{location}/agent - * - projectLocationConversationModel: projects/{project}/locations/{location}/conversationModels/{conversation_model} - * - projectLocationConversationProfile: projects/{project}/locations/{location}/conversationProfiles/{conversation_profile} - * - projectLocationKnowledgeBase: projects/{project}/locations/{location}/knowledgeBases/{knowledge_base} - * - projectLocationKnowledgeBaseDocument: projects/{project}/locations/{location}/knowledgeBases/{knowledge_base}/documents/{document} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dialogflow.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Clears a suggestion feature from a conversation profile for the given - * participant role. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [ClearSuggestionFeatureConfigOperationMetadata][google.cloud.dialogflow.v2.ClearSuggestionFeatureConfigOperationMetadata] - * - `response`: - * [ConversationProfile][google.cloud.dialogflow.v2.ConversationProfile] - * - * The async variant is {@see self::clearSuggestionFeatureConfigAsync()} . - * - * @param ClearSuggestionFeatureConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function clearSuggestionFeatureConfig(ClearSuggestionFeatureConfigRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ClearSuggestionFeatureConfig', $request, $callOptions)->wait(); - } - - /** - * Creates a conversation profile in the specified project. - * - * [ConversationProfile.CreateTime][] and [ConversationProfile.UpdateTime][] - * aren't populated in the response. You can retrieve them via - * [GetConversationProfile][google.cloud.dialogflow.v2.ConversationProfiles.GetConversationProfile] - * API. - * - * The async variant is {@see self::createConversationProfileAsync()} . - * - * @param CreateConversationProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ConversationProfile - * - * @throws ApiException Thrown if the API call fails. - */ - public function createConversationProfile(CreateConversationProfileRequest $request, array $callOptions = []): ConversationProfile - { - return $this->startApiCall('CreateConversationProfile', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified conversation profile. - * - * The async variant is {@see self::deleteConversationProfileAsync()} . - * - * @param DeleteConversationProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteConversationProfile(DeleteConversationProfileRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteConversationProfile', $request, $callOptions)->wait(); - } - - /** - * Retrieves the specified conversation profile. - * - * The async variant is {@see self::getConversationProfileAsync()} . - * - * @param GetConversationProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ConversationProfile - * - * @throws ApiException Thrown if the API call fails. - */ - public function getConversationProfile(GetConversationProfileRequest $request, array $callOptions = []): ConversationProfile - { - return $this->startApiCall('GetConversationProfile', $request, $callOptions)->wait(); - } - - /** - * Returns the list of all conversation profiles in the specified project. - * - * The async variant is {@see self::listConversationProfilesAsync()} . - * - * @param ListConversationProfilesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listConversationProfiles(ListConversationProfilesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListConversationProfiles', $request, $callOptions); - } - - /** - * Adds or updates a suggestion feature in a conversation profile. - * If the conversation profile contains the type of suggestion feature for - * the participant role, it will update it. Otherwise it will insert the - * suggestion feature. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [SetSuggestionFeatureConfigOperationMetadata][google.cloud.dialogflow.v2.SetSuggestionFeatureConfigOperationMetadata] - * - `response`: - * [ConversationProfile][google.cloud.dialogflow.v2.ConversationProfile] - * - * If a long running operation to add or update suggestion feature - * config for the same conversation profile, participant role and suggestion - * feature type exists, please cancel the existing long running operation - * before sending such request, otherwise the request will be rejected. - * - * The async variant is {@see self::setSuggestionFeatureConfigAsync()} . - * - * @param SetSuggestionFeatureConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setSuggestionFeatureConfig(SetSuggestionFeatureConfigRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetSuggestionFeatureConfig', $request, $callOptions)->wait(); - } - - /** - * Updates the specified conversation profile. - * - * [ConversationProfile.CreateTime][] and [ConversationProfile.UpdateTime][] - * aren't populated in the response. You can retrieve them via - * [GetConversationProfile][google.cloud.dialogflow.v2.ConversationProfiles.GetConversationProfile] - * API. - * - * The async variant is {@see self::updateConversationProfileAsync()} . - * - * @param UpdateConversationProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ConversationProfile - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateConversationProfile(UpdateConversationProfileRequest $request, array $callOptions = []): ConversationProfile - { - return $this->startApiCall('UpdateConversationProfile', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dialogflow/src/V2/Client/BaseClient/ConversationsBaseClient.php b/Dialogflow/src/V2/Client/BaseClient/ConversationsBaseClient.php deleted file mode 100644 index 7a405042f204..000000000000 --- a/Dialogflow/src/V2/Client/BaseClient/ConversationsBaseClient.php +++ /dev/null @@ -1,940 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/conversations_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/conversations_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/conversations_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/conversations_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a agent - * resource. - * - * @param string $project - * - * @return string The formatted agent resource. - */ - public static function agentName(string $project): string - { - return self::getPathTemplate('agent')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * cx_security_settings resource. - * - * @param string $project - * @param string $location - * @param string $securitySettings - * - * @return string The formatted cx_security_settings resource. - */ - public static function cXSecuritySettingsName(string $project, string $location, string $securitySettings): string - { - return self::getPathTemplate('cXSecuritySettings')->render([ - 'project' => $project, - 'location' => $location, - 'security_settings' => $securitySettings, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a conversation - * resource. - * - * @param string $project - * @param string $conversation - * - * @return string The formatted conversation resource. - */ - public static function conversationName(string $project, string $conversation): string - { - return self::getPathTemplate('conversation')->render([ - 'project' => $project, - 'conversation' => $conversation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * conversation_model resource. - * - * @param string $project - * @param string $location - * @param string $conversationModel - * - * @return string The formatted conversation_model resource. - */ - public static function conversationModelName(string $project, string $location, string $conversationModel): string - { - return self::getPathTemplate('conversationModel')->render([ - 'project' => $project, - 'location' => $location, - 'conversation_model' => $conversationModel, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * conversation_profile resource. - * - * @param string $project - * @param string $conversationProfile - * - * @return string The formatted conversation_profile resource. - */ - public static function conversationProfileName(string $project, string $conversationProfile): string - { - return self::getPathTemplate('conversationProfile')->render([ - 'project' => $project, - 'conversation_profile' => $conversationProfile, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a document - * resource. - * - * @param string $project - * @param string $knowledgeBase - * @param string $document - * - * @return string The formatted document resource. - */ - public static function documentName(string $project, string $knowledgeBase, string $document): string - { - return self::getPathTemplate('document')->render([ - 'project' => $project, - 'knowledge_base' => $knowledgeBase, - 'document' => $document, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * knowledge_base resource. - * - * @param string $project - * @param string $knowledgeBase - * - * @return string The formatted knowledge_base resource. - */ - public static function knowledgeBaseName(string $project, string $knowledgeBase): string - { - return self::getPathTemplate('knowledgeBase')->render([ - 'project' => $project, - 'knowledge_base' => $knowledgeBase, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a message - * resource. - * - * @param string $project - * @param string $conversation - * @param string $message - * - * @return string The formatted message resource. - */ - public static function messageName(string $project, string $conversation, string $message): string - { - return self::getPathTemplate('message')->render([ - 'project' => $project, - 'conversation' => $conversation, - 'message' => $message, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_agent resource. - * - * @param string $project - * - * @return string The formatted project_agent resource. - */ - public static function projectAgentName(string $project): string - { - return self::getPathTemplate('projectAgent')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_conversation resource. - * - * @param string $project - * @param string $conversation - * - * @return string The formatted project_conversation resource. - */ - public static function projectConversationName(string $project, string $conversation): string - { - return self::getPathTemplate('projectConversation')->render([ - 'project' => $project, - 'conversation' => $conversation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_conversation_message resource. - * - * @param string $project - * @param string $conversation - * @param string $message - * - * @return string The formatted project_conversation_message resource. - */ - public static function projectConversationMessageName(string $project, string $conversation, string $message): string - { - return self::getPathTemplate('projectConversationMessage')->render([ - 'project' => $project, - 'conversation' => $conversation, - 'message' => $message, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_conversation_model resource. - * - * @param string $project - * @param string $conversationModel - * - * @return string The formatted project_conversation_model resource. - */ - public static function projectConversationModelName(string $project, string $conversationModel): string - { - return self::getPathTemplate('projectConversationModel')->render([ - 'project' => $project, - 'conversation_model' => $conversationModel, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_conversation_profile resource. - * - * @param string $project - * @param string $conversationProfile - * - * @return string The formatted project_conversation_profile resource. - */ - public static function projectConversationProfileName(string $project, string $conversationProfile): string - { - return self::getPathTemplate('projectConversationProfile')->render([ - 'project' => $project, - 'conversation_profile' => $conversationProfile, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_knowledge_base resource. - * - * @param string $project - * @param string $knowledgeBase - * - * @return string The formatted project_knowledge_base resource. - */ - public static function projectKnowledgeBaseName(string $project, string $knowledgeBase): string - { - return self::getPathTemplate('projectKnowledgeBase')->render([ - 'project' => $project, - 'knowledge_base' => $knowledgeBase, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_knowledge_base_document resource. - * - * @param string $project - * @param string $knowledgeBase - * @param string $document - * - * @return string The formatted project_knowledge_base_document resource. - */ - public static function projectKnowledgeBaseDocumentName(string $project, string $knowledgeBase, string $document): string - { - return self::getPathTemplate('projectKnowledgeBaseDocument')->render([ - 'project' => $project, - 'knowledge_base' => $knowledgeBase, - 'document' => $document, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted project_location_agent resource. - */ - public static function projectLocationAgentName(string $project, string $location): string - { - return self::getPathTemplate('projectLocationAgent')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_conversation resource. - * - * @param string $project - * @param string $location - * @param string $conversation - * - * @return string The formatted project_location_conversation resource. - */ - public static function projectLocationConversationName(string $project, string $location, string $conversation): string - { - return self::getPathTemplate('projectLocationConversation')->render([ - 'project' => $project, - 'location' => $location, - 'conversation' => $conversation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_conversation_message resource. - * - * @param string $project - * @param string $location - * @param string $conversation - * @param string $message - * - * @return string The formatted project_location_conversation_message resource. - */ - public static function projectLocationConversationMessageName(string $project, string $location, string $conversation, string $message): string - { - return self::getPathTemplate('projectLocationConversationMessage')->render([ - 'project' => $project, - 'location' => $location, - 'conversation' => $conversation, - 'message' => $message, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_conversation_model resource. - * - * @param string $project - * @param string $location - * @param string $conversationModel - * - * @return string The formatted project_location_conversation_model resource. - */ - public static function projectLocationConversationModelName(string $project, string $location, string $conversationModel): string - { - return self::getPathTemplate('projectLocationConversationModel')->render([ - 'project' => $project, - 'location' => $location, - 'conversation_model' => $conversationModel, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_conversation_profile resource. - * - * @param string $project - * @param string $location - * @param string $conversationProfile - * - * @return string The formatted project_location_conversation_profile resource. - */ - public static function projectLocationConversationProfileName(string $project, string $location, string $conversationProfile): string - { - return self::getPathTemplate('projectLocationConversationProfile')->render([ - 'project' => $project, - 'location' => $location, - 'conversation_profile' => $conversationProfile, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_knowledge_base resource. - * - * @param string $project - * @param string $location - * @param string $knowledgeBase - * - * @return string The formatted project_location_knowledge_base resource. - */ - public static function projectLocationKnowledgeBaseName(string $project, string $location, string $knowledgeBase): string - { - return self::getPathTemplate('projectLocationKnowledgeBase')->render([ - 'project' => $project, - 'location' => $location, - 'knowledge_base' => $knowledgeBase, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_knowledge_base_document resource. - * - * @param string $project - * @param string $location - * @param string $knowledgeBase - * @param string $document - * - * @return string The formatted project_location_knowledge_base_document resource. - */ - public static function projectLocationKnowledgeBaseDocumentName(string $project, string $location, string $knowledgeBase, string $document): string - { - return self::getPathTemplate('projectLocationKnowledgeBaseDocument')->render([ - 'project' => $project, - 'location' => $location, - 'knowledge_base' => $knowledgeBase, - 'document' => $document, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - agent: projects/{project}/agent - * - cXSecuritySettings: projects/{project}/locations/{location}/securitySettings/{security_settings} - * - conversation: projects/{project}/conversations/{conversation} - * - conversationModel: projects/{project}/locations/{location}/conversationModels/{conversation_model} - * - conversationProfile: projects/{project}/conversationProfiles/{conversation_profile} - * - document: projects/{project}/knowledgeBases/{knowledge_base}/documents/{document} - * - knowledgeBase: projects/{project}/knowledgeBases/{knowledge_base} - * - location: projects/{project}/locations/{location} - * - message: projects/{project}/conversations/{conversation}/messages/{message} - * - project: projects/{project} - * - projectAgent: projects/{project}/agent - * - projectConversation: projects/{project}/conversations/{conversation} - * - projectConversationMessage: projects/{project}/conversations/{conversation}/messages/{message} - * - projectConversationModel: projects/{project}/conversationModels/{conversation_model} - * - projectConversationProfile: projects/{project}/conversationProfiles/{conversation_profile} - * - projectKnowledgeBase: projects/{project}/knowledgeBases/{knowledge_base} - * - projectKnowledgeBaseDocument: projects/{project}/knowledgeBases/{knowledge_base}/documents/{document} - * - projectLocationAgent: projects/{project}/locations/{location}/agent - * - projectLocationConversation: projects/{project}/locations/{location}/conversations/{conversation} - * - projectLocationConversationMessage: projects/{project}/locations/{location}/conversations/{conversation}/messages/{message} - * - projectLocationConversationModel: projects/{project}/locations/{location}/conversationModels/{conversation_model} - * - projectLocationConversationProfile: projects/{project}/locations/{location}/conversationProfiles/{conversation_profile} - * - projectLocationKnowledgeBase: projects/{project}/locations/{location}/knowledgeBases/{knowledge_base} - * - projectLocationKnowledgeBaseDocument: projects/{project}/locations/{location}/knowledgeBases/{knowledge_base}/documents/{document} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dialogflow.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Completes the specified conversation. Finished conversations are purged - * from the database after 30 days. - * - * The async variant is {@see self::completeConversationAsync()} . - * - * @param CompleteConversationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Conversation - * - * @throws ApiException Thrown if the API call fails. - */ - public function completeConversation(CompleteConversationRequest $request, array $callOptions = []): Conversation - { - return $this->startApiCall('CompleteConversation', $request, $callOptions)->wait(); - } - - /** - * Creates a new conversation. Conversations are auto-completed after 24 - * hours. - * - * Conversation Lifecycle: - * There are two stages during a conversation: Automated Agent Stage and - * Assist Stage. - * - * For Automated Agent Stage, there will be a dialogflow agent responding to - * user queries. - * - * For Assist Stage, there's no dialogflow agent responding to user queries. - * But we will provide suggestions which are generated from conversation. - * - * If - * [Conversation.conversation_profile][google.cloud.dialogflow.v2.Conversation.conversation_profile] - * is configured for a dialogflow agent, conversation will start from - * `Automated Agent Stage`, otherwise, it will start from `Assist Stage`. And - * during `Automated Agent Stage`, once an - * [Intent][google.cloud.dialogflow.v2.Intent] with - * [Intent.live_agent_handoff][google.cloud.dialogflow.v2.Intent.live_agent_handoff] - * is triggered, conversation will transfer to Assist Stage. - * - * The async variant is {@see self::createConversationAsync()} . - * - * @param CreateConversationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Conversation - * - * @throws ApiException Thrown if the API call fails. - */ - public function createConversation(CreateConversationRequest $request, array $callOptions = []): Conversation - { - return $this->startApiCall('CreateConversation', $request, $callOptions)->wait(); - } - - /** - * Generates and returns a summary for a conversation that does not have a - * resource created for it. - * - * The async variant is {@see self::generateStatelessSummaryAsync()} . - * - * @param GenerateStatelessSummaryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GenerateStatelessSummaryResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function generateStatelessSummary(GenerateStatelessSummaryRequest $request, array $callOptions = []): GenerateStatelessSummaryResponse - { - return $this->startApiCall('GenerateStatelessSummary', $request, $callOptions)->wait(); - } - - /** - * Retrieves the specific conversation. - * - * The async variant is {@see self::getConversationAsync()} . - * - * @param GetConversationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Conversation - * - * @throws ApiException Thrown if the API call fails. - */ - public function getConversation(GetConversationRequest $request, array $callOptions = []): Conversation - { - return $this->startApiCall('GetConversation', $request, $callOptions)->wait(); - } - - /** - * Returns the list of all conversations in the specified project. - * - * The async variant is {@see self::listConversationsAsync()} . - * - * @param ListConversationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listConversations(ListConversationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListConversations', $request, $callOptions); - } - - /** - * Lists messages that belong to a given conversation. - * `messages` are ordered by `create_time` in descending order. To fetch - * updates without duplication, send request with filter - * `create_time_epoch_microseconds > - * [first item's create_time of previous request]` and empty page_token. - * - * The async variant is {@see self::listMessagesAsync()} . - * - * @param ListMessagesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listMessages(ListMessagesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListMessages', $request, $callOptions); - } - - /** - * Get answers for the given query based on knowledge documents. - * - * The async variant is {@see self::searchKnowledgeAsync()} . - * - * @param SearchKnowledgeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SearchKnowledgeResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchKnowledge(SearchKnowledgeRequest $request, array $callOptions = []): SearchKnowledgeResponse - { - return $this->startApiCall('SearchKnowledge', $request, $callOptions)->wait(); - } - - /** - * Suggests summary for a conversation based on specific historical messages. - * The range of the messages to be used for summary can be specified in the - * request. - * - * The async variant is {@see self::suggestConversationSummaryAsync()} . - * - * @param SuggestConversationSummaryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SuggestConversationSummaryResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function suggestConversationSummary(SuggestConversationSummaryRequest $request, array $callOptions = []): SuggestConversationSummaryResponse - { - return $this->startApiCall('SuggestConversationSummary', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dialogflow/src/V2/Client/BaseClient/DocumentsBaseClient.php b/Dialogflow/src/V2/Client/BaseClient/DocumentsBaseClient.php deleted file mode 100644 index d074c8411169..000000000000 --- a/Dialogflow/src/V2/Client/BaseClient/DocumentsBaseClient.php +++ /dev/null @@ -1,669 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/documents_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/documents_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/documents_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/documents_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a document - * resource. - * - * @param string $project - * @param string $knowledgeBase - * @param string $document - * - * @return string The formatted document resource. - */ - public static function documentName(string $project, string $knowledgeBase, string $document): string - { - return self::getPathTemplate('document')->render([ - 'project' => $project, - 'knowledge_base' => $knowledgeBase, - 'document' => $document, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * knowledge_base resource. - * - * @param string $project - * @param string $knowledgeBase - * - * @return string The formatted knowledge_base resource. - */ - public static function knowledgeBaseName(string $project, string $knowledgeBase): string - { - return self::getPathTemplate('knowledgeBase')->render([ - 'project' => $project, - 'knowledge_base' => $knowledgeBase, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_knowledge_base resource. - * - * @param string $project - * @param string $knowledgeBase - * - * @return string The formatted project_knowledge_base resource. - */ - public static function projectKnowledgeBaseName(string $project, string $knowledgeBase): string - { - return self::getPathTemplate('projectKnowledgeBase')->render([ - 'project' => $project, - 'knowledge_base' => $knowledgeBase, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_knowledge_base_document resource. - * - * @param string $project - * @param string $knowledgeBase - * @param string $document - * - * @return string The formatted project_knowledge_base_document resource. - */ - public static function projectKnowledgeBaseDocumentName(string $project, string $knowledgeBase, string $document): string - { - return self::getPathTemplate('projectKnowledgeBaseDocument')->render([ - 'project' => $project, - 'knowledge_base' => $knowledgeBase, - 'document' => $document, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_knowledge_base resource. - * - * @param string $project - * @param string $location - * @param string $knowledgeBase - * - * @return string The formatted project_location_knowledge_base resource. - */ - public static function projectLocationKnowledgeBaseName(string $project, string $location, string $knowledgeBase): string - { - return self::getPathTemplate('projectLocationKnowledgeBase')->render([ - 'project' => $project, - 'location' => $location, - 'knowledge_base' => $knowledgeBase, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_knowledge_base_document resource. - * - * @param string $project - * @param string $location - * @param string $knowledgeBase - * @param string $document - * - * @return string The formatted project_location_knowledge_base_document resource. - */ - public static function projectLocationKnowledgeBaseDocumentName(string $project, string $location, string $knowledgeBase, string $document): string - { - return self::getPathTemplate('projectLocationKnowledgeBaseDocument')->render([ - 'project' => $project, - 'location' => $location, - 'knowledge_base' => $knowledgeBase, - 'document' => $document, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - document: projects/{project}/knowledgeBases/{knowledge_base}/documents/{document} - * - knowledgeBase: projects/{project}/knowledgeBases/{knowledge_base} - * - projectKnowledgeBase: projects/{project}/knowledgeBases/{knowledge_base} - * - projectKnowledgeBaseDocument: projects/{project}/knowledgeBases/{knowledge_base}/documents/{document} - * - projectLocationKnowledgeBase: projects/{project}/locations/{location}/knowledgeBases/{knowledge_base} - * - projectLocationKnowledgeBaseDocument: projects/{project}/locations/{location}/knowledgeBases/{knowledge_base}/documents/{document} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dialogflow.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new document. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] - * - `response`: [Document][google.cloud.dialogflow.v2.Document] - * - * The async variant is {@see self::createDocumentAsync()} . - * - * @param CreateDocumentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDocument(CreateDocumentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateDocument', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified document. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] - * - `response`: An [Empty - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) - * - * The async variant is {@see self::deleteDocumentAsync()} . - * - * @param DeleteDocumentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDocument(DeleteDocumentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteDocument', $request, $callOptions)->wait(); - } - - /** - * Exports a smart messaging candidate document into the specified - * destination. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] - * - `response`: [Document][google.cloud.dialogflow.v2.Document] - * - * The async variant is {@see self::exportDocumentAsync()} . - * - * @param ExportDocumentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function exportDocument(ExportDocumentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ExportDocument', $request, $callOptions)->wait(); - } - - /** - * Retrieves the specified document. - * - * The async variant is {@see self::getDocumentAsync()} . - * - * @param GetDocumentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Document - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDocument(GetDocumentRequest $request, array $callOptions = []): Document - { - return $this->startApiCall('GetDocument', $request, $callOptions)->wait(); - } - - /** - * Creates documents by importing data from external sources. - * Dialogflow supports up to 350 documents in each request. If you try to - * import more, Dialogflow will return an error. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] - * - `response`: - * [ImportDocumentsResponse][google.cloud.dialogflow.v2.ImportDocumentsResponse] - * - * The async variant is {@see self::importDocumentsAsync()} . - * - * @param ImportDocumentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function importDocuments(ImportDocumentsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ImportDocuments', $request, $callOptions)->wait(); - } - - /** - * Returns the list of all documents of the knowledge base. - * - * The async variant is {@see self::listDocumentsAsync()} . - * - * @param ListDocumentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDocuments(ListDocumentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDocuments', $request, $callOptions); - } - - /** - * Reloads the specified document from its specified source, content_uri or - * content. The previously loaded content of the document will be deleted. - * Note: Even when the content of the document has not changed, there still - * may be side effects because of internal implementation changes. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] - * - `response`: [Document][google.cloud.dialogflow.v2.Document] - * - * Note: The `projects.agent.knowledgeBases.documents` resource is deprecated; - * only use `projects.knowledgeBases.documents`. - * - * The async variant is {@see self::reloadDocumentAsync()} . - * - * @param ReloadDocumentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function reloadDocument(ReloadDocumentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ReloadDocument', $request, $callOptions)->wait(); - } - - /** - * Updates the specified document. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: - * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] - * - `response`: [Document][google.cloud.dialogflow.v2.Document] - * - * The async variant is {@see self::updateDocumentAsync()} . - * - * @param UpdateDocumentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDocument(UpdateDocumentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateDocument', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dialogflow/src/V2/Client/BaseClient/EntityTypesBaseClient.php b/Dialogflow/src/V2/Client/BaseClient/EntityTypesBaseClient.php deleted file mode 100644 index 1834b180c2b5..000000000000 --- a/Dialogflow/src/V2/Client/BaseClient/EntityTypesBaseClient.php +++ /dev/null @@ -1,728 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/entity_types_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/entity_types_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/entity_types_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/entity_types_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a agent - * resource. - * - * @param string $project - * - * @return string The formatted agent resource. - */ - public static function agentName(string $project): string - { - return self::getPathTemplate('agent')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a entity_type - * resource. - * - * @param string $project - * @param string $entityType - * - * @return string The formatted entity_type resource. - */ - public static function entityTypeName(string $project, string $entityType): string - { - return self::getPathTemplate('entityType')->render([ - 'project' => $project, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_agent resource. - * - * @param string $project - * - * @return string The formatted project_agent resource. - */ - public static function projectAgentName(string $project): string - { - return self::getPathTemplate('projectAgent')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_entity_type resource. - * - * @param string $project - * @param string $entityType - * - * @return string The formatted project_entity_type resource. - */ - public static function projectEntityTypeName(string $project, string $entityType): string - { - return self::getPathTemplate('projectEntityType')->render([ - 'project' => $project, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted project_location_agent resource. - */ - public static function projectLocationAgentName(string $project, string $location): string - { - return self::getPathTemplate('projectLocationAgent')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_entity_type resource. - * - * @param string $project - * @param string $location - * @param string $entityType - * - * @return string The formatted project_location_entity_type resource. - */ - public static function projectLocationEntityTypeName(string $project, string $location, string $entityType): string - { - return self::getPathTemplate('projectLocationEntityType')->render([ - 'project' => $project, - 'location' => $location, - 'entity_type' => $entityType, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - agent: projects/{project}/agent - * - entityType: projects/{project}/agent/entityTypes/{entity_type} - * - projectAgent: projects/{project}/agent - * - projectEntityType: projects/{project}/agent/entityTypes/{entity_type} - * - projectLocationAgent: projects/{project}/locations/{location}/agent - * - projectLocationEntityType: projects/{project}/locations/{location}/agent/entityTypes/{entity_type} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dialogflow.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates multiple new entities in the specified entity type. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: An empty [Struct - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - * - `response`: An [Empty - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) - * - * Note: You should always train an agent prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/es/docs/training). - * - * The async variant is {@see self::batchCreateEntitiesAsync()} . - * - * @param BatchCreateEntitiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchCreateEntities(BatchCreateEntitiesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BatchCreateEntities', $request, $callOptions)->wait(); - } - - /** - * Deletes entities in the specified entity type. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: An empty [Struct - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - * - `response`: An [Empty - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) - * - * Note: You should always train an agent prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/es/docs/training). - * - * The async variant is {@see self::batchDeleteEntitiesAsync()} . - * - * @param BatchDeleteEntitiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchDeleteEntities(BatchDeleteEntitiesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BatchDeleteEntities', $request, $callOptions)->wait(); - } - - /** - * Deletes entity types in the specified agent. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: An empty [Struct - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - * - `response`: An [Empty - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) - * - * Note: You should always train an agent prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/es/docs/training). - * - * The async variant is {@see self::batchDeleteEntityTypesAsync()} . - * - * @param BatchDeleteEntityTypesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchDeleteEntityTypes(BatchDeleteEntityTypesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BatchDeleteEntityTypes', $request, $callOptions)->wait(); - } - - /** - * Updates or creates multiple entities in the specified entity type. This - * method does not affect entities in the entity type that aren't explicitly - * specified in the request. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: An empty [Struct - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - * - `response`: An [Empty - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) - * - * Note: You should always train an agent prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/es/docs/training). - * - * - * The async variant is {@see self::batchUpdateEntitiesAsync()} . - * - * @param BatchUpdateEntitiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchUpdateEntities(BatchUpdateEntitiesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BatchUpdateEntities', $request, $callOptions)->wait(); - } - - /** - * Updates/Creates multiple entity types in the specified agent. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: An empty [Struct - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - * - `response`: - * [BatchUpdateEntityTypesResponse][google.cloud.dialogflow.v2.BatchUpdateEntityTypesResponse] - * - * Note: You should always train an agent prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/es/docs/training). - * - * The async variant is {@see self::batchUpdateEntityTypesAsync()} . - * - * @param BatchUpdateEntityTypesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchUpdateEntityTypes(BatchUpdateEntityTypesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BatchUpdateEntityTypes', $request, $callOptions)->wait(); - } - - /** - * Creates an entity type in the specified agent. - * - * Note: You should always train an agent prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/es/docs/training). - * - * The async variant is {@see self::createEntityTypeAsync()} . - * - * @param CreateEntityTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 EntityType - * - * @throws ApiException Thrown if the API call fails. - */ - public function createEntityType(CreateEntityTypeRequest $request, array $callOptions = []): EntityType - { - return $this->startApiCall('CreateEntityType', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified entity type. - * - * Note: You should always train an agent prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/es/docs/training). - * - * The async variant is {@see self::deleteEntityTypeAsync()} . - * - * @param DeleteEntityTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteEntityType(DeleteEntityTypeRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteEntityType', $request, $callOptions)->wait(); - } - - /** - * Retrieves the specified entity type. - * - * The async variant is {@see self::getEntityTypeAsync()} . - * - * @param GetEntityTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 EntityType - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEntityType(GetEntityTypeRequest $request, array $callOptions = []): EntityType - { - return $this->startApiCall('GetEntityType', $request, $callOptions)->wait(); - } - - /** - * Returns the list of all entity types in the specified agent. - * - * The async variant is {@see self::listEntityTypesAsync()} . - * - * @param ListEntityTypesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listEntityTypes(ListEntityTypesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListEntityTypes', $request, $callOptions); - } - - /** - * Updates the specified entity type. - * - * Note: You should always train an agent prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/es/docs/training). - * - * The async variant is {@see self::updateEntityTypeAsync()} . - * - * @param UpdateEntityTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 EntityType - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateEntityType(UpdateEntityTypeRequest $request, array $callOptions = []): EntityType - { - return $this->startApiCall('UpdateEntityType', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dialogflow/src/V2/Client/BaseClient/EnvironmentsBaseClient.php b/Dialogflow/src/V2/Client/BaseClient/EnvironmentsBaseClient.php deleted file mode 100644 index 211aa964a530..000000000000 --- a/Dialogflow/src/V2/Client/BaseClient/EnvironmentsBaseClient.php +++ /dev/null @@ -1,623 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/environments_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/environments_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/environments_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/environments_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a agent - * resource. - * - * @param string $project - * - * @return string The formatted agent resource. - */ - public static function agentName(string $project): string - { - return self::getPathTemplate('agent')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a environment - * resource. - * - * @param string $project - * @param string $environment - * - * @return string The formatted environment resource. - */ - public static function environmentName(string $project, string $environment): string - { - return self::getPathTemplate('environment')->render([ - 'project' => $project, - 'environment' => $environment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a fulfillment - * resource. - * - * @param string $project - * - * @return string The formatted fulfillment resource. - */ - public static function fulfillmentName(string $project): string - { - return self::getPathTemplate('fulfillment')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_agent resource. - * - * @param string $project - * - * @return string The formatted project_agent resource. - */ - public static function projectAgentName(string $project): string - { - return self::getPathTemplate('projectAgent')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_environment resource. - * - * @param string $project - * @param string $environment - * - * @return string The formatted project_environment resource. - */ - public static function projectEnvironmentName(string $project, string $environment): string - { - return self::getPathTemplate('projectEnvironment')->render([ - 'project' => $project, - 'environment' => $environment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_fulfillment resource. - * - * @param string $project - * - * @return string The formatted project_fulfillment resource. - */ - public static function projectFulfillmentName(string $project): string - { - return self::getPathTemplate('projectFulfillment')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted project_location_agent resource. - */ - public static function projectLocationAgentName(string $project, string $location): string - { - return self::getPathTemplate('projectLocationAgent')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_environment resource. - * - * @param string $project - * @param string $location - * @param string $environment - * - * @return string The formatted project_location_environment resource. - */ - public static function projectLocationEnvironmentName(string $project, string $location, string $environment): string - { - return self::getPathTemplate('projectLocationEnvironment')->render([ - 'project' => $project, - 'location' => $location, - 'environment' => $environment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_fulfillment resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted project_location_fulfillment resource. - */ - public static function projectLocationFulfillmentName(string $project, string $location): string - { - return self::getPathTemplate('projectLocationFulfillment')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_version resource. - * - * @param string $project - * @param string $location - * @param string $version - * - * @return string The formatted project_location_version resource. - */ - public static function projectLocationVersionName(string $project, string $location, string $version): string - { - return self::getPathTemplate('projectLocationVersion')->render([ - 'project' => $project, - 'location' => $location, - 'version' => $version, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_version resource. - * - * @param string $project - * @param string $version - * - * @return string The formatted project_version resource. - */ - public static function projectVersionName(string $project, string $version): string - { - return self::getPathTemplate('projectVersion')->render([ - 'project' => $project, - 'version' => $version, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a version - * resource. - * - * @param string $project - * @param string $version - * - * @return string The formatted version resource. - */ - public static function versionName(string $project, string $version): string - { - return self::getPathTemplate('version')->render([ - 'project' => $project, - 'version' => $version, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - agent: projects/{project}/agent - * - environment: projects/{project}/agent/environments/{environment} - * - fulfillment: projects/{project}/agent/fulfillment - * - projectAgent: projects/{project}/agent - * - projectEnvironment: projects/{project}/agent/environments/{environment} - * - projectFulfillment: projects/{project}/agent/fulfillment - * - projectLocationAgent: projects/{project}/locations/{location}/agent - * - projectLocationEnvironment: projects/{project}/locations/{location}/agent/environments/{environment} - * - projectLocationFulfillment: projects/{project}/locations/{location}/agent/fulfillment - * - projectLocationVersion: projects/{project}/locations/{location}/agent/versions/{version} - * - projectVersion: projects/{project}/agent/versions/{version} - * - version: projects/{project}/agent/versions/{version} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dialogflow.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates an agent environment. - * - * The async variant is {@see self::createEnvironmentAsync()} . - * - * @param CreateEnvironmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Environment - * - * @throws ApiException Thrown if the API call fails. - */ - public function createEnvironment(CreateEnvironmentRequest $request, array $callOptions = []): Environment - { - return $this->startApiCall('CreateEnvironment', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified agent environment. - * - * The async variant is {@see self::deleteEnvironmentAsync()} . - * - * @param DeleteEnvironmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteEnvironment(DeleteEnvironmentRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteEnvironment', $request, $callOptions)->wait(); - } - - /** - * Retrieves the specified agent environment. - * - * The async variant is {@see self::getEnvironmentAsync()} . - * - * @param GetEnvironmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Environment - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEnvironment(GetEnvironmentRequest $request, array $callOptions = []): Environment - { - return $this->startApiCall('GetEnvironment', $request, $callOptions)->wait(); - } - - /** - * Gets the history of the specified environment. - * - * The async variant is {@see self::getEnvironmentHistoryAsync()} . - * - * @param GetEnvironmentHistoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEnvironmentHistory(GetEnvironmentHistoryRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('GetEnvironmentHistory', $request, $callOptions); - } - - /** - * Returns the list of all non-default environments of the specified agent. - * - * The async variant is {@see self::listEnvironmentsAsync()} . - * - * @param ListEnvironmentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listEnvironments(ListEnvironmentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListEnvironments', $request, $callOptions); - } - - /** - * Updates the specified agent environment. - * - * This method allows you to deploy new agent versions into the environment. - * When an environment is pointed to a new agent version by setting - * `environment.agent_version`, the environment is temporarily set to the - * `LOADING` state. During that time, the environment continues serving the - * previous version of the agent. After the new agent version is done loading, - * the environment is set back to the `RUNNING` state. - * You can use "-" as Environment ID in environment name to update an agent - * version in the default environment. WARNING: this will negate all recent - * changes to the draft agent and can't be undone. You may want to save the - * draft agent to a version before calling this method. - * - * The async variant is {@see self::updateEnvironmentAsync()} . - * - * @param UpdateEnvironmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Environment - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateEnvironment(UpdateEnvironmentRequest $request, array $callOptions = []): Environment - { - return $this->startApiCall('UpdateEnvironment', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dialogflow/src/V2/Client/BaseClient/FulfillmentsBaseClient.php b/Dialogflow/src/V2/Client/BaseClient/FulfillmentsBaseClient.php deleted file mode 100644 index 40f53daa547c..000000000000 --- a/Dialogflow/src/V2/Client/BaseClient/FulfillmentsBaseClient.php +++ /dev/null @@ -1,348 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/fulfillments_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/fulfillments_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/fulfillments_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/fulfillments_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a fulfillment - * resource. - * - * @param string $project - * - * @return string The formatted fulfillment resource. - */ - public static function fulfillmentName(string $project): string - { - return self::getPathTemplate('fulfillment')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_fulfillment resource. - * - * @param string $project - * - * @return string The formatted project_fulfillment resource. - */ - public static function projectFulfillmentName(string $project): string - { - return self::getPathTemplate('projectFulfillment')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_fulfillment resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted project_location_fulfillment resource. - */ - public static function projectLocationFulfillmentName(string $project, string $location): string - { - return self::getPathTemplate('projectLocationFulfillment')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - fulfillment: projects/{project}/agent/fulfillment - * - projectFulfillment: projects/{project}/agent/fulfillment - * - projectLocationFulfillment: projects/{project}/locations/{location}/agent/fulfillment - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dialogflow.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves the fulfillment. - * - * The async variant is {@see self::getFulfillmentAsync()} . - * - * @param GetFulfillmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Fulfillment - * - * @throws ApiException Thrown if the API call fails. - */ - public function getFulfillment(GetFulfillmentRequest $request, array $callOptions = []): Fulfillment - { - return $this->startApiCall('GetFulfillment', $request, $callOptions)->wait(); - } - - /** - * Updates the fulfillment. - * - * The async variant is {@see self::updateFulfillmentAsync()} . - * - * @param UpdateFulfillmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Fulfillment - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateFulfillment(UpdateFulfillmentRequest $request, array $callOptions = []): Fulfillment - { - return $this->startApiCall('UpdateFulfillment', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dialogflow/src/V2/Client/BaseClient/IntentsBaseClient.php b/Dialogflow/src/V2/Client/BaseClient/IntentsBaseClient.php deleted file mode 100644 index dc8b0443d2ae..000000000000 --- a/Dialogflow/src/V2/Client/BaseClient/IntentsBaseClient.php +++ /dev/null @@ -1,821 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/intents_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/intents_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/intents_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/intents_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a agent - * resource. - * - * @param string $project - * - * @return string The formatted agent resource. - */ - public static function agentName(string $project): string - { - return self::getPathTemplate('agent')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a context - * resource. - * - * @param string $project - * @param string $session - * @param string $context - * - * @return string The formatted context resource. - */ - public static function contextName(string $project, string $session, string $context): string - { - return self::getPathTemplate('context')->render([ - 'project' => $project, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a intent - * resource. - * - * @param string $project - * @param string $intent - * - * @return string The formatted intent resource. - */ - public static function intentName(string $project, string $intent): string - { - return self::getPathTemplate('intent')->render([ - 'project' => $project, - 'intent' => $intent, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_agent resource. - * - * @param string $project - * - * @return string The formatted project_agent resource. - */ - public static function projectAgentName(string $project): string - { - return self::getPathTemplate('projectAgent')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_environment_user_session resource. - * - * @param string $project - * @param string $environment - * @param string $user - * @param string $session - * - * @return string The formatted project_environment_user_session resource. - */ - public static function projectEnvironmentUserSessionName(string $project, string $environment, string $user, string $session): string - { - return self::getPathTemplate('projectEnvironmentUserSession')->render([ - 'project' => $project, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_environment_user_session_context resource. - * - * @param string $project - * @param string $environment - * @param string $user - * @param string $session - * @param string $context - * - * @return string The formatted project_environment_user_session_context resource. - */ - public static function projectEnvironmentUserSessionContextName(string $project, string $environment, string $user, string $session, string $context): string - { - return self::getPathTemplate('projectEnvironmentUserSessionContext')->render([ - 'project' => $project, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_intent resource. - * - * @param string $project - * @param string $intent - * - * @return string The formatted project_intent resource. - */ - public static function projectIntentName(string $project, string $intent): string - { - return self::getPathTemplate('projectIntent')->render([ - 'project' => $project, - 'intent' => $intent, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted project_location_agent resource. - */ - public static function projectLocationAgentName(string $project, string $location): string - { - return self::getPathTemplate('projectLocationAgent')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_environment_user_session resource. - * - * @param string $project - * @param string $location - * @param string $environment - * @param string $user - * @param string $session - * - * @return string The formatted project_location_environment_user_session resource. - */ - public static function projectLocationEnvironmentUserSessionName(string $project, string $location, string $environment, string $user, string $session): string - { - return self::getPathTemplate('projectLocationEnvironmentUserSession')->render([ - 'project' => $project, - 'location' => $location, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_environment_user_session_context resource. - * - * @param string $project - * @param string $location - * @param string $environment - * @param string $user - * @param string $session - * @param string $context - * - * @return string The formatted project_location_environment_user_session_context resource. - */ - public static function projectLocationEnvironmentUserSessionContextName(string $project, string $location, string $environment, string $user, string $session, string $context): string - { - return self::getPathTemplate('projectLocationEnvironmentUserSessionContext')->render([ - 'project' => $project, - 'location' => $location, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_intent resource. - * - * @param string $project - * @param string $location - * @param string $intent - * - * @return string The formatted project_location_intent resource. - */ - public static function projectLocationIntentName(string $project, string $location, string $intent): string - { - return self::getPathTemplate('projectLocationIntent')->render([ - 'project' => $project, - 'location' => $location, - 'intent' => $intent, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_session resource. - * - * @param string $project - * @param string $location - * @param string $session - * - * @return string The formatted project_location_session resource. - */ - public static function projectLocationSessionName(string $project, string $location, string $session): string - { - return self::getPathTemplate('projectLocationSession')->render([ - 'project' => $project, - 'location' => $location, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_session_context resource. - * - * @param string $project - * @param string $location - * @param string $session - * @param string $context - * - * @return string The formatted project_location_session_context resource. - */ - public static function projectLocationSessionContextName(string $project, string $location, string $session, string $context): string - { - return self::getPathTemplate('projectLocationSessionContext')->render([ - 'project' => $project, - 'location' => $location, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_session resource. - * - * @param string $project - * @param string $session - * - * @return string The formatted project_session resource. - */ - public static function projectSessionName(string $project, string $session): string - { - return self::getPathTemplate('projectSession')->render([ - 'project' => $project, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_session_context resource. - * - * @param string $project - * @param string $session - * @param string $context - * - * @return string The formatted project_session_context resource. - */ - public static function projectSessionContextName(string $project, string $session, string $context): string - { - return self::getPathTemplate('projectSessionContext')->render([ - 'project' => $project, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a session - * resource. - * - * @param string $project - * @param string $session - * - * @return string The formatted session resource. - */ - public static function sessionName(string $project, string $session): string - { - return self::getPathTemplate('session')->render([ - 'project' => $project, - 'session' => $session, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - agent: projects/{project}/agent - * - context: projects/{project}/agent/sessions/{session}/contexts/{context} - * - intent: projects/{project}/agent/intents/{intent} - * - projectAgent: projects/{project}/agent - * - projectEnvironmentUserSession: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session} - * - projectEnvironmentUserSessionContext: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context} - * - projectIntent: projects/{project}/agent/intents/{intent} - * - projectLocationAgent: projects/{project}/locations/{location}/agent - * - projectLocationEnvironmentUserSession: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session} - * - projectLocationEnvironmentUserSessionContext: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context} - * - projectLocationIntent: projects/{project}/locations/{location}/agent/intents/{intent} - * - projectLocationSession: projects/{project}/locations/{location}/agent/sessions/{session} - * - projectLocationSessionContext: projects/{project}/locations/{location}/agent/sessions/{session}/contexts/{context} - * - projectSession: projects/{project}/agent/sessions/{session} - * - projectSessionContext: projects/{project}/agent/sessions/{session}/contexts/{context} - * - session: projects/{project}/agent/sessions/{session} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dialogflow.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes intents in the specified agent. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: An empty [Struct - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - * - `response`: An [Empty - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) - * - * Note: You should always train an agent prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/es/docs/training). - * - * The async variant is {@see self::batchDeleteIntentsAsync()} . - * - * @param BatchDeleteIntentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchDeleteIntents(BatchDeleteIntentsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BatchDeleteIntents', $request, $callOptions)->wait(); - } - - /** - * Updates/Creates multiple intents in the specified agent. - * - * This method is a [long-running - * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). - * The returned `Operation` type has the following method-specific fields: - * - * - `metadata`: An empty [Struct - * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) - * - `response`: - * [BatchUpdateIntentsResponse][google.cloud.dialogflow.v2.BatchUpdateIntentsResponse] - * - * Note: You should always train an agent prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/es/docs/training). - * - * The async variant is {@see self::batchUpdateIntentsAsync()} . - * - * @param BatchUpdateIntentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchUpdateIntents(BatchUpdateIntentsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BatchUpdateIntents', $request, $callOptions)->wait(); - } - - /** - * Creates an intent in the specified agent. - * - * Note: You should always train an agent prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/es/docs/training). - * - * The async variant is {@see self::createIntentAsync()} . - * - * @param CreateIntentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Intent - * - * @throws ApiException Thrown if the API call fails. - */ - public function createIntent(CreateIntentRequest $request, array $callOptions = []): Intent - { - return $this->startApiCall('CreateIntent', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified intent and its direct or indirect followup intents. - * - * Note: You should always train an agent prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/es/docs/training). - * - * The async variant is {@see self::deleteIntentAsync()} . - * - * @param DeleteIntentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteIntent(DeleteIntentRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteIntent', $request, $callOptions)->wait(); - } - - /** - * Retrieves the specified intent. - * - * The async variant is {@see self::getIntentAsync()} . - * - * @param GetIntentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Intent - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIntent(GetIntentRequest $request, array $callOptions = []): Intent - { - return $this->startApiCall('GetIntent', $request, $callOptions)->wait(); - } - - /** - * Returns the list of all intents in the specified agent. - * - * The async variant is {@see self::listIntentsAsync()} . - * - * @param ListIntentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listIntents(ListIntentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListIntents', $request, $callOptions); - } - - /** - * Updates the specified intent. - * - * Note: You should always train an agent prior to sending it queries. See the - * [training - * documentation](https://cloud.google.com/dialogflow/es/docs/training). - * - * The async variant is {@see self::updateIntentAsync()} . - * - * @param UpdateIntentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Intent - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateIntent(UpdateIntentRequest $request, array $callOptions = []): Intent - { - return $this->startApiCall('UpdateIntent', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dialogflow/src/V2/Client/BaseClient/KnowledgeBasesBaseClient.php b/Dialogflow/src/V2/Client/BaseClient/KnowledgeBasesBaseClient.php deleted file mode 100644 index d6346df2d440..000000000000 --- a/Dialogflow/src/V2/Client/BaseClient/KnowledgeBasesBaseClient.php +++ /dev/null @@ -1,465 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/knowledge_bases_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/knowledge_bases_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/knowledge_bases_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/knowledge_bases_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * knowledge_base resource. - * - * @param string $project - * @param string $knowledgeBase - * - * @return string The formatted knowledge_base resource. - */ - public static function knowledgeBaseName(string $project, string $knowledgeBase): string - { - return self::getPathTemplate('knowledgeBase')->render([ - 'project' => $project, - 'knowledge_base' => $knowledgeBase, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_knowledge_base resource. - * - * @param string $project - * @param string $knowledgeBase - * - * @return string The formatted project_knowledge_base resource. - */ - public static function projectKnowledgeBaseName(string $project, string $knowledgeBase): string - { - return self::getPathTemplate('projectKnowledgeBase')->render([ - 'project' => $project, - 'knowledge_base' => $knowledgeBase, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_knowledge_base resource. - * - * @param string $project - * @param string $location - * @param string $knowledgeBase - * - * @return string The formatted project_location_knowledge_base resource. - */ - public static function projectLocationKnowledgeBaseName(string $project, string $location, string $knowledgeBase): string - { - return self::getPathTemplate('projectLocationKnowledgeBase')->render([ - 'project' => $project, - 'location' => $location, - 'knowledge_base' => $knowledgeBase, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - knowledgeBase: projects/{project}/knowledgeBases/{knowledge_base} - * - location: projects/{project}/locations/{location} - * - project: projects/{project} - * - projectKnowledgeBase: projects/{project}/knowledgeBases/{knowledge_base} - * - projectLocationKnowledgeBase: projects/{project}/locations/{location}/knowledgeBases/{knowledge_base} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dialogflow.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a knowledge base. - * - * The async variant is {@see self::createKnowledgeBaseAsync()} . - * - * @param CreateKnowledgeBaseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 KnowledgeBase - * - * @throws ApiException Thrown if the API call fails. - */ - public function createKnowledgeBase(CreateKnowledgeBaseRequest $request, array $callOptions = []): KnowledgeBase - { - return $this->startApiCall('CreateKnowledgeBase', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified knowledge base. - * - * The async variant is {@see self::deleteKnowledgeBaseAsync()} . - * - * @param DeleteKnowledgeBaseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteKnowledgeBase(DeleteKnowledgeBaseRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteKnowledgeBase', $request, $callOptions)->wait(); - } - - /** - * Retrieves the specified knowledge base. - * - * The async variant is {@see self::getKnowledgeBaseAsync()} . - * - * @param GetKnowledgeBaseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 KnowledgeBase - * - * @throws ApiException Thrown if the API call fails. - */ - public function getKnowledgeBase(GetKnowledgeBaseRequest $request, array $callOptions = []): KnowledgeBase - { - return $this->startApiCall('GetKnowledgeBase', $request, $callOptions)->wait(); - } - - /** - * Returns the list of all knowledge bases of the specified agent. - * - * The async variant is {@see self::listKnowledgeBasesAsync()} . - * - * @param ListKnowledgeBasesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listKnowledgeBases(ListKnowledgeBasesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListKnowledgeBases', $request, $callOptions); - } - - /** - * Updates the specified knowledge base. - * - * The async variant is {@see self::updateKnowledgeBaseAsync()} . - * - * @param UpdateKnowledgeBaseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 KnowledgeBase - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateKnowledgeBase(UpdateKnowledgeBaseRequest $request, array $callOptions = []): KnowledgeBase - { - return $this->startApiCall('UpdateKnowledgeBase', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dialogflow/src/V2/Client/BaseClient/ParticipantsBaseClient.php b/Dialogflow/src/V2/Client/BaseClient/ParticipantsBaseClient.php deleted file mode 100644 index 423b944374a1..000000000000 --- a/Dialogflow/src/V2/Client/BaseClient/ParticipantsBaseClient.php +++ /dev/null @@ -1,1006 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/participants_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/participants_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/participants_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/participants_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a context - * resource. - * - * @param string $project - * @param string $session - * @param string $context - * - * @return string The formatted context resource. - */ - public static function contextName(string $project, string $session, string $context): string - { - return self::getPathTemplate('context')->render([ - 'project' => $project, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a conversation - * resource. - * - * @param string $project - * @param string $conversation - * - * @return string The formatted conversation resource. - */ - public static function conversationName(string $project, string $conversation): string - { - return self::getPathTemplate('conversation')->render([ - 'project' => $project, - 'conversation' => $conversation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a message - * resource. - * - * @param string $project - * @param string $conversation - * @param string $message - * - * @return string The formatted message resource. - */ - public static function messageName(string $project, string $conversation, string $message): string - { - return self::getPathTemplate('message')->render([ - 'project' => $project, - 'conversation' => $conversation, - 'message' => $message, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a participant - * resource. - * - * @param string $project - * @param string $conversation - * @param string $participant - * - * @return string The formatted participant resource. - */ - public static function participantName(string $project, string $conversation, string $participant): string - { - return self::getPathTemplate('participant')->render([ - 'project' => $project, - 'conversation' => $conversation, - 'participant' => $participant, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_conversation resource. - * - * @param string $project - * @param string $conversation - * - * @return string The formatted project_conversation resource. - */ - public static function projectConversationName(string $project, string $conversation): string - { - return self::getPathTemplate('projectConversation')->render([ - 'project' => $project, - 'conversation' => $conversation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_conversation_message resource. - * - * @param string $project - * @param string $conversation - * @param string $message - * - * @return string The formatted project_conversation_message resource. - */ - public static function projectConversationMessageName(string $project, string $conversation, string $message): string - { - return self::getPathTemplate('projectConversationMessage')->render([ - 'project' => $project, - 'conversation' => $conversation, - 'message' => $message, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_conversation_participant resource. - * - * @param string $project - * @param string $conversation - * @param string $participant - * - * @return string The formatted project_conversation_participant resource. - */ - public static function projectConversationParticipantName(string $project, string $conversation, string $participant): string - { - return self::getPathTemplate('projectConversationParticipant')->render([ - 'project' => $project, - 'conversation' => $conversation, - 'participant' => $participant, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_environment_user_session resource. - * - * @param string $project - * @param string $environment - * @param string $user - * @param string $session - * - * @return string The formatted project_environment_user_session resource. - */ - public static function projectEnvironmentUserSessionName(string $project, string $environment, string $user, string $session): string - { - return self::getPathTemplate('projectEnvironmentUserSession')->render([ - 'project' => $project, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_environment_user_session_context resource. - * - * @param string $project - * @param string $environment - * @param string $user - * @param string $session - * @param string $context - * - * @return string The formatted project_environment_user_session_context resource. - */ - public static function projectEnvironmentUserSessionContextName(string $project, string $environment, string $user, string $session, string $context): string - { - return self::getPathTemplate('projectEnvironmentUserSessionContext')->render([ - 'project' => $project, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_environment_user_session_entity_type resource. - * - * @param string $project - * @param string $environment - * @param string $user - * @param string $session - * @param string $entityType - * - * @return string The formatted project_environment_user_session_entity_type resource. - */ - public static function projectEnvironmentUserSessionEntityTypeName(string $project, string $environment, string $user, string $session, string $entityType): string - { - return self::getPathTemplate('projectEnvironmentUserSessionEntityType')->render([ - 'project' => $project, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_conversation resource. - * - * @param string $project - * @param string $location - * @param string $conversation - * - * @return string The formatted project_location_conversation resource. - */ - public static function projectLocationConversationName(string $project, string $location, string $conversation): string - { - return self::getPathTemplate('projectLocationConversation')->render([ - 'project' => $project, - 'location' => $location, - 'conversation' => $conversation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_conversation_message resource. - * - * @param string $project - * @param string $location - * @param string $conversation - * @param string $message - * - * @return string The formatted project_location_conversation_message resource. - */ - public static function projectLocationConversationMessageName(string $project, string $location, string $conversation, string $message): string - { - return self::getPathTemplate('projectLocationConversationMessage')->render([ - 'project' => $project, - 'location' => $location, - 'conversation' => $conversation, - 'message' => $message, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_conversation_participant resource. - * - * @param string $project - * @param string $location - * @param string $conversation - * @param string $participant - * - * @return string The formatted project_location_conversation_participant resource. - */ - public static function projectLocationConversationParticipantName(string $project, string $location, string $conversation, string $participant): string - { - return self::getPathTemplate('projectLocationConversationParticipant')->render([ - 'project' => $project, - 'location' => $location, - 'conversation' => $conversation, - 'participant' => $participant, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_environment_user_session resource. - * - * @param string $project - * @param string $location - * @param string $environment - * @param string $user - * @param string $session - * - * @return string The formatted project_location_environment_user_session resource. - */ - public static function projectLocationEnvironmentUserSessionName(string $project, string $location, string $environment, string $user, string $session): string - { - return self::getPathTemplate('projectLocationEnvironmentUserSession')->render([ - 'project' => $project, - 'location' => $location, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_environment_user_session_context resource. - * - * @param string $project - * @param string $location - * @param string $environment - * @param string $user - * @param string $session - * @param string $context - * - * @return string The formatted project_location_environment_user_session_context resource. - */ - public static function projectLocationEnvironmentUserSessionContextName(string $project, string $location, string $environment, string $user, string $session, string $context): string - { - return self::getPathTemplate('projectLocationEnvironmentUserSessionContext')->render([ - 'project' => $project, - 'location' => $location, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_environment_user_session_entity_type resource. - * - * @param string $project - * @param string $location - * @param string $environment - * @param string $user - * @param string $session - * @param string $entityType - * - * @return string The formatted project_location_environment_user_session_entity_type resource. - */ - public static function projectLocationEnvironmentUserSessionEntityTypeName(string $project, string $location, string $environment, string $user, string $session, string $entityType): string - { - return self::getPathTemplate('projectLocationEnvironmentUserSessionEntityType')->render([ - 'project' => $project, - 'location' => $location, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_session resource. - * - * @param string $project - * @param string $location - * @param string $session - * - * @return string The formatted project_location_session resource. - */ - public static function projectLocationSessionName(string $project, string $location, string $session): string - { - return self::getPathTemplate('projectLocationSession')->render([ - 'project' => $project, - 'location' => $location, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_session_context resource. - * - * @param string $project - * @param string $location - * @param string $session - * @param string $context - * - * @return string The formatted project_location_session_context resource. - */ - public static function projectLocationSessionContextName(string $project, string $location, string $session, string $context): string - { - return self::getPathTemplate('projectLocationSessionContext')->render([ - 'project' => $project, - 'location' => $location, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_session_entity_type resource. - * - * @param string $project - * @param string $location - * @param string $session - * @param string $entityType - * - * @return string The formatted project_location_session_entity_type resource. - */ - public static function projectLocationSessionEntityTypeName(string $project, string $location, string $session, string $entityType): string - { - return self::getPathTemplate('projectLocationSessionEntityType')->render([ - 'project' => $project, - 'location' => $location, - 'session' => $session, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_session resource. - * - * @param string $project - * @param string $session - * - * @return string The formatted project_session resource. - */ - public static function projectSessionName(string $project, string $session): string - { - return self::getPathTemplate('projectSession')->render([ - 'project' => $project, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_session_context resource. - * - * @param string $project - * @param string $session - * @param string $context - * - * @return string The formatted project_session_context resource. - */ - public static function projectSessionContextName(string $project, string $session, string $context): string - { - return self::getPathTemplate('projectSessionContext')->render([ - 'project' => $project, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_session_entity_type resource. - * - * @param string $project - * @param string $session - * @param string $entityType - * - * @return string The formatted project_session_entity_type resource. - */ - public static function projectSessionEntityTypeName(string $project, string $session, string $entityType): string - { - return self::getPathTemplate('projectSessionEntityType')->render([ - 'project' => $project, - 'session' => $session, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a session - * resource. - * - * @param string $project - * @param string $session - * - * @return string The formatted session resource. - */ - public static function sessionName(string $project, string $session): string - { - return self::getPathTemplate('session')->render([ - 'project' => $project, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * session_entity_type resource. - * - * @param string $project - * @param string $session - * @param string $entityType - * - * @return string The formatted session_entity_type resource. - */ - public static function sessionEntityTypeName(string $project, string $session, string $entityType): string - { - return self::getPathTemplate('sessionEntityType')->render([ - 'project' => $project, - 'session' => $session, - 'entity_type' => $entityType, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - context: projects/{project}/agent/sessions/{session}/contexts/{context} - * - conversation: projects/{project}/conversations/{conversation} - * - message: projects/{project}/conversations/{conversation}/messages/{message} - * - participant: projects/{project}/conversations/{conversation}/participants/{participant} - * - projectConversation: projects/{project}/conversations/{conversation} - * - projectConversationMessage: projects/{project}/conversations/{conversation}/messages/{message} - * - projectConversationParticipant: projects/{project}/conversations/{conversation}/participants/{participant} - * - projectEnvironmentUserSession: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session} - * - projectEnvironmentUserSessionContext: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context} - * - projectEnvironmentUserSessionEntityType: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}/entityTypes/{entity_type} - * - projectLocationConversation: projects/{project}/locations/{location}/conversations/{conversation} - * - projectLocationConversationMessage: projects/{project}/locations/{location}/conversations/{conversation}/messages/{message} - * - projectLocationConversationParticipant: projects/{project}/locations/{location}/conversations/{conversation}/participants/{participant} - * - projectLocationEnvironmentUserSession: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session} - * - projectLocationEnvironmentUserSessionContext: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context} - * - projectLocationEnvironmentUserSessionEntityType: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session}/entityTypes/{entity_type} - * - projectLocationSession: projects/{project}/locations/{location}/agent/sessions/{session} - * - projectLocationSessionContext: projects/{project}/locations/{location}/agent/sessions/{session}/contexts/{context} - * - projectLocationSessionEntityType: projects/{project}/locations/{location}/agent/sessions/{session}/entityTypes/{entity_type} - * - projectSession: projects/{project}/agent/sessions/{session} - * - projectSessionContext: projects/{project}/agent/sessions/{session}/contexts/{context} - * - projectSessionEntityType: projects/{project}/agent/sessions/{session}/entityTypes/{entity_type} - * - session: projects/{project}/agent/sessions/{session} - * - sessionEntityType: projects/{project}/agent/sessions/{session}/entityTypes/{entity_type} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dialogflow.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Adds a text (chat, for example), or audio (phone recording, for example) - * message from a participant into the conversation. - * - * Note: Always use agent versions for production traffic - * sent to virtual agents. See [Versions and - * environments](https://cloud.google.com/dialogflow/es/docs/agents-versions). - * - * The async variant is {@see self::analyzeContentAsync()} . - * - * @param AnalyzeContentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AnalyzeContentResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function analyzeContent(AnalyzeContentRequest $request, array $callOptions = []): AnalyzeContentResponse - { - return $this->startApiCall('AnalyzeContent', $request, $callOptions)->wait(); - } - - /** - * Creates a new participant in a conversation. - * - * The async variant is {@see self::createParticipantAsync()} . - * - * @param CreateParticipantRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Participant - * - * @throws ApiException Thrown if the API call fails. - */ - public function createParticipant(CreateParticipantRequest $request, array $callOptions = []): Participant - { - return $this->startApiCall('CreateParticipant', $request, $callOptions)->wait(); - } - - /** - * Retrieves a conversation participant. - * - * The async variant is {@see self::getParticipantAsync()} . - * - * @param GetParticipantRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Participant - * - * @throws ApiException Thrown if the API call fails. - */ - public function getParticipant(GetParticipantRequest $request, array $callOptions = []): Participant - { - return $this->startApiCall('GetParticipant', $request, $callOptions)->wait(); - } - - /** - * Returns the list of all participants in the specified conversation. - * - * The async variant is {@see self::listParticipantsAsync()} . - * - * @param ListParticipantsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listParticipants(ListParticipantsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListParticipants', $request, $callOptions); - } - - /** - * Adds a text (chat, for example), or audio (phone recording, for example) - * message from a participant into the conversation. - * Note: This method is only available through the gRPC API (not REST). - * - * The top-level message sent to the client by the server is - * `StreamingAnalyzeContentResponse`. Multiple response messages can be - * returned in order. The first one or more messages contain the - * `recognition_result` field. Each result represents a more complete - * transcript of what the user said. The next message contains the - * `reply_text` field and potentially the `reply_audio` field. The message can - * also contain the `automated_agent_reply` field. - * - * Note: Always use agent versions for production traffic - * sent to virtual agents. See [Versions and - * environments](https://cloud.google.com/dialogflow/es/docs/agents-versions). - * - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return BidiStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function streamingAnalyzeContent(array $callOptions = []): BidiStream - { - return $this->startApiCall('StreamingAnalyzeContent', null, $callOptions); - } - - /** - * Gets suggested articles for a participant based on specific historical - * messages. - * - * The async variant is {@see self::suggestArticlesAsync()} . - * - * @param SuggestArticlesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SuggestArticlesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function suggestArticles(SuggestArticlesRequest $request, array $callOptions = []): SuggestArticlesResponse - { - return $this->startApiCall('SuggestArticles', $request, $callOptions)->wait(); - } - - /** - * Gets suggested faq answers for a participant based on specific historical - * messages. - * - * The async variant is {@see self::suggestFaqAnswersAsync()} . - * - * @param SuggestFaqAnswersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SuggestFaqAnswersResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function suggestFaqAnswers(SuggestFaqAnswersRequest $request, array $callOptions = []): SuggestFaqAnswersResponse - { - return $this->startApiCall('SuggestFaqAnswers', $request, $callOptions)->wait(); - } - - /** - * Gets smart replies for a participant based on specific historical - * messages. - * - * The async variant is {@see self::suggestSmartRepliesAsync()} . - * - * @param SuggestSmartRepliesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SuggestSmartRepliesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function suggestSmartReplies(SuggestSmartRepliesRequest $request, array $callOptions = []): SuggestSmartRepliesResponse - { - return $this->startApiCall('SuggestSmartReplies', $request, $callOptions)->wait(); - } - - /** - * Updates the specified participant. - * - * The async variant is {@see self::updateParticipantAsync()} . - * - * @param UpdateParticipantRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Participant - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateParticipant(UpdateParticipantRequest $request, array $callOptions = []): Participant - { - return $this->startApiCall('UpdateParticipant', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dialogflow/src/V2/Client/BaseClient/SessionEntityTypesBaseClient.php b/Dialogflow/src/V2/Client/BaseClient/SessionEntityTypesBaseClient.php deleted file mode 100644 index 00bb3b2bf189..000000000000 --- a/Dialogflow/src/V2/Client/BaseClient/SessionEntityTypesBaseClient.php +++ /dev/null @@ -1,613 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/session_entity_types_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/session_entity_types_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/session_entity_types_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/session_entity_types_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_environment_user_session resource. - * - * @param string $project - * @param string $environment - * @param string $user - * @param string $session - * - * @return string The formatted project_environment_user_session resource. - */ - public static function projectEnvironmentUserSessionName(string $project, string $environment, string $user, string $session): string - { - return self::getPathTemplate('projectEnvironmentUserSession')->render([ - 'project' => $project, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_environment_user_session_entity_type resource. - * - * @param string $project - * @param string $environment - * @param string $user - * @param string $session - * @param string $entityType - * - * @return string The formatted project_environment_user_session_entity_type resource. - */ - public static function projectEnvironmentUserSessionEntityTypeName(string $project, string $environment, string $user, string $session, string $entityType): string - { - return self::getPathTemplate('projectEnvironmentUserSessionEntityType')->render([ - 'project' => $project, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_environment_user_session resource. - * - * @param string $project - * @param string $location - * @param string $environment - * @param string $user - * @param string $session - * - * @return string The formatted project_location_environment_user_session resource. - */ - public static function projectLocationEnvironmentUserSessionName(string $project, string $location, string $environment, string $user, string $session): string - { - return self::getPathTemplate('projectLocationEnvironmentUserSession')->render([ - 'project' => $project, - 'location' => $location, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_environment_user_session_entity_type resource. - * - * @param string $project - * @param string $location - * @param string $environment - * @param string $user - * @param string $session - * @param string $entityType - * - * @return string The formatted project_location_environment_user_session_entity_type resource. - */ - public static function projectLocationEnvironmentUserSessionEntityTypeName(string $project, string $location, string $environment, string $user, string $session, string $entityType): string - { - return self::getPathTemplate('projectLocationEnvironmentUserSessionEntityType')->render([ - 'project' => $project, - 'location' => $location, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_session resource. - * - * @param string $project - * @param string $location - * @param string $session - * - * @return string The formatted project_location_session resource. - */ - public static function projectLocationSessionName(string $project, string $location, string $session): string - { - return self::getPathTemplate('projectLocationSession')->render([ - 'project' => $project, - 'location' => $location, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_session_entity_type resource. - * - * @param string $project - * @param string $location - * @param string $session - * @param string $entityType - * - * @return string The formatted project_location_session_entity_type resource. - */ - public static function projectLocationSessionEntityTypeName(string $project, string $location, string $session, string $entityType): string - { - return self::getPathTemplate('projectLocationSessionEntityType')->render([ - 'project' => $project, - 'location' => $location, - 'session' => $session, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_session resource. - * - * @param string $project - * @param string $session - * - * @return string The formatted project_session resource. - */ - public static function projectSessionName(string $project, string $session): string - { - return self::getPathTemplate('projectSession')->render([ - 'project' => $project, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_session_entity_type resource. - * - * @param string $project - * @param string $session - * @param string $entityType - * - * @return string The formatted project_session_entity_type resource. - */ - public static function projectSessionEntityTypeName(string $project, string $session, string $entityType): string - { - return self::getPathTemplate('projectSessionEntityType')->render([ - 'project' => $project, - 'session' => $session, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a session - * resource. - * - * @param string $project - * @param string $session - * - * @return string The formatted session resource. - */ - public static function sessionName(string $project, string $session): string - { - return self::getPathTemplate('session')->render([ - 'project' => $project, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * session_entity_type resource. - * - * @param string $project - * @param string $session - * @param string $entityType - * - * @return string The formatted session_entity_type resource. - */ - public static function sessionEntityTypeName(string $project, string $session, string $entityType): string - { - return self::getPathTemplate('sessionEntityType')->render([ - 'project' => $project, - 'session' => $session, - 'entity_type' => $entityType, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - projectEnvironmentUserSession: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session} - * - projectEnvironmentUserSessionEntityType: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}/entityTypes/{entity_type} - * - projectLocationEnvironmentUserSession: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session} - * - projectLocationEnvironmentUserSessionEntityType: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session}/entityTypes/{entity_type} - * - projectLocationSession: projects/{project}/locations/{location}/agent/sessions/{session} - * - projectLocationSessionEntityType: projects/{project}/locations/{location}/agent/sessions/{session}/entityTypes/{entity_type} - * - projectSession: projects/{project}/agent/sessions/{session} - * - projectSessionEntityType: projects/{project}/agent/sessions/{session}/entityTypes/{entity_type} - * - session: projects/{project}/agent/sessions/{session} - * - sessionEntityType: projects/{project}/agent/sessions/{session}/entityTypes/{entity_type} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dialogflow.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a session entity type. - * - * If the specified session entity type already exists, overrides the session - * entity type. - * - * This method doesn't work with Google Assistant integration. - * Contact Dialogflow support if you need to use session entities - * with Google Assistant integration. - * - * The async variant is {@see self::createSessionEntityTypeAsync()} . - * - * @param CreateSessionEntityTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SessionEntityType - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSessionEntityType(CreateSessionEntityTypeRequest $request, array $callOptions = []): SessionEntityType - { - return $this->startApiCall('CreateSessionEntityType', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified session entity type. - * - * This method doesn't work with Google Assistant integration. - * Contact Dialogflow support if you need to use session entities - * with Google Assistant integration. - * - * The async variant is {@see self::deleteSessionEntityTypeAsync()} . - * - * @param DeleteSessionEntityTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSessionEntityType(DeleteSessionEntityTypeRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteSessionEntityType', $request, $callOptions)->wait(); - } - - /** - * Retrieves the specified session entity type. - * - * This method doesn't work with Google Assistant integration. - * Contact Dialogflow support if you need to use session entities - * with Google Assistant integration. - * - * The async variant is {@see self::getSessionEntityTypeAsync()} . - * - * @param GetSessionEntityTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SessionEntityType - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSessionEntityType(GetSessionEntityTypeRequest $request, array $callOptions = []): SessionEntityType - { - return $this->startApiCall('GetSessionEntityType', $request, $callOptions)->wait(); - } - - /** - * Returns the list of all session entity types in the specified session. - * - * This method doesn't work with Google Assistant integration. - * Contact Dialogflow support if you need to use session entities - * with Google Assistant integration. - * - * The async variant is {@see self::listSessionEntityTypesAsync()} . - * - * @param ListSessionEntityTypesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSessionEntityTypes(ListSessionEntityTypesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSessionEntityTypes', $request, $callOptions); - } - - /** - * Updates the specified session entity type. - * - * This method doesn't work with Google Assistant integration. - * Contact Dialogflow support if you need to use session entities - * with Google Assistant integration. - * - * The async variant is {@see self::updateSessionEntityTypeAsync()} . - * - * @param UpdateSessionEntityTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SessionEntityType - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSessionEntityType(UpdateSessionEntityTypeRequest $request, array $callOptions = []): SessionEntityType - { - return $this->startApiCall('UpdateSessionEntityType', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dialogflow/src/V2/Client/BaseClient/SessionsBaseClient.php b/Dialogflow/src/V2/Client/BaseClient/SessionsBaseClient.php deleted file mode 100644 index 22c6a7be9bf2..000000000000 --- a/Dialogflow/src/V2/Client/BaseClient/SessionsBaseClient.php +++ /dev/null @@ -1,648 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/sessions_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/sessions_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/sessions_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/sessions_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a context - * resource. - * - * @param string $project - * @param string $session - * @param string $context - * - * @return string The formatted context resource. - */ - public static function contextName(string $project, string $session, string $context): string - { - return self::getPathTemplate('context')->render([ - 'project' => $project, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_environment_user_session resource. - * - * @param string $project - * @param string $environment - * @param string $user - * @param string $session - * - * @return string The formatted project_environment_user_session resource. - */ - public static function projectEnvironmentUserSessionName(string $project, string $environment, string $user, string $session): string - { - return self::getPathTemplate('projectEnvironmentUserSession')->render([ - 'project' => $project, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_environment_user_session_context resource. - * - * @param string $project - * @param string $environment - * @param string $user - * @param string $session - * @param string $context - * - * @return string The formatted project_environment_user_session_context resource. - */ - public static function projectEnvironmentUserSessionContextName(string $project, string $environment, string $user, string $session, string $context): string - { - return self::getPathTemplate('projectEnvironmentUserSessionContext')->render([ - 'project' => $project, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_environment_user_session_entity_type resource. - * - * @param string $project - * @param string $environment - * @param string $user - * @param string $session - * @param string $entityType - * - * @return string The formatted project_environment_user_session_entity_type resource. - */ - public static function projectEnvironmentUserSessionEntityTypeName(string $project, string $environment, string $user, string $session, string $entityType): string - { - return self::getPathTemplate('projectEnvironmentUserSessionEntityType')->render([ - 'project' => $project, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_environment_user_session resource. - * - * @param string $project - * @param string $location - * @param string $environment - * @param string $user - * @param string $session - * - * @return string The formatted project_location_environment_user_session resource. - */ - public static function projectLocationEnvironmentUserSessionName(string $project, string $location, string $environment, string $user, string $session): string - { - return self::getPathTemplate('projectLocationEnvironmentUserSession')->render([ - 'project' => $project, - 'location' => $location, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_environment_user_session_context resource. - * - * @param string $project - * @param string $location - * @param string $environment - * @param string $user - * @param string $session - * @param string $context - * - * @return string The formatted project_location_environment_user_session_context resource. - */ - public static function projectLocationEnvironmentUserSessionContextName(string $project, string $location, string $environment, string $user, string $session, string $context): string - { - return self::getPathTemplate('projectLocationEnvironmentUserSessionContext')->render([ - 'project' => $project, - 'location' => $location, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_environment_user_session_entity_type resource. - * - * @param string $project - * @param string $location - * @param string $environment - * @param string $user - * @param string $session - * @param string $entityType - * - * @return string The formatted project_location_environment_user_session_entity_type resource. - */ - public static function projectLocationEnvironmentUserSessionEntityTypeName(string $project, string $location, string $environment, string $user, string $session, string $entityType): string - { - return self::getPathTemplate('projectLocationEnvironmentUserSessionEntityType')->render([ - 'project' => $project, - 'location' => $location, - 'environment' => $environment, - 'user' => $user, - 'session' => $session, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_session resource. - * - * @param string $project - * @param string $location - * @param string $session - * - * @return string The formatted project_location_session resource. - */ - public static function projectLocationSessionName(string $project, string $location, string $session): string - { - return self::getPathTemplate('projectLocationSession')->render([ - 'project' => $project, - 'location' => $location, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_session_context resource. - * - * @param string $project - * @param string $location - * @param string $session - * @param string $context - * - * @return string The formatted project_location_session_context resource. - */ - public static function projectLocationSessionContextName(string $project, string $location, string $session, string $context): string - { - return self::getPathTemplate('projectLocationSessionContext')->render([ - 'project' => $project, - 'location' => $location, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_session_entity_type resource. - * - * @param string $project - * @param string $location - * @param string $session - * @param string $entityType - * - * @return string The formatted project_location_session_entity_type resource. - */ - public static function projectLocationSessionEntityTypeName(string $project, string $location, string $session, string $entityType): string - { - return self::getPathTemplate('projectLocationSessionEntityType')->render([ - 'project' => $project, - 'location' => $location, - 'session' => $session, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_session resource. - * - * @param string $project - * @param string $session - * - * @return string The formatted project_session resource. - */ - public static function projectSessionName(string $project, string $session): string - { - return self::getPathTemplate('projectSession')->render([ - 'project' => $project, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_session_context resource. - * - * @param string $project - * @param string $session - * @param string $context - * - * @return string The formatted project_session_context resource. - */ - public static function projectSessionContextName(string $project, string $session, string $context): string - { - return self::getPathTemplate('projectSessionContext')->render([ - 'project' => $project, - 'session' => $session, - 'context' => $context, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_session_entity_type resource. - * - * @param string $project - * @param string $session - * @param string $entityType - * - * @return string The formatted project_session_entity_type resource. - */ - public static function projectSessionEntityTypeName(string $project, string $session, string $entityType): string - { - return self::getPathTemplate('projectSessionEntityType')->render([ - 'project' => $project, - 'session' => $session, - 'entity_type' => $entityType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a session - * resource. - * - * @param string $project - * @param string $session - * - * @return string The formatted session resource. - */ - public static function sessionName(string $project, string $session): string - { - return self::getPathTemplate('session')->render([ - 'project' => $project, - 'session' => $session, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * session_entity_type resource. - * - * @param string $project - * @param string $session - * @param string $entityType - * - * @return string The formatted session_entity_type resource. - */ - public static function sessionEntityTypeName(string $project, string $session, string $entityType): string - { - return self::getPathTemplate('sessionEntityType')->render([ - 'project' => $project, - 'session' => $session, - 'entity_type' => $entityType, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - context: projects/{project}/agent/sessions/{session}/contexts/{context} - * - projectEnvironmentUserSession: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session} - * - projectEnvironmentUserSessionContext: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context} - * - projectEnvironmentUserSessionEntityType: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}/entityTypes/{entity_type} - * - projectLocationEnvironmentUserSession: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session} - * - projectLocationEnvironmentUserSessionContext: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context} - * - projectLocationEnvironmentUserSessionEntityType: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session}/entityTypes/{entity_type} - * - projectLocationSession: projects/{project}/locations/{location}/agent/sessions/{session} - * - projectLocationSessionContext: projects/{project}/locations/{location}/agent/sessions/{session}/contexts/{context} - * - projectLocationSessionEntityType: projects/{project}/locations/{location}/agent/sessions/{session}/entityTypes/{entity_type} - * - projectSession: projects/{project}/agent/sessions/{session} - * - projectSessionContext: projects/{project}/agent/sessions/{session}/contexts/{context} - * - projectSessionEntityType: projects/{project}/agent/sessions/{session}/entityTypes/{entity_type} - * - session: projects/{project}/agent/sessions/{session} - * - sessionEntityType: projects/{project}/agent/sessions/{session}/entityTypes/{entity_type} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dialogflow.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Processes a natural language query and returns structured, actionable data - * as a result. This method is not idempotent, because it may cause contexts - * and session entity types to be updated, which in turn might affect - * results of future queries. - * - * If you might use - * [Agent Assist](https://cloud.google.com/dialogflow/docs/#aa) - * or other CCAI products now or in the future, consider using - * [AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent] - * instead of `DetectIntent`. `AnalyzeContent` has additional - * functionality for Agent Assist and other CCAI products. - * - * Note: Always use agent versions for production traffic. - * See [Versions and - * environments](https://cloud.google.com/dialogflow/es/docs/agents-versions). - * - * The async variant is {@see self::detectIntentAsync()} . - * - * @param DetectIntentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DetectIntentResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function detectIntent(DetectIntentRequest $request, array $callOptions = []): DetectIntentResponse - { - return $this->startApiCall('DetectIntent', $request, $callOptions)->wait(); - } - - /** - * Processes a natural language query in audio format in a streaming fashion - * and returns structured, actionable data as a result. This method is only - * available via the gRPC API (not REST). - * - * If you might use - * [Agent Assist](https://cloud.google.com/dialogflow/docs/#aa) - * or other CCAI products now or in the future, consider using - * [StreamingAnalyzeContent][google.cloud.dialogflow.v2.Participants.StreamingAnalyzeContent] - * instead of `StreamingDetectIntent`. `StreamingAnalyzeContent` has - * additional functionality for Agent Assist and other CCAI products. - * - * Note: Always use agent versions for production traffic. - * See [Versions and - * environments](https://cloud.google.com/dialogflow/es/docs/agents-versions). - * - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return BidiStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function streamingDetectIntent(array $callOptions = []): BidiStream - { - return $this->startApiCall('StreamingDetectIntent', null, $callOptions); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dialogflow/src/V2/Client/BaseClient/VersionsBaseClient.php b/Dialogflow/src/V2/Client/BaseClient/VersionsBaseClient.php deleted file mode 100644 index 53f5fac6362b..000000000000 --- a/Dialogflow/src/V2/Client/BaseClient/VersionsBaseClient.php +++ /dev/null @@ -1,486 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/versions_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/versions_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/versions_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/versions_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a agent - * resource. - * - * @param string $project - * - * @return string The formatted agent resource. - */ - public static function agentName(string $project): string - { - return self::getPathTemplate('agent')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_agent resource. - * - * @param string $project - * - * @return string The formatted project_agent resource. - */ - public static function projectAgentName(string $project): string - { - return self::getPathTemplate('projectAgent')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_agent resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted project_location_agent resource. - */ - public static function projectLocationAgentName(string $project, string $location): string - { - return self::getPathTemplate('projectLocationAgent')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_version resource. - * - * @param string $project - * @param string $location - * @param string $version - * - * @return string The formatted project_location_version resource. - */ - public static function projectLocationVersionName(string $project, string $location, string $version): string - { - return self::getPathTemplate('projectLocationVersion')->render([ - 'project' => $project, - 'location' => $location, - 'version' => $version, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_version resource. - * - * @param string $project - * @param string $version - * - * @return string The formatted project_version resource. - */ - public static function projectVersionName(string $project, string $version): string - { - return self::getPathTemplate('projectVersion')->render([ - 'project' => $project, - 'version' => $version, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a version - * resource. - * - * @param string $project - * @param string $version - * - * @return string The formatted version resource. - */ - public static function versionName(string $project, string $version): string - { - return self::getPathTemplate('version')->render([ - 'project' => $project, - 'version' => $version, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - agent: projects/{project}/agent - * - projectAgent: projects/{project}/agent - * - projectLocationAgent: projects/{project}/locations/{location}/agent - * - projectLocationVersion: projects/{project}/locations/{location}/agent/versions/{version} - * - projectVersion: projects/{project}/agent/versions/{version} - * - version: projects/{project}/agent/versions/{version} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dialogflow.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates an agent version. - * - * The new version points to the agent instance in the "default" environment. - * - * The async variant is {@see self::createVersionAsync()} . - * - * @param CreateVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Version - * - * @throws ApiException Thrown if the API call fails. - */ - public function createVersion(CreateVersionRequest $request, array $callOptions = []): Version - { - return $this->startApiCall('CreateVersion', $request, $callOptions)->wait(); - } - - /** - * Delete the specified agent version. - * - * The async variant is {@see self::deleteVersionAsync()} . - * - * @param DeleteVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteVersion(DeleteVersionRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteVersion', $request, $callOptions)->wait(); - } - - /** - * Retrieves the specified agent version. - * - * The async variant is {@see self::getVersionAsync()} . - * - * @param GetVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Version - * - * @throws ApiException Thrown if the API call fails. - */ - public function getVersion(GetVersionRequest $request, array $callOptions = []): Version - { - return $this->startApiCall('GetVersion', $request, $callOptions)->wait(); - } - - /** - * Returns the list of all versions of the specified agent. - * - * The async variant is {@see self::listVersionsAsync()} . - * - * @param ListVersionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listVersions(ListVersionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListVersions', $request, $callOptions); - } - - /** - * Updates the specified agent version. - * - * Note that this method does not allow you to update the state of the agent - * the given version points to. It allows you to update only mutable - * properties of the version resource. - * - * The async variant is {@see self::updateVersionAsync()} . - * - * @param UpdateVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Version - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateVersion(UpdateVersionRequest $request, array $callOptions = []): Version - { - return $this->startApiCall('UpdateVersion', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Dialogflow/src/V2/Client/ContextsClient.php b/Dialogflow/src/V2/Client/ContextsClient.php index 60ef14d747b8..42464d3107fa 100644 --- a/Dialogflow/src/V2/Client/ContextsClient.php +++ b/Dialogflow/src/V2/Client/ContextsClient.php @@ -24,17 +24,589 @@ namespace Google\Cloud\Dialogflow\V2\Client; -use Google\Cloud\Dialogflow\V2\Client\BaseClient\ContextsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dialogflow\V2\Context; +use Google\Cloud\Dialogflow\V2\CreateContextRequest; +use Google\Cloud\Dialogflow\V2\DeleteAllContextsRequest; +use Google\Cloud\Dialogflow\V2\DeleteContextRequest; +use Google\Cloud\Dialogflow\V2\GetContextRequest; +use Google\Cloud\Dialogflow\V2\ListContextsRequest; +use Google\Cloud\Dialogflow\V2\UpdateContextRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for managing [Contexts][google.cloud.dialogflow.v2.Context]. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dialogflow\V2\ContextsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createContextAsync(CreateContextRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAllContextsAsync(DeleteAllContextsRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteContextAsync(DeleteContextRequest $request, array $optionalArgs = []) + * @method PromiseInterface getContextAsync(GetContextRequest $request, array $optionalArgs = []) + * @method PromiseInterface listContextsAsync(ListContextsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateContextAsync(UpdateContextRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class ContextsClient extends ContextsBaseClient +final class ContextsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ContextsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dialogflow.v2.Contexts'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/dialogflow', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/contexts_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/contexts_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/contexts_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/contexts_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a context + * resource. + * + * @param string $project + * @param string $session + * @param string $context + * + * @return string The formatted context resource. + */ + public static function contextName(string $project, string $session, string $context): string + { + return self::getPathTemplate('context')->render([ + 'project' => $project, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_environment_user_session resource. + * + * @param string $project + * @param string $environment + * @param string $user + * @param string $session + * + * @return string The formatted project_environment_user_session resource. + */ + public static function projectEnvironmentUserSessionName(string $project, string $environment, string $user, string $session): string + { + return self::getPathTemplate('projectEnvironmentUserSession')->render([ + 'project' => $project, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_environment_user_session_context resource. + * + * @param string $project + * @param string $environment + * @param string $user + * @param string $session + * @param string $context + * + * @return string The formatted project_environment_user_session_context resource. + */ + public static function projectEnvironmentUserSessionContextName(string $project, string $environment, string $user, string $session, string $context): string + { + return self::getPathTemplate('projectEnvironmentUserSessionContext')->render([ + 'project' => $project, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_environment_user_session resource. + * + * @param string $project + * @param string $location + * @param string $environment + * @param string $user + * @param string $session + * + * @return string The formatted project_location_environment_user_session resource. + */ + public static function projectLocationEnvironmentUserSessionName(string $project, string $location, string $environment, string $user, string $session): string + { + return self::getPathTemplate('projectLocationEnvironmentUserSession')->render([ + 'project' => $project, + 'location' => $location, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_environment_user_session_context resource. + * + * @param string $project + * @param string $location + * @param string $environment + * @param string $user + * @param string $session + * @param string $context + * + * @return string The formatted project_location_environment_user_session_context resource. + */ + public static function projectLocationEnvironmentUserSessionContextName(string $project, string $location, string $environment, string $user, string $session, string $context): string + { + return self::getPathTemplate('projectLocationEnvironmentUserSessionContext')->render([ + 'project' => $project, + 'location' => $location, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_session resource. + * + * @param string $project + * @param string $location + * @param string $session + * + * @return string The formatted project_location_session resource. + */ + public static function projectLocationSessionName(string $project, string $location, string $session): string + { + return self::getPathTemplate('projectLocationSession')->render([ + 'project' => $project, + 'location' => $location, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_session_context resource. + * + * @param string $project + * @param string $location + * @param string $session + * @param string $context + * + * @return string The formatted project_location_session_context resource. + */ + public static function projectLocationSessionContextName(string $project, string $location, string $session, string $context): string + { + return self::getPathTemplate('projectLocationSessionContext')->render([ + 'project' => $project, + 'location' => $location, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_session resource. + * + * @param string $project + * @param string $session + * + * @return string The formatted project_session resource. + */ + public static function projectSessionName(string $project, string $session): string + { + return self::getPathTemplate('projectSession')->render([ + 'project' => $project, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_session_context resource. + * + * @param string $project + * @param string $session + * @param string $context + * + * @return string The formatted project_session_context resource. + */ + public static function projectSessionContextName(string $project, string $session, string $context): string + { + return self::getPathTemplate('projectSessionContext')->render([ + 'project' => $project, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a session + * resource. + * + * @param string $project + * @param string $session + * + * @return string The formatted session resource. + */ + public static function sessionName(string $project, string $session): string + { + return self::getPathTemplate('session')->render([ + 'project' => $project, + 'session' => $session, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - context: projects/{project}/agent/sessions/{session}/contexts/{context} + * - projectEnvironmentUserSession: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session} + * - projectEnvironmentUserSessionContext: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context} + * - projectLocationEnvironmentUserSession: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session} + * - projectLocationEnvironmentUserSessionContext: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context} + * - projectLocationSession: projects/{project}/locations/{location}/agent/sessions/{session} + * - projectLocationSessionContext: projects/{project}/locations/{location}/agent/sessions/{session}/contexts/{context} + * - projectSession: projects/{project}/agent/sessions/{session} + * - projectSessionContext: projects/{project}/agent/sessions/{session}/contexts/{context} + * - session: projects/{project}/agent/sessions/{session} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dialogflow.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a context. + * + * If the specified context already exists, overrides the context. + * + * The async variant is {@see ContextsClient::createContextAsync()} . + * + * @param CreateContextRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Context + * + * @throws ApiException Thrown if the API call fails. + */ + public function createContext(CreateContextRequest $request, array $callOptions = []): Context + { + return $this->startApiCall('CreateContext', $request, $callOptions)->wait(); + } + + /** + * Deletes all active contexts in the specified session. + * + * The async variant is {@see ContextsClient::deleteAllContextsAsync()} . + * + * @param DeleteAllContextsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAllContexts(DeleteAllContextsRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteAllContexts', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified context. + * + * The async variant is {@see ContextsClient::deleteContextAsync()} . + * + * @param DeleteContextRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteContext(DeleteContextRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteContext', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified context. + * + * The async variant is {@see ContextsClient::getContextAsync()} . + * + * @param GetContextRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Context + * + * @throws ApiException Thrown if the API call fails. + */ + public function getContext(GetContextRequest $request, array $callOptions = []): Context + { + return $this->startApiCall('GetContext', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all contexts in the specified session. + * + * The async variant is {@see ContextsClient::listContextsAsync()} . + * + * @param ListContextsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listContexts(ListContextsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListContexts', $request, $callOptions); + } + + /** + * Updates the specified context. + * + * The async variant is {@see ContextsClient::updateContextAsync()} . + * + * @param UpdateContextRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Context + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateContext(UpdateContextRequest $request, array $callOptions = []): Context + { + return $this->startApiCall('UpdateContext', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see ContextsClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see ContextsClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Dialogflow/src/V2/Client/ConversationDatasetsClient.php b/Dialogflow/src/V2/Client/ConversationDatasetsClient.php index 5e88b4cdfd5e..b9b084fde1a9 100644 --- a/Dialogflow/src/V2/Client/ConversationDatasetsClient.php +++ b/Dialogflow/src/V2/Client/ConversationDatasetsClient.php @@ -24,17 +24,467 @@ namespace Google\Cloud\Dialogflow\V2\Client; -use Google\Cloud\Dialogflow\V2\Client\BaseClient\ConversationDatasetsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dialogflow\V2\ConversationDataset; +use Google\Cloud\Dialogflow\V2\CreateConversationDatasetOperationMetadata; +use Google\Cloud\Dialogflow\V2\CreateConversationDatasetRequest; +use Google\Cloud\Dialogflow\V2\DeleteConversationDatasetOperationMetadata; +use Google\Cloud\Dialogflow\V2\DeleteConversationDatasetRequest; +use Google\Cloud\Dialogflow\V2\GetConversationDatasetRequest; +use Google\Cloud\Dialogflow\V2\ImportConversationDataOperationMetadata; +use Google\Cloud\Dialogflow\V2\ImportConversationDataOperationResponse; +use Google\Cloud\Dialogflow\V2\ImportConversationDataRequest; +use Google\Cloud\Dialogflow\V2\ListConversationDatasetsRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Conversation datasets. * - * This class is currently experimental and may be subject to changes. + * Conversation datasets contain raw conversation files and their + * customizable metadata that can be used for model training. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dialogflow\V2\ConversationDatasetsClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createConversationDatasetAsync(CreateConversationDatasetRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteConversationDatasetAsync(DeleteConversationDatasetRequest $request, array $optionalArgs = []) + * @method PromiseInterface getConversationDatasetAsync(GetConversationDatasetRequest $request, array $optionalArgs = []) + * @method PromiseInterface importConversationDataAsync(ImportConversationDataRequest $request, array $optionalArgs = []) + * @method PromiseInterface listConversationDatasetsAsync(ListConversationDatasetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class ConversationDatasetsClient extends ConversationDatasetsBaseClient +final class ConversationDatasetsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ConversationDatasetsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dialogflow.v2.ConversationDatasets'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/dialogflow', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/conversation_datasets_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/conversation_datasets_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/conversation_datasets_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/conversation_datasets_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * conversation_dataset resource. + * + * @param string $project + * @param string $location + * @param string $conversationDataset + * + * @return string The formatted conversation_dataset resource. + */ + public static function conversationDatasetName(string $project, string $location, string $conversationDataset): string + { + return self::getPathTemplate('conversationDataset')->render([ + 'project' => $project, + 'location' => $location, + 'conversation_dataset' => $conversationDataset, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - conversationDataset: projects/{project}/locations/{location}/conversationDatasets/{conversation_dataset} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dialogflow.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new conversation dataset. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [CreateConversationDatasetOperationMetadata][google.cloud.dialogflow.v2.CreateConversationDatasetOperationMetadata] + * - `response`: + * [ConversationDataset][google.cloud.dialogflow.v2.ConversationDataset] + * + * The async variant is + * {@see ConversationDatasetsClient::createConversationDatasetAsync()} . + * + * @param CreateConversationDatasetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createConversationDataset(CreateConversationDatasetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateConversationDataset', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified conversation dataset. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [DeleteConversationDatasetOperationMetadata][google.cloud.dialogflow.v2.DeleteConversationDatasetOperationMetadata] + * - `response`: An [Empty + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) + * + * The async variant is + * {@see ConversationDatasetsClient::deleteConversationDatasetAsync()} . + * + * @param DeleteConversationDatasetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteConversationDataset(DeleteConversationDatasetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteConversationDataset', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified conversation dataset. + * + * The async variant is + * {@see ConversationDatasetsClient::getConversationDatasetAsync()} . + * + * @param GetConversationDatasetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ConversationDataset + * + * @throws ApiException Thrown if the API call fails. + */ + public function getConversationDataset(GetConversationDatasetRequest $request, array $callOptions = []): ConversationDataset + { + return $this->startApiCall('GetConversationDataset', $request, $callOptions)->wait(); + } + + /** + * Import data into the specified conversation dataset. Note that it + * is not allowed to import data to a conversation dataset that + * already has data in it. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [ImportConversationDataOperationMetadata][google.cloud.dialogflow.v2.ImportConversationDataOperationMetadata] + * - `response`: + * [ImportConversationDataOperationResponse][google.cloud.dialogflow.v2.ImportConversationDataOperationResponse] + * + * The async variant is + * {@see ConversationDatasetsClient::importConversationDataAsync()} . + * + * @param ImportConversationDataRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importConversationData(ImportConversationDataRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportConversationData', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all conversation datasets in the specified + * project and location. + * + * The async variant is + * {@see ConversationDatasetsClient::listConversationDatasetsAsync()} . + * + * @param ListConversationDatasetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listConversationDatasets(ListConversationDatasetsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListConversationDatasets', $request, $callOptions); + } + + /** + * Gets information about a location. + * + * The async variant is {@see ConversationDatasetsClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see ConversationDatasetsClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Dialogflow/src/V2/Client/ConversationModelsClient.php b/Dialogflow/src/V2/Client/ConversationModelsClient.php index 515f930cbbee..f103bcaed80c 100644 --- a/Dialogflow/src/V2/Client/ConversationModelsClient.php +++ b/Dialogflow/src/V2/Client/ConversationModelsClient.php @@ -24,17 +24,749 @@ namespace Google\Cloud\Dialogflow\V2\Client; -use Google\Cloud\Dialogflow\V2\Client\BaseClient\ConversationModelsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dialogflow\V2\ConversationModel; +use Google\Cloud\Dialogflow\V2\ConversationModelEvaluation; +use Google\Cloud\Dialogflow\V2\CreateConversationModelEvaluationRequest; +use Google\Cloud\Dialogflow\V2\CreateConversationModelOperationMetadata; +use Google\Cloud\Dialogflow\V2\CreateConversationModelRequest; +use Google\Cloud\Dialogflow\V2\DeleteConversationModelOperationMetadata; +use Google\Cloud\Dialogflow\V2\DeleteConversationModelRequest; +use Google\Cloud\Dialogflow\V2\DeployConversationModelOperationMetadata; +use Google\Cloud\Dialogflow\V2\DeployConversationModelRequest; +use Google\Cloud\Dialogflow\V2\GetConversationModelEvaluationRequest; +use Google\Cloud\Dialogflow\V2\GetConversationModelRequest; +use Google\Cloud\Dialogflow\V2\ListConversationModelEvaluationsRequest; +use Google\Cloud\Dialogflow\V2\ListConversationModelsRequest; +use Google\Cloud\Dialogflow\V2\UndeployConversationModelOperationMetadata; +use Google\Cloud\Dialogflow\V2\UndeployConversationModelRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Manages a collection of models for human agent assistant. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dialogflow\V2\ConversationModelsClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createConversationModelAsync(CreateConversationModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface createConversationModelEvaluationAsync(CreateConversationModelEvaluationRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteConversationModelAsync(DeleteConversationModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface deployConversationModelAsync(DeployConversationModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface getConversationModelAsync(GetConversationModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface getConversationModelEvaluationAsync(GetConversationModelEvaluationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listConversationModelEvaluationsAsync(ListConversationModelEvaluationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listConversationModelsAsync(ListConversationModelsRequest $request, array $optionalArgs = []) + * @method PromiseInterface undeployConversationModelAsync(UndeployConversationModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class ConversationModelsClient extends ConversationModelsBaseClient +final class ConversationModelsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ConversationModelsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dialogflow.v2.ConversationModels'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/dialogflow', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/conversation_models_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/conversation_models_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/conversation_models_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/conversation_models_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * conversation_dataset resource. + * + * @param string $project + * @param string $location + * @param string $conversationDataset + * + * @return string The formatted conversation_dataset resource. + */ + public static function conversationDatasetName(string $project, string $location, string $conversationDataset): string + { + return self::getPathTemplate('conversationDataset')->render([ + 'project' => $project, + 'location' => $location, + 'conversation_dataset' => $conversationDataset, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * conversation_model resource. + * + * @param string $project + * @param string $location + * @param string $conversationModel + * + * @return string The formatted conversation_model resource. + */ + public static function conversationModelName(string $project, string $location, string $conversationModel): string + { + return self::getPathTemplate('conversationModel')->render([ + 'project' => $project, + 'location' => $location, + 'conversation_model' => $conversationModel, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * conversation_model_evaluation resource. + * + * @param string $project + * @param string $conversationModel + * @param string $evaluation + * + * @return string The formatted conversation_model_evaluation resource. + */ + public static function conversationModelEvaluationName(string $project, string $conversationModel, string $evaluation): string + { + return self::getPathTemplate('conversationModelEvaluation')->render([ + 'project' => $project, + 'conversation_model' => $conversationModel, + 'evaluation' => $evaluation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a document + * resource. + * + * @param string $project + * @param string $knowledgeBase + * @param string $document + * + * @return string The formatted document resource. + */ + public static function documentName(string $project, string $knowledgeBase, string $document): string + { + return self::getPathTemplate('document')->render([ + 'project' => $project, + 'knowledge_base' => $knowledgeBase, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_conversation_model resource. + * + * @param string $project + * @param string $conversationModel + * + * @return string The formatted project_conversation_model resource. + */ + public static function projectConversationModelName(string $project, string $conversationModel): string + { + return self::getPathTemplate('projectConversationModel')->render([ + 'project' => $project, + 'conversation_model' => $conversationModel, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_conversation_model_evaluation resource. + * + * @param string $project + * @param string $conversationModel + * @param string $evaluation + * + * @return string The formatted project_conversation_model_evaluation resource. + */ + public static function projectConversationModelEvaluationName(string $project, string $conversationModel, string $evaluation): string + { + return self::getPathTemplate('projectConversationModelEvaluation')->render([ + 'project' => $project, + 'conversation_model' => $conversationModel, + 'evaluation' => $evaluation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_knowledge_base_document resource. + * + * @param string $project + * @param string $knowledgeBase + * @param string $document + * + * @return string The formatted project_knowledge_base_document resource. + */ + public static function projectKnowledgeBaseDocumentName(string $project, string $knowledgeBase, string $document): string + { + return self::getPathTemplate('projectKnowledgeBaseDocument')->render([ + 'project' => $project, + 'knowledge_base' => $knowledgeBase, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_conversation_model resource. + * + * @param string $project + * @param string $location + * @param string $conversationModel + * + * @return string The formatted project_location_conversation_model resource. + */ + public static function projectLocationConversationModelName(string $project, string $location, string $conversationModel): string + { + return self::getPathTemplate('projectLocationConversationModel')->render([ + 'project' => $project, + 'location' => $location, + 'conversation_model' => $conversationModel, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_conversation_model_evaluation resource. + * + * @param string $project + * @param string $location + * @param string $conversationModel + * @param string $evaluation + * + * @return string The formatted project_location_conversation_model_evaluation resource. + */ + public static function projectLocationConversationModelEvaluationName(string $project, string $location, string $conversationModel, string $evaluation): string + { + return self::getPathTemplate('projectLocationConversationModelEvaluation')->render([ + 'project' => $project, + 'location' => $location, + 'conversation_model' => $conversationModel, + 'evaluation' => $evaluation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_knowledge_base_document resource. + * + * @param string $project + * @param string $location + * @param string $knowledgeBase + * @param string $document + * + * @return string The formatted project_location_knowledge_base_document resource. + */ + public static function projectLocationKnowledgeBaseDocumentName(string $project, string $location, string $knowledgeBase, string $document): string + { + return self::getPathTemplate('projectLocationKnowledgeBaseDocument')->render([ + 'project' => $project, + 'location' => $location, + 'knowledge_base' => $knowledgeBase, + 'document' => $document, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - conversationDataset: projects/{project}/locations/{location}/conversationDatasets/{conversation_dataset} + * - conversationModel: projects/{project}/locations/{location}/conversationModels/{conversation_model} + * - conversationModelEvaluation: projects/{project}/conversationModels/{conversation_model}/evaluations/{evaluation} + * - document: projects/{project}/knowledgeBases/{knowledge_base}/documents/{document} + * - projectConversationModel: projects/{project}/conversationModels/{conversation_model} + * - projectConversationModelEvaluation: projects/{project}/conversationModels/{conversation_model}/evaluations/{evaluation} + * - projectKnowledgeBaseDocument: projects/{project}/knowledgeBases/{knowledge_base}/documents/{document} + * - projectLocationConversationModel: projects/{project}/locations/{location}/conversationModels/{conversation_model} + * - projectLocationConversationModelEvaluation: projects/{project}/locations/{location}/conversationModels/{conversation_model}/evaluations/{evaluation} + * - projectLocationKnowledgeBaseDocument: projects/{project}/locations/{location}/knowledgeBases/{knowledge_base}/documents/{document} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dialogflow.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a model. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [CreateConversationModelOperationMetadata][google.cloud.dialogflow.v2.CreateConversationModelOperationMetadata] + * - `response`: + * [ConversationModel][google.cloud.dialogflow.v2.ConversationModel] + * + * The async variant is + * {@see ConversationModelsClient::createConversationModelAsync()} . + * + * @param CreateConversationModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createConversationModel(CreateConversationModelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateConversationModel', $request, $callOptions)->wait(); + } + + /** + * Creates evaluation of a conversation model. + * + * The async variant is + * {@see ConversationModelsClient::createConversationModelEvaluationAsync()} . + * + * @param CreateConversationModelEvaluationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createConversationModelEvaluation(CreateConversationModelEvaluationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateConversationModelEvaluation', $request, $callOptions)->wait(); + } + + /** + * Deletes a model. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [DeleteConversationModelOperationMetadata][google.cloud.dialogflow.v2.DeleteConversationModelOperationMetadata] + * - `response`: An [Empty + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) + * + * The async variant is + * {@see ConversationModelsClient::deleteConversationModelAsync()} . + * + * @param DeleteConversationModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteConversationModel(DeleteConversationModelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteConversationModel', $request, $callOptions)->wait(); + } + + /** + * Deploys a model. If a model is already deployed, deploying it + * has no effect. A model can only serve prediction requests after it gets + * deployed. For article suggestion, custom model will not be used unless + * it is deployed. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [DeployConversationModelOperationMetadata][google.cloud.dialogflow.v2.DeployConversationModelOperationMetadata] + * - `response`: An [Empty + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) + * + * The async variant is + * {@see ConversationModelsClient::deployConversationModelAsync()} . + * + * @param DeployConversationModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deployConversationModel(DeployConversationModelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeployConversationModel', $request, $callOptions)->wait(); + } + + /** + * Gets conversation model. + * + * The async variant is + * {@see ConversationModelsClient::getConversationModelAsync()} . + * + * @param GetConversationModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ConversationModel + * + * @throws ApiException Thrown if the API call fails. + */ + public function getConversationModel(GetConversationModelRequest $request, array $callOptions = []): ConversationModel + { + return $this->startApiCall('GetConversationModel', $request, $callOptions)->wait(); + } + + /** + * Gets an evaluation of conversation model. + * + * The async variant is + * {@see ConversationModelsClient::getConversationModelEvaluationAsync()} . + * + * @param GetConversationModelEvaluationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ConversationModelEvaluation + * + * @throws ApiException Thrown if the API call fails. + */ + public function getConversationModelEvaluation(GetConversationModelEvaluationRequest $request, array $callOptions = []): ConversationModelEvaluation + { + return $this->startApiCall('GetConversationModelEvaluation', $request, $callOptions)->wait(); + } + + /** + * Lists evaluations of a conversation model. + * + * The async variant is + * {@see ConversationModelsClient::listConversationModelEvaluationsAsync()} . + * + * @param ListConversationModelEvaluationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listConversationModelEvaluations(ListConversationModelEvaluationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListConversationModelEvaluations', $request, $callOptions); + } + + /** + * Lists conversation models. + * + * The async variant is + * {@see ConversationModelsClient::listConversationModelsAsync()} . + * + * @param ListConversationModelsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listConversationModels(ListConversationModelsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListConversationModels', $request, $callOptions); + } + + /** + * Undeploys a model. If the model is not deployed this method has no effect. + * If the model is currently being used: + * - For article suggestion, article suggestion will fallback to the default + * model if model is undeployed. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [UndeployConversationModelOperationMetadata][google.cloud.dialogflow.v2.UndeployConversationModelOperationMetadata] + * - `response`: An [Empty + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) + * + * The async variant is + * {@see ConversationModelsClient::undeployConversationModelAsync()} . + * + * @param UndeployConversationModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function undeployConversationModel(UndeployConversationModelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UndeployConversationModel', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see ConversationModelsClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see ConversationModelsClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Dialogflow/src/V2/Client/ConversationProfilesClient.php b/Dialogflow/src/V2/Client/ConversationProfilesClient.php index 77c01a3cd37e..6e9a5f4d2aaa 100644 --- a/Dialogflow/src/V2/Client/ConversationProfilesClient.php +++ b/Dialogflow/src/V2/Client/ConversationProfilesClient.php @@ -24,17 +24,820 @@ namespace Google\Cloud\Dialogflow\V2\Client; -use Google\Cloud\Dialogflow\V2\Client\BaseClient\ConversationProfilesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dialogflow\V2\ClearSuggestionFeatureConfigOperationMetadata; +use Google\Cloud\Dialogflow\V2\ClearSuggestionFeatureConfigRequest; +use Google\Cloud\Dialogflow\V2\ConversationProfile; +use Google\Cloud\Dialogflow\V2\CreateConversationProfileRequest; +use Google\Cloud\Dialogflow\V2\DeleteConversationProfileRequest; +use Google\Cloud\Dialogflow\V2\GetConversationProfileRequest; +use Google\Cloud\Dialogflow\V2\ListConversationProfilesRequest; +use Google\Cloud\Dialogflow\V2\SetSuggestionFeatureConfigOperationMetadata; +use Google\Cloud\Dialogflow\V2\SetSuggestionFeatureConfigRequest; +use Google\Cloud\Dialogflow\V2\UpdateConversationProfileRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for managing + * [ConversationProfiles][google.cloud.dialogflow.v2.ConversationProfile]. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dialogflow\V2\ConversationProfilesClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface clearSuggestionFeatureConfigAsync(ClearSuggestionFeatureConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface createConversationProfileAsync(CreateConversationProfileRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteConversationProfileAsync(DeleteConversationProfileRequest $request, array $optionalArgs = []) + * @method PromiseInterface getConversationProfileAsync(GetConversationProfileRequest $request, array $optionalArgs = []) + * @method PromiseInterface listConversationProfilesAsync(ListConversationProfilesRequest $request, array $optionalArgs = []) + * @method PromiseInterface setSuggestionFeatureConfigAsync(SetSuggestionFeatureConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateConversationProfileAsync(UpdateConversationProfileRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class ConversationProfilesClient extends ConversationProfilesBaseClient +final class ConversationProfilesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ConversationProfilesBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dialogflow.v2.ConversationProfiles'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/dialogflow', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/conversation_profiles_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/conversation_profiles_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/conversation_profiles_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/conversation_profiles_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a agent + * resource. + * + * @param string $project + * + * @return string The formatted agent resource. + */ + public static function agentName(string $project): string + { + return self::getPathTemplate('agent')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * cx_security_settings resource. + * + * @param string $project + * @param string $location + * @param string $securitySettings + * + * @return string The formatted cx_security_settings resource. + */ + public static function cXSecuritySettingsName(string $project, string $location, string $securitySettings): string + { + return self::getPathTemplate('cXSecuritySettings')->render([ + 'project' => $project, + 'location' => $location, + 'security_settings' => $securitySettings, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * conversation_model resource. + * + * @param string $project + * @param string $location + * @param string $conversationModel + * + * @return string The formatted conversation_model resource. + */ + public static function conversationModelName(string $project, string $location, string $conversationModel): string + { + return self::getPathTemplate('conversationModel')->render([ + 'project' => $project, + 'location' => $location, + 'conversation_model' => $conversationModel, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * conversation_profile resource. + * + * @param string $project + * @param string $conversationProfile + * + * @return string The formatted conversation_profile resource. + */ + public static function conversationProfileName(string $project, string $conversationProfile): string + { + return self::getPathTemplate('conversationProfile')->render([ + 'project' => $project, + 'conversation_profile' => $conversationProfile, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a document + * resource. + * + * @param string $project + * @param string $knowledgeBase + * @param string $document + * + * @return string The formatted document resource. + */ + public static function documentName(string $project, string $knowledgeBase, string $document): string + { + return self::getPathTemplate('document')->render([ + 'project' => $project, + 'knowledge_base' => $knowledgeBase, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * knowledge_base resource. + * + * @param string $project + * @param string $knowledgeBase + * + * @return string The formatted knowledge_base resource. + */ + public static function knowledgeBaseName(string $project, string $knowledgeBase): string + { + return self::getPathTemplate('knowledgeBase')->render([ + 'project' => $project, + 'knowledge_base' => $knowledgeBase, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_agent resource. + * + * @param string $project + * + * @return string The formatted project_agent resource. + */ + public static function projectAgentName(string $project): string + { + return self::getPathTemplate('projectAgent')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_conversation_model resource. + * + * @param string $project + * @param string $conversationModel + * + * @return string The formatted project_conversation_model resource. + */ + public static function projectConversationModelName(string $project, string $conversationModel): string + { + return self::getPathTemplate('projectConversationModel')->render([ + 'project' => $project, + 'conversation_model' => $conversationModel, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_conversation_profile resource. + * + * @param string $project + * @param string $conversationProfile + * + * @return string The formatted project_conversation_profile resource. + */ + public static function projectConversationProfileName(string $project, string $conversationProfile): string + { + return self::getPathTemplate('projectConversationProfile')->render([ + 'project' => $project, + 'conversation_profile' => $conversationProfile, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_knowledge_base resource. + * + * @param string $project + * @param string $knowledgeBase + * + * @return string The formatted project_knowledge_base resource. + */ + public static function projectKnowledgeBaseName(string $project, string $knowledgeBase): string + { + return self::getPathTemplate('projectKnowledgeBase')->render([ + 'project' => $project, + 'knowledge_base' => $knowledgeBase, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_knowledge_base_document resource. + * + * @param string $project + * @param string $knowledgeBase + * @param string $document + * + * @return string The formatted project_knowledge_base_document resource. + */ + public static function projectKnowledgeBaseDocumentName(string $project, string $knowledgeBase, string $document): string + { + return self::getPathTemplate('projectKnowledgeBaseDocument')->render([ + 'project' => $project, + 'knowledge_base' => $knowledgeBase, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted project_location_agent resource. + */ + public static function projectLocationAgentName(string $project, string $location): string + { + return self::getPathTemplate('projectLocationAgent')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_conversation_model resource. + * + * @param string $project + * @param string $location + * @param string $conversationModel + * + * @return string The formatted project_location_conversation_model resource. + */ + public static function projectLocationConversationModelName(string $project, string $location, string $conversationModel): string + { + return self::getPathTemplate('projectLocationConversationModel')->render([ + 'project' => $project, + 'location' => $location, + 'conversation_model' => $conversationModel, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_conversation_profile resource. + * + * @param string $project + * @param string $location + * @param string $conversationProfile + * + * @return string The formatted project_location_conversation_profile resource. + */ + public static function projectLocationConversationProfileName(string $project, string $location, string $conversationProfile): string + { + return self::getPathTemplate('projectLocationConversationProfile')->render([ + 'project' => $project, + 'location' => $location, + 'conversation_profile' => $conversationProfile, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_knowledge_base resource. + * + * @param string $project + * @param string $location + * @param string $knowledgeBase + * + * @return string The formatted project_location_knowledge_base resource. + */ + public static function projectLocationKnowledgeBaseName(string $project, string $location, string $knowledgeBase): string + { + return self::getPathTemplate('projectLocationKnowledgeBase')->render([ + 'project' => $project, + 'location' => $location, + 'knowledge_base' => $knowledgeBase, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_knowledge_base_document resource. + * + * @param string $project + * @param string $location + * @param string $knowledgeBase + * @param string $document + * + * @return string The formatted project_location_knowledge_base_document resource. + */ + public static function projectLocationKnowledgeBaseDocumentName(string $project, string $location, string $knowledgeBase, string $document): string + { + return self::getPathTemplate('projectLocationKnowledgeBaseDocument')->render([ + 'project' => $project, + 'location' => $location, + 'knowledge_base' => $knowledgeBase, + 'document' => $document, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - agent: projects/{project}/agent + * - cXSecuritySettings: projects/{project}/locations/{location}/securitySettings/{security_settings} + * - conversationModel: projects/{project}/locations/{location}/conversationModels/{conversation_model} + * - conversationProfile: projects/{project}/conversationProfiles/{conversation_profile} + * - document: projects/{project}/knowledgeBases/{knowledge_base}/documents/{document} + * - knowledgeBase: projects/{project}/knowledgeBases/{knowledge_base} + * - location: projects/{project}/locations/{location} + * - project: projects/{project} + * - projectAgent: projects/{project}/agent + * - projectConversationModel: projects/{project}/conversationModels/{conversation_model} + * - projectConversationProfile: projects/{project}/conversationProfiles/{conversation_profile} + * - projectKnowledgeBase: projects/{project}/knowledgeBases/{knowledge_base} + * - projectKnowledgeBaseDocument: projects/{project}/knowledgeBases/{knowledge_base}/documents/{document} + * - projectLocationAgent: projects/{project}/locations/{location}/agent + * - projectLocationConversationModel: projects/{project}/locations/{location}/conversationModels/{conversation_model} + * - projectLocationConversationProfile: projects/{project}/locations/{location}/conversationProfiles/{conversation_profile} + * - projectLocationKnowledgeBase: projects/{project}/locations/{location}/knowledgeBases/{knowledge_base} + * - projectLocationKnowledgeBaseDocument: projects/{project}/locations/{location}/knowledgeBases/{knowledge_base}/documents/{document} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dialogflow.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Clears a suggestion feature from a conversation profile for the given + * participant role. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [ClearSuggestionFeatureConfigOperationMetadata][google.cloud.dialogflow.v2.ClearSuggestionFeatureConfigOperationMetadata] + * - `response`: + * [ConversationProfile][google.cloud.dialogflow.v2.ConversationProfile] + * + * The async variant is + * {@see ConversationProfilesClient::clearSuggestionFeatureConfigAsync()} . + * + * @param ClearSuggestionFeatureConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function clearSuggestionFeatureConfig(ClearSuggestionFeatureConfigRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ClearSuggestionFeatureConfig', $request, $callOptions)->wait(); + } + + /** + * Creates a conversation profile in the specified project. + * + * [ConversationProfile.CreateTime][] and [ConversationProfile.UpdateTime][] + * aren't populated in the response. You can retrieve them via + * [GetConversationProfile][google.cloud.dialogflow.v2.ConversationProfiles.GetConversationProfile] + * API. + * + * The async variant is + * {@see ConversationProfilesClient::createConversationProfileAsync()} . + * + * @param CreateConversationProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ConversationProfile + * + * @throws ApiException Thrown if the API call fails. + */ + public function createConversationProfile(CreateConversationProfileRequest $request, array $callOptions = []): ConversationProfile + { + return $this->startApiCall('CreateConversationProfile', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified conversation profile. + * + * The async variant is + * {@see ConversationProfilesClient::deleteConversationProfileAsync()} . + * + * @param DeleteConversationProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteConversationProfile(DeleteConversationProfileRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteConversationProfile', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified conversation profile. + * + * The async variant is + * {@see ConversationProfilesClient::getConversationProfileAsync()} . + * + * @param GetConversationProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ConversationProfile + * + * @throws ApiException Thrown if the API call fails. + */ + public function getConversationProfile(GetConversationProfileRequest $request, array $callOptions = []): ConversationProfile + { + return $this->startApiCall('GetConversationProfile', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all conversation profiles in the specified project. + * + * The async variant is + * {@see ConversationProfilesClient::listConversationProfilesAsync()} . + * + * @param ListConversationProfilesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listConversationProfiles(ListConversationProfilesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListConversationProfiles', $request, $callOptions); + } + + /** + * Adds or updates a suggestion feature in a conversation profile. + * If the conversation profile contains the type of suggestion feature for + * the participant role, it will update it. Otherwise it will insert the + * suggestion feature. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [SetSuggestionFeatureConfigOperationMetadata][google.cloud.dialogflow.v2.SetSuggestionFeatureConfigOperationMetadata] + * - `response`: + * [ConversationProfile][google.cloud.dialogflow.v2.ConversationProfile] + * + * If a long running operation to add or update suggestion feature + * config for the same conversation profile, participant role and suggestion + * feature type exists, please cancel the existing long running operation + * before sending such request, otherwise the request will be rejected. + * + * The async variant is + * {@see ConversationProfilesClient::setSuggestionFeatureConfigAsync()} . + * + * @param SetSuggestionFeatureConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setSuggestionFeatureConfig(SetSuggestionFeatureConfigRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetSuggestionFeatureConfig', $request, $callOptions)->wait(); + } + + /** + * Updates the specified conversation profile. + * + * [ConversationProfile.CreateTime][] and [ConversationProfile.UpdateTime][] + * aren't populated in the response. You can retrieve them via + * [GetConversationProfile][google.cloud.dialogflow.v2.ConversationProfiles.GetConversationProfile] + * API. + * + * The async variant is + * {@see ConversationProfilesClient::updateConversationProfileAsync()} . + * + * @param UpdateConversationProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ConversationProfile + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateConversationProfile(UpdateConversationProfileRequest $request, array $callOptions = []): ConversationProfile + { + return $this->startApiCall('UpdateConversationProfile', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see ConversationProfilesClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see ConversationProfilesClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Dialogflow/src/V2/Client/ConversationsClient.php b/Dialogflow/src/V2/Client/ConversationsClient.php index ab9e1ae1f55a..c2db704e3e37 100644 --- a/Dialogflow/src/V2/Client/ConversationsClient.php +++ b/Dialogflow/src/V2/Client/ConversationsClient.php @@ -24,17 +24,917 @@ namespace Google\Cloud\Dialogflow\V2\Client; -use Google\Cloud\Dialogflow\V2\Client\BaseClient\ConversationsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dialogflow\V2\CompleteConversationRequest; +use Google\Cloud\Dialogflow\V2\Conversation; +use Google\Cloud\Dialogflow\V2\CreateConversationRequest; +use Google\Cloud\Dialogflow\V2\GenerateStatelessSummaryRequest; +use Google\Cloud\Dialogflow\V2\GenerateStatelessSummaryResponse; +use Google\Cloud\Dialogflow\V2\GetConversationRequest; +use Google\Cloud\Dialogflow\V2\ListConversationsRequest; +use Google\Cloud\Dialogflow\V2\ListMessagesRequest; +use Google\Cloud\Dialogflow\V2\SearchKnowledgeRequest; +use Google\Cloud\Dialogflow\V2\SearchKnowledgeResponse; +use Google\Cloud\Dialogflow\V2\SuggestConversationSummaryRequest; +use Google\Cloud\Dialogflow\V2\SuggestConversationSummaryResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for managing + * [Conversations][google.cloud.dialogflow.v2.Conversation]. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dialogflow\V2\ConversationsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface completeConversationAsync(CompleteConversationRequest $request, array $optionalArgs = []) + * @method PromiseInterface createConversationAsync(CreateConversationRequest $request, array $optionalArgs = []) + * @method PromiseInterface generateStatelessSummaryAsync(GenerateStatelessSummaryRequest $request, array $optionalArgs = []) + * @method PromiseInterface getConversationAsync(GetConversationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listConversationsAsync(ListConversationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listMessagesAsync(ListMessagesRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchKnowledgeAsync(SearchKnowledgeRequest $request, array $optionalArgs = []) + * @method PromiseInterface suggestConversationSummaryAsync(SuggestConversationSummaryRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class ConversationsClient extends ConversationsBaseClient +final class ConversationsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ConversationsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dialogflow.v2.Conversations'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/dialogflow', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/conversations_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/conversations_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/conversations_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/conversations_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a agent + * resource. + * + * @param string $project + * + * @return string The formatted agent resource. + */ + public static function agentName(string $project): string + { + return self::getPathTemplate('agent')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * cx_security_settings resource. + * + * @param string $project + * @param string $location + * @param string $securitySettings + * + * @return string The formatted cx_security_settings resource. + */ + public static function cXSecuritySettingsName(string $project, string $location, string $securitySettings): string + { + return self::getPathTemplate('cXSecuritySettings')->render([ + 'project' => $project, + 'location' => $location, + 'security_settings' => $securitySettings, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a conversation + * resource. + * + * @param string $project + * @param string $conversation + * + * @return string The formatted conversation resource. + */ + public static function conversationName(string $project, string $conversation): string + { + return self::getPathTemplate('conversation')->render([ + 'project' => $project, + 'conversation' => $conversation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * conversation_model resource. + * + * @param string $project + * @param string $location + * @param string $conversationModel + * + * @return string The formatted conversation_model resource. + */ + public static function conversationModelName(string $project, string $location, string $conversationModel): string + { + return self::getPathTemplate('conversationModel')->render([ + 'project' => $project, + 'location' => $location, + 'conversation_model' => $conversationModel, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * conversation_profile resource. + * + * @param string $project + * @param string $conversationProfile + * + * @return string The formatted conversation_profile resource. + */ + public static function conversationProfileName(string $project, string $conversationProfile): string + { + return self::getPathTemplate('conversationProfile')->render([ + 'project' => $project, + 'conversation_profile' => $conversationProfile, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a document + * resource. + * + * @param string $project + * @param string $knowledgeBase + * @param string $document + * + * @return string The formatted document resource. + */ + public static function documentName(string $project, string $knowledgeBase, string $document): string + { + return self::getPathTemplate('document')->render([ + 'project' => $project, + 'knowledge_base' => $knowledgeBase, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * knowledge_base resource. + * + * @param string $project + * @param string $knowledgeBase + * + * @return string The formatted knowledge_base resource. + */ + public static function knowledgeBaseName(string $project, string $knowledgeBase): string + { + return self::getPathTemplate('knowledgeBase')->render([ + 'project' => $project, + 'knowledge_base' => $knowledgeBase, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a message + * resource. + * + * @param string $project + * @param string $conversation + * @param string $message + * + * @return string The formatted message resource. + */ + public static function messageName(string $project, string $conversation, string $message): string + { + return self::getPathTemplate('message')->render([ + 'project' => $project, + 'conversation' => $conversation, + 'message' => $message, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_agent resource. + * + * @param string $project + * + * @return string The formatted project_agent resource. + */ + public static function projectAgentName(string $project): string + { + return self::getPathTemplate('projectAgent')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_conversation resource. + * + * @param string $project + * @param string $conversation + * + * @return string The formatted project_conversation resource. + */ + public static function projectConversationName(string $project, string $conversation): string + { + return self::getPathTemplate('projectConversation')->render([ + 'project' => $project, + 'conversation' => $conversation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_conversation_message resource. + * + * @param string $project + * @param string $conversation + * @param string $message + * + * @return string The formatted project_conversation_message resource. + */ + public static function projectConversationMessageName(string $project, string $conversation, string $message): string + { + return self::getPathTemplate('projectConversationMessage')->render([ + 'project' => $project, + 'conversation' => $conversation, + 'message' => $message, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_conversation_model resource. + * + * @param string $project + * @param string $conversationModel + * + * @return string The formatted project_conversation_model resource. + */ + public static function projectConversationModelName(string $project, string $conversationModel): string + { + return self::getPathTemplate('projectConversationModel')->render([ + 'project' => $project, + 'conversation_model' => $conversationModel, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_conversation_profile resource. + * + * @param string $project + * @param string $conversationProfile + * + * @return string The formatted project_conversation_profile resource. + */ + public static function projectConversationProfileName(string $project, string $conversationProfile): string + { + return self::getPathTemplate('projectConversationProfile')->render([ + 'project' => $project, + 'conversation_profile' => $conversationProfile, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_knowledge_base resource. + * + * @param string $project + * @param string $knowledgeBase + * + * @return string The formatted project_knowledge_base resource. + */ + public static function projectKnowledgeBaseName(string $project, string $knowledgeBase): string + { + return self::getPathTemplate('projectKnowledgeBase')->render([ + 'project' => $project, + 'knowledge_base' => $knowledgeBase, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_knowledge_base_document resource. + * + * @param string $project + * @param string $knowledgeBase + * @param string $document + * + * @return string The formatted project_knowledge_base_document resource. + */ + public static function projectKnowledgeBaseDocumentName(string $project, string $knowledgeBase, string $document): string + { + return self::getPathTemplate('projectKnowledgeBaseDocument')->render([ + 'project' => $project, + 'knowledge_base' => $knowledgeBase, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted project_location_agent resource. + */ + public static function projectLocationAgentName(string $project, string $location): string + { + return self::getPathTemplate('projectLocationAgent')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_conversation resource. + * + * @param string $project + * @param string $location + * @param string $conversation + * + * @return string The formatted project_location_conversation resource. + */ + public static function projectLocationConversationName(string $project, string $location, string $conversation): string + { + return self::getPathTemplate('projectLocationConversation')->render([ + 'project' => $project, + 'location' => $location, + 'conversation' => $conversation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_conversation_message resource. + * + * @param string $project + * @param string $location + * @param string $conversation + * @param string $message + * + * @return string The formatted project_location_conversation_message resource. + */ + public static function projectLocationConversationMessageName(string $project, string $location, string $conversation, string $message): string + { + return self::getPathTemplate('projectLocationConversationMessage')->render([ + 'project' => $project, + 'location' => $location, + 'conversation' => $conversation, + 'message' => $message, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_conversation_model resource. + * + * @param string $project + * @param string $location + * @param string $conversationModel + * + * @return string The formatted project_location_conversation_model resource. + */ + public static function projectLocationConversationModelName(string $project, string $location, string $conversationModel): string + { + return self::getPathTemplate('projectLocationConversationModel')->render([ + 'project' => $project, + 'location' => $location, + 'conversation_model' => $conversationModel, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_conversation_profile resource. + * + * @param string $project + * @param string $location + * @param string $conversationProfile + * + * @return string The formatted project_location_conversation_profile resource. + */ + public static function projectLocationConversationProfileName(string $project, string $location, string $conversationProfile): string + { + return self::getPathTemplate('projectLocationConversationProfile')->render([ + 'project' => $project, + 'location' => $location, + 'conversation_profile' => $conversationProfile, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_knowledge_base resource. + * + * @param string $project + * @param string $location + * @param string $knowledgeBase + * + * @return string The formatted project_location_knowledge_base resource. + */ + public static function projectLocationKnowledgeBaseName(string $project, string $location, string $knowledgeBase): string + { + return self::getPathTemplate('projectLocationKnowledgeBase')->render([ + 'project' => $project, + 'location' => $location, + 'knowledge_base' => $knowledgeBase, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_knowledge_base_document resource. + * + * @param string $project + * @param string $location + * @param string $knowledgeBase + * @param string $document + * + * @return string The formatted project_location_knowledge_base_document resource. + */ + public static function projectLocationKnowledgeBaseDocumentName(string $project, string $location, string $knowledgeBase, string $document): string + { + return self::getPathTemplate('projectLocationKnowledgeBaseDocument')->render([ + 'project' => $project, + 'location' => $location, + 'knowledge_base' => $knowledgeBase, + 'document' => $document, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - agent: projects/{project}/agent + * - cXSecuritySettings: projects/{project}/locations/{location}/securitySettings/{security_settings} + * - conversation: projects/{project}/conversations/{conversation} + * - conversationModel: projects/{project}/locations/{location}/conversationModels/{conversation_model} + * - conversationProfile: projects/{project}/conversationProfiles/{conversation_profile} + * - document: projects/{project}/knowledgeBases/{knowledge_base}/documents/{document} + * - knowledgeBase: projects/{project}/knowledgeBases/{knowledge_base} + * - location: projects/{project}/locations/{location} + * - message: projects/{project}/conversations/{conversation}/messages/{message} + * - project: projects/{project} + * - projectAgent: projects/{project}/agent + * - projectConversation: projects/{project}/conversations/{conversation} + * - projectConversationMessage: projects/{project}/conversations/{conversation}/messages/{message} + * - projectConversationModel: projects/{project}/conversationModels/{conversation_model} + * - projectConversationProfile: projects/{project}/conversationProfiles/{conversation_profile} + * - projectKnowledgeBase: projects/{project}/knowledgeBases/{knowledge_base} + * - projectKnowledgeBaseDocument: projects/{project}/knowledgeBases/{knowledge_base}/documents/{document} + * - projectLocationAgent: projects/{project}/locations/{location}/agent + * - projectLocationConversation: projects/{project}/locations/{location}/conversations/{conversation} + * - projectLocationConversationMessage: projects/{project}/locations/{location}/conversations/{conversation}/messages/{message} + * - projectLocationConversationModel: projects/{project}/locations/{location}/conversationModels/{conversation_model} + * - projectLocationConversationProfile: projects/{project}/locations/{location}/conversationProfiles/{conversation_profile} + * - projectLocationKnowledgeBase: projects/{project}/locations/{location}/knowledgeBases/{knowledge_base} + * - projectLocationKnowledgeBaseDocument: projects/{project}/locations/{location}/knowledgeBases/{knowledge_base}/documents/{document} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dialogflow.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Completes the specified conversation. Finished conversations are purged + * from the database after 30 days. + * + * The async variant is {@see ConversationsClient::completeConversationAsync()} . + * + * @param CompleteConversationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Conversation + * + * @throws ApiException Thrown if the API call fails. + */ + public function completeConversation(CompleteConversationRequest $request, array $callOptions = []): Conversation + { + return $this->startApiCall('CompleteConversation', $request, $callOptions)->wait(); + } + + /** + * Creates a new conversation. Conversations are auto-completed after 24 + * hours. + * + * Conversation Lifecycle: + * There are two stages during a conversation: Automated Agent Stage and + * Assist Stage. + * + * For Automated Agent Stage, there will be a dialogflow agent responding to + * user queries. + * + * For Assist Stage, there's no dialogflow agent responding to user queries. + * But we will provide suggestions which are generated from conversation. + * + * If + * [Conversation.conversation_profile][google.cloud.dialogflow.v2.Conversation.conversation_profile] + * is configured for a dialogflow agent, conversation will start from + * `Automated Agent Stage`, otherwise, it will start from `Assist Stage`. And + * during `Automated Agent Stage`, once an + * [Intent][google.cloud.dialogflow.v2.Intent] with + * [Intent.live_agent_handoff][google.cloud.dialogflow.v2.Intent.live_agent_handoff] + * is triggered, conversation will transfer to Assist Stage. + * + * The async variant is {@see ConversationsClient::createConversationAsync()} . + * + * @param CreateConversationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Conversation + * + * @throws ApiException Thrown if the API call fails. + */ + public function createConversation(CreateConversationRequest $request, array $callOptions = []): Conversation + { + return $this->startApiCall('CreateConversation', $request, $callOptions)->wait(); + } + + /** + * Generates and returns a summary for a conversation that does not have a + * resource created for it. + * + * The async variant is {@see ConversationsClient::generateStatelessSummaryAsync()} + * . + * + * @param GenerateStatelessSummaryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GenerateStatelessSummaryResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function generateStatelessSummary(GenerateStatelessSummaryRequest $request, array $callOptions = []): GenerateStatelessSummaryResponse + { + return $this->startApiCall('GenerateStatelessSummary', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specific conversation. + * + * The async variant is {@see ConversationsClient::getConversationAsync()} . + * + * @param GetConversationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Conversation + * + * @throws ApiException Thrown if the API call fails. + */ + public function getConversation(GetConversationRequest $request, array $callOptions = []): Conversation + { + return $this->startApiCall('GetConversation', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all conversations in the specified project. + * + * The async variant is {@see ConversationsClient::listConversationsAsync()} . + * + * @param ListConversationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listConversations(ListConversationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListConversations', $request, $callOptions); + } + + /** + * Lists messages that belong to a given conversation. + * `messages` are ordered by `create_time` in descending order. To fetch + * updates without duplication, send request with filter + * `create_time_epoch_microseconds > + * [first item's create_time of previous request]` and empty page_token. + * + * The async variant is {@see ConversationsClient::listMessagesAsync()} . + * + * @param ListMessagesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listMessages(ListMessagesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListMessages', $request, $callOptions); + } + + /** + * Get answers for the given query based on knowledge documents. + * + * The async variant is {@see ConversationsClient::searchKnowledgeAsync()} . + * + * @param SearchKnowledgeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SearchKnowledgeResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchKnowledge(SearchKnowledgeRequest $request, array $callOptions = []): SearchKnowledgeResponse + { + return $this->startApiCall('SearchKnowledge', $request, $callOptions)->wait(); + } + + /** + * Suggests summary for a conversation based on specific historical messages. + * The range of the messages to be used for summary can be specified in the + * request. + * + * The async variant is + * {@see ConversationsClient::suggestConversationSummaryAsync()} . + * + * @param SuggestConversationSummaryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SuggestConversationSummaryResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function suggestConversationSummary(SuggestConversationSummaryRequest $request, array $callOptions = []): SuggestConversationSummaryResponse + { + return $this->startApiCall('SuggestConversationSummary', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see ConversationsClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see ConversationsClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Dialogflow/src/V2/Client/DocumentsClient.php b/Dialogflow/src/V2/Client/DocumentsClient.php index c54c5413d02b..5ccc05383398 100644 --- a/Dialogflow/src/V2/Client/DocumentsClient.php +++ b/Dialogflow/src/V2/Client/DocumentsClient.php @@ -24,17 +24,644 @@ namespace Google\Cloud\Dialogflow\V2\Client; -use Google\Cloud\Dialogflow\V2\Client\BaseClient\DocumentsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dialogflow\V2\CreateDocumentRequest; +use Google\Cloud\Dialogflow\V2\DeleteDocumentRequest; +use Google\Cloud\Dialogflow\V2\Document; +use Google\Cloud\Dialogflow\V2\ExportDocumentRequest; +use Google\Cloud\Dialogflow\V2\GetDocumentRequest; +use Google\Cloud\Dialogflow\V2\ImportDocumentsRequest; +use Google\Cloud\Dialogflow\V2\ImportDocumentsResponse; +use Google\Cloud\Dialogflow\V2\KnowledgeOperationMetadata; +use Google\Cloud\Dialogflow\V2\ListDocumentsRequest; +use Google\Cloud\Dialogflow\V2\ReloadDocumentRequest; +use Google\Cloud\Dialogflow\V2\UpdateDocumentRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for managing knowledge + * [Documents][google.cloud.dialogflow.v2.Document]. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dialogflow\V2\DocumentsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createDocumentAsync(CreateDocumentRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDocumentAsync(DeleteDocumentRequest $request, array $optionalArgs = []) + * @method PromiseInterface exportDocumentAsync(ExportDocumentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDocumentAsync(GetDocumentRequest $request, array $optionalArgs = []) + * @method PromiseInterface importDocumentsAsync(ImportDocumentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDocumentsAsync(ListDocumentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface reloadDocumentAsync(ReloadDocumentRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDocumentAsync(UpdateDocumentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class DocumentsClient extends DocumentsBaseClient +final class DocumentsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DocumentsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dialogflow.v2.Documents'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/dialogflow', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/documents_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/documents_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/documents_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/documents_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a document + * resource. + * + * @param string $project + * @param string $knowledgeBase + * @param string $document + * + * @return string The formatted document resource. + */ + public static function documentName(string $project, string $knowledgeBase, string $document): string + { + return self::getPathTemplate('document')->render([ + 'project' => $project, + 'knowledge_base' => $knowledgeBase, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * knowledge_base resource. + * + * @param string $project + * @param string $knowledgeBase + * + * @return string The formatted knowledge_base resource. + */ + public static function knowledgeBaseName(string $project, string $knowledgeBase): string + { + return self::getPathTemplate('knowledgeBase')->render([ + 'project' => $project, + 'knowledge_base' => $knowledgeBase, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_knowledge_base resource. + * + * @param string $project + * @param string $knowledgeBase + * + * @return string The formatted project_knowledge_base resource. + */ + public static function projectKnowledgeBaseName(string $project, string $knowledgeBase): string + { + return self::getPathTemplate('projectKnowledgeBase')->render([ + 'project' => $project, + 'knowledge_base' => $knowledgeBase, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_knowledge_base_document resource. + * + * @param string $project + * @param string $knowledgeBase + * @param string $document + * + * @return string The formatted project_knowledge_base_document resource. + */ + public static function projectKnowledgeBaseDocumentName(string $project, string $knowledgeBase, string $document): string + { + return self::getPathTemplate('projectKnowledgeBaseDocument')->render([ + 'project' => $project, + 'knowledge_base' => $knowledgeBase, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_knowledge_base resource. + * + * @param string $project + * @param string $location + * @param string $knowledgeBase + * + * @return string The formatted project_location_knowledge_base resource. + */ + public static function projectLocationKnowledgeBaseName(string $project, string $location, string $knowledgeBase): string + { + return self::getPathTemplate('projectLocationKnowledgeBase')->render([ + 'project' => $project, + 'location' => $location, + 'knowledge_base' => $knowledgeBase, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_knowledge_base_document resource. + * + * @param string $project + * @param string $location + * @param string $knowledgeBase + * @param string $document + * + * @return string The formatted project_location_knowledge_base_document resource. + */ + public static function projectLocationKnowledgeBaseDocumentName(string $project, string $location, string $knowledgeBase, string $document): string + { + return self::getPathTemplate('projectLocationKnowledgeBaseDocument')->render([ + 'project' => $project, + 'location' => $location, + 'knowledge_base' => $knowledgeBase, + 'document' => $document, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - document: projects/{project}/knowledgeBases/{knowledge_base}/documents/{document} + * - knowledgeBase: projects/{project}/knowledgeBases/{knowledge_base} + * - projectKnowledgeBase: projects/{project}/knowledgeBases/{knowledge_base} + * - projectKnowledgeBaseDocument: projects/{project}/knowledgeBases/{knowledge_base}/documents/{document} + * - projectLocationKnowledgeBase: projects/{project}/locations/{location}/knowledgeBases/{knowledge_base} + * - projectLocationKnowledgeBaseDocument: projects/{project}/locations/{location}/knowledgeBases/{knowledge_base}/documents/{document} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dialogflow.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new document. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] + * - `response`: [Document][google.cloud.dialogflow.v2.Document] + * + * The async variant is {@see DocumentsClient::createDocumentAsync()} . + * + * @param CreateDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDocument(CreateDocumentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateDocument', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified document. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] + * - `response`: An [Empty + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) + * + * The async variant is {@see DocumentsClient::deleteDocumentAsync()} . + * + * @param DeleteDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDocument(DeleteDocumentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteDocument', $request, $callOptions)->wait(); + } + + /** + * Exports a smart messaging candidate document into the specified + * destination. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] + * - `response`: [Document][google.cloud.dialogflow.v2.Document] + * + * The async variant is {@see DocumentsClient::exportDocumentAsync()} . + * + * @param ExportDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportDocument(ExportDocumentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ExportDocument', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified document. + * + * The async variant is {@see DocumentsClient::getDocumentAsync()} . + * + * @param GetDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Document + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDocument(GetDocumentRequest $request, array $callOptions = []): Document + { + return $this->startApiCall('GetDocument', $request, $callOptions)->wait(); + } + + /** + * Creates documents by importing data from external sources. + * Dialogflow supports up to 350 documents in each request. If you try to + * import more, Dialogflow will return an error. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] + * - `response`: + * [ImportDocumentsResponse][google.cloud.dialogflow.v2.ImportDocumentsResponse] + * + * The async variant is {@see DocumentsClient::importDocumentsAsync()} . + * + * @param ImportDocumentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importDocuments(ImportDocumentsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportDocuments', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all documents of the knowledge base. + * + * The async variant is {@see DocumentsClient::listDocumentsAsync()} . + * + * @param ListDocumentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDocuments(ListDocumentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDocuments', $request, $callOptions); + } + + /** + * Reloads the specified document from its specified source, content_uri or + * content. The previously loaded content of the document will be deleted. + * Note: Even when the content of the document has not changed, there still + * may be side effects because of internal implementation changes. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] + * - `response`: [Document][google.cloud.dialogflow.v2.Document] + * + * Note: The `projects.agent.knowledgeBases.documents` resource is deprecated; + * only use `projects.knowledgeBases.documents`. + * + * The async variant is {@see DocumentsClient::reloadDocumentAsync()} . + * + * @param ReloadDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function reloadDocument(ReloadDocumentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ReloadDocument', $request, $callOptions)->wait(); + } + + /** + * Updates the specified document. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: + * [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata] + * - `response`: [Document][google.cloud.dialogflow.v2.Document] + * + * The async variant is {@see DocumentsClient::updateDocumentAsync()} . + * + * @param UpdateDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDocument(UpdateDocumentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateDocument', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see DocumentsClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see DocumentsClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Dialogflow/src/V2/Client/EntityTypesClient.php b/Dialogflow/src/V2/Client/EntityTypesClient.php index e535aa81b89b..f41d71cbe877 100644 --- a/Dialogflow/src/V2/Client/EntityTypesClient.php +++ b/Dialogflow/src/V2/Client/EntityTypesClient.php @@ -24,17 +24,703 @@ namespace Google\Cloud\Dialogflow\V2\Client; -use Google\Cloud\Dialogflow\V2\Client\BaseClient\EntityTypesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dialogflow\V2\BatchCreateEntitiesRequest; +use Google\Cloud\Dialogflow\V2\BatchDeleteEntitiesRequest; +use Google\Cloud\Dialogflow\V2\BatchDeleteEntityTypesRequest; +use Google\Cloud\Dialogflow\V2\BatchUpdateEntitiesRequest; +use Google\Cloud\Dialogflow\V2\BatchUpdateEntityTypesRequest; +use Google\Cloud\Dialogflow\V2\BatchUpdateEntityTypesResponse; +use Google\Cloud\Dialogflow\V2\CreateEntityTypeRequest; +use Google\Cloud\Dialogflow\V2\DeleteEntityTypeRequest; +use Google\Cloud\Dialogflow\V2\EntityType; +use Google\Cloud\Dialogflow\V2\EntityType\Entity; +use Google\Cloud\Dialogflow\V2\GetEntityTypeRequest; +use Google\Cloud\Dialogflow\V2\ListEntityTypesRequest; +use Google\Cloud\Dialogflow\V2\UpdateEntityTypeRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use Google\Protobuf\Struct; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for managing [EntityTypes][google.cloud.dialogflow.v2.EntityType]. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dialogflow\V2\EntityTypesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface batchCreateEntitiesAsync(BatchCreateEntitiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface batchDeleteEntitiesAsync(BatchDeleteEntitiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface batchDeleteEntityTypesAsync(BatchDeleteEntityTypesRequest $request, array $optionalArgs = []) + * @method PromiseInterface batchUpdateEntitiesAsync(BatchUpdateEntitiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface batchUpdateEntityTypesAsync(BatchUpdateEntityTypesRequest $request, array $optionalArgs = []) + * @method PromiseInterface createEntityTypeAsync(CreateEntityTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteEntityTypeAsync(DeleteEntityTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEntityTypeAsync(GetEntityTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface listEntityTypesAsync(ListEntityTypesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateEntityTypeAsync(UpdateEntityTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class EntityTypesClient extends EntityTypesBaseClient +final class EntityTypesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see EntityTypesBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dialogflow.v2.EntityTypes'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/dialogflow', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/entity_types_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/entity_types_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/entity_types_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/entity_types_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a agent + * resource. + * + * @param string $project + * + * @return string The formatted agent resource. + */ + public static function agentName(string $project): string + { + return self::getPathTemplate('agent')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a entity_type + * resource. + * + * @param string $project + * @param string $entityType + * + * @return string The formatted entity_type resource. + */ + public static function entityTypeName(string $project, string $entityType): string + { + return self::getPathTemplate('entityType')->render([ + 'project' => $project, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_agent resource. + * + * @param string $project + * + * @return string The formatted project_agent resource. + */ + public static function projectAgentName(string $project): string + { + return self::getPathTemplate('projectAgent')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_entity_type resource. + * + * @param string $project + * @param string $entityType + * + * @return string The formatted project_entity_type resource. + */ + public static function projectEntityTypeName(string $project, string $entityType): string + { + return self::getPathTemplate('projectEntityType')->render([ + 'project' => $project, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted project_location_agent resource. + */ + public static function projectLocationAgentName(string $project, string $location): string + { + return self::getPathTemplate('projectLocationAgent')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_entity_type resource. + * + * @param string $project + * @param string $location + * @param string $entityType + * + * @return string The formatted project_location_entity_type resource. + */ + public static function projectLocationEntityTypeName(string $project, string $location, string $entityType): string + { + return self::getPathTemplate('projectLocationEntityType')->render([ + 'project' => $project, + 'location' => $location, + 'entity_type' => $entityType, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - agent: projects/{project}/agent + * - entityType: projects/{project}/agent/entityTypes/{entity_type} + * - projectAgent: projects/{project}/agent + * - projectEntityType: projects/{project}/agent/entityTypes/{entity_type} + * - projectLocationAgent: projects/{project}/locations/{location}/agent + * - projectLocationEntityType: projects/{project}/locations/{location}/agent/entityTypes/{entity_type} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dialogflow.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates multiple new entities in the specified entity type. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: An empty [Struct + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) + * - `response`: An [Empty + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) + * + * Note: You should always train an agent prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/es/docs/training). + * + * The async variant is {@see EntityTypesClient::batchCreateEntitiesAsync()} . + * + * @param BatchCreateEntitiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchCreateEntities(BatchCreateEntitiesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchCreateEntities', $request, $callOptions)->wait(); + } + + /** + * Deletes entities in the specified entity type. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: An empty [Struct + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) + * - `response`: An [Empty + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) + * + * Note: You should always train an agent prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/es/docs/training). + * + * The async variant is {@see EntityTypesClient::batchDeleteEntitiesAsync()} . + * + * @param BatchDeleteEntitiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchDeleteEntities(BatchDeleteEntitiesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchDeleteEntities', $request, $callOptions)->wait(); + } + + /** + * Deletes entity types in the specified agent. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: An empty [Struct + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) + * - `response`: An [Empty + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) + * + * Note: You should always train an agent prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/es/docs/training). + * + * The async variant is {@see EntityTypesClient::batchDeleteEntityTypesAsync()} . + * + * @param BatchDeleteEntityTypesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchDeleteEntityTypes(BatchDeleteEntityTypesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchDeleteEntityTypes', $request, $callOptions)->wait(); + } + + /** + * Updates or creates multiple entities in the specified entity type. This + * method does not affect entities in the entity type that aren't explicitly + * specified in the request. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: An empty [Struct + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) + * - `response`: An [Empty + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) + * + * Note: You should always train an agent prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/es/docs/training). + * + * + * The async variant is {@see EntityTypesClient::batchUpdateEntitiesAsync()} . + * + * @param BatchUpdateEntitiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchUpdateEntities(BatchUpdateEntitiesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchUpdateEntities', $request, $callOptions)->wait(); + } + + /** + * Updates/Creates multiple entity types in the specified agent. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: An empty [Struct + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) + * - `response`: + * [BatchUpdateEntityTypesResponse][google.cloud.dialogflow.v2.BatchUpdateEntityTypesResponse] + * + * Note: You should always train an agent prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/es/docs/training). + * + * The async variant is {@see EntityTypesClient::batchUpdateEntityTypesAsync()} . + * + * @param BatchUpdateEntityTypesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchUpdateEntityTypes(BatchUpdateEntityTypesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchUpdateEntityTypes', $request, $callOptions)->wait(); + } + + /** + * Creates an entity type in the specified agent. + * + * Note: You should always train an agent prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/es/docs/training). + * + * The async variant is {@see EntityTypesClient::createEntityTypeAsync()} . + * + * @param CreateEntityTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 EntityType + * + * @throws ApiException Thrown if the API call fails. + */ + public function createEntityType(CreateEntityTypeRequest $request, array $callOptions = []): EntityType + { + return $this->startApiCall('CreateEntityType', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified entity type. + * + * Note: You should always train an agent prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/es/docs/training). + * + * The async variant is {@see EntityTypesClient::deleteEntityTypeAsync()} . + * + * @param DeleteEntityTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteEntityType(DeleteEntityTypeRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteEntityType', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified entity type. + * + * The async variant is {@see EntityTypesClient::getEntityTypeAsync()} . + * + * @param GetEntityTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 EntityType + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEntityType(GetEntityTypeRequest $request, array $callOptions = []): EntityType + { + return $this->startApiCall('GetEntityType', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all entity types in the specified agent. + * + * The async variant is {@see EntityTypesClient::listEntityTypesAsync()} . + * + * @param ListEntityTypesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listEntityTypes(ListEntityTypesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEntityTypes', $request, $callOptions); + } + + /** + * Updates the specified entity type. + * + * Note: You should always train an agent prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/es/docs/training). + * + * The async variant is {@see EntityTypesClient::updateEntityTypeAsync()} . + * + * @param UpdateEntityTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 EntityType + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateEntityType(UpdateEntityTypeRequest $request, array $callOptions = []): EntityType + { + return $this->startApiCall('UpdateEntityType', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see EntityTypesClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see EntityTypesClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Dialogflow/src/V2/Client/EnvironmentsClient.php b/Dialogflow/src/V2/Client/EnvironmentsClient.php index bfffed9aed53..dd20da1f6884 100644 --- a/Dialogflow/src/V2/Client/EnvironmentsClient.php +++ b/Dialogflow/src/V2/Client/EnvironmentsClient.php @@ -24,17 +24,598 @@ namespace Google\Cloud\Dialogflow\V2\Client; -use Google\Cloud\Dialogflow\V2\Client\BaseClient\EnvironmentsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dialogflow\V2\CreateEnvironmentRequest; +use Google\Cloud\Dialogflow\V2\DeleteEnvironmentRequest; +use Google\Cloud\Dialogflow\V2\Environment; +use Google\Cloud\Dialogflow\V2\GetEnvironmentHistoryRequest; +use Google\Cloud\Dialogflow\V2\GetEnvironmentRequest; +use Google\Cloud\Dialogflow\V2\ListEnvironmentsRequest; +use Google\Cloud\Dialogflow\V2\UpdateEnvironmentRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for managing [Environments][google.cloud.dialogflow.v2.Environment]. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dialogflow\V2\EnvironmentsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createEnvironmentAsync(CreateEnvironmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteEnvironmentAsync(DeleteEnvironmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEnvironmentAsync(GetEnvironmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEnvironmentHistoryAsync(GetEnvironmentHistoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface listEnvironmentsAsync(ListEnvironmentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateEnvironmentAsync(UpdateEnvironmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class EnvironmentsClient extends EnvironmentsBaseClient +final class EnvironmentsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see EnvironmentsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dialogflow.v2.Environments'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/dialogflow', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/environments_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/environments_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/environments_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/environments_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a agent + * resource. + * + * @param string $project + * + * @return string The formatted agent resource. + */ + public static function agentName(string $project): string + { + return self::getPathTemplate('agent')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a environment + * resource. + * + * @param string $project + * @param string $environment + * + * @return string The formatted environment resource. + */ + public static function environmentName(string $project, string $environment): string + { + return self::getPathTemplate('environment')->render([ + 'project' => $project, + 'environment' => $environment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a fulfillment + * resource. + * + * @param string $project + * + * @return string The formatted fulfillment resource. + */ + public static function fulfillmentName(string $project): string + { + return self::getPathTemplate('fulfillment')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_agent resource. + * + * @param string $project + * + * @return string The formatted project_agent resource. + */ + public static function projectAgentName(string $project): string + { + return self::getPathTemplate('projectAgent')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_environment resource. + * + * @param string $project + * @param string $environment + * + * @return string The formatted project_environment resource. + */ + public static function projectEnvironmentName(string $project, string $environment): string + { + return self::getPathTemplate('projectEnvironment')->render([ + 'project' => $project, + 'environment' => $environment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_fulfillment resource. + * + * @param string $project + * + * @return string The formatted project_fulfillment resource. + */ + public static function projectFulfillmentName(string $project): string + { + return self::getPathTemplate('projectFulfillment')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted project_location_agent resource. + */ + public static function projectLocationAgentName(string $project, string $location): string + { + return self::getPathTemplate('projectLocationAgent')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_environment resource. + * + * @param string $project + * @param string $location + * @param string $environment + * + * @return string The formatted project_location_environment resource. + */ + public static function projectLocationEnvironmentName(string $project, string $location, string $environment): string + { + return self::getPathTemplate('projectLocationEnvironment')->render([ + 'project' => $project, + 'location' => $location, + 'environment' => $environment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_fulfillment resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted project_location_fulfillment resource. + */ + public static function projectLocationFulfillmentName(string $project, string $location): string + { + return self::getPathTemplate('projectLocationFulfillment')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_version resource. + * + * @param string $project + * @param string $location + * @param string $version + * + * @return string The formatted project_location_version resource. + */ + public static function projectLocationVersionName(string $project, string $location, string $version): string + { + return self::getPathTemplate('projectLocationVersion')->render([ + 'project' => $project, + 'location' => $location, + 'version' => $version, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_version resource. + * + * @param string $project + * @param string $version + * + * @return string The formatted project_version resource. + */ + public static function projectVersionName(string $project, string $version): string + { + return self::getPathTemplate('projectVersion')->render([ + 'project' => $project, + 'version' => $version, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a version + * resource. + * + * @param string $project + * @param string $version + * + * @return string The formatted version resource. + */ + public static function versionName(string $project, string $version): string + { + return self::getPathTemplate('version')->render([ + 'project' => $project, + 'version' => $version, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - agent: projects/{project}/agent + * - environment: projects/{project}/agent/environments/{environment} + * - fulfillment: projects/{project}/agent/fulfillment + * - projectAgent: projects/{project}/agent + * - projectEnvironment: projects/{project}/agent/environments/{environment} + * - projectFulfillment: projects/{project}/agent/fulfillment + * - projectLocationAgent: projects/{project}/locations/{location}/agent + * - projectLocationEnvironment: projects/{project}/locations/{location}/agent/environments/{environment} + * - projectLocationFulfillment: projects/{project}/locations/{location}/agent/fulfillment + * - projectLocationVersion: projects/{project}/locations/{location}/agent/versions/{version} + * - projectVersion: projects/{project}/agent/versions/{version} + * - version: projects/{project}/agent/versions/{version} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dialogflow.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates an agent environment. + * + * The async variant is {@see EnvironmentsClient::createEnvironmentAsync()} . + * + * @param CreateEnvironmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Environment + * + * @throws ApiException Thrown if the API call fails. + */ + public function createEnvironment(CreateEnvironmentRequest $request, array $callOptions = []): Environment + { + return $this->startApiCall('CreateEnvironment', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified agent environment. + * + * The async variant is {@see EnvironmentsClient::deleteEnvironmentAsync()} . + * + * @param DeleteEnvironmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteEnvironment(DeleteEnvironmentRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteEnvironment', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified agent environment. + * + * The async variant is {@see EnvironmentsClient::getEnvironmentAsync()} . + * + * @param GetEnvironmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Environment + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEnvironment(GetEnvironmentRequest $request, array $callOptions = []): Environment + { + return $this->startApiCall('GetEnvironment', $request, $callOptions)->wait(); + } + + /** + * Gets the history of the specified environment. + * + * The async variant is {@see EnvironmentsClient::getEnvironmentHistoryAsync()} . + * + * @param GetEnvironmentHistoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEnvironmentHistory(GetEnvironmentHistoryRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('GetEnvironmentHistory', $request, $callOptions); + } + + /** + * Returns the list of all non-default environments of the specified agent. + * + * The async variant is {@see EnvironmentsClient::listEnvironmentsAsync()} . + * + * @param ListEnvironmentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listEnvironments(ListEnvironmentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEnvironments', $request, $callOptions); + } + + /** + * Updates the specified agent environment. + * + * This method allows you to deploy new agent versions into the environment. + * When an environment is pointed to a new agent version by setting + * `environment.agent_version`, the environment is temporarily set to the + * `LOADING` state. During that time, the environment continues serving the + * previous version of the agent. After the new agent version is done loading, + * the environment is set back to the `RUNNING` state. + * You can use "-" as Environment ID in environment name to update an agent + * version in the default environment. WARNING: this will negate all recent + * changes to the draft agent and can't be undone. You may want to save the + * draft agent to a version before calling this method. + * + * The async variant is {@see EnvironmentsClient::updateEnvironmentAsync()} . + * + * @param UpdateEnvironmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Environment + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateEnvironment(UpdateEnvironmentRequest $request, array $callOptions = []): Environment + { + return $this->startApiCall('UpdateEnvironment', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see EnvironmentsClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see EnvironmentsClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Dialogflow/src/V2/Client/FulfillmentsClient.php b/Dialogflow/src/V2/Client/FulfillmentsClient.php index 6cd6c0fe3cf0..f2d1e4e44ffa 100644 --- a/Dialogflow/src/V2/Client/FulfillmentsClient.php +++ b/Dialogflow/src/V2/Client/FulfillmentsClient.php @@ -24,17 +24,323 @@ namespace Google\Cloud\Dialogflow\V2\Client; -use Google\Cloud\Dialogflow\V2\Client\BaseClient\FulfillmentsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dialogflow\V2\Fulfillment; +use Google\Cloud\Dialogflow\V2\GetFulfillmentRequest; +use Google\Cloud\Dialogflow\V2\UpdateFulfillmentRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for managing [Fulfillments][google.cloud.dialogflow.v2.Fulfillment]. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dialogflow\V2\FulfillmentsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface getFulfillmentAsync(GetFulfillmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateFulfillmentAsync(UpdateFulfillmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class FulfillmentsClient extends FulfillmentsBaseClient +final class FulfillmentsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see FulfillmentsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dialogflow.v2.Fulfillments'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/dialogflow', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/fulfillments_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/fulfillments_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/fulfillments_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/fulfillments_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a fulfillment + * resource. + * + * @param string $project + * + * @return string The formatted fulfillment resource. + */ + public static function fulfillmentName(string $project): string + { + return self::getPathTemplate('fulfillment')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_fulfillment resource. + * + * @param string $project + * + * @return string The formatted project_fulfillment resource. + */ + public static function projectFulfillmentName(string $project): string + { + return self::getPathTemplate('projectFulfillment')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_fulfillment resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted project_location_fulfillment resource. + */ + public static function projectLocationFulfillmentName(string $project, string $location): string + { + return self::getPathTemplate('projectLocationFulfillment')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - fulfillment: projects/{project}/agent/fulfillment + * - projectFulfillment: projects/{project}/agent/fulfillment + * - projectLocationFulfillment: projects/{project}/locations/{location}/agent/fulfillment + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dialogflow.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves the fulfillment. + * + * The async variant is {@see FulfillmentsClient::getFulfillmentAsync()} . + * + * @param GetFulfillmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Fulfillment + * + * @throws ApiException Thrown if the API call fails. + */ + public function getFulfillment(GetFulfillmentRequest $request, array $callOptions = []): Fulfillment + { + return $this->startApiCall('GetFulfillment', $request, $callOptions)->wait(); + } + + /** + * Updates the fulfillment. + * + * The async variant is {@see FulfillmentsClient::updateFulfillmentAsync()} . + * + * @param UpdateFulfillmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Fulfillment + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateFulfillment(UpdateFulfillmentRequest $request, array $callOptions = []): Fulfillment + { + return $this->startApiCall('UpdateFulfillment', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see FulfillmentsClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see FulfillmentsClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Dialogflow/src/V2/Client/IntentsClient.php b/Dialogflow/src/V2/Client/IntentsClient.php index e95f6e5cc325..5dff8f38fbae 100644 --- a/Dialogflow/src/V2/Client/IntentsClient.php +++ b/Dialogflow/src/V2/Client/IntentsClient.php @@ -24,17 +24,796 @@ namespace Google\Cloud\Dialogflow\V2\Client; -use Google\Cloud\Dialogflow\V2\Client\BaseClient\IntentsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dialogflow\V2\BatchDeleteIntentsRequest; +use Google\Cloud\Dialogflow\V2\BatchUpdateIntentsRequest; +use Google\Cloud\Dialogflow\V2\BatchUpdateIntentsResponse; +use Google\Cloud\Dialogflow\V2\CreateIntentRequest; +use Google\Cloud\Dialogflow\V2\DeleteIntentRequest; +use Google\Cloud\Dialogflow\V2\GetIntentRequest; +use Google\Cloud\Dialogflow\V2\Intent; +use Google\Cloud\Dialogflow\V2\ListIntentsRequest; +use Google\Cloud\Dialogflow\V2\UpdateIntentRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use Google\Protobuf\Struct; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for managing [Intents][google.cloud.dialogflow.v2.Intent]. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dialogflow\V2\IntentsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface batchDeleteIntentsAsync(BatchDeleteIntentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface batchUpdateIntentsAsync(BatchUpdateIntentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface createIntentAsync(CreateIntentRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteIntentAsync(DeleteIntentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIntentAsync(GetIntentRequest $request, array $optionalArgs = []) + * @method PromiseInterface listIntentsAsync(ListIntentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateIntentAsync(UpdateIntentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class IntentsClient extends IntentsBaseClient +final class IntentsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see IntentsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dialogflow.v2.Intents'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/dialogflow', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/intents_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/intents_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/intents_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/intents_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a agent + * resource. + * + * @param string $project + * + * @return string The formatted agent resource. + */ + public static function agentName(string $project): string + { + return self::getPathTemplate('agent')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a context + * resource. + * + * @param string $project + * @param string $session + * @param string $context + * + * @return string The formatted context resource. + */ + public static function contextName(string $project, string $session, string $context): string + { + return self::getPathTemplate('context')->render([ + 'project' => $project, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a intent + * resource. + * + * @param string $project + * @param string $intent + * + * @return string The formatted intent resource. + */ + public static function intentName(string $project, string $intent): string + { + return self::getPathTemplate('intent')->render([ + 'project' => $project, + 'intent' => $intent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_agent resource. + * + * @param string $project + * + * @return string The formatted project_agent resource. + */ + public static function projectAgentName(string $project): string + { + return self::getPathTemplate('projectAgent')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_environment_user_session resource. + * + * @param string $project + * @param string $environment + * @param string $user + * @param string $session + * + * @return string The formatted project_environment_user_session resource. + */ + public static function projectEnvironmentUserSessionName(string $project, string $environment, string $user, string $session): string + { + return self::getPathTemplate('projectEnvironmentUserSession')->render([ + 'project' => $project, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_environment_user_session_context resource. + * + * @param string $project + * @param string $environment + * @param string $user + * @param string $session + * @param string $context + * + * @return string The formatted project_environment_user_session_context resource. + */ + public static function projectEnvironmentUserSessionContextName(string $project, string $environment, string $user, string $session, string $context): string + { + return self::getPathTemplate('projectEnvironmentUserSessionContext')->render([ + 'project' => $project, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_intent resource. + * + * @param string $project + * @param string $intent + * + * @return string The formatted project_intent resource. + */ + public static function projectIntentName(string $project, string $intent): string + { + return self::getPathTemplate('projectIntent')->render([ + 'project' => $project, + 'intent' => $intent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted project_location_agent resource. + */ + public static function projectLocationAgentName(string $project, string $location): string + { + return self::getPathTemplate('projectLocationAgent')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_environment_user_session resource. + * + * @param string $project + * @param string $location + * @param string $environment + * @param string $user + * @param string $session + * + * @return string The formatted project_location_environment_user_session resource. + */ + public static function projectLocationEnvironmentUserSessionName(string $project, string $location, string $environment, string $user, string $session): string + { + return self::getPathTemplate('projectLocationEnvironmentUserSession')->render([ + 'project' => $project, + 'location' => $location, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_environment_user_session_context resource. + * + * @param string $project + * @param string $location + * @param string $environment + * @param string $user + * @param string $session + * @param string $context + * + * @return string The formatted project_location_environment_user_session_context resource. + */ + public static function projectLocationEnvironmentUserSessionContextName(string $project, string $location, string $environment, string $user, string $session, string $context): string + { + return self::getPathTemplate('projectLocationEnvironmentUserSessionContext')->render([ + 'project' => $project, + 'location' => $location, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_intent resource. + * + * @param string $project + * @param string $location + * @param string $intent + * + * @return string The formatted project_location_intent resource. + */ + public static function projectLocationIntentName(string $project, string $location, string $intent): string + { + return self::getPathTemplate('projectLocationIntent')->render([ + 'project' => $project, + 'location' => $location, + 'intent' => $intent, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_session resource. + * + * @param string $project + * @param string $location + * @param string $session + * + * @return string The formatted project_location_session resource. + */ + public static function projectLocationSessionName(string $project, string $location, string $session): string + { + return self::getPathTemplate('projectLocationSession')->render([ + 'project' => $project, + 'location' => $location, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_session_context resource. + * + * @param string $project + * @param string $location + * @param string $session + * @param string $context + * + * @return string The formatted project_location_session_context resource. + */ + public static function projectLocationSessionContextName(string $project, string $location, string $session, string $context): string + { + return self::getPathTemplate('projectLocationSessionContext')->render([ + 'project' => $project, + 'location' => $location, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_session resource. + * + * @param string $project + * @param string $session + * + * @return string The formatted project_session resource. + */ + public static function projectSessionName(string $project, string $session): string + { + return self::getPathTemplate('projectSession')->render([ + 'project' => $project, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_session_context resource. + * + * @param string $project + * @param string $session + * @param string $context + * + * @return string The formatted project_session_context resource. + */ + public static function projectSessionContextName(string $project, string $session, string $context): string + { + return self::getPathTemplate('projectSessionContext')->render([ + 'project' => $project, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a session + * resource. + * + * @param string $project + * @param string $session + * + * @return string The formatted session resource. + */ + public static function sessionName(string $project, string $session): string + { + return self::getPathTemplate('session')->render([ + 'project' => $project, + 'session' => $session, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - agent: projects/{project}/agent + * - context: projects/{project}/agent/sessions/{session}/contexts/{context} + * - intent: projects/{project}/agent/intents/{intent} + * - projectAgent: projects/{project}/agent + * - projectEnvironmentUserSession: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session} + * - projectEnvironmentUserSessionContext: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context} + * - projectIntent: projects/{project}/agent/intents/{intent} + * - projectLocationAgent: projects/{project}/locations/{location}/agent + * - projectLocationEnvironmentUserSession: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session} + * - projectLocationEnvironmentUserSessionContext: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context} + * - projectLocationIntent: projects/{project}/locations/{location}/agent/intents/{intent} + * - projectLocationSession: projects/{project}/locations/{location}/agent/sessions/{session} + * - projectLocationSessionContext: projects/{project}/locations/{location}/agent/sessions/{session}/contexts/{context} + * - projectSession: projects/{project}/agent/sessions/{session} + * - projectSessionContext: projects/{project}/agent/sessions/{session}/contexts/{context} + * - session: projects/{project}/agent/sessions/{session} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dialogflow.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes intents in the specified agent. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: An empty [Struct + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) + * - `response`: An [Empty + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#empty) + * + * Note: You should always train an agent prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/es/docs/training). + * + * The async variant is {@see IntentsClient::batchDeleteIntentsAsync()} . + * + * @param BatchDeleteIntentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchDeleteIntents(BatchDeleteIntentsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchDeleteIntents', $request, $callOptions)->wait(); + } + + /** + * Updates/Creates multiple intents in the specified agent. + * + * This method is a [long-running + * operation](https://cloud.google.com/dialogflow/es/docs/how/long-running-operations). + * The returned `Operation` type has the following method-specific fields: + * + * - `metadata`: An empty [Struct + * message](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#struct) + * - `response`: + * [BatchUpdateIntentsResponse][google.cloud.dialogflow.v2.BatchUpdateIntentsResponse] + * + * Note: You should always train an agent prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/es/docs/training). + * + * The async variant is {@see IntentsClient::batchUpdateIntentsAsync()} . + * + * @param BatchUpdateIntentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchUpdateIntents(BatchUpdateIntentsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchUpdateIntents', $request, $callOptions)->wait(); + } + + /** + * Creates an intent in the specified agent. + * + * Note: You should always train an agent prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/es/docs/training). + * + * The async variant is {@see IntentsClient::createIntentAsync()} . + * + * @param CreateIntentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Intent + * + * @throws ApiException Thrown if the API call fails. + */ + public function createIntent(CreateIntentRequest $request, array $callOptions = []): Intent + { + return $this->startApiCall('CreateIntent', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified intent and its direct or indirect followup intents. + * + * Note: You should always train an agent prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/es/docs/training). + * + * The async variant is {@see IntentsClient::deleteIntentAsync()} . + * + * @param DeleteIntentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteIntent(DeleteIntentRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteIntent', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified intent. + * + * The async variant is {@see IntentsClient::getIntentAsync()} . + * + * @param GetIntentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Intent + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIntent(GetIntentRequest $request, array $callOptions = []): Intent + { + return $this->startApiCall('GetIntent', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all intents in the specified agent. + * + * The async variant is {@see IntentsClient::listIntentsAsync()} . + * + * @param ListIntentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listIntents(ListIntentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListIntents', $request, $callOptions); + } + + /** + * Updates the specified intent. + * + * Note: You should always train an agent prior to sending it queries. See the + * [training + * documentation](https://cloud.google.com/dialogflow/es/docs/training). + * + * The async variant is {@see IntentsClient::updateIntentAsync()} . + * + * @param UpdateIntentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Intent + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateIntent(UpdateIntentRequest $request, array $callOptions = []): Intent + { + return $this->startApiCall('UpdateIntent', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see IntentsClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see IntentsClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Dialogflow/src/V2/Client/KnowledgeBasesClient.php b/Dialogflow/src/V2/Client/KnowledgeBasesClient.php index dbc522469198..c3940e83a201 100644 --- a/Dialogflow/src/V2/Client/KnowledgeBasesClient.php +++ b/Dialogflow/src/V2/Client/KnowledgeBasesClient.php @@ -24,17 +24,440 @@ namespace Google\Cloud\Dialogflow\V2\Client; -use Google\Cloud\Dialogflow\V2\Client\BaseClient\KnowledgeBasesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dialogflow\V2\CreateKnowledgeBaseRequest; +use Google\Cloud\Dialogflow\V2\DeleteKnowledgeBaseRequest; +use Google\Cloud\Dialogflow\V2\GetKnowledgeBaseRequest; +use Google\Cloud\Dialogflow\V2\KnowledgeBase; +use Google\Cloud\Dialogflow\V2\ListKnowledgeBasesRequest; +use Google\Cloud\Dialogflow\V2\UpdateKnowledgeBaseRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for managing + * [KnowledgeBases][google.cloud.dialogflow.v2.KnowledgeBase]. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dialogflow\V2\KnowledgeBasesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createKnowledgeBaseAsync(CreateKnowledgeBaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteKnowledgeBaseAsync(DeleteKnowledgeBaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface getKnowledgeBaseAsync(GetKnowledgeBaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface listKnowledgeBasesAsync(ListKnowledgeBasesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateKnowledgeBaseAsync(UpdateKnowledgeBaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class KnowledgeBasesClient extends KnowledgeBasesBaseClient +final class KnowledgeBasesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see KnowledgeBasesBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dialogflow.v2.KnowledgeBases'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/dialogflow', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/knowledge_bases_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/knowledge_bases_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/knowledge_bases_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/knowledge_bases_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * knowledge_base resource. + * + * @param string $project + * @param string $knowledgeBase + * + * @return string The formatted knowledge_base resource. + */ + public static function knowledgeBaseName(string $project, string $knowledgeBase): string + { + return self::getPathTemplate('knowledgeBase')->render([ + 'project' => $project, + 'knowledge_base' => $knowledgeBase, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_knowledge_base resource. + * + * @param string $project + * @param string $knowledgeBase + * + * @return string The formatted project_knowledge_base resource. + */ + public static function projectKnowledgeBaseName(string $project, string $knowledgeBase): string + { + return self::getPathTemplate('projectKnowledgeBase')->render([ + 'project' => $project, + 'knowledge_base' => $knowledgeBase, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_knowledge_base resource. + * + * @param string $project + * @param string $location + * @param string $knowledgeBase + * + * @return string The formatted project_location_knowledge_base resource. + */ + public static function projectLocationKnowledgeBaseName(string $project, string $location, string $knowledgeBase): string + { + return self::getPathTemplate('projectLocationKnowledgeBase')->render([ + 'project' => $project, + 'location' => $location, + 'knowledge_base' => $knowledgeBase, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - knowledgeBase: projects/{project}/knowledgeBases/{knowledge_base} + * - location: projects/{project}/locations/{location} + * - project: projects/{project} + * - projectKnowledgeBase: projects/{project}/knowledgeBases/{knowledge_base} + * - projectLocationKnowledgeBase: projects/{project}/locations/{location}/knowledgeBases/{knowledge_base} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dialogflow.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a knowledge base. + * + * The async variant is {@see KnowledgeBasesClient::createKnowledgeBaseAsync()} . + * + * @param CreateKnowledgeBaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 KnowledgeBase + * + * @throws ApiException Thrown if the API call fails. + */ + public function createKnowledgeBase(CreateKnowledgeBaseRequest $request, array $callOptions = []): KnowledgeBase + { + return $this->startApiCall('CreateKnowledgeBase', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified knowledge base. + * + * The async variant is {@see KnowledgeBasesClient::deleteKnowledgeBaseAsync()} . + * + * @param DeleteKnowledgeBaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteKnowledgeBase(DeleteKnowledgeBaseRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteKnowledgeBase', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified knowledge base. + * + * The async variant is {@see KnowledgeBasesClient::getKnowledgeBaseAsync()} . + * + * @param GetKnowledgeBaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 KnowledgeBase + * + * @throws ApiException Thrown if the API call fails. + */ + public function getKnowledgeBase(GetKnowledgeBaseRequest $request, array $callOptions = []): KnowledgeBase + { + return $this->startApiCall('GetKnowledgeBase', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all knowledge bases of the specified agent. + * + * The async variant is {@see KnowledgeBasesClient::listKnowledgeBasesAsync()} . + * + * @param ListKnowledgeBasesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listKnowledgeBases(ListKnowledgeBasesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListKnowledgeBases', $request, $callOptions); + } + + /** + * Updates the specified knowledge base. + * + * The async variant is {@see KnowledgeBasesClient::updateKnowledgeBaseAsync()} . + * + * @param UpdateKnowledgeBaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 KnowledgeBase + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateKnowledgeBase(UpdateKnowledgeBaseRequest $request, array $callOptions = []): KnowledgeBase + { + return $this->startApiCall('UpdateKnowledgeBase', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see KnowledgeBasesClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see KnowledgeBasesClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Dialogflow/src/V2/Client/ParticipantsClient.php b/Dialogflow/src/V2/Client/ParticipantsClient.php index ff8605444557..835ef5430b26 100644 --- a/Dialogflow/src/V2/Client/ParticipantsClient.php +++ b/Dialogflow/src/V2/Client/ParticipantsClient.php @@ -24,17 +24,981 @@ namespace Google\Cloud\Dialogflow\V2\Client; -use Google\Cloud\Dialogflow\V2\Client\BaseClient\ParticipantsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\BidiStream; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dialogflow\V2\AnalyzeContentRequest; +use Google\Cloud\Dialogflow\V2\AnalyzeContentResponse; +use Google\Cloud\Dialogflow\V2\CreateParticipantRequest; +use Google\Cloud\Dialogflow\V2\GetParticipantRequest; +use Google\Cloud\Dialogflow\V2\ListParticipantsRequest; +use Google\Cloud\Dialogflow\V2\Participant; +use Google\Cloud\Dialogflow\V2\SuggestArticlesRequest; +use Google\Cloud\Dialogflow\V2\SuggestArticlesResponse; +use Google\Cloud\Dialogflow\V2\SuggestFaqAnswersRequest; +use Google\Cloud\Dialogflow\V2\SuggestFaqAnswersResponse; +use Google\Cloud\Dialogflow\V2\SuggestSmartRepliesRequest; +use Google\Cloud\Dialogflow\V2\SuggestSmartRepliesResponse; +use Google\Cloud\Dialogflow\V2\UpdateParticipantRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for managing [Participants][google.cloud.dialogflow.v2.Participant]. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dialogflow\V2\ParticipantsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface analyzeContentAsync(AnalyzeContentRequest $request, array $optionalArgs = []) + * @method PromiseInterface createParticipantAsync(CreateParticipantRequest $request, array $optionalArgs = []) + * @method PromiseInterface getParticipantAsync(GetParticipantRequest $request, array $optionalArgs = []) + * @method PromiseInterface listParticipantsAsync(ListParticipantsRequest $request, array $optionalArgs = []) + * @method PromiseInterface suggestArticlesAsync(SuggestArticlesRequest $request, array $optionalArgs = []) + * @method PromiseInterface suggestFaqAnswersAsync(SuggestFaqAnswersRequest $request, array $optionalArgs = []) + * @method PromiseInterface suggestSmartRepliesAsync(SuggestSmartRepliesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateParticipantAsync(UpdateParticipantRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class ParticipantsClient extends ParticipantsBaseClient +final class ParticipantsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ParticipantsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dialogflow.v2.Participants'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/dialogflow', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/participants_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/participants_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/participants_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/participants_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a context + * resource. + * + * @param string $project + * @param string $session + * @param string $context + * + * @return string The formatted context resource. + */ + public static function contextName(string $project, string $session, string $context): string + { + return self::getPathTemplate('context')->render([ + 'project' => $project, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a conversation + * resource. + * + * @param string $project + * @param string $conversation + * + * @return string The formatted conversation resource. + */ + public static function conversationName(string $project, string $conversation): string + { + return self::getPathTemplate('conversation')->render([ + 'project' => $project, + 'conversation' => $conversation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a message + * resource. + * + * @param string $project + * @param string $conversation + * @param string $message + * + * @return string The formatted message resource. + */ + public static function messageName(string $project, string $conversation, string $message): string + { + return self::getPathTemplate('message')->render([ + 'project' => $project, + 'conversation' => $conversation, + 'message' => $message, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a participant + * resource. + * + * @param string $project + * @param string $conversation + * @param string $participant + * + * @return string The formatted participant resource. + */ + public static function participantName(string $project, string $conversation, string $participant): string + { + return self::getPathTemplate('participant')->render([ + 'project' => $project, + 'conversation' => $conversation, + 'participant' => $participant, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_conversation resource. + * + * @param string $project + * @param string $conversation + * + * @return string The formatted project_conversation resource. + */ + public static function projectConversationName(string $project, string $conversation): string + { + return self::getPathTemplate('projectConversation')->render([ + 'project' => $project, + 'conversation' => $conversation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_conversation_message resource. + * + * @param string $project + * @param string $conversation + * @param string $message + * + * @return string The formatted project_conversation_message resource. + */ + public static function projectConversationMessageName(string $project, string $conversation, string $message): string + { + return self::getPathTemplate('projectConversationMessage')->render([ + 'project' => $project, + 'conversation' => $conversation, + 'message' => $message, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_conversation_participant resource. + * + * @param string $project + * @param string $conversation + * @param string $participant + * + * @return string The formatted project_conversation_participant resource. + */ + public static function projectConversationParticipantName(string $project, string $conversation, string $participant): string + { + return self::getPathTemplate('projectConversationParticipant')->render([ + 'project' => $project, + 'conversation' => $conversation, + 'participant' => $participant, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_environment_user_session resource. + * + * @param string $project + * @param string $environment + * @param string $user + * @param string $session + * + * @return string The formatted project_environment_user_session resource. + */ + public static function projectEnvironmentUserSessionName(string $project, string $environment, string $user, string $session): string + { + return self::getPathTemplate('projectEnvironmentUserSession')->render([ + 'project' => $project, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_environment_user_session_context resource. + * + * @param string $project + * @param string $environment + * @param string $user + * @param string $session + * @param string $context + * + * @return string The formatted project_environment_user_session_context resource. + */ + public static function projectEnvironmentUserSessionContextName(string $project, string $environment, string $user, string $session, string $context): string + { + return self::getPathTemplate('projectEnvironmentUserSessionContext')->render([ + 'project' => $project, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_environment_user_session_entity_type resource. + * + * @param string $project + * @param string $environment + * @param string $user + * @param string $session + * @param string $entityType + * + * @return string The formatted project_environment_user_session_entity_type resource. + */ + public static function projectEnvironmentUserSessionEntityTypeName(string $project, string $environment, string $user, string $session, string $entityType): string + { + return self::getPathTemplate('projectEnvironmentUserSessionEntityType')->render([ + 'project' => $project, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_conversation resource. + * + * @param string $project + * @param string $location + * @param string $conversation + * + * @return string The formatted project_location_conversation resource. + */ + public static function projectLocationConversationName(string $project, string $location, string $conversation): string + { + return self::getPathTemplate('projectLocationConversation')->render([ + 'project' => $project, + 'location' => $location, + 'conversation' => $conversation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_conversation_message resource. + * + * @param string $project + * @param string $location + * @param string $conversation + * @param string $message + * + * @return string The formatted project_location_conversation_message resource. + */ + public static function projectLocationConversationMessageName(string $project, string $location, string $conversation, string $message): string + { + return self::getPathTemplate('projectLocationConversationMessage')->render([ + 'project' => $project, + 'location' => $location, + 'conversation' => $conversation, + 'message' => $message, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_conversation_participant resource. + * + * @param string $project + * @param string $location + * @param string $conversation + * @param string $participant + * + * @return string The formatted project_location_conversation_participant resource. + */ + public static function projectLocationConversationParticipantName(string $project, string $location, string $conversation, string $participant): string + { + return self::getPathTemplate('projectLocationConversationParticipant')->render([ + 'project' => $project, + 'location' => $location, + 'conversation' => $conversation, + 'participant' => $participant, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_environment_user_session resource. + * + * @param string $project + * @param string $location + * @param string $environment + * @param string $user + * @param string $session + * + * @return string The formatted project_location_environment_user_session resource. + */ + public static function projectLocationEnvironmentUserSessionName(string $project, string $location, string $environment, string $user, string $session): string + { + return self::getPathTemplate('projectLocationEnvironmentUserSession')->render([ + 'project' => $project, + 'location' => $location, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_environment_user_session_context resource. + * + * @param string $project + * @param string $location + * @param string $environment + * @param string $user + * @param string $session + * @param string $context + * + * @return string The formatted project_location_environment_user_session_context resource. + */ + public static function projectLocationEnvironmentUserSessionContextName(string $project, string $location, string $environment, string $user, string $session, string $context): string + { + return self::getPathTemplate('projectLocationEnvironmentUserSessionContext')->render([ + 'project' => $project, + 'location' => $location, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_environment_user_session_entity_type resource. + * + * @param string $project + * @param string $location + * @param string $environment + * @param string $user + * @param string $session + * @param string $entityType + * + * @return string The formatted project_location_environment_user_session_entity_type resource. + */ + public static function projectLocationEnvironmentUserSessionEntityTypeName(string $project, string $location, string $environment, string $user, string $session, string $entityType): string + { + return self::getPathTemplate('projectLocationEnvironmentUserSessionEntityType')->render([ + 'project' => $project, + 'location' => $location, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_session resource. + * + * @param string $project + * @param string $location + * @param string $session + * + * @return string The formatted project_location_session resource. + */ + public static function projectLocationSessionName(string $project, string $location, string $session): string + { + return self::getPathTemplate('projectLocationSession')->render([ + 'project' => $project, + 'location' => $location, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_session_context resource. + * + * @param string $project + * @param string $location + * @param string $session + * @param string $context + * + * @return string The formatted project_location_session_context resource. + */ + public static function projectLocationSessionContextName(string $project, string $location, string $session, string $context): string + { + return self::getPathTemplate('projectLocationSessionContext')->render([ + 'project' => $project, + 'location' => $location, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_session_entity_type resource. + * + * @param string $project + * @param string $location + * @param string $session + * @param string $entityType + * + * @return string The formatted project_location_session_entity_type resource. + */ + public static function projectLocationSessionEntityTypeName(string $project, string $location, string $session, string $entityType): string + { + return self::getPathTemplate('projectLocationSessionEntityType')->render([ + 'project' => $project, + 'location' => $location, + 'session' => $session, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_session resource. + * + * @param string $project + * @param string $session + * + * @return string The formatted project_session resource. + */ + public static function projectSessionName(string $project, string $session): string + { + return self::getPathTemplate('projectSession')->render([ + 'project' => $project, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_session_context resource. + * + * @param string $project + * @param string $session + * @param string $context + * + * @return string The formatted project_session_context resource. + */ + public static function projectSessionContextName(string $project, string $session, string $context): string + { + return self::getPathTemplate('projectSessionContext')->render([ + 'project' => $project, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_session_entity_type resource. + * + * @param string $project + * @param string $session + * @param string $entityType + * + * @return string The formatted project_session_entity_type resource. + */ + public static function projectSessionEntityTypeName(string $project, string $session, string $entityType): string + { + return self::getPathTemplate('projectSessionEntityType')->render([ + 'project' => $project, + 'session' => $session, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a session + * resource. + * + * @param string $project + * @param string $session + * + * @return string The formatted session resource. + */ + public static function sessionName(string $project, string $session): string + { + return self::getPathTemplate('session')->render([ + 'project' => $project, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * session_entity_type resource. + * + * @param string $project + * @param string $session + * @param string $entityType + * + * @return string The formatted session_entity_type resource. + */ + public static function sessionEntityTypeName(string $project, string $session, string $entityType): string + { + return self::getPathTemplate('sessionEntityType')->render([ + 'project' => $project, + 'session' => $session, + 'entity_type' => $entityType, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - context: projects/{project}/agent/sessions/{session}/contexts/{context} + * - conversation: projects/{project}/conversations/{conversation} + * - message: projects/{project}/conversations/{conversation}/messages/{message} + * - participant: projects/{project}/conversations/{conversation}/participants/{participant} + * - projectConversation: projects/{project}/conversations/{conversation} + * - projectConversationMessage: projects/{project}/conversations/{conversation}/messages/{message} + * - projectConversationParticipant: projects/{project}/conversations/{conversation}/participants/{participant} + * - projectEnvironmentUserSession: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session} + * - projectEnvironmentUserSessionContext: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context} + * - projectEnvironmentUserSessionEntityType: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}/entityTypes/{entity_type} + * - projectLocationConversation: projects/{project}/locations/{location}/conversations/{conversation} + * - projectLocationConversationMessage: projects/{project}/locations/{location}/conversations/{conversation}/messages/{message} + * - projectLocationConversationParticipant: projects/{project}/locations/{location}/conversations/{conversation}/participants/{participant} + * - projectLocationEnvironmentUserSession: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session} + * - projectLocationEnvironmentUserSessionContext: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context} + * - projectLocationEnvironmentUserSessionEntityType: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session}/entityTypes/{entity_type} + * - projectLocationSession: projects/{project}/locations/{location}/agent/sessions/{session} + * - projectLocationSessionContext: projects/{project}/locations/{location}/agent/sessions/{session}/contexts/{context} + * - projectLocationSessionEntityType: projects/{project}/locations/{location}/agent/sessions/{session}/entityTypes/{entity_type} + * - projectSession: projects/{project}/agent/sessions/{session} + * - projectSessionContext: projects/{project}/agent/sessions/{session}/contexts/{context} + * - projectSessionEntityType: projects/{project}/agent/sessions/{session}/entityTypes/{entity_type} + * - session: projects/{project}/agent/sessions/{session} + * - sessionEntityType: projects/{project}/agent/sessions/{session}/entityTypes/{entity_type} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dialogflow.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Adds a text (chat, for example), or audio (phone recording, for example) + * message from a participant into the conversation. + * + * Note: Always use agent versions for production traffic + * sent to virtual agents. See [Versions and + * environments](https://cloud.google.com/dialogflow/es/docs/agents-versions). + * + * The async variant is {@see ParticipantsClient::analyzeContentAsync()} . + * + * @param AnalyzeContentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AnalyzeContentResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function analyzeContent(AnalyzeContentRequest $request, array $callOptions = []): AnalyzeContentResponse + { + return $this->startApiCall('AnalyzeContent', $request, $callOptions)->wait(); + } + + /** + * Creates a new participant in a conversation. + * + * The async variant is {@see ParticipantsClient::createParticipantAsync()} . + * + * @param CreateParticipantRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Participant + * + * @throws ApiException Thrown if the API call fails. + */ + public function createParticipant(CreateParticipantRequest $request, array $callOptions = []): Participant + { + return $this->startApiCall('CreateParticipant', $request, $callOptions)->wait(); + } + + /** + * Retrieves a conversation participant. + * + * The async variant is {@see ParticipantsClient::getParticipantAsync()} . + * + * @param GetParticipantRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Participant + * + * @throws ApiException Thrown if the API call fails. + */ + public function getParticipant(GetParticipantRequest $request, array $callOptions = []): Participant + { + return $this->startApiCall('GetParticipant', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all participants in the specified conversation. + * + * The async variant is {@see ParticipantsClient::listParticipantsAsync()} . + * + * @param ListParticipantsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listParticipants(ListParticipantsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListParticipants', $request, $callOptions); + } + + /** + * Adds a text (chat, for example), or audio (phone recording, for example) + * message from a participant into the conversation. + * Note: This method is only available through the gRPC API (not REST). + * + * The top-level message sent to the client by the server is + * `StreamingAnalyzeContentResponse`. Multiple response messages can be + * returned in order. The first one or more messages contain the + * `recognition_result` field. Each result represents a more complete + * transcript of what the user said. The next message contains the + * `reply_text` field and potentially the `reply_audio` field. The message can + * also contain the `automated_agent_reply` field. + * + * Note: Always use agent versions for production traffic + * sent to virtual agents. See [Versions and + * environments](https://cloud.google.com/dialogflow/es/docs/agents-versions). + * + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return BidiStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function streamingAnalyzeContent(array $callOptions = []): BidiStream + { + return $this->startApiCall('StreamingAnalyzeContent', null, $callOptions); + } + + /** + * Gets suggested articles for a participant based on specific historical + * messages. + * + * The async variant is {@see ParticipantsClient::suggestArticlesAsync()} . + * + * @param SuggestArticlesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SuggestArticlesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function suggestArticles(SuggestArticlesRequest $request, array $callOptions = []): SuggestArticlesResponse + { + return $this->startApiCall('SuggestArticles', $request, $callOptions)->wait(); + } + + /** + * Gets suggested faq answers for a participant based on specific historical + * messages. + * + * The async variant is {@see ParticipantsClient::suggestFaqAnswersAsync()} . + * + * @param SuggestFaqAnswersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SuggestFaqAnswersResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function suggestFaqAnswers(SuggestFaqAnswersRequest $request, array $callOptions = []): SuggestFaqAnswersResponse + { + return $this->startApiCall('SuggestFaqAnswers', $request, $callOptions)->wait(); + } + + /** + * Gets smart replies for a participant based on specific historical + * messages. + * + * The async variant is {@see ParticipantsClient::suggestSmartRepliesAsync()} . + * + * @param SuggestSmartRepliesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SuggestSmartRepliesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function suggestSmartReplies(SuggestSmartRepliesRequest $request, array $callOptions = []): SuggestSmartRepliesResponse + { + return $this->startApiCall('SuggestSmartReplies', $request, $callOptions)->wait(); + } + + /** + * Updates the specified participant. + * + * The async variant is {@see ParticipantsClient::updateParticipantAsync()} . + * + * @param UpdateParticipantRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Participant + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateParticipant(UpdateParticipantRequest $request, array $callOptions = []): Participant + { + return $this->startApiCall('UpdateParticipant', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see ParticipantsClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see ParticipantsClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Dialogflow/src/V2/Client/SessionEntityTypesClient.php b/Dialogflow/src/V2/Client/SessionEntityTypesClient.php index b511af11cc46..87b70eeef8af 100644 --- a/Dialogflow/src/V2/Client/SessionEntityTypesClient.php +++ b/Dialogflow/src/V2/Client/SessionEntityTypesClient.php @@ -24,17 +24,593 @@ namespace Google\Cloud\Dialogflow\V2\Client; -use Google\Cloud\Dialogflow\V2\Client\BaseClient\SessionEntityTypesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dialogflow\V2\CreateSessionEntityTypeRequest; +use Google\Cloud\Dialogflow\V2\DeleteSessionEntityTypeRequest; +use Google\Cloud\Dialogflow\V2\GetSessionEntityTypeRequest; +use Google\Cloud\Dialogflow\V2\ListSessionEntityTypesRequest; +use Google\Cloud\Dialogflow\V2\SessionEntityType; +use Google\Cloud\Dialogflow\V2\UpdateSessionEntityTypeRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for managing + * [SessionEntityTypes][google.cloud.dialogflow.v2.SessionEntityType]. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dialogflow\V2\SessionEntityTypesClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createSessionEntityTypeAsync(CreateSessionEntityTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSessionEntityTypeAsync(DeleteSessionEntityTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSessionEntityTypeAsync(GetSessionEntityTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSessionEntityTypesAsync(ListSessionEntityTypesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSessionEntityTypeAsync(UpdateSessionEntityTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class SessionEntityTypesClient extends SessionEntityTypesBaseClient +final class SessionEntityTypesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SessionEntityTypesBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dialogflow.v2.SessionEntityTypes'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/dialogflow', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/session_entity_types_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/session_entity_types_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/session_entity_types_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/session_entity_types_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_environment_user_session resource. + * + * @param string $project + * @param string $environment + * @param string $user + * @param string $session + * + * @return string The formatted project_environment_user_session resource. + */ + public static function projectEnvironmentUserSessionName(string $project, string $environment, string $user, string $session): string + { + return self::getPathTemplate('projectEnvironmentUserSession')->render([ + 'project' => $project, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_environment_user_session_entity_type resource. + * + * @param string $project + * @param string $environment + * @param string $user + * @param string $session + * @param string $entityType + * + * @return string The formatted project_environment_user_session_entity_type resource. + */ + public static function projectEnvironmentUserSessionEntityTypeName(string $project, string $environment, string $user, string $session, string $entityType): string + { + return self::getPathTemplate('projectEnvironmentUserSessionEntityType')->render([ + 'project' => $project, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_environment_user_session resource. + * + * @param string $project + * @param string $location + * @param string $environment + * @param string $user + * @param string $session + * + * @return string The formatted project_location_environment_user_session resource. + */ + public static function projectLocationEnvironmentUserSessionName(string $project, string $location, string $environment, string $user, string $session): string + { + return self::getPathTemplate('projectLocationEnvironmentUserSession')->render([ + 'project' => $project, + 'location' => $location, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_environment_user_session_entity_type resource. + * + * @param string $project + * @param string $location + * @param string $environment + * @param string $user + * @param string $session + * @param string $entityType + * + * @return string The formatted project_location_environment_user_session_entity_type resource. + */ + public static function projectLocationEnvironmentUserSessionEntityTypeName(string $project, string $location, string $environment, string $user, string $session, string $entityType): string + { + return self::getPathTemplate('projectLocationEnvironmentUserSessionEntityType')->render([ + 'project' => $project, + 'location' => $location, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_session resource. + * + * @param string $project + * @param string $location + * @param string $session + * + * @return string The formatted project_location_session resource. + */ + public static function projectLocationSessionName(string $project, string $location, string $session): string + { + return self::getPathTemplate('projectLocationSession')->render([ + 'project' => $project, + 'location' => $location, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_session_entity_type resource. + * + * @param string $project + * @param string $location + * @param string $session + * @param string $entityType + * + * @return string The formatted project_location_session_entity_type resource. + */ + public static function projectLocationSessionEntityTypeName(string $project, string $location, string $session, string $entityType): string + { + return self::getPathTemplate('projectLocationSessionEntityType')->render([ + 'project' => $project, + 'location' => $location, + 'session' => $session, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_session resource. + * + * @param string $project + * @param string $session + * + * @return string The formatted project_session resource. + */ + public static function projectSessionName(string $project, string $session): string + { + return self::getPathTemplate('projectSession')->render([ + 'project' => $project, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_session_entity_type resource. + * + * @param string $project + * @param string $session + * @param string $entityType + * + * @return string The formatted project_session_entity_type resource. + */ + public static function projectSessionEntityTypeName(string $project, string $session, string $entityType): string + { + return self::getPathTemplate('projectSessionEntityType')->render([ + 'project' => $project, + 'session' => $session, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a session + * resource. + * + * @param string $project + * @param string $session + * + * @return string The formatted session resource. + */ + public static function sessionName(string $project, string $session): string + { + return self::getPathTemplate('session')->render([ + 'project' => $project, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * session_entity_type resource. + * + * @param string $project + * @param string $session + * @param string $entityType + * + * @return string The formatted session_entity_type resource. + */ + public static function sessionEntityTypeName(string $project, string $session, string $entityType): string + { + return self::getPathTemplate('sessionEntityType')->render([ + 'project' => $project, + 'session' => $session, + 'entity_type' => $entityType, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - projectEnvironmentUserSession: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session} + * - projectEnvironmentUserSessionEntityType: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}/entityTypes/{entity_type} + * - projectLocationEnvironmentUserSession: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session} + * - projectLocationEnvironmentUserSessionEntityType: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session}/entityTypes/{entity_type} + * - projectLocationSession: projects/{project}/locations/{location}/agent/sessions/{session} + * - projectLocationSessionEntityType: projects/{project}/locations/{location}/agent/sessions/{session}/entityTypes/{entity_type} + * - projectSession: projects/{project}/agent/sessions/{session} + * - projectSessionEntityType: projects/{project}/agent/sessions/{session}/entityTypes/{entity_type} + * - session: projects/{project}/agent/sessions/{session} + * - sessionEntityType: projects/{project}/agent/sessions/{session}/entityTypes/{entity_type} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dialogflow.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a session entity type. + * + * If the specified session entity type already exists, overrides the session + * entity type. + * + * This method doesn't work with Google Assistant integration. + * Contact Dialogflow support if you need to use session entities + * with Google Assistant integration. + * + * The async variant is + * {@see SessionEntityTypesClient::createSessionEntityTypeAsync()} . + * + * @param CreateSessionEntityTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SessionEntityType + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSessionEntityType(CreateSessionEntityTypeRequest $request, array $callOptions = []): SessionEntityType + { + return $this->startApiCall('CreateSessionEntityType', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified session entity type. + * + * This method doesn't work with Google Assistant integration. + * Contact Dialogflow support if you need to use session entities + * with Google Assistant integration. + * + * The async variant is + * {@see SessionEntityTypesClient::deleteSessionEntityTypeAsync()} . + * + * @param DeleteSessionEntityTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSessionEntityType(DeleteSessionEntityTypeRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteSessionEntityType', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified session entity type. + * + * This method doesn't work with Google Assistant integration. + * Contact Dialogflow support if you need to use session entities + * with Google Assistant integration. + * + * The async variant is + * {@see SessionEntityTypesClient::getSessionEntityTypeAsync()} . + * + * @param GetSessionEntityTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SessionEntityType + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSessionEntityType(GetSessionEntityTypeRequest $request, array $callOptions = []): SessionEntityType + { + return $this->startApiCall('GetSessionEntityType', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all session entity types in the specified session. + * + * This method doesn't work with Google Assistant integration. + * Contact Dialogflow support if you need to use session entities + * with Google Assistant integration. + * + * The async variant is + * {@see SessionEntityTypesClient::listSessionEntityTypesAsync()} . + * + * @param ListSessionEntityTypesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSessionEntityTypes(ListSessionEntityTypesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSessionEntityTypes', $request, $callOptions); + } + + /** + * Updates the specified session entity type. + * + * This method doesn't work with Google Assistant integration. + * Contact Dialogflow support if you need to use session entities + * with Google Assistant integration. + * + * The async variant is + * {@see SessionEntityTypesClient::updateSessionEntityTypeAsync()} . + * + * @param UpdateSessionEntityTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SessionEntityType + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSessionEntityType(UpdateSessionEntityTypeRequest $request, array $callOptions = []): SessionEntityType + { + return $this->startApiCall('UpdateSessionEntityType', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see SessionEntityTypesClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see SessionEntityTypesClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Dialogflow/src/V2/Client/SessionsClient.php b/Dialogflow/src/V2/Client/SessionsClient.php index b530047c938a..f8a9471f97eb 100644 --- a/Dialogflow/src/V2/Client/SessionsClient.php +++ b/Dialogflow/src/V2/Client/SessionsClient.php @@ -24,17 +24,623 @@ namespace Google\Cloud\Dialogflow\V2\Client; -use Google\Cloud\Dialogflow\V2\Client\BaseClient\SessionsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\BidiStream; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dialogflow\V2\DetectIntentRequest; +use Google\Cloud\Dialogflow\V2\DetectIntentResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service used for session interactions. * - * This class is currently experimental and may be subject to changes. + * For more information, see the [API interactions + * guide](https://cloud.google.com/dialogflow/docs/api-overview). + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dialogflow\V2\SessionsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface detectIntentAsync(DetectIntentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class SessionsClient extends SessionsBaseClient +final class SessionsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SessionsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dialogflow.v2.Sessions'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/dialogflow', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/sessions_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/sessions_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/sessions_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/sessions_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a context + * resource. + * + * @param string $project + * @param string $session + * @param string $context + * + * @return string The formatted context resource. + */ + public static function contextName(string $project, string $session, string $context): string + { + return self::getPathTemplate('context')->render([ + 'project' => $project, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_environment_user_session resource. + * + * @param string $project + * @param string $environment + * @param string $user + * @param string $session + * + * @return string The formatted project_environment_user_session resource. + */ + public static function projectEnvironmentUserSessionName(string $project, string $environment, string $user, string $session): string + { + return self::getPathTemplate('projectEnvironmentUserSession')->render([ + 'project' => $project, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_environment_user_session_context resource. + * + * @param string $project + * @param string $environment + * @param string $user + * @param string $session + * @param string $context + * + * @return string The formatted project_environment_user_session_context resource. + */ + public static function projectEnvironmentUserSessionContextName(string $project, string $environment, string $user, string $session, string $context): string + { + return self::getPathTemplate('projectEnvironmentUserSessionContext')->render([ + 'project' => $project, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_environment_user_session_entity_type resource. + * + * @param string $project + * @param string $environment + * @param string $user + * @param string $session + * @param string $entityType + * + * @return string The formatted project_environment_user_session_entity_type resource. + */ + public static function projectEnvironmentUserSessionEntityTypeName(string $project, string $environment, string $user, string $session, string $entityType): string + { + return self::getPathTemplate('projectEnvironmentUserSessionEntityType')->render([ + 'project' => $project, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_environment_user_session resource. + * + * @param string $project + * @param string $location + * @param string $environment + * @param string $user + * @param string $session + * + * @return string The formatted project_location_environment_user_session resource. + */ + public static function projectLocationEnvironmentUserSessionName(string $project, string $location, string $environment, string $user, string $session): string + { + return self::getPathTemplate('projectLocationEnvironmentUserSession')->render([ + 'project' => $project, + 'location' => $location, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_environment_user_session_context resource. + * + * @param string $project + * @param string $location + * @param string $environment + * @param string $user + * @param string $session + * @param string $context + * + * @return string The formatted project_location_environment_user_session_context resource. + */ + public static function projectLocationEnvironmentUserSessionContextName(string $project, string $location, string $environment, string $user, string $session, string $context): string + { + return self::getPathTemplate('projectLocationEnvironmentUserSessionContext')->render([ + 'project' => $project, + 'location' => $location, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_environment_user_session_entity_type resource. + * + * @param string $project + * @param string $location + * @param string $environment + * @param string $user + * @param string $session + * @param string $entityType + * + * @return string The formatted project_location_environment_user_session_entity_type resource. + */ + public static function projectLocationEnvironmentUserSessionEntityTypeName(string $project, string $location, string $environment, string $user, string $session, string $entityType): string + { + return self::getPathTemplate('projectLocationEnvironmentUserSessionEntityType')->render([ + 'project' => $project, + 'location' => $location, + 'environment' => $environment, + 'user' => $user, + 'session' => $session, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_session resource. + * + * @param string $project + * @param string $location + * @param string $session + * + * @return string The formatted project_location_session resource. + */ + public static function projectLocationSessionName(string $project, string $location, string $session): string + { + return self::getPathTemplate('projectLocationSession')->render([ + 'project' => $project, + 'location' => $location, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_session_context resource. + * + * @param string $project + * @param string $location + * @param string $session + * @param string $context + * + * @return string The formatted project_location_session_context resource. + */ + public static function projectLocationSessionContextName(string $project, string $location, string $session, string $context): string + { + return self::getPathTemplate('projectLocationSessionContext')->render([ + 'project' => $project, + 'location' => $location, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_session_entity_type resource. + * + * @param string $project + * @param string $location + * @param string $session + * @param string $entityType + * + * @return string The formatted project_location_session_entity_type resource. + */ + public static function projectLocationSessionEntityTypeName(string $project, string $location, string $session, string $entityType): string + { + return self::getPathTemplate('projectLocationSessionEntityType')->render([ + 'project' => $project, + 'location' => $location, + 'session' => $session, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_session resource. + * + * @param string $project + * @param string $session + * + * @return string The formatted project_session resource. + */ + public static function projectSessionName(string $project, string $session): string + { + return self::getPathTemplate('projectSession')->render([ + 'project' => $project, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_session_context resource. + * + * @param string $project + * @param string $session + * @param string $context + * + * @return string The formatted project_session_context resource. + */ + public static function projectSessionContextName(string $project, string $session, string $context): string + { + return self::getPathTemplate('projectSessionContext')->render([ + 'project' => $project, + 'session' => $session, + 'context' => $context, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_session_entity_type resource. + * + * @param string $project + * @param string $session + * @param string $entityType + * + * @return string The formatted project_session_entity_type resource. + */ + public static function projectSessionEntityTypeName(string $project, string $session, string $entityType): string + { + return self::getPathTemplate('projectSessionEntityType')->render([ + 'project' => $project, + 'session' => $session, + 'entity_type' => $entityType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a session + * resource. + * + * @param string $project + * @param string $session + * + * @return string The formatted session resource. + */ + public static function sessionName(string $project, string $session): string + { + return self::getPathTemplate('session')->render([ + 'project' => $project, + 'session' => $session, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * session_entity_type resource. + * + * @param string $project + * @param string $session + * @param string $entityType + * + * @return string The formatted session_entity_type resource. + */ + public static function sessionEntityTypeName(string $project, string $session, string $entityType): string + { + return self::getPathTemplate('sessionEntityType')->render([ + 'project' => $project, + 'session' => $session, + 'entity_type' => $entityType, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - context: projects/{project}/agent/sessions/{session}/contexts/{context} + * - projectEnvironmentUserSession: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session} + * - projectEnvironmentUserSessionContext: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context} + * - projectEnvironmentUserSessionEntityType: projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}/entityTypes/{entity_type} + * - projectLocationEnvironmentUserSession: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session} + * - projectLocationEnvironmentUserSessionContext: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context} + * - projectLocationEnvironmentUserSessionEntityType: projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session}/entityTypes/{entity_type} + * - projectLocationSession: projects/{project}/locations/{location}/agent/sessions/{session} + * - projectLocationSessionContext: projects/{project}/locations/{location}/agent/sessions/{session}/contexts/{context} + * - projectLocationSessionEntityType: projects/{project}/locations/{location}/agent/sessions/{session}/entityTypes/{entity_type} + * - projectSession: projects/{project}/agent/sessions/{session} + * - projectSessionContext: projects/{project}/agent/sessions/{session}/contexts/{context} + * - projectSessionEntityType: projects/{project}/agent/sessions/{session}/entityTypes/{entity_type} + * - session: projects/{project}/agent/sessions/{session} + * - sessionEntityType: projects/{project}/agent/sessions/{session}/entityTypes/{entity_type} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dialogflow.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Processes a natural language query and returns structured, actionable data + * as a result. This method is not idempotent, because it may cause contexts + * and session entity types to be updated, which in turn might affect + * results of future queries. + * + * If you might use + * [Agent Assist](https://cloud.google.com/dialogflow/docs/#aa) + * or other CCAI products now or in the future, consider using + * [AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent] + * instead of `DetectIntent`. `AnalyzeContent` has additional + * functionality for Agent Assist and other CCAI products. + * + * Note: Always use agent versions for production traffic. + * See [Versions and + * environments](https://cloud.google.com/dialogflow/es/docs/agents-versions). + * + * The async variant is {@see SessionsClient::detectIntentAsync()} . + * + * @param DetectIntentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DetectIntentResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function detectIntent(DetectIntentRequest $request, array $callOptions = []): DetectIntentResponse + { + return $this->startApiCall('DetectIntent', $request, $callOptions)->wait(); + } + + /** + * Processes a natural language query in audio format in a streaming fashion + * and returns structured, actionable data as a result. This method is only + * available via the gRPC API (not REST). + * + * If you might use + * [Agent Assist](https://cloud.google.com/dialogflow/docs/#aa) + * or other CCAI products now or in the future, consider using + * [StreamingAnalyzeContent][google.cloud.dialogflow.v2.Participants.StreamingAnalyzeContent] + * instead of `StreamingDetectIntent`. `StreamingAnalyzeContent` has + * additional functionality for Agent Assist and other CCAI products. + * + * Note: Always use agent versions for production traffic. + * See [Versions and + * environments](https://cloud.google.com/dialogflow/es/docs/agents-versions). + * + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return BidiStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function streamingDetectIntent(array $callOptions = []): BidiStream + { + return $this->startApiCall('StreamingDetectIntent', null, $callOptions); + } + + /** + * Gets information about a location. + * + * The async variant is {@see SessionsClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see SessionsClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Dialogflow/src/V2/Client/VersionsClient.php b/Dialogflow/src/V2/Client/VersionsClient.php index c529a55de550..a1e56c19d9ef 100644 --- a/Dialogflow/src/V2/Client/VersionsClient.php +++ b/Dialogflow/src/V2/Client/VersionsClient.php @@ -24,17 +24,461 @@ namespace Google\Cloud\Dialogflow\V2\Client; -use Google\Cloud\Dialogflow\V2\Client\BaseClient\VersionsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dialogflow\V2\CreateVersionRequest; +use Google\Cloud\Dialogflow\V2\DeleteVersionRequest; +use Google\Cloud\Dialogflow\V2\GetVersionRequest; +use Google\Cloud\Dialogflow\V2\ListVersionsRequest; +use Google\Cloud\Dialogflow\V2\UpdateVersionRequest; +use Google\Cloud\Dialogflow\V2\Version; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for managing [Versions][google.cloud.dialogflow.v2.Version]. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dialogflow\V2\VersionsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createVersionAsync(CreateVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteVersionAsync(DeleteVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getVersionAsync(GetVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface listVersionsAsync(ListVersionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateVersionAsync(UpdateVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class VersionsClient extends VersionsBaseClient +final class VersionsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see VersionsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.dialogflow.v2.Versions'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dialogflow.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/dialogflow', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/versions_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/versions_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/versions_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/versions_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a agent + * resource. + * + * @param string $project + * + * @return string The formatted agent resource. + */ + public static function agentName(string $project): string + { + return self::getPathTemplate('agent')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_agent resource. + * + * @param string $project + * + * @return string The formatted project_agent resource. + */ + public static function projectAgentName(string $project): string + { + return self::getPathTemplate('projectAgent')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_agent resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted project_location_agent resource. + */ + public static function projectLocationAgentName(string $project, string $location): string + { + return self::getPathTemplate('projectLocationAgent')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_version resource. + * + * @param string $project + * @param string $location + * @param string $version + * + * @return string The formatted project_location_version resource. + */ + public static function projectLocationVersionName(string $project, string $location, string $version): string + { + return self::getPathTemplate('projectLocationVersion')->render([ + 'project' => $project, + 'location' => $location, + 'version' => $version, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_version resource. + * + * @param string $project + * @param string $version + * + * @return string The formatted project_version resource. + */ + public static function projectVersionName(string $project, string $version): string + { + return self::getPathTemplate('projectVersion')->render([ + 'project' => $project, + 'version' => $version, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a version + * resource. + * + * @param string $project + * @param string $version + * + * @return string The formatted version resource. + */ + public static function versionName(string $project, string $version): string + { + return self::getPathTemplate('version')->render([ + 'project' => $project, + 'version' => $version, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - agent: projects/{project}/agent + * - projectAgent: projects/{project}/agent + * - projectLocationAgent: projects/{project}/locations/{location}/agent + * - projectLocationVersion: projects/{project}/locations/{location}/agent/versions/{version} + * - projectVersion: projects/{project}/agent/versions/{version} + * - version: projects/{project}/agent/versions/{version} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dialogflow.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates an agent version. + * + * The new version points to the agent instance in the "default" environment. + * + * The async variant is {@see VersionsClient::createVersionAsync()} . + * + * @param CreateVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Version + * + * @throws ApiException Thrown if the API call fails. + */ + public function createVersion(CreateVersionRequest $request, array $callOptions = []): Version + { + return $this->startApiCall('CreateVersion', $request, $callOptions)->wait(); + } + + /** + * Delete the specified agent version. + * + * The async variant is {@see VersionsClient::deleteVersionAsync()} . + * + * @param DeleteVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteVersion(DeleteVersionRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteVersion', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified agent version. + * + * The async variant is {@see VersionsClient::getVersionAsync()} . + * + * @param GetVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Version + * + * @throws ApiException Thrown if the API call fails. + */ + public function getVersion(GetVersionRequest $request, array $callOptions = []): Version + { + return $this->startApiCall('GetVersion', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all versions of the specified agent. + * + * The async variant is {@see VersionsClient::listVersionsAsync()} . + * + * @param ListVersionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listVersions(ListVersionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListVersions', $request, $callOptions); + } + + /** + * Updates the specified agent version. + * + * Note that this method does not allow you to update the state of the agent + * the given version points to. It allows you to update only mutable + * properties of the version resource. + * + * The async variant is {@see VersionsClient::updateVersionAsync()} . + * + * @param UpdateVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Version + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateVersion(UpdateVersionRequest $request, array $callOptions = []): Version + { + return $this->startApiCall('UpdateVersion', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see VersionsClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see VersionsClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/DiscoveryEngine/composer.json b/DiscoveryEngine/composer.json index 1e604522e4cd..601d509eee5a 100644 --- a/DiscoveryEngine/composer.json +++ b/DiscoveryEngine/composer.json @@ -18,7 +18,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.20.0" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/DiscoveryEngine/src/V1/Client/BaseClient/CompletionServiceBaseClient.php b/DiscoveryEngine/src/V1/Client/BaseClient/CompletionServiceBaseClient.php deleted file mode 100644 index 3ed73d837baa..000000000000 --- a/DiscoveryEngine/src/V1/Client/BaseClient/CompletionServiceBaseClient.php +++ /dev/null @@ -1,312 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . - '/../../resources/completion_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../../resources/completion_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . - '/../../resources/completion_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../../resources/completion_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a data_store - * resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * - * @return string The formatted data_store resource. - */ - public static function dataStoreName( - string $project, - string $location, - string $dataStore - ): string { - return self::getPathTemplate('dataStore')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * - * @return string The formatted project_location_collection_data_store resource. - */ - public static function projectLocationCollectionDataStoreName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStore' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * - * @return string The formatted project_location_data_store resource. - */ - public static function projectLocationDataStoreName( - string $project, - string $location, - string $dataStore - ): string { - return self::getPathTemplate('projectLocationDataStore')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - dataStore: projects/{project}/locations/{location}/dataStores/{data_store} - * - projectLocationCollectionDataStore: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store} - * - projectLocationDataStore: projects/{project}/locations/{location}/dataStores/{data_store} - * - * 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( - string $formattedName, - string $template = null - ): array { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'discoveryengine.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error( - 'Call to undefined method ' . __CLASS__ . "::$method()", - E_USER_ERROR - ); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Completes the specified user input with keyword suggestions. - * - * The async variant is {@see self::completeQueryAsync()} . - * - * @example samples/V1/CompletionServiceClient/complete_query.php - * - * @param CompleteQueryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CompleteQueryResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function completeQuery( - CompleteQueryRequest $request, - array $callOptions = [] - ): CompleteQueryResponse { - return $this->startApiCall( - 'CompleteQuery', - $request, - $callOptions - )->wait(); - } -} diff --git a/DiscoveryEngine/src/V1/Client/BaseClient/ConversationalSearchServiceBaseClient.php b/DiscoveryEngine/src/V1/Client/BaseClient/ConversationalSearchServiceBaseClient.php deleted file mode 100644 index 04076f960bb9..000000000000 --- a/DiscoveryEngine/src/V1/Client/BaseClient/ConversationalSearchServiceBaseClient.php +++ /dev/null @@ -1,660 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . - '/../../resources/conversational_search_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../../resources/conversational_search_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . - '/../../resources/conversational_search_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../../resources/conversational_search_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a conversation - * resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $conversation - * - * @return string The formatted conversation resource. - */ - public static function conversationName( - string $project, - string $location, - string $dataStore, - string $conversation - ): string { - return self::getPathTemplate('conversation')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'conversation' => $conversation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a data_store - * resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * - * @return string The formatted data_store resource. - */ - public static function dataStoreName( - string $project, - string $location, - string $dataStore - ): string { - return self::getPathTemplate('dataStore')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * - * @return string The formatted project_location_collection_data_store resource. - */ - public static function projectLocationCollectionDataStoreName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStore' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store_conversation resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * @param string $conversation - * - * @return string The formatted project_location_collection_data_store_conversation resource. - */ - public static function projectLocationCollectionDataStoreConversationName( - string $project, - string $location, - string $collection, - string $dataStore, - string $conversation - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStoreConversation' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - 'conversation' => $conversation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store_serving_config resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * @param string $servingConfig - * - * @return string The formatted project_location_collection_data_store_serving_config resource. - */ - public static function projectLocationCollectionDataStoreServingConfigName( - string $project, - string $location, - string $collection, - string $dataStore, - string $servingConfig - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStoreServingConfig' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - 'serving_config' => $servingConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * - * @return string The formatted project_location_data_store resource. - */ - public static function projectLocationDataStoreName( - string $project, - string $location, - string $dataStore - ): string { - return self::getPathTemplate('projectLocationDataStore')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store_conversation resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $conversation - * - * @return string The formatted project_location_data_store_conversation resource. - */ - public static function projectLocationDataStoreConversationName( - string $project, - string $location, - string $dataStore, - string $conversation - ): string { - return self::getPathTemplate( - 'projectLocationDataStoreConversation' - )->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'conversation' => $conversation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store_serving_config resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $servingConfig - * - * @return string The formatted project_location_data_store_serving_config resource. - */ - public static function projectLocationDataStoreServingConfigName( - string $project, - string $location, - string $dataStore, - string $servingConfig - ): string { - return self::getPathTemplate( - 'projectLocationDataStoreServingConfig' - )->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'serving_config' => $servingConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * serving_config resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $servingConfig - * - * @return string The formatted serving_config resource. - */ - public static function servingConfigName( - string $project, - string $location, - string $dataStore, - string $servingConfig - ): string { - return self::getPathTemplate('servingConfig')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'serving_config' => $servingConfig, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - conversation: projects/{project}/locations/{location}/dataStores/{data_store}/conversations/{conversation} - * - dataStore: projects/{project}/locations/{location}/dataStores/{data_store} - * - projectLocationCollectionDataStore: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store} - * - projectLocationCollectionDataStoreConversation: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/conversations/{conversation} - * - projectLocationCollectionDataStoreServingConfig: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config} - * - projectLocationDataStore: projects/{project}/locations/{location}/dataStores/{data_store} - * - projectLocationDataStoreConversation: projects/{project}/locations/{location}/dataStores/{data_store}/conversations/{conversation} - * - projectLocationDataStoreServingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} - * - servingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} - * - * 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( - string $formattedName, - string $template = null - ): array { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'discoveryengine.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error( - 'Call to undefined method ' . __CLASS__ . "::$method()", - E_USER_ERROR - ); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Converses a conversation. - * - * The async variant is {@see self::converseConversationAsync()} . - * - * @example samples/V1/ConversationalSearchServiceClient/converse_conversation.php - * - * @param ConverseConversationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ConverseConversationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function converseConversation( - ConverseConversationRequest $request, - array $callOptions = [] - ): ConverseConversationResponse { - return $this->startApiCall( - 'ConverseConversation', - $request, - $callOptions - )->wait(); - } - - /** - * Creates a Conversation. - * - * If the [Conversation][google.cloud.discoveryengine.v1.Conversation] to - * create already exists, an ALREADY_EXISTS error is returned. - * - * The async variant is {@see self::createConversationAsync()} . - * - * @example samples/V1/ConversationalSearchServiceClient/create_conversation.php - * - * @param CreateConversationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Conversation - * - * @throws ApiException Thrown if the API call fails. - */ - public function createConversation( - CreateConversationRequest $request, - array $callOptions = [] - ): Conversation { - return $this->startApiCall( - 'CreateConversation', - $request, - $callOptions - )->wait(); - } - - /** - * Deletes a Conversation. - * - * If the [Conversation][google.cloud.discoveryengine.v1.Conversation] to - * delete does not exist, a NOT_FOUND error is returned. - * - * The async variant is {@see self::deleteConversationAsync()} . - * - * @example samples/V1/ConversationalSearchServiceClient/delete_conversation.php - * - * @param DeleteConversationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteConversation( - DeleteConversationRequest $request, - array $callOptions = [] - ): void { - $this->startApiCall( - 'DeleteConversation', - $request, - $callOptions - )->wait(); - } - - /** - * Gets a Conversation. - * - * The async variant is {@see self::getConversationAsync()} . - * - * @example samples/V1/ConversationalSearchServiceClient/get_conversation.php - * - * @param GetConversationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Conversation - * - * @throws ApiException Thrown if the API call fails. - */ - public function getConversation( - GetConversationRequest $request, - array $callOptions = [] - ): Conversation { - return $this->startApiCall( - 'GetConversation', - $request, - $callOptions - )->wait(); - } - - /** - * Lists all Conversations by their parent - * [DataStore][google.cloud.discoveryengine.v1.DataStore]. - * - * The async variant is {@see self::listConversationsAsync()} . - * - * @example samples/V1/ConversationalSearchServiceClient/list_conversations.php - * - * @param ListConversationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listConversations( - ListConversationsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListConversations', $request, $callOptions); - } - - /** - * Updates a Conversation. - * - * [Conversation][google.cloud.discoveryengine.v1.Conversation] action type - * cannot be changed. If the - * [Conversation][google.cloud.discoveryengine.v1.Conversation] to update does - * not exist, a NOT_FOUND error is returned. - * - * The async variant is {@see self::updateConversationAsync()} . - * - * @example samples/V1/ConversationalSearchServiceClient/update_conversation.php - * - * @param UpdateConversationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Conversation - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateConversation( - UpdateConversationRequest $request, - array $callOptions = [] - ): Conversation { - return $this->startApiCall( - 'UpdateConversation', - $request, - $callOptions - )->wait(); - } -} diff --git a/DiscoveryEngine/src/V1/Client/BaseClient/DocumentServiceBaseClient.php b/DiscoveryEngine/src/V1/Client/BaseClient/DocumentServiceBaseClient.php deleted file mode 100644 index 3854a5675e68..000000000000 --- a/DiscoveryEngine/src/V1/Client/BaseClient/DocumentServiceBaseClient.php +++ /dev/null @@ -1,672 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . - '/../../resources/document_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../../resources/document_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . '/../../resources/document_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../../resources/document_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; - $operation = new OperationResponse( - $operationName, - $this->getOperationsClient(), - $options - ); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a branch - * resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $branch - * - * @return string The formatted branch resource. - */ - public static function branchName( - string $project, - string $location, - string $dataStore, - string $branch - ): string { - return self::getPathTemplate('branch')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'branch' => $branch, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a document - * resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $branch - * @param string $document - * - * @return string The formatted document resource. - */ - public static function documentName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document - ): string { - return self::getPathTemplate('document')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'branch' => $branch, - 'document' => $document, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store_branch resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * @param string $branch - * - * @return string The formatted project_location_collection_data_store_branch resource. - */ - public static function projectLocationCollectionDataStoreBranchName( - string $project, - string $location, - string $collection, - string $dataStore, - string $branch - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStoreBranch' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - 'branch' => $branch, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store_branch_document resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * @param string $branch - * @param string $document - * - * @return string The formatted project_location_collection_data_store_branch_document resource. - */ - public static function projectLocationCollectionDataStoreBranchDocumentName( - string $project, - string $location, - string $collection, - string $dataStore, - string $branch, - string $document - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStoreBranchDocument' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - 'branch' => $branch, - 'document' => $document, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store_branch resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $branch - * - * @return string The formatted project_location_data_store_branch resource. - */ - public static function projectLocationDataStoreBranchName( - string $project, - string $location, - string $dataStore, - string $branch - ): string { - return self::getPathTemplate('projectLocationDataStoreBranch')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'branch' => $branch, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store_branch_document resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $branch - * @param string $document - * - * @return string The formatted project_location_data_store_branch_document resource. - */ - public static function projectLocationDataStoreBranchDocumentName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document - ): string { - return self::getPathTemplate( - 'projectLocationDataStoreBranchDocument' - )->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'branch' => $branch, - 'document' => $document, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - branch: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch} - * - document: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} - * - projectLocationCollectionDataStoreBranch: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch} - * - projectLocationCollectionDataStoreBranchDocument: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document} - * - projectLocationDataStoreBranch: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch} - * - projectLocationDataStoreBranchDocument: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} - * - * 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( - string $formattedName, - string $template = null - ): array { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'discoveryengine.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error( - 'Call to undefined method ' . __CLASS__ . "::$method()", - E_USER_ERROR - ); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a [Document][google.cloud.discoveryengine.v1.Document]. - * - * The async variant is {@see self::createDocumentAsync()} . - * - * @example samples/V1/DocumentServiceClient/create_document.php - * - * @param CreateDocumentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Document - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDocument( - CreateDocumentRequest $request, - array $callOptions = [] - ): Document { - return $this->startApiCall( - 'CreateDocument', - $request, - $callOptions - )->wait(); - } - - /** - * Deletes a [Document][google.cloud.discoveryengine.v1.Document]. - * - * The async variant is {@see self::deleteDocumentAsync()} . - * - * @example samples/V1/DocumentServiceClient/delete_document.php - * - * @param DeleteDocumentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDocument( - DeleteDocumentRequest $request, - array $callOptions = [] - ): void { - $this->startApiCall('DeleteDocument', $request, $callOptions)->wait(); - } - - /** - * Gets a [Document][google.cloud.discoveryengine.v1.Document]. - * - * The async variant is {@see self::getDocumentAsync()} . - * - * @example samples/V1/DocumentServiceClient/get_document.php - * - * @param GetDocumentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Document - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDocument( - GetDocumentRequest $request, - array $callOptions = [] - ): Document { - return $this->startApiCall( - 'GetDocument', - $request, - $callOptions - )->wait(); - } - - /** - * Bulk import of multiple - * [Document][google.cloud.discoveryengine.v1.Document]s. Request processing - * may be synchronous. Non-existing items will be created. - * - * Note: It is possible for a subset of the - * [Document][google.cloud.discoveryengine.v1.Document]s to be successfully - * updated. - * - * The async variant is {@see self::importDocumentsAsync()} . - * - * @example samples/V1/DocumentServiceClient/import_documents.php - * - * @param ImportDocumentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function importDocuments( - ImportDocumentsRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'ImportDocuments', - $request, - $callOptions - )->wait(); - } - - /** - * Gets a list of [Document][google.cloud.discoveryengine.v1.Document]s. - * - * The async variant is {@see self::listDocumentsAsync()} . - * - * @example samples/V1/DocumentServiceClient/list_documents.php - * - * @param ListDocumentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDocuments( - ListDocumentsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListDocuments', $request, $callOptions); - } - - /** - * Permanently deletes all selected - * [Document][google.cloud.discoveryengine.v1.Document]s in a branch. - * - * This process is asynchronous. Depending on the number of - * [Document][google.cloud.discoveryengine.v1.Document]s to be deleted, this - * operation can take hours to complete. Before the delete operation - * completes, some [Document][google.cloud.discoveryengine.v1.Document]s might - * still be returned by - * [DocumentService.GetDocument][google.cloud.discoveryengine.v1.DocumentService.GetDocument] - * or - * [DocumentService.ListDocuments][google.cloud.discoveryengine.v1.DocumentService.ListDocuments]. - * - * To get a list of the [Document][google.cloud.discoveryengine.v1.Document]s - * to be deleted, set - * [PurgeDocumentsRequest.force][google.cloud.discoveryengine.v1.PurgeDocumentsRequest.force] - * to false. - * - * The async variant is {@see self::purgeDocumentsAsync()} . - * - * @example samples/V1/DocumentServiceClient/purge_documents.php - * - * @param PurgeDocumentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function purgeDocuments( - PurgeDocumentsRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'PurgeDocuments', - $request, - $callOptions - )->wait(); - } - - /** - * Updates a [Document][google.cloud.discoveryengine.v1.Document]. - * - * The async variant is {@see self::updateDocumentAsync()} . - * - * @example samples/V1/DocumentServiceClient/update_document.php - * - * @param UpdateDocumentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Document - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDocument( - UpdateDocumentRequest $request, - array $callOptions = [] - ): Document { - return $this->startApiCall( - 'UpdateDocument', - $request, - $callOptions - )->wait(); - } -} diff --git a/DiscoveryEngine/src/V1/Client/BaseClient/SchemaServiceBaseClient.php b/DiscoveryEngine/src/V1/Client/BaseClient/SchemaServiceBaseClient.php deleted file mode 100644 index 2cd6f20a23fc..000000000000 --- a/DiscoveryEngine/src/V1/Client/BaseClient/SchemaServiceBaseClient.php +++ /dev/null @@ -1,563 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . '/../../resources/schema_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../../resources/schema_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . '/../../resources/schema_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../../resources/schema_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; - $operation = new OperationResponse( - $operationName, - $this->getOperationsClient(), - $options - ); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a data_store - * resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * - * @return string The formatted data_store resource. - */ - public static function dataStoreName( - string $project, - string $location, - string $dataStore - ): string { - return self::getPathTemplate('dataStore')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * - * @return string The formatted project_location_collection_data_store resource. - */ - public static function projectLocationCollectionDataStoreName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStore' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store_schema resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * @param string $schema - * - * @return string The formatted project_location_collection_data_store_schema resource. - */ - public static function projectLocationCollectionDataStoreSchemaName( - string $project, - string $location, - string $collection, - string $dataStore, - string $schema - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStoreSchema' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - 'schema' => $schema, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * - * @return string The formatted project_location_data_store resource. - */ - public static function projectLocationDataStoreName( - string $project, - string $location, - string $dataStore - ): string { - return self::getPathTemplate('projectLocationDataStore')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store_schema resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $schema - * - * @return string The formatted project_location_data_store_schema resource. - */ - public static function projectLocationDataStoreSchemaName( - string $project, - string $location, - string $dataStore, - string $schema - ): string { - return self::getPathTemplate('projectLocationDataStoreSchema')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'schema' => $schema, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a schema - * resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $schema - * - * @return string The formatted schema resource. - */ - public static function schemaName( - string $project, - string $location, - string $dataStore, - string $schema - ): string { - return self::getPathTemplate('schema')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'schema' => $schema, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - dataStore: projects/{project}/locations/{location}/dataStores/{data_store} - * - projectLocationCollectionDataStore: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store} - * - projectLocationCollectionDataStoreSchema: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema} - * - projectLocationDataStore: projects/{project}/locations/{location}/dataStores/{data_store} - * - projectLocationDataStoreSchema: projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema} - * - schema: projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema} - * - * 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( - string $formattedName, - string $template = null - ): array { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'discoveryengine.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error( - 'Call to undefined method ' . __CLASS__ . "::$method()", - E_USER_ERROR - ); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a [Schema][google.cloud.discoveryengine.v1.Schema]. - * - * The async variant is {@see self::createSchemaAsync()} . - * - * @example samples/V1/SchemaServiceClient/create_schema.php - * - * @param CreateSchemaRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSchema( - CreateSchemaRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'CreateSchema', - $request, - $callOptions - )->wait(); - } - - /** - * Deletes a [Schema][google.cloud.discoveryengine.v1.Schema]. - * - * The async variant is {@see self::deleteSchemaAsync()} . - * - * @example samples/V1/SchemaServiceClient/delete_schema.php - * - * @param DeleteSchemaRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSchema( - DeleteSchemaRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'DeleteSchema', - $request, - $callOptions - )->wait(); - } - - /** - * Gets a [Schema][google.cloud.discoveryengine.v1.Schema]. - * - * The async variant is {@see self::getSchemaAsync()} . - * - * @example samples/V1/SchemaServiceClient/get_schema.php - * - * @param GetSchemaRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Schema - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSchema( - GetSchemaRequest $request, - array $callOptions = [] - ): Schema { - return $this->startApiCall('GetSchema', $request, $callOptions)->wait(); - } - - /** - * Gets a list of [Schema][google.cloud.discoveryengine.v1.Schema]s. - * - * The async variant is {@see self::listSchemasAsync()} . - * - * @example samples/V1/SchemaServiceClient/list_schemas.php - * - * @param ListSchemasRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSchemas( - ListSchemasRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListSchemas', $request, $callOptions); - } - - /** - * Updates a [Schema][google.cloud.discoveryengine.v1.Schema]. - * - * The async variant is {@see self::updateSchemaAsync()} . - * - * @example samples/V1/SchemaServiceClient/update_schema.php - * - * @param UpdateSchemaRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSchema( - UpdateSchemaRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'UpdateSchema', - $request, - $callOptions - )->wait(); - } -} diff --git a/DiscoveryEngine/src/V1/Client/BaseClient/SearchServiceBaseClient.php b/DiscoveryEngine/src/V1/Client/BaseClient/SearchServiceBaseClient.php deleted file mode 100644 index 7dbb7ff61922..000000000000 --- a/DiscoveryEngine/src/V1/Client/BaseClient/SearchServiceBaseClient.php +++ /dev/null @@ -1,400 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . '/../../resources/search_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../../resources/search_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . '/../../resources/search_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../../resources/search_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a branch - * resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $branch - * - * @return string The formatted branch resource. - */ - public static function branchName( - string $project, - string $location, - string $dataStore, - string $branch - ): string { - return self::getPathTemplate('branch')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'branch' => $branch, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store_branch resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * @param string $branch - * - * @return string The formatted project_location_collection_data_store_branch resource. - */ - public static function projectLocationCollectionDataStoreBranchName( - string $project, - string $location, - string $collection, - string $dataStore, - string $branch - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStoreBranch' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - 'branch' => $branch, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store_serving_config resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * @param string $servingConfig - * - * @return string The formatted project_location_collection_data_store_serving_config resource. - */ - public static function projectLocationCollectionDataStoreServingConfigName( - string $project, - string $location, - string $collection, - string $dataStore, - string $servingConfig - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStoreServingConfig' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - 'serving_config' => $servingConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store_branch resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $branch - * - * @return string The formatted project_location_data_store_branch resource. - */ - public static function projectLocationDataStoreBranchName( - string $project, - string $location, - string $dataStore, - string $branch - ): string { - return self::getPathTemplate('projectLocationDataStoreBranch')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'branch' => $branch, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store_serving_config resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $servingConfig - * - * @return string The formatted project_location_data_store_serving_config resource. - */ - public static function projectLocationDataStoreServingConfigName( - string $project, - string $location, - string $dataStore, - string $servingConfig - ): string { - return self::getPathTemplate( - 'projectLocationDataStoreServingConfig' - )->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'serving_config' => $servingConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * serving_config resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $servingConfig - * - * @return string The formatted serving_config resource. - */ - public static function servingConfigName( - string $project, - string $location, - string $dataStore, - string $servingConfig - ): string { - return self::getPathTemplate('servingConfig')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'serving_config' => $servingConfig, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - branch: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch} - * - projectLocationCollectionDataStoreBranch: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch} - * - projectLocationCollectionDataStoreServingConfig: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config} - * - projectLocationDataStoreBranch: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch} - * - projectLocationDataStoreServingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} - * - servingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} - * - * 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( - string $formattedName, - string $template = null - ): array { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'discoveryengine.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error( - 'Call to undefined method ' . __CLASS__ . "::$method()", - E_USER_ERROR - ); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Performs a search. - * - * The async variant is {@see self::searchAsync()} . - * - * @example samples/V1/SearchServiceClient/search.php - * - * @param SearchRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function search( - SearchRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('Search', $request, $callOptions); - } -} diff --git a/DiscoveryEngine/src/V1/Client/BaseClient/UserEventServiceBaseClient.php b/DiscoveryEngine/src/V1/Client/BaseClient/UserEventServiceBaseClient.php deleted file mode 100644 index 005a69d401c5..000000000000 --- a/DiscoveryEngine/src/V1/Client/BaseClient/UserEventServiceBaseClient.php +++ /dev/null @@ -1,526 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . - '/../../resources/user_event_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../../resources/user_event_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . - '/../../resources/user_event_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../../resources/user_event_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; - $operation = new OperationResponse( - $operationName, - $this->getOperationsClient(), - $options - ); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a data_store - * resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * - * @return string The formatted data_store resource. - */ - public static function dataStoreName( - string $project, - string $location, - string $dataStore - ): string { - return self::getPathTemplate('dataStore')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a document - * resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $branch - * @param string $document - * - * @return string The formatted document resource. - */ - public static function documentName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document - ): string { - return self::getPathTemplate('document')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'branch' => $branch, - 'document' => $document, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * - * @return string The formatted project_location_collection_data_store resource. - */ - public static function projectLocationCollectionDataStoreName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStore' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store_branch_document resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * @param string $branch - * @param string $document - * - * @return string The formatted project_location_collection_data_store_branch_document resource. - */ - public static function projectLocationCollectionDataStoreBranchDocumentName( - string $project, - string $location, - string $collection, - string $dataStore, - string $branch, - string $document - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStoreBranchDocument' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - 'branch' => $branch, - 'document' => $document, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * - * @return string The formatted project_location_data_store resource. - */ - public static function projectLocationDataStoreName( - string $project, - string $location, - string $dataStore - ): string { - return self::getPathTemplate('projectLocationDataStore')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store_branch_document resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $branch - * @param string $document - * - * @return string The formatted project_location_data_store_branch_document resource. - */ - public static function projectLocationDataStoreBranchDocumentName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document - ): string { - return self::getPathTemplate( - 'projectLocationDataStoreBranchDocument' - )->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'branch' => $branch, - 'document' => $document, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - dataStore: projects/{project}/locations/{location}/dataStores/{data_store} - * - document: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} - * - projectLocationCollectionDataStore: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store} - * - projectLocationCollectionDataStoreBranchDocument: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document} - * - projectLocationDataStore: projects/{project}/locations/{location}/dataStores/{data_store} - * - projectLocationDataStoreBranchDocument: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} - * - * 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( - string $formattedName, - string $template = null - ): array { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'discoveryengine.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error( - 'Call to undefined method ' . __CLASS__ . "::$method()", - E_USER_ERROR - ); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Writes a single user event from the browser. This uses a GET request to - * due to browser restriction of POST-ing to a third-party domain. - * - * This method is used only by the Discovery Engine API JavaScript pixel and - * Google Tag Manager. Users should not call this method directly. - * - * The async variant is {@see self::collectUserEventAsync()} . - * - * @example samples/V1/UserEventServiceClient/collect_user_event.php - * - * @param CollectUserEventRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 HttpBody - * - * @throws ApiException Thrown if the API call fails. - */ - public function collectUserEvent( - CollectUserEventRequest $request, - array $callOptions = [] - ): HttpBody { - return $this->startApiCall( - 'CollectUserEvent', - $request, - $callOptions - )->wait(); - } - - /** - * Bulk import of User events. Request processing might be - * synchronous. Events that already exist are skipped. - * Use this method for backfilling historical user events. - * - * Operation.response is of type ImportResponse. Note that it is - * possible for a subset of the items to be successfully inserted. - * Operation.metadata is of type ImportMetadata. - * - * The async variant is {@see self::importUserEventsAsync()} . - * - * @example samples/V1/UserEventServiceClient/import_user_events.php - * - * @param ImportUserEventsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function importUserEvents( - ImportUserEventsRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'ImportUserEvents', - $request, - $callOptions - )->wait(); - } - - /** - * Writes a single user event. - * - * The async variant is {@see self::writeUserEventAsync()} . - * - * @example samples/V1/UserEventServiceClient/write_user_event.php - * - * @param WriteUserEventRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 UserEvent - * - * @throws ApiException Thrown if the API call fails. - */ - public function writeUserEvent( - WriteUserEventRequest $request, - array $callOptions = [] - ): UserEvent { - return $this->startApiCall( - 'WriteUserEvent', - $request, - $callOptions - )->wait(); - } -} diff --git a/DiscoveryEngine/src/V1/Client/CompletionServiceClient.php b/DiscoveryEngine/src/V1/Client/CompletionServiceClient.php index 1b7ae376d481..be08d5dcab14 100644 --- a/DiscoveryEngine/src/V1/Client/CompletionServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/CompletionServiceClient.php @@ -24,17 +24,255 @@ namespace Google\Cloud\DiscoveryEngine\V1\Client; -use Google\Cloud\DiscoveryEngine\V1\Client\BaseClient\CompletionServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\DiscoveryEngine\V1\CompleteQueryRequest; +use Google\Cloud\DiscoveryEngine\V1\CompleteQueryResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for Auto-Completion. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface completeQueryAsync(CompleteQueryRequest $request, array $optionalArgs = []) */ -final class CompletionServiceClient extends CompletionServiceBaseClient +final class CompletionServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CompletionServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.discoveryengine.v1.CompletionService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'discoveryengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/completion_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/completion_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/completion_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/completion_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a data_store + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted data_store resource. + */ + public static function dataStoreName(string $project, string $location, string $dataStore): string + { + return self::getPathTemplate('dataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * + * @return string The formatted project_location_collection_data_store resource. + */ + public static function projectLocationCollectionDataStoreName(string $project, string $location, string $collection, string $dataStore): string + { + return self::getPathTemplate('projectLocationCollectionDataStore')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted project_location_data_store resource. + */ + public static function projectLocationDataStoreName(string $project, string $location, string $dataStore): string + { + return self::getPathTemplate('projectLocationDataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - dataStore: projects/{project}/locations/{location}/dataStores/{data_store} + * - projectLocationCollectionDataStore: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store} + * - projectLocationDataStore: projects/{project}/locations/{location}/dataStores/{data_store} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'discoveryengine.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Completes the specified user input with keyword suggestions. + * + * The async variant is {@see CompletionServiceClient::completeQueryAsync()} . + * + * @example samples/V1/CompletionServiceClient/complete_query.php + * + * @param CompleteQueryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CompleteQueryResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function completeQuery(CompleteQueryRequest $request, array $callOptions = []): CompleteQueryResponse + { + return $this->startApiCall('CompleteQuery', $request, $callOptions)->wait(); + } } diff --git a/DiscoveryEngine/src/V1/Client/ConversationalSearchServiceClient.php b/DiscoveryEngine/src/V1/Client/ConversationalSearchServiceClient.php index 777cd624a620..efea80d5b68c 100644 --- a/DiscoveryEngine/src/V1/Client/ConversationalSearchServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/ConversationalSearchServiceClient.php @@ -24,17 +24,549 @@ namespace Google\Cloud\DiscoveryEngine\V1\Client; -use Google\Cloud\DiscoveryEngine\V1\Client\BaseClient\ConversationalSearchServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\DiscoveryEngine\V1\Conversation; +use Google\Cloud\DiscoveryEngine\V1\ConverseConversationRequest; +use Google\Cloud\DiscoveryEngine\V1\ConverseConversationResponse; +use Google\Cloud\DiscoveryEngine\V1\CreateConversationRequest; +use Google\Cloud\DiscoveryEngine\V1\DeleteConversationRequest; +use Google\Cloud\DiscoveryEngine\V1\GetConversationRequest; +use Google\Cloud\DiscoveryEngine\V1\ListConversationsRequest; +use Google\Cloud\DiscoveryEngine\V1\UpdateConversationRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for conversational search. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface converseConversationAsync(ConverseConversationRequest $request, array $optionalArgs = []) + * @method PromiseInterface createConversationAsync(CreateConversationRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteConversationAsync(DeleteConversationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getConversationAsync(GetConversationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listConversationsAsync(ListConversationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateConversationAsync(UpdateConversationRequest $request, array $optionalArgs = []) */ -final class ConversationalSearchServiceClient extends ConversationalSearchServiceBaseClient +final class ConversationalSearchServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ConversationalSearchServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.discoveryengine.v1.ConversationalSearchService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'discoveryengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/conversational_search_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/conversational_search_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/conversational_search_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/conversational_search_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a conversation + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $conversation + * + * @return string The formatted conversation resource. + */ + public static function conversationName(string $project, string $location, string $dataStore, string $conversation): string + { + return self::getPathTemplate('conversation')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'conversation' => $conversation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a data_store + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted data_store resource. + */ + public static function dataStoreName(string $project, string $location, string $dataStore): string + { + return self::getPathTemplate('dataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * + * @return string The formatted project_location_collection_data_store resource. + */ + public static function projectLocationCollectionDataStoreName(string $project, string $location, string $collection, string $dataStore): string + { + return self::getPathTemplate('projectLocationCollectionDataStore')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_conversation resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $conversation + * + * @return string The formatted project_location_collection_data_store_conversation resource. + */ + public static function projectLocationCollectionDataStoreConversationName(string $project, string $location, string $collection, string $dataStore, string $conversation): string + { + return self::getPathTemplate('projectLocationCollectionDataStoreConversation')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'conversation' => $conversation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_serving_config resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $servingConfig + * + * @return string The formatted project_location_collection_data_store_serving_config resource. + */ + public static function projectLocationCollectionDataStoreServingConfigName(string $project, string $location, string $collection, string $dataStore, string $servingConfig): string + { + return self::getPathTemplate('projectLocationCollectionDataStoreServingConfig')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'serving_config' => $servingConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted project_location_data_store resource. + */ + public static function projectLocationDataStoreName(string $project, string $location, string $dataStore): string + { + return self::getPathTemplate('projectLocationDataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_conversation resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $conversation + * + * @return string The formatted project_location_data_store_conversation resource. + */ + public static function projectLocationDataStoreConversationName(string $project, string $location, string $dataStore, string $conversation): string + { + return self::getPathTemplate('projectLocationDataStoreConversation')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'conversation' => $conversation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_serving_config resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $servingConfig + * + * @return string The formatted project_location_data_store_serving_config resource. + */ + public static function projectLocationDataStoreServingConfigName(string $project, string $location, string $dataStore, string $servingConfig): string + { + return self::getPathTemplate('projectLocationDataStoreServingConfig')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'serving_config' => $servingConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * serving_config resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $servingConfig + * + * @return string The formatted serving_config resource. + */ + public static function servingConfigName(string $project, string $location, string $dataStore, string $servingConfig): string + { + return self::getPathTemplate('servingConfig')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'serving_config' => $servingConfig, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - conversation: projects/{project}/locations/{location}/dataStores/{data_store}/conversations/{conversation} + * - dataStore: projects/{project}/locations/{location}/dataStores/{data_store} + * - projectLocationCollectionDataStore: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store} + * - projectLocationCollectionDataStoreConversation: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/conversations/{conversation} + * - projectLocationCollectionDataStoreServingConfig: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config} + * - projectLocationDataStore: projects/{project}/locations/{location}/dataStores/{data_store} + * - projectLocationDataStoreConversation: projects/{project}/locations/{location}/dataStores/{data_store}/conversations/{conversation} + * - projectLocationDataStoreServingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} + * - servingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'discoveryengine.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Converses a conversation. + * + * The async variant is + * {@see ConversationalSearchServiceClient::converseConversationAsync()} . + * + * @example samples/V1/ConversationalSearchServiceClient/converse_conversation.php + * + * @param ConverseConversationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ConverseConversationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function converseConversation(ConverseConversationRequest $request, array $callOptions = []): ConverseConversationResponse + { + return $this->startApiCall('ConverseConversation', $request, $callOptions)->wait(); + } + + /** + * Creates a Conversation. + * + * If the [Conversation][google.cloud.discoveryengine.v1.Conversation] to + * create already exists, an ALREADY_EXISTS error is returned. + * + * The async variant is + * {@see ConversationalSearchServiceClient::createConversationAsync()} . + * + * @example samples/V1/ConversationalSearchServiceClient/create_conversation.php + * + * @param CreateConversationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Conversation + * + * @throws ApiException Thrown if the API call fails. + */ + public function createConversation(CreateConversationRequest $request, array $callOptions = []): Conversation + { + return $this->startApiCall('CreateConversation', $request, $callOptions)->wait(); + } + + /** + * Deletes a Conversation. + * + * If the [Conversation][google.cloud.discoveryengine.v1.Conversation] to + * delete does not exist, a NOT_FOUND error is returned. + * + * The async variant is + * {@see ConversationalSearchServiceClient::deleteConversationAsync()} . + * + * @example samples/V1/ConversationalSearchServiceClient/delete_conversation.php + * + * @param DeleteConversationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteConversation(DeleteConversationRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteConversation', $request, $callOptions)->wait(); + } + + /** + * Gets a Conversation. + * + * The async variant is + * {@see ConversationalSearchServiceClient::getConversationAsync()} . + * + * @example samples/V1/ConversationalSearchServiceClient/get_conversation.php + * + * @param GetConversationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Conversation + * + * @throws ApiException Thrown if the API call fails. + */ + public function getConversation(GetConversationRequest $request, array $callOptions = []): Conversation + { + return $this->startApiCall('GetConversation', $request, $callOptions)->wait(); + } + + /** + * Lists all Conversations by their parent + * [DataStore][google.cloud.discoveryengine.v1.DataStore]. + * + * The async variant is + * {@see ConversationalSearchServiceClient::listConversationsAsync()} . + * + * @example samples/V1/ConversationalSearchServiceClient/list_conversations.php + * + * @param ListConversationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listConversations(ListConversationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListConversations', $request, $callOptions); + } + + /** + * Updates a Conversation. + * + * [Conversation][google.cloud.discoveryengine.v1.Conversation] action type + * cannot be changed. If the + * [Conversation][google.cloud.discoveryengine.v1.Conversation] to update does + * not exist, a NOT_FOUND error is returned. + * + * The async variant is + * {@see ConversationalSearchServiceClient::updateConversationAsync()} . + * + * @example samples/V1/ConversationalSearchServiceClient/update_conversation.php + * + * @param UpdateConversationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Conversation + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateConversation(UpdateConversationRequest $request, array $callOptions = []): Conversation + { + return $this->startApiCall('UpdateConversation', $request, $callOptions)->wait(); + } } diff --git a/DiscoveryEngine/src/V1/Client/DocumentServiceClient.php b/DiscoveryEngine/src/V1/Client/DocumentServiceClient.php index 8150c919adf7..d5154b0443ca 100644 --- a/DiscoveryEngine/src/V1/Client/DocumentServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/DocumentServiceClient.php @@ -24,17 +24,559 @@ namespace Google\Cloud\DiscoveryEngine\V1\Client; -use Google\Cloud\DiscoveryEngine\V1\Client\BaseClient\DocumentServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\DiscoveryEngine\V1\CreateDocumentRequest; +use Google\Cloud\DiscoveryEngine\V1\DeleteDocumentRequest; +use Google\Cloud\DiscoveryEngine\V1\Document; +use Google\Cloud\DiscoveryEngine\V1\GetDocumentRequest; +use Google\Cloud\DiscoveryEngine\V1\ImportDocumentsRequest; +use Google\Cloud\DiscoveryEngine\V1\ListDocumentsRequest; +use Google\Cloud\DiscoveryEngine\V1\PurgeDocumentsRequest; +use Google\Cloud\DiscoveryEngine\V1\UpdateDocumentRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for ingesting [Document][google.cloud.discoveryengine.v1.Document] + * information of the customer's website. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createDocumentAsync(CreateDocumentRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDocumentAsync(DeleteDocumentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDocumentAsync(GetDocumentRequest $request, array $optionalArgs = []) + * @method PromiseInterface importDocumentsAsync(ImportDocumentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDocumentsAsync(ListDocumentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface purgeDocumentsAsync(PurgeDocumentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDocumentAsync(UpdateDocumentRequest $request, array $optionalArgs = []) */ -final class DocumentServiceClient extends DocumentServiceBaseClient +final class DocumentServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DocumentServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.discoveryengine.v1.DocumentService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'discoveryengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/document_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/document_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/document_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/document_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a branch + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * + * @return string The formatted branch resource. + */ + public static function branchName(string $project, string $location, string $dataStore, string $branch): string + { + return self::getPathTemplate('branch')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a document + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted document resource. + */ + public static function documentName(string $project, string $location, string $dataStore, string $branch, string $document): string + { + return self::getPathTemplate('document')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_branch resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $branch + * + * @return string The formatted project_location_collection_data_store_branch resource. + */ + public static function projectLocationCollectionDataStoreBranchName(string $project, string $location, string $collection, string $dataStore, string $branch): string + { + return self::getPathTemplate('projectLocationCollectionDataStoreBranch')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'branch' => $branch, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_branch_document resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted project_location_collection_data_store_branch_document resource. + */ + public static function projectLocationCollectionDataStoreBranchDocumentName(string $project, string $location, string $collection, string $dataStore, string $branch, string $document): string + { + return self::getPathTemplate('projectLocationCollectionDataStoreBranchDocument')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_branch resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * + * @return string The formatted project_location_data_store_branch resource. + */ + public static function projectLocationDataStoreBranchName(string $project, string $location, string $dataStore, string $branch): string + { + return self::getPathTemplate('projectLocationDataStoreBranch')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_branch_document resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted project_location_data_store_branch_document resource. + */ + public static function projectLocationDataStoreBranchDocumentName(string $project, string $location, string $dataStore, string $branch, string $document): string + { + return self::getPathTemplate('projectLocationDataStoreBranchDocument')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - branch: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch} + * - document: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} + * - projectLocationCollectionDataStoreBranch: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch} + * - projectLocationCollectionDataStoreBranchDocument: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document} + * - projectLocationDataStoreBranch: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch} + * - projectLocationDataStoreBranchDocument: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'discoveryengine.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a [Document][google.cloud.discoveryengine.v1.Document]. + * + * The async variant is {@see DocumentServiceClient::createDocumentAsync()} . + * + * @example samples/V1/DocumentServiceClient/create_document.php + * + * @param CreateDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Document + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDocument(CreateDocumentRequest $request, array $callOptions = []): Document + { + return $this->startApiCall('CreateDocument', $request, $callOptions)->wait(); + } + + /** + * Deletes a [Document][google.cloud.discoveryengine.v1.Document]. + * + * The async variant is {@see DocumentServiceClient::deleteDocumentAsync()} . + * + * @example samples/V1/DocumentServiceClient/delete_document.php + * + * @param DeleteDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDocument(DeleteDocumentRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteDocument', $request, $callOptions)->wait(); + } + + /** + * Gets a [Document][google.cloud.discoveryengine.v1.Document]. + * + * The async variant is {@see DocumentServiceClient::getDocumentAsync()} . + * + * @example samples/V1/DocumentServiceClient/get_document.php + * + * @param GetDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Document + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDocument(GetDocumentRequest $request, array $callOptions = []): Document + { + return $this->startApiCall('GetDocument', $request, $callOptions)->wait(); + } + + /** + * Bulk import of multiple + * [Document][google.cloud.discoveryengine.v1.Document]s. Request processing + * may be synchronous. Non-existing items will be created. + * + * Note: It is possible for a subset of the + * [Document][google.cloud.discoveryengine.v1.Document]s to be successfully + * updated. + * + * The async variant is {@see DocumentServiceClient::importDocumentsAsync()} . + * + * @example samples/V1/DocumentServiceClient/import_documents.php + * + * @param ImportDocumentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importDocuments(ImportDocumentsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportDocuments', $request, $callOptions)->wait(); + } + + /** + * Gets a list of [Document][google.cloud.discoveryengine.v1.Document]s. + * + * The async variant is {@see DocumentServiceClient::listDocumentsAsync()} . + * + * @example samples/V1/DocumentServiceClient/list_documents.php + * + * @param ListDocumentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDocuments(ListDocumentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDocuments', $request, $callOptions); + } + + /** + * Permanently deletes all selected + * [Document][google.cloud.discoveryengine.v1.Document]s in a branch. + * + * This process is asynchronous. Depending on the number of + * [Document][google.cloud.discoveryengine.v1.Document]s to be deleted, this + * operation can take hours to complete. Before the delete operation + * completes, some [Document][google.cloud.discoveryengine.v1.Document]s might + * still be returned by + * [DocumentService.GetDocument][google.cloud.discoveryengine.v1.DocumentService.GetDocument] + * or + * [DocumentService.ListDocuments][google.cloud.discoveryengine.v1.DocumentService.ListDocuments]. + * + * To get a list of the [Document][google.cloud.discoveryengine.v1.Document]s + * to be deleted, set + * [PurgeDocumentsRequest.force][google.cloud.discoveryengine.v1.PurgeDocumentsRequest.force] + * to false. + * + * The async variant is {@see DocumentServiceClient::purgeDocumentsAsync()} . + * + * @example samples/V1/DocumentServiceClient/purge_documents.php + * + * @param PurgeDocumentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function purgeDocuments(PurgeDocumentsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('PurgeDocuments', $request, $callOptions)->wait(); + } + + /** + * Updates a [Document][google.cloud.discoveryengine.v1.Document]. + * + * The async variant is {@see DocumentServiceClient::updateDocumentAsync()} . + * + * @example samples/V1/DocumentServiceClient/update_document.php + * + * @param UpdateDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Document + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDocument(UpdateDocumentRequest $request, array $callOptions = []): Document + { + return $this->startApiCall('UpdateDocument', $request, $callOptions)->wait(); + } } diff --git a/DiscoveryEngine/src/V1/Client/SchemaServiceClient.php b/DiscoveryEngine/src/V1/Client/SchemaServiceClient.php index c385e87909e1..1ac316b85d87 100644 --- a/DiscoveryEngine/src/V1/Client/SchemaServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/SchemaServiceClient.php @@ -24,17 +24,471 @@ namespace Google\Cloud\DiscoveryEngine\V1\Client; -use Google\Cloud\DiscoveryEngine\V1\Client\BaseClient\SchemaServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\DiscoveryEngine\V1\CreateSchemaRequest; +use Google\Cloud\DiscoveryEngine\V1\DeleteSchemaRequest; +use Google\Cloud\DiscoveryEngine\V1\GetSchemaRequest; +use Google\Cloud\DiscoveryEngine\V1\ListSchemasRequest; +use Google\Cloud\DiscoveryEngine\V1\Schema; +use Google\Cloud\DiscoveryEngine\V1\UpdateSchemaRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for managing [Schema][google.cloud.discoveryengine.v1.Schema]s. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createSchemaAsync(CreateSchemaRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSchemaAsync(DeleteSchemaRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSchemaAsync(GetSchemaRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSchemasAsync(ListSchemasRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSchemaAsync(UpdateSchemaRequest $request, array $optionalArgs = []) */ -final class SchemaServiceClient extends SchemaServiceBaseClient +final class SchemaServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SchemaServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.discoveryengine.v1.SchemaService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'discoveryengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/schema_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/schema_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/schema_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/schema_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a data_store + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted data_store resource. + */ + public static function dataStoreName(string $project, string $location, string $dataStore): string + { + return self::getPathTemplate('dataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * + * @return string The formatted project_location_collection_data_store resource. + */ + public static function projectLocationCollectionDataStoreName(string $project, string $location, string $collection, string $dataStore): string + { + return self::getPathTemplate('projectLocationCollectionDataStore')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_schema resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $schema + * + * @return string The formatted project_location_collection_data_store_schema resource. + */ + public static function projectLocationCollectionDataStoreSchemaName(string $project, string $location, string $collection, string $dataStore, string $schema): string + { + return self::getPathTemplate('projectLocationCollectionDataStoreSchema')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'schema' => $schema, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted project_location_data_store resource. + */ + public static function projectLocationDataStoreName(string $project, string $location, string $dataStore): string + { + return self::getPathTemplate('projectLocationDataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_schema resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $schema + * + * @return string The formatted project_location_data_store_schema resource. + */ + public static function projectLocationDataStoreSchemaName(string $project, string $location, string $dataStore, string $schema): string + { + return self::getPathTemplate('projectLocationDataStoreSchema')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'schema' => $schema, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a schema + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $schema + * + * @return string The formatted schema resource. + */ + public static function schemaName(string $project, string $location, string $dataStore, string $schema): string + { + return self::getPathTemplate('schema')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'schema' => $schema, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - dataStore: projects/{project}/locations/{location}/dataStores/{data_store} + * - projectLocationCollectionDataStore: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store} + * - projectLocationCollectionDataStoreSchema: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema} + * - projectLocationDataStore: projects/{project}/locations/{location}/dataStores/{data_store} + * - projectLocationDataStoreSchema: projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema} + * - schema: projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'discoveryengine.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a [Schema][google.cloud.discoveryengine.v1.Schema]. + * + * The async variant is {@see SchemaServiceClient::createSchemaAsync()} . + * + * @example samples/V1/SchemaServiceClient/create_schema.php + * + * @param CreateSchemaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSchema(CreateSchemaRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateSchema', $request, $callOptions)->wait(); + } + + /** + * Deletes a [Schema][google.cloud.discoveryengine.v1.Schema]. + * + * The async variant is {@see SchemaServiceClient::deleteSchemaAsync()} . + * + * @example samples/V1/SchemaServiceClient/delete_schema.php + * + * @param DeleteSchemaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSchema(DeleteSchemaRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteSchema', $request, $callOptions)->wait(); + } + + /** + * Gets a [Schema][google.cloud.discoveryengine.v1.Schema]. + * + * The async variant is {@see SchemaServiceClient::getSchemaAsync()} . + * + * @example samples/V1/SchemaServiceClient/get_schema.php + * + * @param GetSchemaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Schema + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSchema(GetSchemaRequest $request, array $callOptions = []): Schema + { + return $this->startApiCall('GetSchema', $request, $callOptions)->wait(); + } + + /** + * Gets a list of [Schema][google.cloud.discoveryengine.v1.Schema]s. + * + * The async variant is {@see SchemaServiceClient::listSchemasAsync()} . + * + * @example samples/V1/SchemaServiceClient/list_schemas.php + * + * @param ListSchemasRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSchemas(ListSchemasRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSchemas', $request, $callOptions); + } + + /** + * Updates a [Schema][google.cloud.discoveryengine.v1.Schema]. + * + * The async variant is {@see SchemaServiceClient::updateSchemaAsync()} . + * + * @example samples/V1/SchemaServiceClient/update_schema.php + * + * @param UpdateSchemaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSchema(UpdateSchemaRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateSchema', $request, $callOptions)->wait(); + } } diff --git a/DiscoveryEngine/src/V1/Client/SearchServiceClient.php b/DiscoveryEngine/src/V1/Client/SearchServiceClient.php index 5fdbff65a70d..b21ca18e4af3 100644 --- a/DiscoveryEngine/src/V1/Client/SearchServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/SearchServiceClient.php @@ -24,17 +24,329 @@ namespace Google\Cloud\DiscoveryEngine\V1\Client; -use Google\Cloud\DiscoveryEngine\V1\Client\BaseClient\SearchServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\DiscoveryEngine\V1\SearchRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for search. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface searchAsync(SearchRequest $request, array $optionalArgs = []) */ -final class SearchServiceClient extends SearchServiceBaseClient +final class SearchServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SearchServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.discoveryengine.v1.SearchService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'discoveryengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/search_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/search_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/search_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/search_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a branch + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * + * @return string The formatted branch resource. + */ + public static function branchName(string $project, string $location, string $dataStore, string $branch): string + { + return self::getPathTemplate('branch')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_branch resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $branch + * + * @return string The formatted project_location_collection_data_store_branch resource. + */ + public static function projectLocationCollectionDataStoreBranchName(string $project, string $location, string $collection, string $dataStore, string $branch): string + { + return self::getPathTemplate('projectLocationCollectionDataStoreBranch')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'branch' => $branch, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_serving_config resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $servingConfig + * + * @return string The formatted project_location_collection_data_store_serving_config resource. + */ + public static function projectLocationCollectionDataStoreServingConfigName(string $project, string $location, string $collection, string $dataStore, string $servingConfig): string + { + return self::getPathTemplate('projectLocationCollectionDataStoreServingConfig')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'serving_config' => $servingConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_branch resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * + * @return string The formatted project_location_data_store_branch resource. + */ + public static function projectLocationDataStoreBranchName(string $project, string $location, string $dataStore, string $branch): string + { + return self::getPathTemplate('projectLocationDataStoreBranch')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_serving_config resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $servingConfig + * + * @return string The formatted project_location_data_store_serving_config resource. + */ + public static function projectLocationDataStoreServingConfigName(string $project, string $location, string $dataStore, string $servingConfig): string + { + return self::getPathTemplate('projectLocationDataStoreServingConfig')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'serving_config' => $servingConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * serving_config resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $servingConfig + * + * @return string The formatted serving_config resource. + */ + public static function servingConfigName(string $project, string $location, string $dataStore, string $servingConfig): string + { + return self::getPathTemplate('servingConfig')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'serving_config' => $servingConfig, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - branch: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch} + * - projectLocationCollectionDataStoreBranch: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch} + * - projectLocationCollectionDataStoreServingConfig: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config} + * - projectLocationDataStoreBranch: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch} + * - projectLocationDataStoreServingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} + * - servingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'discoveryengine.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Performs a search. + * + * The async variant is {@see SearchServiceClient::searchAsync()} . + * + * @example samples/V1/SearchServiceClient/search.php + * + * @param SearchRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function search(SearchRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('Search', $request, $callOptions); + } } diff --git a/DiscoveryEngine/src/V1/Client/UserEventServiceClient.php b/DiscoveryEngine/src/V1/Client/UserEventServiceClient.php index 26bf5619e75c..adc57d9c8f46 100644 --- a/DiscoveryEngine/src/V1/Client/UserEventServiceClient.php +++ b/DiscoveryEngine/src/V1/Client/UserEventServiceClient.php @@ -24,17 +24,431 @@ namespace Google\Cloud\DiscoveryEngine\V1\Client; -use Google\Cloud\DiscoveryEngine\V1\Client\BaseClient\UserEventServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Api\HttpBody; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\DiscoveryEngine\V1\CollectUserEventRequest; +use Google\Cloud\DiscoveryEngine\V1\ImportUserEventsRequest; +use Google\Cloud\DiscoveryEngine\V1\UserEvent; +use Google\Cloud\DiscoveryEngine\V1\WriteUserEventRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for ingesting end user actions on a website to Discovery Engine API. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface collectUserEventAsync(CollectUserEventRequest $request, array $optionalArgs = []) + * @method PromiseInterface importUserEventsAsync(ImportUserEventsRequest $request, array $optionalArgs = []) + * @method PromiseInterface writeUserEventAsync(WriteUserEventRequest $request, array $optionalArgs = []) */ -final class UserEventServiceClient extends UserEventServiceBaseClient +final class UserEventServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see UserEventServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.discoveryengine.v1.UserEventService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'discoveryengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/user_event_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/user_event_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/user_event_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/user_event_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a data_store + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted data_store resource. + */ + public static function dataStoreName(string $project, string $location, string $dataStore): string + { + return self::getPathTemplate('dataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a document + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted document resource. + */ + public static function documentName(string $project, string $location, string $dataStore, string $branch, string $document): string + { + return self::getPathTemplate('document')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * + * @return string The formatted project_location_collection_data_store resource. + */ + public static function projectLocationCollectionDataStoreName(string $project, string $location, string $collection, string $dataStore): string + { + return self::getPathTemplate('projectLocationCollectionDataStore')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_branch_document resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted project_location_collection_data_store_branch_document resource. + */ + public static function projectLocationCollectionDataStoreBranchDocumentName(string $project, string $location, string $collection, string $dataStore, string $branch, string $document): string + { + return self::getPathTemplate('projectLocationCollectionDataStoreBranchDocument')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted project_location_data_store resource. + */ + public static function projectLocationDataStoreName(string $project, string $location, string $dataStore): string + { + return self::getPathTemplate('projectLocationDataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_branch_document resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted project_location_data_store_branch_document resource. + */ + public static function projectLocationDataStoreBranchDocumentName(string $project, string $location, string $dataStore, string $branch, string $document): string + { + return self::getPathTemplate('projectLocationDataStoreBranchDocument')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - dataStore: projects/{project}/locations/{location}/dataStores/{data_store} + * - document: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} + * - projectLocationCollectionDataStore: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store} + * - projectLocationCollectionDataStoreBranchDocument: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document} + * - projectLocationDataStore: projects/{project}/locations/{location}/dataStores/{data_store} + * - projectLocationDataStoreBranchDocument: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'discoveryengine.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Writes a single user event from the browser. This uses a GET request to + * due to browser restriction of POST-ing to a third-party domain. + * + * This method is used only by the Discovery Engine API JavaScript pixel and + * Google Tag Manager. Users should not call this method directly. + * + * The async variant is {@see UserEventServiceClient::collectUserEventAsync()} . + * + * @example samples/V1/UserEventServiceClient/collect_user_event.php + * + * @param CollectUserEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 HttpBody + * + * @throws ApiException Thrown if the API call fails. + */ + public function collectUserEvent(CollectUserEventRequest $request, array $callOptions = []): HttpBody + { + return $this->startApiCall('CollectUserEvent', $request, $callOptions)->wait(); + } + + /** + * Bulk import of User events. Request processing might be + * synchronous. Events that already exist are skipped. + * Use this method for backfilling historical user events. + * + * Operation.response is of type ImportResponse. Note that it is + * possible for a subset of the items to be successfully inserted. + * Operation.metadata is of type ImportMetadata. + * + * The async variant is {@see UserEventServiceClient::importUserEventsAsync()} . + * + * @example samples/V1/UserEventServiceClient/import_user_events.php + * + * @param ImportUserEventsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importUserEvents(ImportUserEventsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportUserEvents', $request, $callOptions)->wait(); + } + + /** + * Writes a single user event. + * + * The async variant is {@see UserEventServiceClient::writeUserEventAsync()} . + * + * @example samples/V1/UserEventServiceClient/write_user_event.php + * + * @param WriteUserEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 UserEvent + * + * @throws ApiException Thrown if the API call fails. + */ + public function writeUserEvent(WriteUserEventRequest $request, array $callOptions = []): UserEvent + { + return $this->startApiCall('WriteUserEvent', $request, $callOptions)->wait(); + } } diff --git a/DiscoveryEngine/src/V1beta/Client/BaseClient/CompletionServiceBaseClient.php b/DiscoveryEngine/src/V1beta/Client/BaseClient/CompletionServiceBaseClient.php deleted file mode 100644 index 85b45ad65fee..000000000000 --- a/DiscoveryEngine/src/V1beta/Client/BaseClient/CompletionServiceBaseClient.php +++ /dev/null @@ -1,326 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . - '/../../resources/completion_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../../resources/completion_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . - '/../../resources/completion_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../../resources/completion_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a data_store - * resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * - * @return string The formatted data_store resource. - * - * @experimental - */ - public static function dataStoreName( - string $project, - string $location, - string $dataStore - ): string { - return self::getPathTemplate('dataStore')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * - * @return string The formatted project_location_collection_data_store resource. - * - * @experimental - */ - public static function projectLocationCollectionDataStoreName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStore' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * - * @return string The formatted project_location_data_store resource. - * - * @experimental - */ - public static function projectLocationDataStoreName( - string $project, - string $location, - string $dataStore - ): string { - return self::getPathTemplate('projectLocationDataStore')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - dataStore: projects/{project}/locations/{location}/dataStores/{data_store} - * - projectLocationCollectionDataStore: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store} - * - projectLocationDataStore: projects/{project}/locations/{location}/dataStores/{data_store} - * - * 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( - string $formattedName, - string $template = null - ): array { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'discoveryengine.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); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error( - 'Call to undefined method ' . __CLASS__ . "::$method()", - E_USER_ERROR - ); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Completes the specified user input with keyword suggestions. - * - * The async variant is {@see self::completeQueryAsync()} . - * - * @example samples/V1beta/CompletionServiceClient/complete_query.php - * - * @param CompleteQueryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CompleteQueryResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function completeQuery( - CompleteQueryRequest $request, - array $callOptions = [] - ): CompleteQueryResponse { - return $this->startApiCall( - 'CompleteQuery', - $request, - $callOptions - )->wait(); - } -} diff --git a/DiscoveryEngine/src/V1beta/Client/BaseClient/ConversationalSearchServiceBaseClient.php b/DiscoveryEngine/src/V1beta/Client/BaseClient/ConversationalSearchServiceBaseClient.php deleted file mode 100644 index bff377c1db87..000000000000 --- a/DiscoveryEngine/src/V1beta/Client/BaseClient/ConversationalSearchServiceBaseClient.php +++ /dev/null @@ -1,696 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . - '/../../resources/conversational_search_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../../resources/conversational_search_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . - '/../../resources/conversational_search_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../../resources/conversational_search_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a conversation - * resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $conversation - * - * @return string The formatted conversation resource. - * - * @experimental - */ - public static function conversationName( - string $project, - string $location, - string $dataStore, - string $conversation - ): string { - return self::getPathTemplate('conversation')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'conversation' => $conversation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a data_store - * resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * - * @return string The formatted data_store resource. - * - * @experimental - */ - public static function dataStoreName( - string $project, - string $location, - string $dataStore - ): string { - return self::getPathTemplate('dataStore')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * - * @return string The formatted project_location_collection_data_store resource. - * - * @experimental - */ - public static function projectLocationCollectionDataStoreName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStore' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store_conversation resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * @param string $conversation - * - * @return string The formatted project_location_collection_data_store_conversation resource. - * - * @experimental - */ - public static function projectLocationCollectionDataStoreConversationName( - string $project, - string $location, - string $collection, - string $dataStore, - string $conversation - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStoreConversation' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - 'conversation' => $conversation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store_serving_config resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * @param string $servingConfig - * - * @return string The formatted project_location_collection_data_store_serving_config resource. - * - * @experimental - */ - public static function projectLocationCollectionDataStoreServingConfigName( - string $project, - string $location, - string $collection, - string $dataStore, - string $servingConfig - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStoreServingConfig' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - 'serving_config' => $servingConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * - * @return string The formatted project_location_data_store resource. - * - * @experimental - */ - public static function projectLocationDataStoreName( - string $project, - string $location, - string $dataStore - ): string { - return self::getPathTemplate('projectLocationDataStore')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store_conversation resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $conversation - * - * @return string The formatted project_location_data_store_conversation resource. - * - * @experimental - */ - public static function projectLocationDataStoreConversationName( - string $project, - string $location, - string $dataStore, - string $conversation - ): string { - return self::getPathTemplate( - 'projectLocationDataStoreConversation' - )->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'conversation' => $conversation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store_serving_config resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $servingConfig - * - * @return string The formatted project_location_data_store_serving_config resource. - * - * @experimental - */ - public static function projectLocationDataStoreServingConfigName( - string $project, - string $location, - string $dataStore, - string $servingConfig - ): string { - return self::getPathTemplate( - 'projectLocationDataStoreServingConfig' - )->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'serving_config' => $servingConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * serving_config resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $servingConfig - * - * @return string The formatted serving_config resource. - * - * @experimental - */ - public static function servingConfigName( - string $project, - string $location, - string $dataStore, - string $servingConfig - ): string { - return self::getPathTemplate('servingConfig')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'serving_config' => $servingConfig, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - conversation: projects/{project}/locations/{location}/dataStores/{data_store}/conversations/{conversation} - * - dataStore: projects/{project}/locations/{location}/dataStores/{data_store} - * - projectLocationCollectionDataStore: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store} - * - projectLocationCollectionDataStoreConversation: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/conversations/{conversation} - * - projectLocationCollectionDataStoreServingConfig: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config} - * - projectLocationDataStore: projects/{project}/locations/{location}/dataStores/{data_store} - * - projectLocationDataStoreConversation: projects/{project}/locations/{location}/dataStores/{data_store}/conversations/{conversation} - * - projectLocationDataStoreServingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} - * - servingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} - * - * 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( - string $formattedName, - string $template = null - ): array { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'discoveryengine.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); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error( - 'Call to undefined method ' . __CLASS__ . "::$method()", - E_USER_ERROR - ); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Converses a conversation. - * - * The async variant is {@see self::converseConversationAsync()} . - * - * @example samples/V1beta/ConversationalSearchServiceClient/converse_conversation.php - * - * @param ConverseConversationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ConverseConversationResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function converseConversation( - ConverseConversationRequest $request, - array $callOptions = [] - ): ConverseConversationResponse { - return $this->startApiCall( - 'ConverseConversation', - $request, - $callOptions - )->wait(); - } - - /** - * Creates a Conversation. - * - * If the [Conversation][google.cloud.discoveryengine.v1beta.Conversation] to - * create already exists, an ALREADY_EXISTS error is returned. - * - * The async variant is {@see self::createConversationAsync()} . - * - * @example samples/V1beta/ConversationalSearchServiceClient/create_conversation.php - * - * @param CreateConversationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Conversation - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createConversation( - CreateConversationRequest $request, - array $callOptions = [] - ): Conversation { - return $this->startApiCall( - 'CreateConversation', - $request, - $callOptions - )->wait(); - } - - /** - * Deletes a Conversation. - * - * If the [Conversation][google.cloud.discoveryengine.v1beta.Conversation] to - * delete does not exist, a NOT_FOUND error is returned. - * - * The async variant is {@see self::deleteConversationAsync()} . - * - * @example samples/V1beta/ConversationalSearchServiceClient/delete_conversation.php - * - * @param DeleteConversationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteConversation( - DeleteConversationRequest $request, - array $callOptions = [] - ): void { - $this->startApiCall( - 'DeleteConversation', - $request, - $callOptions - )->wait(); - } - - /** - * Gets a Conversation. - * - * The async variant is {@see self::getConversationAsync()} . - * - * @example samples/V1beta/ConversationalSearchServiceClient/get_conversation.php - * - * @param GetConversationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Conversation - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getConversation( - GetConversationRequest $request, - array $callOptions = [] - ): Conversation { - return $this->startApiCall( - 'GetConversation', - $request, - $callOptions - )->wait(); - } - - /** - * Lists all Conversations by their parent - * [DataStore][google.cloud.discoveryengine.v1beta.DataStore]. - * - * The async variant is {@see self::listConversationsAsync()} . - * - * @example samples/V1beta/ConversationalSearchServiceClient/list_conversations.php - * - * @param ListConversationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listConversations( - ListConversationsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListConversations', $request, $callOptions); - } - - /** - * Updates a Conversation. - * - * [Conversation][google.cloud.discoveryengine.v1beta.Conversation] action - * type cannot be changed. If the - * [Conversation][google.cloud.discoveryengine.v1beta.Conversation] to update - * does not exist, a NOT_FOUND error is returned. - * - * The async variant is {@see self::updateConversationAsync()} . - * - * @example samples/V1beta/ConversationalSearchServiceClient/update_conversation.php - * - * @param UpdateConversationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Conversation - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function updateConversation( - UpdateConversationRequest $request, - array $callOptions = [] - ): Conversation { - return $this->startApiCall( - 'UpdateConversation', - $request, - $callOptions - )->wait(); - } -} diff --git a/DiscoveryEngine/src/V1beta/Client/BaseClient/DocumentServiceBaseClient.php b/DiscoveryEngine/src/V1beta/Client/BaseClient/DocumentServiceBaseClient.php deleted file mode 100644 index 4fd417136be7..000000000000 --- a/DiscoveryEngine/src/V1beta/Client/BaseClient/DocumentServiceBaseClient.php +++ /dev/null @@ -1,710 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . - '/../../resources/document_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../../resources/document_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . '/../../resources/document_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../../resources/document_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - * - * @experimental - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - * - * @experimental - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; - $operation = new OperationResponse( - $operationName, - $this->getOperationsClient(), - $options - ); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a branch - * resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $branch - * - * @return string The formatted branch resource. - * - * @experimental - */ - public static function branchName( - string $project, - string $location, - string $dataStore, - string $branch - ): string { - return self::getPathTemplate('branch')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'branch' => $branch, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a document - * resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $branch - * @param string $document - * - * @return string The formatted document resource. - * - * @experimental - */ - public static function documentName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document - ): string { - return self::getPathTemplate('document')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'branch' => $branch, - 'document' => $document, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store_branch resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * @param string $branch - * - * @return string The formatted project_location_collection_data_store_branch resource. - * - * @experimental - */ - public static function projectLocationCollectionDataStoreBranchName( - string $project, - string $location, - string $collection, - string $dataStore, - string $branch - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStoreBranch' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - 'branch' => $branch, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store_branch_document resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * @param string $branch - * @param string $document - * - * @return string The formatted project_location_collection_data_store_branch_document resource. - * - * @experimental - */ - public static function projectLocationCollectionDataStoreBranchDocumentName( - string $project, - string $location, - string $collection, - string $dataStore, - string $branch, - string $document - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStoreBranchDocument' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - 'branch' => $branch, - 'document' => $document, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store_branch resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $branch - * - * @return string The formatted project_location_data_store_branch resource. - * - * @experimental - */ - public static function projectLocationDataStoreBranchName( - string $project, - string $location, - string $dataStore, - string $branch - ): string { - return self::getPathTemplate('projectLocationDataStoreBranch')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'branch' => $branch, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store_branch_document resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $branch - * @param string $document - * - * @return string The formatted project_location_data_store_branch_document resource. - * - * @experimental - */ - public static function projectLocationDataStoreBranchDocumentName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document - ): string { - return self::getPathTemplate( - 'projectLocationDataStoreBranchDocument' - )->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'branch' => $branch, - 'document' => $document, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - branch: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch} - * - document: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} - * - projectLocationCollectionDataStoreBranch: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch} - * - projectLocationCollectionDataStoreBranchDocument: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document} - * - projectLocationDataStoreBranch: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch} - * - projectLocationDataStoreBranchDocument: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} - * - * 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( - string $formattedName, - string $template = null - ): array { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'discoveryengine.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); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error( - 'Call to undefined method ' . __CLASS__ . "::$method()", - E_USER_ERROR - ); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a [Document][google.cloud.discoveryengine.v1beta.Document]. - * - * The async variant is {@see self::createDocumentAsync()} . - * - * @example samples/V1beta/DocumentServiceClient/create_document.php - * - * @param CreateDocumentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Document - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createDocument( - CreateDocumentRequest $request, - array $callOptions = [] - ): Document { - return $this->startApiCall( - 'CreateDocument', - $request, - $callOptions - )->wait(); - } - - /** - * Deletes a [Document][google.cloud.discoveryengine.v1beta.Document]. - * - * The async variant is {@see self::deleteDocumentAsync()} . - * - * @example samples/V1beta/DocumentServiceClient/delete_document.php - * - * @param DeleteDocumentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteDocument( - DeleteDocumentRequest $request, - array $callOptions = [] - ): void { - $this->startApiCall('DeleteDocument', $request, $callOptions)->wait(); - } - - /** - * Gets a [Document][google.cloud.discoveryengine.v1beta.Document]. - * - * The async variant is {@see self::getDocumentAsync()} . - * - * @example samples/V1beta/DocumentServiceClient/get_document.php - * - * @param GetDocumentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Document - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getDocument( - GetDocumentRequest $request, - array $callOptions = [] - ): Document { - return $this->startApiCall( - 'GetDocument', - $request, - $callOptions - )->wait(); - } - - /** - * Bulk import of multiple - * [Document][google.cloud.discoveryengine.v1beta.Document]s. Request - * processing may be synchronous. Non-existing items will be created. - * - * Note: It is possible for a subset of the - * [Document][google.cloud.discoveryengine.v1beta.Document]s to be - * successfully updated. - * - * The async variant is {@see self::importDocumentsAsync()} . - * - * @example samples/V1beta/DocumentServiceClient/import_documents.php - * - * @param ImportDocumentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function importDocuments( - ImportDocumentsRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'ImportDocuments', - $request, - $callOptions - )->wait(); - } - - /** - * Gets a list of [Document][google.cloud.discoveryengine.v1beta.Document]s. - * - * The async variant is {@see self::listDocumentsAsync()} . - * - * @example samples/V1beta/DocumentServiceClient/list_documents.php - * - * @param ListDocumentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listDocuments( - ListDocumentsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListDocuments', $request, $callOptions); - } - - /** - * Permanently deletes all selected - * [Document][google.cloud.discoveryengine.v1beta.Document]s in a branch. - * - * This process is asynchronous. Depending on the number of - * [Document][google.cloud.discoveryengine.v1beta.Document]s to be deleted, - * this operation can take hours to complete. Before the delete operation - * completes, some [Document][google.cloud.discoveryengine.v1beta.Document]s - * might still be returned by - * [DocumentService.GetDocument][google.cloud.discoveryengine.v1beta.DocumentService.GetDocument] - * or - * [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments]. - * - * To get a list of the - * [Document][google.cloud.discoveryengine.v1beta.Document]s to be deleted, - * set - * [PurgeDocumentsRequest.force][google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest.force] - * to false. - * - * The async variant is {@see self::purgeDocumentsAsync()} . - * - * @example samples/V1beta/DocumentServiceClient/purge_documents.php - * - * @param PurgeDocumentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function purgeDocuments( - PurgeDocumentsRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'PurgeDocuments', - $request, - $callOptions - )->wait(); - } - - /** - * Updates a [Document][google.cloud.discoveryengine.v1beta.Document]. - * - * The async variant is {@see self::updateDocumentAsync()} . - * - * @example samples/V1beta/DocumentServiceClient/update_document.php - * - * @param UpdateDocumentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Document - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function updateDocument( - UpdateDocumentRequest $request, - array $callOptions = [] - ): Document { - return $this->startApiCall( - 'UpdateDocument', - $request, - $callOptions - )->wait(); - } -} diff --git a/DiscoveryEngine/src/V1beta/Client/BaseClient/RecommendationServiceBaseClient.php b/DiscoveryEngine/src/V1beta/Client/BaseClient/RecommendationServiceBaseClient.php deleted file mode 100644 index 8dd64ce9022c..000000000000 --- a/DiscoveryEngine/src/V1beta/Client/BaseClient/RecommendationServiceBaseClient.php +++ /dev/null @@ -1,433 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . - '/../../resources/recommendation_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../../resources/recommendation_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . - '/../../resources/recommendation_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../../resources/recommendation_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a document - * resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $branch - * @param string $document - * - * @return string The formatted document resource. - * - * @experimental - */ - public static function documentName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document - ): string { - return self::getPathTemplate('document')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'branch' => $branch, - 'document' => $document, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store_branch_document resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * @param string $branch - * @param string $document - * - * @return string The formatted project_location_collection_data_store_branch_document resource. - * - * @experimental - */ - public static function projectLocationCollectionDataStoreBranchDocumentName( - string $project, - string $location, - string $collection, - string $dataStore, - string $branch, - string $document - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStoreBranchDocument' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - 'branch' => $branch, - 'document' => $document, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store_serving_config resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * @param string $servingConfig - * - * @return string The formatted project_location_collection_data_store_serving_config resource. - * - * @experimental - */ - public static function projectLocationCollectionDataStoreServingConfigName( - string $project, - string $location, - string $collection, - string $dataStore, - string $servingConfig - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStoreServingConfig' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - 'serving_config' => $servingConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store_branch_document resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $branch - * @param string $document - * - * @return string The formatted project_location_data_store_branch_document resource. - * - * @experimental - */ - public static function projectLocationDataStoreBranchDocumentName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document - ): string { - return self::getPathTemplate( - 'projectLocationDataStoreBranchDocument' - )->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'branch' => $branch, - 'document' => $document, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store_serving_config resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $servingConfig - * - * @return string The formatted project_location_data_store_serving_config resource. - * - * @experimental - */ - public static function projectLocationDataStoreServingConfigName( - string $project, - string $location, - string $dataStore, - string $servingConfig - ): string { - return self::getPathTemplate( - 'projectLocationDataStoreServingConfig' - )->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'serving_config' => $servingConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * serving_config resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $servingConfig - * - * @return string The formatted serving_config resource. - * - * @experimental - */ - public static function servingConfigName( - string $project, - string $location, - string $dataStore, - string $servingConfig - ): string { - return self::getPathTemplate('servingConfig')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'serving_config' => $servingConfig, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - document: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} - * - projectLocationCollectionDataStoreBranchDocument: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document} - * - projectLocationCollectionDataStoreServingConfig: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config} - * - projectLocationDataStoreBranchDocument: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} - * - projectLocationDataStoreServingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} - * - servingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} - * - * 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( - string $formattedName, - string $template = null - ): array { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'discoveryengine.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); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error( - 'Call to undefined method ' . __CLASS__ . "::$method()", - E_USER_ERROR - ); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Makes a recommendation, which requires a contextual user event. - * - * The async variant is {@see self::recommendAsync()} . - * - * @example samples/V1beta/RecommendationServiceClient/recommend.php - * - * @param RecommendRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RecommendResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function recommend( - RecommendRequest $request, - array $callOptions = [] - ): RecommendResponse { - return $this->startApiCall('Recommend', $request, $callOptions)->wait(); - } -} diff --git a/DiscoveryEngine/src/V1beta/Client/BaseClient/SchemaServiceBaseClient.php b/DiscoveryEngine/src/V1beta/Client/BaseClient/SchemaServiceBaseClient.php deleted file mode 100644 index 3e375a2f8c5d..000000000000 --- a/DiscoveryEngine/src/V1beta/Client/BaseClient/SchemaServiceBaseClient.php +++ /dev/null @@ -1,595 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . '/../../resources/schema_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../../resources/schema_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . '/../../resources/schema_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../../resources/schema_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - * - * @experimental - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - * - * @experimental - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; - $operation = new OperationResponse( - $operationName, - $this->getOperationsClient(), - $options - ); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a data_store - * resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * - * @return string The formatted data_store resource. - * - * @experimental - */ - public static function dataStoreName( - string $project, - string $location, - string $dataStore - ): string { - return self::getPathTemplate('dataStore')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * - * @return string The formatted project_location_collection_data_store resource. - * - * @experimental - */ - public static function projectLocationCollectionDataStoreName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStore' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store_schema resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * @param string $schema - * - * @return string The formatted project_location_collection_data_store_schema resource. - * - * @experimental - */ - public static function projectLocationCollectionDataStoreSchemaName( - string $project, - string $location, - string $collection, - string $dataStore, - string $schema - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStoreSchema' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - 'schema' => $schema, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * - * @return string The formatted project_location_data_store resource. - * - * @experimental - */ - public static function projectLocationDataStoreName( - string $project, - string $location, - string $dataStore - ): string { - return self::getPathTemplate('projectLocationDataStore')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store_schema resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $schema - * - * @return string The formatted project_location_data_store_schema resource. - * - * @experimental - */ - public static function projectLocationDataStoreSchemaName( - string $project, - string $location, - string $dataStore, - string $schema - ): string { - return self::getPathTemplate('projectLocationDataStoreSchema')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'schema' => $schema, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a schema - * resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $schema - * - * @return string The formatted schema resource. - * - * @experimental - */ - public static function schemaName( - string $project, - string $location, - string $dataStore, - string $schema - ): string { - return self::getPathTemplate('schema')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'schema' => $schema, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - dataStore: projects/{project}/locations/{location}/dataStores/{data_store} - * - projectLocationCollectionDataStore: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store} - * - projectLocationCollectionDataStoreSchema: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema} - * - projectLocationDataStore: projects/{project}/locations/{location}/dataStores/{data_store} - * - projectLocationDataStoreSchema: projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema} - * - schema: projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema} - * - * 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( - string $formattedName, - string $template = null - ): array { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'discoveryengine.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); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error( - 'Call to undefined method ' . __CLASS__ . "::$method()", - E_USER_ERROR - ); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a [Schema][google.cloud.discoveryengine.v1beta.Schema]. - * - * The async variant is {@see self::createSchemaAsync()} . - * - * @example samples/V1beta/SchemaServiceClient/create_schema.php - * - * @param CreateSchemaRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createSchema( - CreateSchemaRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'CreateSchema', - $request, - $callOptions - )->wait(); - } - - /** - * Deletes a [Schema][google.cloud.discoveryengine.v1beta.Schema]. - * - * The async variant is {@see self::deleteSchemaAsync()} . - * - * @example samples/V1beta/SchemaServiceClient/delete_schema.php - * - * @param DeleteSchemaRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteSchema( - DeleteSchemaRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'DeleteSchema', - $request, - $callOptions - )->wait(); - } - - /** - * Gets a [Schema][google.cloud.discoveryengine.v1beta.Schema]. - * - * The async variant is {@see self::getSchemaAsync()} . - * - * @example samples/V1beta/SchemaServiceClient/get_schema.php - * - * @param GetSchemaRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Schema - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getSchema( - GetSchemaRequest $request, - array $callOptions = [] - ): Schema { - return $this->startApiCall('GetSchema', $request, $callOptions)->wait(); - } - - /** - * Gets a list of [Schema][google.cloud.discoveryengine.v1beta.Schema]s. - * - * The async variant is {@see self::listSchemasAsync()} . - * - * @example samples/V1beta/SchemaServiceClient/list_schemas.php - * - * @param ListSchemasRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listSchemas( - ListSchemasRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListSchemas', $request, $callOptions); - } - - /** - * Updates a [Schema][google.cloud.discoveryengine.v1beta.Schema]. - * - * The async variant is {@see self::updateSchemaAsync()} . - * - * @example samples/V1beta/SchemaServiceClient/update_schema.php - * - * @param UpdateSchemaRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function updateSchema( - UpdateSchemaRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'UpdateSchema', - $request, - $callOptions - )->wait(); - } -} diff --git a/DiscoveryEngine/src/V1beta/Client/BaseClient/SearchServiceBaseClient.php b/DiscoveryEngine/src/V1beta/Client/BaseClient/SearchServiceBaseClient.php deleted file mode 100644 index fe3ee5387404..000000000000 --- a/DiscoveryEngine/src/V1beta/Client/BaseClient/SearchServiceBaseClient.php +++ /dev/null @@ -1,420 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . '/../../resources/search_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../../resources/search_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . '/../../resources/search_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../../resources/search_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a branch - * resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $branch - * - * @return string The formatted branch resource. - * - * @experimental - */ - public static function branchName( - string $project, - string $location, - string $dataStore, - string $branch - ): string { - return self::getPathTemplate('branch')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'branch' => $branch, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store_branch resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * @param string $branch - * - * @return string The formatted project_location_collection_data_store_branch resource. - * - * @experimental - */ - public static function projectLocationCollectionDataStoreBranchName( - string $project, - string $location, - string $collection, - string $dataStore, - string $branch - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStoreBranch' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - 'branch' => $branch, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store_serving_config resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * @param string $servingConfig - * - * @return string The formatted project_location_collection_data_store_serving_config resource. - * - * @experimental - */ - public static function projectLocationCollectionDataStoreServingConfigName( - string $project, - string $location, - string $collection, - string $dataStore, - string $servingConfig - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStoreServingConfig' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - 'serving_config' => $servingConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store_branch resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $branch - * - * @return string The formatted project_location_data_store_branch resource. - * - * @experimental - */ - public static function projectLocationDataStoreBranchName( - string $project, - string $location, - string $dataStore, - string $branch - ): string { - return self::getPathTemplate('projectLocationDataStoreBranch')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'branch' => $branch, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store_serving_config resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $servingConfig - * - * @return string The formatted project_location_data_store_serving_config resource. - * - * @experimental - */ - public static function projectLocationDataStoreServingConfigName( - string $project, - string $location, - string $dataStore, - string $servingConfig - ): string { - return self::getPathTemplate( - 'projectLocationDataStoreServingConfig' - )->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'serving_config' => $servingConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * serving_config resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $servingConfig - * - * @return string The formatted serving_config resource. - * - * @experimental - */ - public static function servingConfigName( - string $project, - string $location, - string $dataStore, - string $servingConfig - ): string { - return self::getPathTemplate('servingConfig')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'serving_config' => $servingConfig, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - branch: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch} - * - projectLocationCollectionDataStoreBranch: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch} - * - projectLocationCollectionDataStoreServingConfig: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config} - * - projectLocationDataStoreBranch: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch} - * - projectLocationDataStoreServingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} - * - servingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} - * - * 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( - string $formattedName, - string $template = null - ): array { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'discoveryengine.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); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error( - 'Call to undefined method ' . __CLASS__ . "::$method()", - E_USER_ERROR - ); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Performs a search. - * - * The async variant is {@see self::searchAsync()} . - * - * @example samples/V1beta/SearchServiceClient/search.php - * - * @param SearchRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function search( - SearchRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('Search', $request, $callOptions); - } -} diff --git a/DiscoveryEngine/src/V1beta/Client/BaseClient/UserEventServiceBaseClient.php b/DiscoveryEngine/src/V1beta/Client/BaseClient/UserEventServiceBaseClient.php deleted file mode 100644 index 65e0013d5f05..000000000000 --- a/DiscoveryEngine/src/V1beta/Client/BaseClient/UserEventServiceBaseClient.php +++ /dev/null @@ -1,554 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . - '/../../resources/user_event_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../../resources/user_event_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . - '/../../resources/user_event_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../../resources/user_event_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - * - * @experimental - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - * - * @experimental - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; - $operation = new OperationResponse( - $operationName, - $this->getOperationsClient(), - $options - ); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a data_store - * resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * - * @return string The formatted data_store resource. - * - * @experimental - */ - public static function dataStoreName( - string $project, - string $location, - string $dataStore - ): string { - return self::getPathTemplate('dataStore')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a document - * resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $branch - * @param string $document - * - * @return string The formatted document resource. - * - * @experimental - */ - public static function documentName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document - ): string { - return self::getPathTemplate('document')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'branch' => $branch, - 'document' => $document, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * - * @return string The formatted project_location_collection_data_store resource. - * - * @experimental - */ - public static function projectLocationCollectionDataStoreName( - string $project, - string $location, - string $collection, - string $dataStore - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStore' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_collection_data_store_branch_document resource. - * - * @param string $project - * @param string $location - * @param string $collection - * @param string $dataStore - * @param string $branch - * @param string $document - * - * @return string The formatted project_location_collection_data_store_branch_document resource. - * - * @experimental - */ - public static function projectLocationCollectionDataStoreBranchDocumentName( - string $project, - string $location, - string $collection, - string $dataStore, - string $branch, - string $document - ): string { - return self::getPathTemplate( - 'projectLocationCollectionDataStoreBranchDocument' - )->render([ - 'project' => $project, - 'location' => $location, - 'collection' => $collection, - 'data_store' => $dataStore, - 'branch' => $branch, - 'document' => $document, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * - * @return string The formatted project_location_data_store resource. - * - * @experimental - */ - public static function projectLocationDataStoreName( - string $project, - string $location, - string $dataStore - ): string { - return self::getPathTemplate('projectLocationDataStore')->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_data_store_branch_document resource. - * - * @param string $project - * @param string $location - * @param string $dataStore - * @param string $branch - * @param string $document - * - * @return string The formatted project_location_data_store_branch_document resource. - * - * @experimental - */ - public static function projectLocationDataStoreBranchDocumentName( - string $project, - string $location, - string $dataStore, - string $branch, - string $document - ): string { - return self::getPathTemplate( - 'projectLocationDataStoreBranchDocument' - )->render([ - 'project' => $project, - 'location' => $location, - 'data_store' => $dataStore, - 'branch' => $branch, - 'document' => $document, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - dataStore: projects/{project}/locations/{location}/dataStores/{data_store} - * - document: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} - * - projectLocationCollectionDataStore: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store} - * - projectLocationCollectionDataStoreBranchDocument: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document} - * - projectLocationDataStore: projects/{project}/locations/{location}/dataStores/{data_store} - * - projectLocationDataStoreBranchDocument: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} - * - * 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( - string $formattedName, - string $template = null - ): array { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'discoveryengine.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); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error( - 'Call to undefined method ' . __CLASS__ . "::$method()", - E_USER_ERROR - ); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Writes a single user event from the browser. This uses a GET request to - * due to browser restriction of POST-ing to a third-party domain. - * - * This method is used only by the Discovery Engine API JavaScript pixel and - * Google Tag Manager. Users should not call this method directly. - * - * The async variant is {@see self::collectUserEventAsync()} . - * - * @example samples/V1beta/UserEventServiceClient/collect_user_event.php - * - * @param CollectUserEventRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 HttpBody - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function collectUserEvent( - CollectUserEventRequest $request, - array $callOptions = [] - ): HttpBody { - return $this->startApiCall( - 'CollectUserEvent', - $request, - $callOptions - )->wait(); - } - - /** - * Bulk import of User events. Request processing might be - * synchronous. Events that already exist are skipped. - * Use this method for backfilling historical user events. - * - * Operation.response is of type ImportResponse. Note that it is - * possible for a subset of the items to be successfully inserted. - * Operation.metadata is of type ImportMetadata. - * - * The async variant is {@see self::importUserEventsAsync()} . - * - * @example samples/V1beta/UserEventServiceClient/import_user_events.php - * - * @param ImportUserEventsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function importUserEvents( - ImportUserEventsRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'ImportUserEvents', - $request, - $callOptions - )->wait(); - } - - /** - * Writes a single user event. - * - * The async variant is {@see self::writeUserEventAsync()} . - * - * @example samples/V1beta/UserEventServiceClient/write_user_event.php - * - * @param WriteUserEventRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 UserEvent - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function writeUserEvent( - WriteUserEventRequest $request, - array $callOptions = [] - ): UserEvent { - return $this->startApiCall( - 'WriteUserEvent', - $request, - $callOptions - )->wait(); - } -} diff --git a/DiscoveryEngine/src/V1beta/Client/CompletionServiceClient.php b/DiscoveryEngine/src/V1beta/Client/CompletionServiceClient.php index 6855fab218e3..e87b81b9a73e 100644 --- a/DiscoveryEngine/src/V1beta/Client/CompletionServiceClient.php +++ b/DiscoveryEngine/src/V1beta/Client/CompletionServiceClient.php @@ -26,17 +26,267 @@ namespace Google\Cloud\DiscoveryEngine\V1beta\Client; -use Google\Cloud\DiscoveryEngine\V1beta\Client\BaseClient\CompletionServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\DiscoveryEngine\V1beta\CompleteQueryRequest; +use Google\Cloud\DiscoveryEngine\V1beta\CompleteQueryResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for Auto-Completion. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface completeQueryAsync(CompleteQueryRequest $request, array $optionalArgs = []) */ -final class CompletionServiceClient extends CompletionServiceBaseClient +final class CompletionServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CompletionServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.discoveryengine.v1beta.CompletionService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'discoveryengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/completion_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/completion_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/completion_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/completion_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a data_store + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted data_store resource. + * + * @experimental + */ + public static function dataStoreName(string $project, string $location, string $dataStore): string + { + return self::getPathTemplate('dataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * + * @return string The formatted project_location_collection_data_store resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreName(string $project, string $location, string $collection, string $dataStore): string + { + return self::getPathTemplate('projectLocationCollectionDataStore')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted project_location_data_store resource. + * + * @experimental + */ + public static function projectLocationDataStoreName(string $project, string $location, string $dataStore): string + { + return self::getPathTemplate('projectLocationDataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - dataStore: projects/{project}/locations/{location}/dataStores/{data_store} + * - projectLocationCollectionDataStore: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store} + * - projectLocationDataStore: projects/{project}/locations/{location}/dataStores/{data_store} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'discoveryengine.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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Completes the specified user input with keyword suggestions. + * + * The async variant is {@see CompletionServiceClient::completeQueryAsync()} . + * + * @example samples/V1beta/CompletionServiceClient/complete_query.php + * + * @param CompleteQueryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CompleteQueryResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function completeQuery(CompleteQueryRequest $request, array $callOptions = []): CompleteQueryResponse + { + return $this->startApiCall('CompleteQuery', $request, $callOptions)->wait(); + } } diff --git a/DiscoveryEngine/src/V1beta/Client/ConversationalSearchServiceClient.php b/DiscoveryEngine/src/V1beta/Client/ConversationalSearchServiceClient.php index 1cc718d625b2..505bd05806ad 100644 --- a/DiscoveryEngine/src/V1beta/Client/ConversationalSearchServiceClient.php +++ b/DiscoveryEngine/src/V1beta/Client/ConversationalSearchServiceClient.php @@ -26,17 +26,583 @@ namespace Google\Cloud\DiscoveryEngine\V1beta\Client; -use Google\Cloud\DiscoveryEngine\V1beta\Client\BaseClient\ConversationalSearchServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\DiscoveryEngine\V1beta\Conversation; +use Google\Cloud\DiscoveryEngine\V1beta\ConverseConversationRequest; +use Google\Cloud\DiscoveryEngine\V1beta\ConverseConversationResponse; +use Google\Cloud\DiscoveryEngine\V1beta\CreateConversationRequest; +use Google\Cloud\DiscoveryEngine\V1beta\DeleteConversationRequest; +use Google\Cloud\DiscoveryEngine\V1beta\GetConversationRequest; +use Google\Cloud\DiscoveryEngine\V1beta\ListConversationsRequest; +use Google\Cloud\DiscoveryEngine\V1beta\UpdateConversationRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for conversational search. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface converseConversationAsync(ConverseConversationRequest $request, array $optionalArgs = []) + * @method PromiseInterface createConversationAsync(CreateConversationRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteConversationAsync(DeleteConversationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getConversationAsync(GetConversationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listConversationsAsync(ListConversationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateConversationAsync(UpdateConversationRequest $request, array $optionalArgs = []) */ -final class ConversationalSearchServiceClient extends ConversationalSearchServiceBaseClient +final class ConversationalSearchServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ConversationalSearchServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.discoveryengine.v1beta.ConversationalSearchService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'discoveryengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/conversational_search_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/conversational_search_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/conversational_search_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/conversational_search_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a conversation + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $conversation + * + * @return string The formatted conversation resource. + * + * @experimental + */ + public static function conversationName(string $project, string $location, string $dataStore, string $conversation): string + { + return self::getPathTemplate('conversation')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'conversation' => $conversation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a data_store + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted data_store resource. + * + * @experimental + */ + public static function dataStoreName(string $project, string $location, string $dataStore): string + { + return self::getPathTemplate('dataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * + * @return string The formatted project_location_collection_data_store resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreName(string $project, string $location, string $collection, string $dataStore): string + { + return self::getPathTemplate('projectLocationCollectionDataStore')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_conversation resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $conversation + * + * @return string The formatted project_location_collection_data_store_conversation resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreConversationName(string $project, string $location, string $collection, string $dataStore, string $conversation): string + { + return self::getPathTemplate('projectLocationCollectionDataStoreConversation')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'conversation' => $conversation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_serving_config resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $servingConfig + * + * @return string The formatted project_location_collection_data_store_serving_config resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreServingConfigName(string $project, string $location, string $collection, string $dataStore, string $servingConfig): string + { + return self::getPathTemplate('projectLocationCollectionDataStoreServingConfig')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'serving_config' => $servingConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted project_location_data_store resource. + * + * @experimental + */ + public static function projectLocationDataStoreName(string $project, string $location, string $dataStore): string + { + return self::getPathTemplate('projectLocationDataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_conversation resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $conversation + * + * @return string The formatted project_location_data_store_conversation resource. + * + * @experimental + */ + public static function projectLocationDataStoreConversationName(string $project, string $location, string $dataStore, string $conversation): string + { + return self::getPathTemplate('projectLocationDataStoreConversation')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'conversation' => $conversation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_serving_config resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $servingConfig + * + * @return string The formatted project_location_data_store_serving_config resource. + * + * @experimental + */ + public static function projectLocationDataStoreServingConfigName(string $project, string $location, string $dataStore, string $servingConfig): string + { + return self::getPathTemplate('projectLocationDataStoreServingConfig')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'serving_config' => $servingConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * serving_config resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $servingConfig + * + * @return string The formatted serving_config resource. + * + * @experimental + */ + public static function servingConfigName(string $project, string $location, string $dataStore, string $servingConfig): string + { + return self::getPathTemplate('servingConfig')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'serving_config' => $servingConfig, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - conversation: projects/{project}/locations/{location}/dataStores/{data_store}/conversations/{conversation} + * - dataStore: projects/{project}/locations/{location}/dataStores/{data_store} + * - projectLocationCollectionDataStore: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store} + * - projectLocationCollectionDataStoreConversation: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/conversations/{conversation} + * - projectLocationCollectionDataStoreServingConfig: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config} + * - projectLocationDataStore: projects/{project}/locations/{location}/dataStores/{data_store} + * - projectLocationDataStoreConversation: projects/{project}/locations/{location}/dataStores/{data_store}/conversations/{conversation} + * - projectLocationDataStoreServingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} + * - servingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'discoveryengine.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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Converses a conversation. + * + * The async variant is + * {@see ConversationalSearchServiceClient::converseConversationAsync()} . + * + * @example samples/V1beta/ConversationalSearchServiceClient/converse_conversation.php + * + * @param ConverseConversationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ConverseConversationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function converseConversation(ConverseConversationRequest $request, array $callOptions = []): ConverseConversationResponse + { + return $this->startApiCall('ConverseConversation', $request, $callOptions)->wait(); + } + + /** + * Creates a Conversation. + * + * If the [Conversation][google.cloud.discoveryengine.v1beta.Conversation] to + * create already exists, an ALREADY_EXISTS error is returned. + * + * The async variant is + * {@see ConversationalSearchServiceClient::createConversationAsync()} . + * + * @example samples/V1beta/ConversationalSearchServiceClient/create_conversation.php + * + * @param CreateConversationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Conversation + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createConversation(CreateConversationRequest $request, array $callOptions = []): Conversation + { + return $this->startApiCall('CreateConversation', $request, $callOptions)->wait(); + } + + /** + * Deletes a Conversation. + * + * If the [Conversation][google.cloud.discoveryengine.v1beta.Conversation] to + * delete does not exist, a NOT_FOUND error is returned. + * + * The async variant is + * {@see ConversationalSearchServiceClient::deleteConversationAsync()} . + * + * @example samples/V1beta/ConversationalSearchServiceClient/delete_conversation.php + * + * @param DeleteConversationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteConversation(DeleteConversationRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteConversation', $request, $callOptions)->wait(); + } + + /** + * Gets a Conversation. + * + * The async variant is + * {@see ConversationalSearchServiceClient::getConversationAsync()} . + * + * @example samples/V1beta/ConversationalSearchServiceClient/get_conversation.php + * + * @param GetConversationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Conversation + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getConversation(GetConversationRequest $request, array $callOptions = []): Conversation + { + return $this->startApiCall('GetConversation', $request, $callOptions)->wait(); + } + + /** + * Lists all Conversations by their parent + * [DataStore][google.cloud.discoveryengine.v1beta.DataStore]. + * + * The async variant is + * {@see ConversationalSearchServiceClient::listConversationsAsync()} . + * + * @example samples/V1beta/ConversationalSearchServiceClient/list_conversations.php + * + * @param ListConversationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listConversations(ListConversationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListConversations', $request, $callOptions); + } + + /** + * Updates a Conversation. + * + * [Conversation][google.cloud.discoveryengine.v1beta.Conversation] action + * type cannot be changed. If the + * [Conversation][google.cloud.discoveryengine.v1beta.Conversation] to update + * does not exist, a NOT_FOUND error is returned. + * + * The async variant is + * {@see ConversationalSearchServiceClient::updateConversationAsync()} . + * + * @example samples/V1beta/ConversationalSearchServiceClient/update_conversation.php + * + * @param UpdateConversationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Conversation + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function updateConversation(UpdateConversationRequest $request, array $callOptions = []): Conversation + { + return $this->startApiCall('UpdateConversation', $request, $callOptions)->wait(); + } } diff --git a/DiscoveryEngine/src/V1beta/Client/DocumentServiceClient.php b/DiscoveryEngine/src/V1beta/Client/DocumentServiceClient.php index 2a9f1b3543d3..a5167564ecf2 100644 --- a/DiscoveryEngine/src/V1beta/Client/DocumentServiceClient.php +++ b/DiscoveryEngine/src/V1beta/Client/DocumentServiceClient.php @@ -26,17 +26,595 @@ namespace Google\Cloud\DiscoveryEngine\V1beta\Client; -use Google\Cloud\DiscoveryEngine\V1beta\Client\BaseClient\DocumentServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\DiscoveryEngine\V1beta\CreateDocumentRequest; +use Google\Cloud\DiscoveryEngine\V1beta\DeleteDocumentRequest; +use Google\Cloud\DiscoveryEngine\V1beta\Document; +use Google\Cloud\DiscoveryEngine\V1beta\GetDocumentRequest; +use Google\Cloud\DiscoveryEngine\V1beta\ImportDocumentsRequest; +use Google\Cloud\DiscoveryEngine\V1beta\ListDocumentsRequest; +use Google\Cloud\DiscoveryEngine\V1beta\PurgeDocumentsRequest; +use Google\Cloud\DiscoveryEngine\V1beta\UpdateDocumentRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for ingesting + * [Document][google.cloud.discoveryengine.v1beta.Document] information of the + * customer's website. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createDocumentAsync(CreateDocumentRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDocumentAsync(DeleteDocumentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDocumentAsync(GetDocumentRequest $request, array $optionalArgs = []) + * @method PromiseInterface importDocumentsAsync(ImportDocumentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDocumentsAsync(ListDocumentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface purgeDocumentsAsync(PurgeDocumentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDocumentAsync(UpdateDocumentRequest $request, array $optionalArgs = []) */ -final class DocumentServiceClient extends DocumentServiceBaseClient +final class DocumentServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DocumentServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.discoveryengine.v1beta.DocumentService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'discoveryengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/document_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/document_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/document_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/document_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + * + * @experimental + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + * + * @experimental + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a branch + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * + * @return string The formatted branch resource. + * + * @experimental + */ + public static function branchName(string $project, string $location, string $dataStore, string $branch): string + { + return self::getPathTemplate('branch')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a document + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted document resource. + * + * @experimental + */ + public static function documentName(string $project, string $location, string $dataStore, string $branch, string $document): string + { + return self::getPathTemplate('document')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_branch resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $branch + * + * @return string The formatted project_location_collection_data_store_branch resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreBranchName(string $project, string $location, string $collection, string $dataStore, string $branch): string + { + return self::getPathTemplate('projectLocationCollectionDataStoreBranch')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'branch' => $branch, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_branch_document resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted project_location_collection_data_store_branch_document resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreBranchDocumentName(string $project, string $location, string $collection, string $dataStore, string $branch, string $document): string + { + return self::getPathTemplate('projectLocationCollectionDataStoreBranchDocument')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_branch resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * + * @return string The formatted project_location_data_store_branch resource. + * + * @experimental + */ + public static function projectLocationDataStoreBranchName(string $project, string $location, string $dataStore, string $branch): string + { + return self::getPathTemplate('projectLocationDataStoreBranch')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_branch_document resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted project_location_data_store_branch_document resource. + * + * @experimental + */ + public static function projectLocationDataStoreBranchDocumentName(string $project, string $location, string $dataStore, string $branch, string $document): string + { + return self::getPathTemplate('projectLocationDataStoreBranchDocument')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - branch: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch} + * - document: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} + * - projectLocationCollectionDataStoreBranch: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch} + * - projectLocationCollectionDataStoreBranchDocument: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document} + * - projectLocationDataStoreBranch: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch} + * - projectLocationDataStoreBranchDocument: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'discoveryengine.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); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a [Document][google.cloud.discoveryengine.v1beta.Document]. + * + * The async variant is {@see DocumentServiceClient::createDocumentAsync()} . + * + * @example samples/V1beta/DocumentServiceClient/create_document.php + * + * @param CreateDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Document + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createDocument(CreateDocumentRequest $request, array $callOptions = []): Document + { + return $this->startApiCall('CreateDocument', $request, $callOptions)->wait(); + } + + /** + * Deletes a [Document][google.cloud.discoveryengine.v1beta.Document]. + * + * The async variant is {@see DocumentServiceClient::deleteDocumentAsync()} . + * + * @example samples/V1beta/DocumentServiceClient/delete_document.php + * + * @param DeleteDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteDocument(DeleteDocumentRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteDocument', $request, $callOptions)->wait(); + } + + /** + * Gets a [Document][google.cloud.discoveryengine.v1beta.Document]. + * + * The async variant is {@see DocumentServiceClient::getDocumentAsync()} . + * + * @example samples/V1beta/DocumentServiceClient/get_document.php + * + * @param GetDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Document + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getDocument(GetDocumentRequest $request, array $callOptions = []): Document + { + return $this->startApiCall('GetDocument', $request, $callOptions)->wait(); + } + + /** + * Bulk import of multiple + * [Document][google.cloud.discoveryengine.v1beta.Document]s. Request + * processing may be synchronous. Non-existing items will be created. + * + * Note: It is possible for a subset of the + * [Document][google.cloud.discoveryengine.v1beta.Document]s to be + * successfully updated. + * + * The async variant is {@see DocumentServiceClient::importDocumentsAsync()} . + * + * @example samples/V1beta/DocumentServiceClient/import_documents.php + * + * @param ImportDocumentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function importDocuments(ImportDocumentsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportDocuments', $request, $callOptions)->wait(); + } + + /** + * Gets a list of [Document][google.cloud.discoveryengine.v1beta.Document]s. + * + * The async variant is {@see DocumentServiceClient::listDocumentsAsync()} . + * + * @example samples/V1beta/DocumentServiceClient/list_documents.php + * + * @param ListDocumentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listDocuments(ListDocumentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDocuments', $request, $callOptions); + } + + /** + * Permanently deletes all selected + * [Document][google.cloud.discoveryengine.v1beta.Document]s in a branch. + * + * This process is asynchronous. Depending on the number of + * [Document][google.cloud.discoveryengine.v1beta.Document]s to be deleted, + * this operation can take hours to complete. Before the delete operation + * completes, some [Document][google.cloud.discoveryengine.v1beta.Document]s + * might still be returned by + * [DocumentService.GetDocument][google.cloud.discoveryengine.v1beta.DocumentService.GetDocument] + * or + * [DocumentService.ListDocuments][google.cloud.discoveryengine.v1beta.DocumentService.ListDocuments]. + * + * To get a list of the + * [Document][google.cloud.discoveryengine.v1beta.Document]s to be deleted, + * set + * [PurgeDocumentsRequest.force][google.cloud.discoveryengine.v1beta.PurgeDocumentsRequest.force] + * to false. + * + * The async variant is {@see DocumentServiceClient::purgeDocumentsAsync()} . + * + * @example samples/V1beta/DocumentServiceClient/purge_documents.php + * + * @param PurgeDocumentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function purgeDocuments(PurgeDocumentsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('PurgeDocuments', $request, $callOptions)->wait(); + } + + /** + * Updates a [Document][google.cloud.discoveryengine.v1beta.Document]. + * + * The async variant is {@see DocumentServiceClient::updateDocumentAsync()} . + * + * @example samples/V1beta/DocumentServiceClient/update_document.php + * + * @param UpdateDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Document + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function updateDocument(UpdateDocumentRequest $request, array $callOptions = []): Document + { + return $this->startApiCall('UpdateDocument', $request, $callOptions)->wait(); + } } diff --git a/DiscoveryEngine/src/V1beta/Client/RecommendationServiceClient.php b/DiscoveryEngine/src/V1beta/Client/RecommendationServiceClient.php index c3ffa75871d8..87fb120a9858 100644 --- a/DiscoveryEngine/src/V1beta/Client/RecommendationServiceClient.php +++ b/DiscoveryEngine/src/V1beta/Client/RecommendationServiceClient.php @@ -26,17 +26,353 @@ namespace Google\Cloud\DiscoveryEngine\V1beta\Client; -use Google\Cloud\DiscoveryEngine\V1beta\Client\BaseClient\RecommendationServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\DiscoveryEngine\V1beta\RecommendRequest; +use Google\Cloud\DiscoveryEngine\V1beta\RecommendResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for making recommendations. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface recommendAsync(RecommendRequest $request, array $optionalArgs = []) */ -final class RecommendationServiceClient extends RecommendationServiceBaseClient +final class RecommendationServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RecommendationServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.discoveryengine.v1beta.RecommendationService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'discoveryengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/recommendation_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/recommendation_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/recommendation_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/recommendation_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a document + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted document resource. + * + * @experimental + */ + public static function documentName(string $project, string $location, string $dataStore, string $branch, string $document): string + { + return self::getPathTemplate('document')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_branch_document resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted project_location_collection_data_store_branch_document resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreBranchDocumentName(string $project, string $location, string $collection, string $dataStore, string $branch, string $document): string + { + return self::getPathTemplate('projectLocationCollectionDataStoreBranchDocument')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_serving_config resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $servingConfig + * + * @return string The formatted project_location_collection_data_store_serving_config resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreServingConfigName(string $project, string $location, string $collection, string $dataStore, string $servingConfig): string + { + return self::getPathTemplate('projectLocationCollectionDataStoreServingConfig')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'serving_config' => $servingConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_branch_document resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted project_location_data_store_branch_document resource. + * + * @experimental + */ + public static function projectLocationDataStoreBranchDocumentName(string $project, string $location, string $dataStore, string $branch, string $document): string + { + return self::getPathTemplate('projectLocationDataStoreBranchDocument')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_serving_config resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $servingConfig + * + * @return string The formatted project_location_data_store_serving_config resource. + * + * @experimental + */ + public static function projectLocationDataStoreServingConfigName(string $project, string $location, string $dataStore, string $servingConfig): string + { + return self::getPathTemplate('projectLocationDataStoreServingConfig')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'serving_config' => $servingConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * serving_config resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $servingConfig + * + * @return string The formatted serving_config resource. + * + * @experimental + */ + public static function servingConfigName(string $project, string $location, string $dataStore, string $servingConfig): string + { + return self::getPathTemplate('servingConfig')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'serving_config' => $servingConfig, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - document: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} + * - projectLocationCollectionDataStoreBranchDocument: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document} + * - projectLocationCollectionDataStoreServingConfig: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config} + * - projectLocationDataStoreBranchDocument: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} + * - projectLocationDataStoreServingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} + * - servingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'discoveryengine.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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Makes a recommendation, which requires a contextual user event. + * + * The async variant is {@see RecommendationServiceClient::recommendAsync()} . + * + * @example samples/V1beta/RecommendationServiceClient/recommend.php + * + * @param RecommendRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RecommendResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function recommend(RecommendRequest $request, array $callOptions = []): RecommendResponse + { + return $this->startApiCall('Recommend', $request, $callOptions)->wait(); + } } diff --git a/DiscoveryEngine/src/V1beta/Client/SchemaServiceClient.php b/DiscoveryEngine/src/V1beta/Client/SchemaServiceClient.php index 4282e2279c98..0014f3513404 100644 --- a/DiscoveryEngine/src/V1beta/Client/SchemaServiceClient.php +++ b/DiscoveryEngine/src/V1beta/Client/SchemaServiceClient.php @@ -26,17 +26,501 @@ namespace Google\Cloud\DiscoveryEngine\V1beta\Client; -use Google\Cloud\DiscoveryEngine\V1beta\Client\BaseClient\SchemaServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\DiscoveryEngine\V1beta\CreateSchemaRequest; +use Google\Cloud\DiscoveryEngine\V1beta\DeleteSchemaRequest; +use Google\Cloud\DiscoveryEngine\V1beta\GetSchemaRequest; +use Google\Cloud\DiscoveryEngine\V1beta\ListSchemasRequest; +use Google\Cloud\DiscoveryEngine\V1beta\Schema; +use Google\Cloud\DiscoveryEngine\V1beta\UpdateSchemaRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for managing [Schema][google.cloud.discoveryengine.v1beta.Schema]s. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createSchemaAsync(CreateSchemaRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSchemaAsync(DeleteSchemaRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSchemaAsync(GetSchemaRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSchemasAsync(ListSchemasRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSchemaAsync(UpdateSchemaRequest $request, array $optionalArgs = []) */ -final class SchemaServiceClient extends SchemaServiceBaseClient +final class SchemaServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SchemaServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.discoveryengine.v1beta.SchemaService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'discoveryengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/schema_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/schema_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/schema_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/schema_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + * + * @experimental + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + * + * @experimental + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a data_store + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted data_store resource. + * + * @experimental + */ + public static function dataStoreName(string $project, string $location, string $dataStore): string + { + return self::getPathTemplate('dataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * + * @return string The formatted project_location_collection_data_store resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreName(string $project, string $location, string $collection, string $dataStore): string + { + return self::getPathTemplate('projectLocationCollectionDataStore')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_schema resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $schema + * + * @return string The formatted project_location_collection_data_store_schema resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreSchemaName(string $project, string $location, string $collection, string $dataStore, string $schema): string + { + return self::getPathTemplate('projectLocationCollectionDataStoreSchema')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'schema' => $schema, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted project_location_data_store resource. + * + * @experimental + */ + public static function projectLocationDataStoreName(string $project, string $location, string $dataStore): string + { + return self::getPathTemplate('projectLocationDataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_schema resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $schema + * + * @return string The formatted project_location_data_store_schema resource. + * + * @experimental + */ + public static function projectLocationDataStoreSchemaName(string $project, string $location, string $dataStore, string $schema): string + { + return self::getPathTemplate('projectLocationDataStoreSchema')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'schema' => $schema, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a schema + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $schema + * + * @return string The formatted schema resource. + * + * @experimental + */ + public static function schemaName(string $project, string $location, string $dataStore, string $schema): string + { + return self::getPathTemplate('schema')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'schema' => $schema, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - dataStore: projects/{project}/locations/{location}/dataStores/{data_store} + * - projectLocationCollectionDataStore: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store} + * - projectLocationCollectionDataStoreSchema: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/schemas/{schema} + * - projectLocationDataStore: projects/{project}/locations/{location}/dataStores/{data_store} + * - projectLocationDataStoreSchema: projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema} + * - schema: projects/{project}/locations/{location}/dataStores/{data_store}/schemas/{schema} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'discoveryengine.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); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a [Schema][google.cloud.discoveryengine.v1beta.Schema]. + * + * The async variant is {@see SchemaServiceClient::createSchemaAsync()} . + * + * @example samples/V1beta/SchemaServiceClient/create_schema.php + * + * @param CreateSchemaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createSchema(CreateSchemaRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateSchema', $request, $callOptions)->wait(); + } + + /** + * Deletes a [Schema][google.cloud.discoveryengine.v1beta.Schema]. + * + * The async variant is {@see SchemaServiceClient::deleteSchemaAsync()} . + * + * @example samples/V1beta/SchemaServiceClient/delete_schema.php + * + * @param DeleteSchemaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteSchema(DeleteSchemaRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteSchema', $request, $callOptions)->wait(); + } + + /** + * Gets a [Schema][google.cloud.discoveryengine.v1beta.Schema]. + * + * The async variant is {@see SchemaServiceClient::getSchemaAsync()} . + * + * @example samples/V1beta/SchemaServiceClient/get_schema.php + * + * @param GetSchemaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Schema + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getSchema(GetSchemaRequest $request, array $callOptions = []): Schema + { + return $this->startApiCall('GetSchema', $request, $callOptions)->wait(); + } + + /** + * Gets a list of [Schema][google.cloud.discoveryengine.v1beta.Schema]s. + * + * The async variant is {@see SchemaServiceClient::listSchemasAsync()} . + * + * @example samples/V1beta/SchemaServiceClient/list_schemas.php + * + * @param ListSchemasRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listSchemas(ListSchemasRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSchemas', $request, $callOptions); + } + + /** + * Updates a [Schema][google.cloud.discoveryengine.v1beta.Schema]. + * + * The async variant is {@see SchemaServiceClient::updateSchemaAsync()} . + * + * @example samples/V1beta/SchemaServiceClient/update_schema.php + * + * @param UpdateSchemaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function updateSchema(UpdateSchemaRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateSchema', $request, $callOptions)->wait(); + } } diff --git a/DiscoveryEngine/src/V1beta/Client/SearchServiceClient.php b/DiscoveryEngine/src/V1beta/Client/SearchServiceClient.php index c34c2ee6ce98..dc9ed6e40ea0 100644 --- a/DiscoveryEngine/src/V1beta/Client/SearchServiceClient.php +++ b/DiscoveryEngine/src/V1beta/Client/SearchServiceClient.php @@ -26,17 +26,347 @@ namespace Google\Cloud\DiscoveryEngine\V1beta\Client; -use Google\Cloud\DiscoveryEngine\V1beta\Client\BaseClient\SearchServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\DiscoveryEngine\V1beta\SearchRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for search. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface searchAsync(SearchRequest $request, array $optionalArgs = []) */ -final class SearchServiceClient extends SearchServiceBaseClient +final class SearchServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SearchServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.discoveryengine.v1beta.SearchService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'discoveryengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/search_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/search_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/search_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/search_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a branch + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * + * @return string The formatted branch resource. + * + * @experimental + */ + public static function branchName(string $project, string $location, string $dataStore, string $branch): string + { + return self::getPathTemplate('branch')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_branch resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $branch + * + * @return string The formatted project_location_collection_data_store_branch resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreBranchName(string $project, string $location, string $collection, string $dataStore, string $branch): string + { + return self::getPathTemplate('projectLocationCollectionDataStoreBranch')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'branch' => $branch, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_serving_config resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $servingConfig + * + * @return string The formatted project_location_collection_data_store_serving_config resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreServingConfigName(string $project, string $location, string $collection, string $dataStore, string $servingConfig): string + { + return self::getPathTemplate('projectLocationCollectionDataStoreServingConfig')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'serving_config' => $servingConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_branch resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * + * @return string The formatted project_location_data_store_branch resource. + * + * @experimental + */ + public static function projectLocationDataStoreBranchName(string $project, string $location, string $dataStore, string $branch): string + { + return self::getPathTemplate('projectLocationDataStoreBranch')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_serving_config resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $servingConfig + * + * @return string The formatted project_location_data_store_serving_config resource. + * + * @experimental + */ + public static function projectLocationDataStoreServingConfigName(string $project, string $location, string $dataStore, string $servingConfig): string + { + return self::getPathTemplate('projectLocationDataStoreServingConfig')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'serving_config' => $servingConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * serving_config resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $servingConfig + * + * @return string The formatted serving_config resource. + * + * @experimental + */ + public static function servingConfigName(string $project, string $location, string $dataStore, string $servingConfig): string + { + return self::getPathTemplate('servingConfig')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'serving_config' => $servingConfig, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - branch: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch} + * - projectLocationCollectionDataStoreBranch: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch} + * - projectLocationCollectionDataStoreServingConfig: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/servingConfigs/{serving_config} + * - projectLocationDataStoreBranch: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch} + * - projectLocationDataStoreServingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} + * - servingConfig: projects/{project}/locations/{location}/dataStores/{data_store}/servingConfigs/{serving_config} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'discoveryengine.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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Performs a search. + * + * The async variant is {@see SearchServiceClient::searchAsync()} . + * + * @example samples/V1beta/SearchServiceClient/search.php + * + * @param SearchRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function search(SearchRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('Search', $request, $callOptions); + } } diff --git a/DiscoveryEngine/src/V1beta/Client/UserEventServiceClient.php b/DiscoveryEngine/src/V1beta/Client/UserEventServiceClient.php index 3f3791ebcd2d..e432d402616b 100644 --- a/DiscoveryEngine/src/V1beta/Client/UserEventServiceClient.php +++ b/DiscoveryEngine/src/V1beta/Client/UserEventServiceClient.php @@ -26,17 +26,457 @@ namespace Google\Cloud\DiscoveryEngine\V1beta\Client; -use Google\Cloud\DiscoveryEngine\V1beta\Client\BaseClient\UserEventServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Api\HttpBody; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\DiscoveryEngine\V1beta\CollectUserEventRequest; +use Google\Cloud\DiscoveryEngine\V1beta\ImportUserEventsRequest; +use Google\Cloud\DiscoveryEngine\V1beta\UserEvent; +use Google\Cloud\DiscoveryEngine\V1beta\WriteUserEventRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for ingesting end user actions on a website to Discovery Engine API. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface collectUserEventAsync(CollectUserEventRequest $request, array $optionalArgs = []) + * @method PromiseInterface importUserEventsAsync(ImportUserEventsRequest $request, array $optionalArgs = []) + * @method PromiseInterface writeUserEventAsync(WriteUserEventRequest $request, array $optionalArgs = []) */ -final class UserEventServiceClient extends UserEventServiceBaseClient +final class UserEventServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see UserEventServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.discoveryengine.v1beta.UserEventService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'discoveryengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/user_event_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/user_event_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/user_event_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/user_event_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + * + * @experimental + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + * + * @experimental + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a data_store + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted data_store resource. + * + * @experimental + */ + public static function dataStoreName(string $project, string $location, string $dataStore): string + { + return self::getPathTemplate('dataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a document + * resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted document resource. + * + * @experimental + */ + public static function documentName(string $project, string $location, string $dataStore, string $branch, string $document): string + { + return self::getPathTemplate('document')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * + * @return string The formatted project_location_collection_data_store resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreName(string $project, string $location, string $collection, string $dataStore): string + { + return self::getPathTemplate('projectLocationCollectionDataStore')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_collection_data_store_branch_document resource. + * + * @param string $project + * @param string $location + * @param string $collection + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted project_location_collection_data_store_branch_document resource. + * + * @experimental + */ + public static function projectLocationCollectionDataStoreBranchDocumentName(string $project, string $location, string $collection, string $dataStore, string $branch, string $document): string + { + return self::getPathTemplate('projectLocationCollectionDataStoreBranchDocument')->render([ + 'project' => $project, + 'location' => $location, + 'collection' => $collection, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * + * @return string The formatted project_location_data_store resource. + * + * @experimental + */ + public static function projectLocationDataStoreName(string $project, string $location, string $dataStore): string + { + return self::getPathTemplate('projectLocationDataStore')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_data_store_branch_document resource. + * + * @param string $project + * @param string $location + * @param string $dataStore + * @param string $branch + * @param string $document + * + * @return string The formatted project_location_data_store_branch_document resource. + * + * @experimental + */ + public static function projectLocationDataStoreBranchDocumentName(string $project, string $location, string $dataStore, string $branch, string $document): string + { + return self::getPathTemplate('projectLocationDataStoreBranchDocument')->render([ + 'project' => $project, + 'location' => $location, + 'data_store' => $dataStore, + 'branch' => $branch, + 'document' => $document, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - dataStore: projects/{project}/locations/{location}/dataStores/{data_store} + * - document: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} + * - projectLocationCollectionDataStore: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store} + * - projectLocationCollectionDataStoreBranchDocument: projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document} + * - projectLocationDataStore: projects/{project}/locations/{location}/dataStores/{data_store} + * - projectLocationDataStoreBranchDocument: projects/{project}/locations/{location}/dataStores/{data_store}/branches/{branch}/documents/{document} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'discoveryengine.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); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Writes a single user event from the browser. This uses a GET request to + * due to browser restriction of POST-ing to a third-party domain. + * + * This method is used only by the Discovery Engine API JavaScript pixel and + * Google Tag Manager. Users should not call this method directly. + * + * The async variant is {@see UserEventServiceClient::collectUserEventAsync()} . + * + * @example samples/V1beta/UserEventServiceClient/collect_user_event.php + * + * @param CollectUserEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 HttpBody + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function collectUserEvent(CollectUserEventRequest $request, array $callOptions = []): HttpBody + { + return $this->startApiCall('CollectUserEvent', $request, $callOptions)->wait(); + } + + /** + * Bulk import of User events. Request processing might be + * synchronous. Events that already exist are skipped. + * Use this method for backfilling historical user events. + * + * Operation.response is of type ImportResponse. Note that it is + * possible for a subset of the items to be successfully inserted. + * Operation.metadata is of type ImportMetadata. + * + * The async variant is {@see UserEventServiceClient::importUserEventsAsync()} . + * + * @example samples/V1beta/UserEventServiceClient/import_user_events.php + * + * @param ImportUserEventsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function importUserEvents(ImportUserEventsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportUserEvents', $request, $callOptions)->wait(); + } + + /** + * Writes a single user event. + * + * The async variant is {@see UserEventServiceClient::writeUserEventAsync()} . + * + * @example samples/V1beta/UserEventServiceClient/write_user_event.php + * + * @param WriteUserEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 UserEvent + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function writeUserEvent(WriteUserEventRequest $request, array $callOptions = []): UserEvent + { + return $this->startApiCall('WriteUserEvent', $request, $callOptions)->wait(); + } } diff --git a/Dlp/composer.json b/Dlp/composer.json index 12d9d349cc1b..df60aaa79809 100644 --- a/Dlp/composer.json +++ b/Dlp/composer.json @@ -5,11 +5,11 @@ "minimum-stability": "stable", "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", - "google/cloud-core": "^1.39" + "google/cloud-core": "^1.52.7" }, "suggest": { "ext-protobuf": "Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions." diff --git a/Dlp/src/V2/Client/BaseClient/DlpServiceBaseClient.php b/Dlp/src/V2/Client/BaseClient/DlpServiceBaseClient.php deleted file mode 100644 index 501168278e3e..000000000000 --- a/Dlp/src/V2/Client/BaseClient/DlpServiceBaseClient.php +++ /dev/null @@ -1,1625 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/dlp_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/dlp_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/dlp_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/dlp_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * deidentify_template resource. - * - * @param string $organization - * @param string $deidentifyTemplate - * - * @return string The formatted deidentify_template resource. - */ - public static function deidentifyTemplateName(string $organization, string $deidentifyTemplate): string - { - return self::getPathTemplate('deidentifyTemplate')->render([ - 'organization' => $organization, - 'deidentify_template' => $deidentifyTemplate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a dlp_job - * resource. - * - * @param string $project - * @param string $dlpJob - * - * @return string The formatted dlp_job resource. - */ - public static function dlpJobName(string $project, string $dlpJob): string - { - return self::getPathTemplate('dlpJob')->render([ - 'project' => $project, - 'dlp_job' => $dlpJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * inspect_template resource. - * - * @param string $organization - * @param string $inspectTemplate - * - * @return string The formatted inspect_template resource. - */ - public static function inspectTemplateName(string $organization, string $inspectTemplate): string - { - return self::getPathTemplate('inspectTemplate')->render([ - 'organization' => $organization, - 'inspect_template' => $inspectTemplate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a job_trigger - * resource. - * - * @param string $project - * @param string $jobTrigger - * - * @return string The formatted job_trigger resource. - */ - public static function jobTriggerName(string $project, string $jobTrigger): string - { - return self::getPathTemplate('jobTrigger')->render([ - 'project' => $project, - 'job_trigger' => $jobTrigger, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * 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(string $organization): string - { - return self::getPathTemplate('organization')->render([ - 'organization' => $organization, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_deidentify_template resource. - * - * @param string $organization - * @param string $deidentifyTemplate - * - * @return string The formatted organization_deidentify_template resource. - */ - public static function organizationDeidentifyTemplateName(string $organization, string $deidentifyTemplate): string - { - return self::getPathTemplate('organizationDeidentifyTemplate')->render([ - 'organization' => $organization, - 'deidentify_template' => $deidentifyTemplate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_inspect_template resource. - * - * @param string $organization - * @param string $inspectTemplate - * - * @return string The formatted organization_inspect_template resource. - */ - public static function organizationInspectTemplateName(string $organization, string $inspectTemplate): string - { - return self::getPathTemplate('organizationInspectTemplate')->render([ - 'organization' => $organization, - 'inspect_template' => $inspectTemplate, - ]); - } - - /** - * 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(string $organization, string $location): string - { - return self::getPathTemplate('organizationLocation')->render([ - 'organization' => $organization, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_location_deidentify_template resource. - * - * @param string $organization - * @param string $location - * @param string $deidentifyTemplate - * - * @return string The formatted organization_location_deidentify_template resource. - */ - public static function organizationLocationDeidentifyTemplateName(string $organization, string $location, string $deidentifyTemplate): string - { - return self::getPathTemplate('organizationLocationDeidentifyTemplate')->render([ - 'organization' => $organization, - 'location' => $location, - 'deidentify_template' => $deidentifyTemplate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_location_inspect_template resource. - * - * @param string $organization - * @param string $location - * @param string $inspectTemplate - * - * @return string The formatted organization_location_inspect_template resource. - */ - public static function organizationLocationInspectTemplateName(string $organization, string $location, string $inspectTemplate): string - { - return self::getPathTemplate('organizationLocationInspectTemplate')->render([ - 'organization' => $organization, - 'location' => $location, - 'inspect_template' => $inspectTemplate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_location_stored_info_type resource. - * - * @param string $organization - * @param string $location - * @param string $storedInfoType - * - * @return string The formatted organization_location_stored_info_type resource. - */ - public static function organizationLocationStoredInfoTypeName(string $organization, string $location, string $storedInfoType): string - { - return self::getPathTemplate('organizationLocationStoredInfoType')->render([ - 'organization' => $organization, - 'location' => $location, - 'stored_info_type' => $storedInfoType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_stored_info_type resource. - * - * @param string $organization - * @param string $storedInfoType - * - * @return string The formatted organization_stored_info_type resource. - */ - public static function organizationStoredInfoTypeName(string $organization, string $storedInfoType): string - { - return self::getPathTemplate('organizationStoredInfoType')->render([ - 'organization' => $organization, - 'stored_info_type' => $storedInfoType, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_deidentify_template resource. - * - * @param string $project - * @param string $deidentifyTemplate - * - * @return string The formatted project_deidentify_template resource. - */ - public static function projectDeidentifyTemplateName(string $project, string $deidentifyTemplate): string - { - return self::getPathTemplate('projectDeidentifyTemplate')->render([ - 'project' => $project, - 'deidentify_template' => $deidentifyTemplate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_dlp_job resource. - * - * @param string $project - * @param string $dlpJob - * - * @return string The formatted project_dlp_job resource. - */ - public static function projectDlpJobName(string $project, string $dlpJob): string - { - return self::getPathTemplate('projectDlpJob')->render([ - 'project' => $project, - 'dlp_job' => $dlpJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_inspect_template resource. - * - * @param string $project - * @param string $inspectTemplate - * - * @return string The formatted project_inspect_template resource. - */ - public static function projectInspectTemplateName(string $project, string $inspectTemplate): string - { - return self::getPathTemplate('projectInspectTemplate')->render([ - 'project' => $project, - 'inspect_template' => $inspectTemplate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_job_trigger resource. - * - * @param string $project - * @param string $jobTrigger - * - * @return string The formatted project_job_trigger resource. - */ - public static function projectJobTriggerName(string $project, string $jobTrigger): string - { - return self::getPathTemplate('projectJobTrigger')->render([ - 'project' => $project, - 'job_trigger' => $jobTrigger, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_deidentify_template resource. - * - * @param string $project - * @param string $location - * @param string $deidentifyTemplate - * - * @return string The formatted project_location_deidentify_template resource. - */ - public static function projectLocationDeidentifyTemplateName(string $project, string $location, string $deidentifyTemplate): string - { - return self::getPathTemplate('projectLocationDeidentifyTemplate')->render([ - 'project' => $project, - 'location' => $location, - 'deidentify_template' => $deidentifyTemplate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_dlp_job resource. - * - * @param string $project - * @param string $location - * @param string $dlpJob - * - * @return string The formatted project_location_dlp_job resource. - */ - public static function projectLocationDlpJobName(string $project, string $location, string $dlpJob): string - { - return self::getPathTemplate('projectLocationDlpJob')->render([ - 'project' => $project, - 'location' => $location, - 'dlp_job' => $dlpJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_inspect_template resource. - * - * @param string $project - * @param string $location - * @param string $inspectTemplate - * - * @return string The formatted project_location_inspect_template resource. - */ - public static function projectLocationInspectTemplateName(string $project, string $location, string $inspectTemplate): string - { - return self::getPathTemplate('projectLocationInspectTemplate')->render([ - 'project' => $project, - 'location' => $location, - 'inspect_template' => $inspectTemplate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_job_trigger resource. - * - * @param string $project - * @param string $location - * @param string $jobTrigger - * - * @return string The formatted project_location_job_trigger resource. - */ - public static function projectLocationJobTriggerName(string $project, string $location, string $jobTrigger): string - { - return self::getPathTemplate('projectLocationJobTrigger')->render([ - 'project' => $project, - 'location' => $location, - 'job_trigger' => $jobTrigger, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_stored_info_type resource. - * - * @param string $project - * @param string $location - * @param string $storedInfoType - * - * @return string The formatted project_location_stored_info_type resource. - */ - public static function projectLocationStoredInfoTypeName(string $project, string $location, string $storedInfoType): string - { - return self::getPathTemplate('projectLocationStoredInfoType')->render([ - 'project' => $project, - 'location' => $location, - 'stored_info_type' => $storedInfoType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_stored_info_type resource. - * - * @param string $project - * @param string $storedInfoType - * - * @return string The formatted project_stored_info_type resource. - */ - public static function projectStoredInfoTypeName(string $project, string $storedInfoType): string - { - return self::getPathTemplate('projectStoredInfoType')->render([ - 'project' => $project, - 'stored_info_type' => $storedInfoType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * stored_info_type resource. - * - * @param string $organization - * @param string $storedInfoType - * - * @return string The formatted stored_info_type resource. - */ - public static function storedInfoTypeName(string $organization, string $storedInfoType): string - { - return self::getPathTemplate('storedInfoType')->render([ - 'organization' => $organization, - 'stored_info_type' => $storedInfoType, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - deidentifyTemplate: organizations/{organization}/deidentifyTemplates/{deidentify_template} - * - dlpJob: projects/{project}/dlpJobs/{dlp_job} - * - inspectTemplate: organizations/{organization}/inspectTemplates/{inspect_template} - * - jobTrigger: projects/{project}/jobTriggers/{job_trigger} - * - location: projects/{project}/locations/{location} - * - organization: organizations/{organization} - * - organizationDeidentifyTemplate: organizations/{organization}/deidentifyTemplates/{deidentify_template} - * - organizationInspectTemplate: organizations/{organization}/inspectTemplates/{inspect_template} - * - organizationLocation: organizations/{organization}/locations/{location} - * - organizationLocationDeidentifyTemplate: organizations/{organization}/locations/{location}/deidentifyTemplates/{deidentify_template} - * - organizationLocationInspectTemplate: organizations/{organization}/locations/{location}/inspectTemplates/{inspect_template} - * - organizationLocationStoredInfoType: organizations/{organization}/locations/{location}/storedInfoTypes/{stored_info_type} - * - organizationStoredInfoType: organizations/{organization}/storedInfoTypes/{stored_info_type} - * - project: projects/{project} - * - projectDeidentifyTemplate: projects/{project}/deidentifyTemplates/{deidentify_template} - * - projectDlpJob: projects/{project}/dlpJobs/{dlp_job} - * - projectInspectTemplate: projects/{project}/inspectTemplates/{inspect_template} - * - projectJobTrigger: projects/{project}/jobTriggers/{job_trigger} - * - projectLocationDeidentifyTemplate: projects/{project}/locations/{location}/deidentifyTemplates/{deidentify_template} - * - projectLocationDlpJob: projects/{project}/locations/{location}/dlpJobs/{dlp_job} - * - projectLocationInspectTemplate: projects/{project}/locations/{location}/inspectTemplates/{inspect_template} - * - projectLocationJobTrigger: projects/{project}/locations/{location}/jobTriggers/{job_trigger} - * - projectLocationStoredInfoType: projects/{project}/locations/{location}/storedInfoTypes/{stored_info_type} - * - projectStoredInfoType: projects/{project}/storedInfoTypes/{stored_info_type} - * - storedInfoType: organizations/{organization}/storedInfoTypes/{stored_info_type} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'dlp.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Activate a job trigger. Causes the immediate execute of a trigger - * instead of waiting on the trigger event to occur. - * - * The async variant is {@see self::activateJobTriggerAsync()} . - * - * @param ActivateJobTriggerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DlpJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function activateJobTrigger(ActivateJobTriggerRequest $request, array $callOptions = []): DlpJob - { - return $this->startApiCall('ActivateJobTrigger', $request, $callOptions)->wait(); - } - - /** - * Starts asynchronous cancellation on a long-running DlpJob. The server - * makes a best effort to cancel the DlpJob, but success is not - * guaranteed. - * See https://cloud.google.com/dlp/docs/inspecting-storage and - * https://cloud.google.com/dlp/docs/compute-risk-analysis to learn more. - * - * The async variant is {@see self::cancelDlpJobAsync()} . - * - * @param CancelDlpJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function cancelDlpJob(CancelDlpJobRequest $request, array $callOptions = []): void - { - $this->startApiCall('CancelDlpJob', $request, $callOptions)->wait(); - } - - /** - * Creates a DeidentifyTemplate for reusing frequently used configuration - * for de-identifying content, images, and storage. - * See https://cloud.google.com/dlp/docs/creating-templates-deid to learn - * more. - * - * The async variant is {@see self::createDeidentifyTemplateAsync()} . - * - * @param CreateDeidentifyTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DeidentifyTemplate - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDeidentifyTemplate(CreateDeidentifyTemplateRequest $request, array $callOptions = []): DeidentifyTemplate - { - return $this->startApiCall('CreateDeidentifyTemplate', $request, $callOptions)->wait(); - } - - /** - * Creates a new job to inspect storage or calculate risk metrics. - * See https://cloud.google.com/dlp/docs/inspecting-storage and - * https://cloud.google.com/dlp/docs/compute-risk-analysis to learn more. - * - * When no InfoTypes or CustomInfoTypes are specified in inspect jobs, the - * system will automatically choose what detectors to run. By default this may - * be all types, but may change over time as detectors are updated. - * - * The async variant is {@see self::createDlpJobAsync()} . - * - * @param CreateDlpJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DlpJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDlpJob(CreateDlpJobRequest $request, array $callOptions = []): DlpJob - { - return $this->startApiCall('CreateDlpJob', $request, $callOptions)->wait(); - } - - /** - * Creates an InspectTemplate for reusing frequently used configuration - * for inspecting content, images, and storage. - * See https://cloud.google.com/dlp/docs/creating-templates to learn more. - * - * The async variant is {@see self::createInspectTemplateAsync()} . - * - * @param CreateInspectTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InspectTemplate - * - * @throws ApiException Thrown if the API call fails. - */ - public function createInspectTemplate(CreateInspectTemplateRequest $request, array $callOptions = []): InspectTemplate - { - return $this->startApiCall('CreateInspectTemplate', $request, $callOptions)->wait(); - } - - /** - * Creates a job trigger to run DLP actions such as scanning storage for - * sensitive information on a set schedule. - * See https://cloud.google.com/dlp/docs/creating-job-triggers to learn more. - * - * The async variant is {@see self::createJobTriggerAsync()} . - * - * @param CreateJobTriggerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 JobTrigger - * - * @throws ApiException Thrown if the API call fails. - */ - public function createJobTrigger(CreateJobTriggerRequest $request, array $callOptions = []): JobTrigger - { - return $this->startApiCall('CreateJobTrigger', $request, $callOptions)->wait(); - } - - /** - * Creates a pre-built stored infoType to be used for inspection. - * See https://cloud.google.com/dlp/docs/creating-stored-infotypes to - * learn more. - * - * The async variant is {@see self::createStoredInfoTypeAsync()} . - * - * @param CreateStoredInfoTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 StoredInfoType - * - * @throws ApiException Thrown if the API call fails. - */ - public function createStoredInfoType(CreateStoredInfoTypeRequest $request, array $callOptions = []): StoredInfoType - { - return $this->startApiCall('CreateStoredInfoType', $request, $callOptions)->wait(); - } - - /** - * De-identifies potentially sensitive info from a ContentItem. - * This method has limits on input size and output size. - * See https://cloud.google.com/dlp/docs/deidentify-sensitive-data to - * learn more. - * - * When no InfoTypes or CustomInfoTypes are specified in this request, the - * system will automatically choose what detectors to run. By default this may - * be all types, but may change over time as detectors are updated. - * - * The async variant is {@see self::deidentifyContentAsync()} . - * - * @param DeidentifyContentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DeidentifyContentResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deidentifyContent(DeidentifyContentRequest $request, array $callOptions = []): DeidentifyContentResponse - { - return $this->startApiCall('DeidentifyContent', $request, $callOptions)->wait(); - } - - /** - * Deletes a DeidentifyTemplate. - * See https://cloud.google.com/dlp/docs/creating-templates-deid to learn - * more. - * - * The async variant is {@see self::deleteDeidentifyTemplateAsync()} . - * - * @param DeleteDeidentifyTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDeidentifyTemplate(DeleteDeidentifyTemplateRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteDeidentifyTemplate', $request, $callOptions)->wait(); - } - - /** - * Deletes a long-running DlpJob. This method indicates that the client is - * no longer interested in the DlpJob result. The job will be canceled if - * possible. - * See https://cloud.google.com/dlp/docs/inspecting-storage and - * https://cloud.google.com/dlp/docs/compute-risk-analysis to learn more. - * - * The async variant is {@see self::deleteDlpJobAsync()} . - * - * @param DeleteDlpJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDlpJob(DeleteDlpJobRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteDlpJob', $request, $callOptions)->wait(); - } - - /** - * Deletes an InspectTemplate. - * See https://cloud.google.com/dlp/docs/creating-templates to learn more. - * - * The async variant is {@see self::deleteInspectTemplateAsync()} . - * - * @param DeleteInspectTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteInspectTemplate(DeleteInspectTemplateRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteInspectTemplate', $request, $callOptions)->wait(); - } - - /** - * Deletes a job trigger. - * See https://cloud.google.com/dlp/docs/creating-job-triggers to learn more. - * - * The async variant is {@see self::deleteJobTriggerAsync()} . - * - * @param DeleteJobTriggerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteJobTrigger(DeleteJobTriggerRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteJobTrigger', $request, $callOptions)->wait(); - } - - /** - * Deletes a stored infoType. - * See https://cloud.google.com/dlp/docs/creating-stored-infotypes to - * learn more. - * - * The async variant is {@see self::deleteStoredInfoTypeAsync()} . - * - * @param DeleteStoredInfoTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteStoredInfoType(DeleteStoredInfoTypeRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteStoredInfoType', $request, $callOptions)->wait(); - } - - /** - * Finish a running hybrid DlpJob. Triggers the finalization steps and running - * of any enabled actions that have not yet run. - * - * The async variant is {@see self::finishDlpJobAsync()} . - * - * @param FinishDlpJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function finishDlpJob(FinishDlpJobRequest $request, array $callOptions = []): void - { - $this->startApiCall('FinishDlpJob', $request, $callOptions)->wait(); - } - - /** - * Gets a DeidentifyTemplate. - * See https://cloud.google.com/dlp/docs/creating-templates-deid to learn - * more. - * - * The async variant is {@see self::getDeidentifyTemplateAsync()} . - * - * @param GetDeidentifyTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DeidentifyTemplate - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDeidentifyTemplate(GetDeidentifyTemplateRequest $request, array $callOptions = []): DeidentifyTemplate - { - return $this->startApiCall('GetDeidentifyTemplate', $request, $callOptions)->wait(); - } - - /** - * Gets the latest state of a long-running DlpJob. - * See https://cloud.google.com/dlp/docs/inspecting-storage and - * https://cloud.google.com/dlp/docs/compute-risk-analysis to learn more. - * - * The async variant is {@see self::getDlpJobAsync()} . - * - * @param GetDlpJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DlpJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDlpJob(GetDlpJobRequest $request, array $callOptions = []): DlpJob - { - return $this->startApiCall('GetDlpJob', $request, $callOptions)->wait(); - } - - /** - * Gets an InspectTemplate. - * See https://cloud.google.com/dlp/docs/creating-templates to learn more. - * - * The async variant is {@see self::getInspectTemplateAsync()} . - * - * @param GetInspectTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InspectTemplate - * - * @throws ApiException Thrown if the API call fails. - */ - public function getInspectTemplate(GetInspectTemplateRequest $request, array $callOptions = []): InspectTemplate - { - return $this->startApiCall('GetInspectTemplate', $request, $callOptions)->wait(); - } - - /** - * Gets a job trigger. - * See https://cloud.google.com/dlp/docs/creating-job-triggers to learn more. - * - * The async variant is {@see self::getJobTriggerAsync()} . - * - * @param GetJobTriggerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 JobTrigger - * - * @throws ApiException Thrown if the API call fails. - */ - public function getJobTrigger(GetJobTriggerRequest $request, array $callOptions = []): JobTrigger - { - return $this->startApiCall('GetJobTrigger', $request, $callOptions)->wait(); - } - - /** - * Gets a stored infoType. - * See https://cloud.google.com/dlp/docs/creating-stored-infotypes to - * learn more. - * - * The async variant is {@see self::getStoredInfoTypeAsync()} . - * - * @param GetStoredInfoTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 StoredInfoType - * - * @throws ApiException Thrown if the API call fails. - */ - public function getStoredInfoType(GetStoredInfoTypeRequest $request, array $callOptions = []): StoredInfoType - { - return $this->startApiCall('GetStoredInfoType', $request, $callOptions)->wait(); - } - - /** - * Inspect hybrid content and store findings to a job. - * To review the findings, inspect the job. Inspection will occur - * asynchronously. - * - * The async variant is {@see self::hybridInspectDlpJobAsync()} . - * - * @param HybridInspectDlpJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 HybridInspectResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function hybridInspectDlpJob(HybridInspectDlpJobRequest $request, array $callOptions = []): HybridInspectResponse - { - return $this->startApiCall('HybridInspectDlpJob', $request, $callOptions)->wait(); - } - - /** - * Inspect hybrid content and store findings to a trigger. The inspection - * will be processed asynchronously. To review the findings monitor the - * jobs within the trigger. - * - * The async variant is {@see self::hybridInspectJobTriggerAsync()} . - * - * @param HybridInspectJobTriggerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 HybridInspectResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function hybridInspectJobTrigger(HybridInspectJobTriggerRequest $request, array $callOptions = []): HybridInspectResponse - { - return $this->startApiCall('HybridInspectJobTrigger', $request, $callOptions)->wait(); - } - - /** - * Finds potentially sensitive info in content. - * This method has limits on input size, processing time, and output size. - * - * When no InfoTypes or CustomInfoTypes are specified in this request, the - * system will automatically choose what detectors to run. By default this may - * be all types, but may change over time as detectors are updated. - * - * For how to guides, see https://cloud.google.com/dlp/docs/inspecting-images - * and https://cloud.google.com/dlp/docs/inspecting-text, - * - * The async variant is {@see self::inspectContentAsync()} . - * - * @param InspectContentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InspectContentResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function inspectContent(InspectContentRequest $request, array $callOptions = []): InspectContentResponse - { - return $this->startApiCall('InspectContent', $request, $callOptions)->wait(); - } - - /** - * Lists DeidentifyTemplates. - * See https://cloud.google.com/dlp/docs/creating-templates-deid to learn - * more. - * - * The async variant is {@see self::listDeidentifyTemplatesAsync()} . - * - * @param ListDeidentifyTemplatesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDeidentifyTemplates(ListDeidentifyTemplatesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDeidentifyTemplates', $request, $callOptions); - } - - /** - * Lists DlpJobs that match the specified filter in the request. - * See https://cloud.google.com/dlp/docs/inspecting-storage and - * https://cloud.google.com/dlp/docs/compute-risk-analysis to learn more. - * - * The async variant is {@see self::listDlpJobsAsync()} . - * - * @param ListDlpJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDlpJobs(ListDlpJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDlpJobs', $request, $callOptions); - } - - /** - * Returns a list of the sensitive information types that DLP API - * supports. See https://cloud.google.com/dlp/docs/infotypes-reference to - * learn more. - * - * The async variant is {@see self::listInfoTypesAsync()} . - * - * @param ListInfoTypesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ListInfoTypesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listInfoTypes(ListInfoTypesRequest $request, array $callOptions = []): ListInfoTypesResponse - { - return $this->startApiCall('ListInfoTypes', $request, $callOptions)->wait(); - } - - /** - * Lists InspectTemplates. - * See https://cloud.google.com/dlp/docs/creating-templates to learn more. - * - * The async variant is {@see self::listInspectTemplatesAsync()} . - * - * @param ListInspectTemplatesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listInspectTemplates(ListInspectTemplatesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListInspectTemplates', $request, $callOptions); - } - - /** - * Lists job triggers. - * See https://cloud.google.com/dlp/docs/creating-job-triggers to learn more. - * - * The async variant is {@see self::listJobTriggersAsync()} . - * - * @param ListJobTriggersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listJobTriggers(ListJobTriggersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListJobTriggers', $request, $callOptions); - } - - /** - * Lists stored infoTypes. - * See https://cloud.google.com/dlp/docs/creating-stored-infotypes to - * learn more. - * - * The async variant is {@see self::listStoredInfoTypesAsync()} . - * - * @param ListStoredInfoTypesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listStoredInfoTypes(ListStoredInfoTypesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListStoredInfoTypes', $request, $callOptions); - } - - /** - * Redacts potentially sensitive info from an image. - * This method has limits on input size, processing time, and output size. - * See https://cloud.google.com/dlp/docs/redacting-sensitive-data-images to - * learn more. - * - * When no InfoTypes or CustomInfoTypes are specified in this request, the - * system will automatically choose what detectors to run. By default this may - * be all types, but may change over time as detectors are updated. - * - * The async variant is {@see self::redactImageAsync()} . - * - * @param RedactImageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RedactImageResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function redactImage(RedactImageRequest $request, array $callOptions = []): RedactImageResponse - { - return $this->startApiCall('RedactImage', $request, $callOptions)->wait(); - } - - /** - * Re-identifies content that has been de-identified. - * See - * https://cloud.google.com/dlp/docs/pseudonymization#re-identification_in_free_text_code_example - * to learn more. - * - * The async variant is {@see self::reidentifyContentAsync()} . - * - * @param ReidentifyContentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ReidentifyContentResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function reidentifyContent(ReidentifyContentRequest $request, array $callOptions = []): ReidentifyContentResponse - { - return $this->startApiCall('ReidentifyContent', $request, $callOptions)->wait(); - } - - /** - * Updates the DeidentifyTemplate. - * See https://cloud.google.com/dlp/docs/creating-templates-deid to learn - * more. - * - * The async variant is {@see self::updateDeidentifyTemplateAsync()} . - * - * @param UpdateDeidentifyTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DeidentifyTemplate - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDeidentifyTemplate(UpdateDeidentifyTemplateRequest $request, array $callOptions = []): DeidentifyTemplate - { - return $this->startApiCall('UpdateDeidentifyTemplate', $request, $callOptions)->wait(); - } - - /** - * Updates the InspectTemplate. - * See https://cloud.google.com/dlp/docs/creating-templates to learn more. - * - * The async variant is {@see self::updateInspectTemplateAsync()} . - * - * @param UpdateInspectTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InspectTemplate - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateInspectTemplate(UpdateInspectTemplateRequest $request, array $callOptions = []): InspectTemplate - { - return $this->startApiCall('UpdateInspectTemplate', $request, $callOptions)->wait(); - } - - /** - * Updates a job trigger. - * See https://cloud.google.com/dlp/docs/creating-job-triggers to learn more. - * - * The async variant is {@see self::updateJobTriggerAsync()} . - * - * @param UpdateJobTriggerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 JobTrigger - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateJobTrigger(UpdateJobTriggerRequest $request, array $callOptions = []): JobTrigger - { - return $this->startApiCall('UpdateJobTrigger', $request, $callOptions)->wait(); - } - - /** - * Updates the stored infoType by creating a new version. The existing version - * will continue to be used until the new version is ready. - * See https://cloud.google.com/dlp/docs/creating-stored-infotypes to - * learn more. - * - * The async variant is {@see self::updateStoredInfoTypeAsync()} . - * - * @param UpdateStoredInfoTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 StoredInfoType - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateStoredInfoType(UpdateStoredInfoTypeRequest $request, array $callOptions = []): StoredInfoType - { - return $this->startApiCall('UpdateStoredInfoType', $request, $callOptions)->wait(); - } -} diff --git a/Dlp/src/V2/Client/DlpServiceClient.php b/Dlp/src/V2/Client/DlpServiceClient.php index c5bd7f64182a..19671b49d2f6 100644 --- a/Dlp/src/V2/Client/DlpServiceClient.php +++ b/Dlp/src/V2/Client/DlpServiceClient.php @@ -24,15 +24,1600 @@ namespace Google\Cloud\Dlp\V2\Client; -use Google\Cloud\Dlp\V2\Client\BaseClient\DlpServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Dlp\V2\ActivateJobTriggerRequest; +use Google\Cloud\Dlp\V2\CancelDlpJobRequest; +use Google\Cloud\Dlp\V2\CreateDeidentifyTemplateRequest; +use Google\Cloud\Dlp\V2\CreateDlpJobRequest; +use Google\Cloud\Dlp\V2\CreateInspectTemplateRequest; +use Google\Cloud\Dlp\V2\CreateJobTriggerRequest; +use Google\Cloud\Dlp\V2\CreateStoredInfoTypeRequest; +use Google\Cloud\Dlp\V2\DeidentifyContentRequest; +use Google\Cloud\Dlp\V2\DeidentifyContentResponse; +use Google\Cloud\Dlp\V2\DeidentifyTemplate; +use Google\Cloud\Dlp\V2\DeleteDeidentifyTemplateRequest; +use Google\Cloud\Dlp\V2\DeleteDlpJobRequest; +use Google\Cloud\Dlp\V2\DeleteInspectTemplateRequest; +use Google\Cloud\Dlp\V2\DeleteJobTriggerRequest; +use Google\Cloud\Dlp\V2\DeleteStoredInfoTypeRequest; +use Google\Cloud\Dlp\V2\DlpJob; +use Google\Cloud\Dlp\V2\FinishDlpJobRequest; +use Google\Cloud\Dlp\V2\GetDeidentifyTemplateRequest; +use Google\Cloud\Dlp\V2\GetDlpJobRequest; +use Google\Cloud\Dlp\V2\GetInspectTemplateRequest; +use Google\Cloud\Dlp\V2\GetJobTriggerRequest; +use Google\Cloud\Dlp\V2\GetStoredInfoTypeRequest; +use Google\Cloud\Dlp\V2\HybridInspectDlpJobRequest; +use Google\Cloud\Dlp\V2\HybridInspectJobTriggerRequest; +use Google\Cloud\Dlp\V2\HybridInspectResponse; +use Google\Cloud\Dlp\V2\InspectContentRequest; +use Google\Cloud\Dlp\V2\InspectContentResponse; +use Google\Cloud\Dlp\V2\InspectTemplate; +use Google\Cloud\Dlp\V2\JobTrigger; +use Google\Cloud\Dlp\V2\ListDeidentifyTemplatesRequest; +use Google\Cloud\Dlp\V2\ListDlpJobsRequest; +use Google\Cloud\Dlp\V2\ListInfoTypesRequest; +use Google\Cloud\Dlp\V2\ListInfoTypesResponse; +use Google\Cloud\Dlp\V2\ListInspectTemplatesRequest; +use Google\Cloud\Dlp\V2\ListJobTriggersRequest; +use Google\Cloud\Dlp\V2\ListStoredInfoTypesRequest; +use Google\Cloud\Dlp\V2\RedactImageRequest; +use Google\Cloud\Dlp\V2\RedactImageResponse; +use Google\Cloud\Dlp\V2\ReidentifyContentRequest; +use Google\Cloud\Dlp\V2\ReidentifyContentResponse; +use Google\Cloud\Dlp\V2\StoredInfoType; +use Google\Cloud\Dlp\V2\UpdateDeidentifyTemplateRequest; +use Google\Cloud\Dlp\V2\UpdateInspectTemplateRequest; +use Google\Cloud\Dlp\V2\UpdateJobTriggerRequest; +use Google\Cloud\Dlp\V2\UpdateStoredInfoTypeRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Cloud Data Loss Prevention (DLP) API is a service that allows clients + * to detect the presence of Personally Identifiable Information (PII) and other + * privacy-sensitive data in user-supplied, unstructured data streams, like text + * blocks or images. + * The service also includes methods for sensitive data redaction and + * scheduling of data scans on Google Cloud Platform based data sets. * - * This class is currently experimental and may be subject to changes. + * To learn more about concepts and find how-to guides see + * https://cloud.google.com/dlp/docs/. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Dlp\V2\DlpServiceClient} for the stable implementation + * + * @method PromiseInterface activateJobTriggerAsync(ActivateJobTriggerRequest $request, array $optionalArgs = []) + * @method PromiseInterface cancelDlpJobAsync(CancelDlpJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface createDeidentifyTemplateAsync(CreateDeidentifyTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface createDlpJobAsync(CreateDlpJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface createInspectTemplateAsync(CreateInspectTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface createJobTriggerAsync(CreateJobTriggerRequest $request, array $optionalArgs = []) + * @method PromiseInterface createStoredInfoTypeAsync(CreateStoredInfoTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface deidentifyContentAsync(DeidentifyContentRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDeidentifyTemplateAsync(DeleteDeidentifyTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDlpJobAsync(DeleteDlpJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteInspectTemplateAsync(DeleteInspectTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteJobTriggerAsync(DeleteJobTriggerRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteStoredInfoTypeAsync(DeleteStoredInfoTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface finishDlpJobAsync(FinishDlpJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDeidentifyTemplateAsync(GetDeidentifyTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDlpJobAsync(GetDlpJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInspectTemplateAsync(GetInspectTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface getJobTriggerAsync(GetJobTriggerRequest $request, array $optionalArgs = []) + * @method PromiseInterface getStoredInfoTypeAsync(GetStoredInfoTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface hybridInspectDlpJobAsync(HybridInspectDlpJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface hybridInspectJobTriggerAsync(HybridInspectJobTriggerRequest $request, array $optionalArgs = []) + * @method PromiseInterface inspectContentAsync(InspectContentRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDeidentifyTemplatesAsync(ListDeidentifyTemplatesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDlpJobsAsync(ListDlpJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInfoTypesAsync(ListInfoTypesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInspectTemplatesAsync(ListInspectTemplatesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listJobTriggersAsync(ListJobTriggersRequest $request, array $optionalArgs = []) + * @method PromiseInterface listStoredInfoTypesAsync(ListStoredInfoTypesRequest $request, array $optionalArgs = []) + * @method PromiseInterface redactImageAsync(RedactImageRequest $request, array $optionalArgs = []) + * @method PromiseInterface reidentifyContentAsync(ReidentifyContentRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDeidentifyTemplateAsync(UpdateDeidentifyTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateInspectTemplateAsync(UpdateInspectTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateJobTriggerAsync(UpdateJobTriggerRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateStoredInfoTypeAsync(UpdateStoredInfoTypeRequest $request, array $optionalArgs = []) */ -class DlpServiceClient extends DlpServiceBaseClient +class DlpServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DlpServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.privacy.dlp.v2.DlpService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'dlp.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/dlp_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/dlp_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/dlp_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/dlp_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * deidentify_template resource. + * + * @param string $organization + * @param string $deidentifyTemplate + * + * @return string The formatted deidentify_template resource. + */ + public static function deidentifyTemplateName(string $organization, string $deidentifyTemplate): string + { + return self::getPathTemplate('deidentifyTemplate')->render([ + 'organization' => $organization, + 'deidentify_template' => $deidentifyTemplate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a dlp_job + * resource. + * + * @param string $project + * @param string $dlpJob + * + * @return string The formatted dlp_job resource. + */ + public static function dlpJobName(string $project, string $dlpJob): string + { + return self::getPathTemplate('dlpJob')->render([ + 'project' => $project, + 'dlp_job' => $dlpJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * inspect_template resource. + * + * @param string $organization + * @param string $inspectTemplate + * + * @return string The formatted inspect_template resource. + */ + public static function inspectTemplateName(string $organization, string $inspectTemplate): string + { + return self::getPathTemplate('inspectTemplate')->render([ + 'organization' => $organization, + 'inspect_template' => $inspectTemplate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a job_trigger + * resource. + * + * @param string $project + * @param string $jobTrigger + * + * @return string The formatted job_trigger resource. + */ + public static function jobTriggerName(string $project, string $jobTrigger): string + { + return self::getPathTemplate('jobTrigger')->render([ + 'project' => $project, + 'job_trigger' => $jobTrigger, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * 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(string $organization): string + { + return self::getPathTemplate('organization')->render([ + 'organization' => $organization, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_deidentify_template resource. + * + * @param string $organization + * @param string $deidentifyTemplate + * + * @return string The formatted organization_deidentify_template resource. + */ + public static function organizationDeidentifyTemplateName(string $organization, string $deidentifyTemplate): string + { + return self::getPathTemplate('organizationDeidentifyTemplate')->render([ + 'organization' => $organization, + 'deidentify_template' => $deidentifyTemplate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_inspect_template resource. + * + * @param string $organization + * @param string $inspectTemplate + * + * @return string The formatted organization_inspect_template resource. + */ + public static function organizationInspectTemplateName(string $organization, string $inspectTemplate): string + { + return self::getPathTemplate('organizationInspectTemplate')->render([ + 'organization' => $organization, + 'inspect_template' => $inspectTemplate, + ]); + } + + /** + * 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(string $organization, string $location): string + { + return self::getPathTemplate('organizationLocation')->render([ + 'organization' => $organization, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_location_deidentify_template resource. + * + * @param string $organization + * @param string $location + * @param string $deidentifyTemplate + * + * @return string The formatted organization_location_deidentify_template resource. + */ + public static function organizationLocationDeidentifyTemplateName(string $organization, string $location, string $deidentifyTemplate): string + { + return self::getPathTemplate('organizationLocationDeidentifyTemplate')->render([ + 'organization' => $organization, + 'location' => $location, + 'deidentify_template' => $deidentifyTemplate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_location_inspect_template resource. + * + * @param string $organization + * @param string $location + * @param string $inspectTemplate + * + * @return string The formatted organization_location_inspect_template resource. + */ + public static function organizationLocationInspectTemplateName(string $organization, string $location, string $inspectTemplate): string + { + return self::getPathTemplate('organizationLocationInspectTemplate')->render([ + 'organization' => $organization, + 'location' => $location, + 'inspect_template' => $inspectTemplate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_location_stored_info_type resource. + * + * @param string $organization + * @param string $location + * @param string $storedInfoType + * + * @return string The formatted organization_location_stored_info_type resource. + */ + public static function organizationLocationStoredInfoTypeName(string $organization, string $location, string $storedInfoType): string + { + return self::getPathTemplate('organizationLocationStoredInfoType')->render([ + 'organization' => $organization, + 'location' => $location, + 'stored_info_type' => $storedInfoType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_stored_info_type resource. + * + * @param string $organization + * @param string $storedInfoType + * + * @return string The formatted organization_stored_info_type resource. + */ + public static function organizationStoredInfoTypeName(string $organization, string $storedInfoType): string + { + return self::getPathTemplate('organizationStoredInfoType')->render([ + 'organization' => $organization, + 'stored_info_type' => $storedInfoType, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_deidentify_template resource. + * + * @param string $project + * @param string $deidentifyTemplate + * + * @return string The formatted project_deidentify_template resource. + */ + public static function projectDeidentifyTemplateName(string $project, string $deidentifyTemplate): string + { + return self::getPathTemplate('projectDeidentifyTemplate')->render([ + 'project' => $project, + 'deidentify_template' => $deidentifyTemplate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_dlp_job resource. + * + * @param string $project + * @param string $dlpJob + * + * @return string The formatted project_dlp_job resource. + */ + public static function projectDlpJobName(string $project, string $dlpJob): string + { + return self::getPathTemplate('projectDlpJob')->render([ + 'project' => $project, + 'dlp_job' => $dlpJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_inspect_template resource. + * + * @param string $project + * @param string $inspectTemplate + * + * @return string The formatted project_inspect_template resource. + */ + public static function projectInspectTemplateName(string $project, string $inspectTemplate): string + { + return self::getPathTemplate('projectInspectTemplate')->render([ + 'project' => $project, + 'inspect_template' => $inspectTemplate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_job_trigger resource. + * + * @param string $project + * @param string $jobTrigger + * + * @return string The formatted project_job_trigger resource. + */ + public static function projectJobTriggerName(string $project, string $jobTrigger): string + { + return self::getPathTemplate('projectJobTrigger')->render([ + 'project' => $project, + 'job_trigger' => $jobTrigger, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_deidentify_template resource. + * + * @param string $project + * @param string $location + * @param string $deidentifyTemplate + * + * @return string The formatted project_location_deidentify_template resource. + */ + public static function projectLocationDeidentifyTemplateName(string $project, string $location, string $deidentifyTemplate): string + { + return self::getPathTemplate('projectLocationDeidentifyTemplate')->render([ + 'project' => $project, + 'location' => $location, + 'deidentify_template' => $deidentifyTemplate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_dlp_job resource. + * + * @param string $project + * @param string $location + * @param string $dlpJob + * + * @return string The formatted project_location_dlp_job resource. + */ + public static function projectLocationDlpJobName(string $project, string $location, string $dlpJob): string + { + return self::getPathTemplate('projectLocationDlpJob')->render([ + 'project' => $project, + 'location' => $location, + 'dlp_job' => $dlpJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_inspect_template resource. + * + * @param string $project + * @param string $location + * @param string $inspectTemplate + * + * @return string The formatted project_location_inspect_template resource. + */ + public static function projectLocationInspectTemplateName(string $project, string $location, string $inspectTemplate): string + { + return self::getPathTemplate('projectLocationInspectTemplate')->render([ + 'project' => $project, + 'location' => $location, + 'inspect_template' => $inspectTemplate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_job_trigger resource. + * + * @param string $project + * @param string $location + * @param string $jobTrigger + * + * @return string The formatted project_location_job_trigger resource. + */ + public static function projectLocationJobTriggerName(string $project, string $location, string $jobTrigger): string + { + return self::getPathTemplate('projectLocationJobTrigger')->render([ + 'project' => $project, + 'location' => $location, + 'job_trigger' => $jobTrigger, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_stored_info_type resource. + * + * @param string $project + * @param string $location + * @param string $storedInfoType + * + * @return string The formatted project_location_stored_info_type resource. + */ + public static function projectLocationStoredInfoTypeName(string $project, string $location, string $storedInfoType): string + { + return self::getPathTemplate('projectLocationStoredInfoType')->render([ + 'project' => $project, + 'location' => $location, + 'stored_info_type' => $storedInfoType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_stored_info_type resource. + * + * @param string $project + * @param string $storedInfoType + * + * @return string The formatted project_stored_info_type resource. + */ + public static function projectStoredInfoTypeName(string $project, string $storedInfoType): string + { + return self::getPathTemplate('projectStoredInfoType')->render([ + 'project' => $project, + 'stored_info_type' => $storedInfoType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * stored_info_type resource. + * + * @param string $organization + * @param string $storedInfoType + * + * @return string The formatted stored_info_type resource. + */ + public static function storedInfoTypeName(string $organization, string $storedInfoType): string + { + return self::getPathTemplate('storedInfoType')->render([ + 'organization' => $organization, + 'stored_info_type' => $storedInfoType, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - deidentifyTemplate: organizations/{organization}/deidentifyTemplates/{deidentify_template} + * - dlpJob: projects/{project}/dlpJobs/{dlp_job} + * - inspectTemplate: organizations/{organization}/inspectTemplates/{inspect_template} + * - jobTrigger: projects/{project}/jobTriggers/{job_trigger} + * - location: projects/{project}/locations/{location} + * - organization: organizations/{organization} + * - organizationDeidentifyTemplate: organizations/{organization}/deidentifyTemplates/{deidentify_template} + * - organizationInspectTemplate: organizations/{organization}/inspectTemplates/{inspect_template} + * - organizationLocation: organizations/{organization}/locations/{location} + * - organizationLocationDeidentifyTemplate: organizations/{organization}/locations/{location}/deidentifyTemplates/{deidentify_template} + * - organizationLocationInspectTemplate: organizations/{organization}/locations/{location}/inspectTemplates/{inspect_template} + * - organizationLocationStoredInfoType: organizations/{organization}/locations/{location}/storedInfoTypes/{stored_info_type} + * - organizationStoredInfoType: organizations/{organization}/storedInfoTypes/{stored_info_type} + * - project: projects/{project} + * - projectDeidentifyTemplate: projects/{project}/deidentifyTemplates/{deidentify_template} + * - projectDlpJob: projects/{project}/dlpJobs/{dlp_job} + * - projectInspectTemplate: projects/{project}/inspectTemplates/{inspect_template} + * - projectJobTrigger: projects/{project}/jobTriggers/{job_trigger} + * - projectLocationDeidentifyTemplate: projects/{project}/locations/{location}/deidentifyTemplates/{deidentify_template} + * - projectLocationDlpJob: projects/{project}/locations/{location}/dlpJobs/{dlp_job} + * - projectLocationInspectTemplate: projects/{project}/locations/{location}/inspectTemplates/{inspect_template} + * - projectLocationJobTrigger: projects/{project}/locations/{location}/jobTriggers/{job_trigger} + * - projectLocationStoredInfoType: projects/{project}/locations/{location}/storedInfoTypes/{stored_info_type} + * - projectStoredInfoType: projects/{project}/storedInfoTypes/{stored_info_type} + * - storedInfoType: organizations/{organization}/storedInfoTypes/{stored_info_type} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'dlp.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Activate a job trigger. Causes the immediate execute of a trigger + * instead of waiting on the trigger event to occur. + * + * The async variant is {@see DlpServiceClient::activateJobTriggerAsync()} . + * + * @param ActivateJobTriggerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DlpJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function activateJobTrigger(ActivateJobTriggerRequest $request, array $callOptions = []): DlpJob + { + return $this->startApiCall('ActivateJobTrigger', $request, $callOptions)->wait(); + } + + /** + * Starts asynchronous cancellation on a long-running DlpJob. The server + * makes a best effort to cancel the DlpJob, but success is not + * guaranteed. + * See https://cloud.google.com/dlp/docs/inspecting-storage and + * https://cloud.google.com/dlp/docs/compute-risk-analysis to learn more. + * + * The async variant is {@see DlpServiceClient::cancelDlpJobAsync()} . + * + * @param CancelDlpJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function cancelDlpJob(CancelDlpJobRequest $request, array $callOptions = []): void + { + $this->startApiCall('CancelDlpJob', $request, $callOptions)->wait(); + } + + /** + * Creates a DeidentifyTemplate for reusing frequently used configuration + * for de-identifying content, images, and storage. + * See https://cloud.google.com/dlp/docs/creating-templates-deid to learn + * more. + * + * The async variant is {@see DlpServiceClient::createDeidentifyTemplateAsync()} . + * + * @param CreateDeidentifyTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DeidentifyTemplate + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDeidentifyTemplate(CreateDeidentifyTemplateRequest $request, array $callOptions = []): DeidentifyTemplate + { + return $this->startApiCall('CreateDeidentifyTemplate', $request, $callOptions)->wait(); + } + + /** + * Creates a new job to inspect storage or calculate risk metrics. + * See https://cloud.google.com/dlp/docs/inspecting-storage and + * https://cloud.google.com/dlp/docs/compute-risk-analysis to learn more. + * + * When no InfoTypes or CustomInfoTypes are specified in inspect jobs, the + * system will automatically choose what detectors to run. By default this may + * be all types, but may change over time as detectors are updated. + * + * The async variant is {@see DlpServiceClient::createDlpJobAsync()} . + * + * @param CreateDlpJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DlpJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDlpJob(CreateDlpJobRequest $request, array $callOptions = []): DlpJob + { + return $this->startApiCall('CreateDlpJob', $request, $callOptions)->wait(); + } + + /** + * Creates an InspectTemplate for reusing frequently used configuration + * for inspecting content, images, and storage. + * See https://cloud.google.com/dlp/docs/creating-templates to learn more. + * + * The async variant is {@see DlpServiceClient::createInspectTemplateAsync()} . + * + * @param CreateInspectTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InspectTemplate + * + * @throws ApiException Thrown if the API call fails. + */ + public function createInspectTemplate(CreateInspectTemplateRequest $request, array $callOptions = []): InspectTemplate + { + return $this->startApiCall('CreateInspectTemplate', $request, $callOptions)->wait(); + } + + /** + * Creates a job trigger to run DLP actions such as scanning storage for + * sensitive information on a set schedule. + * See https://cloud.google.com/dlp/docs/creating-job-triggers to learn more. + * + * The async variant is {@see DlpServiceClient::createJobTriggerAsync()} . + * + * @param CreateJobTriggerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 JobTrigger + * + * @throws ApiException Thrown if the API call fails. + */ + public function createJobTrigger(CreateJobTriggerRequest $request, array $callOptions = []): JobTrigger + { + return $this->startApiCall('CreateJobTrigger', $request, $callOptions)->wait(); + } + + /** + * Creates a pre-built stored infoType to be used for inspection. + * See https://cloud.google.com/dlp/docs/creating-stored-infotypes to + * learn more. + * + * The async variant is {@see DlpServiceClient::createStoredInfoTypeAsync()} . + * + * @param CreateStoredInfoTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 StoredInfoType + * + * @throws ApiException Thrown if the API call fails. + */ + public function createStoredInfoType(CreateStoredInfoTypeRequest $request, array $callOptions = []): StoredInfoType + { + return $this->startApiCall('CreateStoredInfoType', $request, $callOptions)->wait(); + } + + /** + * De-identifies potentially sensitive info from a ContentItem. + * This method has limits on input size and output size. + * See https://cloud.google.com/dlp/docs/deidentify-sensitive-data to + * learn more. + * + * When no InfoTypes or CustomInfoTypes are specified in this request, the + * system will automatically choose what detectors to run. By default this may + * be all types, but may change over time as detectors are updated. + * + * The async variant is {@see DlpServiceClient::deidentifyContentAsync()} . + * + * @param DeidentifyContentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DeidentifyContentResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deidentifyContent(DeidentifyContentRequest $request, array $callOptions = []): DeidentifyContentResponse + { + return $this->startApiCall('DeidentifyContent', $request, $callOptions)->wait(); + } + + /** + * Deletes a DeidentifyTemplate. + * See https://cloud.google.com/dlp/docs/creating-templates-deid to learn + * more. + * + * The async variant is {@see DlpServiceClient::deleteDeidentifyTemplateAsync()} . + * + * @param DeleteDeidentifyTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDeidentifyTemplate(DeleteDeidentifyTemplateRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteDeidentifyTemplate', $request, $callOptions)->wait(); + } + + /** + * Deletes a long-running DlpJob. This method indicates that the client is + * no longer interested in the DlpJob result. The job will be canceled if + * possible. + * See https://cloud.google.com/dlp/docs/inspecting-storage and + * https://cloud.google.com/dlp/docs/compute-risk-analysis to learn more. + * + * The async variant is {@see DlpServiceClient::deleteDlpJobAsync()} . + * + * @param DeleteDlpJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDlpJob(DeleteDlpJobRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteDlpJob', $request, $callOptions)->wait(); + } + + /** + * Deletes an InspectTemplate. + * See https://cloud.google.com/dlp/docs/creating-templates to learn more. + * + * The async variant is {@see DlpServiceClient::deleteInspectTemplateAsync()} . + * + * @param DeleteInspectTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteInspectTemplate(DeleteInspectTemplateRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteInspectTemplate', $request, $callOptions)->wait(); + } + + /** + * Deletes a job trigger. + * See https://cloud.google.com/dlp/docs/creating-job-triggers to learn more. + * + * The async variant is {@see DlpServiceClient::deleteJobTriggerAsync()} . + * + * @param DeleteJobTriggerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteJobTrigger(DeleteJobTriggerRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteJobTrigger', $request, $callOptions)->wait(); + } + + /** + * Deletes a stored infoType. + * See https://cloud.google.com/dlp/docs/creating-stored-infotypes to + * learn more. + * + * The async variant is {@see DlpServiceClient::deleteStoredInfoTypeAsync()} . + * + * @param DeleteStoredInfoTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteStoredInfoType(DeleteStoredInfoTypeRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteStoredInfoType', $request, $callOptions)->wait(); + } + + /** + * Finish a running hybrid DlpJob. Triggers the finalization steps and running + * of any enabled actions that have not yet run. + * + * The async variant is {@see DlpServiceClient::finishDlpJobAsync()} . + * + * @param FinishDlpJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function finishDlpJob(FinishDlpJobRequest $request, array $callOptions = []): void + { + $this->startApiCall('FinishDlpJob', $request, $callOptions)->wait(); + } + + /** + * Gets a DeidentifyTemplate. + * See https://cloud.google.com/dlp/docs/creating-templates-deid to learn + * more. + * + * The async variant is {@see DlpServiceClient::getDeidentifyTemplateAsync()} . + * + * @param GetDeidentifyTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DeidentifyTemplate + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDeidentifyTemplate(GetDeidentifyTemplateRequest $request, array $callOptions = []): DeidentifyTemplate + { + return $this->startApiCall('GetDeidentifyTemplate', $request, $callOptions)->wait(); + } + + /** + * Gets the latest state of a long-running DlpJob. + * See https://cloud.google.com/dlp/docs/inspecting-storage and + * https://cloud.google.com/dlp/docs/compute-risk-analysis to learn more. + * + * The async variant is {@see DlpServiceClient::getDlpJobAsync()} . + * + * @param GetDlpJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DlpJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDlpJob(GetDlpJobRequest $request, array $callOptions = []): DlpJob + { + return $this->startApiCall('GetDlpJob', $request, $callOptions)->wait(); + } + + /** + * Gets an InspectTemplate. + * See https://cloud.google.com/dlp/docs/creating-templates to learn more. + * + * The async variant is {@see DlpServiceClient::getInspectTemplateAsync()} . + * + * @param GetInspectTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InspectTemplate + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInspectTemplate(GetInspectTemplateRequest $request, array $callOptions = []): InspectTemplate + { + return $this->startApiCall('GetInspectTemplate', $request, $callOptions)->wait(); + } + + /** + * Gets a job trigger. + * See https://cloud.google.com/dlp/docs/creating-job-triggers to learn more. + * + * The async variant is {@see DlpServiceClient::getJobTriggerAsync()} . + * + * @param GetJobTriggerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 JobTrigger + * + * @throws ApiException Thrown if the API call fails. + */ + public function getJobTrigger(GetJobTriggerRequest $request, array $callOptions = []): JobTrigger + { + return $this->startApiCall('GetJobTrigger', $request, $callOptions)->wait(); + } + + /** + * Gets a stored infoType. + * See https://cloud.google.com/dlp/docs/creating-stored-infotypes to + * learn more. + * + * The async variant is {@see DlpServiceClient::getStoredInfoTypeAsync()} . + * + * @param GetStoredInfoTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 StoredInfoType + * + * @throws ApiException Thrown if the API call fails. + */ + public function getStoredInfoType(GetStoredInfoTypeRequest $request, array $callOptions = []): StoredInfoType + { + return $this->startApiCall('GetStoredInfoType', $request, $callOptions)->wait(); + } + + /** + * Inspect hybrid content and store findings to a job. + * To review the findings, inspect the job. Inspection will occur + * asynchronously. + * + * The async variant is {@see DlpServiceClient::hybridInspectDlpJobAsync()} . + * + * @param HybridInspectDlpJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 HybridInspectResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function hybridInspectDlpJob(HybridInspectDlpJobRequest $request, array $callOptions = []): HybridInspectResponse + { + return $this->startApiCall('HybridInspectDlpJob', $request, $callOptions)->wait(); + } + + /** + * Inspect hybrid content and store findings to a trigger. The inspection + * will be processed asynchronously. To review the findings monitor the + * jobs within the trigger. + * + * The async variant is {@see DlpServiceClient::hybridInspectJobTriggerAsync()} . + * + * @param HybridInspectJobTriggerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 HybridInspectResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function hybridInspectJobTrigger(HybridInspectJobTriggerRequest $request, array $callOptions = []): HybridInspectResponse + { + return $this->startApiCall('HybridInspectJobTrigger', $request, $callOptions)->wait(); + } + + /** + * Finds potentially sensitive info in content. + * This method has limits on input size, processing time, and output size. + * + * When no InfoTypes or CustomInfoTypes are specified in this request, the + * system will automatically choose what detectors to run. By default this may + * be all types, but may change over time as detectors are updated. + * + * For how to guides, see https://cloud.google.com/dlp/docs/inspecting-images + * and https://cloud.google.com/dlp/docs/inspecting-text, + * + * The async variant is {@see DlpServiceClient::inspectContentAsync()} . + * + * @param InspectContentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InspectContentResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function inspectContent(InspectContentRequest $request, array $callOptions = []): InspectContentResponse + { + return $this->startApiCall('InspectContent', $request, $callOptions)->wait(); + } + + /** + * Lists DeidentifyTemplates. + * See https://cloud.google.com/dlp/docs/creating-templates-deid to learn + * more. + * + * The async variant is {@see DlpServiceClient::listDeidentifyTemplatesAsync()} . + * + * @param ListDeidentifyTemplatesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDeidentifyTemplates(ListDeidentifyTemplatesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDeidentifyTemplates', $request, $callOptions); + } + + /** + * Lists DlpJobs that match the specified filter in the request. + * See https://cloud.google.com/dlp/docs/inspecting-storage and + * https://cloud.google.com/dlp/docs/compute-risk-analysis to learn more. + * + * The async variant is {@see DlpServiceClient::listDlpJobsAsync()} . + * + * @param ListDlpJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDlpJobs(ListDlpJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDlpJobs', $request, $callOptions); + } + + /** + * Returns a list of the sensitive information types that DLP API + * supports. See https://cloud.google.com/dlp/docs/infotypes-reference to + * learn more. + * + * The async variant is {@see DlpServiceClient::listInfoTypesAsync()} . + * + * @param ListInfoTypesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ListInfoTypesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInfoTypes(ListInfoTypesRequest $request, array $callOptions = []): ListInfoTypesResponse + { + return $this->startApiCall('ListInfoTypes', $request, $callOptions)->wait(); + } + + /** + * Lists InspectTemplates. + * See https://cloud.google.com/dlp/docs/creating-templates to learn more. + * + * The async variant is {@see DlpServiceClient::listInspectTemplatesAsync()} . + * + * @param ListInspectTemplatesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInspectTemplates(ListInspectTemplatesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInspectTemplates', $request, $callOptions); + } + + /** + * Lists job triggers. + * See https://cloud.google.com/dlp/docs/creating-job-triggers to learn more. + * + * The async variant is {@see DlpServiceClient::listJobTriggersAsync()} . + * + * @param ListJobTriggersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listJobTriggers(ListJobTriggersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListJobTriggers', $request, $callOptions); + } + + /** + * Lists stored infoTypes. + * See https://cloud.google.com/dlp/docs/creating-stored-infotypes to + * learn more. + * + * The async variant is {@see DlpServiceClient::listStoredInfoTypesAsync()} . + * + * @param ListStoredInfoTypesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listStoredInfoTypes(ListStoredInfoTypesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListStoredInfoTypes', $request, $callOptions); + } + + /** + * Redacts potentially sensitive info from an image. + * This method has limits on input size, processing time, and output size. + * See https://cloud.google.com/dlp/docs/redacting-sensitive-data-images to + * learn more. + * + * When no InfoTypes or CustomInfoTypes are specified in this request, the + * system will automatically choose what detectors to run. By default this may + * be all types, but may change over time as detectors are updated. + * + * The async variant is {@see DlpServiceClient::redactImageAsync()} . + * + * @param RedactImageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RedactImageResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function redactImage(RedactImageRequest $request, array $callOptions = []): RedactImageResponse + { + return $this->startApiCall('RedactImage', $request, $callOptions)->wait(); + } + + /** + * Re-identifies content that has been de-identified. + * See + * https://cloud.google.com/dlp/docs/pseudonymization#re-identification_in_free_text_code_example + * to learn more. + * + * The async variant is {@see DlpServiceClient::reidentifyContentAsync()} . + * + * @param ReidentifyContentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ReidentifyContentResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function reidentifyContent(ReidentifyContentRequest $request, array $callOptions = []): ReidentifyContentResponse + { + return $this->startApiCall('ReidentifyContent', $request, $callOptions)->wait(); + } + + /** + * Updates the DeidentifyTemplate. + * See https://cloud.google.com/dlp/docs/creating-templates-deid to learn + * more. + * + * The async variant is {@see DlpServiceClient::updateDeidentifyTemplateAsync()} . + * + * @param UpdateDeidentifyTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DeidentifyTemplate + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDeidentifyTemplate(UpdateDeidentifyTemplateRequest $request, array $callOptions = []): DeidentifyTemplate + { + return $this->startApiCall('UpdateDeidentifyTemplate', $request, $callOptions)->wait(); + } + + /** + * Updates the InspectTemplate. + * See https://cloud.google.com/dlp/docs/creating-templates to learn more. + * + * The async variant is {@see DlpServiceClient::updateInspectTemplateAsync()} . + * + * @param UpdateInspectTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InspectTemplate + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateInspectTemplate(UpdateInspectTemplateRequest $request, array $callOptions = []): InspectTemplate + { + return $this->startApiCall('UpdateInspectTemplate', $request, $callOptions)->wait(); + } + + /** + * Updates a job trigger. + * See https://cloud.google.com/dlp/docs/creating-job-triggers to learn more. + * + * The async variant is {@see DlpServiceClient::updateJobTriggerAsync()} . + * + * @param UpdateJobTriggerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 JobTrigger + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateJobTrigger(UpdateJobTriggerRequest $request, array $callOptions = []): JobTrigger + { + return $this->startApiCall('UpdateJobTrigger', $request, $callOptions)->wait(); + } + + /** + * Updates the stored infoType by creating a new version. The existing version + * will continue to be used until the new version is ready. + * See https://cloud.google.com/dlp/docs/creating-stored-infotypes to + * learn more. + * + * The async variant is {@see DlpServiceClient::updateStoredInfoTypeAsync()} . + * + * @param UpdateStoredInfoTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 StoredInfoType + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateStoredInfoType(UpdateStoredInfoTypeRequest $request, array $callOptions = []): StoredInfoType + { + return $this->startApiCall('UpdateStoredInfoType', $request, $callOptions)->wait(); + } } diff --git a/Dms/composer.json b/Dms/composer.json index f0b4a197dc07..e5fd66cdc66d 100644 --- a/Dms/composer.json +++ b/Dms/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Dms/src/V1/Client/BaseClient/DataMigrationServiceBaseClient.php b/Dms/src/V1/Client/BaseClient/DataMigrationServiceBaseClient.php deleted file mode 100644 index 7e77f925edcf..000000000000 --- a/Dms/src/V1/Client/BaseClient/DataMigrationServiceBaseClient.php +++ /dev/null @@ -1,1462 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/data_migration_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/data_migration_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/data_migration_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/data_migration_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * connection_profile resource. - * - * @param string $project - * @param string $location - * @param string $connectionProfile - * - * @return string The formatted connection_profile resource. - */ - public static function connectionProfileName(string $project, string $location, string $connectionProfile): string - { - return self::getPathTemplate('connectionProfile')->render([ - 'project' => $project, - 'location' => $location, - 'connection_profile' => $connectionProfile, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * conversion_workspace resource. - * - * @param string $project - * @param string $location - * @param string $conversionWorkspace - * - * @return string The formatted conversion_workspace resource. - */ - public static function conversionWorkspaceName(string $project, string $location, string $conversionWorkspace): string - { - return self::getPathTemplate('conversionWorkspace')->render([ - 'project' => $project, - 'location' => $location, - 'conversion_workspace' => $conversionWorkspace, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a mapping_rule - * resource. - * - * @param string $project - * @param string $location - * @param string $conversionWorkspace - * @param string $mappingRule - * - * @return string The formatted mapping_rule resource. - */ - public static function mappingRuleName(string $project, string $location, string $conversionWorkspace, string $mappingRule): string - { - return self::getPathTemplate('mappingRule')->render([ - 'project' => $project, - 'location' => $location, - 'conversion_workspace' => $conversionWorkspace, - 'mapping_rule' => $mappingRule, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * migration_job resource. - * - * @param string $project - * @param string $location - * @param string $migrationJob - * - * @return string The formatted migration_job resource. - */ - public static function migrationJobName(string $project, string $location, string $migrationJob): string - { - return self::getPathTemplate('migrationJob')->render([ - 'project' => $project, - 'location' => $location, - 'migration_job' => $migrationJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a networks - * resource. - * - * @param string $project - * @param string $network - * - * @return string The formatted networks resource. - */ - public static function networksName(string $project, string $network): string - { - return self::getPathTemplate('networks')->render([ - 'project' => $project, - 'network' => $network, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * private_connection resource. - * - * @param string $project - * @param string $location - * @param string $privateConnection - * - * @return string The formatted private_connection resource. - */ - public static function privateConnectionName(string $project, string $location, string $privateConnection): string - { - return self::getPathTemplate('privateConnection')->render([ - 'project' => $project, - 'location' => $location, - 'private_connection' => $privateConnection, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - connectionProfile: projects/{project}/locations/{location}/connectionProfiles/{connection_profile} - * - conversionWorkspace: projects/{project}/locations/{location}/conversionWorkspaces/{conversion_workspace} - * - location: projects/{project}/locations/{location} - * - mappingRule: projects/{project}/locations/{location}/conversionWorkspaces/{conversion_workspace}/mappingRules/{mapping_rule} - * - migrationJob: projects/{project}/locations/{location}/migrationJobs/{migration_job} - * - networks: projects/{project}/global/networks/{network} - * - privateConnection: projects/{project}/locations/{location}/privateConnections/{private_connection} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'datamigration.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Applies draft tree onto a specific destination database. - * - * The async variant is {@see self::applyConversionWorkspaceAsync()} . - * - * @param ApplyConversionWorkspaceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function applyConversionWorkspace(ApplyConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ApplyConversionWorkspace', $request, $callOptions)->wait(); - } - - /** - * Marks all the data in the conversion workspace as committed. - * - * The async variant is {@see self::commitConversionWorkspaceAsync()} . - * - * @param CommitConversionWorkspaceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function commitConversionWorkspace(CommitConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CommitConversionWorkspace', $request, $callOptions)->wait(); - } - - /** - * Creates a draft tree schema for the destination database. - * - * The async variant is {@see self::convertConversionWorkspaceAsync()} . - * - * @param ConvertConversionWorkspaceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function convertConversionWorkspace(ConvertConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ConvertConversionWorkspace', $request, $callOptions)->wait(); - } - - /** - * Creates a new connection profile in a given project and location. - * - * The async variant is {@see self::createConnectionProfileAsync()} . - * - * @param CreateConnectionProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createConnectionProfile(CreateConnectionProfileRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateConnectionProfile', $request, $callOptions)->wait(); - } - - /** - * Creates a new conversion workspace in a given project and location. - * - * The async variant is {@see self::createConversionWorkspaceAsync()} . - * - * @param CreateConversionWorkspaceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createConversionWorkspace(CreateConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateConversionWorkspace', $request, $callOptions)->wait(); - } - - /** - * Creates a new mapping rule for a given conversion workspace. - * - * The async variant is {@see self::createMappingRuleAsync()} . - * - * @param CreateMappingRuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MappingRule - * - * @throws ApiException Thrown if the API call fails. - */ - public function createMappingRule(CreateMappingRuleRequest $request, array $callOptions = []): MappingRule - { - return $this->startApiCall('CreateMappingRule', $request, $callOptions)->wait(); - } - - /** - * Creates a new migration job in a given project and location. - * - * The async variant is {@see self::createMigrationJobAsync()} . - * - * @param CreateMigrationJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createMigrationJob(CreateMigrationJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateMigrationJob', $request, $callOptions)->wait(); - } - - /** - * Creates a new private connection in a given project and location. - * - * The async variant is {@see self::createPrivateConnectionAsync()} . - * - * @param CreatePrivateConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createPrivateConnection(CreatePrivateConnectionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreatePrivateConnection', $request, $callOptions)->wait(); - } - - /** - * Deletes a single Database Migration Service connection profile. - * A connection profile can only be deleted if it is not in use by any - * active migration jobs. - * - * The async variant is {@see self::deleteConnectionProfileAsync()} . - * - * @param DeleteConnectionProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteConnectionProfile(DeleteConnectionProfileRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteConnectionProfile', $request, $callOptions)->wait(); - } - - /** - * Deletes a single conversion workspace. - * - * The async variant is {@see self::deleteConversionWorkspaceAsync()} . - * - * @param DeleteConversionWorkspaceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteConversionWorkspace(DeleteConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteConversionWorkspace', $request, $callOptions)->wait(); - } - - /** - * Deletes a single mapping rule. - * - * The async variant is {@see self::deleteMappingRuleAsync()} . - * - * @param DeleteMappingRuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteMappingRule(DeleteMappingRuleRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteMappingRule', $request, $callOptions)->wait(); - } - - /** - * Deletes a single migration job. - * - * The async variant is {@see self::deleteMigrationJobAsync()} . - * - * @param DeleteMigrationJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteMigrationJob(DeleteMigrationJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteMigrationJob', $request, $callOptions)->wait(); - } - - /** - * Deletes a single Database Migration Service private connection. - * - * The async variant is {@see self::deletePrivateConnectionAsync()} . - * - * @param DeletePrivateConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deletePrivateConnection(DeletePrivateConnectionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeletePrivateConnection', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of committed revisions of a specific conversion - * workspace. - * - * The async variant is {@see self::describeConversionWorkspaceRevisionsAsync()} . - * - * @param DescribeConversionWorkspaceRevisionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DescribeConversionWorkspaceRevisionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function describeConversionWorkspaceRevisions(DescribeConversionWorkspaceRevisionsRequest $request, array $callOptions = []): DescribeConversionWorkspaceRevisionsResponse - { - return $this->startApiCall('DescribeConversionWorkspaceRevisions', $request, $callOptions)->wait(); - } - - /** - * Describes the database entities tree for a specific conversion workspace - * and a specific tree type. - * - * Database entities are not resources like conversion workspaces or mapping - * rules, and they can't be created, updated or deleted. Instead, they are - * simple data objects describing the structure of the client database. - * - * The async variant is {@see self::describeDatabaseEntitiesAsync()} . - * - * @param DescribeDatabaseEntitiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function describeDatabaseEntities(DescribeDatabaseEntitiesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('DescribeDatabaseEntities', $request, $callOptions); - } - - /** - * Fetches a set of static IP addresses that need to be allowlisted by the - * customer when using the static-IP connectivity method. - * - * The async variant is {@see self::fetchStaticIpsAsync()} . - * - * @param FetchStaticIpsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function fetchStaticIps(FetchStaticIpsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('FetchStaticIps', $request, $callOptions); - } - - /** - * Generate a SSH configuration script to configure the reverse SSH - * connectivity. - * - * The async variant is {@see self::generateSshScriptAsync()} . - * - * @param GenerateSshScriptRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SshScript - * - * @throws ApiException Thrown if the API call fails. - */ - public function generateSshScript(GenerateSshScriptRequest $request, array $callOptions = []): SshScript - { - return $this->startApiCall('GenerateSshScript', $request, $callOptions)->wait(); - } - - /** - * Generate a TCP Proxy configuration script to configure a cloud-hosted VM - * running a TCP Proxy. - * - * The async variant is {@see self::generateTcpProxyScriptAsync()} . - * - * @param GenerateTcpProxyScriptRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TcpProxyScript - * - * @throws ApiException Thrown if the API call fails. - */ - public function generateTcpProxyScript(GenerateTcpProxyScriptRequest $request, array $callOptions = []): TcpProxyScript - { - return $this->startApiCall('GenerateTcpProxyScript', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single connection profile. - * - * The async variant is {@see self::getConnectionProfileAsync()} . - * - * @param GetConnectionProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ConnectionProfile - * - * @throws ApiException Thrown if the API call fails. - */ - public function getConnectionProfile(GetConnectionProfileRequest $request, array $callOptions = []): ConnectionProfile - { - return $this->startApiCall('GetConnectionProfile', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single conversion workspace. - * - * The async variant is {@see self::getConversionWorkspaceAsync()} . - * - * @param GetConversionWorkspaceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ConversionWorkspace - * - * @throws ApiException Thrown if the API call fails. - */ - public function getConversionWorkspace(GetConversionWorkspaceRequest $request, array $callOptions = []): ConversionWorkspace - { - return $this->startApiCall('GetConversionWorkspace', $request, $callOptions)->wait(); - } - - /** - * Gets the details of a mapping rule. - * - * The async variant is {@see self::getMappingRuleAsync()} . - * - * @param GetMappingRuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MappingRule - * - * @throws ApiException Thrown if the API call fails. - */ - public function getMappingRule(GetMappingRuleRequest $request, array $callOptions = []): MappingRule - { - return $this->startApiCall('GetMappingRule', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single migration job. - * - * The async variant is {@see self::getMigrationJobAsync()} . - * - * @param GetMigrationJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MigrationJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function getMigrationJob(GetMigrationJobRequest $request, array $callOptions = []): MigrationJob - { - return $this->startApiCall('GetMigrationJob', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single private connection. - * - * The async variant is {@see self::getPrivateConnectionAsync()} . - * - * @param GetPrivateConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PrivateConnection - * - * @throws ApiException Thrown if the API call fails. - */ - public function getPrivateConnection(GetPrivateConnectionRequest $request, array $callOptions = []): PrivateConnection - { - return $this->startApiCall('GetPrivateConnection', $request, $callOptions)->wait(); - } - - /** - * Imports the mapping rules for a given conversion workspace. - * Supports various formats of external rules files. - * - * The async variant is {@see self::importMappingRulesAsync()} . - * - * @param ImportMappingRulesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function importMappingRules(ImportMappingRulesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ImportMappingRules', $request, $callOptions)->wait(); - } - - /** - * Retrieves a list of all connection profiles in a given project and - * location. - * - * The async variant is {@see self::listConnectionProfilesAsync()} . - * - * @param ListConnectionProfilesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listConnectionProfiles(ListConnectionProfilesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListConnectionProfiles', $request, $callOptions); - } - - /** - * Lists conversion workspaces in a given project and location. - * - * The async variant is {@see self::listConversionWorkspacesAsync()} . - * - * @param ListConversionWorkspacesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listConversionWorkspaces(ListConversionWorkspacesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListConversionWorkspaces', $request, $callOptions); - } - - /** - * Lists the mapping rules for a specific conversion workspace. - * - * The async variant is {@see self::listMappingRulesAsync()} . - * - * @param ListMappingRulesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listMappingRules(ListMappingRulesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListMappingRules', $request, $callOptions); - } - - /** - * Lists migration jobs in a given project and location. - * - * The async variant is {@see self::listMigrationJobsAsync()} . - * - * @param ListMigrationJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listMigrationJobs(ListMigrationJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListMigrationJobs', $request, $callOptions); - } - - /** - * Retrieves a list of private connections in a given project and location. - * - * The async variant is {@see self::listPrivateConnectionsAsync()} . - * - * @param ListPrivateConnectionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPrivateConnections(ListPrivateConnectionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPrivateConnections', $request, $callOptions); - } - - /** - * Promote a migration job, stopping replication to the destination and - * promoting the destination to be a standalone database. - * - * The async variant is {@see self::promoteMigrationJobAsync()} . - * - * @param PromoteMigrationJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function promoteMigrationJob(PromoteMigrationJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('PromoteMigrationJob', $request, $callOptions)->wait(); - } - - /** - * Restart a stopped or failed migration job, resetting the destination - * instance to its original state and starting the migration process from - * scratch. - * - * The async variant is {@see self::restartMigrationJobAsync()} . - * - * @param RestartMigrationJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function restartMigrationJob(RestartMigrationJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RestartMigrationJob', $request, $callOptions)->wait(); - } - - /** - * Resume a migration job that is currently stopped and is resumable (was - * stopped during CDC phase). - * - * The async variant is {@see self::resumeMigrationJobAsync()} . - * - * @param ResumeMigrationJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function resumeMigrationJob(ResumeMigrationJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ResumeMigrationJob', $request, $callOptions)->wait(); - } - - /** - * Rolls back a conversion workspace to the last committed snapshot. - * - * The async variant is {@see self::rollbackConversionWorkspaceAsync()} . - * - * @param RollbackConversionWorkspaceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function rollbackConversionWorkspace(RollbackConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RollbackConversionWorkspace', $request, $callOptions)->wait(); - } - - /** - * Searches/lists the background jobs for a specific - * conversion workspace. - * - * The background jobs are not resources like conversion workspaces or - * mapping rules, and they can't be created, updated or deleted. - * Instead, they are a way to expose the data plane jobs log. - * - * The async variant is {@see self::searchBackgroundJobsAsync()} . - * - * @param SearchBackgroundJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SearchBackgroundJobsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchBackgroundJobs(SearchBackgroundJobsRequest $request, array $callOptions = []): SearchBackgroundJobsResponse - { - return $this->startApiCall('SearchBackgroundJobs', $request, $callOptions)->wait(); - } - - /** - * Imports a snapshot of the source database into the - * conversion workspace. - * - * The async variant is {@see self::seedConversionWorkspaceAsync()} . - * - * @param SeedConversionWorkspaceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function seedConversionWorkspace(SeedConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SeedConversionWorkspace', $request, $callOptions)->wait(); - } - - /** - * Start an already created migration job. - * - * The async variant is {@see self::startMigrationJobAsync()} . - * - * @param StartMigrationJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function startMigrationJob(StartMigrationJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StartMigrationJob', $request, $callOptions)->wait(); - } - - /** - * Stops a running migration job. - * - * The async variant is {@see self::stopMigrationJobAsync()} . - * - * @param StopMigrationJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function stopMigrationJob(StopMigrationJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StopMigrationJob', $request, $callOptions)->wait(); - } - - /** - * Update the configuration of a single connection profile. - * - * The async variant is {@see self::updateConnectionProfileAsync()} . - * - * @param UpdateConnectionProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateConnectionProfile(UpdateConnectionProfileRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateConnectionProfile', $request, $callOptions)->wait(); - } - - /** - * Updates the parameters of a single conversion workspace. - * - * The async variant is {@see self::updateConversionWorkspaceAsync()} . - * - * @param UpdateConversionWorkspaceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateConversionWorkspace(UpdateConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateConversionWorkspace', $request, $callOptions)->wait(); - } - - /** - * Updates the parameters of a single migration job. - * - * The async variant is {@see self::updateMigrationJobAsync()} . - * - * @param UpdateMigrationJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateMigrationJob(UpdateMigrationJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateMigrationJob', $request, $callOptions)->wait(); - } - - /** - * Verify a migration job, making sure the destination can reach the source - * and that all configuration and prerequisites are met. - * - * The async variant is {@see self::verifyMigrationJobAsync()} . - * - * @param VerifyMigrationJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function verifyMigrationJob(VerifyMigrationJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('VerifyMigrationJob', $request, $callOptions)->wait(); - } -} diff --git a/Dms/src/V1/Client/DataMigrationServiceClient.php b/Dms/src/V1/Client/DataMigrationServiceClient.php index 2b33dfde7cb5..26cbf3df2e97 100644 --- a/Dms/src/V1/Client/DataMigrationServiceClient.php +++ b/Dms/src/V1/Client/DataMigrationServiceClient.php @@ -24,17 +24,1475 @@ namespace Google\Cloud\CloudDms\V1\Client; -use Google\Cloud\CloudDms\V1\Client\BaseClient\DataMigrationServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\CloudDms\V1\ApplyConversionWorkspaceRequest; +use Google\Cloud\CloudDms\V1\CommitConversionWorkspaceRequest; +use Google\Cloud\CloudDms\V1\ConnectionProfile; +use Google\Cloud\CloudDms\V1\ConversionWorkspace; +use Google\Cloud\CloudDms\V1\ConvertConversionWorkspaceRequest; +use Google\Cloud\CloudDms\V1\CreateConnectionProfileRequest; +use Google\Cloud\CloudDms\V1\CreateConversionWorkspaceRequest; +use Google\Cloud\CloudDms\V1\CreateMappingRuleRequest; +use Google\Cloud\CloudDms\V1\CreateMigrationJobRequest; +use Google\Cloud\CloudDms\V1\CreatePrivateConnectionRequest; +use Google\Cloud\CloudDms\V1\DeleteConnectionProfileRequest; +use Google\Cloud\CloudDms\V1\DeleteConversionWorkspaceRequest; +use Google\Cloud\CloudDms\V1\DeleteMappingRuleRequest; +use Google\Cloud\CloudDms\V1\DeleteMigrationJobRequest; +use Google\Cloud\CloudDms\V1\DeletePrivateConnectionRequest; +use Google\Cloud\CloudDms\V1\DescribeConversionWorkspaceRevisionsRequest; +use Google\Cloud\CloudDms\V1\DescribeConversionWorkspaceRevisionsResponse; +use Google\Cloud\CloudDms\V1\DescribeDatabaseEntitiesRequest; +use Google\Cloud\CloudDms\V1\FetchStaticIpsRequest; +use Google\Cloud\CloudDms\V1\GenerateSshScriptRequest; +use Google\Cloud\CloudDms\V1\GenerateTcpProxyScriptRequest; +use Google\Cloud\CloudDms\V1\GetConnectionProfileRequest; +use Google\Cloud\CloudDms\V1\GetConversionWorkspaceRequest; +use Google\Cloud\CloudDms\V1\GetMappingRuleRequest; +use Google\Cloud\CloudDms\V1\GetMigrationJobRequest; +use Google\Cloud\CloudDms\V1\GetPrivateConnectionRequest; +use Google\Cloud\CloudDms\V1\ImportMappingRulesRequest; +use Google\Cloud\CloudDms\V1\ListConnectionProfilesRequest; +use Google\Cloud\CloudDms\V1\ListConversionWorkspacesRequest; +use Google\Cloud\CloudDms\V1\ListMappingRulesRequest; +use Google\Cloud\CloudDms\V1\ListMigrationJobsRequest; +use Google\Cloud\CloudDms\V1\ListPrivateConnectionsRequest; +use Google\Cloud\CloudDms\V1\MappingRule; +use Google\Cloud\CloudDms\V1\MigrationJob; +use Google\Cloud\CloudDms\V1\PrivateConnection; +use Google\Cloud\CloudDms\V1\PromoteMigrationJobRequest; +use Google\Cloud\CloudDms\V1\RestartMigrationJobRequest; +use Google\Cloud\CloudDms\V1\ResumeMigrationJobRequest; +use Google\Cloud\CloudDms\V1\RollbackConversionWorkspaceRequest; +use Google\Cloud\CloudDms\V1\SearchBackgroundJobsRequest; +use Google\Cloud\CloudDms\V1\SearchBackgroundJobsResponse; +use Google\Cloud\CloudDms\V1\SeedConversionWorkspaceRequest; +use Google\Cloud\CloudDms\V1\SshScript; +use Google\Cloud\CloudDms\V1\StartMigrationJobRequest; +use Google\Cloud\CloudDms\V1\StopMigrationJobRequest; +use Google\Cloud\CloudDms\V1\TcpProxyScript; +use Google\Cloud\CloudDms\V1\UpdateConnectionProfileRequest; +use Google\Cloud\CloudDms\V1\UpdateConversionWorkspaceRequest; +use Google\Cloud\CloudDms\V1\UpdateMigrationJobRequest; +use Google\Cloud\CloudDms\V1\VerifyMigrationJobRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Database Migration service * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\CloudDms\V1\DataMigrationServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface applyConversionWorkspaceAsync(ApplyConversionWorkspaceRequest $request, array $optionalArgs = []) + * @method PromiseInterface commitConversionWorkspaceAsync(CommitConversionWorkspaceRequest $request, array $optionalArgs = []) + * @method PromiseInterface convertConversionWorkspaceAsync(ConvertConversionWorkspaceRequest $request, array $optionalArgs = []) + * @method PromiseInterface createConnectionProfileAsync(CreateConnectionProfileRequest $request, array $optionalArgs = []) + * @method PromiseInterface createConversionWorkspaceAsync(CreateConversionWorkspaceRequest $request, array $optionalArgs = []) + * @method PromiseInterface createMappingRuleAsync(CreateMappingRuleRequest $request, array $optionalArgs = []) + * @method PromiseInterface createMigrationJobAsync(CreateMigrationJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface createPrivateConnectionAsync(CreatePrivateConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteConnectionProfileAsync(DeleteConnectionProfileRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteConversionWorkspaceAsync(DeleteConversionWorkspaceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteMappingRuleAsync(DeleteMappingRuleRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteMigrationJobAsync(DeleteMigrationJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface deletePrivateConnectionAsync(DeletePrivateConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface describeConversionWorkspaceRevisionsAsync(DescribeConversionWorkspaceRevisionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface describeDatabaseEntitiesAsync(DescribeDatabaseEntitiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface fetchStaticIpsAsync(FetchStaticIpsRequest $request, array $optionalArgs = []) + * @method PromiseInterface generateSshScriptAsync(GenerateSshScriptRequest $request, array $optionalArgs = []) + * @method PromiseInterface generateTcpProxyScriptAsync(GenerateTcpProxyScriptRequest $request, array $optionalArgs = []) + * @method PromiseInterface getConnectionProfileAsync(GetConnectionProfileRequest $request, array $optionalArgs = []) + * @method PromiseInterface getConversionWorkspaceAsync(GetConversionWorkspaceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getMappingRuleAsync(GetMappingRuleRequest $request, array $optionalArgs = []) + * @method PromiseInterface getMigrationJobAsync(GetMigrationJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getPrivateConnectionAsync(GetPrivateConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface importMappingRulesAsync(ImportMappingRulesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listConnectionProfilesAsync(ListConnectionProfilesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listConversionWorkspacesAsync(ListConversionWorkspacesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listMappingRulesAsync(ListMappingRulesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listMigrationJobsAsync(ListMigrationJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPrivateConnectionsAsync(ListPrivateConnectionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface promoteMigrationJobAsync(PromoteMigrationJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface restartMigrationJobAsync(RestartMigrationJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface resumeMigrationJobAsync(ResumeMigrationJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface rollbackConversionWorkspaceAsync(RollbackConversionWorkspaceRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchBackgroundJobsAsync(SearchBackgroundJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface seedConversionWorkspaceAsync(SeedConversionWorkspaceRequest $request, array $optionalArgs = []) + * @method PromiseInterface startMigrationJobAsync(StartMigrationJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface stopMigrationJobAsync(StopMigrationJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateConnectionProfileAsync(UpdateConnectionProfileRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateConversionWorkspaceAsync(UpdateConversionWorkspaceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateMigrationJobAsync(UpdateMigrationJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface verifyMigrationJobAsync(VerifyMigrationJobRequest $request, array $optionalArgs = []) */ -final class DataMigrationServiceClient extends DataMigrationServiceBaseClient +final class DataMigrationServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DataMigrationServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.clouddms.v1.DataMigrationService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'datamigration.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/data_migration_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/data_migration_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/data_migration_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/data_migration_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * connection_profile resource. + * + * @param string $project + * @param string $location + * @param string $connectionProfile + * + * @return string The formatted connection_profile resource. + */ + public static function connectionProfileName(string $project, string $location, string $connectionProfile): string + { + return self::getPathTemplate('connectionProfile')->render([ + 'project' => $project, + 'location' => $location, + 'connection_profile' => $connectionProfile, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * conversion_workspace resource. + * + * @param string $project + * @param string $location + * @param string $conversionWorkspace + * + * @return string The formatted conversion_workspace resource. + */ + public static function conversionWorkspaceName(string $project, string $location, string $conversionWorkspace): string + { + return self::getPathTemplate('conversionWorkspace')->render([ + 'project' => $project, + 'location' => $location, + 'conversion_workspace' => $conversionWorkspace, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a mapping_rule + * resource. + * + * @param string $project + * @param string $location + * @param string $conversionWorkspace + * @param string $mappingRule + * + * @return string The formatted mapping_rule resource. + */ + public static function mappingRuleName(string $project, string $location, string $conversionWorkspace, string $mappingRule): string + { + return self::getPathTemplate('mappingRule')->render([ + 'project' => $project, + 'location' => $location, + 'conversion_workspace' => $conversionWorkspace, + 'mapping_rule' => $mappingRule, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * migration_job resource. + * + * @param string $project + * @param string $location + * @param string $migrationJob + * + * @return string The formatted migration_job resource. + */ + public static function migrationJobName(string $project, string $location, string $migrationJob): string + { + return self::getPathTemplate('migrationJob')->render([ + 'project' => $project, + 'location' => $location, + 'migration_job' => $migrationJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a networks + * resource. + * + * @param string $project + * @param string $network + * + * @return string The formatted networks resource. + */ + public static function networksName(string $project, string $network): string + { + return self::getPathTemplate('networks')->render([ + 'project' => $project, + 'network' => $network, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * private_connection resource. + * + * @param string $project + * @param string $location + * @param string $privateConnection + * + * @return string The formatted private_connection resource. + */ + public static function privateConnectionName(string $project, string $location, string $privateConnection): string + { + return self::getPathTemplate('privateConnection')->render([ + 'project' => $project, + 'location' => $location, + 'private_connection' => $privateConnection, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - connectionProfile: projects/{project}/locations/{location}/connectionProfiles/{connection_profile} + * - conversionWorkspace: projects/{project}/locations/{location}/conversionWorkspaces/{conversion_workspace} + * - location: projects/{project}/locations/{location} + * - mappingRule: projects/{project}/locations/{location}/conversionWorkspaces/{conversion_workspace}/mappingRules/{mapping_rule} + * - migrationJob: projects/{project}/locations/{location}/migrationJobs/{migration_job} + * - networks: projects/{project}/global/networks/{network} + * - privateConnection: projects/{project}/locations/{location}/privateConnections/{private_connection} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'datamigration.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Applies draft tree onto a specific destination database. + * + * The async variant is + * {@see DataMigrationServiceClient::applyConversionWorkspaceAsync()} . + * + * @param ApplyConversionWorkspaceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function applyConversionWorkspace(ApplyConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ApplyConversionWorkspace', $request, $callOptions)->wait(); + } + + /** + * Marks all the data in the conversion workspace as committed. + * + * The async variant is + * {@see DataMigrationServiceClient::commitConversionWorkspaceAsync()} . + * + * @param CommitConversionWorkspaceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function commitConversionWorkspace(CommitConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CommitConversionWorkspace', $request, $callOptions)->wait(); + } + + /** + * Creates a draft tree schema for the destination database. + * + * The async variant is + * {@see DataMigrationServiceClient::convertConversionWorkspaceAsync()} . + * + * @param ConvertConversionWorkspaceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function convertConversionWorkspace(ConvertConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ConvertConversionWorkspace', $request, $callOptions)->wait(); + } + + /** + * Creates a new connection profile in a given project and location. + * + * The async variant is + * {@see DataMigrationServiceClient::createConnectionProfileAsync()} . + * + * @param CreateConnectionProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createConnectionProfile(CreateConnectionProfileRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateConnectionProfile', $request, $callOptions)->wait(); + } + + /** + * Creates a new conversion workspace in a given project and location. + * + * The async variant is + * {@see DataMigrationServiceClient::createConversionWorkspaceAsync()} . + * + * @param CreateConversionWorkspaceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createConversionWorkspace(CreateConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateConversionWorkspace', $request, $callOptions)->wait(); + } + + /** + * Creates a new mapping rule for a given conversion workspace. + * + * The async variant is {@see DataMigrationServiceClient::createMappingRuleAsync()} + * . + * + * @param CreateMappingRuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MappingRule + * + * @throws ApiException Thrown if the API call fails. + */ + public function createMappingRule(CreateMappingRuleRequest $request, array $callOptions = []): MappingRule + { + return $this->startApiCall('CreateMappingRule', $request, $callOptions)->wait(); + } + + /** + * Creates a new migration job in a given project and location. + * + * The async variant is + * {@see DataMigrationServiceClient::createMigrationJobAsync()} . + * + * @param CreateMigrationJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createMigrationJob(CreateMigrationJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateMigrationJob', $request, $callOptions)->wait(); + } + + /** + * Creates a new private connection in a given project and location. + * + * The async variant is + * {@see DataMigrationServiceClient::createPrivateConnectionAsync()} . + * + * @param CreatePrivateConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createPrivateConnection(CreatePrivateConnectionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreatePrivateConnection', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Database Migration Service connection profile. + * A connection profile can only be deleted if it is not in use by any + * active migration jobs. + * + * The async variant is + * {@see DataMigrationServiceClient::deleteConnectionProfileAsync()} . + * + * @param DeleteConnectionProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteConnectionProfile(DeleteConnectionProfileRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteConnectionProfile', $request, $callOptions)->wait(); + } + + /** + * Deletes a single conversion workspace. + * + * The async variant is + * {@see DataMigrationServiceClient::deleteConversionWorkspaceAsync()} . + * + * @param DeleteConversionWorkspaceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteConversionWorkspace(DeleteConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteConversionWorkspace', $request, $callOptions)->wait(); + } + + /** + * Deletes a single mapping rule. + * + * The async variant is {@see DataMigrationServiceClient::deleteMappingRuleAsync()} + * . + * + * @param DeleteMappingRuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteMappingRule(DeleteMappingRuleRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteMappingRule', $request, $callOptions)->wait(); + } + + /** + * Deletes a single migration job. + * + * The async variant is + * {@see DataMigrationServiceClient::deleteMigrationJobAsync()} . + * + * @param DeleteMigrationJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteMigrationJob(DeleteMigrationJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteMigrationJob', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Database Migration Service private connection. + * + * The async variant is + * {@see DataMigrationServiceClient::deletePrivateConnectionAsync()} . + * + * @param DeletePrivateConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deletePrivateConnection(DeletePrivateConnectionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeletePrivateConnection', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of committed revisions of a specific conversion + * workspace. + * + * The async variant is + * {@see DataMigrationServiceClient::describeConversionWorkspaceRevisionsAsync()} . + * + * @param DescribeConversionWorkspaceRevisionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DescribeConversionWorkspaceRevisionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function describeConversionWorkspaceRevisions(DescribeConversionWorkspaceRevisionsRequest $request, array $callOptions = []): DescribeConversionWorkspaceRevisionsResponse + { + return $this->startApiCall('DescribeConversionWorkspaceRevisions', $request, $callOptions)->wait(); + } + + /** + * Describes the database entities tree for a specific conversion workspace + * and a specific tree type. + * + * Database entities are not resources like conversion workspaces or mapping + * rules, and they can't be created, updated or deleted. Instead, they are + * simple data objects describing the structure of the client database. + * + * The async variant is + * {@see DataMigrationServiceClient::describeDatabaseEntitiesAsync()} . + * + * @param DescribeDatabaseEntitiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function describeDatabaseEntities(DescribeDatabaseEntitiesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('DescribeDatabaseEntities', $request, $callOptions); + } + + /** + * Fetches a set of static IP addresses that need to be allowlisted by the + * customer when using the static-IP connectivity method. + * + * The async variant is {@see DataMigrationServiceClient::fetchStaticIpsAsync()} . + * + * @param FetchStaticIpsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function fetchStaticIps(FetchStaticIpsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('FetchStaticIps', $request, $callOptions); + } + + /** + * Generate a SSH configuration script to configure the reverse SSH + * connectivity. + * + * The async variant is {@see DataMigrationServiceClient::generateSshScriptAsync()} + * . + * + * @param GenerateSshScriptRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SshScript + * + * @throws ApiException Thrown if the API call fails. + */ + public function generateSshScript(GenerateSshScriptRequest $request, array $callOptions = []): SshScript + { + return $this->startApiCall('GenerateSshScript', $request, $callOptions)->wait(); + } + + /** + * Generate a TCP Proxy configuration script to configure a cloud-hosted VM + * running a TCP Proxy. + * + * The async variant is + * {@see DataMigrationServiceClient::generateTcpProxyScriptAsync()} . + * + * @param GenerateTcpProxyScriptRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TcpProxyScript + * + * @throws ApiException Thrown if the API call fails. + */ + public function generateTcpProxyScript(GenerateTcpProxyScriptRequest $request, array $callOptions = []): TcpProxyScript + { + return $this->startApiCall('GenerateTcpProxyScript', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single connection profile. + * + * The async variant is + * {@see DataMigrationServiceClient::getConnectionProfileAsync()} . + * + * @param GetConnectionProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ConnectionProfile + * + * @throws ApiException Thrown if the API call fails. + */ + public function getConnectionProfile(GetConnectionProfileRequest $request, array $callOptions = []): ConnectionProfile + { + return $this->startApiCall('GetConnectionProfile', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single conversion workspace. + * + * The async variant is + * {@see DataMigrationServiceClient::getConversionWorkspaceAsync()} . + * + * @param GetConversionWorkspaceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ConversionWorkspace + * + * @throws ApiException Thrown if the API call fails. + */ + public function getConversionWorkspace(GetConversionWorkspaceRequest $request, array $callOptions = []): ConversionWorkspace + { + return $this->startApiCall('GetConversionWorkspace', $request, $callOptions)->wait(); + } + + /** + * Gets the details of a mapping rule. + * + * The async variant is {@see DataMigrationServiceClient::getMappingRuleAsync()} . + * + * @param GetMappingRuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MappingRule + * + * @throws ApiException Thrown if the API call fails. + */ + public function getMappingRule(GetMappingRuleRequest $request, array $callOptions = []): MappingRule + { + return $this->startApiCall('GetMappingRule', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single migration job. + * + * The async variant is {@see DataMigrationServiceClient::getMigrationJobAsync()} . + * + * @param GetMigrationJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MigrationJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function getMigrationJob(GetMigrationJobRequest $request, array $callOptions = []): MigrationJob + { + return $this->startApiCall('GetMigrationJob', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single private connection. + * + * The async variant is + * {@see DataMigrationServiceClient::getPrivateConnectionAsync()} . + * + * @param GetPrivateConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PrivateConnection + * + * @throws ApiException Thrown if the API call fails. + */ + public function getPrivateConnection(GetPrivateConnectionRequest $request, array $callOptions = []): PrivateConnection + { + return $this->startApiCall('GetPrivateConnection', $request, $callOptions)->wait(); + } + + /** + * Imports the mapping rules for a given conversion workspace. + * Supports various formats of external rules files. + * + * The async variant is + * {@see DataMigrationServiceClient::importMappingRulesAsync()} . + * + * @param ImportMappingRulesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importMappingRules(ImportMappingRulesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportMappingRules', $request, $callOptions)->wait(); + } + + /** + * Retrieves a list of all connection profiles in a given project and + * location. + * + * The async variant is + * {@see DataMigrationServiceClient::listConnectionProfilesAsync()} . + * + * @param ListConnectionProfilesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listConnectionProfiles(ListConnectionProfilesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListConnectionProfiles', $request, $callOptions); + } + + /** + * Lists conversion workspaces in a given project and location. + * + * The async variant is + * {@see DataMigrationServiceClient::listConversionWorkspacesAsync()} . + * + * @param ListConversionWorkspacesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listConversionWorkspaces(ListConversionWorkspacesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListConversionWorkspaces', $request, $callOptions); + } + + /** + * Lists the mapping rules for a specific conversion workspace. + * + * The async variant is {@see DataMigrationServiceClient::listMappingRulesAsync()} + * . + * + * @param ListMappingRulesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listMappingRules(ListMappingRulesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListMappingRules', $request, $callOptions); + } + + /** + * Lists migration jobs in a given project and location. + * + * The async variant is {@see DataMigrationServiceClient::listMigrationJobsAsync()} + * . + * + * @param ListMigrationJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listMigrationJobs(ListMigrationJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListMigrationJobs', $request, $callOptions); + } + + /** + * Retrieves a list of private connections in a given project and location. + * + * The async variant is + * {@see DataMigrationServiceClient::listPrivateConnectionsAsync()} . + * + * @param ListPrivateConnectionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPrivateConnections(ListPrivateConnectionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPrivateConnections', $request, $callOptions); + } + + /** + * Promote a migration job, stopping replication to the destination and + * promoting the destination to be a standalone database. + * + * The async variant is + * {@see DataMigrationServiceClient::promoteMigrationJobAsync()} . + * + * @param PromoteMigrationJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function promoteMigrationJob(PromoteMigrationJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('PromoteMigrationJob', $request, $callOptions)->wait(); + } + + /** + * Restart a stopped or failed migration job, resetting the destination + * instance to its original state and starting the migration process from + * scratch. + * + * The async variant is + * {@see DataMigrationServiceClient::restartMigrationJobAsync()} . + * + * @param RestartMigrationJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function restartMigrationJob(RestartMigrationJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RestartMigrationJob', $request, $callOptions)->wait(); + } + + /** + * Resume a migration job that is currently stopped and is resumable (was + * stopped during CDC phase). + * + * The async variant is + * {@see DataMigrationServiceClient::resumeMigrationJobAsync()} . + * + * @param ResumeMigrationJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function resumeMigrationJob(ResumeMigrationJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ResumeMigrationJob', $request, $callOptions)->wait(); + } + + /** + * Rolls back a conversion workspace to the last committed snapshot. + * + * The async variant is + * {@see DataMigrationServiceClient::rollbackConversionWorkspaceAsync()} . + * + * @param RollbackConversionWorkspaceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function rollbackConversionWorkspace(RollbackConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RollbackConversionWorkspace', $request, $callOptions)->wait(); + } + + /** + * Searches/lists the background jobs for a specific + * conversion workspace. + * + * The background jobs are not resources like conversion workspaces or + * mapping rules, and they can't be created, updated or deleted. + * Instead, they are a way to expose the data plane jobs log. + * + * The async variant is + * {@see DataMigrationServiceClient::searchBackgroundJobsAsync()} . + * + * @param SearchBackgroundJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SearchBackgroundJobsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchBackgroundJobs(SearchBackgroundJobsRequest $request, array $callOptions = []): SearchBackgroundJobsResponse + { + return $this->startApiCall('SearchBackgroundJobs', $request, $callOptions)->wait(); + } + + /** + * Imports a snapshot of the source database into the + * conversion workspace. + * + * The async variant is + * {@see DataMigrationServiceClient::seedConversionWorkspaceAsync()} . + * + * @param SeedConversionWorkspaceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function seedConversionWorkspace(SeedConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SeedConversionWorkspace', $request, $callOptions)->wait(); + } + + /** + * Start an already created migration job. + * + * The async variant is {@see DataMigrationServiceClient::startMigrationJobAsync()} + * . + * + * @param StartMigrationJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function startMigrationJob(StartMigrationJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StartMigrationJob', $request, $callOptions)->wait(); + } + + /** + * Stops a running migration job. + * + * The async variant is {@see DataMigrationServiceClient::stopMigrationJobAsync()} + * . + * + * @param StopMigrationJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function stopMigrationJob(StopMigrationJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StopMigrationJob', $request, $callOptions)->wait(); + } + + /** + * Update the configuration of a single connection profile. + * + * The async variant is + * {@see DataMigrationServiceClient::updateConnectionProfileAsync()} . + * + * @param UpdateConnectionProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateConnectionProfile(UpdateConnectionProfileRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateConnectionProfile', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single conversion workspace. + * + * The async variant is + * {@see DataMigrationServiceClient::updateConversionWorkspaceAsync()} . + * + * @param UpdateConversionWorkspaceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateConversionWorkspace(UpdateConversionWorkspaceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateConversionWorkspace', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single migration job. + * + * The async variant is + * {@see DataMigrationServiceClient::updateMigrationJobAsync()} . + * + * @param UpdateMigrationJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateMigrationJob(UpdateMigrationJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateMigrationJob', $request, $callOptions)->wait(); + } + + /** + * Verify a migration job, making sure the destination can reach the source + * and that all configuration and prerequisites are met. + * + * The async variant is + * {@see DataMigrationServiceClient::verifyMigrationJobAsync()} . + * + * @param VerifyMigrationJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function verifyMigrationJob(VerifyMigrationJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('VerifyMigrationJob', $request, $callOptions)->wait(); + } } diff --git a/DocumentAi/composer.json b/DocumentAi/composer.json index 0f6273a37276..1057c7d6086f 100644 --- a/DocumentAi/composer.json +++ b/DocumentAi/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/DocumentAi/src/V1/Client/BaseClient/DocumentProcessorServiceBaseClient.php b/DocumentAi/src/V1/Client/BaseClient/DocumentProcessorServiceBaseClient.php deleted file mode 100644 index d47b6852c198..000000000000 --- a/DocumentAi/src/V1/Client/BaseClient/DocumentProcessorServiceBaseClient.php +++ /dev/null @@ -1,1001 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/document_processor_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/document_processor_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/document_processor_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/document_processor_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a evaluation - * resource. - * - * @param string $project - * @param string $location - * @param string $processor - * @param string $processorVersion - * @param string $evaluation - * - * @return string The formatted evaluation resource. - */ - public static function evaluationName(string $project, string $location, string $processor, string $processorVersion, string $evaluation): string - { - return self::getPathTemplate('evaluation')->render([ - 'project' => $project, - 'location' => $location, - 'processor' => $processor, - 'processor_version' => $processorVersion, - 'evaluation' => $evaluation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * human_review_config resource. - * - * @param string $project - * @param string $location - * @param string $processor - * - * @return string The formatted human_review_config resource. - */ - public static function humanReviewConfigName(string $project, string $location, string $processor): string - { - return self::getPathTemplate('humanReviewConfig')->render([ - 'project' => $project, - 'location' => $location, - 'processor' => $processor, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a processor - * resource. - * - * @param string $project - * @param string $location - * @param string $processor - * - * @return string The formatted processor resource. - */ - public static function processorName(string $project, string $location, string $processor): string - { - return self::getPathTemplate('processor')->render([ - 'project' => $project, - 'location' => $location, - 'processor' => $processor, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * processor_type resource. - * - * @param string $project - * @param string $location - * @param string $processorType - * - * @return string The formatted processor_type resource. - */ - public static function processorTypeName(string $project, string $location, string $processorType): string - { - return self::getPathTemplate('processorType')->render([ - 'project' => $project, - 'location' => $location, - 'processor_type' => $processorType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * processor_version resource. - * - * @param string $project - * @param string $location - * @param string $processor - * @param string $processorVersion - * - * @return string The formatted processor_version resource. - */ - public static function processorVersionName(string $project, string $location, string $processor, string $processorVersion): string - { - return self::getPathTemplate('processorVersion')->render([ - 'project' => $project, - 'location' => $location, - 'processor' => $processor, - 'processor_version' => $processorVersion, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - evaluation: projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}/evaluations/{evaluation} - * - humanReviewConfig: projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig - * - location: projects/{project}/locations/{location} - * - processor: projects/{project}/locations/{location}/processors/{processor} - * - processorType: projects/{project}/locations/{location}/processorTypes/{processor_type} - * - processorVersion: projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'documentai.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * LRO endpoint to batch process many documents. The output is written - * to Cloud Storage as JSON in the [Document] format. - * - * The async variant is {@see self::batchProcessDocumentsAsync()} . - * - * @param BatchProcessRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchProcessDocuments(BatchProcessRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BatchProcessDocuments', $request, $callOptions)->wait(); - } - - /** - * Creates a processor from the - * [ProcessorType][google.cloud.documentai.v1.ProcessorType] provided. The - * processor will be at `ENABLED` state by default after its creation. - * - * The async variant is {@see self::createProcessorAsync()} . - * - * @param CreateProcessorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Processor - * - * @throws ApiException Thrown if the API call fails. - */ - public function createProcessor(CreateProcessorRequest $request, array $callOptions = []): Processor - { - return $this->startApiCall('CreateProcessor', $request, $callOptions)->wait(); - } - - /** - * Deletes the processor, unloads all deployed model artifacts if it was - * enabled and then deletes all artifacts associated with this processor. - * - * The async variant is {@see self::deleteProcessorAsync()} . - * - * @param DeleteProcessorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteProcessor(DeleteProcessorRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteProcessor', $request, $callOptions)->wait(); - } - - /** - * Deletes the processor version, all artifacts under the processor version - * will be deleted. - * - * The async variant is {@see self::deleteProcessorVersionAsync()} . - * - * @param DeleteProcessorVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteProcessorVersion(DeleteProcessorVersionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteProcessorVersion', $request, $callOptions)->wait(); - } - - /** - * Deploys the processor version. - * - * The async variant is {@see self::deployProcessorVersionAsync()} . - * - * @param DeployProcessorVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deployProcessorVersion(DeployProcessorVersionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeployProcessorVersion', $request, $callOptions)->wait(); - } - - /** - * Disables a processor - * - * The async variant is {@see self::disableProcessorAsync()} . - * - * @param DisableProcessorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function disableProcessor(DisableProcessorRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DisableProcessor', $request, $callOptions)->wait(); - } - - /** - * Enables a processor - * - * The async variant is {@see self::enableProcessorAsync()} . - * - * @param EnableProcessorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function enableProcessor(EnableProcessorRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('EnableProcessor', $request, $callOptions)->wait(); - } - - /** - * Evaluates a ProcessorVersion against annotated documents, producing an - * Evaluation. - * - * The async variant is {@see self::evaluateProcessorVersionAsync()} . - * - * @param EvaluateProcessorVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function evaluateProcessorVersion(EvaluateProcessorVersionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('EvaluateProcessorVersion', $request, $callOptions)->wait(); - } - - /** - * Fetches processor types. Note that we don't use - * [ListProcessorTypes][google.cloud.documentai.v1.DocumentProcessorService.ListProcessorTypes] - * here, because it isn't paginated. - * - * The async variant is {@see self::fetchProcessorTypesAsync()} . - * - * @param FetchProcessorTypesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FetchProcessorTypesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function fetchProcessorTypes(FetchProcessorTypesRequest $request, array $callOptions = []): FetchProcessorTypesResponse - { - return $this->startApiCall('FetchProcessorTypes', $request, $callOptions)->wait(); - } - - /** - * Retrieves a specific evaluation. - * - * The async variant is {@see self::getEvaluationAsync()} . - * - * @param GetEvaluationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Evaluation - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEvaluation(GetEvaluationRequest $request, array $callOptions = []): Evaluation - { - return $this->startApiCall('GetEvaluation', $request, $callOptions)->wait(); - } - - /** - * Gets a processor detail. - * - * The async variant is {@see self::getProcessorAsync()} . - * - * @param GetProcessorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Processor - * - * @throws ApiException Thrown if the API call fails. - */ - public function getProcessor(GetProcessorRequest $request, array $callOptions = []): Processor - { - return $this->startApiCall('GetProcessor', $request, $callOptions)->wait(); - } - - /** - * Gets a processor type detail. - * - * The async variant is {@see self::getProcessorTypeAsync()} . - * - * @param GetProcessorTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ProcessorType - * - * @throws ApiException Thrown if the API call fails. - */ - public function getProcessorType(GetProcessorTypeRequest $request, array $callOptions = []): ProcessorType - { - return $this->startApiCall('GetProcessorType', $request, $callOptions)->wait(); - } - - /** - * Gets a processor version detail. - * - * The async variant is {@see self::getProcessorVersionAsync()} . - * - * @param GetProcessorVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ProcessorVersion - * - * @throws ApiException Thrown if the API call fails. - */ - public function getProcessorVersion(GetProcessorVersionRequest $request, array $callOptions = []): ProcessorVersion - { - return $this->startApiCall('GetProcessorVersion', $request, $callOptions)->wait(); - } - - /** - * Retrieves a set of evaluations for a given processor version. - * - * The async variant is {@see self::listEvaluationsAsync()} . - * - * @param ListEvaluationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listEvaluations(ListEvaluationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListEvaluations', $request, $callOptions); - } - - /** - * Lists the processor types that exist. - * - * The async variant is {@see self::listProcessorTypesAsync()} . - * - * @param ListProcessorTypesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listProcessorTypes(ListProcessorTypesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListProcessorTypes', $request, $callOptions); - } - - /** - * Lists all versions of a processor. - * - * The async variant is {@see self::listProcessorVersionsAsync()} . - * - * @param ListProcessorVersionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listProcessorVersions(ListProcessorVersionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListProcessorVersions', $request, $callOptions); - } - - /** - * Lists all processors which belong to this project. - * - * The async variant is {@see self::listProcessorsAsync()} . - * - * @param ListProcessorsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listProcessors(ListProcessorsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListProcessors', $request, $callOptions); - } - - /** - * Processes a single document. - * - * The async variant is {@see self::processDocumentAsync()} . - * - * @param ProcessRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ProcessResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function processDocument(ProcessRequest $request, array $callOptions = []): ProcessResponse - { - return $this->startApiCall('ProcessDocument', $request, $callOptions)->wait(); - } - - /** - * Send a document for Human Review. The input document should be processed by - * the specified processor. - * - * The async variant is {@see self::reviewDocumentAsync()} . - * - * @param ReviewDocumentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function reviewDocument(ReviewDocumentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ReviewDocument', $request, $callOptions)->wait(); - } - - /** - * Set the default (active) version of a - * [Processor][google.cloud.documentai.v1.Processor] that will be used in - * [ProcessDocument][google.cloud.documentai.v1.DocumentProcessorService.ProcessDocument] - * and - * [BatchProcessDocuments][google.cloud.documentai.v1.DocumentProcessorService.BatchProcessDocuments]. - * - * The async variant is {@see self::setDefaultProcessorVersionAsync()} . - * - * @param SetDefaultProcessorVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setDefaultProcessorVersion(SetDefaultProcessorVersionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetDefaultProcessorVersion', $request, $callOptions)->wait(); - } - - /** - * Trains a new processor version. - * Operation metadata is returned as - * [TrainProcessorVersionMetadata][google.cloud.documentai.v1.TrainProcessorVersionMetadata]. - * - * The async variant is {@see self::trainProcessorVersionAsync()} . - * - * @param TrainProcessorVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function trainProcessorVersion(TrainProcessorVersionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('TrainProcessorVersion', $request, $callOptions)->wait(); - } - - /** - * Undeploys the processor version. - * - * The async variant is {@see self::undeployProcessorVersionAsync()} . - * - * @param UndeployProcessorVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function undeployProcessorVersion(UndeployProcessorVersionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UndeployProcessorVersion', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/DocumentAi/src/V1/Client/DocumentProcessorServiceClient.php b/DocumentAi/src/V1/Client/DocumentProcessorServiceClient.php index e20c3315dbff..a0acdb124cfc 100644 --- a/DocumentAi/src/V1/Client/DocumentProcessorServiceClient.php +++ b/DocumentAi/src/V1/Client/DocumentProcessorServiceClient.php @@ -24,17 +24,999 @@ namespace Google\Cloud\DocumentAI\V1\Client; -use Google\Cloud\DocumentAI\V1\Client\BaseClient\DocumentProcessorServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\DocumentAI\V1\BatchProcessRequest; +use Google\Cloud\DocumentAI\V1\CreateProcessorRequest; +use Google\Cloud\DocumentAI\V1\DeleteProcessorRequest; +use Google\Cloud\DocumentAI\V1\DeleteProcessorVersionRequest; +use Google\Cloud\DocumentAI\V1\DeployProcessorVersionRequest; +use Google\Cloud\DocumentAI\V1\DisableProcessorRequest; +use Google\Cloud\DocumentAI\V1\EnableProcessorRequest; +use Google\Cloud\DocumentAI\V1\EvaluateProcessorVersionRequest; +use Google\Cloud\DocumentAI\V1\Evaluation; +use Google\Cloud\DocumentAI\V1\FetchProcessorTypesRequest; +use Google\Cloud\DocumentAI\V1\FetchProcessorTypesResponse; +use Google\Cloud\DocumentAI\V1\GetEvaluationRequest; +use Google\Cloud\DocumentAI\V1\GetProcessorRequest; +use Google\Cloud\DocumentAI\V1\GetProcessorTypeRequest; +use Google\Cloud\DocumentAI\V1\GetProcessorVersionRequest; +use Google\Cloud\DocumentAI\V1\ListEvaluationsRequest; +use Google\Cloud\DocumentAI\V1\ListProcessorTypesRequest; +use Google\Cloud\DocumentAI\V1\ListProcessorVersionsRequest; +use Google\Cloud\DocumentAI\V1\ListProcessorsRequest; +use Google\Cloud\DocumentAI\V1\ProcessRequest; +use Google\Cloud\DocumentAI\V1\ProcessResponse; +use Google\Cloud\DocumentAI\V1\Processor; +use Google\Cloud\DocumentAI\V1\ProcessorType; +use Google\Cloud\DocumentAI\V1\ProcessorVersion; +use Google\Cloud\DocumentAI\V1\ReviewDocumentRequest; +use Google\Cloud\DocumentAI\V1\SetDefaultProcessorVersionRequest; +use Google\Cloud\DocumentAI\V1\TrainProcessorVersionMetadata; +use Google\Cloud\DocumentAI\V1\TrainProcessorVersionRequest; +use Google\Cloud\DocumentAI\V1\UndeployProcessorVersionRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service to call Document AI to process documents according to the + * processor's definition. Processors are built using state-of-the-art Google + * AI such as natural language, computer vision, and translation to extract + * structured information from unstructured or semi-structured documents. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\DocumentAI\V1\DocumentProcessorServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface batchProcessDocumentsAsync(BatchProcessRequest $request, array $optionalArgs = []) + * @method PromiseInterface createProcessorAsync(CreateProcessorRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteProcessorAsync(DeleteProcessorRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteProcessorVersionAsync(DeleteProcessorVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deployProcessorVersionAsync(DeployProcessorVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface disableProcessorAsync(DisableProcessorRequest $request, array $optionalArgs = []) + * @method PromiseInterface enableProcessorAsync(EnableProcessorRequest $request, array $optionalArgs = []) + * @method PromiseInterface evaluateProcessorVersionAsync(EvaluateProcessorVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface fetchProcessorTypesAsync(FetchProcessorTypesRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEvaluationAsync(GetEvaluationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getProcessorAsync(GetProcessorRequest $request, array $optionalArgs = []) + * @method PromiseInterface getProcessorTypeAsync(GetProcessorTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getProcessorVersionAsync(GetProcessorVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface listEvaluationsAsync(ListEvaluationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listProcessorTypesAsync(ListProcessorTypesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listProcessorVersionsAsync(ListProcessorVersionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listProcessorsAsync(ListProcessorsRequest $request, array $optionalArgs = []) + * @method PromiseInterface processDocumentAsync(ProcessRequest $request, array $optionalArgs = []) + * @method PromiseInterface reviewDocumentAsync(ReviewDocumentRequest $request, array $optionalArgs = []) + * @method PromiseInterface setDefaultProcessorVersionAsync(SetDefaultProcessorVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface trainProcessorVersionAsync(TrainProcessorVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface undeployProcessorVersionAsync(UndeployProcessorVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class DocumentProcessorServiceClient extends DocumentProcessorServiceBaseClient +final class DocumentProcessorServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DocumentProcessorServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.documentai.v1.DocumentProcessorService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'documentai.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/document_processor_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/document_processor_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/document_processor_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/document_processor_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a evaluation + * resource. + * + * @param string $project + * @param string $location + * @param string $processor + * @param string $processorVersion + * @param string $evaluation + * + * @return string The formatted evaluation resource. + */ + public static function evaluationName(string $project, string $location, string $processor, string $processorVersion, string $evaluation): string + { + return self::getPathTemplate('evaluation')->render([ + 'project' => $project, + 'location' => $location, + 'processor' => $processor, + 'processor_version' => $processorVersion, + 'evaluation' => $evaluation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * human_review_config resource. + * + * @param string $project + * @param string $location + * @param string $processor + * + * @return string The formatted human_review_config resource. + */ + public static function humanReviewConfigName(string $project, string $location, string $processor): string + { + return self::getPathTemplate('humanReviewConfig')->render([ + 'project' => $project, + 'location' => $location, + 'processor' => $processor, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a processor + * resource. + * + * @param string $project + * @param string $location + * @param string $processor + * + * @return string The formatted processor resource. + */ + public static function processorName(string $project, string $location, string $processor): string + { + return self::getPathTemplate('processor')->render([ + 'project' => $project, + 'location' => $location, + 'processor' => $processor, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * processor_type resource. + * + * @param string $project + * @param string $location + * @param string $processorType + * + * @return string The formatted processor_type resource. + */ + public static function processorTypeName(string $project, string $location, string $processorType): string + { + return self::getPathTemplate('processorType')->render([ + 'project' => $project, + 'location' => $location, + 'processor_type' => $processorType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * processor_version resource. + * + * @param string $project + * @param string $location + * @param string $processor + * @param string $processorVersion + * + * @return string The formatted processor_version resource. + */ + public static function processorVersionName(string $project, string $location, string $processor, string $processorVersion): string + { + return self::getPathTemplate('processorVersion')->render([ + 'project' => $project, + 'location' => $location, + 'processor' => $processor, + 'processor_version' => $processorVersion, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - evaluation: projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}/evaluations/{evaluation} + * - humanReviewConfig: projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig + * - location: projects/{project}/locations/{location} + * - processor: projects/{project}/locations/{location}/processors/{processor} + * - processorType: projects/{project}/locations/{location}/processorTypes/{processor_type} + * - processorVersion: projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'documentai.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * LRO endpoint to batch process many documents. The output is written + * to Cloud Storage as JSON in the [Document] format. + * + * The async variant is + * {@see DocumentProcessorServiceClient::batchProcessDocumentsAsync()} . + * + * @param BatchProcessRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchProcessDocuments(BatchProcessRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchProcessDocuments', $request, $callOptions)->wait(); + } + + /** + * Creates a processor from the + * [ProcessorType][google.cloud.documentai.v1.ProcessorType] provided. The + * processor will be at `ENABLED` state by default after its creation. + * + * The async variant is + * {@see DocumentProcessorServiceClient::createProcessorAsync()} . + * + * @param CreateProcessorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Processor + * + * @throws ApiException Thrown if the API call fails. + */ + public function createProcessor(CreateProcessorRequest $request, array $callOptions = []): Processor + { + return $this->startApiCall('CreateProcessor', $request, $callOptions)->wait(); + } + + /** + * Deletes the processor, unloads all deployed model artifacts if it was + * enabled and then deletes all artifacts associated with this processor. + * + * The async variant is + * {@see DocumentProcessorServiceClient::deleteProcessorAsync()} . + * + * @param DeleteProcessorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteProcessor(DeleteProcessorRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteProcessor', $request, $callOptions)->wait(); + } + + /** + * Deletes the processor version, all artifacts under the processor version + * will be deleted. + * + * The async variant is + * {@see DocumentProcessorServiceClient::deleteProcessorVersionAsync()} . + * + * @param DeleteProcessorVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteProcessorVersion(DeleteProcessorVersionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteProcessorVersion', $request, $callOptions)->wait(); + } + + /** + * Deploys the processor version. + * + * The async variant is + * {@see DocumentProcessorServiceClient::deployProcessorVersionAsync()} . + * + * @param DeployProcessorVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deployProcessorVersion(DeployProcessorVersionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeployProcessorVersion', $request, $callOptions)->wait(); + } + + /** + * Disables a processor + * + * The async variant is + * {@see DocumentProcessorServiceClient::disableProcessorAsync()} . + * + * @param DisableProcessorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function disableProcessor(DisableProcessorRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DisableProcessor', $request, $callOptions)->wait(); + } + + /** + * Enables a processor + * + * The async variant is + * {@see DocumentProcessorServiceClient::enableProcessorAsync()} . + * + * @param EnableProcessorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function enableProcessor(EnableProcessorRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('EnableProcessor', $request, $callOptions)->wait(); + } + + /** + * Evaluates a ProcessorVersion against annotated documents, producing an + * Evaluation. + * + * The async variant is + * {@see DocumentProcessorServiceClient::evaluateProcessorVersionAsync()} . + * + * @param EvaluateProcessorVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function evaluateProcessorVersion(EvaluateProcessorVersionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('EvaluateProcessorVersion', $request, $callOptions)->wait(); + } + + /** + * Fetches processor types. Note that we don't use + * [ListProcessorTypes][google.cloud.documentai.v1.DocumentProcessorService.ListProcessorTypes] + * here, because it isn't paginated. + * + * The async variant is + * {@see DocumentProcessorServiceClient::fetchProcessorTypesAsync()} . + * + * @param FetchProcessorTypesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FetchProcessorTypesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function fetchProcessorTypes(FetchProcessorTypesRequest $request, array $callOptions = []): FetchProcessorTypesResponse + { + return $this->startApiCall('FetchProcessorTypes', $request, $callOptions)->wait(); + } + + /** + * Retrieves a specific evaluation. + * + * The async variant is {@see DocumentProcessorServiceClient::getEvaluationAsync()} + * . + * + * @param GetEvaluationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Evaluation + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEvaluation(GetEvaluationRequest $request, array $callOptions = []): Evaluation + { + return $this->startApiCall('GetEvaluation', $request, $callOptions)->wait(); + } + + /** + * Gets a processor detail. + * + * The async variant is {@see DocumentProcessorServiceClient::getProcessorAsync()} + * . + * + * @param GetProcessorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Processor + * + * @throws ApiException Thrown if the API call fails. + */ + public function getProcessor(GetProcessorRequest $request, array $callOptions = []): Processor + { + return $this->startApiCall('GetProcessor', $request, $callOptions)->wait(); + } + + /** + * Gets a processor type detail. + * + * The async variant is + * {@see DocumentProcessorServiceClient::getProcessorTypeAsync()} . + * + * @param GetProcessorTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ProcessorType + * + * @throws ApiException Thrown if the API call fails. + */ + public function getProcessorType(GetProcessorTypeRequest $request, array $callOptions = []): ProcessorType + { + return $this->startApiCall('GetProcessorType', $request, $callOptions)->wait(); + } + + /** + * Gets a processor version detail. + * + * The async variant is + * {@see DocumentProcessorServiceClient::getProcessorVersionAsync()} . + * + * @param GetProcessorVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ProcessorVersion + * + * @throws ApiException Thrown if the API call fails. + */ + public function getProcessorVersion(GetProcessorVersionRequest $request, array $callOptions = []): ProcessorVersion + { + return $this->startApiCall('GetProcessorVersion', $request, $callOptions)->wait(); + } + + /** + * Retrieves a set of evaluations for a given processor version. + * + * The async variant is + * {@see DocumentProcessorServiceClient::listEvaluationsAsync()} . + * + * @param ListEvaluationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listEvaluations(ListEvaluationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEvaluations', $request, $callOptions); + } + + /** + * Lists the processor types that exist. + * + * The async variant is + * {@see DocumentProcessorServiceClient::listProcessorTypesAsync()} . + * + * @param ListProcessorTypesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listProcessorTypes(ListProcessorTypesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListProcessorTypes', $request, $callOptions); + } + + /** + * Lists all versions of a processor. + * + * The async variant is + * {@see DocumentProcessorServiceClient::listProcessorVersionsAsync()} . + * + * @param ListProcessorVersionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listProcessorVersions(ListProcessorVersionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListProcessorVersions', $request, $callOptions); + } + + /** + * Lists all processors which belong to this project. + * + * The async variant is + * {@see DocumentProcessorServiceClient::listProcessorsAsync()} . + * + * @param ListProcessorsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listProcessors(ListProcessorsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListProcessors', $request, $callOptions); + } + + /** + * Processes a single document. + * + * The async variant is + * {@see DocumentProcessorServiceClient::processDocumentAsync()} . + * + * @param ProcessRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ProcessResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function processDocument(ProcessRequest $request, array $callOptions = []): ProcessResponse + { + return $this->startApiCall('ProcessDocument', $request, $callOptions)->wait(); + } + + /** + * Send a document for Human Review. The input document should be processed by + * the specified processor. + * + * The async variant is + * {@see DocumentProcessorServiceClient::reviewDocumentAsync()} . + * + * @param ReviewDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function reviewDocument(ReviewDocumentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ReviewDocument', $request, $callOptions)->wait(); + } + + /** + * Set the default (active) version of a + * [Processor][google.cloud.documentai.v1.Processor] that will be used in + * [ProcessDocument][google.cloud.documentai.v1.DocumentProcessorService.ProcessDocument] + * and + * [BatchProcessDocuments][google.cloud.documentai.v1.DocumentProcessorService.BatchProcessDocuments]. + * + * The async variant is + * {@see DocumentProcessorServiceClient::setDefaultProcessorVersionAsync()} . + * + * @param SetDefaultProcessorVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setDefaultProcessorVersion(SetDefaultProcessorVersionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetDefaultProcessorVersion', $request, $callOptions)->wait(); + } + + /** + * Trains a new processor version. + * Operation metadata is returned as + * [TrainProcessorVersionMetadata][google.cloud.documentai.v1.TrainProcessorVersionMetadata]. + * + * The async variant is + * {@see DocumentProcessorServiceClient::trainProcessorVersionAsync()} . + * + * @param TrainProcessorVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function trainProcessorVersion(TrainProcessorVersionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('TrainProcessorVersion', $request, $callOptions)->wait(); + } + + /** + * Undeploys the processor version. + * + * The async variant is + * {@see DocumentProcessorServiceClient::undeployProcessorVersionAsync()} . + * + * @param UndeployProcessorVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function undeployProcessorVersion(UndeployProcessorVersionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UndeployProcessorVersion', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see DocumentProcessorServiceClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see DocumentProcessorServiceClient::listLocationsAsync()} + * . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/DocumentAi/src/V1/ProcessOptions.php b/DocumentAi/src/V1/ProcessOptions.php index 624ca6530ea5..d735fc5b057a 100644 --- a/DocumentAi/src/V1/ProcessOptions.php +++ b/DocumentAi/src/V1/ProcessOptions.php @@ -33,8 +33,8 @@ class ProcessOptions extends \Google\Protobuf\Internal\Message * @type \Google\Cloud\DocumentAI\V1\ProcessOptions\IndividualPageSelector $individual_page_selector * Which pages to process (1-indexed). * @type int $from_start - * Only process certain pages from the start. Process all if the document - * has fewer pages. + * Only process certain pages from the start, process all if the document + * has less pages. * @type int $from_end * Only process certain pages from the end, same as above. * @type \Google\Cloud\DocumentAI\V1\OcrConfig $ocr_config @@ -79,8 +79,8 @@ public function setIndividualPageSelector($var) } /** - * Only process certain pages from the start. Process all if the document - * has fewer pages. + * Only process certain pages from the start, process all if the document + * has less pages. * * Generated from protobuf field int32 from_start = 6; * @return int @@ -96,8 +96,8 @@ public function hasFromStart() } /** - * Only process certain pages from the start. Process all if the document - * has fewer pages. + * Only process certain pages from the start, process all if the document + * has less pages. * * Generated from protobuf field int32 from_start = 6; * @param int $var diff --git a/Domains/composer.json b/Domains/composer.json index 2e8c7db26342..20be872aa9a0 100644 --- a/Domains/composer.json +++ b/Domains/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Domains/src/V1/Client/BaseClient/DomainsBaseClient.php b/Domains/src/V1/Client/BaseClient/DomainsBaseClient.php deleted file mode 100644 index 0f53fd261284..000000000000 --- a/Domains/src/V1/Client/BaseClient/DomainsBaseClient.php +++ /dev/null @@ -1,769 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/domains_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/domains_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/domains_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/domains_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a registration - * resource. - * - * @param string $project - * @param string $location - * @param string $registration - * - * @return string The formatted registration resource. - */ - public static function registrationName(string $project, string $location, string $registration): string - { - return self::getPathTemplate('registration')->render([ - 'project' => $project, - 'location' => $location, - 'registration' => $registration, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - location: projects/{project}/locations/{location} - * - registration: projects/{project}/locations/{location}/registrations/{registration} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'domains.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Updates a `Registration`'s contact settings. Some changes require - * confirmation by the domain's registrant contact . - * - * The async variant is {@see self::configureContactSettingsAsync()} . - * - * @example samples/V1/DomainsClient/configure_contact_settings.php - * - * @param ConfigureContactSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function configureContactSettings(ConfigureContactSettingsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ConfigureContactSettings', $request, $callOptions)->wait(); - } - - /** - * Updates a `Registration`'s DNS settings. - * - * The async variant is {@see self::configureDnsSettingsAsync()} . - * - * @example samples/V1/DomainsClient/configure_dns_settings.php - * - * @param ConfigureDnsSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function configureDnsSettings(ConfigureDnsSettingsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ConfigureDnsSettings', $request, $callOptions)->wait(); - } - - /** - * Updates a `Registration`'s management settings. - * - * The async variant is {@see self::configureManagementSettingsAsync()} . - * - * @example samples/V1/DomainsClient/configure_management_settings.php - * - * @param ConfigureManagementSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function configureManagementSettings(ConfigureManagementSettingsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ConfigureManagementSettings', $request, $callOptions)->wait(); - } - - /** - * Deletes a `Registration` resource. - * - * This method works on any `Registration` resource using [Subscription or - * Commitment billing](https://cloud.google.com/domains/pricing#billing-models), provided that the - * resource was created at least 1 day in the past. - * - * For `Registration` resources using - * [Monthly billing](https://cloud.google.com/domains/pricing#billing-models), this method works if: - * - * * `state` is `EXPORTED` with `expire_time` in the past - * * `state` is `REGISTRATION_FAILED` - * * `state` is `TRANSFER_FAILED` - * - * When an active registration is successfully deleted, you can continue to - * use the domain in [Google Domains](https://domains.google/) until it - * expires. The calling user becomes the domain's sole owner in Google - * Domains, and permissions for the domain are subsequently managed there. The - * domain does not renew automatically unless the new owner sets up billing in - * Google Domains. - * - * The async variant is {@see self::deleteRegistrationAsync()} . - * - * @example samples/V1/DomainsClient/delete_registration.php - * - * @param DeleteRegistrationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteRegistration(DeleteRegistrationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteRegistration', $request, $callOptions)->wait(); - } - - /** - * Exports a `Registration` resource, such that it is no longer managed by - * Cloud Domains. - * - * When an active domain is successfully exported, you can continue to use the - * domain in [Google Domains](https://domains.google/) until it expires. The - * calling user becomes the domain's sole owner in Google Domains, and - * permissions for the domain are subsequently managed there. The domain does - * not renew automatically unless the new owner sets up billing in Google - * Domains. - * - * The async variant is {@see self::exportRegistrationAsync()} . - * - * @example samples/V1/DomainsClient/export_registration.php - * - * @param ExportRegistrationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function exportRegistration(ExportRegistrationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ExportRegistration', $request, $callOptions)->wait(); - } - - /** - * Gets the details of a `Registration` resource. - * - * The async variant is {@see self::getRegistrationAsync()} . - * - * @example samples/V1/DomainsClient/get_registration.php - * - * @param GetRegistrationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Registration - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRegistration(GetRegistrationRequest $request, array $callOptions = []): Registration - { - return $this->startApiCall('GetRegistration', $request, $callOptions)->wait(); - } - - /** - * Lists the `Registration` resources in a project. - * - * The async variant is {@see self::listRegistrationsAsync()} . - * - * @example samples/V1/DomainsClient/list_registrations.php - * - * @param ListRegistrationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listRegistrations(ListRegistrationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListRegistrations', $request, $callOptions); - } - - /** - * Registers a new domain name and creates a corresponding `Registration` - * resource. - * - * Call `RetrieveRegisterParameters` first to check availability of the domain - * name and determine parameters like price that are needed to build a call to - * this method. - * - * A successful call creates a `Registration` resource in state - * `REGISTRATION_PENDING`, which resolves to `ACTIVE` within 1-2 - * minutes, indicating that the domain was successfully registered. If the - * resource ends up in state `REGISTRATION_FAILED`, it indicates that the - * domain was not registered successfully, and you can safely delete the - * resource and retry registration. - * - * The async variant is {@see self::registerDomainAsync()} . - * - * @example samples/V1/DomainsClient/register_domain.php - * - * @param RegisterDomainRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function registerDomain(RegisterDomainRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RegisterDomain', $request, $callOptions)->wait(); - } - - /** - * Resets the authorization code of the `Registration` to a new random string. - * - * You can call this method only after 60 days have elapsed since the initial - * domain registration. - * - * The async variant is {@see self::resetAuthorizationCodeAsync()} . - * - * @example samples/V1/DomainsClient/reset_authorization_code.php - * - * @param ResetAuthorizationCodeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AuthorizationCode - * - * @throws ApiException Thrown if the API call fails. - */ - public function resetAuthorizationCode(ResetAuthorizationCodeRequest $request, array $callOptions = []): AuthorizationCode - { - return $this->startApiCall('ResetAuthorizationCode', $request, $callOptions)->wait(); - } - - /** - * Gets the authorization code of the `Registration` for the purpose of - * transferring the domain to another registrar. - * - * You can call this method only after 60 days have elapsed since the initial - * domain registration. - * - * The async variant is {@see self::retrieveAuthorizationCodeAsync()} . - * - * @example samples/V1/DomainsClient/retrieve_authorization_code.php - * - * @param RetrieveAuthorizationCodeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AuthorizationCode - * - * @throws ApiException Thrown if the API call fails. - */ - public function retrieveAuthorizationCode(RetrieveAuthorizationCodeRequest $request, array $callOptions = []): AuthorizationCode - { - return $this->startApiCall('RetrieveAuthorizationCode', $request, $callOptions)->wait(); - } - - /** - * Gets parameters needed to register a new domain name, including price and - * up-to-date availability. Use the returned values to call `RegisterDomain`. - * - * The async variant is {@see self::retrieveRegisterParametersAsync()} . - * - * @example samples/V1/DomainsClient/retrieve_register_parameters.php - * - * @param RetrieveRegisterParametersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RetrieveRegisterParametersResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function retrieveRegisterParameters(RetrieveRegisterParametersRequest $request, array $callOptions = []): RetrieveRegisterParametersResponse - { - return $this->startApiCall('RetrieveRegisterParameters', $request, $callOptions)->wait(); - } - - /** - * Gets parameters needed to transfer a domain name from another registrar to - * Cloud Domains. For domains managed by Google Domains, transferring to Cloud - * Domains is not supported. - * - * - * Use the returned values to call `TransferDomain`. - * - * The async variant is {@see self::retrieveTransferParametersAsync()} . - * - * @example samples/V1/DomainsClient/retrieve_transfer_parameters.php - * - * @param RetrieveTransferParametersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RetrieveTransferParametersResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function retrieveTransferParameters(RetrieveTransferParametersRequest $request, array $callOptions = []): RetrieveTransferParametersResponse - { - return $this->startApiCall('RetrieveTransferParameters', $request, $callOptions)->wait(); - } - - /** - * Searches for available domain names similar to the provided query. - * - * Availability results from this method are approximate; call - * `RetrieveRegisterParameters` on a domain before registering to confirm - * availability. - * - * The async variant is {@see self::searchDomainsAsync()} . - * - * @example samples/V1/DomainsClient/search_domains.php - * - * @param SearchDomainsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SearchDomainsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchDomains(SearchDomainsRequest $request, array $callOptions = []): SearchDomainsResponse - { - return $this->startApiCall('SearchDomains', $request, $callOptions)->wait(); - } - - /** - * Transfers a domain name from another registrar to Cloud Domains. For - * domains managed by Google Domains, transferring to Cloud Domains is not - * supported. - * - * - * Before calling this method, go to the domain's current registrar to unlock - * the domain for transfer and retrieve the domain's transfer authorization - * code. Then call `RetrieveTransferParameters` to confirm that the domain is - * unlocked and to get values needed to build a call to this method. - * - * A successful call creates a `Registration` resource in state - * `TRANSFER_PENDING`. It can take several days to complete the transfer - * process. The registrant can often speed up this process by approving the - * transfer through the current registrar, either by clicking a link in an - * email from the registrar or by visiting the registrar's website. - * - * A few minutes after transfer approval, the resource transitions to state - * `ACTIVE`, indicating that the transfer was successful. If the transfer is - * rejected or the request expires without being approved, the resource can - * end up in state `TRANSFER_FAILED`. If transfer fails, you can safely delete - * the resource and retry the transfer. - * - * The async variant is {@see self::transferDomainAsync()} . - * - * @example samples/V1/DomainsClient/transfer_domain.php - * - * @param TransferDomainRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function transferDomain(TransferDomainRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('TransferDomain', $request, $callOptions)->wait(); - } - - /** - * Updates select fields of a `Registration` resource, notably `labels`. To - * update other fields, use the appropriate custom update method: - * - * * To update management settings, see `ConfigureManagementSettings` - * * To update DNS configuration, see `ConfigureDnsSettings` - * * To update contact information, see `ConfigureContactSettings` - * - * The async variant is {@see self::updateRegistrationAsync()} . - * - * @example samples/V1/DomainsClient/update_registration.php - * - * @param UpdateRegistrationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateRegistration(UpdateRegistrationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateRegistration', $request, $callOptions)->wait(); - } -} diff --git a/Domains/src/V1/Client/DomainsClient.php b/Domains/src/V1/Client/DomainsClient.php index 218ef6e8f0d5..c486729d68b7 100644 --- a/Domains/src/V1/Client/DomainsClient.php +++ b/Domains/src/V1/Client/DomainsClient.php @@ -24,17 +24,744 @@ namespace Google\Cloud\Domains\V1\Client; -use Google\Cloud\Domains\V1\Client\BaseClient\DomainsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Domains\V1\AuthorizationCode; +use Google\Cloud\Domains\V1\ConfigureContactSettingsRequest; +use Google\Cloud\Domains\V1\ConfigureDnsSettingsRequest; +use Google\Cloud\Domains\V1\ConfigureManagementSettingsRequest; +use Google\Cloud\Domains\V1\DeleteRegistrationRequest; +use Google\Cloud\Domains\V1\ExportRegistrationRequest; +use Google\Cloud\Domains\V1\GetRegistrationRequest; +use Google\Cloud\Domains\V1\ListRegistrationsRequest; +use Google\Cloud\Domains\V1\RegisterDomainRequest; +use Google\Cloud\Domains\V1\Registration; +use Google\Cloud\Domains\V1\ResetAuthorizationCodeRequest; +use Google\Cloud\Domains\V1\RetrieveAuthorizationCodeRequest; +use Google\Cloud\Domains\V1\RetrieveRegisterParametersRequest; +use Google\Cloud\Domains\V1\RetrieveRegisterParametersResponse; +use Google\Cloud\Domains\V1\RetrieveTransferParametersRequest; +use Google\Cloud\Domains\V1\RetrieveTransferParametersResponse; +use Google\Cloud\Domains\V1\SearchDomainsRequest; +use Google\Cloud\Domains\V1\SearchDomainsResponse; +use Google\Cloud\Domains\V1\TransferDomainRequest; +use Google\Cloud\Domains\V1\UpdateRegistrationRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Cloud Domains API enables management and configuration of domain names. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface configureContactSettingsAsync(ConfigureContactSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface configureDnsSettingsAsync(ConfigureDnsSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface configureManagementSettingsAsync(ConfigureManagementSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteRegistrationAsync(DeleteRegistrationRequest $request, array $optionalArgs = []) + * @method PromiseInterface exportRegistrationAsync(ExportRegistrationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRegistrationAsync(GetRegistrationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listRegistrationsAsync(ListRegistrationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface registerDomainAsync(RegisterDomainRequest $request, array $optionalArgs = []) + * @method PromiseInterface resetAuthorizationCodeAsync(ResetAuthorizationCodeRequest $request, array $optionalArgs = []) + * @method PromiseInterface retrieveAuthorizationCodeAsync(RetrieveAuthorizationCodeRequest $request, array $optionalArgs = []) + * @method PromiseInterface retrieveRegisterParametersAsync(RetrieveRegisterParametersRequest $request, array $optionalArgs = []) + * @method PromiseInterface retrieveTransferParametersAsync(RetrieveTransferParametersRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchDomainsAsync(SearchDomainsRequest $request, array $optionalArgs = []) + * @method PromiseInterface transferDomainAsync(TransferDomainRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateRegistrationAsync(UpdateRegistrationRequest $request, array $optionalArgs = []) */ -final class DomainsClient extends DomainsBaseClient +final class DomainsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DomainsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.domains.v1.Domains'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'domains.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/domains_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/domains_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/domains_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/domains_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a registration + * resource. + * + * @param string $project + * @param string $location + * @param string $registration + * + * @return string The formatted registration resource. + */ + public static function registrationName(string $project, string $location, string $registration): string + { + return self::getPathTemplate('registration')->render([ + 'project' => $project, + 'location' => $location, + 'registration' => $registration, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - location: projects/{project}/locations/{location} + * - registration: projects/{project}/locations/{location}/registrations/{registration} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'domains.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Updates a `Registration`'s contact settings. Some changes require + * confirmation by the domain's registrant contact . + * + * The async variant is {@see DomainsClient::configureContactSettingsAsync()} . + * + * @example samples/V1/DomainsClient/configure_contact_settings.php + * + * @param ConfigureContactSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function configureContactSettings(ConfigureContactSettingsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ConfigureContactSettings', $request, $callOptions)->wait(); + } + + /** + * Updates a `Registration`'s DNS settings. + * + * The async variant is {@see DomainsClient::configureDnsSettingsAsync()} . + * + * @example samples/V1/DomainsClient/configure_dns_settings.php + * + * @param ConfigureDnsSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function configureDnsSettings(ConfigureDnsSettingsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ConfigureDnsSettings', $request, $callOptions)->wait(); + } + + /** + * Updates a `Registration`'s management settings. + * + * The async variant is {@see DomainsClient::configureManagementSettingsAsync()} . + * + * @example samples/V1/DomainsClient/configure_management_settings.php + * + * @param ConfigureManagementSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function configureManagementSettings(ConfigureManagementSettingsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ConfigureManagementSettings', $request, $callOptions)->wait(); + } + + /** + * Deletes a `Registration` resource. + * + * This method works on any `Registration` resource using [Subscription or + * Commitment billing](https://cloud.google.com/domains/pricing#billing-models), provided that the + * resource was created at least 1 day in the past. + * + * For `Registration` resources using + * [Monthly billing](https://cloud.google.com/domains/pricing#billing-models), this method works if: + * + * * `state` is `EXPORTED` with `expire_time` in the past + * * `state` is `REGISTRATION_FAILED` + * * `state` is `TRANSFER_FAILED` + * + * When an active registration is successfully deleted, you can continue to + * use the domain in [Google Domains](https://domains.google/) until it + * expires. The calling user becomes the domain's sole owner in Google + * Domains, and permissions for the domain are subsequently managed there. The + * domain does not renew automatically unless the new owner sets up billing in + * Google Domains. + * + * The async variant is {@see DomainsClient::deleteRegistrationAsync()} . + * + * @example samples/V1/DomainsClient/delete_registration.php + * + * @param DeleteRegistrationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteRegistration(DeleteRegistrationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteRegistration', $request, $callOptions)->wait(); + } + + /** + * Exports a `Registration` resource, such that it is no longer managed by + * Cloud Domains. + * + * When an active domain is successfully exported, you can continue to use the + * domain in [Google Domains](https://domains.google/) until it expires. The + * calling user becomes the domain's sole owner in Google Domains, and + * permissions for the domain are subsequently managed there. The domain does + * not renew automatically unless the new owner sets up billing in Google + * Domains. + * + * The async variant is {@see DomainsClient::exportRegistrationAsync()} . + * + * @example samples/V1/DomainsClient/export_registration.php + * + * @param ExportRegistrationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportRegistration(ExportRegistrationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ExportRegistration', $request, $callOptions)->wait(); + } + + /** + * Gets the details of a `Registration` resource. + * + * The async variant is {@see DomainsClient::getRegistrationAsync()} . + * + * @example samples/V1/DomainsClient/get_registration.php + * + * @param GetRegistrationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Registration + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRegistration(GetRegistrationRequest $request, array $callOptions = []): Registration + { + return $this->startApiCall('GetRegistration', $request, $callOptions)->wait(); + } + + /** + * Lists the `Registration` resources in a project. + * + * The async variant is {@see DomainsClient::listRegistrationsAsync()} . + * + * @example samples/V1/DomainsClient/list_registrations.php + * + * @param ListRegistrationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listRegistrations(ListRegistrationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListRegistrations', $request, $callOptions); + } + + /** + * Registers a new domain name and creates a corresponding `Registration` + * resource. + * + * Call `RetrieveRegisterParameters` first to check availability of the domain + * name and determine parameters like price that are needed to build a call to + * this method. + * + * A successful call creates a `Registration` resource in state + * `REGISTRATION_PENDING`, which resolves to `ACTIVE` within 1-2 + * minutes, indicating that the domain was successfully registered. If the + * resource ends up in state `REGISTRATION_FAILED`, it indicates that the + * domain was not registered successfully, and you can safely delete the + * resource and retry registration. + * + * The async variant is {@see DomainsClient::registerDomainAsync()} . + * + * @example samples/V1/DomainsClient/register_domain.php + * + * @param RegisterDomainRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function registerDomain(RegisterDomainRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RegisterDomain', $request, $callOptions)->wait(); + } + + /** + * Resets the authorization code of the `Registration` to a new random string. + * + * You can call this method only after 60 days have elapsed since the initial + * domain registration. + * + * The async variant is {@see DomainsClient::resetAuthorizationCodeAsync()} . + * + * @example samples/V1/DomainsClient/reset_authorization_code.php + * + * @param ResetAuthorizationCodeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AuthorizationCode + * + * @throws ApiException Thrown if the API call fails. + */ + public function resetAuthorizationCode(ResetAuthorizationCodeRequest $request, array $callOptions = []): AuthorizationCode + { + return $this->startApiCall('ResetAuthorizationCode', $request, $callOptions)->wait(); + } + + /** + * Gets the authorization code of the `Registration` for the purpose of + * transferring the domain to another registrar. + * + * You can call this method only after 60 days have elapsed since the initial + * domain registration. + * + * The async variant is {@see DomainsClient::retrieveAuthorizationCodeAsync()} . + * + * @example samples/V1/DomainsClient/retrieve_authorization_code.php + * + * @param RetrieveAuthorizationCodeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AuthorizationCode + * + * @throws ApiException Thrown if the API call fails. + */ + public function retrieveAuthorizationCode(RetrieveAuthorizationCodeRequest $request, array $callOptions = []): AuthorizationCode + { + return $this->startApiCall('RetrieveAuthorizationCode', $request, $callOptions)->wait(); + } + + /** + * Gets parameters needed to register a new domain name, including price and + * up-to-date availability. Use the returned values to call `RegisterDomain`. + * + * The async variant is {@see DomainsClient::retrieveRegisterParametersAsync()} . + * + * @example samples/V1/DomainsClient/retrieve_register_parameters.php + * + * @param RetrieveRegisterParametersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RetrieveRegisterParametersResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function retrieveRegisterParameters(RetrieveRegisterParametersRequest $request, array $callOptions = []): RetrieveRegisterParametersResponse + { + return $this->startApiCall('RetrieveRegisterParameters', $request, $callOptions)->wait(); + } + + /** + * Gets parameters needed to transfer a domain name from another registrar to + * Cloud Domains. For domains managed by Google Domains, transferring to Cloud + * Domains is not supported. + * + * + * Use the returned values to call `TransferDomain`. + * + * The async variant is {@see DomainsClient::retrieveTransferParametersAsync()} . + * + * @example samples/V1/DomainsClient/retrieve_transfer_parameters.php + * + * @param RetrieveTransferParametersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RetrieveTransferParametersResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function retrieveTransferParameters(RetrieveTransferParametersRequest $request, array $callOptions = []): RetrieveTransferParametersResponse + { + return $this->startApiCall('RetrieveTransferParameters', $request, $callOptions)->wait(); + } + + /** + * Searches for available domain names similar to the provided query. + * + * Availability results from this method are approximate; call + * `RetrieveRegisterParameters` on a domain before registering to confirm + * availability. + * + * The async variant is {@see DomainsClient::searchDomainsAsync()} . + * + * @example samples/V1/DomainsClient/search_domains.php + * + * @param SearchDomainsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SearchDomainsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchDomains(SearchDomainsRequest $request, array $callOptions = []): SearchDomainsResponse + { + return $this->startApiCall('SearchDomains', $request, $callOptions)->wait(); + } + + /** + * Transfers a domain name from another registrar to Cloud Domains. For + * domains managed by Google Domains, transferring to Cloud Domains is not + * supported. + * + * + * Before calling this method, go to the domain's current registrar to unlock + * the domain for transfer and retrieve the domain's transfer authorization + * code. Then call `RetrieveTransferParameters` to confirm that the domain is + * unlocked and to get values needed to build a call to this method. + * + * A successful call creates a `Registration` resource in state + * `TRANSFER_PENDING`. It can take several days to complete the transfer + * process. The registrant can often speed up this process by approving the + * transfer through the current registrar, either by clicking a link in an + * email from the registrar or by visiting the registrar's website. + * + * A few minutes after transfer approval, the resource transitions to state + * `ACTIVE`, indicating that the transfer was successful. If the transfer is + * rejected or the request expires without being approved, the resource can + * end up in state `TRANSFER_FAILED`. If transfer fails, you can safely delete + * the resource and retry the transfer. + * + * The async variant is {@see DomainsClient::transferDomainAsync()} . + * + * @example samples/V1/DomainsClient/transfer_domain.php + * + * @param TransferDomainRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function transferDomain(TransferDomainRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('TransferDomain', $request, $callOptions)->wait(); + } + + /** + * Updates select fields of a `Registration` resource, notably `labels`. To + * update other fields, use the appropriate custom update method: + * + * * To update management settings, see `ConfigureManagementSettings` + * * To update DNS configuration, see `ConfigureDnsSettings` + * * To update contact information, see `ConfigureContactSettings` + * + * The async variant is {@see DomainsClient::updateRegistrationAsync()} . + * + * @example samples/V1/DomainsClient/update_registration.php + * + * @param UpdateRegistrationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateRegistration(UpdateRegistrationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateRegistration', $request, $callOptions)->wait(); + } } diff --git a/ErrorReporting/composer.json b/ErrorReporting/composer.json index c5e80098d65e..c26a617c319d 100644 --- a/ErrorReporting/composer.json +++ b/ErrorReporting/composer.json @@ -6,12 +6,12 @@ "require": { "php": ">=7.4", "google/cloud-logging": "^1.16", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", "phpspec/prophecy-phpunit": "^2.0", - "google/cloud-core": "^1.39" + "google/cloud-core": "^1.52.7" }, "suggest": { "ext-grpc": "The gRPC extension allows more granular control over Error Reporting", diff --git a/ErrorReporting/src/V1beta1/Client/BaseClient/ErrorGroupServiceBaseClient.php b/ErrorReporting/src/V1beta1/Client/BaseClient/ErrorGroupServiceBaseClient.php deleted file mode 100644 index 6d2b1a151fbc..000000000000 --- a/ErrorReporting/src/V1beta1/Client/BaseClient/ErrorGroupServiceBaseClient.php +++ /dev/null @@ -1,277 +0,0 @@ - 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', - ], - ], - ]; - } - - /** - * 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(string $project, string $group): string - { - return self::getPathTemplate('errorGroup')->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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Get the specified group. - * - * The async variant is {@see self::getGroupAsync()} . - * - * @example samples/V1beta1/ErrorGroupServiceClient/get_group.php - * - * @param GetGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ErrorGroup - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getGroup(GetGroupRequest $request, array $callOptions = []): ErrorGroup - { - return $this->startApiCall('GetGroup', $request, $callOptions)->wait(); - } - - /** - * Replace the data for the specified group. - * Fails if the group does not exist. - * - * The async variant is {@see self::updateGroupAsync()} . - * - * @example samples/V1beta1/ErrorGroupServiceClient/update_group.php - * - * @param UpdateGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ErrorGroup - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function updateGroup(UpdateGroupRequest $request, array $callOptions = []): ErrorGroup - { - return $this->startApiCall('UpdateGroup', $request, $callOptions)->wait(); - } -} diff --git a/ErrorReporting/src/V1beta1/Client/BaseClient/ReportErrorsServiceBaseClient.php b/ErrorReporting/src/V1beta1/Client/BaseClient/ReportErrorsServiceBaseClient.php deleted file mode 100644 index a9d30bd0b9c5..000000000000 --- a/ErrorReporting/src/V1beta1/Client/BaseClient/ReportErrorsServiceBaseClient.php +++ /dev/null @@ -1,257 +0,0 @@ - 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', - ], - ], - ]; - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * 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 global service built - * on Cloud Logging and doesn't analyze logs stored - * in regional log buckets or logs routed to other Google Cloud projects. - * - * - * The async variant is {@see self::reportErrorEventAsync()} . - * - * @example samples/V1beta1/ReportErrorsServiceClient/report_error_event.php - * - * @param ReportErrorEventRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ReportErrorEventResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function reportErrorEvent(ReportErrorEventRequest $request, array $callOptions = []): ReportErrorEventResponse - { - return $this->startApiCall('ReportErrorEvent', $request, $callOptions)->wait(); - } -} diff --git a/ErrorReporting/src/V1beta1/Client/ErrorGroupServiceClient.php b/ErrorReporting/src/V1beta1/Client/ErrorGroupServiceClient.php index 26ac1a62d22d..6ee8bf2d4fd4 100644 --- a/ErrorReporting/src/V1beta1/Client/ErrorGroupServiceClient.php +++ b/ErrorReporting/src/V1beta1/Client/ErrorGroupServiceClient.php @@ -26,17 +26,250 @@ namespace Google\Cloud\ErrorReporting\V1beta1\Client; -use Google\Cloud\ErrorReporting\V1beta1\Client\BaseClient\ErrorGroupServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\ErrorReporting\V1beta1\ErrorGroup; +use Google\Cloud\ErrorReporting\V1beta1\GetGroupRequest; +use Google\Cloud\ErrorReporting\V1beta1\UpdateGroupRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for retrieving and updating individual error groups. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface getGroupAsync(GetGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateGroupAsync(UpdateGroupRequest $request, array $optionalArgs = []) */ -final class ErrorGroupServiceClient extends ErrorGroupServiceBaseClient +final class ErrorGroupServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ErrorGroupServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.devtools.clouderrorreporting.v1beta1.ErrorGroupService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'clouderrorreporting.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + 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', + ], + ], + ]; + } + + /** + * 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(string $project, string $group): string + { + return self::getPathTemplate('errorGroup')->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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Get the specified group. + * + * The async variant is {@see ErrorGroupServiceClient::getGroupAsync()} . + * + * @example samples/V1beta1/ErrorGroupServiceClient/get_group.php + * + * @param GetGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ErrorGroup + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getGroup(GetGroupRequest $request, array $callOptions = []): ErrorGroup + { + return $this->startApiCall('GetGroup', $request, $callOptions)->wait(); + } + + /** + * Replace the data for the specified group. + * Fails if the group does not exist. + * + * The async variant is {@see ErrorGroupServiceClient::updateGroupAsync()} . + * + * @example samples/V1beta1/ErrorGroupServiceClient/update_group.php + * + * @param UpdateGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ErrorGroup + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function updateGroup(UpdateGroupRequest $request, array $callOptions = []): ErrorGroup + { + return $this->startApiCall('UpdateGroup', $request, $callOptions)->wait(); + } } diff --git a/ErrorReporting/src/V1beta1/Client/ErrorStatsServiceClient.php b/ErrorReporting/src/V1beta1/Client/ErrorStatsServiceClient.php index 7800317b4413..19d0fcaf8fb7 100644 --- a/ErrorReporting/src/V1beta1/Client/ErrorStatsServiceClient.php +++ b/ErrorReporting/src/V1beta1/Client/ErrorStatsServiceClient.php @@ -26,17 +26,279 @@ namespace Google\Cloud\ErrorReporting\V1beta1\Client; -use Google\Cloud\ErrorReporting\V1beta1\Client\BaseClient\ErrorStatsServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\ErrorReporting\V1beta1\DeleteEventsRequest; +use Google\Cloud\ErrorReporting\V1beta1\DeleteEventsResponse; +use Google\Cloud\ErrorReporting\V1beta1\ListEventsRequest; +use Google\Cloud\ErrorReporting\V1beta1\ListGroupStatsRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: An API for retrieving and managing error statistics as well as data for + * individual events. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface deleteEventsAsync(DeleteEventsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listEventsAsync(ListEventsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listGroupStatsAsync(ListGroupStatsRequest $request, array $optionalArgs = []) */ -final class ErrorStatsServiceClient extends ErrorStatsServiceBaseClient +final class ErrorStatsServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ErrorStatsServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.devtools.clouderrorreporting.v1beta1.ErrorStatsService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'clouderrorreporting.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + 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', + ], + ], + ]; + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes all error events of a given project. + * + * The async variant is {@see ErrorStatsServiceClient::deleteEventsAsync()} . + * + * @example samples/V1beta1/ErrorStatsServiceClient/delete_events.php + * + * @param DeleteEventsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DeleteEventsResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteEvents(DeleteEventsRequest $request, array $callOptions = []): DeleteEventsResponse + { + return $this->startApiCall('DeleteEvents', $request, $callOptions)->wait(); + } + + /** + * Lists the specified events. + * + * The async variant is {@see ErrorStatsServiceClient::listEventsAsync()} . + * + * @example samples/V1beta1/ErrorStatsServiceClient/list_events.php + * + * @param ListEventsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listEvents(ListEventsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEvents', $request, $callOptions); + } + + /** + * Lists the specified groups. + * + * The async variant is {@see ErrorStatsServiceClient::listGroupStatsAsync()} . + * + * @example samples/V1beta1/ErrorStatsServiceClient/list_group_stats.php + * + * @param ListGroupStatsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listGroupStats(ListGroupStatsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListGroupStats', $request, $callOptions); + } } diff --git a/ErrorReporting/src/V1beta1/Client/ReportErrorsServiceClient.php b/ErrorReporting/src/V1beta1/Client/ReportErrorsServiceClient.php index d22d13922eab..b11e45df8d4d 100644 --- a/ErrorReporting/src/V1beta1/Client/ReportErrorsServiceClient.php +++ b/ErrorReporting/src/V1beta1/Client/ReportErrorsServiceClient.php @@ -26,17 +26,230 @@ namespace Google\Cloud\ErrorReporting\V1beta1\Client; -use Google\Cloud\ErrorReporting\V1beta1\Client\BaseClient\ReportErrorsServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\ErrorReporting\V1beta1\ReportErrorEventRequest; +use Google\Cloud\ErrorReporting\V1beta1\ReportErrorEventResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: An API for reporting error events. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface reportErrorEventAsync(ReportErrorEventRequest $request, array $optionalArgs = []) */ -final class ReportErrorsServiceClient extends ReportErrorsServiceBaseClient +final class ReportErrorsServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ReportErrorsServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.devtools.clouderrorreporting.v1beta1.ReportErrorsService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'clouderrorreporting.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + 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', + ], + ], + ]; + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * 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 global service built + * on Cloud Logging and doesn't analyze logs stored + * in regional log buckets or logs routed to other Google Cloud projects. + * + * + * The async variant is {@see ReportErrorsServiceClient::reportErrorEventAsync()} . + * + * @example samples/V1beta1/ReportErrorsServiceClient/report_error_event.php + * + * @param ReportErrorEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ReportErrorEventResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function reportErrorEvent(ReportErrorEventRequest $request, array $callOptions = []): ReportErrorEventResponse + { + return $this->startApiCall('ReportErrorEvent', $request, $callOptions)->wait(); + } } diff --git a/EssentialContacts/composer.json b/EssentialContacts/composer.json index de215fc8aa79..c6d2f738cddb 100644 --- a/EssentialContacts/composer.json +++ b/EssentialContacts/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/EssentialContacts/src/V1/Client/BaseClient/EssentialContactsServiceBaseClient.php b/EssentialContacts/src/V1/Client/BaseClient/EssentialContactsServiceBaseClient.php deleted file mode 100644 index 66c422bde10b..000000000000 --- a/EssentialContacts/src/V1/Client/BaseClient/EssentialContactsServiceBaseClient.php +++ /dev/null @@ -1,509 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/essential_contacts_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/essential_contacts_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/essential_contacts_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/essential_contacts_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a contact - * resource. - * - * @param string $project - * @param string $contact - * - * @return string The formatted contact resource. - */ - public static function contactName(string $project, string $contact): string - { - return self::getPathTemplate('contact')->render([ - 'project' => $project, - 'contact' => $contact, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a folder - * resource. - * - * @param string $folder - * - * @return string The formatted folder resource. - */ - public static function folderName(string $folder): string - { - return self::getPathTemplate('folder')->render([ - 'folder' => $folder, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_contact resource. - * - * @param string $folder - * @param string $contact - * - * @return string The formatted folder_contact resource. - */ - public static function folderContactName(string $folder, string $contact): string - { - return self::getPathTemplate('folderContact')->render([ - 'folder' => $folder, - 'contact' => $contact, - ]); - } - - /** - * 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(string $organization): string - { - return self::getPathTemplate('organization')->render([ - 'organization' => $organization, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_contact resource. - * - * @param string $organization - * @param string $contact - * - * @return string The formatted organization_contact resource. - */ - public static function organizationContactName(string $organization, string $contact): string - { - return self::getPathTemplate('organizationContact')->render([ - 'organization' => $organization, - 'contact' => $contact, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_contact resource. - * - * @param string $project - * @param string $contact - * - * @return string The formatted project_contact resource. - */ - public static function projectContactName(string $project, string $contact): string - { - return self::getPathTemplate('projectContact')->render([ - 'project' => $project, - 'contact' => $contact, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - contact: projects/{project}/contacts/{contact} - * - folder: folders/{folder} - * - folderContact: folders/{folder}/contacts/{contact} - * - organization: organizations/{organization} - * - organizationContact: organizations/{organization}/contacts/{contact} - * - project: projects/{project} - * - projectContact: projects/{project}/contacts/{contact} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'essentialcontacts.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Lists all contacts for the resource that are subscribed to the - * specified notification categories, including contacts inherited from - * any parent resources. - * - * The async variant is {@see self::computeContactsAsync()} . - * - * @example samples/V1/EssentialContactsServiceClient/compute_contacts.php - * - * @param ComputeContactsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function computeContacts(ComputeContactsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ComputeContacts', $request, $callOptions); - } - - /** - * Adds a new contact for a resource. - * - * The async variant is {@see self::createContactAsync()} . - * - * @example samples/V1/EssentialContactsServiceClient/create_contact.php - * - * @param CreateContactRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Contact - * - * @throws ApiException Thrown if the API call fails. - */ - public function createContact(CreateContactRequest $request, array $callOptions = []): Contact - { - return $this->startApiCall('CreateContact', $request, $callOptions)->wait(); - } - - /** - * Deletes a contact. - * - * The async variant is {@see self::deleteContactAsync()} . - * - * @example samples/V1/EssentialContactsServiceClient/delete_contact.php - * - * @param DeleteContactRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteContact(DeleteContactRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteContact', $request, $callOptions)->wait(); - } - - /** - * Gets a single contact. - * - * The async variant is {@see self::getContactAsync()} . - * - * @example samples/V1/EssentialContactsServiceClient/get_contact.php - * - * @param GetContactRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Contact - * - * @throws ApiException Thrown if the API call fails. - */ - public function getContact(GetContactRequest $request, array $callOptions = []): Contact - { - return $this->startApiCall('GetContact', $request, $callOptions)->wait(); - } - - /** - * Lists the contacts that have been set on a resource. - * - * The async variant is {@see self::listContactsAsync()} . - * - * @example samples/V1/EssentialContactsServiceClient/list_contacts.php - * - * @param ListContactsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listContacts(ListContactsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListContacts', $request, $callOptions); - } - - /** - * Allows a contact admin to send a test message to contact to verify that it - * has been configured correctly. - * - * The async variant is {@see self::sendTestMessageAsync()} . - * - * @example samples/V1/EssentialContactsServiceClient/send_test_message.php - * - * @param SendTestMessageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function sendTestMessage(SendTestMessageRequest $request, array $callOptions = []): void - { - $this->startApiCall('SendTestMessage', $request, $callOptions)->wait(); - } - - /** - * Updates a contact. - * Note: A contact's email address cannot be changed. - * - * The async variant is {@see self::updateContactAsync()} . - * - * @example samples/V1/EssentialContactsServiceClient/update_contact.php - * - * @param UpdateContactRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Contact - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateContact(UpdateContactRequest $request, array $callOptions = []): Contact - { - return $this->startApiCall('UpdateContact', $request, $callOptions)->wait(); - } -} diff --git a/EssentialContacts/src/V1/Client/EssentialContactsServiceClient.php b/EssentialContacts/src/V1/Client/EssentialContactsServiceClient.php index e5f6c658786d..b57b5d9324cf 100644 --- a/EssentialContacts/src/V1/Client/EssentialContactsServiceClient.php +++ b/EssentialContacts/src/V1/Client/EssentialContactsServiceClient.php @@ -24,17 +24,490 @@ namespace Google\Cloud\EssentialContacts\V1\Client; -use Google\Cloud\EssentialContacts\V1\Client\BaseClient\EssentialContactsServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\EssentialContacts\V1\ComputeContactsRequest; +use Google\Cloud\EssentialContacts\V1\Contact; +use Google\Cloud\EssentialContacts\V1\CreateContactRequest; +use Google\Cloud\EssentialContacts\V1\DeleteContactRequest; +use Google\Cloud\EssentialContacts\V1\GetContactRequest; +use Google\Cloud\EssentialContacts\V1\ListContactsRequest; +use Google\Cloud\EssentialContacts\V1\SendTestMessageRequest; +use Google\Cloud\EssentialContacts\V1\UpdateContactRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Manages contacts for important Google Cloud notifications. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\EssentialContacts\V1\EssentialContactsServiceClient} for the + * stable implementation * * @experimental + * + * @method PromiseInterface computeContactsAsync(ComputeContactsRequest $request, array $optionalArgs = []) + * @method PromiseInterface createContactAsync(CreateContactRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteContactAsync(DeleteContactRequest $request, array $optionalArgs = []) + * @method PromiseInterface getContactAsync(GetContactRequest $request, array $optionalArgs = []) + * @method PromiseInterface listContactsAsync(ListContactsRequest $request, array $optionalArgs = []) + * @method PromiseInterface sendTestMessageAsync(SendTestMessageRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateContactAsync(UpdateContactRequest $request, array $optionalArgs = []) */ -final class EssentialContactsServiceClient extends EssentialContactsServiceBaseClient +final class EssentialContactsServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see EssentialContactsServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.essentialcontacts.v1.EssentialContactsService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'essentialcontacts.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/essential_contacts_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/essential_contacts_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/essential_contacts_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/essential_contacts_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a contact + * resource. + * + * @param string $project + * @param string $contact + * + * @return string The formatted contact resource. + */ + public static function contactName(string $project, string $contact): string + { + return self::getPathTemplate('contact')->render([ + 'project' => $project, + 'contact' => $contact, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a folder + * resource. + * + * @param string $folder + * + * @return string The formatted folder resource. + */ + public static function folderName(string $folder): string + { + return self::getPathTemplate('folder')->render([ + 'folder' => $folder, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_contact resource. + * + * @param string $folder + * @param string $contact + * + * @return string The formatted folder_contact resource. + */ + public static function folderContactName(string $folder, string $contact): string + { + return self::getPathTemplate('folderContact')->render([ + 'folder' => $folder, + 'contact' => $contact, + ]); + } + + /** + * 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(string $organization): string + { + return self::getPathTemplate('organization')->render([ + 'organization' => $organization, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_contact resource. + * + * @param string $organization + * @param string $contact + * + * @return string The formatted organization_contact resource. + */ + public static function organizationContactName(string $organization, string $contact): string + { + return self::getPathTemplate('organizationContact')->render([ + 'organization' => $organization, + 'contact' => $contact, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_contact resource. + * + * @param string $project + * @param string $contact + * + * @return string The formatted project_contact resource. + */ + public static function projectContactName(string $project, string $contact): string + { + return self::getPathTemplate('projectContact')->render([ + 'project' => $project, + 'contact' => $contact, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - contact: projects/{project}/contacts/{contact} + * - folder: folders/{folder} + * - folderContact: folders/{folder}/contacts/{contact} + * - organization: organizations/{organization} + * - organizationContact: organizations/{organization}/contacts/{contact} + * - project: projects/{project} + * - projectContact: projects/{project}/contacts/{contact} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'essentialcontacts.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Lists all contacts for the resource that are subscribed to the + * specified notification categories, including contacts inherited from + * any parent resources. + * + * The async variant is + * {@see EssentialContactsServiceClient::computeContactsAsync()} . + * + * @example samples/V1/EssentialContactsServiceClient/compute_contacts.php + * + * @param ComputeContactsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function computeContacts(ComputeContactsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ComputeContacts', $request, $callOptions); + } + + /** + * Adds a new contact for a resource. + * + * The async variant is {@see EssentialContactsServiceClient::createContactAsync()} + * . + * + * @example samples/V1/EssentialContactsServiceClient/create_contact.php + * + * @param CreateContactRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Contact + * + * @throws ApiException Thrown if the API call fails. + */ + public function createContact(CreateContactRequest $request, array $callOptions = []): Contact + { + return $this->startApiCall('CreateContact', $request, $callOptions)->wait(); + } + + /** + * Deletes a contact. + * + * The async variant is {@see EssentialContactsServiceClient::deleteContactAsync()} + * . + * + * @example samples/V1/EssentialContactsServiceClient/delete_contact.php + * + * @param DeleteContactRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteContact(DeleteContactRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteContact', $request, $callOptions)->wait(); + } + + /** + * Gets a single contact. + * + * The async variant is {@see EssentialContactsServiceClient::getContactAsync()} . + * + * @example samples/V1/EssentialContactsServiceClient/get_contact.php + * + * @param GetContactRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Contact + * + * @throws ApiException Thrown if the API call fails. + */ + public function getContact(GetContactRequest $request, array $callOptions = []): Contact + { + return $this->startApiCall('GetContact', $request, $callOptions)->wait(); + } + + /** + * Lists the contacts that have been set on a resource. + * + * The async variant is {@see EssentialContactsServiceClient::listContactsAsync()} + * . + * + * @example samples/V1/EssentialContactsServiceClient/list_contacts.php + * + * @param ListContactsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listContacts(ListContactsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListContacts', $request, $callOptions); + } + + /** + * Allows a contact admin to send a test message to contact to verify that it + * has been configured correctly. + * + * The async variant is + * {@see EssentialContactsServiceClient::sendTestMessageAsync()} . + * + * @example samples/V1/EssentialContactsServiceClient/send_test_message.php + * + * @param SendTestMessageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function sendTestMessage(SendTestMessageRequest $request, array $callOptions = []): void + { + $this->startApiCall('SendTestMessage', $request, $callOptions)->wait(); + } + + /** + * Updates a contact. + * Note: A contact's email address cannot be changed. + * + * The async variant is {@see EssentialContactsServiceClient::updateContactAsync()} + * . + * + * @example samples/V1/EssentialContactsServiceClient/update_contact.php + * + * @param UpdateContactRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Contact + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateContact(UpdateContactRequest $request, array $callOptions = []): Contact + { + return $this->startApiCall('UpdateContact', $request, $callOptions)->wait(); + } } diff --git a/Eventarc/composer.json b/Eventarc/composer.json index 9fbf70f63293..eabe7398f6a8 100644 --- a/Eventarc/composer.json +++ b/Eventarc/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Eventarc/src/V1/Client/BaseClient/EventarcBaseClient.php b/Eventarc/src/V1/Client/BaseClient/EventarcBaseClient.php deleted file mode 100644 index a69fb238dd05..000000000000 --- a/Eventarc/src/V1/Client/BaseClient/EventarcBaseClient.php +++ /dev/null @@ -1,1040 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/eventarc_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/eventarc_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/eventarc_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/eventarc_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a channel - * resource. - * - * @param string $project - * @param string $location - * @param string $channel - * - * @return string The formatted channel resource. - */ - public static function channelName(string $project, string $location, string $channel): string - { - return self::getPathTemplate('channel')->render([ - 'project' => $project, - 'location' => $location, - 'channel' => $channel, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * channel_connection resource. - * - * @param string $project - * @param string $location - * @param string $channelConnection - * - * @return string The formatted channel_connection resource. - */ - public static function channelConnectionName(string $project, string $location, string $channelConnection): string - { - return self::getPathTemplate('channelConnection')->render([ - 'project' => $project, - 'location' => $location, - 'channel_connection' => $channelConnection, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * cloud_function resource. - * - * @param string $project - * @param string $location - * @param string $function - * - * @return string The formatted cloud_function resource. - */ - public static function cloudFunctionName(string $project, string $location, string $function): string - { - return self::getPathTemplate('cloudFunction')->render([ - 'project' => $project, - 'location' => $location, - 'function' => $function, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a crypto_key - * resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * @param string $cryptoKey - * - * @return string The formatted crypto_key resource. - */ - public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string - { - return self::getPathTemplate('cryptoKey')->render([ - 'project' => $project, - 'location' => $location, - 'key_ring' => $keyRing, - 'crypto_key' => $cryptoKey, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * google_channel_config resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted google_channel_config resource. - */ - public static function googleChannelConfigName(string $project, string $location): string - { - return self::getPathTemplate('googleChannelConfig')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a provider - * resource. - * - * @param string $project - * @param string $location - * @param string $provider - * - * @return string The formatted provider resource. - */ - public static function providerName(string $project, string $location, string $provider): string - { - return self::getPathTemplate('provider')->render([ - 'project' => $project, - 'location' => $location, - 'provider' => $provider, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * service_account resource. - * - * @param string $project - * @param string $serviceAccount - * - * @return string The formatted service_account resource. - */ - public static function serviceAccountName(string $project, string $serviceAccount): string - { - return self::getPathTemplate('serviceAccount')->render([ - 'project' => $project, - 'service_account' => $serviceAccount, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a trigger - * resource. - * - * @param string $project - * @param string $location - * @param string $trigger - * - * @return string The formatted trigger resource. - */ - public static function triggerName(string $project, string $location, string $trigger): string - { - return self::getPathTemplate('trigger')->render([ - 'project' => $project, - 'location' => $location, - 'trigger' => $trigger, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a workflow - * resource. - * - * @param string $project - * @param string $location - * @param string $workflow - * - * @return string The formatted workflow resource. - */ - public static function workflowName(string $project, string $location, string $workflow): string - { - return self::getPathTemplate('workflow')->render([ - 'project' => $project, - 'location' => $location, - 'workflow' => $workflow, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - channel: projects/{project}/locations/{location}/channels/{channel} - * - channelConnection: projects/{project}/locations/{location}/channelConnections/{channel_connection} - * - cloudFunction: projects/{project}/locations/{location}/functions/{function} - * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} - * - googleChannelConfig: projects/{project}/locations/{location}/googleChannelConfig - * - location: projects/{project}/locations/{location} - * - provider: projects/{project}/locations/{location}/providers/{provider} - * - serviceAccount: projects/{project}/serviceAccounts/{service_account} - * - trigger: projects/{project}/locations/{location}/triggers/{trigger} - * - workflow: projects/{project}/locations/{location}/workflows/{workflow} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'eventarc.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Create a new channel in a particular project and location. - * - * The async variant is {@see self::createChannelAsync()} . - * - * @param CreateChannelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createChannel(CreateChannelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateChannel', $request, $callOptions)->wait(); - } - - /** - * Create a new ChannelConnection in a particular project and location. - * - * The async variant is {@see self::createChannelConnectionAsync()} . - * - * @param CreateChannelConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createChannelConnection(CreateChannelConnectionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateChannelConnection', $request, $callOptions)->wait(); - } - - /** - * Create a new trigger in a particular project and location. - * - * The async variant is {@see self::createTriggerAsync()} . - * - * @param CreateTriggerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTrigger(CreateTriggerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateTrigger', $request, $callOptions)->wait(); - } - - /** - * Delete a single channel. - * - * The async variant is {@see self::deleteChannelAsync()} . - * - * @param DeleteChannelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteChannel(DeleteChannelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteChannel', $request, $callOptions)->wait(); - } - - /** - * Delete a single ChannelConnection. - * - * The async variant is {@see self::deleteChannelConnectionAsync()} . - * - * @param DeleteChannelConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteChannelConnection(DeleteChannelConnectionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteChannelConnection', $request, $callOptions)->wait(); - } - - /** - * Delete a single trigger. - * - * The async variant is {@see self::deleteTriggerAsync()} . - * - * @param DeleteTriggerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTrigger(DeleteTriggerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteTrigger', $request, $callOptions)->wait(); - } - - /** - * Get a single Channel. - * - * The async variant is {@see self::getChannelAsync()} . - * - * @param GetChannelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Channel - * - * @throws ApiException Thrown if the API call fails. - */ - public function getChannel(GetChannelRequest $request, array $callOptions = []): Channel - { - return $this->startApiCall('GetChannel', $request, $callOptions)->wait(); - } - - /** - * Get a single ChannelConnection. - * - * The async variant is {@see self::getChannelConnectionAsync()} . - * - * @param GetChannelConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ChannelConnection - * - * @throws ApiException Thrown if the API call fails. - */ - public function getChannelConnection(GetChannelConnectionRequest $request, array $callOptions = []): ChannelConnection - { - return $this->startApiCall('GetChannelConnection', $request, $callOptions)->wait(); - } - - /** - * Get a GoogleChannelConfig - * - * The async variant is {@see self::getGoogleChannelConfigAsync()} . - * - * @param GetGoogleChannelConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GoogleChannelConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getGoogleChannelConfig(GetGoogleChannelConfigRequest $request, array $callOptions = []): GoogleChannelConfig - { - return $this->startApiCall('GetGoogleChannelConfig', $request, $callOptions)->wait(); - } - - /** - * Get a single Provider. - * - * The async variant is {@see self::getProviderAsync()} . - * - * @param GetProviderRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Provider - * - * @throws ApiException Thrown if the API call fails. - */ - public function getProvider(GetProviderRequest $request, array $callOptions = []): Provider - { - return $this->startApiCall('GetProvider', $request, $callOptions)->wait(); - } - - /** - * Get a single trigger. - * - * The async variant is {@see self::getTriggerAsync()} . - * - * @param GetTriggerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Trigger - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTrigger(GetTriggerRequest $request, array $callOptions = []): Trigger - { - return $this->startApiCall('GetTrigger', $request, $callOptions)->wait(); - } - - /** - * List channel connections. - * - * The async variant is {@see self::listChannelConnectionsAsync()} . - * - * @param ListChannelConnectionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listChannelConnections(ListChannelConnectionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListChannelConnections', $request, $callOptions); - } - - /** - * List channels. - * - * The async variant is {@see self::listChannelsAsync()} . - * - * @param ListChannelsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listChannels(ListChannelsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListChannels', $request, $callOptions); - } - - /** - * List providers. - * - * The async variant is {@see self::listProvidersAsync()} . - * - * @param ListProvidersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listProviders(ListProvidersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListProviders', $request, $callOptions); - } - - /** - * List triggers. - * - * The async variant is {@see self::listTriggersAsync()} . - * - * @param ListTriggersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTriggers(ListTriggersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTriggers', $request, $callOptions); - } - - /** - * Update a single channel. - * - * The async variant is {@see self::updateChannelAsync()} . - * - * @param UpdateChannelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateChannel(UpdateChannelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateChannel', $request, $callOptions)->wait(); - } - - /** - * Update a single GoogleChannelConfig - * - * The async variant is {@see self::updateGoogleChannelConfigAsync()} . - * - * @param UpdateGoogleChannelConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GoogleChannelConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateGoogleChannelConfig(UpdateGoogleChannelConfigRequest $request, array $callOptions = []): GoogleChannelConfig - { - return $this->startApiCall('UpdateGoogleChannelConfig', $request, $callOptions)->wait(); - } - - /** - * Update a single trigger. - * - * The async variant is {@see self::updateTriggerAsync()} . - * - * @param UpdateTriggerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateTrigger(UpdateTriggerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateTrigger', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Eventarc/src/V1/Client/EventarcClient.php b/Eventarc/src/V1/Client/EventarcClient.php index 4e90eab4ecec..109f59b2a865 100644 --- a/Eventarc/src/V1/Client/EventarcClient.php +++ b/Eventarc/src/V1/Client/EventarcClient.php @@ -24,17 +24,1015 @@ namespace Google\Cloud\Eventarc\V1\Client; -use Google\Cloud\Eventarc\V1\Client\BaseClient\EventarcBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Eventarc\V1\Channel; +use Google\Cloud\Eventarc\V1\ChannelConnection; +use Google\Cloud\Eventarc\V1\CreateChannelConnectionRequest; +use Google\Cloud\Eventarc\V1\CreateChannelRequest; +use Google\Cloud\Eventarc\V1\CreateTriggerRequest; +use Google\Cloud\Eventarc\V1\DeleteChannelConnectionRequest; +use Google\Cloud\Eventarc\V1\DeleteChannelRequest; +use Google\Cloud\Eventarc\V1\DeleteTriggerRequest; +use Google\Cloud\Eventarc\V1\GetChannelConnectionRequest; +use Google\Cloud\Eventarc\V1\GetChannelRequest; +use Google\Cloud\Eventarc\V1\GetGoogleChannelConfigRequest; +use Google\Cloud\Eventarc\V1\GetProviderRequest; +use Google\Cloud\Eventarc\V1\GetTriggerRequest; +use Google\Cloud\Eventarc\V1\GoogleChannelConfig; +use Google\Cloud\Eventarc\V1\ListChannelConnectionsRequest; +use Google\Cloud\Eventarc\V1\ListChannelsRequest; +use Google\Cloud\Eventarc\V1\ListProvidersRequest; +use Google\Cloud\Eventarc\V1\ListTriggersRequest; +use Google\Cloud\Eventarc\V1\Provider; +use Google\Cloud\Eventarc\V1\Trigger; +use Google\Cloud\Eventarc\V1\UpdateChannelRequest; +use Google\Cloud\Eventarc\V1\UpdateGoogleChannelConfigRequest; +use Google\Cloud\Eventarc\V1\UpdateTriggerRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Eventarc allows users to subscribe to various events that are provided by + * Google Cloud services and forward them to supported destinations. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Eventarc\V1\EventarcClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createChannelAsync(CreateChannelRequest $request, array $optionalArgs = []) + * @method PromiseInterface createChannelConnectionAsync(CreateChannelConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface createTriggerAsync(CreateTriggerRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteChannelAsync(DeleteChannelRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteChannelConnectionAsync(DeleteChannelConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTriggerAsync(DeleteTriggerRequest $request, array $optionalArgs = []) + * @method PromiseInterface getChannelAsync(GetChannelRequest $request, array $optionalArgs = []) + * @method PromiseInterface getChannelConnectionAsync(GetChannelConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getGoogleChannelConfigAsync(GetGoogleChannelConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getProviderAsync(GetProviderRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTriggerAsync(GetTriggerRequest $request, array $optionalArgs = []) + * @method PromiseInterface listChannelConnectionsAsync(ListChannelConnectionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listChannelsAsync(ListChannelsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listProvidersAsync(ListProvidersRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTriggersAsync(ListTriggersRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateChannelAsync(UpdateChannelRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateGoogleChannelConfigAsync(UpdateGoogleChannelConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateTriggerAsync(UpdateTriggerRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class EventarcClient extends EventarcBaseClient +final class EventarcClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see EventarcBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.eventarc.v1.Eventarc'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'eventarc.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/eventarc_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/eventarc_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/eventarc_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/eventarc_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a channel + * resource. + * + * @param string $project + * @param string $location + * @param string $channel + * + * @return string The formatted channel resource. + */ + public static function channelName(string $project, string $location, string $channel): string + { + return self::getPathTemplate('channel')->render([ + 'project' => $project, + 'location' => $location, + 'channel' => $channel, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * channel_connection resource. + * + * @param string $project + * @param string $location + * @param string $channelConnection + * + * @return string The formatted channel_connection resource. + */ + public static function channelConnectionName(string $project, string $location, string $channelConnection): string + { + return self::getPathTemplate('channelConnection')->render([ + 'project' => $project, + 'location' => $location, + 'channel_connection' => $channelConnection, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * cloud_function resource. + * + * @param string $project + * @param string $location + * @param string $function + * + * @return string The formatted cloud_function resource. + */ + public static function cloudFunctionName(string $project, string $location, string $function): string + { + return self::getPathTemplate('cloudFunction')->render([ + 'project' => $project, + 'location' => $location, + 'function' => $function, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a crypto_key + * resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * + * @return string The formatted crypto_key resource. + */ + public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string + { + return self::getPathTemplate('cryptoKey')->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'crypto_key' => $cryptoKey, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * google_channel_config resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted google_channel_config resource. + */ + public static function googleChannelConfigName(string $project, string $location): string + { + return self::getPathTemplate('googleChannelConfig')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a provider + * resource. + * + * @param string $project + * @param string $location + * @param string $provider + * + * @return string The formatted provider resource. + */ + public static function providerName(string $project, string $location, string $provider): string + { + return self::getPathTemplate('provider')->render([ + 'project' => $project, + 'location' => $location, + 'provider' => $provider, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * service_account resource. + * + * @param string $project + * @param string $serviceAccount + * + * @return string The formatted service_account resource. + */ + public static function serviceAccountName(string $project, string $serviceAccount): string + { + return self::getPathTemplate('serviceAccount')->render([ + 'project' => $project, + 'service_account' => $serviceAccount, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a trigger + * resource. + * + * @param string $project + * @param string $location + * @param string $trigger + * + * @return string The formatted trigger resource. + */ + public static function triggerName(string $project, string $location, string $trigger): string + { + return self::getPathTemplate('trigger')->render([ + 'project' => $project, + 'location' => $location, + 'trigger' => $trigger, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a workflow + * resource. + * + * @param string $project + * @param string $location + * @param string $workflow + * + * @return string The formatted workflow resource. + */ + public static function workflowName(string $project, string $location, string $workflow): string + { + return self::getPathTemplate('workflow')->render([ + 'project' => $project, + 'location' => $location, + 'workflow' => $workflow, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - channel: projects/{project}/locations/{location}/channels/{channel} + * - channelConnection: projects/{project}/locations/{location}/channelConnections/{channel_connection} + * - cloudFunction: projects/{project}/locations/{location}/functions/{function} + * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} + * - googleChannelConfig: projects/{project}/locations/{location}/googleChannelConfig + * - location: projects/{project}/locations/{location} + * - provider: projects/{project}/locations/{location}/providers/{provider} + * - serviceAccount: projects/{project}/serviceAccounts/{service_account} + * - trigger: projects/{project}/locations/{location}/triggers/{trigger} + * - workflow: projects/{project}/locations/{location}/workflows/{workflow} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'eventarc.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Create a new channel in a particular project and location. + * + * The async variant is {@see EventarcClient::createChannelAsync()} . + * + * @param CreateChannelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createChannel(CreateChannelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateChannel', $request, $callOptions)->wait(); + } + + /** + * Create a new ChannelConnection in a particular project and location. + * + * The async variant is {@see EventarcClient::createChannelConnectionAsync()} . + * + * @param CreateChannelConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createChannelConnection(CreateChannelConnectionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateChannelConnection', $request, $callOptions)->wait(); + } + + /** + * Create a new trigger in a particular project and location. + * + * The async variant is {@see EventarcClient::createTriggerAsync()} . + * + * @param CreateTriggerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTrigger(CreateTriggerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateTrigger', $request, $callOptions)->wait(); + } + + /** + * Delete a single channel. + * + * The async variant is {@see EventarcClient::deleteChannelAsync()} . + * + * @param DeleteChannelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteChannel(DeleteChannelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteChannel', $request, $callOptions)->wait(); + } + + /** + * Delete a single ChannelConnection. + * + * The async variant is {@see EventarcClient::deleteChannelConnectionAsync()} . + * + * @param DeleteChannelConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteChannelConnection(DeleteChannelConnectionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteChannelConnection', $request, $callOptions)->wait(); + } + + /** + * Delete a single trigger. + * + * The async variant is {@see EventarcClient::deleteTriggerAsync()} . + * + * @param DeleteTriggerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTrigger(DeleteTriggerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteTrigger', $request, $callOptions)->wait(); + } + + /** + * Get a single Channel. + * + * The async variant is {@see EventarcClient::getChannelAsync()} . + * + * @param GetChannelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Channel + * + * @throws ApiException Thrown if the API call fails. + */ + public function getChannel(GetChannelRequest $request, array $callOptions = []): Channel + { + return $this->startApiCall('GetChannel', $request, $callOptions)->wait(); + } + + /** + * Get a single ChannelConnection. + * + * The async variant is {@see EventarcClient::getChannelConnectionAsync()} . + * + * @param GetChannelConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ChannelConnection + * + * @throws ApiException Thrown if the API call fails. + */ + public function getChannelConnection(GetChannelConnectionRequest $request, array $callOptions = []): ChannelConnection + { + return $this->startApiCall('GetChannelConnection', $request, $callOptions)->wait(); + } + + /** + * Get a GoogleChannelConfig + * + * The async variant is {@see EventarcClient::getGoogleChannelConfigAsync()} . + * + * @param GetGoogleChannelConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GoogleChannelConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getGoogleChannelConfig(GetGoogleChannelConfigRequest $request, array $callOptions = []): GoogleChannelConfig + { + return $this->startApiCall('GetGoogleChannelConfig', $request, $callOptions)->wait(); + } + + /** + * Get a single Provider. + * + * The async variant is {@see EventarcClient::getProviderAsync()} . + * + * @param GetProviderRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Provider + * + * @throws ApiException Thrown if the API call fails. + */ + public function getProvider(GetProviderRequest $request, array $callOptions = []): Provider + { + return $this->startApiCall('GetProvider', $request, $callOptions)->wait(); + } + + /** + * Get a single trigger. + * + * The async variant is {@see EventarcClient::getTriggerAsync()} . + * + * @param GetTriggerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Trigger + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTrigger(GetTriggerRequest $request, array $callOptions = []): Trigger + { + return $this->startApiCall('GetTrigger', $request, $callOptions)->wait(); + } + + /** + * List channel connections. + * + * The async variant is {@see EventarcClient::listChannelConnectionsAsync()} . + * + * @param ListChannelConnectionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listChannelConnections(ListChannelConnectionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListChannelConnections', $request, $callOptions); + } + + /** + * List channels. + * + * The async variant is {@see EventarcClient::listChannelsAsync()} . + * + * @param ListChannelsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listChannels(ListChannelsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListChannels', $request, $callOptions); + } + + /** + * List providers. + * + * The async variant is {@see EventarcClient::listProvidersAsync()} . + * + * @param ListProvidersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listProviders(ListProvidersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListProviders', $request, $callOptions); + } + + /** + * List triggers. + * + * The async variant is {@see EventarcClient::listTriggersAsync()} . + * + * @param ListTriggersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTriggers(ListTriggersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTriggers', $request, $callOptions); + } + + /** + * Update a single channel. + * + * The async variant is {@see EventarcClient::updateChannelAsync()} . + * + * @param UpdateChannelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateChannel(UpdateChannelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateChannel', $request, $callOptions)->wait(); + } + + /** + * Update a single GoogleChannelConfig + * + * The async variant is {@see EventarcClient::updateGoogleChannelConfigAsync()} . + * + * @param UpdateGoogleChannelConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GoogleChannelConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateGoogleChannelConfig(UpdateGoogleChannelConfigRequest $request, array $callOptions = []): GoogleChannelConfig + { + return $this->startApiCall('UpdateGoogleChannelConfig', $request, $callOptions)->wait(); + } + + /** + * Update a single trigger. + * + * The async variant is {@see EventarcClient::updateTriggerAsync()} . + * + * @param UpdateTriggerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTrigger(UpdateTriggerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateTrigger', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see EventarcClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see EventarcClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see EventarcClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see EventarcClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see EventarcClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/EventarcPublishing/composer.json b/EventarcPublishing/composer.json index b2e28928f1a3..a86b71689a5a 100644 --- a/EventarcPublishing/composer.json +++ b/EventarcPublishing/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/EventarcPublishing/src/V1/Client/BaseClient/PublisherBaseClient.php b/EventarcPublishing/src/V1/Client/BaseClient/PublisherBaseClient.php deleted file mode 100644 index 794a06a77e9d..000000000000 --- a/EventarcPublishing/src/V1/Client/BaseClient/PublisherBaseClient.php +++ /dev/null @@ -1,243 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/publisher_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/publisher_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/publisher_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/publisher_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'eventarcpublishing.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Publish events to a ChannelConnection in a partner's project. - * - * The async variant is {@see self::publishChannelConnectionEventsAsync()} . - * - * @example samples/V1/PublisherClient/publish_channel_connection_events.php - * - * @param PublishChannelConnectionEventsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PublishChannelConnectionEventsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function publishChannelConnectionEvents(PublishChannelConnectionEventsRequest $request, array $callOptions = []): PublishChannelConnectionEventsResponse - { - return $this->startApiCall('PublishChannelConnectionEvents', $request, $callOptions)->wait(); - } - - /** - * Publish events to a subscriber's channel. - * - * The async variant is {@see self::publishEventsAsync()} . - * - * @example samples/V1/PublisherClient/publish_events.php - * - * @param PublishEventsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PublishEventsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function publishEvents(PublishEventsRequest $request, array $callOptions = []): PublishEventsResponse - { - return $this->startApiCall('PublishEvents', $request, $callOptions)->wait(); - } -} diff --git a/EventarcPublishing/src/V1/Client/PublisherClient.php b/EventarcPublishing/src/V1/Client/PublisherClient.php index 353777a80665..cb4f096d2055 100644 --- a/EventarcPublishing/src/V1/Client/PublisherClient.php +++ b/EventarcPublishing/src/V1/Client/PublisherClient.php @@ -24,17 +24,219 @@ namespace Google\Cloud\Eventarc\Publishing\V1\Client; -use Google\Cloud\Eventarc\Publishing\V1\Client\BaseClient\PublisherBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Eventarc\Publishing\V1\PublishChannelConnectionEventsRequest; +use Google\Cloud\Eventarc\Publishing\V1\PublishChannelConnectionEventsResponse; +use Google\Cloud\Eventarc\Publishing\V1\PublishEventsRequest; +use Google\Cloud\Eventarc\Publishing\V1\PublishEventsResponse; +use Google\Protobuf\Any; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Eventarc processes events generated by an event provider and delivers them to + * a subscriber. * - * This class is currently experimental and may be subject to changes. + * An event provider is a software-as-a-service (SaaS) system or + * product that can generate and deliver events through Eventarc. + * + * A third-party event provider is an event provider from outside of Google. + * + * A partner is a third-party event provider that is integrated with Eventarc. + * + * A subscriber is a GCP customer interested in receiving events. + * + * Channel is a first-class Eventarc resource that is created and managed + * by the subscriber in their GCP project. A Channel represents a subscriber's + * intent to receive events from an event provider. A Channel is associated with + * exactly one event provider. + * + * ChannelConnection is a first-class Eventarc resource that + * is created and managed by the partner in their GCP project. A + * ChannelConnection represents a connection between a partner and a + * subscriber's Channel. A ChannelConnection has a one-to-one mapping with a + * Channel. + * + * Publisher allows an event provider to publish events to Eventarc. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Eventarc\Publishing\V1\PublisherClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface publishChannelConnectionEventsAsync(PublishChannelConnectionEventsRequest $request, array $optionalArgs = []) + * @method PromiseInterface publishEventsAsync(PublishEventsRequest $request, array $optionalArgs = []) */ -final class PublisherClient extends PublisherBaseClient +final class PublisherClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see PublisherBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.eventarc.publishing.v1.Publisher'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'eventarcpublishing.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/publisher_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/publisher_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/publisher_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/publisher_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'eventarcpublishing.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Publish events to a ChannelConnection in a partner's project. + * + * The async variant is + * {@see PublisherClient::publishChannelConnectionEventsAsync()} . + * + * @example samples/V1/PublisherClient/publish_channel_connection_events.php + * + * @param PublishChannelConnectionEventsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PublishChannelConnectionEventsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function publishChannelConnectionEvents(PublishChannelConnectionEventsRequest $request, array $callOptions = []): PublishChannelConnectionEventsResponse + { + return $this->startApiCall('PublishChannelConnectionEvents', $request, $callOptions)->wait(); + } + + /** + * Publish events to a subscriber's channel. + * + * The async variant is {@see PublisherClient::publishEventsAsync()} . + * + * @example samples/V1/PublisherClient/publish_events.php + * + * @param PublishEventsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PublishEventsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function publishEvents(PublishEventsRequest $request, array $callOptions = []): PublishEventsResponse + { + return $this->startApiCall('PublishEvents', $request, $callOptions)->wait(); + } } diff --git a/Filestore/composer.json b/Filestore/composer.json index 9bb602de9ccb..6f35dfce6ae1 100644 --- a/Filestore/composer.json +++ b/Filestore/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1", + "google/gax": "^1.24.0", "google/cloud-common-protos": "^0.4" }, "require-dev": { diff --git a/Filestore/src/V1/Client/BaseClient/CloudFilestoreManagerBaseClient.php b/Filestore/src/V1/Client/BaseClient/CloudFilestoreManagerBaseClient.php deleted file mode 100644 index b366953a1f5f..000000000000 --- a/Filestore/src/V1/Client/BaseClient/CloudFilestoreManagerBaseClient.php +++ /dev/null @@ -1,754 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/cloud_filestore_manager_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/cloud_filestore_manager_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/cloud_filestore_manager_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/cloud_filestore_manager_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a backup - * resource. - * - * @param string $project - * @param string $location - * @param string $backup - * - * @return string The formatted backup resource. - */ - public static function backupName(string $project, string $location, string $backup): string - { - return self::getPathTemplate('backup')->render([ - 'project' => $project, - 'location' => $location, - 'backup' => $backup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a instance - * resource. - * - * @param string $project - * @param string $location - * @param string $instance - * - * @return string The formatted instance resource. - */ - public static function instanceName(string $project, string $location, string $instance): string - { - return self::getPathTemplate('instance')->render([ - 'project' => $project, - 'location' => $location, - 'instance' => $instance, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a snapshot - * resource. - * - * @param string $project - * @param string $location - * @param string $instance - * @param string $snapshot - * - * @return string The formatted snapshot resource. - */ - public static function snapshotName(string $project, string $location, string $instance, string $snapshot): string - { - return self::getPathTemplate('snapshot')->render([ - 'project' => $project, - 'location' => $location, - 'instance' => $instance, - 'snapshot' => $snapshot, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - backup: projects/{project}/locations/{location}/backups/{backup} - * - instance: projects/{project}/locations/{location}/instances/{instance} - * - location: projects/{project}/locations/{location} - * - snapshot: projects/{project}/locations/{location}/instances/{instance}/snapshots/{snapshot} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'file.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a backup. - * - * The async variant is {@see self::createBackupAsync()} . - * - * @param CreateBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createBackup(CreateBackupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateBackup', $request, $callOptions)->wait(); - } - - /** - * Creates an instance. - * When creating from a backup, the capacity of the new instance needs to be - * equal to or larger than the capacity of the backup (and also equal to or - * larger than the minimum capacity of the tier). - * - * The async variant is {@see self::createInstanceAsync()} . - * - * @param CreateInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createInstance(CreateInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateInstance', $request, $callOptions)->wait(); - } - - /** - * Creates a snapshot. - * - * The async variant is {@see self::createSnapshotAsync()} . - * - * @param CreateSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSnapshot(CreateSnapshotRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateSnapshot', $request, $callOptions)->wait(); - } - - /** - * Deletes a backup. - * - * The async variant is {@see self::deleteBackupAsync()} . - * - * @param DeleteBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteBackup(DeleteBackupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteBackup', $request, $callOptions)->wait(); - } - - /** - * Deletes an instance. - * - * The async variant is {@see self::deleteInstanceAsync()} . - * - * @param DeleteInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); - } - - /** - * Deletes a snapshot. - * - * The async variant is {@see self::deleteSnapshotAsync()} . - * - * @param DeleteSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSnapshot(DeleteSnapshotRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteSnapshot', $request, $callOptions)->wait(); - } - - /** - * Gets the details of a specific backup. - * - * The async variant is {@see self::getBackupAsync()} . - * - * @param GetBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Backup - * - * @throws ApiException Thrown if the API call fails. - */ - public function getBackup(GetBackupRequest $request, array $callOptions = []): Backup - { - return $this->startApiCall('GetBackup', $request, $callOptions)->wait(); - } - - /** - * Gets the details of a specific instance. - * - * The async variant is {@see self::getInstanceAsync()} . - * - * @param GetInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Instance - * - * @throws ApiException Thrown if the API call fails. - */ - public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance - { - return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); - } - - /** - * Gets the details of a specific snapshot. - * - * The async variant is {@see self::getSnapshotAsync()} . - * - * @param GetSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Snapshot - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSnapshot(GetSnapshotRequest $request, array $callOptions = []): Snapshot - { - return $this->startApiCall('GetSnapshot', $request, $callOptions)->wait(); - } - - /** - * Lists all backups in a project for either a specified location or for all - * locations. - * - * The async variant is {@see self::listBackupsAsync()} . - * - * @param ListBackupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listBackups(ListBackupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListBackups', $request, $callOptions); - } - - /** - * Lists all instances in a project for either a specified location - * or for all locations. - * - * The async variant is {@see self::listInstancesAsync()} . - * - * @param ListInstancesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listInstances(ListInstancesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListInstances', $request, $callOptions); - } - - /** - * Lists all snapshots in a project for either a specified location - * or for all locations. - * - * The async variant is {@see self::listSnapshotsAsync()} . - * - * @param ListSnapshotsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSnapshots(ListSnapshotsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSnapshots', $request, $callOptions); - } - - /** - * Restores an existing instance's file share from a backup. - * - * The capacity of the instance needs to be equal to or larger than the - * capacity of the backup (and also equal to or larger than the minimum - * capacity of the tier). - * - * The async variant is {@see self::restoreInstanceAsync()} . - * - * @param RestoreInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function restoreInstance(RestoreInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RestoreInstance', $request, $callOptions)->wait(); - } - - /** - * Updates the settings of a specific backup. - * - * The async variant is {@see self::updateBackupAsync()} . - * - * @param UpdateBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateBackup(UpdateBackupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateBackup', $request, $callOptions)->wait(); - } - - /** - * Updates the settings of a specific instance. - * - * The async variant is {@see self::updateInstanceAsync()} . - * - * @param UpdateInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateInstance(UpdateInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateInstance', $request, $callOptions)->wait(); - } - - /** - * Updates the settings of a specific snapshot. - * - * The async variant is {@see self::updateSnapshotAsync()} . - * - * @param UpdateSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSnapshot(UpdateSnapshotRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateSnapshot', $request, $callOptions)->wait(); - } -} diff --git a/Filestore/src/V1/Client/CloudFilestoreManagerClient.php b/Filestore/src/V1/Client/CloudFilestoreManagerClient.php index c60e74094de5..4b15115f60f1 100644 --- a/Filestore/src/V1/Client/CloudFilestoreManagerClient.php +++ b/Filestore/src/V1/Client/CloudFilestoreManagerClient.php @@ -24,17 +24,730 @@ namespace Google\Cloud\Filestore\V1\Client; -use Google\Cloud\Filestore\V1\Client\BaseClient\CloudFilestoreManagerBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Filestore\V1\Backup; +use Google\Cloud\Filestore\V1\CreateBackupRequest; +use Google\Cloud\Filestore\V1\CreateInstanceRequest; +use Google\Cloud\Filestore\V1\CreateSnapshotRequest; +use Google\Cloud\Filestore\V1\DeleteBackupRequest; +use Google\Cloud\Filestore\V1\DeleteInstanceRequest; +use Google\Cloud\Filestore\V1\DeleteSnapshotRequest; +use Google\Cloud\Filestore\V1\GetBackupRequest; +use Google\Cloud\Filestore\V1\GetInstanceRequest; +use Google\Cloud\Filestore\V1\GetSnapshotRequest; +use Google\Cloud\Filestore\V1\Instance; +use Google\Cloud\Filestore\V1\ListBackupsRequest; +use Google\Cloud\Filestore\V1\ListInstancesRequest; +use Google\Cloud\Filestore\V1\ListSnapshotsRequest; +use Google\Cloud\Filestore\V1\RestoreInstanceRequest; +use Google\Cloud\Filestore\V1\Snapshot; +use Google\Cloud\Filestore\V1\UpdateBackupRequest; +use Google\Cloud\Filestore\V1\UpdateInstanceRequest; +use Google\Cloud\Filestore\V1\UpdateSnapshotRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Configures and manages Filestore resources. * - * This class is currently experimental and may be subject to changes. + * Filestore Manager v1. + * + * The `file.googleapis.com` service implements the Filestore API and + * defines the following resource model for managing instances: + * * The service works with a collection of cloud projects, named: `/projects/*` + * * Each project has a collection of available locations, named: `/locations/*` + * * Each location has a collection of instances and backups, named: + * `/instances/*` and `/backups/*` respectively. + * * As such, Filestore instances are resources of the form: + * `/projects/{project_number}/locations/{location_id}/instances/{instance_id}` + * and backups are resources of the form: + * `/projects/{project_number}/locations/{location_id}/backup/{backup_id}` + * + * Note that location_id must be a Google Cloud `zone` for instances, but + * a Google Cloud `region` for backups; for example: + * * `projects/12345/locations/us-central1-c/instances/my-filestore` + * * `projects/12345/locations/us-central1/backups/my-backup` + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Filestore\V1\CloudFilestoreManagerClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createBackupAsync(CreateBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface createInstanceAsync(CreateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSnapshotAsync(CreateSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteBackupAsync(DeleteBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteInstanceAsync(DeleteInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSnapshotAsync(DeleteSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface getBackupAsync(GetBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInstanceAsync(GetInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSnapshotAsync(GetSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface listBackupsAsync(ListBackupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInstancesAsync(ListInstancesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSnapshotsAsync(ListSnapshotsRequest $request, array $optionalArgs = []) + * @method PromiseInterface restoreInstanceAsync(RestoreInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateBackupAsync(UpdateBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateInstanceAsync(UpdateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSnapshotAsync(UpdateSnapshotRequest $request, array $optionalArgs = []) */ -final class CloudFilestoreManagerClient extends CloudFilestoreManagerBaseClient +final class CloudFilestoreManagerClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CloudFilestoreManagerBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.filestore.v1.CloudFilestoreManager'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'file.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/cloud_filestore_manager_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/cloud_filestore_manager_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/cloud_filestore_manager_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/cloud_filestore_manager_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a backup + * resource. + * + * @param string $project + * @param string $location + * @param string $backup + * + * @return string The formatted backup resource. + */ + public static function backupName(string $project, string $location, string $backup): string + { + return self::getPathTemplate('backup')->render([ + 'project' => $project, + 'location' => $location, + 'backup' => $backup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a instance + * resource. + * + * @param string $project + * @param string $location + * @param string $instance + * + * @return string The formatted instance resource. + */ + public static function instanceName(string $project, string $location, string $instance): string + { + return self::getPathTemplate('instance')->render([ + 'project' => $project, + 'location' => $location, + 'instance' => $instance, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a snapshot + * resource. + * + * @param string $project + * @param string $location + * @param string $instance + * @param string $snapshot + * + * @return string The formatted snapshot resource. + */ + public static function snapshotName(string $project, string $location, string $instance, string $snapshot): string + { + return self::getPathTemplate('snapshot')->render([ + 'project' => $project, + 'location' => $location, + 'instance' => $instance, + 'snapshot' => $snapshot, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - backup: projects/{project}/locations/{location}/backups/{backup} + * - instance: projects/{project}/locations/{location}/instances/{instance} + * - location: projects/{project}/locations/{location} + * - snapshot: projects/{project}/locations/{location}/instances/{instance}/snapshots/{snapshot} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'file.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a backup. + * + * The async variant is {@see CloudFilestoreManagerClient::createBackupAsync()} . + * + * @param CreateBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createBackup(CreateBackupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateBackup', $request, $callOptions)->wait(); + } + + /** + * Creates an instance. + * When creating from a backup, the capacity of the new instance needs to be + * equal to or larger than the capacity of the backup (and also equal to or + * larger than the minimum capacity of the tier). + * + * The async variant is {@see CloudFilestoreManagerClient::createInstanceAsync()} . + * + * @param CreateInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createInstance(CreateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateInstance', $request, $callOptions)->wait(); + } + + /** + * Creates a snapshot. + * + * The async variant is {@see CloudFilestoreManagerClient::createSnapshotAsync()} . + * + * @param CreateSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSnapshot(CreateSnapshotRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateSnapshot', $request, $callOptions)->wait(); + } + + /** + * Deletes a backup. + * + * The async variant is {@see CloudFilestoreManagerClient::deleteBackupAsync()} . + * + * @param DeleteBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteBackup(DeleteBackupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteBackup', $request, $callOptions)->wait(); + } + + /** + * Deletes an instance. + * + * The async variant is {@see CloudFilestoreManagerClient::deleteInstanceAsync()} . + * + * @param DeleteInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); + } + + /** + * Deletes a snapshot. + * + * The async variant is {@see CloudFilestoreManagerClient::deleteSnapshotAsync()} . + * + * @param DeleteSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSnapshot(DeleteSnapshotRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteSnapshot', $request, $callOptions)->wait(); + } + + /** + * Gets the details of a specific backup. + * + * The async variant is {@see CloudFilestoreManagerClient::getBackupAsync()} . + * + * @param GetBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Backup + * + * @throws ApiException Thrown if the API call fails. + */ + public function getBackup(GetBackupRequest $request, array $callOptions = []): Backup + { + return $this->startApiCall('GetBackup', $request, $callOptions)->wait(); + } + + /** + * Gets the details of a specific instance. + * + * The async variant is {@see CloudFilestoreManagerClient::getInstanceAsync()} . + * + * @param GetInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Instance + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance + { + return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); + } + + /** + * Gets the details of a specific snapshot. + * + * The async variant is {@see CloudFilestoreManagerClient::getSnapshotAsync()} . + * + * @param GetSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Snapshot + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSnapshot(GetSnapshotRequest $request, array $callOptions = []): Snapshot + { + return $this->startApiCall('GetSnapshot', $request, $callOptions)->wait(); + } + + /** + * Lists all backups in a project for either a specified location or for all + * locations. + * + * The async variant is {@see CloudFilestoreManagerClient::listBackupsAsync()} . + * + * @param ListBackupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listBackups(ListBackupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListBackups', $request, $callOptions); + } + + /** + * Lists all instances in a project for either a specified location + * or for all locations. + * + * The async variant is {@see CloudFilestoreManagerClient::listInstancesAsync()} . + * + * @param ListInstancesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInstances(ListInstancesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInstances', $request, $callOptions); + } + + /** + * Lists all snapshots in a project for either a specified location + * or for all locations. + * + * The async variant is {@see CloudFilestoreManagerClient::listSnapshotsAsync()} . + * + * @param ListSnapshotsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSnapshots(ListSnapshotsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSnapshots', $request, $callOptions); + } + + /** + * Restores an existing instance's file share from a backup. + * + * The capacity of the instance needs to be equal to or larger than the + * capacity of the backup (and also equal to or larger than the minimum + * capacity of the tier). + * + * The async variant is {@see CloudFilestoreManagerClient::restoreInstanceAsync()} + * . + * + * @param RestoreInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function restoreInstance(RestoreInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RestoreInstance', $request, $callOptions)->wait(); + } + + /** + * Updates the settings of a specific backup. + * + * The async variant is {@see CloudFilestoreManagerClient::updateBackupAsync()} . + * + * @param UpdateBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateBackup(UpdateBackupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateBackup', $request, $callOptions)->wait(); + } + + /** + * Updates the settings of a specific instance. + * + * The async variant is {@see CloudFilestoreManagerClient::updateInstanceAsync()} . + * + * @param UpdateInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateInstance(UpdateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateInstance', $request, $callOptions)->wait(); + } + + /** + * Updates the settings of a specific snapshot. + * + * The async variant is {@see CloudFilestoreManagerClient::updateSnapshotAsync()} . + * + * @param UpdateSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSnapshot(UpdateSnapshotRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateSnapshot', $request, $callOptions)->wait(); + } } diff --git a/Firestore/VERSION b/Firestore/VERSION index bbb542a4e2ec..d2829d87d659 100644 --- a/Firestore/VERSION +++ b/Firestore/VERSION @@ -1 +1 @@ -1.37.2 +1.37.3 diff --git a/Firestore/composer.json b/Firestore/composer.json index c852f23028c0..19c7bfe6d850 100644 --- a/Firestore/composer.json +++ b/Firestore/composer.json @@ -6,8 +6,8 @@ "require": { "php": ">=7.4", "ext-grpc": "*", - "google/cloud-core": "^1.49.4", - "google/gax": "^1.19.1", + "google/cloud-core": "^1.52.7", + "google/gax": "^1.24.0", "ramsey/uuid": "^3.0|^4.0" }, "require-dev": { diff --git a/Firestore/src/Admin/V1/Client/BaseClient/FirestoreAdminBaseClient.php b/Firestore/src/Admin/V1/Client/BaseClient/FirestoreAdminBaseClient.php deleted file mode 100644 index 336eef22d319..000000000000 --- a/Firestore/src/Admin/V1/Client/BaseClient/FirestoreAdminBaseClient.php +++ /dev/null @@ -1,735 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/firestore_admin_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/firestore_admin_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/firestore_admin_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/firestore_admin_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * collection_group resource. - * - * @param string $project - * @param string $database - * @param string $collection - * - * @return string The formatted collection_group resource. - */ - public static function collectionGroupName(string $project, string $database, string $collection): string - { - return self::getPathTemplate('collectionGroup')->render([ - 'project' => $project, - 'database' => $database, - 'collection' => $collection, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a database - * resource. - * - * @param string $project - * @param string $database - * - * @return string The formatted database resource. - */ - public static function databaseName(string $project, string $database): string - { - return self::getPathTemplate('database')->render([ - 'project' => $project, - 'database' => $database, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a field - * resource. - * - * @param string $project - * @param string $database - * @param string $collection - * @param string $field - * - * @return string The formatted field resource. - */ - public static function fieldName(string $project, string $database, string $collection, string $field): string - { - return self::getPathTemplate('field')->render([ - 'project' => $project, - 'database' => $database, - 'collection' => $collection, - 'field' => $field, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a index - * resource. - * - * @param string $project - * @param string $database - * @param string $collection - * @param string $index - * - * @return string The formatted index resource. - */ - public static function indexName(string $project, string $database, string $collection, string $index): string - { - return self::getPathTemplate('index')->render([ - 'project' => $project, - 'database' => $database, - 'collection' => $collection, - 'index' => $index, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->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 - * - collectionGroup: projects/{project}/databases/{database}/collectionGroups/{collection} - * - database: projects/{project}/databases/{database} - * - field: projects/{project}/databases/{database}/collectionGroups/{collection}/fields/{field} - * - index: projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index} - * - 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. - */ - public static function parseName(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'firestore.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Create a database. - * - * The async variant is {@see self::createDatabaseAsync()} . - * - * @param CreateDatabaseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDatabase(CreateDatabaseRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateDatabase', $request, $callOptions)->wait(); - } - - /** - * Creates a composite index. This returns a - * [google.longrunning.Operation][google.longrunning.Operation] which may be - * used to track the status of the creation. The metadata for the operation - * will be the type - * [IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata]. - * - * The async variant is {@see self::createIndexAsync()} . - * - * @param CreateIndexRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createIndex(CreateIndexRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateIndex', $request, $callOptions)->wait(); - } - - /** - * Deletes a composite index. - * - * The async variant is {@see self::deleteIndexAsync()} . - * - * @param DeleteIndexRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteIndex(DeleteIndexRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteIndex', $request, $callOptions)->wait(); - } - - /** - * Exports a copy of all or a subset of documents from Google Cloud Firestore - * to another storage system, such as Google Cloud Storage. Recent updates to - * documents may not be reflected in the export. The export occurs in the - * background and its progress can be monitored and managed via the - * Operation resource that is created. The output of an export may only be - * used once the associated operation is done. If an export operation is - * cancelled before completion it may leave partial data behind in Google - * Cloud Storage. - * - * For more details on export behavior and output format, refer to: - * https://cloud.google.com/firestore/docs/manage-data/export-import - * - * The async variant is {@see self::exportDocumentsAsync()} . - * - * @param ExportDocumentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function exportDocuments(ExportDocumentsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ExportDocuments', $request, $callOptions)->wait(); - } - - /** - * Gets information about a database. - * - * The async variant is {@see self::getDatabaseAsync()} . - * - * @param GetDatabaseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Database - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDatabase(GetDatabaseRequest $request, array $callOptions = []): Database - { - return $this->startApiCall('GetDatabase', $request, $callOptions)->wait(); - } - - /** - * Gets the metadata and configuration for a Field. - * - * The async variant is {@see self::getFieldAsync()} . - * - * @param GetFieldRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Field - * - * @throws ApiException Thrown if the API call fails. - */ - public function getField(GetFieldRequest $request, array $callOptions = []): Field - { - return $this->startApiCall('GetField', $request, $callOptions)->wait(); - } - - /** - * Gets a composite index. - * - * The async variant is {@see self::getIndexAsync()} . - * - * @param GetIndexRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Index - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIndex(GetIndexRequest $request, array $callOptions = []): Index - { - return $this->startApiCall('GetIndex', $request, $callOptions)->wait(); - } - - /** - * Imports documents into Google Cloud Firestore. Existing documents with the - * same name are overwritten. The import occurs in the background and its - * progress can be monitored and managed via the Operation resource that is - * created. If an ImportDocuments operation is cancelled, it is possible - * that a subset of the data has already been imported to Cloud Firestore. - * - * The async variant is {@see self::importDocumentsAsync()} . - * - * @param ImportDocumentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function importDocuments(ImportDocumentsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ImportDocuments', $request, $callOptions)->wait(); - } - - /** - * List all the databases in the project. - * - * The async variant is {@see self::listDatabasesAsync()} . - * - * @param ListDatabasesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ListDatabasesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDatabases(ListDatabasesRequest $request, array $callOptions = []): ListDatabasesResponse - { - return $this->startApiCall('ListDatabases', $request, $callOptions)->wait(); - } - - /** - * Lists the field configuration and metadata for this database. - * - * Currently, - * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] - * only supports listing fields that have been explicitly overridden. To issue - * this query, call - * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] - * with the filter set to `indexConfig.usesAncestorConfig:false` . - * - * The async variant is {@see self::listFieldsAsync()} . - * - * @param ListFieldsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listFields(ListFieldsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListFields', $request, $callOptions); - } - - /** - * Lists composite indexes. - * - * The async variant is {@see self::listIndexesAsync()} . - * - * @param ListIndexesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listIndexes(ListIndexesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListIndexes', $request, $callOptions); - } - - /** - * Updates a database. - * - * The async variant is {@see self::updateDatabaseAsync()} . - * - * @param UpdateDatabaseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDatabase(UpdateDatabaseRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateDatabase', $request, $callOptions)->wait(); - } - - /** - * Updates a field configuration. Currently, field updates apply only to - * single field index configuration. However, calls to - * [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField] - * should provide a field mask to avoid changing any configuration that the - * caller isn't aware of. The field mask should be specified as: `{ paths: - * "index_config" }`. - * - * This call returns a - * [google.longrunning.Operation][google.longrunning.Operation] which may be - * used to track the status of the field update. The metadata for the - * operation will be the type - * [FieldOperationMetadata][google.firestore.admin.v1.FieldOperationMetadata]. - * - * To configure the default field settings for the database, use - * the special `Field` with resource name: - * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`. - * - * The async variant is {@see self::updateFieldAsync()} . - * - * @param UpdateFieldRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateField(UpdateFieldRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateField', $request, $callOptions)->wait(); - } -} diff --git a/Firestore/src/Admin/V1/Client/FirestoreAdminClient.php b/Firestore/src/Admin/V1/Client/FirestoreAdminClient.php index 22e5e28ba1d9..63f570876541 100644 --- a/Firestore/src/Admin/V1/Client/FirestoreAdminClient.php +++ b/Firestore/src/Admin/V1/Client/FirestoreAdminClient.php @@ -24,17 +24,710 @@ namespace Google\Cloud\Firestore\Admin\V1\Client; -use Google\Cloud\Firestore\Admin\V1\Client\BaseClient\FirestoreAdminBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Firestore\Admin\V1\CreateDatabaseRequest; +use Google\Cloud\Firestore\Admin\V1\CreateIndexRequest; +use Google\Cloud\Firestore\Admin\V1\Database; +use Google\Cloud\Firestore\Admin\V1\DeleteIndexRequest; +use Google\Cloud\Firestore\Admin\V1\ExportDocumentsRequest; +use Google\Cloud\Firestore\Admin\V1\Field; +use Google\Cloud\Firestore\Admin\V1\FieldOperationMetadata; +use Google\Cloud\Firestore\Admin\V1\GetDatabaseRequest; +use Google\Cloud\Firestore\Admin\V1\GetFieldRequest; +use Google\Cloud\Firestore\Admin\V1\GetIndexRequest; +use Google\Cloud\Firestore\Admin\V1\ImportDocumentsRequest; +use Google\Cloud\Firestore\Admin\V1\Index; +use Google\Cloud\Firestore\Admin\V1\IndexOperationMetadata; +use Google\Cloud\Firestore\Admin\V1\ListDatabasesRequest; +use Google\Cloud\Firestore\Admin\V1\ListDatabasesResponse; +use Google\Cloud\Firestore\Admin\V1\ListFieldsRequest; +use Google\Cloud\Firestore\Admin\V1\ListIndexesRequest; +use Google\Cloud\Firestore\Admin\V1\UpdateDatabaseRequest; +use Google\Cloud\Firestore\Admin\V1\UpdateFieldRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Cloud Firestore Admin API. * - * This class is currently experimental and may be subject to changes. + * This API provides several administrative services for Cloud Firestore. + * + * Project, Database, Namespace, Collection, Collection Group, and Document are + * used as defined in the Google Cloud Firestore API. + * + * Operation: An Operation represents work being performed in the background. + * + * The index service manages Cloud Firestore indexes. + * + * Index creation is performed asynchronously. + * An Operation resource is created for each such asynchronous operation. + * The state of the operation (including any errors encountered) + * may be queried via the Operation resource. + * + * The Operations collection provides a record of actions performed for the + * specified Project (including any Operations in progress). Operations are not + * created directly but through calls on other collections or resources. + * + * An Operation that is done may be deleted so that it is no longer listed as + * part of the Operation collection. Operations are garbage collected after + * 30 days. By default, ListOperations will only return in progress and failed + * operations. To list completed operation, issue a ListOperations request with + * the filter `done: true`. + * + * Operations are created by service `FirestoreAdmin`, but are accessed via + * service `google.longrunning.Operations`. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Firestore\Admin\V1\FirestoreAdminClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createDatabaseAsync(CreateDatabaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface createIndexAsync(CreateIndexRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteIndexAsync(DeleteIndexRequest $request, array $optionalArgs = []) + * @method PromiseInterface exportDocumentsAsync(ExportDocumentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDatabaseAsync(GetDatabaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface getFieldAsync(GetFieldRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIndexAsync(GetIndexRequest $request, array $optionalArgs = []) + * @method PromiseInterface importDocumentsAsync(ImportDocumentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDatabasesAsync(ListDatabasesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listFieldsAsync(ListFieldsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listIndexesAsync(ListIndexesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDatabaseAsync(UpdateDatabaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateFieldAsync(UpdateFieldRequest $request, array $optionalArgs = []) */ -final class FirestoreAdminClient extends FirestoreAdminBaseClient +final class FirestoreAdminClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see FirestoreAdminBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.firestore.admin.v1.FirestoreAdmin'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'firestore.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/datastore', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/firestore_admin_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/firestore_admin_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/firestore_admin_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/firestore_admin_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * collection_group resource. + * + * @param string $project + * @param string $database + * @param string $collection + * + * @return string The formatted collection_group resource. + */ + public static function collectionGroupName(string $project, string $database, string $collection): string + { + return self::getPathTemplate('collectionGroup')->render([ + 'project' => $project, + 'database' => $database, + 'collection' => $collection, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a database + * resource. + * + * @param string $project + * @param string $database + * + * @return string The formatted database resource. + */ + public static function databaseName(string $project, string $database): string + { + return self::getPathTemplate('database')->render([ + 'project' => $project, + 'database' => $database, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a field + * resource. + * + * @param string $project + * @param string $database + * @param string $collection + * @param string $field + * + * @return string The formatted field resource. + */ + public static function fieldName(string $project, string $database, string $collection, string $field): string + { + return self::getPathTemplate('field')->render([ + 'project' => $project, + 'database' => $database, + 'collection' => $collection, + 'field' => $field, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a index + * resource. + * + * @param string $project + * @param string $database + * @param string $collection + * @param string $index + * + * @return string The formatted index resource. + */ + public static function indexName(string $project, string $database, string $collection, string $index): string + { + return self::getPathTemplate('index')->render([ + 'project' => $project, + 'database' => $database, + 'collection' => $collection, + 'index' => $index, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->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 + * - collectionGroup: projects/{project}/databases/{database}/collectionGroups/{collection} + * - database: projects/{project}/databases/{database} + * - field: projects/{project}/databases/{database}/collectionGroups/{collection}/fields/{field} + * - index: projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index} + * - 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. + */ + public static function parseName(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'firestore.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Create a database. + * + * The async variant is {@see FirestoreAdminClient::createDatabaseAsync()} . + * + * @param CreateDatabaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDatabase(CreateDatabaseRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateDatabase', $request, $callOptions)->wait(); + } + + /** + * Creates a composite index. This returns a + * [google.longrunning.Operation][google.longrunning.Operation] which may be + * used to track the status of the creation. The metadata for the operation + * will be the type + * [IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata]. + * + * The async variant is {@see FirestoreAdminClient::createIndexAsync()} . + * + * @param CreateIndexRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createIndex(CreateIndexRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateIndex', $request, $callOptions)->wait(); + } + + /** + * Deletes a composite index. + * + * The async variant is {@see FirestoreAdminClient::deleteIndexAsync()} . + * + * @param DeleteIndexRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteIndex(DeleteIndexRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteIndex', $request, $callOptions)->wait(); + } + + /** + * Exports a copy of all or a subset of documents from Google Cloud Firestore + * to another storage system, such as Google Cloud Storage. Recent updates to + * documents may not be reflected in the export. The export occurs in the + * background and its progress can be monitored and managed via the + * Operation resource that is created. The output of an export may only be + * used once the associated operation is done. If an export operation is + * cancelled before completion it may leave partial data behind in Google + * Cloud Storage. + * + * For more details on export behavior and output format, refer to: + * https://cloud.google.com/firestore/docs/manage-data/export-import + * + * The async variant is {@see FirestoreAdminClient::exportDocumentsAsync()} . + * + * @param ExportDocumentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportDocuments(ExportDocumentsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ExportDocuments', $request, $callOptions)->wait(); + } + + /** + * Gets information about a database. + * + * The async variant is {@see FirestoreAdminClient::getDatabaseAsync()} . + * + * @param GetDatabaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Database + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDatabase(GetDatabaseRequest $request, array $callOptions = []): Database + { + return $this->startApiCall('GetDatabase', $request, $callOptions)->wait(); + } + + /** + * Gets the metadata and configuration for a Field. + * + * The async variant is {@see FirestoreAdminClient::getFieldAsync()} . + * + * @param GetFieldRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Field + * + * @throws ApiException Thrown if the API call fails. + */ + public function getField(GetFieldRequest $request, array $callOptions = []): Field + { + return $this->startApiCall('GetField', $request, $callOptions)->wait(); + } + + /** + * Gets a composite index. + * + * The async variant is {@see FirestoreAdminClient::getIndexAsync()} . + * + * @param GetIndexRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Index + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIndex(GetIndexRequest $request, array $callOptions = []): Index + { + return $this->startApiCall('GetIndex', $request, $callOptions)->wait(); + } + + /** + * Imports documents into Google Cloud Firestore. Existing documents with the + * same name are overwritten. The import occurs in the background and its + * progress can be monitored and managed via the Operation resource that is + * created. If an ImportDocuments operation is cancelled, it is possible + * that a subset of the data has already been imported to Cloud Firestore. + * + * The async variant is {@see FirestoreAdminClient::importDocumentsAsync()} . + * + * @param ImportDocumentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importDocuments(ImportDocumentsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportDocuments', $request, $callOptions)->wait(); + } + + /** + * List all the databases in the project. + * + * The async variant is {@see FirestoreAdminClient::listDatabasesAsync()} . + * + * @param ListDatabasesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ListDatabasesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDatabases(ListDatabasesRequest $request, array $callOptions = []): ListDatabasesResponse + { + return $this->startApiCall('ListDatabases', $request, $callOptions)->wait(); + } + + /** + * Lists the field configuration and metadata for this database. + * + * Currently, + * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] + * only supports listing fields that have been explicitly overridden. To issue + * this query, call + * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] + * with the filter set to `indexConfig.usesAncestorConfig:false` . + * + * The async variant is {@see FirestoreAdminClient::listFieldsAsync()} . + * + * @param ListFieldsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listFields(ListFieldsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListFields', $request, $callOptions); + } + + /** + * Lists composite indexes. + * + * The async variant is {@see FirestoreAdminClient::listIndexesAsync()} . + * + * @param ListIndexesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listIndexes(ListIndexesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListIndexes', $request, $callOptions); + } + + /** + * Updates a database. + * + * The async variant is {@see FirestoreAdminClient::updateDatabaseAsync()} . + * + * @param UpdateDatabaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDatabase(UpdateDatabaseRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateDatabase', $request, $callOptions)->wait(); + } + + /** + * Updates a field configuration. Currently, field updates apply only to + * single field index configuration. However, calls to + * [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField] + * should provide a field mask to avoid changing any configuration that the + * caller isn't aware of. The field mask should be specified as: `{ paths: + * "index_config" }`. + * + * This call returns a + * [google.longrunning.Operation][google.longrunning.Operation] which may be + * used to track the status of the field update. The metadata for the + * operation will be the type + * [FieldOperationMetadata][google.firestore.admin.v1.FieldOperationMetadata]. + * + * To configure the default field settings for the database, use + * the special `Field` with resource name: + * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`. + * + * The async variant is {@see FirestoreAdminClient::updateFieldAsync()} . + * + * @param UpdateFieldRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateField(UpdateFieldRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateField', $request, $callOptions)->wait(); + } } diff --git a/Firestore/src/FirestoreClient.php b/Firestore/src/FirestoreClient.php index e8801bc01886..bc2b720984a7 100644 --- a/Firestore/src/FirestoreClient.php +++ b/Firestore/src/FirestoreClient.php @@ -75,7 +75,7 @@ class FirestoreClient use SnapshotTrait; use ValidateTrait; - const VERSION = '1.37.2'; + const VERSION = '1.37.3'; const DEFAULT_DATABASE = '(default)'; diff --git a/Firestore/src/V1/Client/BaseClient/FirestoreBaseClient.php b/Firestore/src/V1/Client/BaseClient/FirestoreBaseClient.php deleted file mode 100644 index a42786df2f2d..000000000000 --- a/Firestore/src/V1/Client/BaseClient/FirestoreBaseClient.php +++ /dev/null @@ -1,587 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/firestore_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/firestore_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/firestore_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/firestore_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'firestore.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Gets multiple documents. - * - * Documents returned by this method are not guaranteed to be returned in the - * same order that they were requested. - * - * @param BatchGetDocumentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return ServerStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchGetDocuments(BatchGetDocumentsRequest $request, array $callOptions = []): ServerStream - { - return $this->startApiCall('BatchGetDocuments', $request, $callOptions); - } - - /** - * Applies a batch of write operations. - * - * The BatchWrite method does not apply the write operations atomically - * and can apply them out of order. Method does not allow more than one write - * per document. Each write succeeds or fails independently. See the - * [BatchWriteResponse][google.firestore.v1.BatchWriteResponse] for the - * success status of each write. - * - * If you require an atomically applied set of writes, use - * [Commit][google.firestore.v1.Firestore.Commit] instead. - * - * The async variant is {@see self::batchWriteAsync()} . - * - * @param BatchWriteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BatchWriteResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchWrite(BatchWriteRequest $request, array $callOptions = []): BatchWriteResponse - { - return $this->startApiCall('BatchWrite', $request, $callOptions)->wait(); - } - - /** - * Starts a new transaction. - * - * The async variant is {@see self::beginTransactionAsync()} . - * - * @param BeginTransactionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BeginTransactionResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function beginTransaction(BeginTransactionRequest $request, array $callOptions = []): BeginTransactionResponse - { - return $this->startApiCall('BeginTransaction', $request, $callOptions)->wait(); - } - - /** - * Commits a transaction, while optionally updating documents. - * - * The async variant is {@see self::commitAsync()} . - * - * @param CommitRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CommitResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function commit(CommitRequest $request, array $callOptions = []): CommitResponse - { - return $this->startApiCall('Commit', $request, $callOptions)->wait(); - } - - /** - * Creates a new document. - * - * The async variant is {@see self::createDocumentAsync()} . - * - * @param CreateDocumentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Document - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDocument(CreateDocumentRequest $request, array $callOptions = []): Document - { - return $this->startApiCall('CreateDocument', $request, $callOptions)->wait(); - } - - /** - * Deletes a document. - * - * The async variant is {@see self::deleteDocumentAsync()} . - * - * @param DeleteDocumentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDocument(DeleteDocumentRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteDocument', $request, $callOptions)->wait(); - } - - /** - * Gets a single document. - * - * The async variant is {@see self::getDocumentAsync()} . - * - * @param GetDocumentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Document - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDocument(GetDocumentRequest $request, array $callOptions = []): Document - { - return $this->startApiCall('GetDocument', $request, $callOptions)->wait(); - } - - /** - * Lists all the collection IDs underneath a document. - * - * The async variant is {@see self::listCollectionIdsAsync()} . - * - * @param ListCollectionIdsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCollectionIds(ListCollectionIdsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCollectionIds', $request, $callOptions); - } - - /** - * Lists documents. - * - * The async variant is {@see self::listDocumentsAsync()} . - * - * @param ListDocumentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDocuments(ListDocumentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDocuments', $request, $callOptions); - } - - /** - * Listens to changes. This method is only available via gRPC or WebChannel - * (not REST). - * - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return BidiStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function listen(array $callOptions = []): BidiStream - { - return $this->startApiCall('Listen', null, $callOptions); - } - - /** - * Partitions a query by returning partition cursors that can be used to run - * the query in parallel. The returned partition cursors are split points that - * can be used by RunQuery as starting/end points for the query results. - * - * The async variant is {@see self::partitionQueryAsync()} . - * - * @param PartitionQueryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function partitionQuery(PartitionQueryRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('PartitionQuery', $request, $callOptions); - } - - /** - * Rolls back a transaction. - * - * The async variant is {@see self::rollbackAsync()} . - * - * @param RollbackRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function rollback(RollbackRequest $request, array $callOptions = []): void - { - $this->startApiCall('Rollback', $request, $callOptions)->wait(); - } - - /** - * Runs an aggregation query. - * - * Rather than producing [Document][google.firestore.v1.Document] results like - * [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery], this API - * allows running an aggregation to produce a series of - * [AggregationResult][google.firestore.v1.AggregationResult] server-side. - * - * High-Level Example: - * - * ``` - * -- Return the number of documents in table given a filter. - * SELECT COUNT(*) FROM ( SELECT * FROM k where a = true ); - * ``` - * - * @param RunAggregationQueryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return ServerStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function runAggregationQuery(RunAggregationQueryRequest $request, array $callOptions = []): ServerStream - { - return $this->startApiCall('RunAggregationQuery', $request, $callOptions); - } - - /** - * Runs a query. - * - * @param RunQueryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return ServerStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function runQuery(RunQueryRequest $request, array $callOptions = []): ServerStream - { - return $this->startApiCall('RunQuery', $request, $callOptions); - } - - /** - * Updates or inserts a document. - * - * The async variant is {@see self::updateDocumentAsync()} . - * - * @param UpdateDocumentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Document - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDocument(UpdateDocumentRequest $request, array $callOptions = []): Document - { - return $this->startApiCall('UpdateDocument', $request, $callOptions)->wait(); - } - - /** - * Streams batches of document updates and deletes, in order. This method is - * only available via gRPC or WebChannel (not REST). - * - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return BidiStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function write(array $callOptions = []): BidiStream - { - return $this->startApiCall('Write', null, $callOptions); - } -} diff --git a/Firestore/src/V1/Client/FirestoreClient.php b/Firestore/src/V1/Client/FirestoreClient.php index 57d3f2a45c2e..781414b244f5 100644 --- a/Firestore/src/V1/Client/FirestoreClient.php +++ b/Firestore/src/V1/Client/FirestoreClient.php @@ -24,17 +24,562 @@ namespace Google\Cloud\Firestore\V1\Client; -use Google\Cloud\Firestore\V1\Client\BaseClient\FirestoreBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\BidiStream; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\ServerStream; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Firestore\V1\BatchGetDocumentsRequest; +use Google\Cloud\Firestore\V1\BatchWriteRequest; +use Google\Cloud\Firestore\V1\BatchWriteResponse; +use Google\Cloud\Firestore\V1\BeginTransactionRequest; +use Google\Cloud\Firestore\V1\BeginTransactionResponse; +use Google\Cloud\Firestore\V1\CommitRequest; +use Google\Cloud\Firestore\V1\CommitResponse; +use Google\Cloud\Firestore\V1\CreateDocumentRequest; +use Google\Cloud\Firestore\V1\DeleteDocumentRequest; +use Google\Cloud\Firestore\V1\Document; +use Google\Cloud\Firestore\V1\GetDocumentRequest; +use Google\Cloud\Firestore\V1\ListCollectionIdsRequest; +use Google\Cloud\Firestore\V1\ListDocumentsRequest; +use Google\Cloud\Firestore\V1\PartitionQueryRequest; +use Google\Cloud\Firestore\V1\RollbackRequest; +use Google\Cloud\Firestore\V1\RunAggregationQueryRequest; +use Google\Cloud\Firestore\V1\RunQueryRequest; +use Google\Cloud\Firestore\V1\UpdateDocumentRequest; +use Google\Cloud\Firestore\V1\Write; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Cloud Firestore service. * - * This class is currently experimental and may be subject to changes. + * Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL + * document database that simplifies storing, syncing, and querying data for + * your mobile, web, and IoT apps at global scale. Its client libraries provide + * live synchronization and offline support, while its security features and + * integrations with Firebase and Google Cloud Platform accelerate building + * truly serverless apps. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Firestore\V1\FirestoreClient} for the stable implementation * * @experimental + * + * @method PromiseInterface batchWriteAsync(BatchWriteRequest $request, array $optionalArgs = []) + * @method PromiseInterface beginTransactionAsync(BeginTransactionRequest $request, array $optionalArgs = []) + * @method PromiseInterface commitAsync(CommitRequest $request, array $optionalArgs = []) + * @method PromiseInterface createDocumentAsync(CreateDocumentRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDocumentAsync(DeleteDocumentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDocumentAsync(GetDocumentRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCollectionIdsAsync(ListCollectionIdsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDocumentsAsync(ListDocumentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface partitionQueryAsync(PartitionQueryRequest $request, array $optionalArgs = []) + * @method PromiseInterface rollbackAsync(RollbackRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDocumentAsync(UpdateDocumentRequest $request, array $optionalArgs = []) */ -final class FirestoreClient extends FirestoreBaseClient +final class FirestoreClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see FirestoreBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.firestore.v1.Firestore'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'firestore.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/datastore', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/firestore_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/firestore_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/firestore_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/firestore_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'firestore.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Gets multiple documents. + * + * Documents returned by this method are not guaranteed to be returned in the + * same order that they were requested. + * + * @param BatchGetDocumentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return ServerStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchGetDocuments(BatchGetDocumentsRequest $request, array $callOptions = []): ServerStream + { + return $this->startApiCall('BatchGetDocuments', $request, $callOptions); + } + + /** + * Applies a batch of write operations. + * + * The BatchWrite method does not apply the write operations atomically + * and can apply them out of order. Method does not allow more than one write + * per document. Each write succeeds or fails independently. See the + * [BatchWriteResponse][google.firestore.v1.BatchWriteResponse] for the + * success status of each write. + * + * If you require an atomically applied set of writes, use + * [Commit][google.firestore.v1.Firestore.Commit] instead. + * + * The async variant is {@see FirestoreClient::batchWriteAsync()} . + * + * @param BatchWriteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BatchWriteResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchWrite(BatchWriteRequest $request, array $callOptions = []): BatchWriteResponse + { + return $this->startApiCall('BatchWrite', $request, $callOptions)->wait(); + } + + /** + * Starts a new transaction. + * + * The async variant is {@see FirestoreClient::beginTransactionAsync()} . + * + * @param BeginTransactionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BeginTransactionResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function beginTransaction(BeginTransactionRequest $request, array $callOptions = []): BeginTransactionResponse + { + return $this->startApiCall('BeginTransaction', $request, $callOptions)->wait(); + } + + /** + * Commits a transaction, while optionally updating documents. + * + * The async variant is {@see FirestoreClient::commitAsync()} . + * + * @param CommitRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CommitResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function commit(CommitRequest $request, array $callOptions = []): CommitResponse + { + return $this->startApiCall('Commit', $request, $callOptions)->wait(); + } + + /** + * Creates a new document. + * + * The async variant is {@see FirestoreClient::createDocumentAsync()} . + * + * @param CreateDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Document + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDocument(CreateDocumentRequest $request, array $callOptions = []): Document + { + return $this->startApiCall('CreateDocument', $request, $callOptions)->wait(); + } + + /** + * Deletes a document. + * + * The async variant is {@see FirestoreClient::deleteDocumentAsync()} . + * + * @param DeleteDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDocument(DeleteDocumentRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteDocument', $request, $callOptions)->wait(); + } + + /** + * Gets a single document. + * + * The async variant is {@see FirestoreClient::getDocumentAsync()} . + * + * @param GetDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Document + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDocument(GetDocumentRequest $request, array $callOptions = []): Document + { + return $this->startApiCall('GetDocument', $request, $callOptions)->wait(); + } + + /** + * Lists all the collection IDs underneath a document. + * + * The async variant is {@see FirestoreClient::listCollectionIdsAsync()} . + * + * @param ListCollectionIdsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCollectionIds(ListCollectionIdsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCollectionIds', $request, $callOptions); + } + + /** + * Lists documents. + * + * The async variant is {@see FirestoreClient::listDocumentsAsync()} . + * + * @param ListDocumentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDocuments(ListDocumentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDocuments', $request, $callOptions); + } + + /** + * Listens to changes. This method is only available via gRPC or WebChannel + * (not REST). + * + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return BidiStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function listen(array $callOptions = []): BidiStream + { + return $this->startApiCall('Listen', null, $callOptions); + } + + /** + * Partitions a query by returning partition cursors that can be used to run + * the query in parallel. The returned partition cursors are split points that + * can be used by RunQuery as starting/end points for the query results. + * + * The async variant is {@see FirestoreClient::partitionQueryAsync()} . + * + * @param PartitionQueryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function partitionQuery(PartitionQueryRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('PartitionQuery', $request, $callOptions); + } + + /** + * Rolls back a transaction. + * + * The async variant is {@see FirestoreClient::rollbackAsync()} . + * + * @param RollbackRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function rollback(RollbackRequest $request, array $callOptions = []): void + { + $this->startApiCall('Rollback', $request, $callOptions)->wait(); + } + + /** + * Runs an aggregation query. + * + * Rather than producing [Document][google.firestore.v1.Document] results like + * [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery], this API + * allows running an aggregation to produce a series of + * [AggregationResult][google.firestore.v1.AggregationResult] server-side. + * + * High-Level Example: + * + * ``` + * -- Return the number of documents in table given a filter. + * SELECT COUNT(*) FROM ( SELECT * FROM k where a = true ); + * ``` + * + * @param RunAggregationQueryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return ServerStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function runAggregationQuery(RunAggregationQueryRequest $request, array $callOptions = []): ServerStream + { + return $this->startApiCall('RunAggregationQuery', $request, $callOptions); + } + + /** + * Runs a query. + * + * @param RunQueryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return ServerStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function runQuery(RunQueryRequest $request, array $callOptions = []): ServerStream + { + return $this->startApiCall('RunQuery', $request, $callOptions); + } + + /** + * Updates or inserts a document. + * + * The async variant is {@see FirestoreClient::updateDocumentAsync()} . + * + * @param UpdateDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Document + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDocument(UpdateDocumentRequest $request, array $callOptions = []): Document + { + return $this->startApiCall('UpdateDocument', $request, $callOptions)->wait(); + } + + /** + * Streams batches of document updates and deletes, in order. This method is + * only available via gRPC or WebChannel (not REST). + * + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return BidiStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function write(array $callOptions = []): BidiStream + { + return $this->startApiCall('Write', null, $callOptions); + } } diff --git a/Firestore/src/V1/PartitionQueryResponse.php b/Firestore/src/V1/PartitionQueryResponse.php index 1b608d6ab0f6..afa65cefa425 100644 --- a/Firestore/src/V1/PartitionQueryResponse.php +++ b/Firestore/src/V1/PartitionQueryResponse.php @@ -30,7 +30,7 @@ class PartitionQueryResponse extends \Google\Protobuf\Internal\Message * * query, start_at A, end_at B * * query, start_at B * An empty result may indicate that the query has too few results to be - * partitioned. + * partitioned, or that the query is not yet supported for partitioning. * * Generated from protobuf field repeated .google.firestore.v1.Cursor partitions = 1; */ @@ -64,7 +64,7 @@ class PartitionQueryResponse extends \Google\Protobuf\Internal\Message * * query, start_at A, end_at B * * query, start_at B * An empty result may indicate that the query has too few results to be - * partitioned. + * partitioned, or that the query is not yet supported for partitioning. * @type string $next_page_token * A page token that may be used to request an additional set of results, up * to the number specified by `partition_count` in the PartitionQuery request. @@ -90,7 +90,7 @@ public function __construct($data = NULL) { * * query, start_at A, end_at B * * query, start_at B * An empty result may indicate that the query has too few results to be - * partitioned. + * partitioned, or that the query is not yet supported for partitioning. * * Generated from protobuf field repeated .google.firestore.v1.Cursor partitions = 1; * @return \Google\Protobuf\Internal\RepeatedField @@ -114,7 +114,7 @@ public function getPartitions() * * query, start_at A, end_at B * * query, start_at B * An empty result may indicate that the query has too few results to be - * partitioned. + * partitioned, or that the query is not yet supported for partitioning. * * Generated from protobuf field repeated .google.firestore.v1.Cursor partitions = 1; * @param array<\Google\Cloud\Firestore\V1\Cursor>|\Google\Protobuf\Internal\RepeatedField $var diff --git a/Firestore/src/V1/StructuredQuery/FieldReference.php b/Firestore/src/V1/StructuredQuery/FieldReference.php index 16a574a825ee..90c70fb21a9a 100644 --- a/Firestore/src/V1/StructuredQuery/FieldReference.php +++ b/Firestore/src/V1/StructuredQuery/FieldReference.php @@ -16,9 +16,10 @@ class FieldReference extends \Google\Protobuf\Internal\Message { /** - * The relative path of the document being referenced. + * A reference to a field in a document. * Requires: - * * Conform to [document field name][google.firestore.v1.Document.fields] + * * MUST be a dot-delimited (`.`) string of segments, where each segment + * conforms to [document field name][google.firestore.v1.Document.fields] * limitations. * * Generated from protobuf field string field_path = 2; @@ -32,9 +33,10 @@ class FieldReference extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $field_path - * The relative path of the document being referenced. + * A reference to a field in a document. * Requires: - * * Conform to [document field name][google.firestore.v1.Document.fields] + * * MUST be a dot-delimited (`.`) string of segments, where each segment + * conforms to [document field name][google.firestore.v1.Document.fields] * limitations. * } */ @@ -44,9 +46,10 @@ public function __construct($data = NULL) { } /** - * The relative path of the document being referenced. + * A reference to a field in a document. * Requires: - * * Conform to [document field name][google.firestore.v1.Document.fields] + * * MUST be a dot-delimited (`.`) string of segments, where each segment + * conforms to [document field name][google.firestore.v1.Document.fields] * limitations. * * Generated from protobuf field string field_path = 2; @@ -58,9 +61,10 @@ public function getFieldPath() } /** - * The relative path of the document being referenced. + * A reference to a field in a document. * Requires: - * * Conform to [document field name][google.firestore.v1.Document.fields] + * * MUST be a dot-delimited (`.`) string of segments, where each segment + * conforms to [document field name][google.firestore.v1.Document.fields] * limitations. * * Generated from protobuf field string field_path = 2; diff --git a/Firestore/src/V1/Target.php b/Firestore/src/V1/Target.php index bd30daeb7564..8f0fb8e77b54 100644 --- a/Firestore/src/V1/Target.php +++ b/Firestore/src/V1/Target.php @@ -18,6 +18,18 @@ class Target extends \Google\Protobuf\Internal\Message /** * The target ID that identifies the target on the stream. Must be a positive * number and non-zero. + * If `target_id` is 0 (or unspecified), the server will assign an ID for this + * target and return that in a `TargetChange::ADD` event. Once a target with + * `target_id=0` is added, all subsequent targets must also have + * `target_id=0`. If an `AddTarget` request with `target_id != 0` is + * sent to the server after a target with `target_id=0` is added, the server + * will immediately send a response with a `TargetChange::Remove` event. + * Note that if the client sends multiple `AddTarget` requests + * without an ID, the order of IDs returned in `TargetChage.target_ids` are + * undefined. Therefore, clients should provide a target ID instead of relying + * on the server to assign one. + * If `target_id` is non-zero, there must not be an existing active target on + * this stream with the same ID. * * Generated from protobuf field int32 target_id = 5; */ @@ -61,6 +73,18 @@ class Target extends \Google\Protobuf\Internal\Message * @type int $target_id * The target ID that identifies the target on the stream. Must be a positive * number and non-zero. + * If `target_id` is 0 (or unspecified), the server will assign an ID for this + * target and return that in a `TargetChange::ADD` event. Once a target with + * `target_id=0` is added, all subsequent targets must also have + * `target_id=0`. If an `AddTarget` request with `target_id != 0` is + * sent to the server after a target with `target_id=0` is added, the server + * will immediately send a response with a `TargetChange::Remove` event. + * Note that if the client sends multiple `AddTarget` requests + * without an ID, the order of IDs returned in `TargetChage.target_ids` are + * undefined. Therefore, clients should provide a target ID instead of relying + * on the server to assign one. + * If `target_id` is non-zero, there must not be an existing active target on + * this stream with the same ID. * @type bool $once * If the target should be removed once it is current and consistent. * @type \Google\Protobuf\Int32Value $expected_count @@ -209,6 +233,18 @@ public function setReadTime($var) /** * The target ID that identifies the target on the stream. Must be a positive * number and non-zero. + * If `target_id` is 0 (or unspecified), the server will assign an ID for this + * target and return that in a `TargetChange::ADD` event. Once a target with + * `target_id=0` is added, all subsequent targets must also have + * `target_id=0`. If an `AddTarget` request with `target_id != 0` is + * sent to the server after a target with `target_id=0` is added, the server + * will immediately send a response with a `TargetChange::Remove` event. + * Note that if the client sends multiple `AddTarget` requests + * without an ID, the order of IDs returned in `TargetChage.target_ids` are + * undefined. Therefore, clients should provide a target ID instead of relying + * on the server to assign one. + * If `target_id` is non-zero, there must not be an existing active target on + * this stream with the same ID. * * Generated from protobuf field int32 target_id = 5; * @return int @@ -221,6 +257,18 @@ public function getTargetId() /** * The target ID that identifies the target on the stream. Must be a positive * number and non-zero. + * If `target_id` is 0 (or unspecified), the server will assign an ID for this + * target and return that in a `TargetChange::ADD` event. Once a target with + * `target_id=0` is added, all subsequent targets must also have + * `target_id=0`. If an `AddTarget` request with `target_id != 0` is + * sent to the server after a target with `target_id=0` is added, the server + * will immediately send a response with a `TargetChange::Remove` event. + * Note that if the client sends multiple `AddTarget` requests + * without an ID, the order of IDs returned in `TargetChage.target_ids` are + * undefined. Therefore, clients should provide a target ID instead of relying + * on the server to assign one. + * If `target_id` is non-zero, there must not be an existing active target on + * this stream with the same ID. * * Generated from protobuf field int32 target_id = 5; * @param int $var diff --git a/Functions/composer.json b/Functions/composer.json index 4564e9a64011..2164bb889cdd 100644 --- a/Functions/composer.json +++ b/Functions/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Functions/src/V2/Client/BaseClient/FunctionServiceBaseClient.php b/Functions/src/V2/Client/BaseClient/FunctionServiceBaseClient.php deleted file mode 100644 index c2afc5779771..000000000000 --- a/Functions/src/V2/Client/BaseClient/FunctionServiceBaseClient.php +++ /dev/null @@ -1,808 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/function_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/function_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/function_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/function_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a build - * resource. - * - * @param string $project - * @param string $location - * @param string $build - * - * @return string The formatted build resource. - */ - public static function buildName(string $project, string $location, string $build): string - { - return self::getPathTemplate('build')->render([ - 'project' => $project, - 'location' => $location, - 'build' => $build, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a channel - * resource. - * - * @param string $project - * @param string $location - * @param string $channel - * - * @return string The formatted channel resource. - */ - public static function channelName(string $project, string $location, string $channel): string - { - return self::getPathTemplate('channel')->render([ - 'project' => $project, - 'location' => $location, - 'channel' => $channel, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a connector - * resource. - * - * @param string $project - * @param string $location - * @param string $connector - * - * @return string The formatted connector resource. - */ - public static function connectorName(string $project, string $location, string $connector): string - { - return self::getPathTemplate('connector')->render([ - 'project' => $project, - 'location' => $location, - 'connector' => $connector, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a crypto_key - * resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * @param string $cryptoKey - * - * @return string The formatted crypto_key resource. - */ - public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string - { - return self::getPathTemplate('cryptoKey')->render([ - 'project' => $project, - 'location' => $location, - 'key_ring' => $keyRing, - 'crypto_key' => $cryptoKey, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a function - * resource. - * - * @param string $project - * @param string $location - * @param string $function - * - * @return string The formatted function resource. - */ - public static function functionName(string $project, string $location, string $function): string - { - return self::getPathTemplate('function')->render([ - 'project' => $project, - 'location' => $location, - 'function' => $function, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a repository - * resource. - * - * @param string $project - * @param string $location - * @param string $repository - * - * @return string The formatted repository resource. - */ - public static function repositoryName(string $project, string $location, string $repository): string - { - return self::getPathTemplate('repository')->render([ - 'project' => $project, - 'location' => $location, - 'repository' => $repository, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a service - * resource. - * - * @param string $project - * @param string $location - * @param string $service - * - * @return string The formatted service resource. - */ - public static function serviceName(string $project, string $location, string $service): string - { - return self::getPathTemplate('service')->render([ - 'project' => $project, - 'location' => $location, - 'service' => $service, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a topic - * resource. - * - * @param string $project - * @param string $topic - * - * @return string The formatted topic resource. - */ - public static function topicName(string $project, string $topic): string - { - return self::getPathTemplate('topic')->render([ - 'project' => $project, - 'topic' => $topic, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a trigger - * resource. - * - * @param string $project - * @param string $location - * @param string $trigger - * - * @return string The formatted trigger resource. - */ - public static function triggerName(string $project, string $location, string $trigger): string - { - return self::getPathTemplate('trigger')->render([ - 'project' => $project, - 'location' => $location, - 'trigger' => $trigger, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a worker_pool - * resource. - * - * @param string $project - * @param string $location - * @param string $workerPool - * - * @return string The formatted worker_pool resource. - */ - public static function workerPoolName(string $project, string $location, string $workerPool): string - { - return self::getPathTemplate('workerPool')->render([ - 'project' => $project, - 'location' => $location, - 'worker_pool' => $workerPool, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - build: projects/{project}/locations/{location}/builds/{build} - * - channel: projects/{project}/locations/{location}/channels/{channel} - * - connector: projects/{project}/locations/{location}/connectors/{connector} - * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} - * - function: projects/{project}/locations/{location}/functions/{function} - * - location: projects/{project}/locations/{location} - * - repository: projects/{project}/locations/{location}/repositories/{repository} - * - service: projects/{project}/locations/{location}/services/{service} - * - topic: projects/{project}/topics/{topic} - * - trigger: projects/{project}/locations/{location}/triggers/{trigger} - * - workerPool: projects/{project}/locations/{location}/workerPools/{worker_pool} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudfunctions.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new function. If a function with the given name already exists in - * the specified project, the long running operation will return - * `ALREADY_EXISTS` error. - * - * The async variant is {@see self::createFunctionAsync()} . - * - * @param CreateFunctionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createFunction(CreateFunctionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateFunction', $request, $callOptions)->wait(); - } - - /** - * Deletes a function with the given name from the specified project. If the - * given function is used by some trigger, the trigger will be updated to - * remove this function. - * - * The async variant is {@see self::deleteFunctionAsync()} . - * - * @param DeleteFunctionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteFunction(DeleteFunctionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteFunction', $request, $callOptions)->wait(); - } - - /** - * Returns a signed URL for downloading deployed function source code. - * The URL is only valid for a limited period and should be used within - * 30 minutes of generation. - * For more information about the signed URL usage see: - * https://cloud.google.com/storage/docs/access-control/signed-urls - * - * The async variant is {@see self::generateDownloadUrlAsync()} . - * - * @param GenerateDownloadUrlRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GenerateDownloadUrlResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function generateDownloadUrl(GenerateDownloadUrlRequest $request, array $callOptions = []): GenerateDownloadUrlResponse - { - return $this->startApiCall('GenerateDownloadUrl', $request, $callOptions)->wait(); - } - - /** - * Returns a signed URL for uploading a function source code. - * For more information about the signed URL usage see: - * https://cloud.google.com/storage/docs/access-control/signed-urls. - * Once the function source code upload is complete, the used signed - * URL should be provided in CreateFunction or UpdateFunction request - * as a reference to the function source code. - * - * When uploading source code to the generated signed URL, please follow - * these restrictions: - * - * * Source file type should be a zip file. - * * No credentials should be attached - the signed URLs provide access to the - * target bucket using internal service identity; if credentials were - * attached, the identity from the credentials would be used, but that - * identity does not have permissions to upload files to the URL. - * - * When making a HTTP PUT request, these two headers need to be specified: - * - * * `content-type: application/zip` - * - * And this header SHOULD NOT be specified: - * - * * `Authorization: Bearer YOUR_TOKEN` - * - * The async variant is {@see self::generateUploadUrlAsync()} . - * - * @param GenerateUploadUrlRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GenerateUploadUrlResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function generateUploadUrl(GenerateUploadUrlRequest $request, array $callOptions = []): GenerateUploadUrlResponse - { - return $this->startApiCall('GenerateUploadUrl', $request, $callOptions)->wait(); - } - - /** - * Returns a function with the given name from the requested project. - * - * The async variant is {@see self::getFunctionAsync()} . - * - * @param GetFunctionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PBFunction - * - * @throws ApiException Thrown if the API call fails. - */ - public function getFunction(GetFunctionRequest $request, array $callOptions = []): PBFunction - { - return $this->startApiCall('GetFunction', $request, $callOptions)->wait(); - } - - /** - * Returns a list of functions that belong to the requested project. - * - * The async variant is {@see self::listFunctionsAsync()} . - * - * @param ListFunctionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listFunctions(ListFunctionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListFunctions', $request, $callOptions); - } - - /** - * Returns a list of runtimes that are supported for the requested project. - * - * The async variant is {@see self::listRuntimesAsync()} . - * - * @param ListRuntimesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ListRuntimesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listRuntimes(ListRuntimesRequest $request, array $callOptions = []): ListRuntimesResponse - { - return $this->startApiCall('ListRuntimes', $request, $callOptions)->wait(); - } - - /** - * Updates existing function. - * - * The async variant is {@see self::updateFunctionAsync()} . - * - * @param UpdateFunctionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateFunction(UpdateFunctionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateFunction', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Functions/src/V2/Client/FunctionServiceClient.php b/Functions/src/V2/Client/FunctionServiceClient.php index e5226069d7f0..0c09f0bc83a9 100644 --- a/Functions/src/V2/Client/FunctionServiceClient.php +++ b/Functions/src/V2/Client/FunctionServiceClient.php @@ -24,17 +24,783 @@ namespace Google\Cloud\Functions\V2\Client; -use Google\Cloud\Functions\V2\Client\BaseClient\FunctionServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Functions\V2\CreateFunctionRequest; +use Google\Cloud\Functions\V2\DeleteFunctionRequest; +use Google\Cloud\Functions\V2\GenerateDownloadUrlRequest; +use Google\Cloud\Functions\V2\GenerateDownloadUrlResponse; +use Google\Cloud\Functions\V2\GenerateUploadUrlRequest; +use Google\Cloud\Functions\V2\GenerateUploadUrlResponse; +use Google\Cloud\Functions\V2\GetFunctionRequest; +use Google\Cloud\Functions\V2\ListFunctionsRequest; +use Google\Cloud\Functions\V2\ListRuntimesRequest; +use Google\Cloud\Functions\V2\ListRuntimesResponse; +use Google\Cloud\Functions\V2\PBFunction; +use Google\Cloud\Functions\V2\UpdateFunctionRequest; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\ListLocationsRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Google Cloud Functions is used to deploy functions that are executed by + * Google in response to various events. Data connected with that event is + * passed to a function as the input data. * - * This class is currently experimental and may be subject to changes. + * A **function** is a resource which describes a function that should be + * executed and how it is triggered. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Functions\V2\FunctionServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createFunctionAsync(CreateFunctionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteFunctionAsync(DeleteFunctionRequest $request, array $optionalArgs = []) + * @method PromiseInterface generateDownloadUrlAsync(GenerateDownloadUrlRequest $request, array $optionalArgs = []) + * @method PromiseInterface generateUploadUrlAsync(GenerateUploadUrlRequest $request, array $optionalArgs = []) + * @method PromiseInterface getFunctionAsync(GetFunctionRequest $request, array $optionalArgs = []) + * @method PromiseInterface listFunctionsAsync(ListFunctionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listRuntimesAsync(ListRuntimesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateFunctionAsync(UpdateFunctionRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class FunctionServiceClient extends FunctionServiceBaseClient +final class FunctionServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see FunctionServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.functions.v2.FunctionService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudfunctions.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/function_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/function_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/function_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/function_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a build + * resource. + * + * @param string $project + * @param string $location + * @param string $build + * + * @return string The formatted build resource. + */ + public static function buildName(string $project, string $location, string $build): string + { + return self::getPathTemplate('build')->render([ + 'project' => $project, + 'location' => $location, + 'build' => $build, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a channel + * resource. + * + * @param string $project + * @param string $location + * @param string $channel + * + * @return string The formatted channel resource. + */ + public static function channelName(string $project, string $location, string $channel): string + { + return self::getPathTemplate('channel')->render([ + 'project' => $project, + 'location' => $location, + 'channel' => $channel, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a connector + * resource. + * + * @param string $project + * @param string $location + * @param string $connector + * + * @return string The formatted connector resource. + */ + public static function connectorName(string $project, string $location, string $connector): string + { + return self::getPathTemplate('connector')->render([ + 'project' => $project, + 'location' => $location, + 'connector' => $connector, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a crypto_key + * resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * + * @return string The formatted crypto_key resource. + */ + public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string + { + return self::getPathTemplate('cryptoKey')->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'crypto_key' => $cryptoKey, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a function + * resource. + * + * @param string $project + * @param string $location + * @param string $function + * + * @return string The formatted function resource. + */ + public static function functionName(string $project, string $location, string $function): string + { + return self::getPathTemplate('function')->render([ + 'project' => $project, + 'location' => $location, + 'function' => $function, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a repository + * resource. + * + * @param string $project + * @param string $location + * @param string $repository + * + * @return string The formatted repository resource. + */ + public static function repositoryName(string $project, string $location, string $repository): string + { + return self::getPathTemplate('repository')->render([ + 'project' => $project, + 'location' => $location, + 'repository' => $repository, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a service + * resource. + * + * @param string $project + * @param string $location + * @param string $service + * + * @return string The formatted service resource. + */ + public static function serviceName(string $project, string $location, string $service): string + { + return self::getPathTemplate('service')->render([ + 'project' => $project, + 'location' => $location, + 'service' => $service, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a topic + * resource. + * + * @param string $project + * @param string $topic + * + * @return string The formatted topic resource. + */ + public static function topicName(string $project, string $topic): string + { + return self::getPathTemplate('topic')->render([ + 'project' => $project, + 'topic' => $topic, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a trigger + * resource. + * + * @param string $project + * @param string $location + * @param string $trigger + * + * @return string The formatted trigger resource. + */ + public static function triggerName(string $project, string $location, string $trigger): string + { + return self::getPathTemplate('trigger')->render([ + 'project' => $project, + 'location' => $location, + 'trigger' => $trigger, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a worker_pool + * resource. + * + * @param string $project + * @param string $location + * @param string $workerPool + * + * @return string The formatted worker_pool resource. + */ + public static function workerPoolName(string $project, string $location, string $workerPool): string + { + return self::getPathTemplate('workerPool')->render([ + 'project' => $project, + 'location' => $location, + 'worker_pool' => $workerPool, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - build: projects/{project}/locations/{location}/builds/{build} + * - channel: projects/{project}/locations/{location}/channels/{channel} + * - connector: projects/{project}/locations/{location}/connectors/{connector} + * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} + * - function: projects/{project}/locations/{location}/functions/{function} + * - location: projects/{project}/locations/{location} + * - repository: projects/{project}/locations/{location}/repositories/{repository} + * - service: projects/{project}/locations/{location}/services/{service} + * - topic: projects/{project}/topics/{topic} + * - trigger: projects/{project}/locations/{location}/triggers/{trigger} + * - workerPool: projects/{project}/locations/{location}/workerPools/{worker_pool} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudfunctions.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new function. If a function with the given name already exists in + * the specified project, the long running operation will return + * `ALREADY_EXISTS` error. + * + * The async variant is {@see FunctionServiceClient::createFunctionAsync()} . + * + * @param CreateFunctionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createFunction(CreateFunctionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateFunction', $request, $callOptions)->wait(); + } + + /** + * Deletes a function with the given name from the specified project. If the + * given function is used by some trigger, the trigger will be updated to + * remove this function. + * + * The async variant is {@see FunctionServiceClient::deleteFunctionAsync()} . + * + * @param DeleteFunctionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteFunction(DeleteFunctionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteFunction', $request, $callOptions)->wait(); + } + + /** + * Returns a signed URL for downloading deployed function source code. + * The URL is only valid for a limited period and should be used within + * 30 minutes of generation. + * For more information about the signed URL usage see: + * https://cloud.google.com/storage/docs/access-control/signed-urls + * + * The async variant is {@see FunctionServiceClient::generateDownloadUrlAsync()} . + * + * @param GenerateDownloadUrlRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GenerateDownloadUrlResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function generateDownloadUrl(GenerateDownloadUrlRequest $request, array $callOptions = []): GenerateDownloadUrlResponse + { + return $this->startApiCall('GenerateDownloadUrl', $request, $callOptions)->wait(); + } + + /** + * Returns a signed URL for uploading a function source code. + * For more information about the signed URL usage see: + * https://cloud.google.com/storage/docs/access-control/signed-urls. + * Once the function source code upload is complete, the used signed + * URL should be provided in CreateFunction or UpdateFunction request + * as a reference to the function source code. + * + * When uploading source code to the generated signed URL, please follow + * these restrictions: + * + * * Source file type should be a zip file. + * * No credentials should be attached - the signed URLs provide access to the + * target bucket using internal service identity; if credentials were + * attached, the identity from the credentials would be used, but that + * identity does not have permissions to upload files to the URL. + * + * When making a HTTP PUT request, these two headers need to be specified: + * + * * `content-type: application/zip` + * + * And this header SHOULD NOT be specified: + * + * * `Authorization: Bearer YOUR_TOKEN` + * + * The async variant is {@see FunctionServiceClient::generateUploadUrlAsync()} . + * + * @param GenerateUploadUrlRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GenerateUploadUrlResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function generateUploadUrl(GenerateUploadUrlRequest $request, array $callOptions = []): GenerateUploadUrlResponse + { + return $this->startApiCall('GenerateUploadUrl', $request, $callOptions)->wait(); + } + + /** + * Returns a function with the given name from the requested project. + * + * The async variant is {@see FunctionServiceClient::getFunctionAsync()} . + * + * @param GetFunctionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PBFunction + * + * @throws ApiException Thrown if the API call fails. + */ + public function getFunction(GetFunctionRequest $request, array $callOptions = []): PBFunction + { + return $this->startApiCall('GetFunction', $request, $callOptions)->wait(); + } + + /** + * Returns a list of functions that belong to the requested project. + * + * The async variant is {@see FunctionServiceClient::listFunctionsAsync()} . + * + * @param ListFunctionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listFunctions(ListFunctionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListFunctions', $request, $callOptions); + } + + /** + * Returns a list of runtimes that are supported for the requested project. + * + * The async variant is {@see FunctionServiceClient::listRuntimesAsync()} . + * + * @param ListRuntimesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ListRuntimesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listRuntimes(ListRuntimesRequest $request, array $callOptions = []): ListRuntimesResponse + { + return $this->startApiCall('ListRuntimes', $request, $callOptions)->wait(); + } + + /** + * Updates existing function. + * + * The async variant is {@see FunctionServiceClient::updateFunctionAsync()} . + * + * @param UpdateFunctionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateFunction(UpdateFunctionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateFunction', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see FunctionServiceClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see FunctionServiceClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see FunctionServiceClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see FunctionServiceClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/GSuiteAddOns/composer.json b/GSuiteAddOns/composer.json index e5610d8529da..88cbd915be8c 100644 --- a/GSuiteAddOns/composer.json +++ b/GSuiteAddOns/composer.json @@ -21,7 +21,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/GSuiteAddOns/src/V1/Client/BaseClient/GSuiteAddOnsBaseClient.php b/GSuiteAddOns/src/V1/Client/BaseClient/GSuiteAddOnsBaseClient.php deleted file mode 100644 index 142b4d2297b2..000000000000 --- a/GSuiteAddOns/src/V1/Client/BaseClient/GSuiteAddOnsBaseClient.php +++ /dev/null @@ -1,539 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/g_suite_add_ons_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/g_suite_add_ons_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/g_suite_add_ons_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/g_suite_add_ons_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * authorization resource. - * - * @param string $project - * - * @return string The formatted authorization resource. - */ - public static function authorizationName(string $project): string - { - return self::getPathTemplate('authorization')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a deployment - * resource. - * - * @param string $project - * @param string $deployment - * - * @return string The formatted deployment resource. - */ - public static function deploymentName(string $project, string $deployment): string - { - return self::getPathTemplate('deployment')->render([ - 'project' => $project, - 'deployment' => $deployment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * install_status resource. - * - * @param string $project - * @param string $deployment - * - * @return string The formatted install_status resource. - */ - public static function installStatusName(string $project, string $deployment): string - { - return self::getPathTemplate('installStatus')->render([ - 'project' => $project, - 'deployment' => $deployment, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->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 - * - authorization: projects/{project}/authorization - * - deployment: projects/{project}/deployments/{deployment} - * - installStatus: projects/{project}/deployments/{deployment}/installStatus - * - 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. - */ - public static function parseName(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'gsuiteaddons.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a deployment with the specified name and configuration. - * - * The async variant is {@see self::createDeploymentAsync()} . - * - * @example samples/V1/GSuiteAddOnsClient/create_deployment.php - * - * @param CreateDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Deployment - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDeployment(CreateDeploymentRequest $request, array $callOptions = []): Deployment - { - return $this->startApiCall('CreateDeployment', $request, $callOptions)->wait(); - } - - /** - * Deletes the deployment with the given name. - * - * The async variant is {@see self::deleteDeploymentAsync()} . - * - * @example samples/V1/GSuiteAddOnsClient/delete_deployment.php - * - * @param DeleteDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDeployment(DeleteDeploymentRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteDeployment', $request, $callOptions)->wait(); - } - - /** - * Gets the authorization information for deployments in a given project. - * - * The async variant is {@see self::getAuthorizationAsync()} . - * - * @example samples/V1/GSuiteAddOnsClient/get_authorization.php - * - * @param GetAuthorizationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Authorization - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAuthorization(GetAuthorizationRequest $request, array $callOptions = []): Authorization - { - return $this->startApiCall('GetAuthorization', $request, $callOptions)->wait(); - } - - /** - * Gets the deployment with the specified name. - * - * The async variant is {@see self::getDeploymentAsync()} . - * - * @example samples/V1/GSuiteAddOnsClient/get_deployment.php - * - * @param GetDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Deployment - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDeployment(GetDeploymentRequest $request, array $callOptions = []): Deployment - { - return $this->startApiCall('GetDeployment', $request, $callOptions)->wait(); - } - - /** - * Fetches the install status of a developer mode deployment. - * - * The async variant is {@see self::getInstallStatusAsync()} . - * - * @example samples/V1/GSuiteAddOnsClient/get_install_status.php - * - * @param GetInstallStatusRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InstallStatus - * - * @throws ApiException Thrown if the API call fails. - */ - public function getInstallStatus(GetInstallStatusRequest $request, array $callOptions = []): InstallStatus - { - return $this->startApiCall('GetInstallStatus', $request, $callOptions)->wait(); - } - - /** - * Installs a deployment in developer mode. - * See: - * https://developers.google.com/gsuite/add-ons/how-tos/testing-gsuite-addons. - * - * The async variant is {@see self::installDeploymentAsync()} . - * - * @example samples/V1/GSuiteAddOnsClient/install_deployment.php - * - * @param InstallDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function installDeployment(InstallDeploymentRequest $request, array $callOptions = []): void - { - $this->startApiCall('InstallDeployment', $request, $callOptions)->wait(); - } - - /** - * Lists all deployments in a particular project. - * - * The async variant is {@see self::listDeploymentsAsync()} . - * - * @example samples/V1/GSuiteAddOnsClient/list_deployments.php - * - * @param ListDeploymentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDeployments(ListDeploymentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDeployments', $request, $callOptions); - } - - /** - * Creates or replaces a deployment with the specified name. - * - * The async variant is {@see self::replaceDeploymentAsync()} . - * - * @example samples/V1/GSuiteAddOnsClient/replace_deployment.php - * - * @param ReplaceDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Deployment - * - * @throws ApiException Thrown if the API call fails. - */ - public function replaceDeployment(ReplaceDeploymentRequest $request, array $callOptions = []): Deployment - { - return $this->startApiCall('ReplaceDeployment', $request, $callOptions)->wait(); - } - - /** - * Uninstalls a developer mode deployment. - * See: - * https://developers.google.com/gsuite/add-ons/how-tos/testing-gsuite-addons. - * - * The async variant is {@see self::uninstallDeploymentAsync()} . - * - * @example samples/V1/GSuiteAddOnsClient/uninstall_deployment.php - * - * @param UninstallDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function uninstallDeployment(UninstallDeploymentRequest $request, array $callOptions = []): void - { - $this->startApiCall('UninstallDeployment', $request, $callOptions)->wait(); - } -} diff --git a/GSuiteAddOns/src/V1/Client/GSuiteAddOnsClient.php b/GSuiteAddOns/src/V1/Client/GSuiteAddOnsClient.php index 95e8054f51ca..048becd5d353 100644 --- a/GSuiteAddOns/src/V1/Client/GSuiteAddOnsClient.php +++ b/GSuiteAddOns/src/V1/Client/GSuiteAddOnsClient.php @@ -24,17 +24,514 @@ namespace Google\Cloud\GSuiteAddOns\V1\Client; -use Google\Cloud\GSuiteAddOns\V1\Client\BaseClient\GSuiteAddOnsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\GSuiteAddOns\V1\Authorization; +use Google\Cloud\GSuiteAddOns\V1\CreateDeploymentRequest; +use Google\Cloud\GSuiteAddOns\V1\DeleteDeploymentRequest; +use Google\Cloud\GSuiteAddOns\V1\Deployment; +use Google\Cloud\GSuiteAddOns\V1\GetAuthorizationRequest; +use Google\Cloud\GSuiteAddOns\V1\GetDeploymentRequest; +use Google\Cloud\GSuiteAddOns\V1\GetInstallStatusRequest; +use Google\Cloud\GSuiteAddOns\V1\InstallDeploymentRequest; +use Google\Cloud\GSuiteAddOns\V1\InstallStatus; +use Google\Cloud\GSuiteAddOns\V1\ListDeploymentsRequest; +use Google\Cloud\GSuiteAddOns\V1\ReplaceDeploymentRequest; +use Google\Cloud\GSuiteAddOns\V1\UninstallDeploymentRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service for managing Google Workspace Add-ons deployments. * - * This class is currently experimental and may be subject to changes. + * A Google Workspace Add-on is a third-party embedded component that can be + * installed in Google Workspace Applications like Gmail, Calendar, Drive, and + * the Google Docs, Sheets, and Slides editors. Google Workspace Add-ons can + * display UI cards, receive contextual information from the host application, + * and perform actions in the host application (See: + * https://developers.google.com/gsuite/add-ons/overview for more information). + * + * A Google Workspace Add-on deployment resource specifies metadata about the + * add-on, including a specification of the entry points in the host application + * that trigger add-on executions (see: + * https://developers.google.com/gsuite/add-ons/concepts/gsuite-manifests). + * Add-on deployments defined via the Google Workspace Add-ons API define their + * entrypoints using HTTPS URLs (See: + * https://developers.google.com/gsuite/add-ons/guides/alternate-runtimes), + * + * A Google Workspace Add-on deployment can be installed in developer mode, + * which allows an add-on developer to test the experience an end-user would see + * when installing and running the add-on in their G Suite applications. When + * running in developer mode, more detailed error messages are exposed in the + * add-on UI to aid in debugging. + * + * A Google Workspace Add-on deployment can be published to Google Workspace + * Marketplace, which allows other Google Workspace users to discover and + * install the add-on. See: + * https://developers.google.com/gsuite/add-ons/how-tos/publish-add-on-overview + * for details. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\GSuiteAddOns\V1\GSuiteAddOnsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createDeploymentAsync(CreateDeploymentRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDeploymentAsync(DeleteDeploymentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAuthorizationAsync(GetAuthorizationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDeploymentAsync(GetDeploymentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInstallStatusAsync(GetInstallStatusRequest $request, array $optionalArgs = []) + * @method PromiseInterface installDeploymentAsync(InstallDeploymentRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDeploymentsAsync(ListDeploymentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface replaceDeploymentAsync(ReplaceDeploymentRequest $request, array $optionalArgs = []) + * @method PromiseInterface uninstallDeploymentAsync(UninstallDeploymentRequest $request, array $optionalArgs = []) */ -final class GSuiteAddOnsClient extends GSuiteAddOnsBaseClient +final class GSuiteAddOnsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see GSuiteAddOnsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.gsuiteaddons.v1.GSuiteAddOns'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'gsuiteaddons.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/g_suite_add_ons_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/g_suite_add_ons_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/g_suite_add_ons_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/g_suite_add_ons_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * authorization resource. + * + * @param string $project + * + * @return string The formatted authorization resource. + */ + public static function authorizationName(string $project): string + { + return self::getPathTemplate('authorization')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a deployment + * resource. + * + * @param string $project + * @param string $deployment + * + * @return string The formatted deployment resource. + */ + public static function deploymentName(string $project, string $deployment): string + { + return self::getPathTemplate('deployment')->render([ + 'project' => $project, + 'deployment' => $deployment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * install_status resource. + * + * @param string $project + * @param string $deployment + * + * @return string The formatted install_status resource. + */ + public static function installStatusName(string $project, string $deployment): string + { + return self::getPathTemplate('installStatus')->render([ + 'project' => $project, + 'deployment' => $deployment, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->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 + * - authorization: projects/{project}/authorization + * - deployment: projects/{project}/deployments/{deployment} + * - installStatus: projects/{project}/deployments/{deployment}/installStatus + * - 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. + */ + public static function parseName(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'gsuiteaddons.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a deployment with the specified name and configuration. + * + * The async variant is {@see GSuiteAddOnsClient::createDeploymentAsync()} . + * + * @example samples/V1/GSuiteAddOnsClient/create_deployment.php + * + * @param CreateDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Deployment + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDeployment(CreateDeploymentRequest $request, array $callOptions = []): Deployment + { + return $this->startApiCall('CreateDeployment', $request, $callOptions)->wait(); + } + + /** + * Deletes the deployment with the given name. + * + * The async variant is {@see GSuiteAddOnsClient::deleteDeploymentAsync()} . + * + * @example samples/V1/GSuiteAddOnsClient/delete_deployment.php + * + * @param DeleteDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDeployment(DeleteDeploymentRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteDeployment', $request, $callOptions)->wait(); + } + + /** + * Gets the authorization information for deployments in a given project. + * + * The async variant is {@see GSuiteAddOnsClient::getAuthorizationAsync()} . + * + * @example samples/V1/GSuiteAddOnsClient/get_authorization.php + * + * @param GetAuthorizationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Authorization + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAuthorization(GetAuthorizationRequest $request, array $callOptions = []): Authorization + { + return $this->startApiCall('GetAuthorization', $request, $callOptions)->wait(); + } + + /** + * Gets the deployment with the specified name. + * + * The async variant is {@see GSuiteAddOnsClient::getDeploymentAsync()} . + * + * @example samples/V1/GSuiteAddOnsClient/get_deployment.php + * + * @param GetDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Deployment + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDeployment(GetDeploymentRequest $request, array $callOptions = []): Deployment + { + return $this->startApiCall('GetDeployment', $request, $callOptions)->wait(); + } + + /** + * Fetches the install status of a developer mode deployment. + * + * The async variant is {@see GSuiteAddOnsClient::getInstallStatusAsync()} . + * + * @example samples/V1/GSuiteAddOnsClient/get_install_status.php + * + * @param GetInstallStatusRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InstallStatus + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInstallStatus(GetInstallStatusRequest $request, array $callOptions = []): InstallStatus + { + return $this->startApiCall('GetInstallStatus', $request, $callOptions)->wait(); + } + + /** + * Installs a deployment in developer mode. + * See: + * https://developers.google.com/gsuite/add-ons/how-tos/testing-gsuite-addons. + * + * The async variant is {@see GSuiteAddOnsClient::installDeploymentAsync()} . + * + * @example samples/V1/GSuiteAddOnsClient/install_deployment.php + * + * @param InstallDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function installDeployment(InstallDeploymentRequest $request, array $callOptions = []): void + { + $this->startApiCall('InstallDeployment', $request, $callOptions)->wait(); + } + + /** + * Lists all deployments in a particular project. + * + * The async variant is {@see GSuiteAddOnsClient::listDeploymentsAsync()} . + * + * @example samples/V1/GSuiteAddOnsClient/list_deployments.php + * + * @param ListDeploymentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDeployments(ListDeploymentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDeployments', $request, $callOptions); + } + + /** + * Creates or replaces a deployment with the specified name. + * + * The async variant is {@see GSuiteAddOnsClient::replaceDeploymentAsync()} . + * + * @example samples/V1/GSuiteAddOnsClient/replace_deployment.php + * + * @param ReplaceDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Deployment + * + * @throws ApiException Thrown if the API call fails. + */ + public function replaceDeployment(ReplaceDeploymentRequest $request, array $callOptions = []): Deployment + { + return $this->startApiCall('ReplaceDeployment', $request, $callOptions)->wait(); + } + + /** + * Uninstalls a developer mode deployment. + * See: + * https://developers.google.com/gsuite/add-ons/how-tos/testing-gsuite-addons. + * + * The async variant is {@see GSuiteAddOnsClient::uninstallDeploymentAsync()} . + * + * @example samples/V1/GSuiteAddOnsClient/uninstall_deployment.php + * + * @param UninstallDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function uninstallDeployment(UninstallDeploymentRequest $request, array $callOptions = []): void + { + $this->startApiCall('UninstallDeployment', $request, $callOptions)->wait(); + } } diff --git a/Gaming/composer.json b/Gaming/composer.json index 4a46daa361d2..f8941814099d 100644 --- a/Gaming/composer.json +++ b/Gaming/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/GkeBackup/composer.json b/GkeBackup/composer.json index 2e729ade6df7..5dfe25a100ff 100644 --- a/GkeBackup/composer.json +++ b/GkeBackup/composer.json @@ -19,7 +19,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/GkeBackup/src/V1/Client/BackupForGKEClient.php b/GkeBackup/src/V1/Client/BackupForGKEClient.php index 468725210438..eef87fde94cb 100644 --- a/GkeBackup/src/V1/Client/BackupForGKEClient.php +++ b/GkeBackup/src/V1/Client/BackupForGKEClient.php @@ -24,17 +24,1226 @@ namespace Google\Cloud\GkeBackup\V1\Client; -use Google\Cloud\GkeBackup\V1\Client\BaseClient\BackupForGKEBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\GkeBackup\V1\Backup; +use Google\Cloud\GkeBackup\V1\BackupPlan; +use Google\Cloud\GkeBackup\V1\CreateBackupPlanRequest; +use Google\Cloud\GkeBackup\V1\CreateBackupRequest; +use Google\Cloud\GkeBackup\V1\CreateRestorePlanRequest; +use Google\Cloud\GkeBackup\V1\CreateRestoreRequest; +use Google\Cloud\GkeBackup\V1\DeleteBackupPlanRequest; +use Google\Cloud\GkeBackup\V1\DeleteBackupRequest; +use Google\Cloud\GkeBackup\V1\DeleteRestorePlanRequest; +use Google\Cloud\GkeBackup\V1\DeleteRestoreRequest; +use Google\Cloud\GkeBackup\V1\GetBackupPlanRequest; +use Google\Cloud\GkeBackup\V1\GetBackupRequest; +use Google\Cloud\GkeBackup\V1\GetRestorePlanRequest; +use Google\Cloud\GkeBackup\V1\GetRestoreRequest; +use Google\Cloud\GkeBackup\V1\GetVolumeBackupRequest; +use Google\Cloud\GkeBackup\V1\GetVolumeRestoreRequest; +use Google\Cloud\GkeBackup\V1\ListBackupPlansRequest; +use Google\Cloud\GkeBackup\V1\ListBackupsRequest; +use Google\Cloud\GkeBackup\V1\ListRestorePlansRequest; +use Google\Cloud\GkeBackup\V1\ListRestoresRequest; +use Google\Cloud\GkeBackup\V1\ListVolumeBackupsRequest; +use Google\Cloud\GkeBackup\V1\ListVolumeRestoresRequest; +use Google\Cloud\GkeBackup\V1\Restore; +use Google\Cloud\GkeBackup\V1\RestorePlan; +use Google\Cloud\GkeBackup\V1\UpdateBackupPlanRequest; +use Google\Cloud\GkeBackup\V1\UpdateBackupRequest; +use Google\Cloud\GkeBackup\V1\UpdateRestorePlanRequest; +use Google\Cloud\GkeBackup\V1\UpdateRestoreRequest; +use Google\Cloud\GkeBackup\V1\VolumeBackup; +use Google\Cloud\GkeBackup\V1\VolumeRestore; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: BackupForGKE allows Kubernetes administrators to configure, execute, and + * manage backup and restore operations for their GKE clusters. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\GkeBackup\V1\BackupForGKEClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createBackupAsync(CreateBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface createBackupPlanAsync(CreateBackupPlanRequest $request, array $optionalArgs = []) + * @method PromiseInterface createRestoreAsync(CreateRestoreRequest $request, array $optionalArgs = []) + * @method PromiseInterface createRestorePlanAsync(CreateRestorePlanRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteBackupAsync(DeleteBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteBackupPlanAsync(DeleteBackupPlanRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteRestoreAsync(DeleteRestoreRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteRestorePlanAsync(DeleteRestorePlanRequest $request, array $optionalArgs = []) + * @method PromiseInterface getBackupAsync(GetBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface getBackupPlanAsync(GetBackupPlanRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRestoreAsync(GetRestoreRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRestorePlanAsync(GetRestorePlanRequest $request, array $optionalArgs = []) + * @method PromiseInterface getVolumeBackupAsync(GetVolumeBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface getVolumeRestoreAsync(GetVolumeRestoreRequest $request, array $optionalArgs = []) + * @method PromiseInterface listBackupPlansAsync(ListBackupPlansRequest $request, array $optionalArgs = []) + * @method PromiseInterface listBackupsAsync(ListBackupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listRestorePlansAsync(ListRestorePlansRequest $request, array $optionalArgs = []) + * @method PromiseInterface listRestoresAsync(ListRestoresRequest $request, array $optionalArgs = []) + * @method PromiseInterface listVolumeBackupsAsync(ListVolumeBackupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listVolumeRestoresAsync(ListVolumeRestoresRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateBackupAsync(UpdateBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateBackupPlanAsync(UpdateBackupPlanRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateRestoreAsync(UpdateRestoreRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateRestorePlanAsync(UpdateRestorePlanRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class BackupForGKEClient extends BackupForGKEBaseClient +final class BackupForGKEClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see BackupForGKEBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.gkebackup.v1.BackupForGKE'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'gkebackup.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/backup_for_gke_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/backup_for_gke_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/backup_for_gke_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/backup_for_gke_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a backup + * resource. + * + * @param string $project + * @param string $location + * @param string $backupPlan + * @param string $backup + * + * @return string The formatted backup resource. + */ + public static function backupName(string $project, string $location, string $backupPlan, string $backup): string + { + return self::getPathTemplate('backup')->render([ + 'project' => $project, + 'location' => $location, + 'backup_plan' => $backupPlan, + 'backup' => $backup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a backup_plan + * resource. + * + * @param string $project + * @param string $location + * @param string $backupPlan + * + * @return string The formatted backup_plan resource. + */ + public static function backupPlanName(string $project, string $location, string $backupPlan): string + { + return self::getPathTemplate('backupPlan')->render([ + 'project' => $project, + 'location' => $location, + 'backup_plan' => $backupPlan, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a cluster + * resource. + * + * @param string $project + * @param string $location + * @param string $cluster + * + * @return string The formatted cluster resource. + */ + public static function clusterName(string $project, string $location, string $cluster): string + { + return self::getPathTemplate('cluster')->render([ + 'project' => $project, + 'location' => $location, + 'cluster' => $cluster, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a crypto_key + * resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * + * @return string The formatted crypto_key resource. + */ + public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string + { + return self::getPathTemplate('cryptoKey')->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'crypto_key' => $cryptoKey, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a restore + * resource. + * + * @param string $project + * @param string $location + * @param string $restorePlan + * @param string $restore + * + * @return string The formatted restore resource. + */ + public static function restoreName(string $project, string $location, string $restorePlan, string $restore): string + { + return self::getPathTemplate('restore')->render([ + 'project' => $project, + 'location' => $location, + 'restore_plan' => $restorePlan, + 'restore' => $restore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a restore_plan + * resource. + * + * @param string $project + * @param string $location + * @param string $restorePlan + * + * @return string The formatted restore_plan resource. + */ + public static function restorePlanName(string $project, string $location, string $restorePlan): string + { + return self::getPathTemplate('restorePlan')->render([ + 'project' => $project, + 'location' => $location, + 'restore_plan' => $restorePlan, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * volume_backup resource. + * + * @param string $project + * @param string $location + * @param string $backupPlan + * @param string $backup + * @param string $volumeBackup + * + * @return string The formatted volume_backup resource. + */ + public static function volumeBackupName(string $project, string $location, string $backupPlan, string $backup, string $volumeBackup): string + { + return self::getPathTemplate('volumeBackup')->render([ + 'project' => $project, + 'location' => $location, + 'backup_plan' => $backupPlan, + 'backup' => $backup, + 'volume_backup' => $volumeBackup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * volume_restore resource. + * + * @param string $project + * @param string $location + * @param string $restorePlan + * @param string $restore + * @param string $volumeRestore + * + * @return string The formatted volume_restore resource. + */ + public static function volumeRestoreName(string $project, string $location, string $restorePlan, string $restore, string $volumeRestore): string + { + return self::getPathTemplate('volumeRestore')->render([ + 'project' => $project, + 'location' => $location, + 'restore_plan' => $restorePlan, + 'restore' => $restore, + 'volume_restore' => $volumeRestore, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - backup: projects/{project}/locations/{location}/backupPlans/{backup_plan}/backups/{backup} + * - backupPlan: projects/{project}/locations/{location}/backupPlans/{backup_plan} + * - cluster: projects/{project}/locations/{location}/clusters/{cluster} + * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} + * - location: projects/{project}/locations/{location} + * - restore: projects/{project}/locations/{location}/restorePlans/{restore_plan}/restores/{restore} + * - restorePlan: projects/{project}/locations/{location}/restorePlans/{restore_plan} + * - volumeBackup: projects/{project}/locations/{location}/backupPlans/{backup_plan}/backups/{backup}/volumeBackups/{volume_backup} + * - volumeRestore: projects/{project}/locations/{location}/restorePlans/{restore_plan}/restores/{restore}/volumeRestores/{volume_restore} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'gkebackup.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a Backup for the given BackupPlan. + * + * The async variant is {@see BackupForGKEClient::createBackupAsync()} . + * + * @example samples/V1/BackupForGKEClient/create_backup.php + * + * @param CreateBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createBackup(CreateBackupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateBackup', $request, $callOptions)->wait(); + } + + /** + * Creates a new BackupPlan in a given location. + * + * The async variant is {@see BackupForGKEClient::createBackupPlanAsync()} . + * + * @example samples/V1/BackupForGKEClient/create_backup_plan.php + * + * @param CreateBackupPlanRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createBackupPlan(CreateBackupPlanRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateBackupPlan', $request, $callOptions)->wait(); + } + + /** + * Creates a new Restore for the given RestorePlan. + * + * The async variant is {@see BackupForGKEClient::createRestoreAsync()} . + * + * @example samples/V1/BackupForGKEClient/create_restore.php + * + * @param CreateRestoreRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createRestore(CreateRestoreRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateRestore', $request, $callOptions)->wait(); + } + + /** + * Creates a new RestorePlan in a given location. + * + * The async variant is {@see BackupForGKEClient::createRestorePlanAsync()} . + * + * @example samples/V1/BackupForGKEClient/create_restore_plan.php + * + * @param CreateRestorePlanRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createRestorePlan(CreateRestorePlanRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateRestorePlan', $request, $callOptions)->wait(); + } + + /** + * Deletes an existing Backup. + * + * The async variant is {@see BackupForGKEClient::deleteBackupAsync()} . + * + * @example samples/V1/BackupForGKEClient/delete_backup.php + * + * @param DeleteBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteBackup(DeleteBackupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteBackup', $request, $callOptions)->wait(); + } + + /** + * Deletes an existing BackupPlan. + * + * The async variant is {@see BackupForGKEClient::deleteBackupPlanAsync()} . + * + * @example samples/V1/BackupForGKEClient/delete_backup_plan.php + * + * @param DeleteBackupPlanRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteBackupPlan(DeleteBackupPlanRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteBackupPlan', $request, $callOptions)->wait(); + } + + /** + * Deletes an existing Restore. + * + * The async variant is {@see BackupForGKEClient::deleteRestoreAsync()} . + * + * @example samples/V1/BackupForGKEClient/delete_restore.php + * + * @param DeleteRestoreRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteRestore(DeleteRestoreRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteRestore', $request, $callOptions)->wait(); + } + + /** + * Deletes an existing RestorePlan. + * + * The async variant is {@see BackupForGKEClient::deleteRestorePlanAsync()} . + * + * @example samples/V1/BackupForGKEClient/delete_restore_plan.php + * + * @param DeleteRestorePlanRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteRestorePlan(DeleteRestorePlanRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteRestorePlan', $request, $callOptions)->wait(); + } + + /** + * Retrieve the details of a single Backup. + * + * The async variant is {@see BackupForGKEClient::getBackupAsync()} . + * + * @example samples/V1/BackupForGKEClient/get_backup.php + * + * @param GetBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Backup + * + * @throws ApiException Thrown if the API call fails. + */ + public function getBackup(GetBackupRequest $request, array $callOptions = []): Backup + { + return $this->startApiCall('GetBackup', $request, $callOptions)->wait(); + } + + /** + * Retrieve the details of a single BackupPlan. + * + * The async variant is {@see BackupForGKEClient::getBackupPlanAsync()} . + * + * @example samples/V1/BackupForGKEClient/get_backup_plan.php + * + * @param GetBackupPlanRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BackupPlan + * + * @throws ApiException Thrown if the API call fails. + */ + public function getBackupPlan(GetBackupPlanRequest $request, array $callOptions = []): BackupPlan + { + return $this->startApiCall('GetBackupPlan', $request, $callOptions)->wait(); + } + + /** + * Retrieves the details of a single Restore. + * + * The async variant is {@see BackupForGKEClient::getRestoreAsync()} . + * + * @example samples/V1/BackupForGKEClient/get_restore.php + * + * @param GetRestoreRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Restore + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRestore(GetRestoreRequest $request, array $callOptions = []): Restore + { + return $this->startApiCall('GetRestore', $request, $callOptions)->wait(); + } + + /** + * Retrieve the details of a single RestorePlan. + * + * The async variant is {@see BackupForGKEClient::getRestorePlanAsync()} . + * + * @example samples/V1/BackupForGKEClient/get_restore_plan.php + * + * @param GetRestorePlanRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RestorePlan + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRestorePlan(GetRestorePlanRequest $request, array $callOptions = []): RestorePlan + { + return $this->startApiCall('GetRestorePlan', $request, $callOptions)->wait(); + } + + /** + * Retrieve the details of a single VolumeBackup. + * + * The async variant is {@see BackupForGKEClient::getVolumeBackupAsync()} . + * + * @example samples/V1/BackupForGKEClient/get_volume_backup.php + * + * @param GetVolumeBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 VolumeBackup + * + * @throws ApiException Thrown if the API call fails. + */ + public function getVolumeBackup(GetVolumeBackupRequest $request, array $callOptions = []): VolumeBackup + { + return $this->startApiCall('GetVolumeBackup', $request, $callOptions)->wait(); + } + + /** + * Retrieve the details of a single VolumeRestore. + * + * The async variant is {@see BackupForGKEClient::getVolumeRestoreAsync()} . + * + * @example samples/V1/BackupForGKEClient/get_volume_restore.php + * + * @param GetVolumeRestoreRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 VolumeRestore + * + * @throws ApiException Thrown if the API call fails. + */ + public function getVolumeRestore(GetVolumeRestoreRequest $request, array $callOptions = []): VolumeRestore + { + return $this->startApiCall('GetVolumeRestore', $request, $callOptions)->wait(); + } + + /** + * Lists BackupPlans in a given location. + * + * The async variant is {@see BackupForGKEClient::listBackupPlansAsync()} . + * + * @example samples/V1/BackupForGKEClient/list_backup_plans.php + * + * @param ListBackupPlansRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listBackupPlans(ListBackupPlansRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListBackupPlans', $request, $callOptions); + } + + /** + * Lists the Backups for a given BackupPlan. + * + * The async variant is {@see BackupForGKEClient::listBackupsAsync()} . + * + * @example samples/V1/BackupForGKEClient/list_backups.php + * + * @param ListBackupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listBackups(ListBackupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListBackups', $request, $callOptions); + } + + /** + * Lists RestorePlans in a given location. + * + * The async variant is {@see BackupForGKEClient::listRestorePlansAsync()} . + * + * @example samples/V1/BackupForGKEClient/list_restore_plans.php + * + * @param ListRestorePlansRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listRestorePlans(ListRestorePlansRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListRestorePlans', $request, $callOptions); + } + + /** + * Lists the Restores for a given RestorePlan. + * + * The async variant is {@see BackupForGKEClient::listRestoresAsync()} . + * + * @example samples/V1/BackupForGKEClient/list_restores.php + * + * @param ListRestoresRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listRestores(ListRestoresRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListRestores', $request, $callOptions); + } + + /** + * Lists the VolumeBackups for a given Backup. + * + * The async variant is {@see BackupForGKEClient::listVolumeBackupsAsync()} . + * + * @example samples/V1/BackupForGKEClient/list_volume_backups.php + * + * @param ListVolumeBackupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listVolumeBackups(ListVolumeBackupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListVolumeBackups', $request, $callOptions); + } + + /** + * Lists the VolumeRestores for a given Restore. + * + * The async variant is {@see BackupForGKEClient::listVolumeRestoresAsync()} . + * + * @example samples/V1/BackupForGKEClient/list_volume_restores.php + * + * @param ListVolumeRestoresRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listVolumeRestores(ListVolumeRestoresRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListVolumeRestores', $request, $callOptions); + } + + /** + * Update a Backup. + * + * The async variant is {@see BackupForGKEClient::updateBackupAsync()} . + * + * @example samples/V1/BackupForGKEClient/update_backup.php + * + * @param UpdateBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateBackup(UpdateBackupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateBackup', $request, $callOptions)->wait(); + } + + /** + * Update a BackupPlan. + * + * The async variant is {@see BackupForGKEClient::updateBackupPlanAsync()} . + * + * @example samples/V1/BackupForGKEClient/update_backup_plan.php + * + * @param UpdateBackupPlanRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateBackupPlan(UpdateBackupPlanRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateBackupPlan', $request, $callOptions)->wait(); + } + + /** + * Update a Restore. + * + * The async variant is {@see BackupForGKEClient::updateRestoreAsync()} . + * + * @example samples/V1/BackupForGKEClient/update_restore.php + * + * @param UpdateRestoreRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateRestore(UpdateRestoreRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateRestore', $request, $callOptions)->wait(); + } + + /** + * Update a RestorePlan. + * + * The async variant is {@see BackupForGKEClient::updateRestorePlanAsync()} . + * + * @example samples/V1/BackupForGKEClient/update_restore_plan.php + * + * @param UpdateRestorePlanRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateRestorePlan(UpdateRestorePlanRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateRestorePlan', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see BackupForGKEClient::getLocationAsync()} . + * + * @example samples/V1/BackupForGKEClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see BackupForGKEClient::listLocationsAsync()} . + * + * @example samples/V1/BackupForGKEClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see BackupForGKEClient::getIamPolicyAsync()} . + * + * @example samples/V1/BackupForGKEClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see BackupForGKEClient::setIamPolicyAsync()} . + * + * @example samples/V1/BackupForGKEClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see BackupForGKEClient::testIamPermissionsAsync()} . + * + * @example samples/V1/BackupForGKEClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/GkeBackup/src/V1/Client/BaseClient/BackupForGKEBaseClient.php b/GkeBackup/src/V1/Client/BaseClient/BackupForGKEBaseClient.php deleted file mode 100644 index e6c599d75293..000000000000 --- a/GkeBackup/src/V1/Client/BaseClient/BackupForGKEBaseClient.php +++ /dev/null @@ -1,1251 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/backup_for_gke_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/backup_for_gke_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/backup_for_gke_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/backup_for_gke_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a backup - * resource. - * - * @param string $project - * @param string $location - * @param string $backupPlan - * @param string $backup - * - * @return string The formatted backup resource. - */ - public static function backupName(string $project, string $location, string $backupPlan, string $backup): string - { - return self::getPathTemplate('backup')->render([ - 'project' => $project, - 'location' => $location, - 'backup_plan' => $backupPlan, - 'backup' => $backup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a backup_plan - * resource. - * - * @param string $project - * @param string $location - * @param string $backupPlan - * - * @return string The formatted backup_plan resource. - */ - public static function backupPlanName(string $project, string $location, string $backupPlan): string - { - return self::getPathTemplate('backupPlan')->render([ - 'project' => $project, - 'location' => $location, - 'backup_plan' => $backupPlan, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a cluster - * resource. - * - * @param string $project - * @param string $location - * @param string $cluster - * - * @return string The formatted cluster resource. - */ - public static function clusterName(string $project, string $location, string $cluster): string - { - return self::getPathTemplate('cluster')->render([ - 'project' => $project, - 'location' => $location, - 'cluster' => $cluster, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a crypto_key - * resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * @param string $cryptoKey - * - * @return string The formatted crypto_key resource. - */ - public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string - { - return self::getPathTemplate('cryptoKey')->render([ - 'project' => $project, - 'location' => $location, - 'key_ring' => $keyRing, - 'crypto_key' => $cryptoKey, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a restore - * resource. - * - * @param string $project - * @param string $location - * @param string $restorePlan - * @param string $restore - * - * @return string The formatted restore resource. - */ - public static function restoreName(string $project, string $location, string $restorePlan, string $restore): string - { - return self::getPathTemplate('restore')->render([ - 'project' => $project, - 'location' => $location, - 'restore_plan' => $restorePlan, - 'restore' => $restore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a restore_plan - * resource. - * - * @param string $project - * @param string $location - * @param string $restorePlan - * - * @return string The formatted restore_plan resource. - */ - public static function restorePlanName(string $project, string $location, string $restorePlan): string - { - return self::getPathTemplate('restorePlan')->render([ - 'project' => $project, - 'location' => $location, - 'restore_plan' => $restorePlan, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * volume_backup resource. - * - * @param string $project - * @param string $location - * @param string $backupPlan - * @param string $backup - * @param string $volumeBackup - * - * @return string The formatted volume_backup resource. - */ - public static function volumeBackupName(string $project, string $location, string $backupPlan, string $backup, string $volumeBackup): string - { - return self::getPathTemplate('volumeBackup')->render([ - 'project' => $project, - 'location' => $location, - 'backup_plan' => $backupPlan, - 'backup' => $backup, - 'volume_backup' => $volumeBackup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * volume_restore resource. - * - * @param string $project - * @param string $location - * @param string $restorePlan - * @param string $restore - * @param string $volumeRestore - * - * @return string The formatted volume_restore resource. - */ - public static function volumeRestoreName(string $project, string $location, string $restorePlan, string $restore, string $volumeRestore): string - { - return self::getPathTemplate('volumeRestore')->render([ - 'project' => $project, - 'location' => $location, - 'restore_plan' => $restorePlan, - 'restore' => $restore, - 'volume_restore' => $volumeRestore, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - backup: projects/{project}/locations/{location}/backupPlans/{backup_plan}/backups/{backup} - * - backupPlan: projects/{project}/locations/{location}/backupPlans/{backup_plan} - * - cluster: projects/{project}/locations/{location}/clusters/{cluster} - * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} - * - location: projects/{project}/locations/{location} - * - restore: projects/{project}/locations/{location}/restorePlans/{restore_plan}/restores/{restore} - * - restorePlan: projects/{project}/locations/{location}/restorePlans/{restore_plan} - * - volumeBackup: projects/{project}/locations/{location}/backupPlans/{backup_plan}/backups/{backup}/volumeBackups/{volume_backup} - * - volumeRestore: projects/{project}/locations/{location}/restorePlans/{restore_plan}/restores/{restore}/volumeRestores/{volume_restore} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'gkebackup.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a Backup for the given BackupPlan. - * - * The async variant is {@see self::createBackupAsync()} . - * - * @example samples/V1/BackupForGKEClient/create_backup.php - * - * @param CreateBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createBackup(CreateBackupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateBackup', $request, $callOptions)->wait(); - } - - /** - * Creates a new BackupPlan in a given location. - * - * The async variant is {@see self::createBackupPlanAsync()} . - * - * @example samples/V1/BackupForGKEClient/create_backup_plan.php - * - * @param CreateBackupPlanRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createBackupPlan(CreateBackupPlanRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateBackupPlan', $request, $callOptions)->wait(); - } - - /** - * Creates a new Restore for the given RestorePlan. - * - * The async variant is {@see self::createRestoreAsync()} . - * - * @example samples/V1/BackupForGKEClient/create_restore.php - * - * @param CreateRestoreRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createRestore(CreateRestoreRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateRestore', $request, $callOptions)->wait(); - } - - /** - * Creates a new RestorePlan in a given location. - * - * The async variant is {@see self::createRestorePlanAsync()} . - * - * @example samples/V1/BackupForGKEClient/create_restore_plan.php - * - * @param CreateRestorePlanRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createRestorePlan(CreateRestorePlanRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateRestorePlan', $request, $callOptions)->wait(); - } - - /** - * Deletes an existing Backup. - * - * The async variant is {@see self::deleteBackupAsync()} . - * - * @example samples/V1/BackupForGKEClient/delete_backup.php - * - * @param DeleteBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteBackup(DeleteBackupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteBackup', $request, $callOptions)->wait(); - } - - /** - * Deletes an existing BackupPlan. - * - * The async variant is {@see self::deleteBackupPlanAsync()} . - * - * @example samples/V1/BackupForGKEClient/delete_backup_plan.php - * - * @param DeleteBackupPlanRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteBackupPlan(DeleteBackupPlanRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteBackupPlan', $request, $callOptions)->wait(); - } - - /** - * Deletes an existing Restore. - * - * The async variant is {@see self::deleteRestoreAsync()} . - * - * @example samples/V1/BackupForGKEClient/delete_restore.php - * - * @param DeleteRestoreRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteRestore(DeleteRestoreRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteRestore', $request, $callOptions)->wait(); - } - - /** - * Deletes an existing RestorePlan. - * - * The async variant is {@see self::deleteRestorePlanAsync()} . - * - * @example samples/V1/BackupForGKEClient/delete_restore_plan.php - * - * @param DeleteRestorePlanRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteRestorePlan(DeleteRestorePlanRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteRestorePlan', $request, $callOptions)->wait(); - } - - /** - * Retrieve the details of a single Backup. - * - * The async variant is {@see self::getBackupAsync()} . - * - * @example samples/V1/BackupForGKEClient/get_backup.php - * - * @param GetBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Backup - * - * @throws ApiException Thrown if the API call fails. - */ - public function getBackup(GetBackupRequest $request, array $callOptions = []): Backup - { - return $this->startApiCall('GetBackup', $request, $callOptions)->wait(); - } - - /** - * Retrieve the details of a single BackupPlan. - * - * The async variant is {@see self::getBackupPlanAsync()} . - * - * @example samples/V1/BackupForGKEClient/get_backup_plan.php - * - * @param GetBackupPlanRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BackupPlan - * - * @throws ApiException Thrown if the API call fails. - */ - public function getBackupPlan(GetBackupPlanRequest $request, array $callOptions = []): BackupPlan - { - return $this->startApiCall('GetBackupPlan', $request, $callOptions)->wait(); - } - - /** - * Retrieves the details of a single Restore. - * - * The async variant is {@see self::getRestoreAsync()} . - * - * @example samples/V1/BackupForGKEClient/get_restore.php - * - * @param GetRestoreRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Restore - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRestore(GetRestoreRequest $request, array $callOptions = []): Restore - { - return $this->startApiCall('GetRestore', $request, $callOptions)->wait(); - } - - /** - * Retrieve the details of a single RestorePlan. - * - * The async variant is {@see self::getRestorePlanAsync()} . - * - * @example samples/V1/BackupForGKEClient/get_restore_plan.php - * - * @param GetRestorePlanRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RestorePlan - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRestorePlan(GetRestorePlanRequest $request, array $callOptions = []): RestorePlan - { - return $this->startApiCall('GetRestorePlan', $request, $callOptions)->wait(); - } - - /** - * Retrieve the details of a single VolumeBackup. - * - * The async variant is {@see self::getVolumeBackupAsync()} . - * - * @example samples/V1/BackupForGKEClient/get_volume_backup.php - * - * @param GetVolumeBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 VolumeBackup - * - * @throws ApiException Thrown if the API call fails. - */ - public function getVolumeBackup(GetVolumeBackupRequest $request, array $callOptions = []): VolumeBackup - { - return $this->startApiCall('GetVolumeBackup', $request, $callOptions)->wait(); - } - - /** - * Retrieve the details of a single VolumeRestore. - * - * The async variant is {@see self::getVolumeRestoreAsync()} . - * - * @example samples/V1/BackupForGKEClient/get_volume_restore.php - * - * @param GetVolumeRestoreRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 VolumeRestore - * - * @throws ApiException Thrown if the API call fails. - */ - public function getVolumeRestore(GetVolumeRestoreRequest $request, array $callOptions = []): VolumeRestore - { - return $this->startApiCall('GetVolumeRestore', $request, $callOptions)->wait(); - } - - /** - * Lists BackupPlans in a given location. - * - * The async variant is {@see self::listBackupPlansAsync()} . - * - * @example samples/V1/BackupForGKEClient/list_backup_plans.php - * - * @param ListBackupPlansRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listBackupPlans(ListBackupPlansRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListBackupPlans', $request, $callOptions); - } - - /** - * Lists the Backups for a given BackupPlan. - * - * The async variant is {@see self::listBackupsAsync()} . - * - * @example samples/V1/BackupForGKEClient/list_backups.php - * - * @param ListBackupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listBackups(ListBackupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListBackups', $request, $callOptions); - } - - /** - * Lists RestorePlans in a given location. - * - * The async variant is {@see self::listRestorePlansAsync()} . - * - * @example samples/V1/BackupForGKEClient/list_restore_plans.php - * - * @param ListRestorePlansRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listRestorePlans(ListRestorePlansRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListRestorePlans', $request, $callOptions); - } - - /** - * Lists the Restores for a given RestorePlan. - * - * The async variant is {@see self::listRestoresAsync()} . - * - * @example samples/V1/BackupForGKEClient/list_restores.php - * - * @param ListRestoresRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listRestores(ListRestoresRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListRestores', $request, $callOptions); - } - - /** - * Lists the VolumeBackups for a given Backup. - * - * The async variant is {@see self::listVolumeBackupsAsync()} . - * - * @example samples/V1/BackupForGKEClient/list_volume_backups.php - * - * @param ListVolumeBackupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listVolumeBackups(ListVolumeBackupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListVolumeBackups', $request, $callOptions); - } - - /** - * Lists the VolumeRestores for a given Restore. - * - * The async variant is {@see self::listVolumeRestoresAsync()} . - * - * @example samples/V1/BackupForGKEClient/list_volume_restores.php - * - * @param ListVolumeRestoresRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listVolumeRestores(ListVolumeRestoresRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListVolumeRestores', $request, $callOptions); - } - - /** - * Update a Backup. - * - * The async variant is {@see self::updateBackupAsync()} . - * - * @example samples/V1/BackupForGKEClient/update_backup.php - * - * @param UpdateBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateBackup(UpdateBackupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateBackup', $request, $callOptions)->wait(); - } - - /** - * Update a BackupPlan. - * - * The async variant is {@see self::updateBackupPlanAsync()} . - * - * @example samples/V1/BackupForGKEClient/update_backup_plan.php - * - * @param UpdateBackupPlanRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateBackupPlan(UpdateBackupPlanRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateBackupPlan', $request, $callOptions)->wait(); - } - - /** - * Update a Restore. - * - * The async variant is {@see self::updateRestoreAsync()} . - * - * @example samples/V1/BackupForGKEClient/update_restore.php - * - * @param UpdateRestoreRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateRestore(UpdateRestoreRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateRestore', $request, $callOptions)->wait(); - } - - /** - * Update a RestorePlan. - * - * The async variant is {@see self::updateRestorePlanAsync()} . - * - * @example samples/V1/BackupForGKEClient/update_restore_plan.php - * - * @param UpdateRestorePlanRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateRestorePlan(UpdateRestorePlanRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateRestorePlan', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/BackupForGKEClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/BackupForGKEClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/BackupForGKEClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/BackupForGKEClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/BackupForGKEClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/GkeConnectGateway/composer.json b/GkeConnectGateway/composer.json index 7642fb2d3955..2dc2acd074ce 100644 --- a/GkeConnectGateway/composer.json +++ b/GkeConnectGateway/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/GkeConnectGateway/src/V1beta1/Client/BaseClient/GatewayServiceBaseClient.php b/GkeConnectGateway/src/V1beta1/Client/BaseClient/GatewayServiceBaseClient.php deleted file mode 100644 index 339d5a11b380..000000000000 --- a/GkeConnectGateway/src/V1beta1/Client/BaseClient/GatewayServiceBaseClient.php +++ /dev/null @@ -1,314 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/gateway_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/gateway_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/gateway_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/gateway_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'connectgateway.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); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * DeleteResource performs an HTTP DELETE on the Kubernetes API Server. - * - * The async variant is {@see self::deleteResourceAsync()} . - * - * @example samples/V1beta1/GatewayServiceClient/delete_resource.php - * - * @param HttpBody $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 HttpBody - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteResource(HttpBody $request, array $callOptions = []): HttpBody - { - return $this->startApiCall('DeleteResource', $request, $callOptions)->wait(); - } - - /** - * GetResource performs an HTTP GET request on the Kubernetes API Server. - * - * The async variant is {@see self::getResourceAsync()} . - * - * @example samples/V1beta1/GatewayServiceClient/get_resource.php - * - * @param HttpBody $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 HttpBody - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getResource(HttpBody $request, array $callOptions = []): HttpBody - { - return $this->startApiCall('GetResource', $request, $callOptions)->wait(); - } - - /** - * PatchResource performs an HTTP PATCH on the Kubernetes API Server. - * - * The async variant is {@see self::patchResourceAsync()} . - * - * @example samples/V1beta1/GatewayServiceClient/patch_resource.php - * - * @param HttpBody $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 HttpBody - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function patchResource(HttpBody $request, array $callOptions = []): HttpBody - { - return $this->startApiCall('PatchResource', $request, $callOptions)->wait(); - } - - /** - * PostResource performs an HTTP POST on the Kubernetes API Server. - * - * The async variant is {@see self::postResourceAsync()} . - * - * @example samples/V1beta1/GatewayServiceClient/post_resource.php - * - * @param HttpBody $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 HttpBody - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function postResource(HttpBody $request, array $callOptions = []): HttpBody - { - return $this->startApiCall('PostResource', $request, $callOptions)->wait(); - } - - /** - * PutResource performs an HTTP PUT on the Kubernetes API Server. - * - * The async variant is {@see self::putResourceAsync()} . - * - * @example samples/V1beta1/GatewayServiceClient/put_resource.php - * - * @param HttpBody $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 HttpBody - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function putResource(HttpBody $request, array $callOptions = []): HttpBody - { - return $this->startApiCall('PutResource', $request, $callOptions)->wait(); - } -} diff --git a/GkeConnectGateway/src/V1beta1/Client/GatewayServiceClient.php b/GkeConnectGateway/src/V1beta1/Client/GatewayServiceClient.php index 769dad76db63..19208f3e631c 100644 --- a/GkeConnectGateway/src/V1beta1/Client/GatewayServiceClient.php +++ b/GkeConnectGateway/src/V1beta1/Client/GatewayServiceClient.php @@ -26,17 +26,287 @@ namespace Google\Cloud\GkeConnect\Gateway\V1beta1\Client; -use Google\Cloud\GkeConnect\Gateway\V1beta1\Client\BaseClient\GatewayServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Api\HttpBody; +use Google\Auth\FetchAuthTokenInterface; +use Google\Protobuf\Any; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Gateway service is a public API which works as a Kubernetes resource model + * proxy between end users and registered Kubernetes clusters. Each RPC in this + * service matches with an HTTP verb. End user will initiate kubectl commands + * against the Gateway service, and Gateway service will forward user requests + * to clusters. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface deleteResourceAsync(HttpBody $request, array $optionalArgs = []) + * @method PromiseInterface getResourceAsync(HttpBody $request, array $optionalArgs = []) + * @method PromiseInterface patchResourceAsync(HttpBody $request, array $optionalArgs = []) + * @method PromiseInterface postResourceAsync(HttpBody $request, array $optionalArgs = []) + * @method PromiseInterface putResourceAsync(HttpBody $request, array $optionalArgs = []) */ -final class GatewayServiceClient extends GatewayServiceBaseClient +final class GatewayServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see GatewayServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.gkeconnect.gateway.v1beta1.GatewayService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'connectgateway.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/gateway_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/gateway_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/gateway_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/gateway_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'connectgateway.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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * DeleteResource performs an HTTP DELETE on the Kubernetes API Server. + * + * The async variant is {@see GatewayServiceClient::deleteResourceAsync()} . + * + * @example samples/V1beta1/GatewayServiceClient/delete_resource.php + * + * @param HttpBody $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 HttpBody + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteResource(HttpBody $request, array $callOptions = []): HttpBody + { + return $this->startApiCall('DeleteResource', $request, $callOptions)->wait(); + } + + /** + * GetResource performs an HTTP GET request on the Kubernetes API Server. + * + * The async variant is {@see GatewayServiceClient::getResourceAsync()} . + * + * @example samples/V1beta1/GatewayServiceClient/get_resource.php + * + * @param HttpBody $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 HttpBody + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getResource(HttpBody $request, array $callOptions = []): HttpBody + { + return $this->startApiCall('GetResource', $request, $callOptions)->wait(); + } + + /** + * PatchResource performs an HTTP PATCH on the Kubernetes API Server. + * + * The async variant is {@see GatewayServiceClient::patchResourceAsync()} . + * + * @example samples/V1beta1/GatewayServiceClient/patch_resource.php + * + * @param HttpBody $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 HttpBody + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function patchResource(HttpBody $request, array $callOptions = []): HttpBody + { + return $this->startApiCall('PatchResource', $request, $callOptions)->wait(); + } + + /** + * PostResource performs an HTTP POST on the Kubernetes API Server. + * + * The async variant is {@see GatewayServiceClient::postResourceAsync()} . + * + * @example samples/V1beta1/GatewayServiceClient/post_resource.php + * + * @param HttpBody $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 HttpBody + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function postResource(HttpBody $request, array $callOptions = []): HttpBody + { + return $this->startApiCall('PostResource', $request, $callOptions)->wait(); + } + + /** + * PutResource performs an HTTP PUT on the Kubernetes API Server. + * + * The async variant is {@see GatewayServiceClient::putResourceAsync()} . + * + * @example samples/V1beta1/GatewayServiceClient/put_resource.php + * + * @param HttpBody $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 HttpBody + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function putResource(HttpBody $request, array $callOptions = []): HttpBody + { + return $this->startApiCall('PutResource', $request, $callOptions)->wait(); + } } diff --git a/GkeHub/composer.json b/GkeHub/composer.json index d7c1d5837e0b..1fed3142aaf5 100644 --- a/GkeHub/composer.json +++ b/GkeHub/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/GkeHub/src/V1/Client/BaseClient/GkeHubBaseClient.php b/GkeHub/src/V1/Client/BaseClient/GkeHubBaseClient.php deleted file mode 100644 index 602ed56c9d07..000000000000 --- a/GkeHub/src/V1/Client/BaseClient/GkeHubBaseClient.php +++ /dev/null @@ -1,621 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/gke_hub_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/gke_hub_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/gke_hub_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/gke_hub_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a feature - * resource. - * - * @param string $project - * @param string $location - * @param string $feature - * - * @return string The formatted feature resource. - */ - public static function featureName(string $project, string $location, string $feature): string - { - return self::getPathTemplate('feature')->render([ - 'project' => $project, - 'location' => $location, - 'feature' => $feature, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a membership - * resource. - * - * @param string $project - * @param string $location - * @param string $membership - * - * @return string The formatted membership resource. - */ - public static function membershipName(string $project, string $location, string $membership): string - { - return self::getPathTemplate('membership')->render([ - 'project' => $project, - 'location' => $location, - 'membership' => $membership, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - feature: projects/{project}/locations/{location}/features/{feature} - * - location: projects/{project}/locations/{location} - * - membership: projects/{project}/locations/{location}/memberships/{membership} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'gkehub.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Adds a new Feature. - * - * The async variant is {@see self::createFeatureAsync()} . - * - * @example samples/V1/GkeHubClient/create_feature.php - * - * @param CreateFeatureRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createFeature(CreateFeatureRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateFeature', $request, $callOptions)->wait(); - } - - /** - * Creates a new Membership. - * - * **This is currently only supported for GKE clusters on Google Cloud**. - * To register other clusters, follow the instructions at - * https://cloud.google.com/anthos/multicluster-management/connect/registering-a-cluster. - * - * The async variant is {@see self::createMembershipAsync()} . - * - * @example samples/V1/GkeHubClient/create_membership.php - * - * @param CreateMembershipRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createMembership(CreateMembershipRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateMembership', $request, $callOptions)->wait(); - } - - /** - * Removes a Feature. - * - * The async variant is {@see self::deleteFeatureAsync()} . - * - * @example samples/V1/GkeHubClient/delete_feature.php - * - * @param DeleteFeatureRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteFeature(DeleteFeatureRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteFeature', $request, $callOptions)->wait(); - } - - /** - * Removes a Membership. - * - * **This is currently only supported for GKE clusters on Google Cloud**. - * To unregister other clusters, follow the instructions at - * https://cloud.google.com/anthos/multicluster-management/connect/unregistering-a-cluster. - * - * The async variant is {@see self::deleteMembershipAsync()} . - * - * @example samples/V1/GkeHubClient/delete_membership.php - * - * @param DeleteMembershipRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteMembership(DeleteMembershipRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteMembership', $request, $callOptions)->wait(); - } - - /** - * Generates the manifest for deployment of the GKE connect agent. - * - * **This method is used internally by Google-provided libraries.** - * Most clients should not need to call this method directly. - * - * The async variant is {@see self::generateConnectManifestAsync()} . - * - * @example samples/V1/GkeHubClient/generate_connect_manifest.php - * - * @param GenerateConnectManifestRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GenerateConnectManifestResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function generateConnectManifest(GenerateConnectManifestRequest $request, array $callOptions = []): GenerateConnectManifestResponse - { - return $this->startApiCall('GenerateConnectManifest', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single Feature. - * - * The async variant is {@see self::getFeatureAsync()} . - * - * @example samples/V1/GkeHubClient/get_feature.php - * - * @param GetFeatureRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Feature - * - * @throws ApiException Thrown if the API call fails. - */ - public function getFeature(GetFeatureRequest $request, array $callOptions = []): Feature - { - return $this->startApiCall('GetFeature', $request, $callOptions)->wait(); - } - - /** - * Gets the details of a Membership. - * - * The async variant is {@see self::getMembershipAsync()} . - * - * @example samples/V1/GkeHubClient/get_membership.php - * - * @param GetMembershipRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Membership - * - * @throws ApiException Thrown if the API call fails. - */ - public function getMembership(GetMembershipRequest $request, array $callOptions = []): Membership - { - return $this->startApiCall('GetMembership', $request, $callOptions)->wait(); - } - - /** - * Lists Features in a given project and location. - * - * The async variant is {@see self::listFeaturesAsync()} . - * - * @example samples/V1/GkeHubClient/list_features.php - * - * @param ListFeaturesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listFeatures(ListFeaturesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListFeatures', $request, $callOptions); - } - - /** - * Lists Memberships in a given project and location. - * - * The async variant is {@see self::listMembershipsAsync()} . - * - * @example samples/V1/GkeHubClient/list_memberships.php - * - * @param ListMembershipsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listMemberships(ListMembershipsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListMemberships', $request, $callOptions); - } - - /** - * Updates an existing Feature. - * - * The async variant is {@see self::updateFeatureAsync()} . - * - * @example samples/V1/GkeHubClient/update_feature.php - * - * @param UpdateFeatureRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateFeature(UpdateFeatureRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateFeature', $request, $callOptions)->wait(); - } - - /** - * Updates an existing Membership. - * - * The async variant is {@see self::updateMembershipAsync()} . - * - * @example samples/V1/GkeHubClient/update_membership.php - * - * @param UpdateMembershipRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateMembership(UpdateMembershipRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateMembership', $request, $callOptions)->wait(); - } -} diff --git a/GkeHub/src/V1/Client/GkeHubClient.php b/GkeHub/src/V1/Client/GkeHubClient.php index 88ca2a9c6440..f7e4d0bbdae8 100644 --- a/GkeHub/src/V1/Client/GkeHubClient.php +++ b/GkeHub/src/V1/Client/GkeHubClient.php @@ -24,17 +24,596 @@ namespace Google\Cloud\GkeHub\V1\Client; -use Google\Cloud\GkeHub\V1\Client\BaseClient\GkeHubBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\GkeHub\V1\CreateFeatureRequest; +use Google\Cloud\GkeHub\V1\CreateMembershipRequest; +use Google\Cloud\GkeHub\V1\DeleteFeatureRequest; +use Google\Cloud\GkeHub\V1\DeleteMembershipRequest; +use Google\Cloud\GkeHub\V1\Feature; +use Google\Cloud\GkeHub\V1\GenerateConnectManifestRequest; +use Google\Cloud\GkeHub\V1\GenerateConnectManifestResponse; +use Google\Cloud\GkeHub\V1\GetFeatureRequest; +use Google\Cloud\GkeHub\V1\GetMembershipRequest; +use Google\Cloud\GkeHub\V1\ListFeaturesRequest; +use Google\Cloud\GkeHub\V1\ListMembershipsRequest; +use Google\Cloud\GkeHub\V1\Membership; +use Google\Cloud\GkeHub\V1\UpdateFeatureRequest; +use Google\Cloud\GkeHub\V1\UpdateMembershipRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The GKE Hub service handles the registration of many Kubernetes clusters to + * Google Cloud, and the management of multi-cluster features over those + * clusters. + * + * The GKE Hub service operates on the following resources: + * + * * [Membership][google.cloud.gkehub.v1.Membership] + * * [Feature][google.cloud.gkehub.v1.Feature] + * + * GKE Hub is currently available in the global region and all regions in + * https://cloud.google.com/compute/docs/regions-zones. Feature is only + * available in global region while membership is global region and all the + * regions. + * + * **Membership management may be non-trivial:** it is recommended to use one + * of the Google-provided client libraries or tools where possible when working + * with Membership resources. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createFeatureAsync(CreateFeatureRequest $request, array $optionalArgs = []) + * @method PromiseInterface createMembershipAsync(CreateMembershipRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteFeatureAsync(DeleteFeatureRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteMembershipAsync(DeleteMembershipRequest $request, array $optionalArgs = []) + * @method PromiseInterface generateConnectManifestAsync(GenerateConnectManifestRequest $request, array $optionalArgs = []) + * @method PromiseInterface getFeatureAsync(GetFeatureRequest $request, array $optionalArgs = []) + * @method PromiseInterface getMembershipAsync(GetMembershipRequest $request, array $optionalArgs = []) + * @method PromiseInterface listFeaturesAsync(ListFeaturesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listMembershipsAsync(ListMembershipsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateFeatureAsync(UpdateFeatureRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateMembershipAsync(UpdateMembershipRequest $request, array $optionalArgs = []) */ -final class GkeHubClient extends GkeHubBaseClient +final class GkeHubClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see GkeHubBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.gkehub.v1.GkeHub'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'gkehub.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/gke_hub_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/gke_hub_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/gke_hub_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/gke_hub_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a feature + * resource. + * + * @param string $project + * @param string $location + * @param string $feature + * + * @return string The formatted feature resource. + */ + public static function featureName(string $project, string $location, string $feature): string + { + return self::getPathTemplate('feature')->render([ + 'project' => $project, + 'location' => $location, + 'feature' => $feature, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a membership + * resource. + * + * @param string $project + * @param string $location + * @param string $membership + * + * @return string The formatted membership resource. + */ + public static function membershipName(string $project, string $location, string $membership): string + { + return self::getPathTemplate('membership')->render([ + 'project' => $project, + 'location' => $location, + 'membership' => $membership, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - feature: projects/{project}/locations/{location}/features/{feature} + * - location: projects/{project}/locations/{location} + * - membership: projects/{project}/locations/{location}/memberships/{membership} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'gkehub.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Adds a new Feature. + * + * The async variant is {@see GkeHubClient::createFeatureAsync()} . + * + * @example samples/V1/GkeHubClient/create_feature.php + * + * @param CreateFeatureRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createFeature(CreateFeatureRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateFeature', $request, $callOptions)->wait(); + } + + /** + * Creates a new Membership. + * + * **This is currently only supported for GKE clusters on Google Cloud**. + * To register other clusters, follow the instructions at + * https://cloud.google.com/anthos/multicluster-management/connect/registering-a-cluster. + * + * The async variant is {@see GkeHubClient::createMembershipAsync()} . + * + * @example samples/V1/GkeHubClient/create_membership.php + * + * @param CreateMembershipRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createMembership(CreateMembershipRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateMembership', $request, $callOptions)->wait(); + } + + /** + * Removes a Feature. + * + * The async variant is {@see GkeHubClient::deleteFeatureAsync()} . + * + * @example samples/V1/GkeHubClient/delete_feature.php + * + * @param DeleteFeatureRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteFeature(DeleteFeatureRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteFeature', $request, $callOptions)->wait(); + } + + /** + * Removes a Membership. + * + * **This is currently only supported for GKE clusters on Google Cloud**. + * To unregister other clusters, follow the instructions at + * https://cloud.google.com/anthos/multicluster-management/connect/unregistering-a-cluster. + * + * The async variant is {@see GkeHubClient::deleteMembershipAsync()} . + * + * @example samples/V1/GkeHubClient/delete_membership.php + * + * @param DeleteMembershipRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteMembership(DeleteMembershipRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteMembership', $request, $callOptions)->wait(); + } + + /** + * Generates the manifest for deployment of the GKE connect agent. + * + * **This method is used internally by Google-provided libraries.** + * Most clients should not need to call this method directly. + * + * The async variant is {@see GkeHubClient::generateConnectManifestAsync()} . + * + * @example samples/V1/GkeHubClient/generate_connect_manifest.php + * + * @param GenerateConnectManifestRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GenerateConnectManifestResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function generateConnectManifest(GenerateConnectManifestRequest $request, array $callOptions = []): GenerateConnectManifestResponse + { + return $this->startApiCall('GenerateConnectManifest', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Feature. + * + * The async variant is {@see GkeHubClient::getFeatureAsync()} . + * + * @example samples/V1/GkeHubClient/get_feature.php + * + * @param GetFeatureRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Feature + * + * @throws ApiException Thrown if the API call fails. + */ + public function getFeature(GetFeatureRequest $request, array $callOptions = []): Feature + { + return $this->startApiCall('GetFeature', $request, $callOptions)->wait(); + } + + /** + * Gets the details of a Membership. + * + * The async variant is {@see GkeHubClient::getMembershipAsync()} . + * + * @example samples/V1/GkeHubClient/get_membership.php + * + * @param GetMembershipRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Membership + * + * @throws ApiException Thrown if the API call fails. + */ + public function getMembership(GetMembershipRequest $request, array $callOptions = []): Membership + { + return $this->startApiCall('GetMembership', $request, $callOptions)->wait(); + } + + /** + * Lists Features in a given project and location. + * + * The async variant is {@see GkeHubClient::listFeaturesAsync()} . + * + * @example samples/V1/GkeHubClient/list_features.php + * + * @param ListFeaturesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listFeatures(ListFeaturesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListFeatures', $request, $callOptions); + } + + /** + * Lists Memberships in a given project and location. + * + * The async variant is {@see GkeHubClient::listMembershipsAsync()} . + * + * @example samples/V1/GkeHubClient/list_memberships.php + * + * @param ListMembershipsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listMemberships(ListMembershipsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListMemberships', $request, $callOptions); + } + + /** + * Updates an existing Feature. + * + * The async variant is {@see GkeHubClient::updateFeatureAsync()} . + * + * @example samples/V1/GkeHubClient/update_feature.php + * + * @param UpdateFeatureRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateFeature(UpdateFeatureRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateFeature', $request, $callOptions)->wait(); + } + + /** + * Updates an existing Membership. + * + * The async variant is {@see GkeHubClient::updateMembershipAsync()} . + * + * @example samples/V1/GkeHubClient/update_membership.php + * + * @param UpdateMembershipRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateMembership(UpdateMembershipRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateMembership', $request, $callOptions)->wait(); + } } diff --git a/GkeMultiCloud/composer.json b/GkeMultiCloud/composer.json index 75251c109939..8b7bd863cdd9 100644 --- a/GkeMultiCloud/composer.json +++ b/GkeMultiCloud/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/GkeMultiCloud/src/V1/Client/AttachedClustersClient.php b/GkeMultiCloud/src/V1/Client/AttachedClustersClient.php index fed5d98cce71..9505016efa78 100644 --- a/GkeMultiCloud/src/V1/Client/AttachedClustersClient.php +++ b/GkeMultiCloud/src/V1/Client/AttachedClustersClient.php @@ -24,17 +24,518 @@ namespace Google\Cloud\GkeMultiCloud\V1\Client; -use Google\Cloud\GkeMultiCloud\V1\Client\BaseClient\AttachedClustersBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\GkeMultiCloud\V1\AttachedCluster; +use Google\Cloud\GkeMultiCloud\V1\AttachedServerConfig; +use Google\Cloud\GkeMultiCloud\V1\CreateAttachedClusterRequest; +use Google\Cloud\GkeMultiCloud\V1\DeleteAttachedClusterRequest; +use Google\Cloud\GkeMultiCloud\V1\GenerateAttachedClusterInstallManifestRequest; +use Google\Cloud\GkeMultiCloud\V1\GenerateAttachedClusterInstallManifestResponse; +use Google\Cloud\GkeMultiCloud\V1\GetAttachedClusterRequest; +use Google\Cloud\GkeMultiCloud\V1\GetAttachedServerConfigRequest; +use Google\Cloud\GkeMultiCloud\V1\ImportAttachedClusterRequest; +use Google\Cloud\GkeMultiCloud\V1\ListAttachedClustersRequest; +use Google\Cloud\GkeMultiCloud\V1\UpdateAttachedClusterRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The AttachedClusters API provides a single centrally managed service + * to register and manage Anthos attached clusters that run on customer's owned + * infrastructure. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\GkeMultiCloud\V1\AttachedClustersClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createAttachedClusterAsync(CreateAttachedClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAttachedClusterAsync(DeleteAttachedClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface generateAttachedClusterInstallManifestAsync(GenerateAttachedClusterInstallManifestRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAttachedClusterAsync(GetAttachedClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAttachedServerConfigAsync(GetAttachedServerConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface importAttachedClusterAsync(ImportAttachedClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAttachedClustersAsync(ListAttachedClustersRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAttachedClusterAsync(UpdateAttachedClusterRequest $request, array $optionalArgs = []) */ -final class AttachedClustersClient extends AttachedClustersBaseClient +final class AttachedClustersClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AttachedClustersBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.gkemulticloud.v1.AttachedClusters'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'gkemulticloud.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/attached_clusters_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/attached_clusters_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/attached_clusters_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/attached_clusters_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * attached_cluster resource. + * + * @param string $project + * @param string $location + * @param string $attachedCluster + * + * @return string The formatted attached_cluster resource. + */ + public static function attachedClusterName(string $project, string $location, string $attachedCluster): string + { + return self::getPathTemplate('attachedCluster')->render([ + 'project' => $project, + 'location' => $location, + 'attached_cluster' => $attachedCluster, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * attached_server_config resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted attached_server_config resource. + */ + public static function attachedServerConfigName(string $project, string $location): string + { + return self::getPathTemplate('attachedServerConfig')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - attachedCluster: projects/{project}/locations/{location}/attachedClusters/{attached_cluster} + * - attachedServerConfig: projects/{project}/locations/{location}/attachedServerConfig + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'gkemulticloud.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new + * [AttachedCluster][google.cloud.gkemulticloud.v1.AttachedCluster] resource + * on a given Google Cloud Platform project and region. + * + * If successful, the response contains a newly created + * [Operation][google.longrunning.Operation] resource that can be + * described to track the status of the operation. + * + * The async variant is {@see AttachedClustersClient::createAttachedClusterAsync()} + * . + * + * @example samples/V1/AttachedClustersClient/create_attached_cluster.php + * + * @param CreateAttachedClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAttachedCluster(CreateAttachedClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateAttachedCluster', $request, $callOptions)->wait(); + } + + /** + * Deletes a specific + * [AttachedCluster][google.cloud.gkemulticloud.v1.AttachedCluster] resource. + * + * If successful, the response contains a newly created + * [Operation][google.longrunning.Operation] resource that can be + * described to track the status of the operation. + * + * The async variant is {@see AttachedClustersClient::deleteAttachedClusterAsync()} + * . + * + * @example samples/V1/AttachedClustersClient/delete_attached_cluster.php + * + * @param DeleteAttachedClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAttachedCluster(DeleteAttachedClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteAttachedCluster', $request, $callOptions)->wait(); + } + + /** + * Generates the install manifest to be installed on the target cluster. + * + * The async variant is + * {@see AttachedClustersClient::generateAttachedClusterInstallManifestAsync()} . + * + * @example samples/V1/AttachedClustersClient/generate_attached_cluster_install_manifest.php + * + * @param GenerateAttachedClusterInstallManifestRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GenerateAttachedClusterInstallManifestResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function generateAttachedClusterInstallManifest(GenerateAttachedClusterInstallManifestRequest $request, array $callOptions = []): GenerateAttachedClusterInstallManifestResponse + { + return $this->startApiCall('GenerateAttachedClusterInstallManifest', $request, $callOptions)->wait(); + } + + /** + * Describes a specific + * [AttachedCluster][google.cloud.gkemulticloud.v1.AttachedCluster] resource. + * + * The async variant is {@see AttachedClustersClient::getAttachedClusterAsync()} . + * + * @example samples/V1/AttachedClustersClient/get_attached_cluster.php + * + * @param GetAttachedClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AttachedCluster + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAttachedCluster(GetAttachedClusterRequest $request, array $callOptions = []): AttachedCluster + { + return $this->startApiCall('GetAttachedCluster', $request, $callOptions)->wait(); + } + + /** + * Returns information, such as supported Kubernetes versions, on a given + * Google Cloud location. + * + * The async variant is + * {@see AttachedClustersClient::getAttachedServerConfigAsync()} . + * + * @example samples/V1/AttachedClustersClient/get_attached_server_config.php + * + * @param GetAttachedServerConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AttachedServerConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAttachedServerConfig(GetAttachedServerConfigRequest $request, array $callOptions = []): AttachedServerConfig + { + return $this->startApiCall('GetAttachedServerConfig', $request, $callOptions)->wait(); + } + + /** + * Imports creates a new + * [AttachedCluster][google.cloud.gkemulticloud.v1.AttachedCluster] resource + * by importing an existing Fleet Membership resource. + * + * Attached Clusters created before the introduction of the Anthos Multi-Cloud + * API can be imported through this method. + * + * If successful, the response contains a newly created + * [Operation][google.longrunning.Operation] resource that can be + * described to track the status of the operation. + * + * The async variant is {@see AttachedClustersClient::importAttachedClusterAsync()} + * . + * + * @example samples/V1/AttachedClustersClient/import_attached_cluster.php + * + * @param ImportAttachedClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importAttachedCluster(ImportAttachedClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportAttachedCluster', $request, $callOptions)->wait(); + } + + /** + * Lists all [AttachedCluster][google.cloud.gkemulticloud.v1.AttachedCluster] + * resources on a given Google Cloud project and region. + * + * The async variant is {@see AttachedClustersClient::listAttachedClustersAsync()} + * . + * + * @example samples/V1/AttachedClustersClient/list_attached_clusters.php + * + * @param ListAttachedClustersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAttachedClusters(ListAttachedClustersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAttachedClusters', $request, $callOptions); + } + + /** + * Updates an + * [AttachedCluster][google.cloud.gkemulticloud.v1.AttachedCluster]. + * + * The async variant is {@see AttachedClustersClient::updateAttachedClusterAsync()} + * . + * + * @example samples/V1/AttachedClustersClient/update_attached_cluster.php + * + * @param UpdateAttachedClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAttachedCluster(UpdateAttachedClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateAttachedCluster', $request, $callOptions)->wait(); + } } diff --git a/GkeMultiCloud/src/V1/Client/AwsClustersClient.php b/GkeMultiCloud/src/V1/Client/AwsClustersClient.php index 712d4ae987a9..ecc1bbb1c93d 100644 --- a/GkeMultiCloud/src/V1/Client/AwsClustersClient.php +++ b/GkeMultiCloud/src/V1/Client/AwsClustersClient.php @@ -24,17 +24,650 @@ namespace Google\Cloud\GkeMultiCloud\V1\Client; -use Google\Cloud\GkeMultiCloud\V1\Client\BaseClient\AwsClustersBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\GkeMultiCloud\V1\AwsCluster; +use Google\Cloud\GkeMultiCloud\V1\AwsNodePool; +use Google\Cloud\GkeMultiCloud\V1\AwsServerConfig; +use Google\Cloud\GkeMultiCloud\V1\CreateAwsClusterRequest; +use Google\Cloud\GkeMultiCloud\V1\CreateAwsNodePoolRequest; +use Google\Cloud\GkeMultiCloud\V1\DeleteAwsClusterRequest; +use Google\Cloud\GkeMultiCloud\V1\DeleteAwsNodePoolRequest; +use Google\Cloud\GkeMultiCloud\V1\GenerateAwsAccessTokenRequest; +use Google\Cloud\GkeMultiCloud\V1\GenerateAwsAccessTokenResponse; +use Google\Cloud\GkeMultiCloud\V1\GetAwsClusterRequest; +use Google\Cloud\GkeMultiCloud\V1\GetAwsNodePoolRequest; +use Google\Cloud\GkeMultiCloud\V1\GetAwsServerConfigRequest; +use Google\Cloud\GkeMultiCloud\V1\ListAwsClustersRequest; +use Google\Cloud\GkeMultiCloud\V1\ListAwsNodePoolsRequest; +use Google\Cloud\GkeMultiCloud\V1\UpdateAwsClusterRequest; +use Google\Cloud\GkeMultiCloud\V1\UpdateAwsNodePoolRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The AwsClusters API provides a single centrally managed service + * to create and manage Anthos clusters that run on AWS infrastructure. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\GkeMultiCloud\V1\AwsClustersClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createAwsClusterAsync(CreateAwsClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface createAwsNodePoolAsync(CreateAwsNodePoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAwsClusterAsync(DeleteAwsClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAwsNodePoolAsync(DeleteAwsNodePoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface generateAwsAccessTokenAsync(GenerateAwsAccessTokenRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAwsClusterAsync(GetAwsClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAwsNodePoolAsync(GetAwsNodePoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAwsServerConfigAsync(GetAwsServerConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAwsClustersAsync(ListAwsClustersRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAwsNodePoolsAsync(ListAwsNodePoolsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAwsClusterAsync(UpdateAwsClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAwsNodePoolAsync(UpdateAwsNodePoolRequest $request, array $optionalArgs = []) */ -final class AwsClustersClient extends AwsClustersBaseClient +final class AwsClustersClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AwsClustersBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.gkemulticloud.v1.AwsClusters'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'gkemulticloud.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/aws_clusters_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/aws_clusters_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/aws_clusters_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/aws_clusters_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a aws_cluster + * resource. + * + * @param string $project + * @param string $location + * @param string $awsCluster + * + * @return string The formatted aws_cluster resource. + */ + public static function awsClusterName(string $project, string $location, string $awsCluster): string + { + return self::getPathTemplate('awsCluster')->render([ + 'project' => $project, + 'location' => $location, + 'aws_cluster' => $awsCluster, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * aws_node_pool resource. + * + * @param string $project + * @param string $location + * @param string $awsCluster + * @param string $awsNodePool + * + * @return string The formatted aws_node_pool resource. + */ + public static function awsNodePoolName(string $project, string $location, string $awsCluster, string $awsNodePool): string + { + return self::getPathTemplate('awsNodePool')->render([ + 'project' => $project, + 'location' => $location, + 'aws_cluster' => $awsCluster, + 'aws_node_pool' => $awsNodePool, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * aws_server_config resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted aws_server_config resource. + */ + public static function awsServerConfigName(string $project, string $location): string + { + return self::getPathTemplate('awsServerConfig')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - awsCluster: projects/{project}/locations/{location}/awsClusters/{aws_cluster} + * - awsNodePool: projects/{project}/locations/{location}/awsClusters/{aws_cluster}/awsNodePools/{aws_node_pool} + * - awsServerConfig: projects/{project}/locations/{location}/awsServerConfig + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'gkemulticloud.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new [AwsCluster][google.cloud.gkemulticloud.v1.AwsCluster] + * resource on a given Google Cloud Platform project and region. + * + * If successful, the response contains a newly created + * [Operation][google.longrunning.Operation] resource that can be + * described to track the status of the operation. + * + * The async variant is {@see AwsClustersClient::createAwsClusterAsync()} . + * + * @example samples/V1/AwsClustersClient/create_aws_cluster.php + * + * @param CreateAwsClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAwsCluster(CreateAwsClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateAwsCluster', $request, $callOptions)->wait(); + } + + /** + * Creates a new [AwsNodePool][google.cloud.gkemulticloud.v1.AwsNodePool], + * attached to a given [AwsCluster][google.cloud.gkemulticloud.v1.AwsCluster]. + * + * If successful, the response contains a newly created + * [Operation][google.longrunning.Operation] resource that can be + * described to track the status of the operation. + * + * The async variant is {@see AwsClustersClient::createAwsNodePoolAsync()} . + * + * @example samples/V1/AwsClustersClient/create_aws_node_pool.php + * + * @param CreateAwsNodePoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAwsNodePool(CreateAwsNodePoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateAwsNodePool', $request, $callOptions)->wait(); + } + + /** + * Deletes a specific [AwsCluster][google.cloud.gkemulticloud.v1.AwsCluster] + * resource. + * + * Fails if the cluster has one or more associated + * [AwsNodePool][google.cloud.gkemulticloud.v1.AwsNodePool] resources. + * + * If successful, the response contains a newly created + * [Operation][google.longrunning.Operation] resource that can be + * described to track the status of the operation. + * + * The async variant is {@see AwsClustersClient::deleteAwsClusterAsync()} . + * + * @example samples/V1/AwsClustersClient/delete_aws_cluster.php + * + * @param DeleteAwsClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAwsCluster(DeleteAwsClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteAwsCluster', $request, $callOptions)->wait(); + } + + /** + * Deletes a specific [AwsNodePool][google.cloud.gkemulticloud.v1.AwsNodePool] + * resource. + * + * If successful, the response contains a newly created + * [Operation][google.longrunning.Operation] resource that can be + * described to track the status of the operation. + * + * The async variant is {@see AwsClustersClient::deleteAwsNodePoolAsync()} . + * + * @example samples/V1/AwsClustersClient/delete_aws_node_pool.php + * + * @param DeleteAwsNodePoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAwsNodePool(DeleteAwsNodePoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteAwsNodePool', $request, $callOptions)->wait(); + } + + /** + * Generates a short-lived access token to authenticate to a given + * [AwsCluster][google.cloud.gkemulticloud.v1.AwsCluster] resource. + * + * The async variant is {@see AwsClustersClient::generateAwsAccessTokenAsync()} . + * + * @example samples/V1/AwsClustersClient/generate_aws_access_token.php + * + * @param GenerateAwsAccessTokenRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GenerateAwsAccessTokenResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function generateAwsAccessToken(GenerateAwsAccessTokenRequest $request, array $callOptions = []): GenerateAwsAccessTokenResponse + { + return $this->startApiCall('GenerateAwsAccessToken', $request, $callOptions)->wait(); + } + + /** + * Describes a specific [AwsCluster][google.cloud.gkemulticloud.v1.AwsCluster] + * resource. + * + * The async variant is {@see AwsClustersClient::getAwsClusterAsync()} . + * + * @example samples/V1/AwsClustersClient/get_aws_cluster.php + * + * @param GetAwsClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AwsCluster + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAwsCluster(GetAwsClusterRequest $request, array $callOptions = []): AwsCluster + { + return $this->startApiCall('GetAwsCluster', $request, $callOptions)->wait(); + } + + /** + * Describes a specific + * [AwsNodePool][google.cloud.gkemulticloud.v1.AwsNodePool] resource. + * + * The async variant is {@see AwsClustersClient::getAwsNodePoolAsync()} . + * + * @example samples/V1/AwsClustersClient/get_aws_node_pool.php + * + * @param GetAwsNodePoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AwsNodePool + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAwsNodePool(GetAwsNodePoolRequest $request, array $callOptions = []): AwsNodePool + { + return $this->startApiCall('GetAwsNodePool', $request, $callOptions)->wait(); + } + + /** + * Returns information, such as supported AWS regions and Kubernetes + * versions, on a given Google Cloud location. + * + * The async variant is {@see AwsClustersClient::getAwsServerConfigAsync()} . + * + * @example samples/V1/AwsClustersClient/get_aws_server_config.php + * + * @param GetAwsServerConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AwsServerConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAwsServerConfig(GetAwsServerConfigRequest $request, array $callOptions = []): AwsServerConfig + { + return $this->startApiCall('GetAwsServerConfig', $request, $callOptions)->wait(); + } + + /** + * Lists all [AwsCluster][google.cloud.gkemulticloud.v1.AwsCluster] resources + * on a given Google Cloud project and region. + * + * The async variant is {@see AwsClustersClient::listAwsClustersAsync()} . + * + * @example samples/V1/AwsClustersClient/list_aws_clusters.php + * + * @param ListAwsClustersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAwsClusters(ListAwsClustersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAwsClusters', $request, $callOptions); + } + + /** + * Lists all [AwsNodePool][google.cloud.gkemulticloud.v1.AwsNodePool] + * resources on a given + * [AwsCluster][google.cloud.gkemulticloud.v1.AwsCluster]. + * + * The async variant is {@see AwsClustersClient::listAwsNodePoolsAsync()} . + * + * @example samples/V1/AwsClustersClient/list_aws_node_pools.php + * + * @param ListAwsNodePoolsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAwsNodePools(ListAwsNodePoolsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAwsNodePools', $request, $callOptions); + } + + /** + * Updates an [AwsCluster][google.cloud.gkemulticloud.v1.AwsCluster]. + * + * The async variant is {@see AwsClustersClient::updateAwsClusterAsync()} . + * + * @example samples/V1/AwsClustersClient/update_aws_cluster.php + * + * @param UpdateAwsClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAwsCluster(UpdateAwsClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateAwsCluster', $request, $callOptions)->wait(); + } + + /** + * Updates an [AwsNodePool][google.cloud.gkemulticloud.v1.AwsNodePool]. + * + * The async variant is {@see AwsClustersClient::updateAwsNodePoolAsync()} . + * + * @example samples/V1/AwsClustersClient/update_aws_node_pool.php + * + * @param UpdateAwsNodePoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAwsNodePool(UpdateAwsNodePoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateAwsNodePool', $request, $callOptions)->wait(); + } } diff --git a/GkeMultiCloud/src/V1/Client/AzureClustersClient.php b/GkeMultiCloud/src/V1/Client/AzureClustersClient.php index 547a182af6c9..ba4e07e20c96 100644 --- a/GkeMultiCloud/src/V1/Client/AzureClustersClient.php +++ b/GkeMultiCloud/src/V1/Client/AzureClustersClient.php @@ -24,17 +24,805 @@ namespace Google\Cloud\GkeMultiCloud\V1\Client; -use Google\Cloud\GkeMultiCloud\V1\Client\BaseClient\AzureClustersBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\GkeMultiCloud\V1\AzureClient; +use Google\Cloud\GkeMultiCloud\V1\AzureCluster; +use Google\Cloud\GkeMultiCloud\V1\AzureNodePool; +use Google\Cloud\GkeMultiCloud\V1\AzureServerConfig; +use Google\Cloud\GkeMultiCloud\V1\CreateAzureClientRequest; +use Google\Cloud\GkeMultiCloud\V1\CreateAzureClusterRequest; +use Google\Cloud\GkeMultiCloud\V1\CreateAzureNodePoolRequest; +use Google\Cloud\GkeMultiCloud\V1\DeleteAzureClientRequest; +use Google\Cloud\GkeMultiCloud\V1\DeleteAzureClusterRequest; +use Google\Cloud\GkeMultiCloud\V1\DeleteAzureNodePoolRequest; +use Google\Cloud\GkeMultiCloud\V1\GenerateAzureAccessTokenRequest; +use Google\Cloud\GkeMultiCloud\V1\GenerateAzureAccessTokenResponse; +use Google\Cloud\GkeMultiCloud\V1\GetAzureClientRequest; +use Google\Cloud\GkeMultiCloud\V1\GetAzureClusterRequest; +use Google\Cloud\GkeMultiCloud\V1\GetAzureNodePoolRequest; +use Google\Cloud\GkeMultiCloud\V1\GetAzureServerConfigRequest; +use Google\Cloud\GkeMultiCloud\V1\ListAzureClientsRequest; +use Google\Cloud\GkeMultiCloud\V1\ListAzureClustersRequest; +use Google\Cloud\GkeMultiCloud\V1\ListAzureNodePoolsRequest; +use Google\Cloud\GkeMultiCloud\V1\UpdateAzureClusterRequest; +use Google\Cloud\GkeMultiCloud\V1\UpdateAzureNodePoolRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The AzureClusters API provides a single centrally managed service + * to create and manage Anthos clusters that run on Azure infrastructure. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\GkeMultiCloud\V1\AzureClustersClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createAzureClientAsync(CreateAzureClientRequest $request, array $optionalArgs = []) + * @method PromiseInterface createAzureClusterAsync(CreateAzureClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface createAzureNodePoolAsync(CreateAzureNodePoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAzureClientAsync(DeleteAzureClientRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAzureClusterAsync(DeleteAzureClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAzureNodePoolAsync(DeleteAzureNodePoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface generateAzureAccessTokenAsync(GenerateAzureAccessTokenRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAzureClientAsync(GetAzureClientRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAzureClusterAsync(GetAzureClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAzureNodePoolAsync(GetAzureNodePoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAzureServerConfigAsync(GetAzureServerConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAzureClientsAsync(ListAzureClientsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAzureClustersAsync(ListAzureClustersRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAzureNodePoolsAsync(ListAzureNodePoolsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAzureClusterAsync(UpdateAzureClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAzureNodePoolAsync(UpdateAzureNodePoolRequest $request, array $optionalArgs = []) */ -final class AzureClustersClient extends AzureClustersBaseClient +final class AzureClustersClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AzureClustersBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.gkemulticloud.v1.AzureClusters'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'gkemulticloud.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/azure_clusters_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/azure_clusters_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/azure_clusters_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/azure_clusters_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a azure_client + * resource. + * + * @param string $project + * @param string $location + * @param string $azureClient + * + * @return string The formatted azure_client resource. + */ + public static function azureClientName(string $project, string $location, string $azureClient): string + { + return self::getPathTemplate('azureClient')->render([ + 'project' => $project, + 'location' => $location, + 'azure_client' => $azureClient, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * azure_cluster resource. + * + * @param string $project + * @param string $location + * @param string $azureCluster + * + * @return string The formatted azure_cluster resource. + */ + public static function azureClusterName(string $project, string $location, string $azureCluster): string + { + return self::getPathTemplate('azureCluster')->render([ + 'project' => $project, + 'location' => $location, + 'azure_cluster' => $azureCluster, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * azure_node_pool resource. + * + * @param string $project + * @param string $location + * @param string $azureCluster + * @param string $azureNodePool + * + * @return string The formatted azure_node_pool resource. + */ + public static function azureNodePoolName(string $project, string $location, string $azureCluster, string $azureNodePool): string + { + return self::getPathTemplate('azureNodePool')->render([ + 'project' => $project, + 'location' => $location, + 'azure_cluster' => $azureCluster, + 'azure_node_pool' => $azureNodePool, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * azure_server_config resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted azure_server_config resource. + */ + public static function azureServerConfigName(string $project, string $location): string + { + return self::getPathTemplate('azureServerConfig')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - azureClient: projects/{project}/locations/{location}/azureClients/{azure_client} + * - azureCluster: projects/{project}/locations/{location}/azureClusters/{azure_cluster} + * - azureNodePool: projects/{project}/locations/{location}/azureClusters/{azure_cluster}/azureNodePools/{azure_node_pool} + * - azureServerConfig: projects/{project}/locations/{location}/azureServerConfig + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'gkemulticloud.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new [AzureClient][google.cloud.gkemulticloud.v1.AzureClient] + * resource on a given Google Cloud project and region. + * + * `AzureClient` resources hold client authentication + * information needed by the Anthos Multicloud API to manage Azure resources + * on your Azure subscription on your behalf. + * + * If successful, the response contains a newly created + * [Operation][google.longrunning.Operation] resource that can be + * described to track the status of the operation. + * + * The async variant is {@see AzureClustersClient::createAzureClientAsync()} . + * + * @example samples/V1/AzureClustersClient/create_azure_client.php + * + * @param CreateAzureClientRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAzureClient(CreateAzureClientRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateAzureClient', $request, $callOptions)->wait(); + } + + /** + * Creates a new [AzureCluster][google.cloud.gkemulticloud.v1.AzureCluster] + * resource on a given Google Cloud Platform project and region. + * + * If successful, the response contains a newly created + * [Operation][google.longrunning.Operation] resource that can be + * described to track the status of the operation. + * + * The async variant is {@see AzureClustersClient::createAzureClusterAsync()} . + * + * @example samples/V1/AzureClustersClient/create_azure_cluster.php + * + * @param CreateAzureClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAzureCluster(CreateAzureClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateAzureCluster', $request, $callOptions)->wait(); + } + + /** + * Creates a new [AzureNodePool][google.cloud.gkemulticloud.v1.AzureNodePool], + * attached to a given + * [AzureCluster][google.cloud.gkemulticloud.v1.AzureCluster]. + * + * If successful, the response contains a newly created + * [Operation][google.longrunning.Operation] resource that can be + * described to track the status of the operation. + * + * The async variant is {@see AzureClustersClient::createAzureNodePoolAsync()} . + * + * @example samples/V1/AzureClustersClient/create_azure_node_pool.php + * + * @param CreateAzureNodePoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAzureNodePool(CreateAzureNodePoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateAzureNodePool', $request, $callOptions)->wait(); + } + + /** + * Deletes a specific [AzureClient][google.cloud.gkemulticloud.v1.AzureClient] + * resource. + * + * If the client is used by one or more clusters, deletion will + * fail and a `FAILED_PRECONDITION` error will be returned. + * + * If successful, the response contains a newly created + * [Operation][google.longrunning.Operation] resource that can be + * described to track the status of the operation. + * + * The async variant is {@see AzureClustersClient::deleteAzureClientAsync()} . + * + * @example samples/V1/AzureClustersClient/delete_azure_client.php + * + * @param DeleteAzureClientRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAzureClient(DeleteAzureClientRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteAzureClient', $request, $callOptions)->wait(); + } + + /** + * Deletes a specific + * [AzureCluster][google.cloud.gkemulticloud.v1.AzureCluster] resource. + * + * Fails if the cluster has one or more associated + * [AzureNodePool][google.cloud.gkemulticloud.v1.AzureNodePool] resources. + * + * If successful, the response contains a newly created + * [Operation][google.longrunning.Operation] resource that can be + * described to track the status of the operation. + * + * The async variant is {@see AzureClustersClient::deleteAzureClusterAsync()} . + * + * @example samples/V1/AzureClustersClient/delete_azure_cluster.php + * + * @param DeleteAzureClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAzureCluster(DeleteAzureClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteAzureCluster', $request, $callOptions)->wait(); + } + + /** + * Deletes a specific + * [AzureNodePool][google.cloud.gkemulticloud.v1.AzureNodePool] resource. + * + * If successful, the response contains a newly created + * [Operation][google.longrunning.Operation] resource that can be + * described to track the status of the operation. + * + * The async variant is {@see AzureClustersClient::deleteAzureNodePoolAsync()} . + * + * @example samples/V1/AzureClustersClient/delete_azure_node_pool.php + * + * @param DeleteAzureNodePoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAzureNodePool(DeleteAzureNodePoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteAzureNodePool', $request, $callOptions)->wait(); + } + + /** + * Generates a short-lived access token to authenticate to a given + * [AzureCluster][google.cloud.gkemulticloud.v1.AzureCluster] resource. + * + * The async variant is {@see AzureClustersClient::generateAzureAccessTokenAsync()} + * . + * + * @example samples/V1/AzureClustersClient/generate_azure_access_token.php + * + * @param GenerateAzureAccessTokenRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GenerateAzureAccessTokenResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function generateAzureAccessToken(GenerateAzureAccessTokenRequest $request, array $callOptions = []): GenerateAzureAccessTokenResponse + { + return $this->startApiCall('GenerateAzureAccessToken', $request, $callOptions)->wait(); + } + + /** + * Describes a specific + * [AzureClient][google.cloud.gkemulticloud.v1.AzureClient] resource. + * + * The async variant is {@see AzureClustersClient::getAzureClientAsync()} . + * + * @example samples/V1/AzureClustersClient/get_azure_client.php + * + * @param GetAzureClientRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AzureClient + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAzureClient(GetAzureClientRequest $request, array $callOptions = []): AzureClient + { + return $this->startApiCall('GetAzureClient', $request, $callOptions)->wait(); + } + + /** + * Describes a specific + * [AzureCluster][google.cloud.gkemulticloud.v1.AzureCluster] resource. + * + * The async variant is {@see AzureClustersClient::getAzureClusterAsync()} . + * + * @example samples/V1/AzureClustersClient/get_azure_cluster.php + * + * @param GetAzureClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AzureCluster + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAzureCluster(GetAzureClusterRequest $request, array $callOptions = []): AzureCluster + { + return $this->startApiCall('GetAzureCluster', $request, $callOptions)->wait(); + } + + /** + * Describes a specific + * [AzureNodePool][google.cloud.gkemulticloud.v1.AzureNodePool] resource. + * + * The async variant is {@see AzureClustersClient::getAzureNodePoolAsync()} . + * + * @example samples/V1/AzureClustersClient/get_azure_node_pool.php + * + * @param GetAzureNodePoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AzureNodePool + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAzureNodePool(GetAzureNodePoolRequest $request, array $callOptions = []): AzureNodePool + { + return $this->startApiCall('GetAzureNodePool', $request, $callOptions)->wait(); + } + + /** + * Returns information, such as supported Azure regions and Kubernetes + * versions, on a given Google Cloud location. + * + * The async variant is {@see AzureClustersClient::getAzureServerConfigAsync()} . + * + * @example samples/V1/AzureClustersClient/get_azure_server_config.php + * + * @param GetAzureServerConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AzureServerConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAzureServerConfig(GetAzureServerConfigRequest $request, array $callOptions = []): AzureServerConfig + { + return $this->startApiCall('GetAzureServerConfig', $request, $callOptions)->wait(); + } + + /** + * Lists all [AzureClient][google.cloud.gkemulticloud.v1.AzureClient] + * resources on a given Google Cloud project and region. + * + * The async variant is {@see AzureClustersClient::listAzureClientsAsync()} . + * + * @example samples/V1/AzureClustersClient/list_azure_clients.php + * + * @param ListAzureClientsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAzureClients(ListAzureClientsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAzureClients', $request, $callOptions); + } + + /** + * Lists all [AzureCluster][google.cloud.gkemulticloud.v1.AzureCluster] + * resources on a given Google Cloud project and region. + * + * The async variant is {@see AzureClustersClient::listAzureClustersAsync()} . + * + * @example samples/V1/AzureClustersClient/list_azure_clusters.php + * + * @param ListAzureClustersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAzureClusters(ListAzureClustersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAzureClusters', $request, $callOptions); + } + + /** + * Lists all [AzureNodePool][google.cloud.gkemulticloud.v1.AzureNodePool] + * resources on a given + * [AzureCluster][google.cloud.gkemulticloud.v1.AzureCluster]. + * + * The async variant is {@see AzureClustersClient::listAzureNodePoolsAsync()} . + * + * @example samples/V1/AzureClustersClient/list_azure_node_pools.php + * + * @param ListAzureNodePoolsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAzureNodePools(ListAzureNodePoolsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAzureNodePools', $request, $callOptions); + } + + /** + * Updates an [AzureCluster][google.cloud.gkemulticloud.v1.AzureCluster]. + * + * The async variant is {@see AzureClustersClient::updateAzureClusterAsync()} . + * + * @example samples/V1/AzureClustersClient/update_azure_cluster.php + * + * @param UpdateAzureClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAzureCluster(UpdateAzureClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateAzureCluster', $request, $callOptions)->wait(); + } + + /** + * Updates an [AzureNodePool][google.cloud.gkemulticloud.v1.AzureNodePool]. + * + * The async variant is {@see AzureClustersClient::updateAzureNodePoolAsync()} . + * + * @example samples/V1/AzureClustersClient/update_azure_node_pool.php + * + * @param UpdateAzureNodePoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAzureNodePool(UpdateAzureNodePoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateAzureNodePool', $request, $callOptions)->wait(); + } } diff --git a/GkeMultiCloud/src/V1/Client/BaseClient/AttachedClustersBaseClient.php b/GkeMultiCloud/src/V1/Client/BaseClient/AttachedClustersBaseClient.php deleted file mode 100644 index f06363547673..000000000000 --- a/GkeMultiCloud/src/V1/Client/BaseClient/AttachedClustersBaseClient.php +++ /dev/null @@ -1,537 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/attached_clusters_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/attached_clusters_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/attached_clusters_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/attached_clusters_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * attached_cluster resource. - * - * @param string $project - * @param string $location - * @param string $attachedCluster - * - * @return string The formatted attached_cluster resource. - */ - public static function attachedClusterName(string $project, string $location, string $attachedCluster): string - { - return self::getPathTemplate('attachedCluster')->render([ - 'project' => $project, - 'location' => $location, - 'attached_cluster' => $attachedCluster, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * attached_server_config resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted attached_server_config resource. - */ - public static function attachedServerConfigName(string $project, string $location): string - { - return self::getPathTemplate('attachedServerConfig')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - attachedCluster: projects/{project}/locations/{location}/attachedClusters/{attached_cluster} - * - attachedServerConfig: projects/{project}/locations/{location}/attachedServerConfig - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'gkemulticloud.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new - * [AttachedCluster][google.cloud.gkemulticloud.v1.AttachedCluster] resource - * on a given Google Cloud Platform project and region. - * - * If successful, the response contains a newly created - * [Operation][google.longrunning.Operation] resource that can be - * described to track the status of the operation. - * - * The async variant is {@see self::createAttachedClusterAsync()} . - * - * @example samples/V1/AttachedClustersClient/create_attached_cluster.php - * - * @param CreateAttachedClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAttachedCluster(CreateAttachedClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateAttachedCluster', $request, $callOptions)->wait(); - } - - /** - * Deletes a specific - * [AttachedCluster][google.cloud.gkemulticloud.v1.AttachedCluster] resource. - * - * If successful, the response contains a newly created - * [Operation][google.longrunning.Operation] resource that can be - * described to track the status of the operation. - * - * The async variant is {@see self::deleteAttachedClusterAsync()} . - * - * @example samples/V1/AttachedClustersClient/delete_attached_cluster.php - * - * @param DeleteAttachedClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAttachedCluster(DeleteAttachedClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteAttachedCluster', $request, $callOptions)->wait(); - } - - /** - * Generates the install manifest to be installed on the target cluster. - * - * The async variant is {@see self::generateAttachedClusterInstallManifestAsync()} - * . - * - * @example samples/V1/AttachedClustersClient/generate_attached_cluster_install_manifest.php - * - * @param GenerateAttachedClusterInstallManifestRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GenerateAttachedClusterInstallManifestResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function generateAttachedClusterInstallManifest(GenerateAttachedClusterInstallManifestRequest $request, array $callOptions = []): GenerateAttachedClusterInstallManifestResponse - { - return $this->startApiCall('GenerateAttachedClusterInstallManifest', $request, $callOptions)->wait(); - } - - /** - * Describes a specific - * [AttachedCluster][google.cloud.gkemulticloud.v1.AttachedCluster] resource. - * - * The async variant is {@see self::getAttachedClusterAsync()} . - * - * @example samples/V1/AttachedClustersClient/get_attached_cluster.php - * - * @param GetAttachedClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AttachedCluster - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAttachedCluster(GetAttachedClusterRequest $request, array $callOptions = []): AttachedCluster - { - return $this->startApiCall('GetAttachedCluster', $request, $callOptions)->wait(); - } - - /** - * Returns information, such as supported Kubernetes versions, on a given - * Google Cloud location. - * - * The async variant is {@see self::getAttachedServerConfigAsync()} . - * - * @example samples/V1/AttachedClustersClient/get_attached_server_config.php - * - * @param GetAttachedServerConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AttachedServerConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAttachedServerConfig(GetAttachedServerConfigRequest $request, array $callOptions = []): AttachedServerConfig - { - return $this->startApiCall('GetAttachedServerConfig', $request, $callOptions)->wait(); - } - - /** - * Imports creates a new - * [AttachedCluster][google.cloud.gkemulticloud.v1.AttachedCluster] resource - * by importing an existing Fleet Membership resource. - * - * Attached Clusters created before the introduction of the Anthos Multi-Cloud - * API can be imported through this method. - * - * If successful, the response contains a newly created - * [Operation][google.longrunning.Operation] resource that can be - * described to track the status of the operation. - * - * The async variant is {@see self::importAttachedClusterAsync()} . - * - * @example samples/V1/AttachedClustersClient/import_attached_cluster.php - * - * @param ImportAttachedClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function importAttachedCluster(ImportAttachedClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ImportAttachedCluster', $request, $callOptions)->wait(); - } - - /** - * Lists all [AttachedCluster][google.cloud.gkemulticloud.v1.AttachedCluster] - * resources on a given Google Cloud project and region. - * - * The async variant is {@see self::listAttachedClustersAsync()} . - * - * @example samples/V1/AttachedClustersClient/list_attached_clusters.php - * - * @param ListAttachedClustersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAttachedClusters(ListAttachedClustersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAttachedClusters', $request, $callOptions); - } - - /** - * Updates an - * [AttachedCluster][google.cloud.gkemulticloud.v1.AttachedCluster]. - * - * The async variant is {@see self::updateAttachedClusterAsync()} . - * - * @example samples/V1/AttachedClustersClient/update_attached_cluster.php - * - * @param UpdateAttachedClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAttachedCluster(UpdateAttachedClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateAttachedCluster', $request, $callOptions)->wait(); - } -} diff --git a/GkeMultiCloud/src/V1/Client/BaseClient/AwsClustersBaseClient.php b/GkeMultiCloud/src/V1/Client/BaseClient/AwsClustersBaseClient.php deleted file mode 100644 index 99050bc581aa..000000000000 --- a/GkeMultiCloud/src/V1/Client/BaseClient/AwsClustersBaseClient.php +++ /dev/null @@ -1,675 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/aws_clusters_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/aws_clusters_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/aws_clusters_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/aws_clusters_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a aws_cluster - * resource. - * - * @param string $project - * @param string $location - * @param string $awsCluster - * - * @return string The formatted aws_cluster resource. - */ - public static function awsClusterName(string $project, string $location, string $awsCluster): string - { - return self::getPathTemplate('awsCluster')->render([ - 'project' => $project, - 'location' => $location, - 'aws_cluster' => $awsCluster, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * aws_node_pool resource. - * - * @param string $project - * @param string $location - * @param string $awsCluster - * @param string $awsNodePool - * - * @return string The formatted aws_node_pool resource. - */ - public static function awsNodePoolName(string $project, string $location, string $awsCluster, string $awsNodePool): string - { - return self::getPathTemplate('awsNodePool')->render([ - 'project' => $project, - 'location' => $location, - 'aws_cluster' => $awsCluster, - 'aws_node_pool' => $awsNodePool, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * aws_server_config resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted aws_server_config resource. - */ - public static function awsServerConfigName(string $project, string $location): string - { - return self::getPathTemplate('awsServerConfig')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - awsCluster: projects/{project}/locations/{location}/awsClusters/{aws_cluster} - * - awsNodePool: projects/{project}/locations/{location}/awsClusters/{aws_cluster}/awsNodePools/{aws_node_pool} - * - awsServerConfig: projects/{project}/locations/{location}/awsServerConfig - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'gkemulticloud.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new [AwsCluster][google.cloud.gkemulticloud.v1.AwsCluster] - * resource on a given Google Cloud Platform project and region. - * - * If successful, the response contains a newly created - * [Operation][google.longrunning.Operation] resource that can be - * described to track the status of the operation. - * - * The async variant is {@see self::createAwsClusterAsync()} . - * - * @example samples/V1/AwsClustersClient/create_aws_cluster.php - * - * @param CreateAwsClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAwsCluster(CreateAwsClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateAwsCluster', $request, $callOptions)->wait(); - } - - /** - * Creates a new [AwsNodePool][google.cloud.gkemulticloud.v1.AwsNodePool], - * attached to a given [AwsCluster][google.cloud.gkemulticloud.v1.AwsCluster]. - * - * If successful, the response contains a newly created - * [Operation][google.longrunning.Operation] resource that can be - * described to track the status of the operation. - * - * The async variant is {@see self::createAwsNodePoolAsync()} . - * - * @example samples/V1/AwsClustersClient/create_aws_node_pool.php - * - * @param CreateAwsNodePoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAwsNodePool(CreateAwsNodePoolRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateAwsNodePool', $request, $callOptions)->wait(); - } - - /** - * Deletes a specific [AwsCluster][google.cloud.gkemulticloud.v1.AwsCluster] - * resource. - * - * Fails if the cluster has one or more associated - * [AwsNodePool][google.cloud.gkemulticloud.v1.AwsNodePool] resources. - * - * If successful, the response contains a newly created - * [Operation][google.longrunning.Operation] resource that can be - * described to track the status of the operation. - * - * The async variant is {@see self::deleteAwsClusterAsync()} . - * - * @example samples/V1/AwsClustersClient/delete_aws_cluster.php - * - * @param DeleteAwsClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAwsCluster(DeleteAwsClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteAwsCluster', $request, $callOptions)->wait(); - } - - /** - * Deletes a specific [AwsNodePool][google.cloud.gkemulticloud.v1.AwsNodePool] - * resource. - * - * If successful, the response contains a newly created - * [Operation][google.longrunning.Operation] resource that can be - * described to track the status of the operation. - * - * The async variant is {@see self::deleteAwsNodePoolAsync()} . - * - * @example samples/V1/AwsClustersClient/delete_aws_node_pool.php - * - * @param DeleteAwsNodePoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAwsNodePool(DeleteAwsNodePoolRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteAwsNodePool', $request, $callOptions)->wait(); - } - - /** - * Generates a short-lived access token to authenticate to a given - * [AwsCluster][google.cloud.gkemulticloud.v1.AwsCluster] resource. - * - * The async variant is {@see self::generateAwsAccessTokenAsync()} . - * - * @example samples/V1/AwsClustersClient/generate_aws_access_token.php - * - * @param GenerateAwsAccessTokenRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GenerateAwsAccessTokenResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function generateAwsAccessToken(GenerateAwsAccessTokenRequest $request, array $callOptions = []): GenerateAwsAccessTokenResponse - { - return $this->startApiCall('GenerateAwsAccessToken', $request, $callOptions)->wait(); - } - - /** - * Describes a specific [AwsCluster][google.cloud.gkemulticloud.v1.AwsCluster] - * resource. - * - * The async variant is {@see self::getAwsClusterAsync()} . - * - * @example samples/V1/AwsClustersClient/get_aws_cluster.php - * - * @param GetAwsClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AwsCluster - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAwsCluster(GetAwsClusterRequest $request, array $callOptions = []): AwsCluster - { - return $this->startApiCall('GetAwsCluster', $request, $callOptions)->wait(); - } - - /** - * Describes a specific - * [AwsNodePool][google.cloud.gkemulticloud.v1.AwsNodePool] resource. - * - * The async variant is {@see self::getAwsNodePoolAsync()} . - * - * @example samples/V1/AwsClustersClient/get_aws_node_pool.php - * - * @param GetAwsNodePoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AwsNodePool - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAwsNodePool(GetAwsNodePoolRequest $request, array $callOptions = []): AwsNodePool - { - return $this->startApiCall('GetAwsNodePool', $request, $callOptions)->wait(); - } - - /** - * Returns information, such as supported AWS regions and Kubernetes - * versions, on a given Google Cloud location. - * - * The async variant is {@see self::getAwsServerConfigAsync()} . - * - * @example samples/V1/AwsClustersClient/get_aws_server_config.php - * - * @param GetAwsServerConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AwsServerConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAwsServerConfig(GetAwsServerConfigRequest $request, array $callOptions = []): AwsServerConfig - { - return $this->startApiCall('GetAwsServerConfig', $request, $callOptions)->wait(); - } - - /** - * Lists all [AwsCluster][google.cloud.gkemulticloud.v1.AwsCluster] resources - * on a given Google Cloud project and region. - * - * The async variant is {@see self::listAwsClustersAsync()} . - * - * @example samples/V1/AwsClustersClient/list_aws_clusters.php - * - * @param ListAwsClustersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAwsClusters(ListAwsClustersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAwsClusters', $request, $callOptions); - } - - /** - * Lists all [AwsNodePool][google.cloud.gkemulticloud.v1.AwsNodePool] - * resources on a given - * [AwsCluster][google.cloud.gkemulticloud.v1.AwsCluster]. - * - * The async variant is {@see self::listAwsNodePoolsAsync()} . - * - * @example samples/V1/AwsClustersClient/list_aws_node_pools.php - * - * @param ListAwsNodePoolsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAwsNodePools(ListAwsNodePoolsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAwsNodePools', $request, $callOptions); - } - - /** - * Updates an [AwsCluster][google.cloud.gkemulticloud.v1.AwsCluster]. - * - * The async variant is {@see self::updateAwsClusterAsync()} . - * - * @example samples/V1/AwsClustersClient/update_aws_cluster.php - * - * @param UpdateAwsClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAwsCluster(UpdateAwsClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateAwsCluster', $request, $callOptions)->wait(); - } - - /** - * Updates an [AwsNodePool][google.cloud.gkemulticloud.v1.AwsNodePool]. - * - * The async variant is {@see self::updateAwsNodePoolAsync()} . - * - * @example samples/V1/AwsClustersClient/update_aws_node_pool.php - * - * @param UpdateAwsNodePoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAwsNodePool(UpdateAwsNodePoolRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateAwsNodePool', $request, $callOptions)->wait(); - } -} diff --git a/GkeMultiCloud/src/V1/Client/BaseClient/AzureClustersBaseClient.php b/GkeMultiCloud/src/V1/Client/BaseClient/AzureClustersBaseClient.php deleted file mode 100644 index f600c2cc9025..000000000000 --- a/GkeMultiCloud/src/V1/Client/BaseClient/AzureClustersBaseClient.php +++ /dev/null @@ -1,829 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/azure_clusters_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/azure_clusters_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/azure_clusters_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/azure_clusters_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a azure_client - * resource. - * - * @param string $project - * @param string $location - * @param string $azureClient - * - * @return string The formatted azure_client resource. - */ - public static function azureClientName(string $project, string $location, string $azureClient): string - { - return self::getPathTemplate('azureClient')->render([ - 'project' => $project, - 'location' => $location, - 'azure_client' => $azureClient, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * azure_cluster resource. - * - * @param string $project - * @param string $location - * @param string $azureCluster - * - * @return string The formatted azure_cluster resource. - */ - public static function azureClusterName(string $project, string $location, string $azureCluster): string - { - return self::getPathTemplate('azureCluster')->render([ - 'project' => $project, - 'location' => $location, - 'azure_cluster' => $azureCluster, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * azure_node_pool resource. - * - * @param string $project - * @param string $location - * @param string $azureCluster - * @param string $azureNodePool - * - * @return string The formatted azure_node_pool resource. - */ - public static function azureNodePoolName(string $project, string $location, string $azureCluster, string $azureNodePool): string - { - return self::getPathTemplate('azureNodePool')->render([ - 'project' => $project, - 'location' => $location, - 'azure_cluster' => $azureCluster, - 'azure_node_pool' => $azureNodePool, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * azure_server_config resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted azure_server_config resource. - */ - public static function azureServerConfigName(string $project, string $location): string - { - return self::getPathTemplate('azureServerConfig')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - azureClient: projects/{project}/locations/{location}/azureClients/{azure_client} - * - azureCluster: projects/{project}/locations/{location}/azureClusters/{azure_cluster} - * - azureNodePool: projects/{project}/locations/{location}/azureClusters/{azure_cluster}/azureNodePools/{azure_node_pool} - * - azureServerConfig: projects/{project}/locations/{location}/azureServerConfig - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'gkemulticloud.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new [AzureClient][google.cloud.gkemulticloud.v1.AzureClient] - * resource on a given Google Cloud project and region. - * - * `AzureClient` resources hold client authentication - * information needed by the Anthos Multicloud API to manage Azure resources - * on your Azure subscription on your behalf. - * - * If successful, the response contains a newly created - * [Operation][google.longrunning.Operation] resource that can be - * described to track the status of the operation. - * - * The async variant is {@see self::createAzureClientAsync()} . - * - * @example samples/V1/AzureClustersClient/create_azure_client.php - * - * @param CreateAzureClientRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAzureClient(CreateAzureClientRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateAzureClient', $request, $callOptions)->wait(); - } - - /** - * Creates a new [AzureCluster][google.cloud.gkemulticloud.v1.AzureCluster] - * resource on a given Google Cloud Platform project and region. - * - * If successful, the response contains a newly created - * [Operation][google.longrunning.Operation] resource that can be - * described to track the status of the operation. - * - * The async variant is {@see self::createAzureClusterAsync()} . - * - * @example samples/V1/AzureClustersClient/create_azure_cluster.php - * - * @param CreateAzureClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAzureCluster(CreateAzureClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateAzureCluster', $request, $callOptions)->wait(); - } - - /** - * Creates a new [AzureNodePool][google.cloud.gkemulticloud.v1.AzureNodePool], - * attached to a given - * [AzureCluster][google.cloud.gkemulticloud.v1.AzureCluster]. - * - * If successful, the response contains a newly created - * [Operation][google.longrunning.Operation] resource that can be - * described to track the status of the operation. - * - * The async variant is {@see self::createAzureNodePoolAsync()} . - * - * @example samples/V1/AzureClustersClient/create_azure_node_pool.php - * - * @param CreateAzureNodePoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAzureNodePool(CreateAzureNodePoolRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateAzureNodePool', $request, $callOptions)->wait(); - } - - /** - * Deletes a specific [AzureClient][google.cloud.gkemulticloud.v1.AzureClient] - * resource. - * - * If the client is used by one or more clusters, deletion will - * fail and a `FAILED_PRECONDITION` error will be returned. - * - * If successful, the response contains a newly created - * [Operation][google.longrunning.Operation] resource that can be - * described to track the status of the operation. - * - * The async variant is {@see self::deleteAzureClientAsync()} . - * - * @example samples/V1/AzureClustersClient/delete_azure_client.php - * - * @param DeleteAzureClientRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAzureClient(DeleteAzureClientRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteAzureClient', $request, $callOptions)->wait(); - } - - /** - * Deletes a specific - * [AzureCluster][google.cloud.gkemulticloud.v1.AzureCluster] resource. - * - * Fails if the cluster has one or more associated - * [AzureNodePool][google.cloud.gkemulticloud.v1.AzureNodePool] resources. - * - * If successful, the response contains a newly created - * [Operation][google.longrunning.Operation] resource that can be - * described to track the status of the operation. - * - * The async variant is {@see self::deleteAzureClusterAsync()} . - * - * @example samples/V1/AzureClustersClient/delete_azure_cluster.php - * - * @param DeleteAzureClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAzureCluster(DeleteAzureClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteAzureCluster', $request, $callOptions)->wait(); - } - - /** - * Deletes a specific - * [AzureNodePool][google.cloud.gkemulticloud.v1.AzureNodePool] resource. - * - * If successful, the response contains a newly created - * [Operation][google.longrunning.Operation] resource that can be - * described to track the status of the operation. - * - * The async variant is {@see self::deleteAzureNodePoolAsync()} . - * - * @example samples/V1/AzureClustersClient/delete_azure_node_pool.php - * - * @param DeleteAzureNodePoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAzureNodePool(DeleteAzureNodePoolRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteAzureNodePool', $request, $callOptions)->wait(); - } - - /** - * Generates a short-lived access token to authenticate to a given - * [AzureCluster][google.cloud.gkemulticloud.v1.AzureCluster] resource. - * - * The async variant is {@see self::generateAzureAccessTokenAsync()} . - * - * @example samples/V1/AzureClustersClient/generate_azure_access_token.php - * - * @param GenerateAzureAccessTokenRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GenerateAzureAccessTokenResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function generateAzureAccessToken(GenerateAzureAccessTokenRequest $request, array $callOptions = []): GenerateAzureAccessTokenResponse - { - return $this->startApiCall('GenerateAzureAccessToken', $request, $callOptions)->wait(); - } - - /** - * Describes a specific - * [AzureClient][google.cloud.gkemulticloud.v1.AzureClient] resource. - * - * The async variant is {@see self::getAzureClientAsync()} . - * - * @example samples/V1/AzureClustersClient/get_azure_client.php - * - * @param GetAzureClientRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AzureClient - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAzureClient(GetAzureClientRequest $request, array $callOptions = []): AzureClient - { - return $this->startApiCall('GetAzureClient', $request, $callOptions)->wait(); - } - - /** - * Describes a specific - * [AzureCluster][google.cloud.gkemulticloud.v1.AzureCluster] resource. - * - * The async variant is {@see self::getAzureClusterAsync()} . - * - * @example samples/V1/AzureClustersClient/get_azure_cluster.php - * - * @param GetAzureClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AzureCluster - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAzureCluster(GetAzureClusterRequest $request, array $callOptions = []): AzureCluster - { - return $this->startApiCall('GetAzureCluster', $request, $callOptions)->wait(); - } - - /** - * Describes a specific - * [AzureNodePool][google.cloud.gkemulticloud.v1.AzureNodePool] resource. - * - * The async variant is {@see self::getAzureNodePoolAsync()} . - * - * @example samples/V1/AzureClustersClient/get_azure_node_pool.php - * - * @param GetAzureNodePoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AzureNodePool - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAzureNodePool(GetAzureNodePoolRequest $request, array $callOptions = []): AzureNodePool - { - return $this->startApiCall('GetAzureNodePool', $request, $callOptions)->wait(); - } - - /** - * Returns information, such as supported Azure regions and Kubernetes - * versions, on a given Google Cloud location. - * - * The async variant is {@see self::getAzureServerConfigAsync()} . - * - * @example samples/V1/AzureClustersClient/get_azure_server_config.php - * - * @param GetAzureServerConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AzureServerConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAzureServerConfig(GetAzureServerConfigRequest $request, array $callOptions = []): AzureServerConfig - { - return $this->startApiCall('GetAzureServerConfig', $request, $callOptions)->wait(); - } - - /** - * Lists all [AzureClient][google.cloud.gkemulticloud.v1.AzureClient] - * resources on a given Google Cloud project and region. - * - * The async variant is {@see self::listAzureClientsAsync()} . - * - * @example samples/V1/AzureClustersClient/list_azure_clients.php - * - * @param ListAzureClientsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAzureClients(ListAzureClientsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAzureClients', $request, $callOptions); - } - - /** - * Lists all [AzureCluster][google.cloud.gkemulticloud.v1.AzureCluster] - * resources on a given Google Cloud project and region. - * - * The async variant is {@see self::listAzureClustersAsync()} . - * - * @example samples/V1/AzureClustersClient/list_azure_clusters.php - * - * @param ListAzureClustersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAzureClusters(ListAzureClustersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAzureClusters', $request, $callOptions); - } - - /** - * Lists all [AzureNodePool][google.cloud.gkemulticloud.v1.AzureNodePool] - * resources on a given - * [AzureCluster][google.cloud.gkemulticloud.v1.AzureCluster]. - * - * The async variant is {@see self::listAzureNodePoolsAsync()} . - * - * @example samples/V1/AzureClustersClient/list_azure_node_pools.php - * - * @param ListAzureNodePoolsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAzureNodePools(ListAzureNodePoolsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAzureNodePools', $request, $callOptions); - } - - /** - * Updates an [AzureCluster][google.cloud.gkemulticloud.v1.AzureCluster]. - * - * The async variant is {@see self::updateAzureClusterAsync()} . - * - * @example samples/V1/AzureClustersClient/update_azure_cluster.php - * - * @param UpdateAzureClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAzureCluster(UpdateAzureClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateAzureCluster', $request, $callOptions)->wait(); - } - - /** - * Updates an [AzureNodePool][google.cloud.gkemulticloud.v1.AzureNodePool]. - * - * The async variant is {@see self::updateAzureNodePoolAsync()} . - * - * @example samples/V1/AzureClustersClient/update_azure_node_pool.php - * - * @param UpdateAzureNodePoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAzureNodePool(UpdateAzureNodePoolRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateAzureNodePool', $request, $callOptions)->wait(); - } -} diff --git a/Grafeas/composer.json b/Grafeas/composer.json index 32648966318d..022ff0a1da13 100644 --- a/Grafeas/composer.json +++ b/Grafeas/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Grafeas/src/V1/Client/BaseClient/GrafeasBaseClient.php b/Grafeas/src/V1/Client/BaseClient/GrafeasBaseClient.php deleted file mode 100644 index 83d4457d8dfc..000000000000 --- a/Grafeas/src/V1/Client/BaseClient/GrafeasBaseClient.php +++ /dev/null @@ -1,651 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/grafeas_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/grafeas_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/grafeas_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/grafeas_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a note - * resource. - * - * @param string $project - * @param string $note - * - * @return string The formatted note resource. - */ - public static function noteName(string $project, string $note): string - { - return self::getPathTemplate('note')->render([ - 'project' => $project, - 'note' => $note, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a occurrence - * resource. - * - * @param string $project - * @param string $occurrence - * - * @return string The formatted occurrence resource. - */ - public static function occurrenceName(string $project, string $occurrence): string - { - return self::getPathTemplate('occurrence')->render([ - 'project' => $project, - 'occurrence' => $occurrence, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->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 - * - note: projects/{project}/notes/{note} - * - occurrence: projects/{project}/occurrences/{occurrence} - * - 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. - */ - public static function parseName(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'containeranalysis.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates new notes in batch. - * - * The async variant is {@see self::batchCreateNotesAsync()} . - * - * @example samples/V1/GrafeasClient/batch_create_notes.php - * - * @param BatchCreateNotesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BatchCreateNotesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchCreateNotes(BatchCreateNotesRequest $request, array $callOptions = []): BatchCreateNotesResponse - { - return $this->startApiCall('BatchCreateNotes', $request, $callOptions)->wait(); - } - - /** - * Creates new occurrences in batch. - * - * The async variant is {@see self::batchCreateOccurrencesAsync()} . - * - * @example samples/V1/GrafeasClient/batch_create_occurrences.php - * - * @param BatchCreateOccurrencesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BatchCreateOccurrencesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchCreateOccurrences(BatchCreateOccurrencesRequest $request, array $callOptions = []): BatchCreateOccurrencesResponse - { - return $this->startApiCall('BatchCreateOccurrences', $request, $callOptions)->wait(); - } - - /** - * Creates a new note. - * - * The async variant is {@see self::createNoteAsync()} . - * - * @example samples/V1/GrafeasClient/create_note.php - * - * @param CreateNoteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Note - * - * @throws ApiException Thrown if the API call fails. - */ - public function createNote(CreateNoteRequest $request, array $callOptions = []): Note - { - return $this->startApiCall('CreateNote', $request, $callOptions)->wait(); - } - - /** - * Creates a new occurrence. - * - * The async variant is {@see self::createOccurrenceAsync()} . - * - * @example samples/V1/GrafeasClient/create_occurrence.php - * - * @param CreateOccurrenceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Occurrence - * - * @throws ApiException Thrown if the API call fails. - */ - public function createOccurrence(CreateOccurrenceRequest $request, array $callOptions = []): Occurrence - { - return $this->startApiCall('CreateOccurrence', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified note. - * - * The async variant is {@see self::deleteNoteAsync()} . - * - * @example samples/V1/GrafeasClient/delete_note.php - * - * @param DeleteNoteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteNote(DeleteNoteRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteNote', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified occurrence. For example, use this method to delete an - * occurrence when the occurrence is no longer applicable for the given - * resource. - * - * The async variant is {@see self::deleteOccurrenceAsync()} . - * - * @example samples/V1/GrafeasClient/delete_occurrence.php - * - * @param DeleteOccurrenceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteOccurrence(DeleteOccurrenceRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteOccurrence', $request, $callOptions)->wait(); - } - - /** - * Gets the specified note. - * - * The async variant is {@see self::getNoteAsync()} . - * - * @example samples/V1/GrafeasClient/get_note.php - * - * @param GetNoteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Note - * - * @throws ApiException Thrown if the API call fails. - */ - public function getNote(GetNoteRequest $request, array $callOptions = []): Note - { - return $this->startApiCall('GetNote', $request, $callOptions)->wait(); - } - - /** - * Gets the specified occurrence. - * - * The async variant is {@see self::getOccurrenceAsync()} . - * - * @example samples/V1/GrafeasClient/get_occurrence.php - * - * @param GetOccurrenceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Occurrence - * - * @throws ApiException Thrown if the API call fails. - */ - public function getOccurrence(GetOccurrenceRequest $request, array $callOptions = []): Occurrence - { - return $this->startApiCall('GetOccurrence', $request, $callOptions)->wait(); - } - - /** - * Gets the note attached to the specified occurrence. Consumer projects can - * use this method to get a note that belongs to a provider project. - * - * The async variant is {@see self::getOccurrenceNoteAsync()} . - * - * @example samples/V1/GrafeasClient/get_occurrence_note.php - * - * @param GetOccurrenceNoteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Note - * - * @throws ApiException Thrown if the API call fails. - */ - public function getOccurrenceNote(GetOccurrenceNoteRequest $request, array $callOptions = []): Note - { - return $this->startApiCall('GetOccurrenceNote', $request, $callOptions)->wait(); - } - - /** - * Lists occurrences referencing the specified note. Provider projects can use - * this method to get all occurrences across consumer projects referencing the - * specified note. - * - * The async variant is {@see self::listNoteOccurrencesAsync()} . - * - * @example samples/V1/GrafeasClient/list_note_occurrences.php - * - * @param ListNoteOccurrencesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listNoteOccurrences(ListNoteOccurrencesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListNoteOccurrences', $request, $callOptions); - } - - /** - * Lists notes for the specified project. - * - * The async variant is {@see self::listNotesAsync()} . - * - * @example samples/V1/GrafeasClient/list_notes.php - * - * @param ListNotesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listNotes(ListNotesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListNotes', $request, $callOptions); - } - - /** - * Lists occurrences for the specified project. - * - * The async variant is {@see self::listOccurrencesAsync()} . - * - * @example samples/V1/GrafeasClient/list_occurrences.php - * - * @param ListOccurrencesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listOccurrences(ListOccurrencesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListOccurrences', $request, $callOptions); - } - - /** - * Updates the specified note. - * - * The async variant is {@see self::updateNoteAsync()} . - * - * @example samples/V1/GrafeasClient/update_note.php - * - * @param UpdateNoteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Note - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateNote(UpdateNoteRequest $request, array $callOptions = []): Note - { - return $this->startApiCall('UpdateNote', $request, $callOptions)->wait(); - } - - /** - * Updates the specified occurrence. - * - * The async variant is {@see self::updateOccurrenceAsync()} . - * - * @example samples/V1/GrafeasClient/update_occurrence.php - * - * @param UpdateOccurrenceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Occurrence - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateOccurrence(UpdateOccurrenceRequest $request, array $callOptions = []): Occurrence - { - return $this->startApiCall('UpdateOccurrence', $request, $callOptions)->wait(); - } -} diff --git a/Grafeas/src/V1/Client/GrafeasClient.php b/Grafeas/src/V1/Client/GrafeasClient.php index 139f7f7da7d6..3bf410a91646 100644 --- a/Grafeas/src/V1/Client/GrafeasClient.php +++ b/Grafeas/src/V1/Client/GrafeasClient.php @@ -24,17 +24,626 @@ namespace Grafeas\V1\Client; -use Grafeas\V1\Client\BaseClient\GrafeasBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Grafeas\V1\BatchCreateNotesRequest; +use Grafeas\V1\BatchCreateNotesResponse; +use Grafeas\V1\BatchCreateOccurrencesRequest; +use Grafeas\V1\BatchCreateOccurrencesResponse; +use Grafeas\V1\CreateNoteRequest; +use Grafeas\V1\CreateOccurrenceRequest; +use Grafeas\V1\DeleteNoteRequest; +use Grafeas\V1\DeleteOccurrenceRequest; +use Grafeas\V1\GetNoteRequest; +use Grafeas\V1\GetOccurrenceNoteRequest; +use Grafeas\V1\GetOccurrenceRequest; +use Grafeas\V1\ListNoteOccurrencesRequest; +use Grafeas\V1\ListNotesRequest; +use Grafeas\V1\ListOccurrencesRequest; +use Grafeas\V1\Note; +use Grafeas\V1\Occurrence; +use Grafeas\V1\UpdateNoteRequest; +use Grafeas\V1\UpdateOccurrenceRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: [Grafeas](https://grafeas.io) API. * - * This class is currently experimental and may be subject to changes. + * Retrieves analysis results of Cloud components such as Docker container + * images. + * + * Analysis results are stored as a series of occurrences. An `Occurrence` + * contains information about a specific analysis instance on a resource. An + * occurrence refers to a `Note`. A note contains details describing the + * analysis and is generally stored in a separate project, called a `Provider`. + * Multiple occurrences can refer to the same note. + * + * For example, an SSL vulnerability could affect multiple images. In this case, + * there would be one note for the vulnerability and an occurrence for each + * image with the vulnerability referring to that note. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Grafeas\V1\GrafeasClient} for the stable implementation * * @experimental + * + * @method PromiseInterface batchCreateNotesAsync(BatchCreateNotesRequest $request, array $optionalArgs = []) + * @method PromiseInterface batchCreateOccurrencesAsync(BatchCreateOccurrencesRequest $request, array $optionalArgs = []) + * @method PromiseInterface createNoteAsync(CreateNoteRequest $request, array $optionalArgs = []) + * @method PromiseInterface createOccurrenceAsync(CreateOccurrenceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteNoteAsync(DeleteNoteRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteOccurrenceAsync(DeleteOccurrenceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getNoteAsync(GetNoteRequest $request, array $optionalArgs = []) + * @method PromiseInterface getOccurrenceAsync(GetOccurrenceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getOccurrenceNoteAsync(GetOccurrenceNoteRequest $request, array $optionalArgs = []) + * @method PromiseInterface listNoteOccurrencesAsync(ListNoteOccurrencesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listNotesAsync(ListNotesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listOccurrencesAsync(ListOccurrencesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateNoteAsync(UpdateNoteRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateOccurrenceAsync(UpdateOccurrenceRequest $request, array $optionalArgs = []) */ -final class GrafeasClient extends GrafeasBaseClient +final class GrafeasClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see GrafeasBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'grafeas.v1.Grafeas'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'containeranalysis.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = []; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/grafeas_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/grafeas_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/grafeas_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/grafeas_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a note + * resource. + * + * @param string $project + * @param string $note + * + * @return string The formatted note resource. + */ + public static function noteName(string $project, string $note): string + { + return self::getPathTemplate('note')->render([ + 'project' => $project, + 'note' => $note, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a occurrence + * resource. + * + * @param string $project + * @param string $occurrence + * + * @return string The formatted occurrence resource. + */ + public static function occurrenceName(string $project, string $occurrence): string + { + return self::getPathTemplate('occurrence')->render([ + 'project' => $project, + 'occurrence' => $occurrence, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->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 + * - note: projects/{project}/notes/{note} + * - occurrence: projects/{project}/occurrences/{occurrence} + * - 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. + */ + public static function parseName(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'containeranalysis.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates new notes in batch. + * + * The async variant is {@see GrafeasClient::batchCreateNotesAsync()} . + * + * @example samples/V1/GrafeasClient/batch_create_notes.php + * + * @param BatchCreateNotesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BatchCreateNotesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchCreateNotes(BatchCreateNotesRequest $request, array $callOptions = []): BatchCreateNotesResponse + { + return $this->startApiCall('BatchCreateNotes', $request, $callOptions)->wait(); + } + + /** + * Creates new occurrences in batch. + * + * The async variant is {@see GrafeasClient::batchCreateOccurrencesAsync()} . + * + * @example samples/V1/GrafeasClient/batch_create_occurrences.php + * + * @param BatchCreateOccurrencesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BatchCreateOccurrencesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchCreateOccurrences(BatchCreateOccurrencesRequest $request, array $callOptions = []): BatchCreateOccurrencesResponse + { + return $this->startApiCall('BatchCreateOccurrences', $request, $callOptions)->wait(); + } + + /** + * Creates a new note. + * + * The async variant is {@see GrafeasClient::createNoteAsync()} . + * + * @example samples/V1/GrafeasClient/create_note.php + * + * @param CreateNoteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Note + * + * @throws ApiException Thrown if the API call fails. + */ + public function createNote(CreateNoteRequest $request, array $callOptions = []): Note + { + return $this->startApiCall('CreateNote', $request, $callOptions)->wait(); + } + + /** + * Creates a new occurrence. + * + * The async variant is {@see GrafeasClient::createOccurrenceAsync()} . + * + * @example samples/V1/GrafeasClient/create_occurrence.php + * + * @param CreateOccurrenceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Occurrence + * + * @throws ApiException Thrown if the API call fails. + */ + public function createOccurrence(CreateOccurrenceRequest $request, array $callOptions = []): Occurrence + { + return $this->startApiCall('CreateOccurrence', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified note. + * + * The async variant is {@see GrafeasClient::deleteNoteAsync()} . + * + * @example samples/V1/GrafeasClient/delete_note.php + * + * @param DeleteNoteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteNote(DeleteNoteRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteNote', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified occurrence. For example, use this method to delete an + * occurrence when the occurrence is no longer applicable for the given + * resource. + * + * The async variant is {@see GrafeasClient::deleteOccurrenceAsync()} . + * + * @example samples/V1/GrafeasClient/delete_occurrence.php + * + * @param DeleteOccurrenceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteOccurrence(DeleteOccurrenceRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteOccurrence', $request, $callOptions)->wait(); + } + + /** + * Gets the specified note. + * + * The async variant is {@see GrafeasClient::getNoteAsync()} . + * + * @example samples/V1/GrafeasClient/get_note.php + * + * @param GetNoteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Note + * + * @throws ApiException Thrown if the API call fails. + */ + public function getNote(GetNoteRequest $request, array $callOptions = []): Note + { + return $this->startApiCall('GetNote', $request, $callOptions)->wait(); + } + + /** + * Gets the specified occurrence. + * + * The async variant is {@see GrafeasClient::getOccurrenceAsync()} . + * + * @example samples/V1/GrafeasClient/get_occurrence.php + * + * @param GetOccurrenceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Occurrence + * + * @throws ApiException Thrown if the API call fails. + */ + public function getOccurrence(GetOccurrenceRequest $request, array $callOptions = []): Occurrence + { + return $this->startApiCall('GetOccurrence', $request, $callOptions)->wait(); + } + + /** + * Gets the note attached to the specified occurrence. Consumer projects can + * use this method to get a note that belongs to a provider project. + * + * The async variant is {@see GrafeasClient::getOccurrenceNoteAsync()} . + * + * @example samples/V1/GrafeasClient/get_occurrence_note.php + * + * @param GetOccurrenceNoteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Note + * + * @throws ApiException Thrown if the API call fails. + */ + public function getOccurrenceNote(GetOccurrenceNoteRequest $request, array $callOptions = []): Note + { + return $this->startApiCall('GetOccurrenceNote', $request, $callOptions)->wait(); + } + + /** + * Lists occurrences referencing the specified note. Provider projects can use + * this method to get all occurrences across consumer projects referencing the + * specified note. + * + * The async variant is {@see GrafeasClient::listNoteOccurrencesAsync()} . + * + * @example samples/V1/GrafeasClient/list_note_occurrences.php + * + * @param ListNoteOccurrencesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listNoteOccurrences(ListNoteOccurrencesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListNoteOccurrences', $request, $callOptions); + } + + /** + * Lists notes for the specified project. + * + * The async variant is {@see GrafeasClient::listNotesAsync()} . + * + * @example samples/V1/GrafeasClient/list_notes.php + * + * @param ListNotesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listNotes(ListNotesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListNotes', $request, $callOptions); + } + + /** + * Lists occurrences for the specified project. + * + * The async variant is {@see GrafeasClient::listOccurrencesAsync()} . + * + * @example samples/V1/GrafeasClient/list_occurrences.php + * + * @param ListOccurrencesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listOccurrences(ListOccurrencesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListOccurrences', $request, $callOptions); + } + + /** + * Updates the specified note. + * + * The async variant is {@see GrafeasClient::updateNoteAsync()} . + * + * @example samples/V1/GrafeasClient/update_note.php + * + * @param UpdateNoteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Note + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateNote(UpdateNoteRequest $request, array $callOptions = []): Note + { + return $this->startApiCall('UpdateNote', $request, $callOptions)->wait(); + } + + /** + * Updates the specified occurrence. + * + * The async variant is {@see GrafeasClient::updateOccurrenceAsync()} . + * + * @example samples/V1/GrafeasClient/update_occurrence.php + * + * @param UpdateOccurrenceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Occurrence + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateOccurrence(UpdateOccurrenceRequest $request, array $callOptions = []): Occurrence + { + return $this->startApiCall('UpdateOccurrence', $request, $callOptions)->wait(); + } } diff --git a/Iam/composer.json b/Iam/composer.json index 5586f2f0bc3c..982ae5a64edd 100644 --- a/Iam/composer.json +++ b/Iam/composer.json @@ -19,7 +19,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Iam/src/V2/Client/BaseClient/PoliciesBaseClient.php b/Iam/src/V2/Client/BaseClient/PoliciesBaseClient.php deleted file mode 100644 index 2ecb4e7e54c7..000000000000 --- a/Iam/src/V2/Client/BaseClient/PoliciesBaseClient.php +++ /dev/null @@ -1,351 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/policies_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/policies_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/policies_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/policies_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'iam.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a policy. - * - * The async variant is {@see self::createPolicyAsync()} . - * - * @example samples/V2/PoliciesClient/create_policy.php - * - * @param CreatePolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createPolicy(CreatePolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreatePolicy', $request, $callOptions)->wait(); - } - - /** - * Deletes a policy. This action is permanent. - * - * The async variant is {@see self::deletePolicyAsync()} . - * - * @example samples/V2/PoliciesClient/delete_policy.php - * - * @param DeletePolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deletePolicy(DeletePolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeletePolicy', $request, $callOptions)->wait(); - } - - /** - * Gets a policy. - * - * The async variant is {@see self::getPolicyAsync()} . - * - * @example samples/V2/PoliciesClient/get_policy.php - * - * @param GetPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getPolicy(GetPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetPolicy', $request, $callOptions)->wait(); - } - - /** - * Retrieves the policies of the specified kind that are attached to a - * resource. - * - * The response lists only policy metadata. In particular, policy rules are - * omitted. - * - * The async variant is {@see self::listPoliciesAsync()} . - * - * @example samples/V2/PoliciesClient/list_policies.php - * - * @param ListPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPolicies(ListPoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPolicies', $request, $callOptions); - } - - /** - * Updates the specified policy. - * - * You can update only the rules and the display name for the policy. - * - * To update a policy, you should use a read-modify-write loop: - * - * 1. Use [GetPolicy][google.iam.v2.Policies.GetPolicy] to read the current version of the policy. - * 2. Modify the policy as needed. - * 3. Use `UpdatePolicy` to write the updated policy. - * - * This pattern helps prevent conflicts between concurrent updates. - * - * The async variant is {@see self::updatePolicyAsync()} . - * - * @example samples/V2/PoliciesClient/update_policy.php - * - * @param UpdatePolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updatePolicy(UpdatePolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdatePolicy', $request, $callOptions)->wait(); - } -} diff --git a/Iam/src/V2/Client/PoliciesClient.php b/Iam/src/V2/Client/PoliciesClient.php index c32e6d26b538..5ac0de573324 100644 --- a/Iam/src/V2/Client/PoliciesClient.php +++ b/Iam/src/V2/Client/PoliciesClient.php @@ -24,17 +24,326 @@ namespace Google\Cloud\Iam\V2\Client; -use Google\Cloud\Iam\V2\Client\BaseClient\PoliciesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V2\CreatePolicyRequest; +use Google\Cloud\Iam\V2\DeletePolicyRequest; +use Google\Cloud\Iam\V2\GetPolicyRequest; +use Google\Cloud\Iam\V2\ListPoliciesRequest; +use Google\Cloud\Iam\V2\Policy; +use Google\Cloud\Iam\V2\UpdatePolicyRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: An interface for managing Identity and Access Management (IAM) policies. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Iam\V2\PoliciesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createPolicyAsync(CreatePolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deletePolicyAsync(DeletePolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getPolicyAsync(GetPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPoliciesAsync(ListPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updatePolicyAsync(UpdatePolicyRequest $request, array $optionalArgs = []) */ -final class PoliciesClient extends PoliciesBaseClient +final class PoliciesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see PoliciesBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.iam.v2.Policies'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'iam.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/policies_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/policies_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/policies_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/policies_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'iam.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a policy. + * + * The async variant is {@see PoliciesClient::createPolicyAsync()} . + * + * @example samples/V2/PoliciesClient/create_policy.php + * + * @param CreatePolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createPolicy(CreatePolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreatePolicy', $request, $callOptions)->wait(); + } + + /** + * Deletes a policy. This action is permanent. + * + * The async variant is {@see PoliciesClient::deletePolicyAsync()} . + * + * @example samples/V2/PoliciesClient/delete_policy.php + * + * @param DeletePolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deletePolicy(DeletePolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeletePolicy', $request, $callOptions)->wait(); + } + + /** + * Gets a policy. + * + * The async variant is {@see PoliciesClient::getPolicyAsync()} . + * + * @example samples/V2/PoliciesClient/get_policy.php + * + * @param GetPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getPolicy(GetPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetPolicy', $request, $callOptions)->wait(); + } + + /** + * Retrieves the policies of the specified kind that are attached to a + * resource. + * + * The response lists only policy metadata. In particular, policy rules are + * omitted. + * + * The async variant is {@see PoliciesClient::listPoliciesAsync()} . + * + * @example samples/V2/PoliciesClient/list_policies.php + * + * @param ListPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPolicies(ListPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPolicies', $request, $callOptions); + } + + /** + * Updates the specified policy. + * + * You can update only the rules and the display name for the policy. + * + * To update a policy, you should use a read-modify-write loop: + * + * 1. Use [GetPolicy][google.iam.v2.Policies.GetPolicy] to read the current version of the policy. + * 2. Modify the policy as needed. + * 3. Use `UpdatePolicy` to write the updated policy. + * + * This pattern helps prevent conflicts between concurrent updates. + * + * The async variant is {@see PoliciesClient::updatePolicyAsync()} . + * + * @example samples/V2/PoliciesClient/update_policy.php + * + * @param UpdatePolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updatePolicy(UpdatePolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdatePolicy', $request, $callOptions)->wait(); + } } diff --git a/IamCredentials/composer.json b/IamCredentials/composer.json index 8dae468495db..9ddb4be33efc 100644 --- a/IamCredentials/composer.json +++ b/IamCredentials/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.20" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/IamCredentials/src/V1/Client/BaseClient/IAMCredentialsBaseClient.php b/IamCredentials/src/V1/Client/BaseClient/IAMCredentialsBaseClient.php deleted file mode 100644 index bdc2e71f43dd..000000000000 --- a/IamCredentials/src/V1/Client/BaseClient/IAMCredentialsBaseClient.php +++ /dev/null @@ -1,325 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/iam_credentials_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/iam_credentials_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/iam_credentials_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/iam_credentials_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * service_account resource. - * - * @param string $project - * @param string $serviceAccount - * - * @return string The formatted service_account resource. - */ - public static function serviceAccountName(string $project, string $serviceAccount): string - { - return self::getPathTemplate('serviceAccount')->render([ - 'project' => $project, - 'service_account' => $serviceAccount, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - serviceAccount: projects/{project}/serviceAccounts/{service_account} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'iamcredentials.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Generates an OAuth 2.0 access token for a service account. - * - * The async variant is {@see self::generateAccessTokenAsync()} . - * - * @param GenerateAccessTokenRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GenerateAccessTokenResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function generateAccessToken(GenerateAccessTokenRequest $request, array $callOptions = []): GenerateAccessTokenResponse - { - return $this->startApiCall('GenerateAccessToken', $request, $callOptions)->wait(); - } - - /** - * Generates an OpenID Connect ID token for a service account. - * - * The async variant is {@see self::generateIdTokenAsync()} . - * - * @param GenerateIdTokenRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GenerateIdTokenResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function generateIdToken(GenerateIdTokenRequest $request, array $callOptions = []): GenerateIdTokenResponse - { - return $this->startApiCall('GenerateIdToken', $request, $callOptions)->wait(); - } - - /** - * Signs a blob using a service account's system-managed private key. - * - * The async variant is {@see self::signBlobAsync()} . - * - * @param SignBlobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SignBlobResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function signBlob(SignBlobRequest $request, array $callOptions = []): SignBlobResponse - { - return $this->startApiCall('SignBlob', $request, $callOptions)->wait(); - } - - /** - * Signs a JWT using a service account's system-managed private key. - * - * The async variant is {@see self::signJwtAsync()} . - * - * @param SignJwtRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SignJwtResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function signJwt(SignJwtRequest $request, array $callOptions = []): SignJwtResponse - { - return $this->startApiCall('SignJwt', $request, $callOptions)->wait(); - } -} diff --git a/IamCredentials/src/V1/Client/IAMCredentialsClient.php b/IamCredentials/src/V1/Client/IAMCredentialsClient.php index 1900700eb871..1d76292973e2 100644 --- a/IamCredentials/src/V1/Client/IAMCredentialsClient.php +++ b/IamCredentials/src/V1/Client/IAMCredentialsClient.php @@ -24,17 +24,300 @@ namespace Google\Cloud\Iam\Credentials\V1\Client; -use Google\Cloud\Iam\Credentials\V1\Client\BaseClient\IAMCredentialsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\Credentials\V1\GenerateAccessTokenRequest; +use Google\Cloud\Iam\Credentials\V1\GenerateAccessTokenResponse; +use Google\Cloud\Iam\Credentials\V1\GenerateIdTokenRequest; +use Google\Cloud\Iam\Credentials\V1\GenerateIdTokenResponse; +use Google\Cloud\Iam\Credentials\V1\SignBlobRequest; +use Google\Cloud\Iam\Credentials\V1\SignBlobResponse; +use Google\Cloud\Iam\Credentials\V1\SignJwtRequest; +use Google\Cloud\Iam\Credentials\V1\SignJwtResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service account is a special type of Google account that belongs to your + * application or a virtual machine (VM), instead of to an individual end user. + * Your application assumes the identity of the service account to call Google + * APIs, so that the users aren't directly involved. * - * This class is currently experimental and may be subject to changes. + * Service account credentials are used to temporarily assume the identity + * of the service account. Supported credential types include OAuth 2.0 access + * tokens, OpenID Connect ID tokens, self-signed JSON Web Tokens (JWTs), and + * more. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Iam\Credentials\V1\IAMCredentialsClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface generateAccessTokenAsync(GenerateAccessTokenRequest $request, array $optionalArgs = []) + * @method PromiseInterface generateIdTokenAsync(GenerateIdTokenRequest $request, array $optionalArgs = []) + * @method PromiseInterface signBlobAsync(SignBlobRequest $request, array $optionalArgs = []) + * @method PromiseInterface signJwtAsync(SignJwtRequest $request, array $optionalArgs = []) */ -final class IAMCredentialsClient extends IAMCredentialsBaseClient +final class IAMCredentialsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see IAMCredentialsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.iam.credentials.v1.IAMCredentials'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'iamcredentials.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/iam_credentials_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/iam_credentials_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/iam_credentials_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/iam_credentials_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * service_account resource. + * + * @param string $project + * @param string $serviceAccount + * + * @return string The formatted service_account resource. + */ + public static function serviceAccountName(string $project, string $serviceAccount): string + { + return self::getPathTemplate('serviceAccount')->render([ + 'project' => $project, + 'service_account' => $serviceAccount, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - serviceAccount: projects/{project}/serviceAccounts/{service_account} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'iamcredentials.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Generates an OAuth 2.0 access token for a service account. + * + * The async variant is {@see IAMCredentialsClient::generateAccessTokenAsync()} . + * + * @param GenerateAccessTokenRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GenerateAccessTokenResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function generateAccessToken(GenerateAccessTokenRequest $request, array $callOptions = []): GenerateAccessTokenResponse + { + return $this->startApiCall('GenerateAccessToken', $request, $callOptions)->wait(); + } + + /** + * Generates an OpenID Connect ID token for a service account. + * + * The async variant is {@see IAMCredentialsClient::generateIdTokenAsync()} . + * + * @param GenerateIdTokenRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GenerateIdTokenResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function generateIdToken(GenerateIdTokenRequest $request, array $callOptions = []): GenerateIdTokenResponse + { + return $this->startApiCall('GenerateIdToken', $request, $callOptions)->wait(); + } + + /** + * Signs a blob using a service account's system-managed private key. + * + * The async variant is {@see IAMCredentialsClient::signBlobAsync()} . + * + * @param SignBlobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SignBlobResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function signBlob(SignBlobRequest $request, array $callOptions = []): SignBlobResponse + { + return $this->startApiCall('SignBlob', $request, $callOptions)->wait(); + } + + /** + * Signs a JWT using a service account's system-managed private key. + * + * The async variant is {@see IAMCredentialsClient::signJwtAsync()} . + * + * @param SignJwtRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SignJwtResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function signJwt(SignJwtRequest $request, array $callOptions = []): SignJwtResponse + { + return $this->startApiCall('SignJwt', $request, $callOptions)->wait(); + } } diff --git a/Iap/composer.json b/Iap/composer.json index dcc9a186706c..66a07aadf1a3 100644 --- a/Iap/composer.json +++ b/Iap/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Iap/src/V1/Client/BaseClient/IdentityAwareProxyAdminServiceBaseClient.php b/Iap/src/V1/Client/BaseClient/IdentityAwareProxyAdminServiceBaseClient.php deleted file mode 100644 index 84a4543a65c0..000000000000 --- a/Iap/src/V1/Client/BaseClient/IdentityAwareProxyAdminServiceBaseClient.php +++ /dev/null @@ -1,504 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/identity_aware_proxy_admin_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/identity_aware_proxy_admin_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/identity_aware_proxy_admin_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/identity_aware_proxy_admin_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * tunnel_dest_group resource. - * - * @param string $project - * @param string $location - * @param string $destGroup - * - * @return string The formatted tunnel_dest_group resource. - */ - public static function tunnelDestGroupName(string $project, string $location, string $destGroup): string - { - return self::getPathTemplate('tunnelDestGroup')->render([ - 'project' => $project, - 'location' => $location, - 'dest_group' => $destGroup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * tunnel_location resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted tunnel_location resource. - */ - public static function tunnelLocationName(string $project, string $location): string - { - return self::getPathTemplate('tunnelLocation')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - tunnelDestGroup: projects/{project}/iap_tunnel/locations/{location}/destGroups/{dest_group} - * - tunnelLocation: projects/{project}/iap_tunnel/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'iap.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new TunnelDestGroup. - * - * The async variant is {@see self::createTunnelDestGroupAsync()} . - * - * @param CreateTunnelDestGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TunnelDestGroup - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTunnelDestGroup(CreateTunnelDestGroupRequest $request, array $callOptions = []): TunnelDestGroup - { - return $this->startApiCall('CreateTunnelDestGroup', $request, $callOptions)->wait(); - } - - /** - * Deletes a TunnelDestGroup. - * - * The async variant is {@see self::deleteTunnelDestGroupAsync()} . - * - * @param DeleteTunnelDestGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTunnelDestGroup(DeleteTunnelDestGroupRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteTunnelDestGroup', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for an Identity-Aware Proxy protected - * resource. - * More information about managing access via IAP can be found at: - * https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets the IAP settings on a particular IAP protected resource. - * - * The async variant is {@see self::getIapSettingsAsync()} . - * - * @param GetIapSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 IapSettings - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIapSettings(GetIapSettingsRequest $request, array $callOptions = []): IapSettings - { - return $this->startApiCall('GetIapSettings', $request, $callOptions)->wait(); - } - - /** - * Retrieves an existing TunnelDestGroup. - * - * The async variant is {@see self::getTunnelDestGroupAsync()} . - * - * @param GetTunnelDestGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TunnelDestGroup - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTunnelDestGroup(GetTunnelDestGroupRequest $request, array $callOptions = []): TunnelDestGroup - { - return $this->startApiCall('GetTunnelDestGroup', $request, $callOptions)->wait(); - } - - /** - * Lists the existing TunnelDestGroups. To group across all locations, use a - * `-` as the location ID. For example: - * `/v1/projects/123/iap_tunnel/locations/-/destGroups` - * - * The async variant is {@see self::listTunnelDestGroupsAsync()} . - * - * @param ListTunnelDestGroupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTunnelDestGroups(ListTunnelDestGroupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTunnelDestGroups', $request, $callOptions); - } - - /** - * Sets the access control policy for an Identity-Aware Proxy protected - * resource. Replaces any existing policy. - * More information about managing access via IAP can be found at: - * https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the Identity-Aware Proxy protected - * resource. - * More information about managing access via IAP can be found at: - * https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Updates the IAP settings on a particular IAP protected resource. It - * replaces all fields unless the `update_mask` is set. - * - * The async variant is {@see self::updateIapSettingsAsync()} . - * - * @param UpdateIapSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 IapSettings - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateIapSettings(UpdateIapSettingsRequest $request, array $callOptions = []): IapSettings - { - return $this->startApiCall('UpdateIapSettings', $request, $callOptions)->wait(); - } - - /** - * Updates a TunnelDestGroup. - * - * The async variant is {@see self::updateTunnelDestGroupAsync()} . - * - * @param UpdateTunnelDestGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TunnelDestGroup - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateTunnelDestGroup(UpdateTunnelDestGroupRequest $request, array $callOptions = []): TunnelDestGroup - { - return $this->startApiCall('UpdateTunnelDestGroup', $request, $callOptions)->wait(); - } -} diff --git a/Iap/src/V1/Client/BaseClient/IdentityAwareProxyOAuthServiceBaseClient.php b/Iap/src/V1/Client/BaseClient/IdentityAwareProxyOAuthServiceBaseClient.php deleted file mode 100644 index 182117b24767..000000000000 --- a/Iap/src/V1/Client/BaseClient/IdentityAwareProxyOAuthServiceBaseClient.php +++ /dev/null @@ -1,386 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/identity_aware_proxy_o_auth_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/identity_aware_proxy_o_auth_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/identity_aware_proxy_o_auth_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/identity_aware_proxy_o_auth_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'iap.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Constructs a new OAuth brand for the project if one does not exist. - * The created brand is "internal only", meaning that OAuth clients created - * under it only accept requests from users who belong to the same Google - * Workspace organization as the project. The brand is created in an - * un-reviewed status. NOTE: The "internal only" status can be manually - * changed in the Google Cloud Console. Requires that a brand does not already - * exist for the project, and that the specified support email is owned by the - * caller. - * - * The async variant is {@see self::createBrandAsync()} . - * - * @param CreateBrandRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Brand - * - * @throws ApiException Thrown if the API call fails. - */ - public function createBrand(CreateBrandRequest $request, array $callOptions = []): Brand - { - return $this->startApiCall('CreateBrand', $request, $callOptions)->wait(); - } - - /** - * Creates an Identity Aware Proxy (IAP) OAuth client. The client is owned - * by IAP. Requires that the brand for the project exists and that it is - * set for internal-only use. - * - * The async variant is {@see self::createIdentityAwareProxyClientAsync()} . - * - * @param CreateIdentityAwareProxyClientRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 IdentityAwareProxyClient - * - * @throws ApiException Thrown if the API call fails. - */ - public function createIdentityAwareProxyClient(CreateIdentityAwareProxyClientRequest $request, array $callOptions = []): IdentityAwareProxyClient - { - return $this->startApiCall('CreateIdentityAwareProxyClient', $request, $callOptions)->wait(); - } - - /** - * Deletes an Identity Aware Proxy (IAP) OAuth client. Useful for removing - * obsolete clients, managing the number of clients in a given project, and - * cleaning up after tests. Requires that the client is owned by IAP. - * - * The async variant is {@see self::deleteIdentityAwareProxyClientAsync()} . - * - * @param DeleteIdentityAwareProxyClientRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteIdentityAwareProxyClient(DeleteIdentityAwareProxyClientRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteIdentityAwareProxyClient', $request, $callOptions)->wait(); - } - - /** - * Retrieves the OAuth brand of the project. - * - * The async variant is {@see self::getBrandAsync()} . - * - * @param GetBrandRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Brand - * - * @throws ApiException Thrown if the API call fails. - */ - public function getBrand(GetBrandRequest $request, array $callOptions = []): Brand - { - return $this->startApiCall('GetBrand', $request, $callOptions)->wait(); - } - - /** - * Retrieves an Identity Aware Proxy (IAP) OAuth client. - * Requires that the client is owned by IAP. - * - * The async variant is {@see self::getIdentityAwareProxyClientAsync()} . - * - * @param GetIdentityAwareProxyClientRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 IdentityAwareProxyClient - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIdentityAwareProxyClient(GetIdentityAwareProxyClientRequest $request, array $callOptions = []): IdentityAwareProxyClient - { - return $this->startApiCall('GetIdentityAwareProxyClient', $request, $callOptions)->wait(); - } - - /** - * Lists the existing brands for the project. - * - * The async variant is {@see self::listBrandsAsync()} . - * - * @param ListBrandsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ListBrandsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listBrands(ListBrandsRequest $request, array $callOptions = []): ListBrandsResponse - { - return $this->startApiCall('ListBrands', $request, $callOptions)->wait(); - } - - /** - * Lists the existing clients for the brand. - * - * The async variant is {@see self::listIdentityAwareProxyClientsAsync()} . - * - * @param ListIdentityAwareProxyClientsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listIdentityAwareProxyClients(ListIdentityAwareProxyClientsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListIdentityAwareProxyClients', $request, $callOptions); - } - - /** - * Resets an Identity Aware Proxy (IAP) OAuth client secret. Useful if the - * secret was compromised. Requires that the client is owned by IAP. - * - * The async variant is {@see self::resetIdentityAwareProxyClientSecretAsync()} . - * - * @param ResetIdentityAwareProxyClientSecretRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 IdentityAwareProxyClient - * - * @throws ApiException Thrown if the API call fails. - */ - public function resetIdentityAwareProxyClientSecret(ResetIdentityAwareProxyClientSecretRequest $request, array $callOptions = []): IdentityAwareProxyClient - { - return $this->startApiCall('ResetIdentityAwareProxyClientSecret', $request, $callOptions)->wait(); - } -} diff --git a/Iap/src/V1/Client/IdentityAwareProxyAdminServiceClient.php b/Iap/src/V1/Client/IdentityAwareProxyAdminServiceClient.php index c6a130675b7c..df67cc621138 100644 --- a/Iap/src/V1/Client/IdentityAwareProxyAdminServiceClient.php +++ b/Iap/src/V1/Client/IdentityAwareProxyAdminServiceClient.php @@ -24,17 +24,489 @@ namespace Google\Cloud\Iap\V1\Client; -use Google\Cloud\Iap\V1\Client\BaseClient\IdentityAwareProxyAdminServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Iap\V1\CreateTunnelDestGroupRequest; +use Google\Cloud\Iap\V1\DeleteTunnelDestGroupRequest; +use Google\Cloud\Iap\V1\GetIapSettingsRequest; +use Google\Cloud\Iap\V1\GetTunnelDestGroupRequest; +use Google\Cloud\Iap\V1\IapSettings; +use Google\Cloud\Iap\V1\ListTunnelDestGroupsRequest; +use Google\Cloud\Iap\V1\TunnelDestGroup; +use Google\Cloud\Iap\V1\UpdateIapSettingsRequest; +use Google\Cloud\Iap\V1\UpdateTunnelDestGroupRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: APIs for Identity-Aware Proxy Admin configurations. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Iap\V1\IdentityAwareProxyAdminServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createTunnelDestGroupAsync(CreateTunnelDestGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTunnelDestGroupAsync(DeleteTunnelDestGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIapSettingsAsync(GetIapSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTunnelDestGroupAsync(GetTunnelDestGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTunnelDestGroupsAsync(ListTunnelDestGroupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateIapSettingsAsync(UpdateIapSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateTunnelDestGroupAsync(UpdateTunnelDestGroupRequest $request, array $optionalArgs = []) */ -final class IdentityAwareProxyAdminServiceClient extends IdentityAwareProxyAdminServiceBaseClient +final class IdentityAwareProxyAdminServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see IdentityAwareProxyAdminServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.iap.v1.IdentityAwareProxyAdminService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'iap.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/identity_aware_proxy_admin_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/identity_aware_proxy_admin_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/identity_aware_proxy_admin_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/identity_aware_proxy_admin_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * tunnel_dest_group resource. + * + * @param string $project + * @param string $location + * @param string $destGroup + * + * @return string The formatted tunnel_dest_group resource. + */ + public static function tunnelDestGroupName(string $project, string $location, string $destGroup): string + { + return self::getPathTemplate('tunnelDestGroup')->render([ + 'project' => $project, + 'location' => $location, + 'dest_group' => $destGroup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * tunnel_location resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted tunnel_location resource. + */ + public static function tunnelLocationName(string $project, string $location): string + { + return self::getPathTemplate('tunnelLocation')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - tunnelDestGroup: projects/{project}/iap_tunnel/locations/{location}/destGroups/{dest_group} + * - tunnelLocation: projects/{project}/iap_tunnel/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'iap.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new TunnelDestGroup. + * + * The async variant is + * {@see IdentityAwareProxyAdminServiceClient::createTunnelDestGroupAsync()} . + * + * @param CreateTunnelDestGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TunnelDestGroup + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTunnelDestGroup(CreateTunnelDestGroupRequest $request, array $callOptions = []): TunnelDestGroup + { + return $this->startApiCall('CreateTunnelDestGroup', $request, $callOptions)->wait(); + } + + /** + * Deletes a TunnelDestGroup. + * + * The async variant is + * {@see IdentityAwareProxyAdminServiceClient::deleteTunnelDestGroupAsync()} . + * + * @param DeleteTunnelDestGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTunnelDestGroup(DeleteTunnelDestGroupRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteTunnelDestGroup', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for an Identity-Aware Proxy protected + * resource. + * More information about managing access via IAP can be found at: + * https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api + * + * The async variant is + * {@see IdentityAwareProxyAdminServiceClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets the IAP settings on a particular IAP protected resource. + * + * The async variant is + * {@see IdentityAwareProxyAdminServiceClient::getIapSettingsAsync()} . + * + * @param GetIapSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 IapSettings + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIapSettings(GetIapSettingsRequest $request, array $callOptions = []): IapSettings + { + return $this->startApiCall('GetIapSettings', $request, $callOptions)->wait(); + } + + /** + * Retrieves an existing TunnelDestGroup. + * + * The async variant is + * {@see IdentityAwareProxyAdminServiceClient::getTunnelDestGroupAsync()} . + * + * @param GetTunnelDestGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TunnelDestGroup + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTunnelDestGroup(GetTunnelDestGroupRequest $request, array $callOptions = []): TunnelDestGroup + { + return $this->startApiCall('GetTunnelDestGroup', $request, $callOptions)->wait(); + } + + /** + * Lists the existing TunnelDestGroups. To group across all locations, use a + * `-` as the location ID. For example: + * `/v1/projects/123/iap_tunnel/locations/-/destGroups` + * + * The async variant is + * {@see IdentityAwareProxyAdminServiceClient::listTunnelDestGroupsAsync()} . + * + * @param ListTunnelDestGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTunnelDestGroups(ListTunnelDestGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTunnelDestGroups', $request, $callOptions); + } + + /** + * Sets the access control policy for an Identity-Aware Proxy protected + * resource. Replaces any existing policy. + * More information about managing access via IAP can be found at: + * https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api + * + * The async variant is + * {@see IdentityAwareProxyAdminServiceClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the Identity-Aware Proxy protected + * resource. + * More information about managing access via IAP can be found at: + * https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api + * + * The async variant is + * {@see IdentityAwareProxyAdminServiceClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates the IAP settings on a particular IAP protected resource. It + * replaces all fields unless the `update_mask` is set. + * + * The async variant is + * {@see IdentityAwareProxyAdminServiceClient::updateIapSettingsAsync()} . + * + * @param UpdateIapSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 IapSettings + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateIapSettings(UpdateIapSettingsRequest $request, array $callOptions = []): IapSettings + { + return $this->startApiCall('UpdateIapSettings', $request, $callOptions)->wait(); + } + + /** + * Updates a TunnelDestGroup. + * + * The async variant is + * {@see IdentityAwareProxyAdminServiceClient::updateTunnelDestGroupAsync()} . + * + * @param UpdateTunnelDestGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TunnelDestGroup + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTunnelDestGroup(UpdateTunnelDestGroupRequest $request, array $callOptions = []): TunnelDestGroup + { + return $this->startApiCall('UpdateTunnelDestGroup', $request, $callOptions)->wait(); + } } diff --git a/Iap/src/V1/Client/IdentityAwareProxyOAuthServiceClient.php b/Iap/src/V1/Client/IdentityAwareProxyOAuthServiceClient.php index d87a52395e4d..dfa5c8e79af4 100644 --- a/Iap/src/V1/Client/IdentityAwareProxyOAuthServiceClient.php +++ b/Iap/src/V1/Client/IdentityAwareProxyOAuthServiceClient.php @@ -24,17 +24,374 @@ namespace Google\Cloud\Iap\V1\Client; -use Google\Cloud\Iap\V1\Client\BaseClient\IdentityAwareProxyOAuthServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iap\V1\Brand; +use Google\Cloud\Iap\V1\CreateBrandRequest; +use Google\Cloud\Iap\V1\CreateIdentityAwareProxyClientRequest; +use Google\Cloud\Iap\V1\DeleteIdentityAwareProxyClientRequest; +use Google\Cloud\Iap\V1\GetBrandRequest; +use Google\Cloud\Iap\V1\GetIdentityAwareProxyClientRequest; +use Google\Cloud\Iap\V1\IdentityAwareProxyClient; +use Google\Cloud\Iap\V1\ListBrandsRequest; +use Google\Cloud\Iap\V1\ListBrandsResponse; +use Google\Cloud\Iap\V1\ListIdentityAwareProxyClientsRequest; +use Google\Cloud\Iap\V1\ResetIdentityAwareProxyClientSecretRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: API to programmatically create, list and retrieve Identity Aware Proxy (IAP) + * OAuth brands; and create, retrieve, delete and reset-secret of IAP OAuth + * clients. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Iap\V1\IdentityAwareProxyOAuthServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createBrandAsync(CreateBrandRequest $request, array $optionalArgs = []) + * @method PromiseInterface createIdentityAwareProxyClientAsync(CreateIdentityAwareProxyClientRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteIdentityAwareProxyClientAsync(DeleteIdentityAwareProxyClientRequest $request, array $optionalArgs = []) + * @method PromiseInterface getBrandAsync(GetBrandRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIdentityAwareProxyClientAsync(GetIdentityAwareProxyClientRequest $request, array $optionalArgs = []) + * @method PromiseInterface listBrandsAsync(ListBrandsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listIdentityAwareProxyClientsAsync(ListIdentityAwareProxyClientsRequest $request, array $optionalArgs = []) + * @method PromiseInterface resetIdentityAwareProxyClientSecretAsync(ResetIdentityAwareProxyClientSecretRequest $request, array $optionalArgs = []) */ -final class IdentityAwareProxyOAuthServiceClient extends IdentityAwareProxyOAuthServiceBaseClient +final class IdentityAwareProxyOAuthServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see IdentityAwareProxyOAuthServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.iap.v1.IdentityAwareProxyOAuthService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'iap.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/identity_aware_proxy_o_auth_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/identity_aware_proxy_o_auth_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/identity_aware_proxy_o_auth_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/identity_aware_proxy_o_auth_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'iap.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Constructs a new OAuth brand for the project if one does not exist. + * The created brand is "internal only", meaning that OAuth clients created + * under it only accept requests from users who belong to the same Google + * Workspace organization as the project. The brand is created in an + * un-reviewed status. NOTE: The "internal only" status can be manually + * changed in the Google Cloud Console. Requires that a brand does not already + * exist for the project, and that the specified support email is owned by the + * caller. + * + * The async variant is + * {@see IdentityAwareProxyOAuthServiceClient::createBrandAsync()} . + * + * @param CreateBrandRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Brand + * + * @throws ApiException Thrown if the API call fails. + */ + public function createBrand(CreateBrandRequest $request, array $callOptions = []): Brand + { + return $this->startApiCall('CreateBrand', $request, $callOptions)->wait(); + } + + /** + * Creates an Identity Aware Proxy (IAP) OAuth client. The client is owned + * by IAP. Requires that the brand for the project exists and that it is + * set for internal-only use. + * + * The async variant is + * {@see IdentityAwareProxyOAuthServiceClient::createIdentityAwareProxyClientAsync()} + * . + * + * @param CreateIdentityAwareProxyClientRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 IdentityAwareProxyClient + * + * @throws ApiException Thrown if the API call fails. + */ + public function createIdentityAwareProxyClient(CreateIdentityAwareProxyClientRequest $request, array $callOptions = []): IdentityAwareProxyClient + { + return $this->startApiCall('CreateIdentityAwareProxyClient', $request, $callOptions)->wait(); + } + + /** + * Deletes an Identity Aware Proxy (IAP) OAuth client. Useful for removing + * obsolete clients, managing the number of clients in a given project, and + * cleaning up after tests. Requires that the client is owned by IAP. + * + * The async variant is + * {@see IdentityAwareProxyOAuthServiceClient::deleteIdentityAwareProxyClientAsync()} + * . + * + * @param DeleteIdentityAwareProxyClientRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteIdentityAwareProxyClient(DeleteIdentityAwareProxyClientRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteIdentityAwareProxyClient', $request, $callOptions)->wait(); + } + + /** + * Retrieves the OAuth brand of the project. + * + * The async variant is + * {@see IdentityAwareProxyOAuthServiceClient::getBrandAsync()} . + * + * @param GetBrandRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Brand + * + * @throws ApiException Thrown if the API call fails. + */ + public function getBrand(GetBrandRequest $request, array $callOptions = []): Brand + { + return $this->startApiCall('GetBrand', $request, $callOptions)->wait(); + } + + /** + * Retrieves an Identity Aware Proxy (IAP) OAuth client. + * Requires that the client is owned by IAP. + * + * The async variant is + * {@see IdentityAwareProxyOAuthServiceClient::getIdentityAwareProxyClientAsync()} + * . + * + * @param GetIdentityAwareProxyClientRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 IdentityAwareProxyClient + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIdentityAwareProxyClient(GetIdentityAwareProxyClientRequest $request, array $callOptions = []): IdentityAwareProxyClient + { + return $this->startApiCall('GetIdentityAwareProxyClient', $request, $callOptions)->wait(); + } + + /** + * Lists the existing brands for the project. + * + * The async variant is + * {@see IdentityAwareProxyOAuthServiceClient::listBrandsAsync()} . + * + * @param ListBrandsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ListBrandsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listBrands(ListBrandsRequest $request, array $callOptions = []): ListBrandsResponse + { + return $this->startApiCall('ListBrands', $request, $callOptions)->wait(); + } + + /** + * Lists the existing clients for the brand. + * + * The async variant is + * {@see IdentityAwareProxyOAuthServiceClient::listIdentityAwareProxyClientsAsync()} + * . + * + * @param ListIdentityAwareProxyClientsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listIdentityAwareProxyClients(ListIdentityAwareProxyClientsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListIdentityAwareProxyClients', $request, $callOptions); + } + + /** + * Resets an Identity Aware Proxy (IAP) OAuth client secret. Useful if the + * secret was compromised. Requires that the client is owned by IAP. + * + * The async variant is + * {@see IdentityAwareProxyOAuthServiceClient::resetIdentityAwareProxyClientSecretAsync()} + * . + * + * @param ResetIdentityAwareProxyClientSecretRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 IdentityAwareProxyClient + * + * @throws ApiException Thrown if the API call fails. + */ + public function resetIdentityAwareProxyClientSecret(ResetIdentityAwareProxyClientSecretRequest $request, array $callOptions = []): IdentityAwareProxyClient + { + return $this->startApiCall('ResetIdentityAwareProxyClientSecret', $request, $callOptions)->wait(); + } } diff --git a/Ids/composer.json b/Ids/composer.json index cd11f7ce1dcb..ff4bc3f61c07 100644 --- a/Ids/composer.json +++ b/Ids/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Ids/src/V1/Client/BaseClient/IDSBaseClient.php b/Ids/src/V1/Client/BaseClient/IDSBaseClient.php deleted file mode 100644 index 6d785be22991..000000000000 --- a/Ids/src/V1/Client/BaseClient/IDSBaseClient.php +++ /dev/null @@ -1,377 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/ids_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/ids_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/ids_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/ids_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a endpoint - * resource. - * - * @param string $project - * @param string $location - * @param string $endpoint - * - * @return string The formatted endpoint resource. - */ - public static function endpointName(string $project, string $location, string $endpoint): string - { - return self::getPathTemplate('endpoint')->render([ - 'project' => $project, - 'location' => $location, - 'endpoint' => $endpoint, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - endpoint: projects/{project}/locations/{location}/endpoints/{endpoint} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'ids.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new Endpoint in a given project and location. - * - * The async variant is {@see self::createEndpointAsync()} . - * - * @example samples/V1/IDSClient/create_endpoint.php - * - * @param CreateEndpointRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createEndpoint(CreateEndpointRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateEndpoint', $request, $callOptions)->wait(); - } - - /** - * Deletes a single Endpoint. - * - * The async variant is {@see self::deleteEndpointAsync()} . - * - * @example samples/V1/IDSClient/delete_endpoint.php - * - * @param DeleteEndpointRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteEndpoint(DeleteEndpointRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteEndpoint', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single Endpoint. - * - * The async variant is {@see self::getEndpointAsync()} . - * - * @example samples/V1/IDSClient/get_endpoint.php - * - * @param GetEndpointRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Endpoint - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEndpoint(GetEndpointRequest $request, array $callOptions = []): Endpoint - { - return $this->startApiCall('GetEndpoint', $request, $callOptions)->wait(); - } - - /** - * Lists Endpoints in a given project and location. - * - * The async variant is {@see self::listEndpointsAsync()} . - * - * @example samples/V1/IDSClient/list_endpoints.php - * - * @param ListEndpointsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listEndpoints(ListEndpointsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListEndpoints', $request, $callOptions); - } -} diff --git a/Ids/src/V1/Client/IDSClient.php b/Ids/src/V1/Client/IDSClient.php index 3d4df2debdaf..9611bf81e480 100644 --- a/Ids/src/V1/Client/IDSClient.php +++ b/Ids/src/V1/Client/IDSClient.php @@ -24,17 +24,352 @@ namespace Google\Cloud\Ids\V1\Client; -use Google\Cloud\Ids\V1\Client\BaseClient\IDSBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Ids\V1\CreateEndpointRequest; +use Google\Cloud\Ids\V1\DeleteEndpointRequest; +use Google\Cloud\Ids\V1\Endpoint; +use Google\Cloud\Ids\V1\GetEndpointRequest; +use Google\Cloud\Ids\V1\ListEndpointsRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The IDS Service * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Ids\V1\IDSClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createEndpointAsync(CreateEndpointRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteEndpointAsync(DeleteEndpointRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEndpointAsync(GetEndpointRequest $request, array $optionalArgs = []) + * @method PromiseInterface listEndpointsAsync(ListEndpointsRequest $request, array $optionalArgs = []) */ -final class IDSClient extends IDSBaseClient +final class IDSClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see IDSBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.ids.v1.IDS'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'ids.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/ids_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/ids_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/ids_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/ids_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a endpoint + * resource. + * + * @param string $project + * @param string $location + * @param string $endpoint + * + * @return string The formatted endpoint resource. + */ + public static function endpointName(string $project, string $location, string $endpoint): string + { + return self::getPathTemplate('endpoint')->render([ + 'project' => $project, + 'location' => $location, + 'endpoint' => $endpoint, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - endpoint: projects/{project}/locations/{location}/endpoints/{endpoint} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'ids.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new Endpoint in a given project and location. + * + * The async variant is {@see IDSClient::createEndpointAsync()} . + * + * @example samples/V1/IDSClient/create_endpoint.php + * + * @param CreateEndpointRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createEndpoint(CreateEndpointRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateEndpoint', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Endpoint. + * + * The async variant is {@see IDSClient::deleteEndpointAsync()} . + * + * @example samples/V1/IDSClient/delete_endpoint.php + * + * @param DeleteEndpointRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteEndpoint(DeleteEndpointRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteEndpoint', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Endpoint. + * + * The async variant is {@see IDSClient::getEndpointAsync()} . + * + * @example samples/V1/IDSClient/get_endpoint.php + * + * @param GetEndpointRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Endpoint + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEndpoint(GetEndpointRequest $request, array $callOptions = []): Endpoint + { + return $this->startApiCall('GetEndpoint', $request, $callOptions)->wait(); + } + + /** + * Lists Endpoints in a given project and location. + * + * The async variant is {@see IDSClient::listEndpointsAsync()} . + * + * @example samples/V1/IDSClient/list_endpoints.php + * + * @param ListEndpointsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listEndpoints(ListEndpointsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEndpoints', $request, $callOptions); + } } diff --git a/Iot/composer.json b/Iot/composer.json index c10339f92c33..60878246520e 100644 --- a/Iot/composer.json +++ b/Iot/composer.json @@ -19,11 +19,11 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", - "google/cloud-core": "^1.39" + "google/cloud-core": "^1.52.7" }, "suggest": { "ext-protobuf": "Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions." diff --git a/Iot/src/V1/Client/BaseClient/DeviceManagerBaseClient.php b/Iot/src/V1/Client/BaseClient/DeviceManagerBaseClient.php deleted file mode 100644 index ffd5937f29e9..000000000000 --- a/Iot/src/V1/Client/BaseClient/DeviceManagerBaseClient.php +++ /dev/null @@ -1,773 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/device_manager_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/device_manager_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/device_manager_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/device_manager_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a device - * resource. - * - * @param string $project - * @param string $location - * @param string $registry - * @param string $device - * - * @return string The formatted device resource. - */ - public static function deviceName(string $project, string $location, string $registry, string $device): string - { - return self::getPathTemplate('device')->render([ - 'project' => $project, - 'location' => $location, - 'registry' => $registry, - 'device' => $device, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a registry - * resource. - * - * @param string $project - * @param string $location - * @param string $registry - * - * @return string The formatted registry resource. - */ - public static function registryName(string $project, string $location, string $registry): string - { - return self::getPathTemplate('registry')->render([ - 'project' => $project, - 'location' => $location, - 'registry' => $registry, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - device: projects/{project}/locations/{location}/registries/{registry}/devices/{device} - * - location: projects/{project}/locations/{location} - * - registry: projects/{project}/locations/{location}/registries/{registry} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudiot.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Associates the device with the gateway. - * - * The async variant is {@see self::bindDeviceToGatewayAsync()} . - * - * @param BindDeviceToGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BindDeviceToGatewayResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function bindDeviceToGateway(BindDeviceToGatewayRequest $request, array $callOptions = []): BindDeviceToGatewayResponse - { - return $this->startApiCall('BindDeviceToGateway', $request, $callOptions)->wait(); - } - - /** - * Creates a device in a device registry. - * - * The async variant is {@see self::createDeviceAsync()} . - * - * @param CreateDeviceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Device - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDevice(CreateDeviceRequest $request, array $callOptions = []): Device - { - return $this->startApiCall('CreateDevice', $request, $callOptions)->wait(); - } - - /** - * Creates a device registry that contains devices. - * - * The async variant is {@see self::createDeviceRegistryAsync()} . - * - * @param CreateDeviceRegistryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DeviceRegistry - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDeviceRegistry(CreateDeviceRegistryRequest $request, array $callOptions = []): DeviceRegistry - { - return $this->startApiCall('CreateDeviceRegistry', $request, $callOptions)->wait(); - } - - /** - * Deletes a device. - * - * The async variant is {@see self::deleteDeviceAsync()} . - * - * @param DeleteDeviceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDevice(DeleteDeviceRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteDevice', $request, $callOptions)->wait(); - } - - /** - * Deletes a device registry configuration. - * - * The async variant is {@see self::deleteDeviceRegistryAsync()} . - * - * @param DeleteDeviceRegistryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDeviceRegistry(DeleteDeviceRegistryRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteDeviceRegistry', $request, $callOptions)->wait(); - } - - /** - * Gets details about a device. - * - * The async variant is {@see self::getDeviceAsync()} . - * - * @param GetDeviceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Device - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDevice(GetDeviceRequest $request, array $callOptions = []): Device - { - return $this->startApiCall('GetDevice', $request, $callOptions)->wait(); - } - - /** - * Gets a device registry configuration. - * - * The async variant is {@see self::getDeviceRegistryAsync()} . - * - * @param GetDeviceRegistryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DeviceRegistry - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDeviceRegistry(GetDeviceRegistryRequest $request, array $callOptions = []): DeviceRegistry - { - return $this->startApiCall('GetDeviceRegistry', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. - * Returns an empty policy if the resource exists and does not have a policy - * set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Lists the last few versions of the device configuration in descending - * order (i.e.: newest first). - * - * The async variant is {@see self::listDeviceConfigVersionsAsync()} . - * - * @param ListDeviceConfigVersionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ListDeviceConfigVersionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDeviceConfigVersions(ListDeviceConfigVersionsRequest $request, array $callOptions = []): ListDeviceConfigVersionsResponse - { - return $this->startApiCall('ListDeviceConfigVersions', $request, $callOptions)->wait(); - } - - /** - * Lists device registries. - * - * The async variant is {@see self::listDeviceRegistriesAsync()} . - * - * @param ListDeviceRegistriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDeviceRegistries(ListDeviceRegistriesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDeviceRegistries', $request, $callOptions); - } - - /** - * Lists the last few versions of the device state in descending order (i.e.: - * newest first). - * - * The async variant is {@see self::listDeviceStatesAsync()} . - * - * @param ListDeviceStatesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ListDeviceStatesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDeviceStates(ListDeviceStatesRequest $request, array $callOptions = []): ListDeviceStatesResponse - { - return $this->startApiCall('ListDeviceStates', $request, $callOptions)->wait(); - } - - /** - * List devices in a device registry. - * - * The async variant is {@see self::listDevicesAsync()} . - * - * @param ListDevicesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDevices(ListDevicesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDevices', $request, $callOptions); - } - - /** - * Modifies the configuration for the device, which is eventually sent from - * the Cloud IoT Core servers. Returns the modified configuration version and - * its metadata. - * - * The async variant is {@see self::modifyCloudToDeviceConfigAsync()} . - * - * @param ModifyCloudToDeviceConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DeviceConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest $request, array $callOptions = []): DeviceConfig - { - return $this->startApiCall('ModifyCloudToDeviceConfig', $request, $callOptions)->wait(); - } - - /** - * Sends a command to the specified device. In order for a device to be able - * to receive commands, it must: - * 1) be connected to Cloud IoT Core using the MQTT protocol, and - * 2) be subscribed to the group of MQTT topics specified by - * /devices/{device-id}/commands/#. This subscription will receive commands - * at the top-level topic /devices/{device-id}/commands as well as commands - * for subfolders, like /devices/{device-id}/commands/subfolder. - * Note that subscribing to specific subfolders is not supported. - * If the command could not be delivered to the device, this method will - * return an error; in particular, if the device is not subscribed, this - * method will return FAILED_PRECONDITION. Otherwise, this method will - * return OK. If the subscription is QoS 1, at least once delivery will be - * guaranteed; for QoS 0, no acknowledgment will be expected from the device. - * - * The async variant is {@see self::sendCommandToDeviceAsync()} . - * - * @param SendCommandToDeviceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SendCommandToDeviceResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function sendCommandToDevice(SendCommandToDeviceRequest $request, array $callOptions = []): SendCommandToDeviceResponse - { - return $this->startApiCall('SendCommandToDevice', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces any - * existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. - * If the resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Deletes the association between the device and the gateway. - * - * The async variant is {@see self::unbindDeviceFromGatewayAsync()} . - * - * @param UnbindDeviceFromGatewayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 UnbindDeviceFromGatewayResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function unbindDeviceFromGateway(UnbindDeviceFromGatewayRequest $request, array $callOptions = []): UnbindDeviceFromGatewayResponse - { - return $this->startApiCall('UnbindDeviceFromGateway', $request, $callOptions)->wait(); - } - - /** - * Updates a device. - * - * The async variant is {@see self::updateDeviceAsync()} . - * - * @param UpdateDeviceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Device - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDevice(UpdateDeviceRequest $request, array $callOptions = []): Device - { - return $this->startApiCall('UpdateDevice', $request, $callOptions)->wait(); - } - - /** - * Updates a device registry configuration. - * - * The async variant is {@see self::updateDeviceRegistryAsync()} . - * - * @param UpdateDeviceRegistryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DeviceRegistry - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDeviceRegistry(UpdateDeviceRegistryRequest $request, array $callOptions = []): DeviceRegistry - { - return $this->startApiCall('UpdateDeviceRegistry', $request, $callOptions)->wait(); - } -} diff --git a/Iot/src/V1/Client/DeviceManagerClient.php b/Iot/src/V1/Client/DeviceManagerClient.php index 8d3f44b19dbc..e60d0e5d7e77 100644 --- a/Iot/src/V1/Client/DeviceManagerClient.php +++ b/Iot/src/V1/Client/DeviceManagerClient.php @@ -24,17 +24,751 @@ namespace Google\Cloud\Iot\V1\Client; -use Google\Cloud\Iot\V1\Client\BaseClient\DeviceManagerBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Iot\V1\BindDeviceToGatewayRequest; +use Google\Cloud\Iot\V1\BindDeviceToGatewayResponse; +use Google\Cloud\Iot\V1\CreateDeviceRegistryRequest; +use Google\Cloud\Iot\V1\CreateDeviceRequest; +use Google\Cloud\Iot\V1\DeleteDeviceRegistryRequest; +use Google\Cloud\Iot\V1\DeleteDeviceRequest; +use Google\Cloud\Iot\V1\Device; +use Google\Cloud\Iot\V1\DeviceConfig; +use Google\Cloud\Iot\V1\DeviceRegistry; +use Google\Cloud\Iot\V1\GetDeviceRegistryRequest; +use Google\Cloud\Iot\V1\GetDeviceRequest; +use Google\Cloud\Iot\V1\ListDeviceConfigVersionsRequest; +use Google\Cloud\Iot\V1\ListDeviceConfigVersionsResponse; +use Google\Cloud\Iot\V1\ListDeviceRegistriesRequest; +use Google\Cloud\Iot\V1\ListDeviceStatesRequest; +use Google\Cloud\Iot\V1\ListDeviceStatesResponse; +use Google\Cloud\Iot\V1\ListDevicesRequest; +use Google\Cloud\Iot\V1\ModifyCloudToDeviceConfigRequest; +use Google\Cloud\Iot\V1\SendCommandToDeviceRequest; +use Google\Cloud\Iot\V1\SendCommandToDeviceResponse; +use Google\Cloud\Iot\V1\UnbindDeviceFromGatewayRequest; +use Google\Cloud\Iot\V1\UnbindDeviceFromGatewayResponse; +use Google\Cloud\Iot\V1\UpdateDeviceRegistryRequest; +use Google\Cloud\Iot\V1\UpdateDeviceRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Internet of Things (IoT) service. Securely connect and manage IoT devices. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Iot\V1\DeviceManagerClient} for the stable implementation * * @experimental + * + * @method PromiseInterface bindDeviceToGatewayAsync(BindDeviceToGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface createDeviceAsync(CreateDeviceRequest $request, array $optionalArgs = []) + * @method PromiseInterface createDeviceRegistryAsync(CreateDeviceRegistryRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDeviceAsync(DeleteDeviceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDeviceRegistryAsync(DeleteDeviceRegistryRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDeviceAsync(GetDeviceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDeviceRegistryAsync(GetDeviceRegistryRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDeviceConfigVersionsAsync(ListDeviceConfigVersionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDeviceRegistriesAsync(ListDeviceRegistriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDeviceStatesAsync(ListDeviceStatesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDevicesAsync(ListDevicesRequest $request, array $optionalArgs = []) + * @method PromiseInterface modifyCloudToDeviceConfigAsync(ModifyCloudToDeviceConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface sendCommandToDeviceAsync(SendCommandToDeviceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface unbindDeviceFromGatewayAsync(UnbindDeviceFromGatewayRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDeviceAsync(UpdateDeviceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDeviceRegistryAsync(UpdateDeviceRegistryRequest $request, array $optionalArgs = []) */ -final class DeviceManagerClient extends DeviceManagerBaseClient +final class DeviceManagerClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DeviceManagerBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.iot.v1.DeviceManager'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudiot.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloudiot', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/device_manager_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/device_manager_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/device_manager_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/device_manager_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a device + * resource. + * + * @param string $project + * @param string $location + * @param string $registry + * @param string $device + * + * @return string The formatted device resource. + */ + public static function deviceName(string $project, string $location, string $registry, string $device): string + { + return self::getPathTemplate('device')->render([ + 'project' => $project, + 'location' => $location, + 'registry' => $registry, + 'device' => $device, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a registry + * resource. + * + * @param string $project + * @param string $location + * @param string $registry + * + * @return string The formatted registry resource. + */ + public static function registryName(string $project, string $location, string $registry): string + { + return self::getPathTemplate('registry')->render([ + 'project' => $project, + 'location' => $location, + 'registry' => $registry, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - device: projects/{project}/locations/{location}/registries/{registry}/devices/{device} + * - location: projects/{project}/locations/{location} + * - registry: projects/{project}/locations/{location}/registries/{registry} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudiot.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Associates the device with the gateway. + * + * The async variant is {@see DeviceManagerClient::bindDeviceToGatewayAsync()} . + * + * @param BindDeviceToGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BindDeviceToGatewayResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function bindDeviceToGateway(BindDeviceToGatewayRequest $request, array $callOptions = []): BindDeviceToGatewayResponse + { + return $this->startApiCall('BindDeviceToGateway', $request, $callOptions)->wait(); + } + + /** + * Creates a device in a device registry. + * + * The async variant is {@see DeviceManagerClient::createDeviceAsync()} . + * + * @param CreateDeviceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Device + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDevice(CreateDeviceRequest $request, array $callOptions = []): Device + { + return $this->startApiCall('CreateDevice', $request, $callOptions)->wait(); + } + + /** + * Creates a device registry that contains devices. + * + * The async variant is {@see DeviceManagerClient::createDeviceRegistryAsync()} . + * + * @param CreateDeviceRegistryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DeviceRegistry + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDeviceRegistry(CreateDeviceRegistryRequest $request, array $callOptions = []): DeviceRegistry + { + return $this->startApiCall('CreateDeviceRegistry', $request, $callOptions)->wait(); + } + + /** + * Deletes a device. + * + * The async variant is {@see DeviceManagerClient::deleteDeviceAsync()} . + * + * @param DeleteDeviceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDevice(DeleteDeviceRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteDevice', $request, $callOptions)->wait(); + } + + /** + * Deletes a device registry configuration. + * + * The async variant is {@see DeviceManagerClient::deleteDeviceRegistryAsync()} . + * + * @param DeleteDeviceRegistryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDeviceRegistry(DeleteDeviceRegistryRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteDeviceRegistry', $request, $callOptions)->wait(); + } + + /** + * Gets details about a device. + * + * The async variant is {@see DeviceManagerClient::getDeviceAsync()} . + * + * @param GetDeviceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Device + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDevice(GetDeviceRequest $request, array $callOptions = []): Device + { + return $this->startApiCall('GetDevice', $request, $callOptions)->wait(); + } + + /** + * Gets a device registry configuration. + * + * The async variant is {@see DeviceManagerClient::getDeviceRegistryAsync()} . + * + * @param GetDeviceRegistryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DeviceRegistry + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDeviceRegistry(GetDeviceRegistryRequest $request, array $callOptions = []): DeviceRegistry + { + return $this->startApiCall('GetDeviceRegistry', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. + * Returns an empty policy if the resource exists and does not have a policy + * set. + * + * The async variant is {@see DeviceManagerClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Lists the last few versions of the device configuration in descending + * order (i.e.: newest first). + * + * The async variant is {@see DeviceManagerClient::listDeviceConfigVersionsAsync()} + * . + * + * @param ListDeviceConfigVersionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ListDeviceConfigVersionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDeviceConfigVersions(ListDeviceConfigVersionsRequest $request, array $callOptions = []): ListDeviceConfigVersionsResponse + { + return $this->startApiCall('ListDeviceConfigVersions', $request, $callOptions)->wait(); + } + + /** + * Lists device registries. + * + * The async variant is {@see DeviceManagerClient::listDeviceRegistriesAsync()} . + * + * @param ListDeviceRegistriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDeviceRegistries(ListDeviceRegistriesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDeviceRegistries', $request, $callOptions); + } + + /** + * Lists the last few versions of the device state in descending order (i.e.: + * newest first). + * + * The async variant is {@see DeviceManagerClient::listDeviceStatesAsync()} . + * + * @param ListDeviceStatesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ListDeviceStatesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDeviceStates(ListDeviceStatesRequest $request, array $callOptions = []): ListDeviceStatesResponse + { + return $this->startApiCall('ListDeviceStates', $request, $callOptions)->wait(); + } + + /** + * List devices in a device registry. + * + * The async variant is {@see DeviceManagerClient::listDevicesAsync()} . + * + * @param ListDevicesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDevices(ListDevicesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDevices', $request, $callOptions); + } + + /** + * Modifies the configuration for the device, which is eventually sent from + * the Cloud IoT Core servers. Returns the modified configuration version and + * its metadata. + * + * The async variant is + * {@see DeviceManagerClient::modifyCloudToDeviceConfigAsync()} . + * + * @param ModifyCloudToDeviceConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DeviceConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest $request, array $callOptions = []): DeviceConfig + { + return $this->startApiCall('ModifyCloudToDeviceConfig', $request, $callOptions)->wait(); + } + + /** + * Sends a command to the specified device. In order for a device to be able + * to receive commands, it must: + * 1) be connected to Cloud IoT Core using the MQTT protocol, and + * 2) be subscribed to the group of MQTT topics specified by + * /devices/{device-id}/commands/#. This subscription will receive commands + * at the top-level topic /devices/{device-id}/commands as well as commands + * for subfolders, like /devices/{device-id}/commands/subfolder. + * Note that subscribing to specific subfolders is not supported. + * If the command could not be delivered to the device, this method will + * return an error; in particular, if the device is not subscribed, this + * method will return FAILED_PRECONDITION. Otherwise, this method will + * return OK. If the subscription is QoS 1, at least once delivery will be + * guaranteed; for QoS 0, no acknowledgment will be expected from the device. + * + * The async variant is {@see DeviceManagerClient::sendCommandToDeviceAsync()} . + * + * @param SendCommandToDeviceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SendCommandToDeviceResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function sendCommandToDevice(SendCommandToDeviceRequest $request, array $callOptions = []): SendCommandToDeviceResponse + { + return $this->startApiCall('SendCommandToDevice', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces any + * existing policy. + * + * The async variant is {@see DeviceManagerClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. + * If the resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * The async variant is {@see DeviceManagerClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Deletes the association between the device and the gateway. + * + * The async variant is {@see DeviceManagerClient::unbindDeviceFromGatewayAsync()} + * . + * + * @param UnbindDeviceFromGatewayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 UnbindDeviceFromGatewayResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function unbindDeviceFromGateway(UnbindDeviceFromGatewayRequest $request, array $callOptions = []): UnbindDeviceFromGatewayResponse + { + return $this->startApiCall('UnbindDeviceFromGateway', $request, $callOptions)->wait(); + } + + /** + * Updates a device. + * + * The async variant is {@see DeviceManagerClient::updateDeviceAsync()} . + * + * @param UpdateDeviceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Device + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDevice(UpdateDeviceRequest $request, array $callOptions = []): Device + { + return $this->startApiCall('UpdateDevice', $request, $callOptions)->wait(); + } + + /** + * Updates a device registry configuration. + * + * The async variant is {@see DeviceManagerClient::updateDeviceRegistryAsync()} . + * + * @param UpdateDeviceRegistryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DeviceRegistry + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDeviceRegistry(UpdateDeviceRegistryRequest $request, array $callOptions = []): DeviceRegistry + { + return $this->startApiCall('UpdateDeviceRegistry', $request, $callOptions)->wait(); + } } diff --git a/Kms/composer.json b/Kms/composer.json index 8184999599c0..966fd1744977 100644 --- a/Kms/composer.json +++ b/Kms/composer.json @@ -24,11 +24,11 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", - "google/cloud-core": "^1.39" + "google/cloud-core": "^1.52.7" }, "suggest": { "ext-grpc": "Enables use of gRPC, a universal high-performance RPC framework created by Google.", diff --git a/Kms/src/V1/Client/BaseClient/EkmServiceBaseClient.php b/Kms/src/V1/Client/BaseClient/EkmServiceBaseClient.php deleted file mode 100644 index 99ff5c5960c4..000000000000 --- a/Kms/src/V1/Client/BaseClient/EkmServiceBaseClient.php +++ /dev/null @@ -1,611 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/ekm_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/ekm_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/ekm_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/ekm_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a ekm_config - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted ekm_config resource. - */ - public static function ekmConfigName(string $project, string $location): string - { - return self::getPathTemplate('ekmConfig')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * ekm_connection resource. - * - * @param string $project - * @param string $location - * @param string $ekmConnection - * - * @return string The formatted ekm_connection resource. - */ - public static function ekmConnectionName(string $project, string $location, string $ekmConnection): string - { - return self::getPathTemplate('ekmConnection')->render([ - 'project' => $project, - 'location' => $location, - 'ekm_connection' => $ekmConnection, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a service - * resource. - * - * @param string $project - * @param string $location - * @param string $namespace - * @param string $service - * - * @return string The formatted service resource. - */ - public static function serviceName(string $project, string $location, string $namespace, string $service): string - { - return self::getPathTemplate('service')->render([ - 'project' => $project, - 'location' => $location, - 'namespace' => $namespace, - 'service' => $service, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - ekmConfig: projects/{project}/locations/{location}/ekmConfig - * - ekmConnection: projects/{project}/locations/{location}/ekmConnections/{ekm_connection} - * - location: projects/{project}/locations/{location} - * - service: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudkms.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new [EkmConnection][google.cloud.kms.v1.EkmConnection] in a given - * Project and Location. - * - * The async variant is {@see self::createEkmConnectionAsync()} . - * - * @param CreateEkmConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 EkmConnection - * - * @throws ApiException Thrown if the API call fails. - */ - public function createEkmConnection(CreateEkmConnectionRequest $request, array $callOptions = []): EkmConnection - { - return $this->startApiCall('CreateEkmConnection', $request, $callOptions)->wait(); - } - - /** - * Returns the [EkmConfig][google.cloud.kms.v1.EkmConfig] singleton resource - * for a given project and location. - * - * The async variant is {@see self::getEkmConfigAsync()} . - * - * @param GetEkmConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 EkmConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEkmConfig(GetEkmConfigRequest $request, array $callOptions = []): EkmConfig - { - return $this->startApiCall('GetEkmConfig', $request, $callOptions)->wait(); - } - - /** - * Returns metadata for a given - * [EkmConnection][google.cloud.kms.v1.EkmConnection]. - * - * The async variant is {@see self::getEkmConnectionAsync()} . - * - * @param GetEkmConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 EkmConnection - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEkmConnection(GetEkmConnectionRequest $request, array $callOptions = []): EkmConnection - { - return $this->startApiCall('GetEkmConnection', $request, $callOptions)->wait(); - } - - /** - * Lists [EkmConnections][google.cloud.kms.v1.EkmConnection]. - * - * The async variant is {@see self::listEkmConnectionsAsync()} . - * - * @param ListEkmConnectionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listEkmConnections(ListEkmConnectionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListEkmConnections', $request, $callOptions); - } - - /** - * Updates the [EkmConfig][google.cloud.kms.v1.EkmConfig] singleton resource - * for a given project and location. - * - * The async variant is {@see self::updateEkmConfigAsync()} . - * - * @param UpdateEkmConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 EkmConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateEkmConfig(UpdateEkmConfigRequest $request, array $callOptions = []): EkmConfig - { - return $this->startApiCall('UpdateEkmConfig', $request, $callOptions)->wait(); - } - - /** - * Updates an [EkmConnection][google.cloud.kms.v1.EkmConnection]'s metadata. - * - * The async variant is {@see self::updateEkmConnectionAsync()} . - * - * @param UpdateEkmConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 EkmConnection - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateEkmConnection(UpdateEkmConnectionRequest $request, array $callOptions = []): EkmConnection - { - return $this->startApiCall('UpdateEkmConnection', $request, $callOptions)->wait(); - } - - /** - * Verifies that Cloud KMS can successfully connect to the external key - * manager specified by an [EkmConnection][google.cloud.kms.v1.EkmConnection]. - * If there is an error connecting to the EKM, this method returns a - * FAILED_PRECONDITION status containing structured information as described - * at https://cloud.google.com/kms/docs/reference/ekm_errors. - * - * The async variant is {@see self::verifyConnectivityAsync()} . - * - * @param VerifyConnectivityRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 VerifyConnectivityResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function verifyConnectivity(VerifyConnectivityRequest $request, array $callOptions = []): VerifyConnectivityResponse - { - return $this->startApiCall('VerifyConnectivity', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Kms/src/V1/Client/BaseClient/KeyManagementServiceBaseClient.php b/Kms/src/V1/Client/BaseClient/KeyManagementServiceBaseClient.php deleted file mode 100644 index bd66d644862b..000000000000 --- a/Kms/src/V1/Client/BaseClient/KeyManagementServiceBaseClient.php +++ /dev/null @@ -1,1297 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/key_management_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/key_management_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/key_management_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/key_management_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a crypto_key - * resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * @param string $cryptoKey - * - * @return string The formatted crypto_key resource. - */ - public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string - { - return self::getPathTemplate('cryptoKey')->render([ - 'project' => $project, - 'location' => $location, - 'key_ring' => $keyRing, - 'crypto_key' => $cryptoKey, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * crypto_key_version resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * @param string $cryptoKey - * @param string $cryptoKeyVersion - * - * @return string The formatted crypto_key_version resource. - */ - public static function cryptoKeyVersionName(string $project, string $location, string $keyRing, string $cryptoKey, string $cryptoKeyVersion): string - { - return self::getPathTemplate('cryptoKeyVersion')->render([ - 'project' => $project, - 'location' => $location, - 'key_ring' => $keyRing, - 'crypto_key' => $cryptoKey, - 'crypto_key_version' => $cryptoKeyVersion, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a import_job - * resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * @param string $importJob - * - * @return string The formatted import_job resource. - */ - public static function importJobName(string $project, string $location, string $keyRing, string $importJob): string - { - return self::getPathTemplate('importJob')->render([ - 'project' => $project, - 'location' => $location, - 'key_ring' => $keyRing, - 'import_job' => $importJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a key_ring - * resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * - * @return string The formatted key_ring resource. - */ - public static function keyRingName(string $project, string $location, string $keyRing): string - { - return self::getPathTemplate('keyRing')->render([ - 'project' => $project, - 'location' => $location, - 'key_ring' => $keyRing, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} - * - cryptoKeyVersion: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version} - * - importJob: projects/{project}/locations/{location}/keyRings/{key_ring}/importJobs/{import_job} - * - keyRing: projects/{project}/locations/{location}/keyRings/{key_ring} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudkms.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Decrypts data that was encrypted with a public key retrieved from - * [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey] - * corresponding to a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] - * with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] - * ASYMMETRIC_DECRYPT. - * - * The async variant is {@see self::asymmetricDecryptAsync()} . - * - * @param AsymmetricDecryptRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AsymmetricDecryptResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function asymmetricDecrypt(AsymmetricDecryptRequest $request, array $callOptions = []): AsymmetricDecryptResponse - { - return $this->startApiCall('AsymmetricDecrypt', $request, $callOptions)->wait(); - } - - /** - * Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] - * with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] - * ASYMMETRIC_SIGN, producing a signature that can be verified with the public - * key retrieved from - * [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey]. - * - * The async variant is {@see self::asymmetricSignAsync()} . - * - * @param AsymmetricSignRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AsymmetricSignResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function asymmetricSign(AsymmetricSignRequest $request, array $callOptions = []): AsymmetricSignResponse - { - return $this->startApiCall('AsymmetricSign', $request, $callOptions)->wait(); - } - - /** - * Create a new [CryptoKey][google.cloud.kms.v1.CryptoKey] within a - * [KeyRing][google.cloud.kms.v1.KeyRing]. - * - * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] and - * [CryptoKey.version_template.algorithm][google.cloud.kms.v1.CryptoKeyVersionTemplate.algorithm] - * are required. - * - * The async variant is {@see self::createCryptoKeyAsync()} . - * - * @param CreateCryptoKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CryptoKey - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCryptoKey(CreateCryptoKeyRequest $request, array $callOptions = []): CryptoKey - { - return $this->startApiCall('CreateCryptoKey', $request, $callOptions)->wait(); - } - - /** - * Create a new [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in a - * [CryptoKey][google.cloud.kms.v1.CryptoKey]. - * - * The server will assign the next sequential id. If unset, - * [state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to - * [ENABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.ENABLED]. - * - * The async variant is {@see self::createCryptoKeyVersionAsync()} . - * - * @param CreateCryptoKeyVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CryptoKeyVersion - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCryptoKeyVersion(CreateCryptoKeyVersionRequest $request, array $callOptions = []): CryptoKeyVersion - { - return $this->startApiCall('CreateCryptoKeyVersion', $request, $callOptions)->wait(); - } - - /** - * Create a new [ImportJob][google.cloud.kms.v1.ImportJob] within a - * [KeyRing][google.cloud.kms.v1.KeyRing]. - * - * [ImportJob.import_method][google.cloud.kms.v1.ImportJob.import_method] is - * required. - * - * The async variant is {@see self::createImportJobAsync()} . - * - * @param CreateImportJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ImportJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function createImportJob(CreateImportJobRequest $request, array $callOptions = []): ImportJob - { - return $this->startApiCall('CreateImportJob', $request, $callOptions)->wait(); - } - - /** - * Create a new [KeyRing][google.cloud.kms.v1.KeyRing] in a given Project and - * Location. - * - * The async variant is {@see self::createKeyRingAsync()} . - * - * @param CreateKeyRingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 KeyRing - * - * @throws ApiException Thrown if the API call fails. - */ - public function createKeyRing(CreateKeyRingRequest $request, array $callOptions = []): KeyRing - { - return $this->startApiCall('CreateKeyRing', $request, $callOptions)->wait(); - } - - /** - * Decrypts data that was protected by - * [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt]. The - * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be - * [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT]. - * - * The async variant is {@see self::decryptAsync()} . - * - * @param DecryptRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DecryptResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function decrypt(DecryptRequest $request, array $callOptions = []): DecryptResponse - { - return $this->startApiCall('Decrypt', $request, $callOptions)->wait(); - } - - /** - * Schedule a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] for - * destruction. - * - * Upon calling this method, - * [CryptoKeyVersion.state][google.cloud.kms.v1.CryptoKeyVersion.state] will - * be set to - * [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED], - * and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will - * be set to the time - * [destroy_scheduled_duration][google.cloud.kms.v1.CryptoKey.destroy_scheduled_duration] - * in the future. At that time, the - * [state][google.cloud.kms.v1.CryptoKeyVersion.state] will automatically - * change to - * [DESTROYED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROYED], - * and the key material will be irrevocably destroyed. - * - * Before the - * [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] is - * reached, - * [RestoreCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.RestoreCryptoKeyVersion] - * may be called to reverse the process. - * - * The async variant is {@see self::destroyCryptoKeyVersionAsync()} . - * - * @param DestroyCryptoKeyVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CryptoKeyVersion - * - * @throws ApiException Thrown if the API call fails. - */ - public function destroyCryptoKeyVersion(DestroyCryptoKeyVersionRequest $request, array $callOptions = []): CryptoKeyVersion - { - return $this->startApiCall('DestroyCryptoKeyVersion', $request, $callOptions)->wait(); - } - - /** - * Encrypts data, so that it can only be recovered by a call to - * [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt]. The - * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be - * [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT]. - * - * The async variant is {@see self::encryptAsync()} . - * - * @param EncryptRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 EncryptResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function encrypt(EncryptRequest $request, array $callOptions = []): EncryptResponse - { - return $this->startApiCall('Encrypt', $request, $callOptions)->wait(); - } - - /** - * Generate random bytes using the Cloud KMS randomness source in the provided - * location. - * - * The async variant is {@see self::generateRandomBytesAsync()} . - * - * @param GenerateRandomBytesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GenerateRandomBytesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function generateRandomBytes(GenerateRandomBytesRequest $request, array $callOptions = []): GenerateRandomBytesResponse - { - return $this->startApiCall('GenerateRandomBytes', $request, $callOptions)->wait(); - } - - /** - * Returns metadata for a given [CryptoKey][google.cloud.kms.v1.CryptoKey], as - * well as its [primary][google.cloud.kms.v1.CryptoKey.primary] - * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]. - * - * The async variant is {@see self::getCryptoKeyAsync()} . - * - * @param GetCryptoKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CryptoKey - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCryptoKey(GetCryptoKeyRequest $request, array $callOptions = []): CryptoKey - { - return $this->startApiCall('GetCryptoKey', $request, $callOptions)->wait(); - } - - /** - * Returns metadata for a given - * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]. - * - * The async variant is {@see self::getCryptoKeyVersionAsync()} . - * - * @param GetCryptoKeyVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CryptoKeyVersion - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCryptoKeyVersion(GetCryptoKeyVersionRequest $request, array $callOptions = []): CryptoKeyVersion - { - return $this->startApiCall('GetCryptoKeyVersion', $request, $callOptions)->wait(); - } - - /** - * Returns metadata for a given [ImportJob][google.cloud.kms.v1.ImportJob]. - * - * The async variant is {@see self::getImportJobAsync()} . - * - * @param GetImportJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ImportJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function getImportJob(GetImportJobRequest $request, array $callOptions = []): ImportJob - { - return $this->startApiCall('GetImportJob', $request, $callOptions)->wait(); - } - - /** - * Returns metadata for a given [KeyRing][google.cloud.kms.v1.KeyRing]. - * - * The async variant is {@see self::getKeyRingAsync()} . - * - * @param GetKeyRingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 KeyRing - * - * @throws ApiException Thrown if the API call fails. - */ - public function getKeyRing(GetKeyRingRequest $request, array $callOptions = []): KeyRing - { - return $this->startApiCall('GetKeyRing', $request, $callOptions)->wait(); - } - - /** - * Returns the public key for the given - * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]. The - * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be - * [ASYMMETRIC_SIGN][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_SIGN] - * or - * [ASYMMETRIC_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_DECRYPT]. - * - * The async variant is {@see self::getPublicKeyAsync()} . - * - * @param GetPublicKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PublicKey - * - * @throws ApiException Thrown if the API call fails. - */ - public function getPublicKey(GetPublicKeyRequest $request, array $callOptions = []): PublicKey - { - return $this->startApiCall('GetPublicKey', $request, $callOptions)->wait(); - } - - /** - * Import wrapped key material into a - * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]. - * - * All requests must specify a [CryptoKey][google.cloud.kms.v1.CryptoKey]. If - * a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] is additionally - * specified in the request, key material will be reimported into that - * version. Otherwise, a new version will be created, and will be assigned the - * next sequential id within the [CryptoKey][google.cloud.kms.v1.CryptoKey]. - * - * The async variant is {@see self::importCryptoKeyVersionAsync()} . - * - * @param ImportCryptoKeyVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CryptoKeyVersion - * - * @throws ApiException Thrown if the API call fails. - */ - public function importCryptoKeyVersion(ImportCryptoKeyVersionRequest $request, array $callOptions = []): CryptoKeyVersion - { - return $this->startApiCall('ImportCryptoKeyVersion', $request, $callOptions)->wait(); - } - - /** - * Lists [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion]. - * - * The async variant is {@see self::listCryptoKeyVersionsAsync()} . - * - * @param ListCryptoKeyVersionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCryptoKeyVersions(ListCryptoKeyVersionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCryptoKeyVersions', $request, $callOptions); - } - - /** - * Lists [CryptoKeys][google.cloud.kms.v1.CryptoKey]. - * - * The async variant is {@see self::listCryptoKeysAsync()} . - * - * @param ListCryptoKeysRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCryptoKeys(ListCryptoKeysRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCryptoKeys', $request, $callOptions); - } - - /** - * Lists [ImportJobs][google.cloud.kms.v1.ImportJob]. - * - * The async variant is {@see self::listImportJobsAsync()} . - * - * @param ListImportJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listImportJobs(ListImportJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListImportJobs', $request, $callOptions); - } - - /** - * Lists [KeyRings][google.cloud.kms.v1.KeyRing]. - * - * The async variant is {@see self::listKeyRingsAsync()} . - * - * @param ListKeyRingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listKeyRings(ListKeyRingsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListKeyRings', $request, $callOptions); - } - - /** - * Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] - * with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] MAC, - * producing a tag that can be verified by another source with the same key. - * - * The async variant is {@see self::macSignAsync()} . - * - * @param MacSignRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MacSignResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function macSign(MacSignRequest $request, array $callOptions = []): MacSignResponse - { - return $this->startApiCall('MacSign', $request, $callOptions)->wait(); - } - - /** - * Verifies MAC tag using a - * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with - * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] MAC, and returns - * a response that indicates whether or not the verification was successful. - * - * The async variant is {@see self::macVerifyAsync()} . - * - * @param MacVerifyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MacVerifyResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function macVerify(MacVerifyRequest $request, array $callOptions = []): MacVerifyResponse - { - return $this->startApiCall('MacVerify', $request, $callOptions)->wait(); - } - - /** - * Decrypts data that was originally encrypted using a raw cryptographic - * mechanism. The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] - * must be - * [RAW_ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.RAW_ENCRYPT_DECRYPT]. - * - * The async variant is {@see self::rawDecryptAsync()} . - * - * @param RawDecryptRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RawDecryptResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function rawDecrypt(RawDecryptRequest $request, array $callOptions = []): RawDecryptResponse - { - return $this->startApiCall('RawDecrypt', $request, $callOptions)->wait(); - } - - /** - * Encrypts data using portable cryptographic primitives. Most users should - * choose [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt] and - * [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt] rather than - * their raw counterparts. The - * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be - * [RAW_ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.RAW_ENCRYPT_DECRYPT]. - * - * The async variant is {@see self::rawEncryptAsync()} . - * - * @param RawEncryptRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RawEncryptResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function rawEncrypt(RawEncryptRequest $request, array $callOptions = []): RawEncryptResponse - { - return $this->startApiCall('RawEncrypt', $request, $callOptions)->wait(); - } - - /** - * Restore a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in the - * [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED] - * state. - * - * Upon restoration of the CryptoKeyVersion, - * [state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to - * [DISABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED], - * and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will - * be cleared. - * - * The async variant is {@see self::restoreCryptoKeyVersionAsync()} . - * - * @param RestoreCryptoKeyVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CryptoKeyVersion - * - * @throws ApiException Thrown if the API call fails. - */ - public function restoreCryptoKeyVersion(RestoreCryptoKeyVersionRequest $request, array $callOptions = []): CryptoKeyVersion - { - return $this->startApiCall('RestoreCryptoKeyVersion', $request, $callOptions)->wait(); - } - - /** - * Update a [CryptoKey][google.cloud.kms.v1.CryptoKey]. - * - * The async variant is {@see self::updateCryptoKeyAsync()} . - * - * @param UpdateCryptoKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CryptoKey - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCryptoKey(UpdateCryptoKeyRequest $request, array $callOptions = []): CryptoKey - { - return $this->startApiCall('UpdateCryptoKey', $request, $callOptions)->wait(); - } - - /** - * Update the version of a [CryptoKey][google.cloud.kms.v1.CryptoKey] that - * will be used in - * [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt]. - * - * Returns an error if called on a key whose purpose is not - * [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT]. - * - * The async variant is {@see self::updateCryptoKeyPrimaryVersionAsync()} . - * - * @param UpdateCryptoKeyPrimaryVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CryptoKey - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCryptoKeyPrimaryVersion(UpdateCryptoKeyPrimaryVersionRequest $request, array $callOptions = []): CryptoKey - { - return $this->startApiCall('UpdateCryptoKeyPrimaryVersion', $request, $callOptions)->wait(); - } - - /** - * Update a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]'s - * metadata. - * - * [state][google.cloud.kms.v1.CryptoKeyVersion.state] may be changed between - * [ENABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.ENABLED] - * and - * [DISABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED] - * using this method. See - * [DestroyCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.DestroyCryptoKeyVersion] - * and - * [RestoreCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.RestoreCryptoKeyVersion] - * to move between other states. - * - * The async variant is {@see self::updateCryptoKeyVersionAsync()} . - * - * @param UpdateCryptoKeyVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CryptoKeyVersion - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCryptoKeyVersion(UpdateCryptoKeyVersionRequest $request, array $callOptions = []): CryptoKeyVersion - { - return $this->startApiCall('UpdateCryptoKeyVersion', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Kms/src/V1/Client/EkmServiceClient.php b/Kms/src/V1/Client/EkmServiceClient.php index d37536c8451c..0e3c77594997 100644 --- a/Kms/src/V1/Client/EkmServiceClient.php +++ b/Kms/src/V1/Client/EkmServiceClient.php @@ -24,17 +24,586 @@ namespace Google\Cloud\Kms\V1\Client; -use Google\Cloud\Kms\V1\Client\BaseClient\EkmServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Kms\V1\CreateEkmConnectionRequest; +use Google\Cloud\Kms\V1\EkmConfig; +use Google\Cloud\Kms\V1\EkmConnection; +use Google\Cloud\Kms\V1\GetEkmConfigRequest; +use Google\Cloud\Kms\V1\GetEkmConnectionRequest; +use Google\Cloud\Kms\V1\ListEkmConnectionsRequest; +use Google\Cloud\Kms\V1\UpdateEkmConfigRequest; +use Google\Cloud\Kms\V1\UpdateEkmConnectionRequest; +use Google\Cloud\Kms\V1\VerifyConnectivityRequest; +use Google\Cloud\Kms\V1\VerifyConnectivityResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Google Cloud Key Management EKM Service * - * This class is currently experimental and may be subject to changes. + * Manages external cryptographic keys and operations using those keys. + * Implements a REST model with the following objects: + * * [EkmConnection][google.cloud.kms.v1.EkmConnection] + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Kms\V1\EkmServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createEkmConnectionAsync(CreateEkmConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEkmConfigAsync(GetEkmConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEkmConnectionAsync(GetEkmConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface listEkmConnectionsAsync(ListEkmConnectionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateEkmConfigAsync(UpdateEkmConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateEkmConnectionAsync(UpdateEkmConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface verifyConnectivityAsync(VerifyConnectivityRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class EkmServiceClient extends EkmServiceBaseClient +final class EkmServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see EkmServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.kms.v1.EkmService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudkms.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloudkms', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/ekm_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/ekm_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/ekm_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/ekm_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a ekm_config + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted ekm_config resource. + */ + public static function ekmConfigName(string $project, string $location): string + { + return self::getPathTemplate('ekmConfig')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * ekm_connection resource. + * + * @param string $project + * @param string $location + * @param string $ekmConnection + * + * @return string The formatted ekm_connection resource. + */ + public static function ekmConnectionName(string $project, string $location, string $ekmConnection): string + { + return self::getPathTemplate('ekmConnection')->render([ + 'project' => $project, + 'location' => $location, + 'ekm_connection' => $ekmConnection, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a service + * resource. + * + * @param string $project + * @param string $location + * @param string $namespace + * @param string $service + * + * @return string The formatted service resource. + */ + public static function serviceName(string $project, string $location, string $namespace, string $service): string + { + return self::getPathTemplate('service')->render([ + 'project' => $project, + 'location' => $location, + 'namespace' => $namespace, + 'service' => $service, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - ekmConfig: projects/{project}/locations/{location}/ekmConfig + * - ekmConnection: projects/{project}/locations/{location}/ekmConnections/{ekm_connection} + * - location: projects/{project}/locations/{location} + * - service: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudkms.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new [EkmConnection][google.cloud.kms.v1.EkmConnection] in a given + * Project and Location. + * + * The async variant is {@see EkmServiceClient::createEkmConnectionAsync()} . + * + * @param CreateEkmConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 EkmConnection + * + * @throws ApiException Thrown if the API call fails. + */ + public function createEkmConnection(CreateEkmConnectionRequest $request, array $callOptions = []): EkmConnection + { + return $this->startApiCall('CreateEkmConnection', $request, $callOptions)->wait(); + } + + /** + * Returns the [EkmConfig][google.cloud.kms.v1.EkmConfig] singleton resource + * for a given project and location. + * + * The async variant is {@see EkmServiceClient::getEkmConfigAsync()} . + * + * @param GetEkmConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 EkmConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEkmConfig(GetEkmConfigRequest $request, array $callOptions = []): EkmConfig + { + return $this->startApiCall('GetEkmConfig', $request, $callOptions)->wait(); + } + + /** + * Returns metadata for a given + * [EkmConnection][google.cloud.kms.v1.EkmConnection]. + * + * The async variant is {@see EkmServiceClient::getEkmConnectionAsync()} . + * + * @param GetEkmConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 EkmConnection + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEkmConnection(GetEkmConnectionRequest $request, array $callOptions = []): EkmConnection + { + return $this->startApiCall('GetEkmConnection', $request, $callOptions)->wait(); + } + + /** + * Lists [EkmConnections][google.cloud.kms.v1.EkmConnection]. + * + * The async variant is {@see EkmServiceClient::listEkmConnectionsAsync()} . + * + * @param ListEkmConnectionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listEkmConnections(ListEkmConnectionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEkmConnections', $request, $callOptions); + } + + /** + * Updates the [EkmConfig][google.cloud.kms.v1.EkmConfig] singleton resource + * for a given project and location. + * + * The async variant is {@see EkmServiceClient::updateEkmConfigAsync()} . + * + * @param UpdateEkmConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 EkmConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateEkmConfig(UpdateEkmConfigRequest $request, array $callOptions = []): EkmConfig + { + return $this->startApiCall('UpdateEkmConfig', $request, $callOptions)->wait(); + } + + /** + * Updates an [EkmConnection][google.cloud.kms.v1.EkmConnection]'s metadata. + * + * The async variant is {@see EkmServiceClient::updateEkmConnectionAsync()} . + * + * @param UpdateEkmConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 EkmConnection + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateEkmConnection(UpdateEkmConnectionRequest $request, array $callOptions = []): EkmConnection + { + return $this->startApiCall('UpdateEkmConnection', $request, $callOptions)->wait(); + } + + /** + * Verifies that Cloud KMS can successfully connect to the external key + * manager specified by an [EkmConnection][google.cloud.kms.v1.EkmConnection]. + * If there is an error connecting to the EKM, this method returns a + * FAILED_PRECONDITION status containing structured information as described + * at https://cloud.google.com/kms/docs/reference/ekm_errors. + * + * The async variant is {@see EkmServiceClient::verifyConnectivityAsync()} . + * + * @param VerifyConnectivityRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 VerifyConnectivityResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function verifyConnectivity(VerifyConnectivityRequest $request, array $callOptions = []): VerifyConnectivityResponse + { + return $this->startApiCall('VerifyConnectivity', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see EkmServiceClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see EkmServiceClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see EkmServiceClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see EkmServiceClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see EkmServiceClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Kms/src/V1/Client/KeyManagementServiceClient.php b/Kms/src/V1/Client/KeyManagementServiceClient.php index 852a019befdc..280353d6629b 100644 --- a/Kms/src/V1/Client/KeyManagementServiceClient.php +++ b/Kms/src/V1/Client/KeyManagementServiceClient.php @@ -24,17 +24,1283 @@ namespace Google\Cloud\Kms\V1\Client; -use Google\Cloud\Kms\V1\Client\BaseClient\KeyManagementServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Kms\V1\AsymmetricDecryptRequest; +use Google\Cloud\Kms\V1\AsymmetricDecryptResponse; +use Google\Cloud\Kms\V1\AsymmetricSignRequest; +use Google\Cloud\Kms\V1\AsymmetricSignResponse; +use Google\Cloud\Kms\V1\CreateCryptoKeyRequest; +use Google\Cloud\Kms\V1\CreateCryptoKeyVersionRequest; +use Google\Cloud\Kms\V1\CreateImportJobRequest; +use Google\Cloud\Kms\V1\CreateKeyRingRequest; +use Google\Cloud\Kms\V1\CryptoKey; +use Google\Cloud\Kms\V1\CryptoKeyVersion; +use Google\Cloud\Kms\V1\DecryptRequest; +use Google\Cloud\Kms\V1\DecryptResponse; +use Google\Cloud\Kms\V1\DestroyCryptoKeyVersionRequest; +use Google\Cloud\Kms\V1\EncryptRequest; +use Google\Cloud\Kms\V1\EncryptResponse; +use Google\Cloud\Kms\V1\GenerateRandomBytesRequest; +use Google\Cloud\Kms\V1\GenerateRandomBytesResponse; +use Google\Cloud\Kms\V1\GetCryptoKeyRequest; +use Google\Cloud\Kms\V1\GetCryptoKeyVersionRequest; +use Google\Cloud\Kms\V1\GetImportJobRequest; +use Google\Cloud\Kms\V1\GetKeyRingRequest; +use Google\Cloud\Kms\V1\GetPublicKeyRequest; +use Google\Cloud\Kms\V1\ImportCryptoKeyVersionRequest; +use Google\Cloud\Kms\V1\ImportJob; +use Google\Cloud\Kms\V1\KeyRing; +use Google\Cloud\Kms\V1\ListCryptoKeyVersionsRequest; +use Google\Cloud\Kms\V1\ListCryptoKeysRequest; +use Google\Cloud\Kms\V1\ListImportJobsRequest; +use Google\Cloud\Kms\V1\ListKeyRingsRequest; +use Google\Cloud\Kms\V1\MacSignRequest; +use Google\Cloud\Kms\V1\MacSignResponse; +use Google\Cloud\Kms\V1\MacVerifyRequest; +use Google\Cloud\Kms\V1\MacVerifyResponse; +use Google\Cloud\Kms\V1\PublicKey; +use Google\Cloud\Kms\V1\RawDecryptRequest; +use Google\Cloud\Kms\V1\RawDecryptResponse; +use Google\Cloud\Kms\V1\RawEncryptRequest; +use Google\Cloud\Kms\V1\RawEncryptResponse; +use Google\Cloud\Kms\V1\RestoreCryptoKeyVersionRequest; +use Google\Cloud\Kms\V1\UpdateCryptoKeyPrimaryVersionRequest; +use Google\Cloud\Kms\V1\UpdateCryptoKeyRequest; +use Google\Cloud\Kms\V1\UpdateCryptoKeyVersionRequest; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Google Cloud Key Management Service * - * This class is currently experimental and may be subject to changes. + * Manages cryptographic keys and operations using those keys. Implements a REST + * model with the following objects: + * + * * [KeyRing][google.cloud.kms.v1.KeyRing] + * * [CryptoKey][google.cloud.kms.v1.CryptoKey] + * * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] + * * [ImportJob][google.cloud.kms.v1.ImportJob] + * + * If you are using manual gRPC libraries, see + * [Using gRPC with Cloud KMS](https://cloud.google.com/kms/docs/grpc). + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Kms\V1\KeyManagementServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface asymmetricDecryptAsync(AsymmetricDecryptRequest $request, array $optionalArgs = []) + * @method PromiseInterface asymmetricSignAsync(AsymmetricSignRequest $request, array $optionalArgs = []) + * @method PromiseInterface createCryptoKeyAsync(CreateCryptoKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface createCryptoKeyVersionAsync(CreateCryptoKeyVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface createImportJobAsync(CreateImportJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface createKeyRingAsync(CreateKeyRingRequest $request, array $optionalArgs = []) + * @method PromiseInterface decryptAsync(DecryptRequest $request, array $optionalArgs = []) + * @method PromiseInterface destroyCryptoKeyVersionAsync(DestroyCryptoKeyVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface encryptAsync(EncryptRequest $request, array $optionalArgs = []) + * @method PromiseInterface generateRandomBytesAsync(GenerateRandomBytesRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCryptoKeyAsync(GetCryptoKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCryptoKeyVersionAsync(GetCryptoKeyVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getImportJobAsync(GetImportJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getKeyRingAsync(GetKeyRingRequest $request, array $optionalArgs = []) + * @method PromiseInterface getPublicKeyAsync(GetPublicKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface importCryptoKeyVersionAsync(ImportCryptoKeyVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCryptoKeyVersionsAsync(ListCryptoKeyVersionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCryptoKeysAsync(ListCryptoKeysRequest $request, array $optionalArgs = []) + * @method PromiseInterface listImportJobsAsync(ListImportJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listKeyRingsAsync(ListKeyRingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface macSignAsync(MacSignRequest $request, array $optionalArgs = []) + * @method PromiseInterface macVerifyAsync(MacVerifyRequest $request, array $optionalArgs = []) + * @method PromiseInterface rawDecryptAsync(RawDecryptRequest $request, array $optionalArgs = []) + * @method PromiseInterface rawEncryptAsync(RawEncryptRequest $request, array $optionalArgs = []) + * @method PromiseInterface restoreCryptoKeyVersionAsync(RestoreCryptoKeyVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCryptoKeyAsync(UpdateCryptoKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCryptoKeyPrimaryVersionAsync(UpdateCryptoKeyPrimaryVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCryptoKeyVersionAsync(UpdateCryptoKeyVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class KeyManagementServiceClient extends KeyManagementServiceBaseClient +final class KeyManagementServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see KeyManagementServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.kms.v1.KeyManagementService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudkms.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloudkms', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/key_management_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/key_management_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/key_management_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/key_management_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a crypto_key + * resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * + * @return string The formatted crypto_key resource. + */ + public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string + { + return self::getPathTemplate('cryptoKey')->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'crypto_key' => $cryptoKey, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * crypto_key_version resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * @param string $cryptoKeyVersion + * + * @return string The formatted crypto_key_version resource. + */ + public static function cryptoKeyVersionName(string $project, string $location, string $keyRing, string $cryptoKey, string $cryptoKeyVersion): string + { + return self::getPathTemplate('cryptoKeyVersion')->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'crypto_key' => $cryptoKey, + 'crypto_key_version' => $cryptoKeyVersion, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a import_job + * resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $importJob + * + * @return string The formatted import_job resource. + */ + public static function importJobName(string $project, string $location, string $keyRing, string $importJob): string + { + return self::getPathTemplate('importJob')->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'import_job' => $importJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a key_ring + * resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * + * @return string The formatted key_ring resource. + */ + public static function keyRingName(string $project, string $location, string $keyRing): string + { + return self::getPathTemplate('keyRing')->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} + * - cryptoKeyVersion: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version} + * - importJob: projects/{project}/locations/{location}/keyRings/{key_ring}/importJobs/{import_job} + * - keyRing: projects/{project}/locations/{location}/keyRings/{key_ring} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudkms.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Decrypts data that was encrypted with a public key retrieved from + * [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey] + * corresponding to a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] + * with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] + * ASYMMETRIC_DECRYPT. + * + * The async variant is {@see KeyManagementServiceClient::asymmetricDecryptAsync()} + * . + * + * @param AsymmetricDecryptRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AsymmetricDecryptResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function asymmetricDecrypt(AsymmetricDecryptRequest $request, array $callOptions = []): AsymmetricDecryptResponse + { + return $this->startApiCall('AsymmetricDecrypt', $request, $callOptions)->wait(); + } + + /** + * Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] + * with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] + * ASYMMETRIC_SIGN, producing a signature that can be verified with the public + * key retrieved from + * [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey]. + * + * The async variant is {@see KeyManagementServiceClient::asymmetricSignAsync()} . + * + * @param AsymmetricSignRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AsymmetricSignResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function asymmetricSign(AsymmetricSignRequest $request, array $callOptions = []): AsymmetricSignResponse + { + return $this->startApiCall('AsymmetricSign', $request, $callOptions)->wait(); + } + + /** + * Create a new [CryptoKey][google.cloud.kms.v1.CryptoKey] within a + * [KeyRing][google.cloud.kms.v1.KeyRing]. + * + * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] and + * [CryptoKey.version_template.algorithm][google.cloud.kms.v1.CryptoKeyVersionTemplate.algorithm] + * are required. + * + * The async variant is {@see KeyManagementServiceClient::createCryptoKeyAsync()} . + * + * @param CreateCryptoKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CryptoKey + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCryptoKey(CreateCryptoKeyRequest $request, array $callOptions = []): CryptoKey + { + return $this->startApiCall('CreateCryptoKey', $request, $callOptions)->wait(); + } + + /** + * Create a new [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in a + * [CryptoKey][google.cloud.kms.v1.CryptoKey]. + * + * The server will assign the next sequential id. If unset, + * [state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to + * [ENABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.ENABLED]. + * + * The async variant is + * {@see KeyManagementServiceClient::createCryptoKeyVersionAsync()} . + * + * @param CreateCryptoKeyVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CryptoKeyVersion + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCryptoKeyVersion(CreateCryptoKeyVersionRequest $request, array $callOptions = []): CryptoKeyVersion + { + return $this->startApiCall('CreateCryptoKeyVersion', $request, $callOptions)->wait(); + } + + /** + * Create a new [ImportJob][google.cloud.kms.v1.ImportJob] within a + * [KeyRing][google.cloud.kms.v1.KeyRing]. + * + * [ImportJob.import_method][google.cloud.kms.v1.ImportJob.import_method] is + * required. + * + * The async variant is {@see KeyManagementServiceClient::createImportJobAsync()} . + * + * @param CreateImportJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ImportJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function createImportJob(CreateImportJobRequest $request, array $callOptions = []): ImportJob + { + return $this->startApiCall('CreateImportJob', $request, $callOptions)->wait(); + } + + /** + * Create a new [KeyRing][google.cloud.kms.v1.KeyRing] in a given Project and + * Location. + * + * The async variant is {@see KeyManagementServiceClient::createKeyRingAsync()} . + * + * @param CreateKeyRingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 KeyRing + * + * @throws ApiException Thrown if the API call fails. + */ + public function createKeyRing(CreateKeyRingRequest $request, array $callOptions = []): KeyRing + { + return $this->startApiCall('CreateKeyRing', $request, $callOptions)->wait(); + } + + /** + * Decrypts data that was protected by + * [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt]. The + * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be + * [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT]. + * + * The async variant is {@see KeyManagementServiceClient::decryptAsync()} . + * + * @param DecryptRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DecryptResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function decrypt(DecryptRequest $request, array $callOptions = []): DecryptResponse + { + return $this->startApiCall('Decrypt', $request, $callOptions)->wait(); + } + + /** + * Schedule a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] for + * destruction. + * + * Upon calling this method, + * [CryptoKeyVersion.state][google.cloud.kms.v1.CryptoKeyVersion.state] will + * be set to + * [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED], + * and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will + * be set to the time + * [destroy_scheduled_duration][google.cloud.kms.v1.CryptoKey.destroy_scheduled_duration] + * in the future. At that time, the + * [state][google.cloud.kms.v1.CryptoKeyVersion.state] will automatically + * change to + * [DESTROYED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROYED], + * and the key material will be irrevocably destroyed. + * + * Before the + * [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] is + * reached, + * [RestoreCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.RestoreCryptoKeyVersion] + * may be called to reverse the process. + * + * The async variant is + * {@see KeyManagementServiceClient::destroyCryptoKeyVersionAsync()} . + * + * @param DestroyCryptoKeyVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CryptoKeyVersion + * + * @throws ApiException Thrown if the API call fails. + */ + public function destroyCryptoKeyVersion(DestroyCryptoKeyVersionRequest $request, array $callOptions = []): CryptoKeyVersion + { + return $this->startApiCall('DestroyCryptoKeyVersion', $request, $callOptions)->wait(); + } + + /** + * Encrypts data, so that it can only be recovered by a call to + * [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt]. The + * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be + * [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT]. + * + * The async variant is {@see KeyManagementServiceClient::encryptAsync()} . + * + * @param EncryptRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 EncryptResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function encrypt(EncryptRequest $request, array $callOptions = []): EncryptResponse + { + return $this->startApiCall('Encrypt', $request, $callOptions)->wait(); + } + + /** + * Generate random bytes using the Cloud KMS randomness source in the provided + * location. + * + * The async variant is + * {@see KeyManagementServiceClient::generateRandomBytesAsync()} . + * + * @param GenerateRandomBytesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GenerateRandomBytesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function generateRandomBytes(GenerateRandomBytesRequest $request, array $callOptions = []): GenerateRandomBytesResponse + { + return $this->startApiCall('GenerateRandomBytes', $request, $callOptions)->wait(); + } + + /** + * Returns metadata for a given [CryptoKey][google.cloud.kms.v1.CryptoKey], as + * well as its [primary][google.cloud.kms.v1.CryptoKey.primary] + * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]. + * + * The async variant is {@see KeyManagementServiceClient::getCryptoKeyAsync()} . + * + * @param GetCryptoKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CryptoKey + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCryptoKey(GetCryptoKeyRequest $request, array $callOptions = []): CryptoKey + { + return $this->startApiCall('GetCryptoKey', $request, $callOptions)->wait(); + } + + /** + * Returns metadata for a given + * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]. + * + * The async variant is + * {@see KeyManagementServiceClient::getCryptoKeyVersionAsync()} . + * + * @param GetCryptoKeyVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CryptoKeyVersion + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCryptoKeyVersion(GetCryptoKeyVersionRequest $request, array $callOptions = []): CryptoKeyVersion + { + return $this->startApiCall('GetCryptoKeyVersion', $request, $callOptions)->wait(); + } + + /** + * Returns metadata for a given [ImportJob][google.cloud.kms.v1.ImportJob]. + * + * The async variant is {@see KeyManagementServiceClient::getImportJobAsync()} . + * + * @param GetImportJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ImportJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function getImportJob(GetImportJobRequest $request, array $callOptions = []): ImportJob + { + return $this->startApiCall('GetImportJob', $request, $callOptions)->wait(); + } + + /** + * Returns metadata for a given [KeyRing][google.cloud.kms.v1.KeyRing]. + * + * The async variant is {@see KeyManagementServiceClient::getKeyRingAsync()} . + * + * @param GetKeyRingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 KeyRing + * + * @throws ApiException Thrown if the API call fails. + */ + public function getKeyRing(GetKeyRingRequest $request, array $callOptions = []): KeyRing + { + return $this->startApiCall('GetKeyRing', $request, $callOptions)->wait(); + } + + /** + * Returns the public key for the given + * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]. The + * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be + * [ASYMMETRIC_SIGN][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_SIGN] + * or + * [ASYMMETRIC_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_DECRYPT]. + * + * The async variant is {@see KeyManagementServiceClient::getPublicKeyAsync()} . + * + * @param GetPublicKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PublicKey + * + * @throws ApiException Thrown if the API call fails. + */ + public function getPublicKey(GetPublicKeyRequest $request, array $callOptions = []): PublicKey + { + return $this->startApiCall('GetPublicKey', $request, $callOptions)->wait(); + } + + /** + * Import wrapped key material into a + * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]. + * + * All requests must specify a [CryptoKey][google.cloud.kms.v1.CryptoKey]. If + * a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] is additionally + * specified in the request, key material will be reimported into that + * version. Otherwise, a new version will be created, and will be assigned the + * next sequential id within the [CryptoKey][google.cloud.kms.v1.CryptoKey]. + * + * The async variant is + * {@see KeyManagementServiceClient::importCryptoKeyVersionAsync()} . + * + * @param ImportCryptoKeyVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CryptoKeyVersion + * + * @throws ApiException Thrown if the API call fails. + */ + public function importCryptoKeyVersion(ImportCryptoKeyVersionRequest $request, array $callOptions = []): CryptoKeyVersion + { + return $this->startApiCall('ImportCryptoKeyVersion', $request, $callOptions)->wait(); + } + + /** + * Lists [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion]. + * + * The async variant is + * {@see KeyManagementServiceClient::listCryptoKeyVersionsAsync()} . + * + * @param ListCryptoKeyVersionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCryptoKeyVersions(ListCryptoKeyVersionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCryptoKeyVersions', $request, $callOptions); + } + + /** + * Lists [CryptoKeys][google.cloud.kms.v1.CryptoKey]. + * + * The async variant is {@see KeyManagementServiceClient::listCryptoKeysAsync()} . + * + * @param ListCryptoKeysRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCryptoKeys(ListCryptoKeysRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCryptoKeys', $request, $callOptions); + } + + /** + * Lists [ImportJobs][google.cloud.kms.v1.ImportJob]. + * + * The async variant is {@see KeyManagementServiceClient::listImportJobsAsync()} . + * + * @param ListImportJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listImportJobs(ListImportJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListImportJobs', $request, $callOptions); + } + + /** + * Lists [KeyRings][google.cloud.kms.v1.KeyRing]. + * + * The async variant is {@see KeyManagementServiceClient::listKeyRingsAsync()} . + * + * @param ListKeyRingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listKeyRings(ListKeyRingsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListKeyRings', $request, $callOptions); + } + + /** + * Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] + * with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] MAC, + * producing a tag that can be verified by another source with the same key. + * + * The async variant is {@see KeyManagementServiceClient::macSignAsync()} . + * + * @param MacSignRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MacSignResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function macSign(MacSignRequest $request, array $callOptions = []): MacSignResponse + { + return $this->startApiCall('MacSign', $request, $callOptions)->wait(); + } + + /** + * Verifies MAC tag using a + * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with + * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] MAC, and returns + * a response that indicates whether or not the verification was successful. + * + * The async variant is {@see KeyManagementServiceClient::macVerifyAsync()} . + * + * @param MacVerifyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MacVerifyResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function macVerify(MacVerifyRequest $request, array $callOptions = []): MacVerifyResponse + { + return $this->startApiCall('MacVerify', $request, $callOptions)->wait(); + } + + /** + * Decrypts data that was originally encrypted using a raw cryptographic + * mechanism. The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] + * must be + * [RAW_ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.RAW_ENCRYPT_DECRYPT]. + * + * The async variant is {@see KeyManagementServiceClient::rawDecryptAsync()} . + * + * @param RawDecryptRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RawDecryptResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function rawDecrypt(RawDecryptRequest $request, array $callOptions = []): RawDecryptResponse + { + return $this->startApiCall('RawDecrypt', $request, $callOptions)->wait(); + } + + /** + * Encrypts data using portable cryptographic primitives. Most users should + * choose [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt] and + * [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt] rather than + * their raw counterparts. The + * [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be + * [RAW_ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.RAW_ENCRYPT_DECRYPT]. + * + * The async variant is {@see KeyManagementServiceClient::rawEncryptAsync()} . + * + * @param RawEncryptRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RawEncryptResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function rawEncrypt(RawEncryptRequest $request, array $callOptions = []): RawEncryptResponse + { + return $this->startApiCall('RawEncrypt', $request, $callOptions)->wait(); + } + + /** + * Restore a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in the + * [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED] + * state. + * + * Upon restoration of the CryptoKeyVersion, + * [state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to + * [DISABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED], + * and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will + * be cleared. + * + * The async variant is + * {@see KeyManagementServiceClient::restoreCryptoKeyVersionAsync()} . + * + * @param RestoreCryptoKeyVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CryptoKeyVersion + * + * @throws ApiException Thrown if the API call fails. + */ + public function restoreCryptoKeyVersion(RestoreCryptoKeyVersionRequest $request, array $callOptions = []): CryptoKeyVersion + { + return $this->startApiCall('RestoreCryptoKeyVersion', $request, $callOptions)->wait(); + } + + /** + * Update a [CryptoKey][google.cloud.kms.v1.CryptoKey]. + * + * The async variant is {@see KeyManagementServiceClient::updateCryptoKeyAsync()} . + * + * @param UpdateCryptoKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CryptoKey + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCryptoKey(UpdateCryptoKeyRequest $request, array $callOptions = []): CryptoKey + { + return $this->startApiCall('UpdateCryptoKey', $request, $callOptions)->wait(); + } + + /** + * Update the version of a [CryptoKey][google.cloud.kms.v1.CryptoKey] that + * will be used in + * [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt]. + * + * Returns an error if called on a key whose purpose is not + * [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT]. + * + * The async variant is + * {@see KeyManagementServiceClient::updateCryptoKeyPrimaryVersionAsync()} . + * + * @param UpdateCryptoKeyPrimaryVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CryptoKey + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCryptoKeyPrimaryVersion(UpdateCryptoKeyPrimaryVersionRequest $request, array $callOptions = []): CryptoKey + { + return $this->startApiCall('UpdateCryptoKeyPrimaryVersion', $request, $callOptions)->wait(); + } + + /** + * Update a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]'s + * metadata. + * + * [state][google.cloud.kms.v1.CryptoKeyVersion.state] may be changed between + * [ENABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.ENABLED] + * and + * [DISABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED] + * using this method. See + * [DestroyCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.DestroyCryptoKeyVersion] + * and + * [RestoreCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.RestoreCryptoKeyVersion] + * to move between other states. + * + * The async variant is + * {@see KeyManagementServiceClient::updateCryptoKeyVersionAsync()} . + * + * @param UpdateCryptoKeyVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CryptoKeyVersion + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCryptoKeyVersion(UpdateCryptoKeyVersionRequest $request, array $callOptions = []): CryptoKeyVersion + { + return $this->startApiCall('UpdateCryptoKeyVersion', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see KeyManagementServiceClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see KeyManagementServiceClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see KeyManagementServiceClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see KeyManagementServiceClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is + * {@see KeyManagementServiceClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/KmsInventory/composer.json b/KmsInventory/composer.json index a51fb36ba74a..6a1efcbffddd 100644 --- a/KmsInventory/composer.json +++ b/KmsInventory/composer.json @@ -18,7 +18,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1", + "google/gax": "^1.24.0", "google/cloud-kms": "^1.15" }, "require-dev": { diff --git a/KmsInventory/src/V1/Client/BaseClient/KeyDashboardServiceBaseClient.php b/KmsInventory/src/V1/Client/BaseClient/KeyDashboardServiceBaseClient.php deleted file mode 100644 index 56808b74e7f4..000000000000 --- a/KmsInventory/src/V1/Client/BaseClient/KeyDashboardServiceBaseClient.php +++ /dev/null @@ -1,238 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/key_dashboard_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/key_dashboard_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/key_dashboard_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/key_dashboard_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->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. - */ - public static function parseName(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'kmsinventory.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Returns cryptographic keys managed by Cloud KMS in a given Cloud project. - * Note that this data is sourced from snapshots, meaning it may not - * completely reflect the actual state of key metadata at call time. - * - * The async variant is {@see self::listCryptoKeysAsync()} . - * - * @example samples/V1/KeyDashboardServiceClient/list_crypto_keys.php - * - * @param ListCryptoKeysRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCryptoKeys(ListCryptoKeysRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCryptoKeys', $request, $callOptions); - } -} diff --git a/KmsInventory/src/V1/Client/BaseClient/KeyTrackingServiceBaseClient.php b/KmsInventory/src/V1/Client/BaseClient/KeyTrackingServiceBaseClient.php deleted file mode 100644 index e1fc3f720539..000000000000 --- a/KmsInventory/src/V1/Client/BaseClient/KeyTrackingServiceBaseClient.php +++ /dev/null @@ -1,340 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/key_tracking_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/key_tracking_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/key_tracking_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/key_tracking_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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(string $organization): string - { - return self::getPathTemplate('organization')->render([ - 'organization' => $organization, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_key_ring_crypto_key_crypto_key_version_protectedResourcesSummary - * resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * @param string $cryptoKey - * @param string $cryptoKeyVersion - * - * @return string The formatted project_location_key_ring_crypto_key_crypto_key_version_protectedResourcesSummary resource. - */ - public static function projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName(string $project, string $location, string $keyRing, string $cryptoKey, string $cryptoKeyVersion): string - { - return self::getPathTemplate('projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummary')->render([ - 'project' => $project, - 'location' => $location, - 'key_ring' => $keyRing, - 'crypto_key' => $cryptoKey, - 'crypto_key_version' => $cryptoKeyVersion, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_key_ring_crypto_key_protectedResourcesSummary resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * @param string $cryptoKey - * - * @return string The formatted project_location_key_ring_crypto_key_protectedResourcesSummary resource. - */ - public static function projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName(string $project, string $location, string $keyRing, string $cryptoKey): string - { - return self::getPathTemplate('projectLocationKeyRingCryptoKeyProtectedResourcesSummary')->render([ - 'project' => $project, - 'location' => $location, - 'key_ring' => $keyRing, - 'crypto_key' => $cryptoKey, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * protected_resources_summary resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * @param string $cryptoKey - * - * @return string The formatted protected_resources_summary resource. - */ - public static function protectedResourcesSummaryName(string $project, string $location, string $keyRing, string $cryptoKey): string - { - return self::getPathTemplate('protectedResourcesSummary')->render([ - 'project' => $project, - 'location' => $location, - 'key_ring' => $keyRing, - 'crypto_key' => $cryptoKey, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - organization: organizations/{organization} - * - projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummary: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}/protectedResourcesSummary - * - projectLocationKeyRingCryptoKeyProtectedResourcesSummary: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/protectedResourcesSummary - * - protectedResourcesSummary: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/protectedResourcesSummary - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'kmsinventory.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Returns aggregate information about the resources protected by the given - * Cloud KMS [CryptoKey][google.cloud.kms.v1.CryptoKey]. Only resources within - * the same Cloud organization as the key will be returned. The project that - * holds the key must be part of an organization in order for this call to - * succeed. - * - * The async variant is {@see self::getProtectedResourcesSummaryAsync()} . - * - * @example samples/V1/KeyTrackingServiceClient/get_protected_resources_summary.php - * - * @param GetProtectedResourcesSummaryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ProtectedResourcesSummary - * - * @throws ApiException Thrown if the API call fails. - */ - public function getProtectedResourcesSummary(GetProtectedResourcesSummaryRequest $request, array $callOptions = []): ProtectedResourcesSummary - { - return $this->startApiCall('GetProtectedResourcesSummary', $request, $callOptions)->wait(); - } - - /** - * Returns metadata about the resources protected by the given Cloud KMS - * [CryptoKey][google.cloud.kms.v1.CryptoKey] in the given Cloud organization. - * - * The async variant is {@see self::searchProtectedResourcesAsync()} . - * - * @example samples/V1/KeyTrackingServiceClient/search_protected_resources.php - * - * @param SearchProtectedResourcesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchProtectedResources(SearchProtectedResourcesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchProtectedResources', $request, $callOptions); - } -} diff --git a/KmsInventory/src/V1/Client/KeyDashboardServiceClient.php b/KmsInventory/src/V1/Client/KeyDashboardServiceClient.php index c13e04007ebd..7d94a42b7132 100644 --- a/KmsInventory/src/V1/Client/KeyDashboardServiceClient.php +++ b/KmsInventory/src/V1/Client/KeyDashboardServiceClient.php @@ -24,17 +24,213 @@ namespace Google\Cloud\Kms\Inventory\V1\Client; -use Google\Cloud\Kms\Inventory\V1\Client\BaseClient\KeyDashboardServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Kms\Inventory\V1\ListCryptoKeysRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Provides a cross-region view of all Cloud KMS keys in a given Cloud project. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Kms\Inventory\V1\KeyDashboardServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface listCryptoKeysAsync(ListCryptoKeysRequest $request, array $optionalArgs = []) */ -final class KeyDashboardServiceClient extends KeyDashboardServiceBaseClient +final class KeyDashboardServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see KeyDashboardServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.kms.inventory.v1.KeyDashboardService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'kmsinventory.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/key_dashboard_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/key_dashboard_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/key_dashboard_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/key_dashboard_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->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. + */ + public static function parseName(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'kmsinventory.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Returns cryptographic keys managed by Cloud KMS in a given Cloud project. + * Note that this data is sourced from snapshots, meaning it may not + * completely reflect the actual state of key metadata at call time. + * + * The async variant is {@see KeyDashboardServiceClient::listCryptoKeysAsync()} . + * + * @example samples/V1/KeyDashboardServiceClient/list_crypto_keys.php + * + * @param ListCryptoKeysRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCryptoKeys(ListCryptoKeysRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCryptoKeys', $request, $callOptions); + } } diff --git a/KmsInventory/src/V1/Client/KeyTrackingServiceClient.php b/KmsInventory/src/V1/Client/KeyTrackingServiceClient.php index a1f959557838..56575d7b5d67 100644 --- a/KmsInventory/src/V1/Client/KeyTrackingServiceClient.php +++ b/KmsInventory/src/V1/Client/KeyTrackingServiceClient.php @@ -24,17 +24,317 @@ namespace Google\Cloud\Kms\Inventory\V1\Client; -use Google\Cloud\Kms\Inventory\V1\Client\BaseClient\KeyTrackingServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Kms\Inventory\V1\GetProtectedResourcesSummaryRequest; +use Google\Cloud\Kms\Inventory\V1\ProtectedResourcesSummary; +use Google\Cloud\Kms\Inventory\V1\SearchProtectedResourcesRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Returns information about the resources in an org that are protected by a + * given Cloud KMS key via CMEK. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Kms\Inventory\V1\KeyTrackingServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface getProtectedResourcesSummaryAsync(GetProtectedResourcesSummaryRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchProtectedResourcesAsync(SearchProtectedResourcesRequest $request, array $optionalArgs = []) */ -final class KeyTrackingServiceClient extends KeyTrackingServiceBaseClient +final class KeyTrackingServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see KeyTrackingServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.kms.inventory.v1.KeyTrackingService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'kmsinventory.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/key_tracking_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/key_tracking_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/key_tracking_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/key_tracking_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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(string $organization): string + { + return self::getPathTemplate('organization')->render([ + 'organization' => $organization, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_key_ring_crypto_key_crypto_key_version_protectedResourcesSummary + * resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * @param string $cryptoKeyVersion + * + * @return string The formatted project_location_key_ring_crypto_key_crypto_key_version_protectedResourcesSummary resource. + */ + public static function projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName(string $project, string $location, string $keyRing, string $cryptoKey, string $cryptoKeyVersion): string + { + return self::getPathTemplate('projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummary')->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'crypto_key' => $cryptoKey, + 'crypto_key_version' => $cryptoKeyVersion, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_key_ring_crypto_key_protectedResourcesSummary resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * + * @return string The formatted project_location_key_ring_crypto_key_protectedResourcesSummary resource. + */ + public static function projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName(string $project, string $location, string $keyRing, string $cryptoKey): string + { + return self::getPathTemplate('projectLocationKeyRingCryptoKeyProtectedResourcesSummary')->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'crypto_key' => $cryptoKey, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * protected_resources_summary resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * + * @return string The formatted protected_resources_summary resource. + */ + public static function protectedResourcesSummaryName(string $project, string $location, string $keyRing, string $cryptoKey): string + { + return self::getPathTemplate('protectedResourcesSummary')->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'crypto_key' => $cryptoKey, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - organization: organizations/{organization} + * - projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummary: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}/protectedResourcesSummary + * - projectLocationKeyRingCryptoKeyProtectedResourcesSummary: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/protectedResourcesSummary + * - protectedResourcesSummary: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/protectedResourcesSummary + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'kmsinventory.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Returns aggregate information about the resources protected by the given + * Cloud KMS [CryptoKey][google.cloud.kms.v1.CryptoKey]. Only resources within + * the same Cloud organization as the key will be returned. The project that + * holds the key must be part of an organization in order for this call to + * succeed. + * + * The async variant is + * {@see KeyTrackingServiceClient::getProtectedResourcesSummaryAsync()} . + * + * @example samples/V1/KeyTrackingServiceClient/get_protected_resources_summary.php + * + * @param GetProtectedResourcesSummaryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ProtectedResourcesSummary + * + * @throws ApiException Thrown if the API call fails. + */ + public function getProtectedResourcesSummary(GetProtectedResourcesSummaryRequest $request, array $callOptions = []): ProtectedResourcesSummary + { + return $this->startApiCall('GetProtectedResourcesSummary', $request, $callOptions)->wait(); + } + + /** + * Returns metadata about the resources protected by the given Cloud KMS + * [CryptoKey][google.cloud.kms.v1.CryptoKey] in the given Cloud organization. + * + * The async variant is + * {@see KeyTrackingServiceClient::searchProtectedResourcesAsync()} . + * + * @example samples/V1/KeyTrackingServiceClient/search_protected_resources.php + * + * @param SearchProtectedResourcesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchProtectedResources(SearchProtectedResourcesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchProtectedResources', $request, $callOptions); + } } diff --git a/Language/composer.json b/Language/composer.json index dad7cfdb7442..4deb31e27581 100644 --- a/Language/composer.json +++ b/Language/composer.json @@ -5,8 +5,8 @@ "minimum-stability": "stable", "require": { "php": ">=7.4", - "google/cloud-core": "^1.39", - "google/gax": "^1.19.1" + "google/cloud-core": "^1.52.7", + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", diff --git a/Language/src/V1/Client/BaseClient/LanguageServiceBaseClient.php b/Language/src/V1/Client/BaseClient/LanguageServiceBaseClient.php deleted file mode 100644 index ea6ddcab161e..000000000000 --- a/Language/src/V1/Client/BaseClient/LanguageServiceBaseClient.php +++ /dev/null @@ -1,373 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/language_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/language_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/language_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/language_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'language.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Finds named entities (currently proper names and common nouns) in the text - * along with entity types, salience, mentions for each entity, and - * other properties. - * - * The async variant is {@see self::analyzeEntitiesAsync()} . - * - * @example samples/V1/LanguageServiceClient/analyze_entities.php - * - * @param AnalyzeEntitiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AnalyzeEntitiesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function analyzeEntities(AnalyzeEntitiesRequest $request, array $callOptions = []): AnalyzeEntitiesResponse - { - return $this->startApiCall('AnalyzeEntities', $request, $callOptions)->wait(); - } - - /** - * Finds entities, similar to - * [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities] - * in the text and analyzes sentiment associated with each entity and its - * mentions. - * - * The async variant is {@see self::analyzeEntitySentimentAsync()} . - * - * @example samples/V1/LanguageServiceClient/analyze_entity_sentiment.php - * - * @param AnalyzeEntitySentimentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AnalyzeEntitySentimentResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function analyzeEntitySentiment(AnalyzeEntitySentimentRequest $request, array $callOptions = []): AnalyzeEntitySentimentResponse - { - return $this->startApiCall('AnalyzeEntitySentiment', $request, $callOptions)->wait(); - } - - /** - * Analyzes the sentiment of the provided text. - * - * The async variant is {@see self::analyzeSentimentAsync()} . - * - * @example samples/V1/LanguageServiceClient/analyze_sentiment.php - * - * @param AnalyzeSentimentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AnalyzeSentimentResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function analyzeSentiment(AnalyzeSentimentRequest $request, array $callOptions = []): AnalyzeSentimentResponse - { - return $this->startApiCall('AnalyzeSentiment', $request, $callOptions)->wait(); - } - - /** - * Analyzes the syntax of the text and provides sentence boundaries and - * tokenization along with part of speech tags, dependency trees, and other - * properties. - * - * The async variant is {@see self::analyzeSyntaxAsync()} . - * - * @example samples/V1/LanguageServiceClient/analyze_syntax.php - * - * @param AnalyzeSyntaxRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AnalyzeSyntaxResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function analyzeSyntax(AnalyzeSyntaxRequest $request, array $callOptions = []): AnalyzeSyntaxResponse - { - return $this->startApiCall('AnalyzeSyntax', $request, $callOptions)->wait(); - } - - /** - * A convenience method that provides all the features that analyzeSentiment, - * analyzeEntities, and analyzeSyntax provide in one call. - * - * The async variant is {@see self::annotateTextAsync()} . - * - * @example samples/V1/LanguageServiceClient/annotate_text.php - * - * @param AnnotateTextRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AnnotateTextResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function annotateText(AnnotateTextRequest $request, array $callOptions = []): AnnotateTextResponse - { - return $this->startApiCall('AnnotateText', $request, $callOptions)->wait(); - } - - /** - * Classifies a document into categories. - * - * The async variant is {@see self::classifyTextAsync()} . - * - * @example samples/V1/LanguageServiceClient/classify_text.php - * - * @param ClassifyTextRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ClassifyTextResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function classifyText(ClassifyTextRequest $request, array $callOptions = []): ClassifyTextResponse - { - return $this->startApiCall('ClassifyText', $request, $callOptions)->wait(); - } - - /** - * Moderates a document for harmful and sensitive categories. - * - * The async variant is {@see self::moderateTextAsync()} . - * - * @example samples/V1/LanguageServiceClient/moderate_text.php - * - * @param ModerateTextRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ModerateTextResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function moderateText(ModerateTextRequest $request, array $callOptions = []): ModerateTextResponse - { - return $this->startApiCall('ModerateText', $request, $callOptions)->wait(); - } -} diff --git a/Language/src/V1/Client/LanguageServiceClient.php b/Language/src/V1/Client/LanguageServiceClient.php index ea36ac6cff22..d44904f0412d 100644 --- a/Language/src/V1/Client/LanguageServiceClient.php +++ b/Language/src/V1/Client/LanguageServiceClient.php @@ -24,17 +24,349 @@ namespace Google\Cloud\Language\V1\Client; -use Google\Cloud\Language\V1\Client\BaseClient\LanguageServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Language\V1\AnalyzeEntitiesRequest; +use Google\Cloud\Language\V1\AnalyzeEntitiesResponse; +use Google\Cloud\Language\V1\AnalyzeEntitySentimentRequest; +use Google\Cloud\Language\V1\AnalyzeEntitySentimentResponse; +use Google\Cloud\Language\V1\AnalyzeSentimentRequest; +use Google\Cloud\Language\V1\AnalyzeSentimentResponse; +use Google\Cloud\Language\V1\AnalyzeSyntaxRequest; +use Google\Cloud\Language\V1\AnalyzeSyntaxResponse; +use Google\Cloud\Language\V1\AnnotateTextRequest; +use Google\Cloud\Language\V1\AnnotateTextResponse; +use Google\Cloud\Language\V1\ClassifyTextRequest; +use Google\Cloud\Language\V1\ClassifyTextResponse; +use Google\Cloud\Language\V1\ModerateTextRequest; +use Google\Cloud\Language\V1\ModerateTextResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Provides text analysis operations such as sentiment analysis and entity + * recognition. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Language\V1\LanguageServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface analyzeEntitiesAsync(AnalyzeEntitiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface analyzeEntitySentimentAsync(AnalyzeEntitySentimentRequest $request, array $optionalArgs = []) + * @method PromiseInterface analyzeSentimentAsync(AnalyzeSentimentRequest $request, array $optionalArgs = []) + * @method PromiseInterface analyzeSyntaxAsync(AnalyzeSyntaxRequest $request, array $optionalArgs = []) + * @method PromiseInterface annotateTextAsync(AnnotateTextRequest $request, array $optionalArgs = []) + * @method PromiseInterface classifyTextAsync(ClassifyTextRequest $request, array $optionalArgs = []) + * @method PromiseInterface moderateTextAsync(ModerateTextRequest $request, array $optionalArgs = []) */ -final class LanguageServiceClient extends LanguageServiceBaseClient +final class LanguageServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see LanguageServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.language.v1.LanguageService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'language.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-language', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/language_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/language_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/language_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/language_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'language.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Finds named entities (currently proper names and common nouns) in the text + * along with entity types, salience, mentions for each entity, and + * other properties. + * + * The async variant is {@see LanguageServiceClient::analyzeEntitiesAsync()} . + * + * @example samples/V1/LanguageServiceClient/analyze_entities.php + * + * @param AnalyzeEntitiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AnalyzeEntitiesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function analyzeEntities(AnalyzeEntitiesRequest $request, array $callOptions = []): AnalyzeEntitiesResponse + { + return $this->startApiCall('AnalyzeEntities', $request, $callOptions)->wait(); + } + + /** + * Finds entities, similar to + * [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities] + * in the text and analyzes sentiment associated with each entity and its + * mentions. + * + * The async variant is {@see LanguageServiceClient::analyzeEntitySentimentAsync()} + * . + * + * @example samples/V1/LanguageServiceClient/analyze_entity_sentiment.php + * + * @param AnalyzeEntitySentimentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AnalyzeEntitySentimentResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function analyzeEntitySentiment(AnalyzeEntitySentimentRequest $request, array $callOptions = []): AnalyzeEntitySentimentResponse + { + return $this->startApiCall('AnalyzeEntitySentiment', $request, $callOptions)->wait(); + } + + /** + * Analyzes the sentiment of the provided text. + * + * The async variant is {@see LanguageServiceClient::analyzeSentimentAsync()} . + * + * @example samples/V1/LanguageServiceClient/analyze_sentiment.php + * + * @param AnalyzeSentimentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AnalyzeSentimentResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function analyzeSentiment(AnalyzeSentimentRequest $request, array $callOptions = []): AnalyzeSentimentResponse + { + return $this->startApiCall('AnalyzeSentiment', $request, $callOptions)->wait(); + } + + /** + * Analyzes the syntax of the text and provides sentence boundaries and + * tokenization along with part of speech tags, dependency trees, and other + * properties. + * + * The async variant is {@see LanguageServiceClient::analyzeSyntaxAsync()} . + * + * @example samples/V1/LanguageServiceClient/analyze_syntax.php + * + * @param AnalyzeSyntaxRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AnalyzeSyntaxResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function analyzeSyntax(AnalyzeSyntaxRequest $request, array $callOptions = []): AnalyzeSyntaxResponse + { + return $this->startApiCall('AnalyzeSyntax', $request, $callOptions)->wait(); + } + + /** + * A convenience method that provides all the features that analyzeSentiment, + * analyzeEntities, and analyzeSyntax provide in one call. + * + * The async variant is {@see LanguageServiceClient::annotateTextAsync()} . + * + * @example samples/V1/LanguageServiceClient/annotate_text.php + * + * @param AnnotateTextRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AnnotateTextResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function annotateText(AnnotateTextRequest $request, array $callOptions = []): AnnotateTextResponse + { + return $this->startApiCall('AnnotateText', $request, $callOptions)->wait(); + } + + /** + * Classifies a document into categories. + * + * The async variant is {@see LanguageServiceClient::classifyTextAsync()} . + * + * @example samples/V1/LanguageServiceClient/classify_text.php + * + * @param ClassifyTextRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ClassifyTextResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function classifyText(ClassifyTextRequest $request, array $callOptions = []): ClassifyTextResponse + { + return $this->startApiCall('ClassifyText', $request, $callOptions)->wait(); + } + + /** + * Moderates a document for harmful and sensitive categories. + * + * The async variant is {@see LanguageServiceClient::moderateTextAsync()} . + * + * @example samples/V1/LanguageServiceClient/moderate_text.php + * + * @param ModerateTextRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ModerateTextResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function moderateText(ModerateTextRequest $request, array $callOptions = []): ModerateTextResponse + { + return $this->startApiCall('ModerateText', $request, $callOptions)->wait(); + } } diff --git a/Language/src/V2/Client/BaseClient/LanguageServiceBaseClient.php b/Language/src/V2/Client/BaseClient/LanguageServiceBaseClient.php deleted file mode 100644 index bc2243dc0035..000000000000 --- a/Language/src/V2/Client/BaseClient/LanguageServiceBaseClient.php +++ /dev/null @@ -1,308 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/language_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/language_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/language_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/language_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'language.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Finds named entities (currently proper names and common nouns) in the text - * along with entity types, probability, mentions for each entity, and - * other properties. - * - * The async variant is {@see self::analyzeEntitiesAsync()} . - * - * @example samples/V2/LanguageServiceClient/analyze_entities.php - * - * @param AnalyzeEntitiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AnalyzeEntitiesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function analyzeEntities(AnalyzeEntitiesRequest $request, array $callOptions = []): AnalyzeEntitiesResponse - { - return $this->startApiCall('AnalyzeEntities', $request, $callOptions)->wait(); - } - - /** - * Analyzes the sentiment of the provided text. - * - * The async variant is {@see self::analyzeSentimentAsync()} . - * - * @example samples/V2/LanguageServiceClient/analyze_sentiment.php - * - * @param AnalyzeSentimentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AnalyzeSentimentResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function analyzeSentiment(AnalyzeSentimentRequest $request, array $callOptions = []): AnalyzeSentimentResponse - { - return $this->startApiCall('AnalyzeSentiment', $request, $callOptions)->wait(); - } - - /** - * A convenience method that provides all features in one call. - * - * The async variant is {@see self::annotateTextAsync()} . - * - * @example samples/V2/LanguageServiceClient/annotate_text.php - * - * @param AnnotateTextRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AnnotateTextResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function annotateText(AnnotateTextRequest $request, array $callOptions = []): AnnotateTextResponse - { - return $this->startApiCall('AnnotateText', $request, $callOptions)->wait(); - } - - /** - * Classifies a document into categories. - * - * The async variant is {@see self::classifyTextAsync()} . - * - * @example samples/V2/LanguageServiceClient/classify_text.php - * - * @param ClassifyTextRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ClassifyTextResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function classifyText(ClassifyTextRequest $request, array $callOptions = []): ClassifyTextResponse - { - return $this->startApiCall('ClassifyText', $request, $callOptions)->wait(); - } - - /** - * Moderates a document for harmful and sensitive categories. - * - * The async variant is {@see self::moderateTextAsync()} . - * - * @example samples/V2/LanguageServiceClient/moderate_text.php - * - * @param ModerateTextRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ModerateTextResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function moderateText(ModerateTextRequest $request, array $callOptions = []): ModerateTextResponse - { - return $this->startApiCall('ModerateText', $request, $callOptions)->wait(); - } -} diff --git a/Language/src/V2/Client/LanguageServiceClient.php b/Language/src/V2/Client/LanguageServiceClient.php index d74706a505ae..dba16d7add96 100644 --- a/Language/src/V2/Client/LanguageServiceClient.php +++ b/Language/src/V2/Client/LanguageServiceClient.php @@ -24,17 +24,283 @@ namespace Google\Cloud\Language\V2\Client; -use Google\Cloud\Language\V2\Client\BaseClient\LanguageServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Language\V2\AnalyzeEntitiesRequest; +use Google\Cloud\Language\V2\AnalyzeEntitiesResponse; +use Google\Cloud\Language\V2\AnalyzeSentimentRequest; +use Google\Cloud\Language\V2\AnalyzeSentimentResponse; +use Google\Cloud\Language\V2\AnnotateTextRequest; +use Google\Cloud\Language\V2\AnnotateTextResponse; +use Google\Cloud\Language\V2\ClassifyTextRequest; +use Google\Cloud\Language\V2\ClassifyTextResponse; +use Google\Cloud\Language\V2\ModerateTextRequest; +use Google\Cloud\Language\V2\ModerateTextResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Provides text analysis operations such as sentiment analysis and entity + * recognition. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface analyzeEntitiesAsync(AnalyzeEntitiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface analyzeSentimentAsync(AnalyzeSentimentRequest $request, array $optionalArgs = []) + * @method PromiseInterface annotateTextAsync(AnnotateTextRequest $request, array $optionalArgs = []) + * @method PromiseInterface classifyTextAsync(ClassifyTextRequest $request, array $optionalArgs = []) + * @method PromiseInterface moderateTextAsync(ModerateTextRequest $request, array $optionalArgs = []) */ -final class LanguageServiceClient extends LanguageServiceBaseClient +final class LanguageServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see LanguageServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.language.v2.LanguageService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'language.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-language', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/language_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/language_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/language_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/language_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'language.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Finds named entities (currently proper names and common nouns) in the text + * along with entity types, probability, mentions for each entity, and + * other properties. + * + * The async variant is {@see LanguageServiceClient::analyzeEntitiesAsync()} . + * + * @example samples/V2/LanguageServiceClient/analyze_entities.php + * + * @param AnalyzeEntitiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AnalyzeEntitiesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function analyzeEntities(AnalyzeEntitiesRequest $request, array $callOptions = []): AnalyzeEntitiesResponse + { + return $this->startApiCall('AnalyzeEntities', $request, $callOptions)->wait(); + } + + /** + * Analyzes the sentiment of the provided text. + * + * The async variant is {@see LanguageServiceClient::analyzeSentimentAsync()} . + * + * @example samples/V2/LanguageServiceClient/analyze_sentiment.php + * + * @param AnalyzeSentimentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AnalyzeSentimentResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function analyzeSentiment(AnalyzeSentimentRequest $request, array $callOptions = []): AnalyzeSentimentResponse + { + return $this->startApiCall('AnalyzeSentiment', $request, $callOptions)->wait(); + } + + /** + * A convenience method that provides all features in one call. + * + * The async variant is {@see LanguageServiceClient::annotateTextAsync()} . + * + * @example samples/V2/LanguageServiceClient/annotate_text.php + * + * @param AnnotateTextRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AnnotateTextResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function annotateText(AnnotateTextRequest $request, array $callOptions = []): AnnotateTextResponse + { + return $this->startApiCall('AnnotateText', $request, $callOptions)->wait(); + } + + /** + * Classifies a document into categories. + * + * The async variant is {@see LanguageServiceClient::classifyTextAsync()} . + * + * @example samples/V2/LanguageServiceClient/classify_text.php + * + * @param ClassifyTextRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ClassifyTextResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function classifyText(ClassifyTextRequest $request, array $callOptions = []): ClassifyTextResponse + { + return $this->startApiCall('ClassifyText', $request, $callOptions)->wait(); + } + + /** + * Moderates a document for harmful and sensitive categories. + * + * The async variant is {@see LanguageServiceClient::moderateTextAsync()} . + * + * @example samples/V2/LanguageServiceClient/moderate_text.php + * + * @param ModerateTextRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ModerateTextResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function moderateText(ModerateTextRequest $request, array $callOptions = []): ModerateTextResponse + { + return $this->startApiCall('ModerateText', $request, $callOptions)->wait(); + } } diff --git a/LifeSciences/composer.json b/LifeSciences/composer.json index 7e8b2974620d..9d2911097097 100644 --- a/LifeSciences/composer.json +++ b/LifeSciences/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/LifeSciences/src/V2beta/Client/BaseClient/WorkflowsServiceV2BetaBaseClient.php b/LifeSciences/src/V2beta/Client/BaseClient/WorkflowsServiceV2BetaBaseClient.php deleted file mode 100644 index e58f19603b06..000000000000 --- a/LifeSciences/src/V2beta/Client/BaseClient/WorkflowsServiceV2BetaBaseClient.php +++ /dev/null @@ -1,313 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/workflows_service_v2_beta_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/workflows_service_v2_beta_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/workflows_service_v2_beta_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/workflows_service_v2_beta_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - * - * @experimental - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - * - * @experimental - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'lifesciences.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); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Runs a pipeline. The returned Operation's [metadata] - * [google.longrunning.Operation.metadata] field will contain a - * [google.cloud.lifesciences.v2beta.Metadata][google.cloud.lifesciences.v2beta.Metadata] - * object describing the status of the pipeline execution. The - * [response][google.longrunning.Operation.response] field will contain a - * [google.cloud.lifesciences.v2beta.RunPipelineResponse][google.cloud.lifesciences.v2beta.RunPipelineResponse] - * object if the pipeline completes successfully. - * - * **Note:** Before you can use this method, the *Life Sciences Service Agent* - * must have access to your project. This is done automatically when the - * Cloud Life Sciences API is first enabled, but if you delete this permission - * you must disable and re-enable the API to grant the Life Sciences - * Service Agent the required permissions. - * Authorization requires the following [Google - * IAM](https://cloud.google.com/iam/) permission: - * - * * `lifesciences.workflows.run` - * - * The async variant is {@see self::runPipelineAsync()} . - * - * @example samples/V2beta/WorkflowsServiceV2BetaClient/run_pipeline.php - * - * @param RunPipelineRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function runPipeline(RunPipelineRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RunPipeline', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V2beta/WorkflowsServiceV2BetaClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V2beta/WorkflowsServiceV2BetaClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/LifeSciences/src/V2beta/Client/WorkflowsServiceV2BetaClient.php b/LifeSciences/src/V2beta/Client/WorkflowsServiceV2BetaClient.php index 6183192b0cfa..044785ebdbef 100644 --- a/LifeSciences/src/V2beta/Client/WorkflowsServiceV2BetaClient.php +++ b/LifeSciences/src/V2beta/Client/WorkflowsServiceV2BetaClient.php @@ -26,17 +26,286 @@ namespace Google\Cloud\LifeSciences\V2beta\Client; -use Google\Cloud\LifeSciences\V2beta\Client\BaseClient\WorkflowsServiceV2BetaBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\LifeSciences\V2beta\Metadata; +use Google\Cloud\LifeSciences\V2beta\RunPipelineRequest; +use Google\Cloud\LifeSciences\V2beta\RunPipelineResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service for running workflows, such as pipelines consisting of Docker + * containers. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface runPipelineAsync(RunPipelineRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class WorkflowsServiceV2BetaClient extends WorkflowsServiceV2BetaBaseClient +final class WorkflowsServiceV2BetaClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see WorkflowsServiceV2BetaBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.lifesciences.v2beta.WorkflowsServiceV2Beta'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'lifesciences.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/workflows_service_v2_beta_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/workflows_service_v2_beta_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/workflows_service_v2_beta_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/workflows_service_v2_beta_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + * + * @experimental + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + * + * @experimental + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'lifesciences.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); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Runs a pipeline. The returned Operation's [metadata] + * [google.longrunning.Operation.metadata] field will contain a + * [google.cloud.lifesciences.v2beta.Metadata][google.cloud.lifesciences.v2beta.Metadata] + * object describing the status of the pipeline execution. The + * [response][google.longrunning.Operation.response] field will contain a + * [google.cloud.lifesciences.v2beta.RunPipelineResponse][google.cloud.lifesciences.v2beta.RunPipelineResponse] + * object if the pipeline completes successfully. + * + * **Note:** Before you can use this method, the *Life Sciences Service Agent* + * must have access to your project. This is done automatically when the + * Cloud Life Sciences API is first enabled, but if you delete this permission + * you must disable and re-enable the API to grant the Life Sciences + * Service Agent the required permissions. + * Authorization requires the following [Google + * IAM](https://cloud.google.com/iam/) permission: + * + * * `lifesciences.workflows.run` + * + * The async variant is {@see WorkflowsServiceV2BetaClient::runPipelineAsync()} . + * + * @example samples/V2beta/WorkflowsServiceV2BetaClient/run_pipeline.php + * + * @param RunPipelineRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function runPipeline(RunPipelineRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RunPipeline', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see WorkflowsServiceV2BetaClient::getLocationAsync()} . + * + * @example samples/V2beta/WorkflowsServiceV2BetaClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see WorkflowsServiceV2BetaClient::listLocationsAsync()} . + * + * @example samples/V2beta/WorkflowsServiceV2BetaClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Logging/composer.json b/Logging/composer.json index 9f1df1aae6e2..c0108d0311a2 100644 --- a/Logging/composer.json +++ b/Logging/composer.json @@ -5,8 +5,8 @@ "minimum-stability": "stable", "require": { "php": ">=7.4", - "google/cloud-core": "^1.39", - "google/gax": "^1.19.1" + "google/cloud-core": "^1.52.7", + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", diff --git a/Logging/src/V2/Client/BaseClient/ConfigServiceV2BaseClient.php b/Logging/src/V2/Client/BaseClient/ConfigServiceV2BaseClient.php deleted file mode 100644 index d9cb371019bc..000000000000 --- a/Logging/src/V2/Client/BaseClient/ConfigServiceV2BaseClient.php +++ /dev/null @@ -1,1939 +0,0 @@ - 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', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/config_service_v2_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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(string $billingAccount): string - { - return self::getPathTemplate('billingAccount')->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_account_cmekSettings resource. - */ - public static function billingAccountCmekSettingsName(string $billingAccount): string - { - return self::getPathTemplate('billingAccountCmekSettings')->render([ - 'billing_account' => $billingAccount, - ]); - } - - /** - * 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_account_exclusion resource. - */ - public static function billingAccountExclusionName(string $billingAccount, string $exclusion): string - { - return self::getPathTemplate('billingAccountExclusion')->render([ - 'billing_account' => $billingAccount, - 'exclusion' => $exclusion, - ]); - } - - /** - * 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(string $billingAccount, string $location): string - { - return self::getPathTemplate('billingAccountLocation')->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(string $billingAccount, string $location, string $bucket): string - { - return self::getPathTemplate('billingAccountLocationBucket')->render([ - 'billing_account' => $billingAccount, - 'location' => $location, - 'bucket' => $bucket, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * billing_account_location_bucket_link resource. - * - * @param string $billingAccount - * @param string $location - * @param string $bucket - * @param string $link - * - * @return string The formatted billing_account_location_bucket_link resource. - */ - public static function billingAccountLocationBucketLinkName(string $billingAccount, string $location, string $bucket, string $link): string - { - return self::getPathTemplate('billingAccountLocationBucketLink')->render([ - 'billing_account' => $billingAccount, - 'location' => $location, - 'bucket' => $bucket, - 'link' => $link, - ]); - } - - /** - * 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(string $billingAccount, string $location, string $bucket, string $view): string - { - return self::getPathTemplate('billingAccountLocationBucketView')->render([ - 'billing_account' => $billingAccount, - 'location' => $location, - 'bucket' => $bucket, - 'view' => $view, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * billing_account_settings resource. - * - * @param string $billingAccount - * - * @return string The formatted billing_account_settings resource. - */ - public static function billingAccountSettingsName(string $billingAccount): string - { - return self::getPathTemplate('billingAccountSettings')->render([ - 'billing_account' => $billingAccount, - ]); - } - - /** - * 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_account_sink resource. - */ - public static function billingAccountSinkName(string $billingAccount, string $sink): string - { - return self::getPathTemplate('billingAccountSink')->render([ - 'billing_account' => $billingAccount, - 'sink' => $sink, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * cmek_settings resource. - * - * @param string $project - * - * @return string The formatted cmek_settings resource. - */ - public static function cmekSettingsName(string $project): string - { - return self::getPathTemplate('cmekSettings')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a folder - * resource. - * - * @param string $folder - * - * @return string The formatted folder resource. - */ - public static function folderName(string $folder): string - { - return self::getPathTemplate('folder')->render([ - 'folder' => $folder, - ]); - } - - /** - * 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(string $folder): string - { - return self::getPathTemplate('folderCmekSettings')->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. - */ - public static function folderExclusionName(string $folder, string $exclusion): string - { - return self::getPathTemplate('folderExclusion')->render([ - 'folder' => $folder, - 'exclusion' => $exclusion, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_location resource. - * - * @param string $folder - * @param string $location - * - * @return string The formatted folder_location resource. - */ - public static function folderLocationName(string $folder, string $location): string - { - return self::getPathTemplate('folderLocation')->render([ - 'folder' => $folder, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_location_bucket resource. - * - * @param string $folder - * @param string $location - * @param string $bucket - * - * @return string The formatted folder_location_bucket resource. - */ - public static function folderLocationBucketName(string $folder, string $location, string $bucket): string - { - return self::getPathTemplate('folderLocationBucket')->render([ - 'folder' => $folder, - 'location' => $location, - 'bucket' => $bucket, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_location_bucket_link resource. - * - * @param string $folder - * @param string $location - * @param string $bucket - * @param string $link - * - * @return string The formatted folder_location_bucket_link resource. - */ - public static function folderLocationBucketLinkName(string $folder, string $location, string $bucket, string $link): string - { - return self::getPathTemplate('folderLocationBucketLink')->render([ - 'folder' => $folder, - 'location' => $location, - 'bucket' => $bucket, - 'link' => $link, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_location_bucket_view resource. - * - * @param string $folder - * @param string $location - * @param string $bucket - * @param string $view - * - * @return string The formatted folder_location_bucket_view resource. - */ - public static function folderLocationBucketViewName(string $folder, string $location, string $bucket, string $view): string - { - return self::getPathTemplate('folderLocationBucketView')->render([ - 'folder' => $folder, - 'location' => $location, - 'bucket' => $bucket, - 'view' => $view, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_settings resource. - * - * @param string $folder - * - * @return string The formatted folder_settings resource. - */ - public static function folderSettingsName(string $folder): string - { - return self::getPathTemplate('folderSettings')->render([ - 'folder' => $folder, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a folder_sink - * resource. - * - * @param string $folder - * @param string $sink - * - * @return string The formatted folder_sink resource. - */ - public static function folderSinkName(string $folder, string $sink): string - { - return self::getPathTemplate('folderSink')->render([ - 'folder' => $folder, - 'sink' => $sink, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a link - * resource. - * - * @param string $project - * @param string $location - * @param string $bucket - * @param string $link - * - * @return string The formatted link resource. - */ - public static function linkName(string $project, string $location, string $bucket, string $link): string - { - return self::getPathTemplate('link')->render([ - 'project' => $project, - 'location' => $location, - 'bucket' => $bucket, - 'link' => $link, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a log_bucket - * resource. - * - * @param string $project - * @param string $location - * @param string $bucket - * - * @return string The formatted log_bucket resource. - */ - public static function logBucketName(string $project, string $location, string $bucket): string - { - return self::getPathTemplate('logBucket')->render([ - 'project' => $project, - 'location' => $location, - 'bucket' => $bucket, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * log_exclusion resource. - * - * @param string $project - * @param string $exclusion - * - * @return string The formatted log_exclusion resource. - */ - public static function logExclusionName(string $project, string $exclusion): string - { - return self::getPathTemplate('logExclusion')->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(string $project, string $sink): string - { - return self::getPathTemplate('logSink')->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(string $project, string $location, string $bucket, string $view): string - { - return self::getPathTemplate('logView')->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(string $organization): string - { - return self::getPathTemplate('organization')->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(string $organization): string - { - return self::getPathTemplate('organizationCmekSettings')->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(string $organization, string $exclusion): string - { - return self::getPathTemplate('organizationExclusion')->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(string $organization, string $location): string - { - return self::getPathTemplate('organizationLocation')->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(string $organization, string $location, string $bucket): string - { - return self::getPathTemplate('organizationLocationBucket')->render([ - 'organization' => $organization, - 'location' => $location, - 'bucket' => $bucket, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_location_bucket_link resource. - * - * @param string $organization - * @param string $location - * @param string $bucket - * @param string $link - * - * @return string The formatted organization_location_bucket_link resource. - */ - public static function organizationLocationBucketLinkName(string $organization, string $location, string $bucket, string $link): string - { - return self::getPathTemplate('organizationLocationBucketLink')->render([ - 'organization' => $organization, - 'location' => $location, - 'bucket' => $bucket, - 'link' => $link, - ]); - } - - /** - * 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(string $organization, string $location, string $bucket, string $view): string - { - return self::getPathTemplate('organizationLocationBucketView')->render([ - 'organization' => $organization, - 'location' => $location, - 'bucket' => $bucket, - 'view' => $view, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_settings resource. - * - * @param string $organization - * - * @return string The formatted organization_settings resource. - */ - public static function organizationSettingsName(string $organization): string - { - return self::getPathTemplate('organizationSettings')->render([ - 'organization' => $organization, - ]); - } - - /** - * 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(string $organization, string $sink): string - { - return self::getPathTemplate('organizationSink')->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(string $project): string - { - return self::getPathTemplate('project')->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(string $project): string - { - return self::getPathTemplate('projectCmekSettings')->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(string $project, string $exclusion): string - { - return self::getPathTemplate('projectExclusion')->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(string $project, string $location, string $bucket): string - { - return self::getPathTemplate('projectLocationBucket')->render([ - 'project' => $project, - 'location' => $location, - 'bucket' => $bucket, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_bucket_link resource. - * - * @param string $project - * @param string $location - * @param string $bucket - * @param string $link - * - * @return string The formatted project_location_bucket_link resource. - */ - public static function projectLocationBucketLinkName(string $project, string $location, string $bucket, string $link): string - { - return self::getPathTemplate('projectLocationBucketLink')->render([ - 'project' => $project, - 'location' => $location, - 'bucket' => $bucket, - 'link' => $link, - ]); - } - - /** - * 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(string $project, string $location, string $bucket, string $view): string - { - return self::getPathTemplate('projectLocationBucketView')->render([ - 'project' => $project, - 'location' => $location, - 'bucket' => $bucket, - 'view' => $view, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_settings resource. - * - * @param string $project - * - * @return string The formatted project_settings resource. - */ - public static function projectSettingsName(string $project): string - { - return self::getPathTemplate('projectSettings')->render([ - 'project' => $project, - ]); - } - - /** - * 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(string $project, string $sink): string - { - return self::getPathTemplate('projectSink')->render([ - 'project' => $project, - 'sink' => $sink, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a settings - * resource. - * - * @param string $project - * - * @return string The formatted settings resource. - */ - public static function settingsName(string $project): string - { - return self::getPathTemplate('settings')->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 - * - 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} - * - billingAccountLocationBucketLink: billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}/links/{link} - * - billingAccountLocationBucketView: billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}/views/{view} - * - billingAccountSettings: billingAccounts/{billing_account}/settings - * - 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} - * - folderLocationBucketLink: folders/{folder}/locations/{location}/buckets/{bucket}/links/{link} - * - folderLocationBucketView: folders/{folder}/locations/{location}/buckets/{bucket}/views/{view} - * - folderSettings: folders/{folder}/settings - * - folderSink: folders/{folder}/sinks/{sink} - * - link: projects/{project}/locations/{location}/buckets/{bucket}/links/{link} - * - 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} - * - organizationLocationBucketLink: organizations/{organization}/locations/{location}/buckets/{bucket}/links/{link} - * - organizationLocationBucketView: organizations/{organization}/locations/{location}/buckets/{bucket}/views/{view} - * - organizationSettings: organizations/{organization}/settings - * - organizationSink: organizations/{organization}/sinks/{sink} - * - project: projects/{project} - * - projectCmekSettings: projects/{project}/cmekSettings - * - projectExclusion: projects/{project}/exclusions/{exclusion} - * - projectLocationBucket: projects/{project}/locations/{location}/buckets/{bucket} - * - projectLocationBucketLink: projects/{project}/locations/{location}/buckets/{bucket}/links/{link} - * - projectLocationBucketView: projects/{project}/locations/{location}/buckets/{bucket}/views/{view} - * - projectSettings: projects/{project}/settings - * - projectSink: projects/{project}/sinks/{sink} - * - settings: projects/{project}/settings - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'logging.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Copies a set of log entries from a log bucket to a Cloud Storage bucket. - * - * The async variant is {@see self::copyLogEntriesAsync()} . - * - * @param CopyLogEntriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function copyLogEntries(CopyLogEntriesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CopyLogEntries', $request, $callOptions)->wait(); - } - - /** - * Creates a log bucket that can be used to store log entries. After a bucket - * has been created, the bucket's location cannot be changed. - * - * The async variant is {@see self::createBucketAsync()} . - * - * @param CreateBucketRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LogBucket - * - * @throws ApiException Thrown if the API call fails. - */ - public function createBucket(CreateBucketRequest $request, array $callOptions = []): LogBucket - { - return $this->startApiCall('CreateBucket', $request, $callOptions)->wait(); - } - - /** - * Creates a log bucket asynchronously that can be used to store log entries. - * - * After a bucket has been created, the bucket's location cannot be changed. - * - * The async variant is {@see self::createBucketAsyncAsync()} . - * - * @param CreateBucketRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createBucketAsync(CreateBucketRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateBucketAsync', $request, $callOptions)->wait(); - } - - /** - * Creates a new exclusion in the _Default sink 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. - * - * The async variant is {@see self::createExclusionAsync()} . - * - * @param CreateExclusionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LogExclusion - * - * @throws ApiException Thrown if the API call fails. - */ - public function createExclusion(CreateExclusionRequest $request, array $callOptions = []): LogExclusion - { - return $this->startApiCall('CreateExclusion', $request, $callOptions)->wait(); - } - - /** - * Asynchronously creates a linked dataset in BigQuery which makes it possible - * to use BigQuery to read the logs stored in the log bucket. A log bucket may - * currently only contain one link. - * - * The async variant is {@see self::createLinkAsync()} . - * - * @param CreateLinkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createLink(CreateLinkRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateLink', $request, $callOptions)->wait(); - } - - /** - * Creates a sink that exports specified log entries to a destination. The - * export of newly-ingested log entries begins immediately, unless the sink's - * `writer_identity` is not permitted to write to the destination. A sink can - * export log entries only from the resource owning the sink. - * - * The async variant is {@see self::createSinkAsync()} . - * - * @param CreateSinkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LogSink - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSink(CreateSinkRequest $request, array $callOptions = []): LogSink - { - return $this->startApiCall('CreateSink', $request, $callOptions)->wait(); - } - - /** - * Creates a view over log entries in a log bucket. A bucket may contain a - * maximum of 30 views. - * - * The async variant is {@see self::createViewAsync()} . - * - * @param CreateViewRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LogView - * - * @throws ApiException Thrown if the API call fails. - */ - public function createView(CreateViewRequest $request, array $callOptions = []): LogView - { - return $this->startApiCall('CreateView', $request, $callOptions)->wait(); - } - - /** - * Deletes a log bucket. - * - * Changes the bucket's `lifecycle_state` to the `DELETE_REQUESTED` state. - * After 7 days, the bucket will be purged and all log entries in the bucket - * will be permanently deleted. - * - * The async variant is {@see self::deleteBucketAsync()} . - * - * @param DeleteBucketRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteBucket(DeleteBucketRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteBucket', $request, $callOptions)->wait(); - } - - /** - * Deletes an exclusion in the _Default sink. - * - * The async variant is {@see self::deleteExclusionAsync()} . - * - * @param DeleteExclusionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteExclusion(DeleteExclusionRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteExclusion', $request, $callOptions)->wait(); - } - - /** - * Deletes a link. This will also delete the corresponding BigQuery linked - * dataset. - * - * The async variant is {@see self::deleteLinkAsync()} . - * - * @param DeleteLinkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteLink(DeleteLinkRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteLink', $request, $callOptions)->wait(); - } - - /** - * Deletes a sink. If the sink has a unique `writer_identity`, then that - * service account is also deleted. - * - * The async variant is {@see self::deleteSinkAsync()} . - * - * @param DeleteSinkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSink(DeleteSinkRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteSink', $request, $callOptions)->wait(); - } - - /** - * Deletes a view on a log bucket. - * If an `UNAVAILABLE` error is returned, this indicates that system is not in - * a state where it can delete the view. If this occurs, please try again in a - * few minutes. - * - * The async variant is {@see self::deleteViewAsync()} . - * - * @param DeleteViewRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteView(DeleteViewRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteView', $request, $callOptions)->wait(); - } - - /** - * Gets a log bucket. - * - * The async variant is {@see self::getBucketAsync()} . - * - * @param GetBucketRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LogBucket - * - * @throws ApiException Thrown if the API call fails. - */ - public function getBucket(GetBucketRequest $request, array $callOptions = []): LogBucket - { - return $this->startApiCall('GetBucket', $request, $callOptions)->wait(); - } - - /** - * Gets the Logging CMEK settings for the given resource. - * - * Note: CMEK for the Log Router can be configured for Google Cloud projects, - * folders, organizations and billing accounts. Once configured for an - * organization, it applies to all projects and folders in the Google Cloud - * organization. - * - * See [Enabling CMEK for Log - * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) - * for more information. - * - * The async variant is {@see self::getCmekSettingsAsync()} . - * - * @param GetCmekSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CmekSettings - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCmekSettings(GetCmekSettingsRequest $request, array $callOptions = []): CmekSettings - { - return $this->startApiCall('GetCmekSettings', $request, $callOptions)->wait(); - } - - /** - * Gets the description of an exclusion in the _Default sink. - * - * The async variant is {@see self::getExclusionAsync()} . - * - * @param GetExclusionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LogExclusion - * - * @throws ApiException Thrown if the API call fails. - */ - public function getExclusion(GetExclusionRequest $request, array $callOptions = []): LogExclusion - { - return $this->startApiCall('GetExclusion', $request, $callOptions)->wait(); - } - - /** - * Gets a link. - * - * The async variant is {@see self::getLinkAsync()} . - * - * @param GetLinkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Link - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLink(GetLinkRequest $request, array $callOptions = []): Link - { - return $this->startApiCall('GetLink', $request, $callOptions)->wait(); - } - - /** - * Gets the Log Router settings for the given resource. - * - * Note: Settings for the Log Router can be get for Google Cloud projects, - * folders, organizations and billing accounts. Currently it can only be - * configured for organizations. Once configured for an organization, it - * applies to all projects and folders in the Google Cloud organization. - * - * See [Enabling CMEK for Log - * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) - * for more information. - * - * The async variant is {@see self::getSettingsAsync()} . - * - * @param GetSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Settings - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSettings(GetSettingsRequest $request, array $callOptions = []): Settings - { - return $this->startApiCall('GetSettings', $request, $callOptions)->wait(); - } - - /** - * Gets a sink. - * - * The async variant is {@see self::getSinkAsync()} . - * - * @param GetSinkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LogSink - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSink(GetSinkRequest $request, array $callOptions = []): LogSink - { - return $this->startApiCall('GetSink', $request, $callOptions)->wait(); - } - - /** - * Gets a view on a log bucket.. - * - * The async variant is {@see self::getViewAsync()} . - * - * @param GetViewRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LogView - * - * @throws ApiException Thrown if the API call fails. - */ - public function getView(GetViewRequest $request, array $callOptions = []): LogView - { - return $this->startApiCall('GetView', $request, $callOptions)->wait(); - } - - /** - * Lists log buckets. - * - * The async variant is {@see self::listBucketsAsync()} . - * - * @param ListBucketsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listBuckets(ListBucketsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListBuckets', $request, $callOptions); - } - - /** - * Lists all the exclusions on the _Default sink in a parent resource. - * - * The async variant is {@see self::listExclusionsAsync()} . - * - * @param ListExclusionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listExclusions(ListExclusionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListExclusions', $request, $callOptions); - } - - /** - * Lists links. - * - * The async variant is {@see self::listLinksAsync()} . - * - * @param ListLinksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLinks(ListLinksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLinks', $request, $callOptions); - } - - /** - * Lists sinks. - * - * The async variant is {@see self::listSinksAsync()} . - * - * @param ListSinksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSinks(ListSinksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSinks', $request, $callOptions); - } - - /** - * Lists views on a log bucket. - * - * The async variant is {@see self::listViewsAsync()} . - * - * @param ListViewsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listViews(ListViewsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListViews', $request, $callOptions); - } - - /** - * Undeletes a log bucket. A bucket that has been deleted can be undeleted - * within the grace period of 7 days. - * - * The async variant is {@see self::undeleteBucketAsync()} . - * - * @param UndeleteBucketRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function undeleteBucket(UndeleteBucketRequest $request, array $callOptions = []): void - { - $this->startApiCall('UndeleteBucket', $request, $callOptions)->wait(); - } - - /** - * Updates a log bucket. - * - * If the bucket has a `lifecycle_state` of `DELETE_REQUESTED`, then - * `FAILED_PRECONDITION` will be returned. - * - * After a bucket has been created, the bucket's location cannot be changed. - * - * The async variant is {@see self::updateBucketAsync()} . - * - * @param UpdateBucketRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LogBucket - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateBucket(UpdateBucketRequest $request, array $callOptions = []): LogBucket - { - return $this->startApiCall('UpdateBucket', $request, $callOptions)->wait(); - } - - /** - * Updates a log bucket asynchronously. - * - * If the bucket has a `lifecycle_state` of `DELETE_REQUESTED`, then - * `FAILED_PRECONDITION` will be returned. - * - * After a bucket has been created, the bucket's location cannot be changed. - * - * The async variant is {@see self::updateBucketAsyncAsync()} . - * - * @param UpdateBucketRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateBucketAsync(UpdateBucketRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateBucketAsync', $request, $callOptions)->wait(); - } - - /** - * Updates the Log Router CMEK settings for the given resource. - * - * Note: CMEK for the Log Router can currently only be configured for Google - * Cloud organizations. Once configured, it applies to all projects and - * folders in the Google Cloud 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 Log - * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) - * for more information. - * - * The async variant is {@see self::updateCmekSettingsAsync()} . - * - * @param UpdateCmekSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CmekSettings - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCmekSettings(UpdateCmekSettingsRequest $request, array $callOptions = []): CmekSettings - { - return $this->startApiCall('UpdateCmekSettings', $request, $callOptions)->wait(); - } - - /** - * Changes one or more properties of an existing exclusion in the _Default - * sink. - * - * The async variant is {@see self::updateExclusionAsync()} . - * - * @param UpdateExclusionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LogExclusion - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateExclusion(UpdateExclusionRequest $request, array $callOptions = []): LogExclusion - { - return $this->startApiCall('UpdateExclusion', $request, $callOptions)->wait(); - } - - /** - * Updates the Log Router settings for the given resource. - * - * Note: Settings for the Log Router can currently only be configured for - * Google Cloud organizations. Once configured, it applies to all projects and - * folders in the Google Cloud organization. - * - * [UpdateSettings][google.logging.v2.ConfigServiceV2.UpdateSettings] - * 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. 4) `location_id` is not supported by - * Logging. 5) `location_id` violate OrgPolicy. - * - * See [Enabling CMEK for Log - * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) - * for more information. - * - * The async variant is {@see self::updateSettingsAsync()} . - * - * @param UpdateSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Settings - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSettings(UpdateSettingsRequest $request, array $callOptions = []): Settings - { - return $this->startApiCall('UpdateSettings', $request, $callOptions)->wait(); - } - - /** - * Updates a sink. This method replaces the following fields in the existing - * sink with values from the new sink: `destination`, and `filter`. - * - * The updated sink might also have a new `writer_identity`; see the - * `unique_writer_identity` field. - * - * The async variant is {@see self::updateSinkAsync()} . - * - * @param UpdateSinkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LogSink - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSink(UpdateSinkRequest $request, array $callOptions = []): LogSink - { - return $this->startApiCall('UpdateSink', $request, $callOptions)->wait(); - } - - /** - * Updates a view on a log bucket. This method replaces the following fields - * in the existing view with values from the new view: `filter`. - * If an `UNAVAILABLE` error is returned, this indicates that system is not in - * a state where it can update the view. If this occurs, please try again in a - * few minutes. - * - * The async variant is {@see self::updateViewAsync()} . - * - * @param UpdateViewRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LogView - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateView(UpdateViewRequest $request, array $callOptions = []): LogView - { - return $this->startApiCall('UpdateView', $request, $callOptions)->wait(); - } -} diff --git a/Logging/src/V2/Client/BaseClient/LoggingServiceV2BaseClient.php b/Logging/src/V2/Client/BaseClient/LoggingServiceV2BaseClient.php deleted file mode 100644 index 7251bab3ee0c..000000000000 --- a/Logging/src/V2/Client/BaseClient/LoggingServiceV2BaseClient.php +++ /dev/null @@ -1,512 +0,0 @@ - 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', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/logging_service_v2_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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(string $billingAccount): string - { - return self::getPathTemplate('billingAccount')->render([ - 'billing_account' => $billingAccount, - ]); - } - - /** - * 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_account_log resource. - */ - public static function billingAccountLogName(string $billingAccount, string $log): string - { - return self::getPathTemplate('billingAccountLog')->render([ - 'billing_account' => $billingAccount, - 'log' => $log, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a folder - * resource. - * - * @param string $folder - * - * @return string The formatted folder resource. - */ - public static function folderName(string $folder): string - { - return self::getPathTemplate('folder')->render([ - 'folder' => $folder, - ]); - } - - /** - * 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. - */ - public static function folderLogName(string $folder, string $log): string - { - return self::getPathTemplate('folderLog')->render([ - 'folder' => $folder, - 'log' => $log, - ]); - } - - /** - * 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. - */ - public static function logName(string $project, string $log): string - { - return self::getPathTemplate('log')->render([ - 'project' => $project, - 'log' => $log, - ]); - } - - /** - * 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(string $organization): string - { - return self::getPathTemplate('organization')->render([ - 'organization' => $organization, - ]); - } - - /** - * 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. - */ - public static function organizationLogName(string $organization, string $log): string - { - return self::getPathTemplate('organizationLog')->render([ - 'organization' => $organization, - 'log' => $log, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $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(string $project, string $log): string - { - return self::getPathTemplate('projectLog')->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 - * - 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} - * - 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. - * - * @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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'logging.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes all the log entries in a log for the _Default Log Bucket. The log - * reappears if it receives new entries. Log entries written shortly before - * the delete operation might not be deleted. Entries received after the - * delete operation with a timestamp before the operation will be deleted. - * - * The async variant is {@see self::deleteLogAsync()} . - * - * @param DeleteLogRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteLog(DeleteLogRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteLog', $request, $callOptions)->wait(); - } - - /** - * 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). - * - * The async variant is {@see self::listLogEntriesAsync()} . - * - * @param ListLogEntriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLogEntries(ListLogEntriesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLogEntries', $request, $callOptions); - } - - /** - * Lists the logs in projects, organizations, folders, or billing accounts. - * Only logs that have entries are listed. - * - * The async variant is {@see self::listLogsAsync()} . - * - * @param ListLogsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLogs(ListLogsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLogs', $request, $callOptions); - } - - /** - * Lists the descriptors for monitored resource types used by Logging. - * - * The async variant is {@see self::listMonitoredResourceDescriptorsAsync()} . - * - * @param ListMonitoredResourceDescriptorsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listMonitoredResourceDescriptors(ListMonitoredResourceDescriptorsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListMonitoredResourceDescriptors', $request, $callOptions); - } - - /** - * Streaming read of log entries as they are ingested. Until the stream is - * terminated, it will continue reading logs. - * - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return BidiStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function tailLogEntries(array $callOptions = []): BidiStream - { - return $this->startApiCall('TailLogEntries', null, $callOptions); - } - - /** - * 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) - * - * The async variant is {@see self::writeLogEntriesAsync()} . - * - * @param WriteLogEntriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 WriteLogEntriesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function writeLogEntries(WriteLogEntriesRequest $request, array $callOptions = []): WriteLogEntriesResponse - { - return $this->startApiCall('WriteLogEntries', $request, $callOptions)->wait(); - } -} diff --git a/Logging/src/V2/Client/BaseClient/MetricsServiceV2BaseClient.php b/Logging/src/V2/Client/BaseClient/MetricsServiceV2BaseClient.php deleted file mode 100644 index bbeafe657173..000000000000 --- a/Logging/src/V2/Client/BaseClient/MetricsServiceV2BaseClient.php +++ /dev/null @@ -1,358 +0,0 @@ - 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', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/metrics_service_v2_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a log_metric - * resource. - * - * @param string $project - * @param string $metric - * - * @return string The formatted log_metric resource. - */ - public static function logMetricName(string $project, string $metric): string - { - return self::getPathTemplate('logMetric')->render([ - 'project' => $project, - 'metric' => $metric, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->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 - * - 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. - * - * @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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'logging.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a logs-based metric. - * - * The async variant is {@see self::createLogMetricAsync()} . - * - * @param CreateLogMetricRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LogMetric - * - * @throws ApiException Thrown if the API call fails. - */ - public function createLogMetric(CreateLogMetricRequest $request, array $callOptions = []): LogMetric - { - return $this->startApiCall('CreateLogMetric', $request, $callOptions)->wait(); - } - - /** - * Deletes a logs-based metric. - * - * The async variant is {@see self::deleteLogMetricAsync()} . - * - * @param DeleteLogMetricRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteLogMetric(DeleteLogMetricRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteLogMetric', $request, $callOptions)->wait(); - } - - /** - * Gets a logs-based metric. - * - * The async variant is {@see self::getLogMetricAsync()} . - * - * @param GetLogMetricRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LogMetric - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLogMetric(GetLogMetricRequest $request, array $callOptions = []): LogMetric - { - return $this->startApiCall('GetLogMetric', $request, $callOptions)->wait(); - } - - /** - * Lists logs-based metrics. - * - * The async variant is {@see self::listLogMetricsAsync()} . - * - * @param ListLogMetricsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLogMetrics(ListLogMetricsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLogMetrics', $request, $callOptions); - } - - /** - * Creates or updates a logs-based metric. - * - * The async variant is {@see self::updateLogMetricAsync()} . - * - * @param UpdateLogMetricRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LogMetric - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateLogMetric(UpdateLogMetricRequest $request, array $callOptions = []): LogMetric - { - return $this->startApiCall('UpdateLogMetric', $request, $callOptions)->wait(); - } -} diff --git a/Logging/src/V2/Client/ConfigServiceV2Client.php b/Logging/src/V2/Client/ConfigServiceV2Client.php index 289c911afb97..4a0736ccbb75 100644 --- a/Logging/src/V2/Client/ConfigServiceV2Client.php +++ b/Logging/src/V2/Client/ConfigServiceV2Client.php @@ -24,17 +24,1914 @@ namespace Google\Cloud\Logging\V2\Client; -use Google\Cloud\Logging\V2\Client\BaseClient\ConfigServiceV2BaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Logging\V2\CmekSettings; +use Google\Cloud\Logging\V2\CopyLogEntriesRequest; +use Google\Cloud\Logging\V2\CreateBucketRequest; +use Google\Cloud\Logging\V2\CreateExclusionRequest; +use Google\Cloud\Logging\V2\CreateLinkRequest; +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\DeleteLinkRequest; +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\GetLinkRequest; +use Google\Cloud\Logging\V2\GetSettingsRequest; +use Google\Cloud\Logging\V2\GetSinkRequest; +use Google\Cloud\Logging\V2\GetViewRequest; +use Google\Cloud\Logging\V2\Link; +use Google\Cloud\Logging\V2\ListBucketsRequest; +use Google\Cloud\Logging\V2\ListExclusionsRequest; +use Google\Cloud\Logging\V2\ListLinksRequest; +use Google\Cloud\Logging\V2\ListSinksRequest; +use Google\Cloud\Logging\V2\ListViewsRequest; +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\Settings; +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\UpdateSettingsRequest; +use Google\Cloud\Logging\V2\UpdateSinkRequest; +use Google\Cloud\Logging\V2\UpdateViewRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for configuring sinks used to route log entries. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Logging\V2\ConfigServiceV2Client} for the stable implementation * * @experimental + * + * @method PromiseInterface copyLogEntriesAsync(CopyLogEntriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface createBucketAsync(CreateBucketRequest $request, array $optionalArgs = []) + * @method PromiseInterface createBucketAsyncAsync(CreateBucketRequest $request, array $optionalArgs = []) + * @method PromiseInterface createExclusionAsync(CreateExclusionRequest $request, array $optionalArgs = []) + * @method PromiseInterface createLinkAsync(CreateLinkRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSinkAsync(CreateSinkRequest $request, array $optionalArgs = []) + * @method PromiseInterface createViewAsync(CreateViewRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteBucketAsync(DeleteBucketRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteExclusionAsync(DeleteExclusionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteLinkAsync(DeleteLinkRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSinkAsync(DeleteSinkRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteViewAsync(DeleteViewRequest $request, array $optionalArgs = []) + * @method PromiseInterface getBucketAsync(GetBucketRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCmekSettingsAsync(GetCmekSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getExclusionAsync(GetExclusionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLinkAsync(GetLinkRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSettingsAsync(GetSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSinkAsync(GetSinkRequest $request, array $optionalArgs = []) + * @method PromiseInterface getViewAsync(GetViewRequest $request, array $optionalArgs = []) + * @method PromiseInterface listBucketsAsync(ListBucketsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listExclusionsAsync(ListExclusionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLinksAsync(ListLinksRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSinksAsync(ListSinksRequest $request, array $optionalArgs = []) + * @method PromiseInterface listViewsAsync(ListViewsRequest $request, array $optionalArgs = []) + * @method PromiseInterface undeleteBucketAsync(UndeleteBucketRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateBucketAsync(UpdateBucketRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateBucketAsyncAsync(UpdateBucketRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCmekSettingsAsync(UpdateCmekSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateExclusionAsync(UpdateExclusionRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSettingsAsync(UpdateSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSinkAsync(UpdateSinkRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateViewAsync(UpdateViewRequest $request, array $optionalArgs = []) */ -final class ConfigServiceV2Client extends ConfigServiceV2BaseClient +final class ConfigServiceV2Client { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ConfigServiceV2BaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.logging.v2.ConfigServiceV2'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'logging.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + 'https://www.googleapis.com/auth/logging.admin', + 'https://www.googleapis.com/auth/logging.read', + ]; + + private $operationsClient; + + 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', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/config_service_v2_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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(string $billingAccount): string + { + return self::getPathTemplate('billingAccount')->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_account_cmekSettings resource. + */ + public static function billingAccountCmekSettingsName(string $billingAccount): string + { + return self::getPathTemplate('billingAccountCmekSettings')->render([ + 'billing_account' => $billingAccount, + ]); + } + + /** + * 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_account_exclusion resource. + */ + public static function billingAccountExclusionName(string $billingAccount, string $exclusion): string + { + return self::getPathTemplate('billingAccountExclusion')->render([ + 'billing_account' => $billingAccount, + 'exclusion' => $exclusion, + ]); + } + + /** + * 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(string $billingAccount, string $location): string + { + return self::getPathTemplate('billingAccountLocation')->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(string $billingAccount, string $location, string $bucket): string + { + return self::getPathTemplate('billingAccountLocationBucket')->render([ + 'billing_account' => $billingAccount, + 'location' => $location, + 'bucket' => $bucket, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * billing_account_location_bucket_link resource. + * + * @param string $billingAccount + * @param string $location + * @param string $bucket + * @param string $link + * + * @return string The formatted billing_account_location_bucket_link resource. + */ + public static function billingAccountLocationBucketLinkName(string $billingAccount, string $location, string $bucket, string $link): string + { + return self::getPathTemplate('billingAccountLocationBucketLink')->render([ + 'billing_account' => $billingAccount, + 'location' => $location, + 'bucket' => $bucket, + 'link' => $link, + ]); + } + + /** + * 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(string $billingAccount, string $location, string $bucket, string $view): string + { + return self::getPathTemplate('billingAccountLocationBucketView')->render([ + 'billing_account' => $billingAccount, + 'location' => $location, + 'bucket' => $bucket, + 'view' => $view, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * billing_account_settings resource. + * + * @param string $billingAccount + * + * @return string The formatted billing_account_settings resource. + */ + public static function billingAccountSettingsName(string $billingAccount): string + { + return self::getPathTemplate('billingAccountSettings')->render([ + 'billing_account' => $billingAccount, + ]); + } + + /** + * 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_account_sink resource. + */ + public static function billingAccountSinkName(string $billingAccount, string $sink): string + { + return self::getPathTemplate('billingAccountSink')->render([ + 'billing_account' => $billingAccount, + 'sink' => $sink, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * cmek_settings resource. + * + * @param string $project + * + * @return string The formatted cmek_settings resource. + */ + public static function cmekSettingsName(string $project): string + { + return self::getPathTemplate('cmekSettings')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a folder + * resource. + * + * @param string $folder + * + * @return string The formatted folder resource. + */ + public static function folderName(string $folder): string + { + return self::getPathTemplate('folder')->render([ + 'folder' => $folder, + ]); + } + + /** + * 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(string $folder): string + { + return self::getPathTemplate('folderCmekSettings')->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. + */ + public static function folderExclusionName(string $folder, string $exclusion): string + { + return self::getPathTemplate('folderExclusion')->render([ + 'folder' => $folder, + 'exclusion' => $exclusion, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_location resource. + * + * @param string $folder + * @param string $location + * + * @return string The formatted folder_location resource. + */ + public static function folderLocationName(string $folder, string $location): string + { + return self::getPathTemplate('folderLocation')->render([ + 'folder' => $folder, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_location_bucket resource. + * + * @param string $folder + * @param string $location + * @param string $bucket + * + * @return string The formatted folder_location_bucket resource. + */ + public static function folderLocationBucketName(string $folder, string $location, string $bucket): string + { + return self::getPathTemplate('folderLocationBucket')->render([ + 'folder' => $folder, + 'location' => $location, + 'bucket' => $bucket, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_location_bucket_link resource. + * + * @param string $folder + * @param string $location + * @param string $bucket + * @param string $link + * + * @return string The formatted folder_location_bucket_link resource. + */ + public static function folderLocationBucketLinkName(string $folder, string $location, string $bucket, string $link): string + { + return self::getPathTemplate('folderLocationBucketLink')->render([ + 'folder' => $folder, + 'location' => $location, + 'bucket' => $bucket, + 'link' => $link, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_location_bucket_view resource. + * + * @param string $folder + * @param string $location + * @param string $bucket + * @param string $view + * + * @return string The formatted folder_location_bucket_view resource. + */ + public static function folderLocationBucketViewName(string $folder, string $location, string $bucket, string $view): string + { + return self::getPathTemplate('folderLocationBucketView')->render([ + 'folder' => $folder, + 'location' => $location, + 'bucket' => $bucket, + 'view' => $view, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_settings resource. + * + * @param string $folder + * + * @return string The formatted folder_settings resource. + */ + public static function folderSettingsName(string $folder): string + { + return self::getPathTemplate('folderSettings')->render([ + 'folder' => $folder, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a folder_sink + * resource. + * + * @param string $folder + * @param string $sink + * + * @return string The formatted folder_sink resource. + */ + public static function folderSinkName(string $folder, string $sink): string + { + return self::getPathTemplate('folderSink')->render([ + 'folder' => $folder, + 'sink' => $sink, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a link + * resource. + * + * @param string $project + * @param string $location + * @param string $bucket + * @param string $link + * + * @return string The formatted link resource. + */ + public static function linkName(string $project, string $location, string $bucket, string $link): string + { + return self::getPathTemplate('link')->render([ + 'project' => $project, + 'location' => $location, + 'bucket' => $bucket, + 'link' => $link, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a log_bucket + * resource. + * + * @param string $project + * @param string $location + * @param string $bucket + * + * @return string The formatted log_bucket resource. + */ + public static function logBucketName(string $project, string $location, string $bucket): string + { + return self::getPathTemplate('logBucket')->render([ + 'project' => $project, + 'location' => $location, + 'bucket' => $bucket, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * log_exclusion resource. + * + * @param string $project + * @param string $exclusion + * + * @return string The formatted log_exclusion resource. + */ + public static function logExclusionName(string $project, string $exclusion): string + { + return self::getPathTemplate('logExclusion')->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(string $project, string $sink): string + { + return self::getPathTemplate('logSink')->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(string $project, string $location, string $bucket, string $view): string + { + return self::getPathTemplate('logView')->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(string $organization): string + { + return self::getPathTemplate('organization')->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(string $organization): string + { + return self::getPathTemplate('organizationCmekSettings')->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(string $organization, string $exclusion): string + { + return self::getPathTemplate('organizationExclusion')->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(string $organization, string $location): string + { + return self::getPathTemplate('organizationLocation')->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(string $organization, string $location, string $bucket): string + { + return self::getPathTemplate('organizationLocationBucket')->render([ + 'organization' => $organization, + 'location' => $location, + 'bucket' => $bucket, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_location_bucket_link resource. + * + * @param string $organization + * @param string $location + * @param string $bucket + * @param string $link + * + * @return string The formatted organization_location_bucket_link resource. + */ + public static function organizationLocationBucketLinkName(string $organization, string $location, string $bucket, string $link): string + { + return self::getPathTemplate('organizationLocationBucketLink')->render([ + 'organization' => $organization, + 'location' => $location, + 'bucket' => $bucket, + 'link' => $link, + ]); + } + + /** + * 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(string $organization, string $location, string $bucket, string $view): string + { + return self::getPathTemplate('organizationLocationBucketView')->render([ + 'organization' => $organization, + 'location' => $location, + 'bucket' => $bucket, + 'view' => $view, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_settings resource. + * + * @param string $organization + * + * @return string The formatted organization_settings resource. + */ + public static function organizationSettingsName(string $organization): string + { + return self::getPathTemplate('organizationSettings')->render([ + 'organization' => $organization, + ]); + } + + /** + * 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(string $organization, string $sink): string + { + return self::getPathTemplate('organizationSink')->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(string $project): string + { + return self::getPathTemplate('project')->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(string $project): string + { + return self::getPathTemplate('projectCmekSettings')->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(string $project, string $exclusion): string + { + return self::getPathTemplate('projectExclusion')->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(string $project, string $location, string $bucket): string + { + return self::getPathTemplate('projectLocationBucket')->render([ + 'project' => $project, + 'location' => $location, + 'bucket' => $bucket, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_bucket_link resource. + * + * @param string $project + * @param string $location + * @param string $bucket + * @param string $link + * + * @return string The formatted project_location_bucket_link resource. + */ + public static function projectLocationBucketLinkName(string $project, string $location, string $bucket, string $link): string + { + return self::getPathTemplate('projectLocationBucketLink')->render([ + 'project' => $project, + 'location' => $location, + 'bucket' => $bucket, + 'link' => $link, + ]); + } + + /** + * 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(string $project, string $location, string $bucket, string $view): string + { + return self::getPathTemplate('projectLocationBucketView')->render([ + 'project' => $project, + 'location' => $location, + 'bucket' => $bucket, + 'view' => $view, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_settings resource. + * + * @param string $project + * + * @return string The formatted project_settings resource. + */ + public static function projectSettingsName(string $project): string + { + return self::getPathTemplate('projectSettings')->render([ + 'project' => $project, + ]); + } + + /** + * 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(string $project, string $sink): string + { + return self::getPathTemplate('projectSink')->render([ + 'project' => $project, + 'sink' => $sink, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a settings + * resource. + * + * @param string $project + * + * @return string The formatted settings resource. + */ + public static function settingsName(string $project): string + { + return self::getPathTemplate('settings')->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 + * - 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} + * - billingAccountLocationBucketLink: billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}/links/{link} + * - billingAccountLocationBucketView: billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}/views/{view} + * - billingAccountSettings: billingAccounts/{billing_account}/settings + * - 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} + * - folderLocationBucketLink: folders/{folder}/locations/{location}/buckets/{bucket}/links/{link} + * - folderLocationBucketView: folders/{folder}/locations/{location}/buckets/{bucket}/views/{view} + * - folderSettings: folders/{folder}/settings + * - folderSink: folders/{folder}/sinks/{sink} + * - link: projects/{project}/locations/{location}/buckets/{bucket}/links/{link} + * - 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} + * - organizationLocationBucketLink: organizations/{organization}/locations/{location}/buckets/{bucket}/links/{link} + * - organizationLocationBucketView: organizations/{organization}/locations/{location}/buckets/{bucket}/views/{view} + * - organizationSettings: organizations/{organization}/settings + * - organizationSink: organizations/{organization}/sinks/{sink} + * - project: projects/{project} + * - projectCmekSettings: projects/{project}/cmekSettings + * - projectExclusion: projects/{project}/exclusions/{exclusion} + * - projectLocationBucket: projects/{project}/locations/{location}/buckets/{bucket} + * - projectLocationBucketLink: projects/{project}/locations/{location}/buckets/{bucket}/links/{link} + * - projectLocationBucketView: projects/{project}/locations/{location}/buckets/{bucket}/views/{view} + * - projectSettings: projects/{project}/settings + * - projectSink: projects/{project}/sinks/{sink} + * - settings: projects/{project}/settings + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'logging.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Copies a set of log entries from a log bucket to a Cloud Storage bucket. + * + * The async variant is {@see ConfigServiceV2Client::copyLogEntriesAsync()} . + * + * @param CopyLogEntriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function copyLogEntries(CopyLogEntriesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CopyLogEntries', $request, $callOptions)->wait(); + } + + /** + * Creates a log bucket that can be used to store log entries. After a bucket + * has been created, the bucket's location cannot be changed. + * + * The async variant is {@see ConfigServiceV2Client::createBucketAsync()} . + * + * @param CreateBucketRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LogBucket + * + * @throws ApiException Thrown if the API call fails. + */ + public function createBucket(CreateBucketRequest $request, array $callOptions = []): LogBucket + { + return $this->startApiCall('CreateBucket', $request, $callOptions)->wait(); + } + + /** + * Creates a log bucket asynchronously that can be used to store log entries. + * + * After a bucket has been created, the bucket's location cannot be changed. + * + * The async variant is {@see ConfigServiceV2Client::createBucketAsyncAsync()} . + * + * @param CreateBucketRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createBucketAsync(CreateBucketRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateBucketAsync', $request, $callOptions)->wait(); + } + + /** + * Creates a new exclusion in the _Default sink 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. + * + * The async variant is {@see ConfigServiceV2Client::createExclusionAsync()} . + * + * @param CreateExclusionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LogExclusion + * + * @throws ApiException Thrown if the API call fails. + */ + public function createExclusion(CreateExclusionRequest $request, array $callOptions = []): LogExclusion + { + return $this->startApiCall('CreateExclusion', $request, $callOptions)->wait(); + } + + /** + * Asynchronously creates a linked dataset in BigQuery which makes it possible + * to use BigQuery to read the logs stored in the log bucket. A log bucket may + * currently only contain one link. + * + * The async variant is {@see ConfigServiceV2Client::createLinkAsync()} . + * + * @param CreateLinkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createLink(CreateLinkRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateLink', $request, $callOptions)->wait(); + } + + /** + * Creates a sink that exports specified log entries to a destination. The + * export of newly-ingested log entries begins immediately, unless the sink's + * `writer_identity` is not permitted to write to the destination. A sink can + * export log entries only from the resource owning the sink. + * + * The async variant is {@see ConfigServiceV2Client::createSinkAsync()} . + * + * @param CreateSinkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LogSink + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSink(CreateSinkRequest $request, array $callOptions = []): LogSink + { + return $this->startApiCall('CreateSink', $request, $callOptions)->wait(); + } + + /** + * Creates a view over log entries in a log bucket. A bucket may contain a + * maximum of 30 views. + * + * The async variant is {@see ConfigServiceV2Client::createViewAsync()} . + * + * @param CreateViewRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LogView + * + * @throws ApiException Thrown if the API call fails. + */ + public function createView(CreateViewRequest $request, array $callOptions = []): LogView + { + return $this->startApiCall('CreateView', $request, $callOptions)->wait(); + } + + /** + * Deletes a log bucket. + * + * Changes the bucket's `lifecycle_state` to the `DELETE_REQUESTED` state. + * After 7 days, the bucket will be purged and all log entries in the bucket + * will be permanently deleted. + * + * The async variant is {@see ConfigServiceV2Client::deleteBucketAsync()} . + * + * @param DeleteBucketRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteBucket(DeleteBucketRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteBucket', $request, $callOptions)->wait(); + } + + /** + * Deletes an exclusion in the _Default sink. + * + * The async variant is {@see ConfigServiceV2Client::deleteExclusionAsync()} . + * + * @param DeleteExclusionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteExclusion(DeleteExclusionRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteExclusion', $request, $callOptions)->wait(); + } + + /** + * Deletes a link. This will also delete the corresponding BigQuery linked + * dataset. + * + * The async variant is {@see ConfigServiceV2Client::deleteLinkAsync()} . + * + * @param DeleteLinkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteLink(DeleteLinkRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteLink', $request, $callOptions)->wait(); + } + + /** + * Deletes a sink. If the sink has a unique `writer_identity`, then that + * service account is also deleted. + * + * The async variant is {@see ConfigServiceV2Client::deleteSinkAsync()} . + * + * @param DeleteSinkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSink(DeleteSinkRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteSink', $request, $callOptions)->wait(); + } + + /** + * Deletes a view on a log bucket. + * If an `UNAVAILABLE` error is returned, this indicates that system is not in + * a state where it can delete the view. If this occurs, please try again in a + * few minutes. + * + * The async variant is {@see ConfigServiceV2Client::deleteViewAsync()} . + * + * @param DeleteViewRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteView(DeleteViewRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteView', $request, $callOptions)->wait(); + } + + /** + * Gets a log bucket. + * + * The async variant is {@see ConfigServiceV2Client::getBucketAsync()} . + * + * @param GetBucketRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LogBucket + * + * @throws ApiException Thrown if the API call fails. + */ + public function getBucket(GetBucketRequest $request, array $callOptions = []): LogBucket + { + return $this->startApiCall('GetBucket', $request, $callOptions)->wait(); + } + + /** + * Gets the Logging CMEK settings for the given resource. + * + * Note: CMEK for the Log Router can be configured for Google Cloud projects, + * folders, organizations and billing accounts. Once configured for an + * organization, it applies to all projects and folders in the Google Cloud + * organization. + * + * See [Enabling CMEK for Log + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. + * + * The async variant is {@see ConfigServiceV2Client::getCmekSettingsAsync()} . + * + * @param GetCmekSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CmekSettings + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCmekSettings(GetCmekSettingsRequest $request, array $callOptions = []): CmekSettings + { + return $this->startApiCall('GetCmekSettings', $request, $callOptions)->wait(); + } + + /** + * Gets the description of an exclusion in the _Default sink. + * + * The async variant is {@see ConfigServiceV2Client::getExclusionAsync()} . + * + * @param GetExclusionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LogExclusion + * + * @throws ApiException Thrown if the API call fails. + */ + public function getExclusion(GetExclusionRequest $request, array $callOptions = []): LogExclusion + { + return $this->startApiCall('GetExclusion', $request, $callOptions)->wait(); + } + + /** + * Gets a link. + * + * The async variant is {@see ConfigServiceV2Client::getLinkAsync()} . + * + * @param GetLinkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Link + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLink(GetLinkRequest $request, array $callOptions = []): Link + { + return $this->startApiCall('GetLink', $request, $callOptions)->wait(); + } + + /** + * Gets the Log Router settings for the given resource. + * + * Note: Settings for the Log Router can be get for Google Cloud projects, + * folders, organizations and billing accounts. Currently it can only be + * configured for organizations. Once configured for an organization, it + * applies to all projects and folders in the Google Cloud organization. + * + * See [Enabling CMEK for Log + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. + * + * The async variant is {@see ConfigServiceV2Client::getSettingsAsync()} . + * + * @param GetSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Settings + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSettings(GetSettingsRequest $request, array $callOptions = []): Settings + { + return $this->startApiCall('GetSettings', $request, $callOptions)->wait(); + } + + /** + * Gets a sink. + * + * The async variant is {@see ConfigServiceV2Client::getSinkAsync()} . + * + * @param GetSinkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LogSink + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSink(GetSinkRequest $request, array $callOptions = []): LogSink + { + return $this->startApiCall('GetSink', $request, $callOptions)->wait(); + } + + /** + * Gets a view on a log bucket.. + * + * The async variant is {@see ConfigServiceV2Client::getViewAsync()} . + * + * @param GetViewRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LogView + * + * @throws ApiException Thrown if the API call fails. + */ + public function getView(GetViewRequest $request, array $callOptions = []): LogView + { + return $this->startApiCall('GetView', $request, $callOptions)->wait(); + } + + /** + * Lists log buckets. + * + * The async variant is {@see ConfigServiceV2Client::listBucketsAsync()} . + * + * @param ListBucketsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listBuckets(ListBucketsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListBuckets', $request, $callOptions); + } + + /** + * Lists all the exclusions on the _Default sink in a parent resource. + * + * The async variant is {@see ConfigServiceV2Client::listExclusionsAsync()} . + * + * @param ListExclusionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listExclusions(ListExclusionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListExclusions', $request, $callOptions); + } + + /** + * Lists links. + * + * The async variant is {@see ConfigServiceV2Client::listLinksAsync()} . + * + * @param ListLinksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLinks(ListLinksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLinks', $request, $callOptions); + } + + /** + * Lists sinks. + * + * The async variant is {@see ConfigServiceV2Client::listSinksAsync()} . + * + * @param ListSinksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSinks(ListSinksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSinks', $request, $callOptions); + } + + /** + * Lists views on a log bucket. + * + * The async variant is {@see ConfigServiceV2Client::listViewsAsync()} . + * + * @param ListViewsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listViews(ListViewsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListViews', $request, $callOptions); + } + + /** + * Undeletes a log bucket. A bucket that has been deleted can be undeleted + * within the grace period of 7 days. + * + * The async variant is {@see ConfigServiceV2Client::undeleteBucketAsync()} . + * + * @param UndeleteBucketRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function undeleteBucket(UndeleteBucketRequest $request, array $callOptions = []): void + { + $this->startApiCall('UndeleteBucket', $request, $callOptions)->wait(); + } + + /** + * Updates a log bucket. + * + * If the bucket has a `lifecycle_state` of `DELETE_REQUESTED`, then + * `FAILED_PRECONDITION` will be returned. + * + * After a bucket has been created, the bucket's location cannot be changed. + * + * The async variant is {@see ConfigServiceV2Client::updateBucketAsync()} . + * + * @param UpdateBucketRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LogBucket + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateBucket(UpdateBucketRequest $request, array $callOptions = []): LogBucket + { + return $this->startApiCall('UpdateBucket', $request, $callOptions)->wait(); + } + + /** + * Updates a log bucket asynchronously. + * + * If the bucket has a `lifecycle_state` of `DELETE_REQUESTED`, then + * `FAILED_PRECONDITION` will be returned. + * + * After a bucket has been created, the bucket's location cannot be changed. + * + * The async variant is {@see ConfigServiceV2Client::updateBucketAsyncAsync()} . + * + * @param UpdateBucketRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateBucketAsync(UpdateBucketRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateBucketAsync', $request, $callOptions)->wait(); + } + + /** + * Updates the Log Router CMEK settings for the given resource. + * + * Note: CMEK for the Log Router can currently only be configured for Google + * Cloud organizations. Once configured, it applies to all projects and + * folders in the Google Cloud 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 Log + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. + * + * The async variant is {@see ConfigServiceV2Client::updateCmekSettingsAsync()} . + * + * @param UpdateCmekSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CmekSettings + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCmekSettings(UpdateCmekSettingsRequest $request, array $callOptions = []): CmekSettings + { + return $this->startApiCall('UpdateCmekSettings', $request, $callOptions)->wait(); + } + + /** + * Changes one or more properties of an existing exclusion in the _Default + * sink. + * + * The async variant is {@see ConfigServiceV2Client::updateExclusionAsync()} . + * + * @param UpdateExclusionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LogExclusion + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateExclusion(UpdateExclusionRequest $request, array $callOptions = []): LogExclusion + { + return $this->startApiCall('UpdateExclusion', $request, $callOptions)->wait(); + } + + /** + * Updates the Log Router settings for the given resource. + * + * Note: Settings for the Log Router can currently only be configured for + * Google Cloud organizations. Once configured, it applies to all projects and + * folders in the Google Cloud organization. + * + * [UpdateSettings][google.logging.v2.ConfigServiceV2.UpdateSettings] + * 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. 4) `location_id` is not supported by + * Logging. 5) `location_id` violate OrgPolicy. + * + * See [Enabling CMEK for Log + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. + * + * The async variant is {@see ConfigServiceV2Client::updateSettingsAsync()} . + * + * @param UpdateSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Settings + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSettings(UpdateSettingsRequest $request, array $callOptions = []): Settings + { + return $this->startApiCall('UpdateSettings', $request, $callOptions)->wait(); + } + + /** + * Updates a sink. This method replaces the following fields in the existing + * sink with values from the new sink: `destination`, and `filter`. + * + * The updated sink might also have a new `writer_identity`; see the + * `unique_writer_identity` field. + * + * The async variant is {@see ConfigServiceV2Client::updateSinkAsync()} . + * + * @param UpdateSinkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LogSink + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSink(UpdateSinkRequest $request, array $callOptions = []): LogSink + { + return $this->startApiCall('UpdateSink', $request, $callOptions)->wait(); + } + + /** + * Updates a view on a log bucket. This method replaces the following fields + * in the existing view with values from the new view: `filter`. + * If an `UNAVAILABLE` error is returned, this indicates that system is not in + * a state where it can update the view. If this occurs, please try again in a + * few minutes. + * + * The async variant is {@see ConfigServiceV2Client::updateViewAsync()} . + * + * @param UpdateViewRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LogView + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateView(UpdateViewRequest $request, array $callOptions = []): LogView + { + return $this->startApiCall('UpdateView', $request, $callOptions)->wait(); + } } diff --git a/Logging/src/V2/Client/LoggingServiceV2Client.php b/Logging/src/V2/Client/LoggingServiceV2Client.php index 7d35c15701b0..7e57372cd139 100644 --- a/Logging/src/V2/Client/LoggingServiceV2Client.php +++ b/Logging/src/V2/Client/LoggingServiceV2Client.php @@ -24,17 +24,488 @@ namespace Google\Cloud\Logging\V2\Client; -use Google\Cloud\Logging\V2\Client\BaseClient\LoggingServiceV2BaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\BidiStream; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Logging\V2\DeleteLogRequest; +use Google\Cloud\Logging\V2\ListLogEntriesRequest; +use Google\Cloud\Logging\V2\ListLogsRequest; +use Google\Cloud\Logging\V2\ListMonitoredResourceDescriptorsRequest; +use Google\Cloud\Logging\V2\WriteLogEntriesRequest; +use Google\Cloud\Logging\V2\WriteLogEntriesResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for ingesting and querying logs. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Logging\V2\LoggingServiceV2Client} for the stable implementation * * @experimental + * + * @method PromiseInterface deleteLogAsync(DeleteLogRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLogEntriesAsync(ListLogEntriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLogsAsync(ListLogsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listMonitoredResourceDescriptorsAsync(ListMonitoredResourceDescriptorsRequest $request, array $optionalArgs = []) + * @method PromiseInterface writeLogEntriesAsync(WriteLogEntriesRequest $request, array $optionalArgs = []) */ -final class LoggingServiceV2Client extends LoggingServiceV2BaseClient +final class LoggingServiceV2Client { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see LoggingServiceV2BaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.logging.v2.LoggingServiceV2'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'logging.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + 'https://www.googleapis.com/auth/logging.admin', + 'https://www.googleapis.com/auth/logging.read', + 'https://www.googleapis.com/auth/logging.write', + ]; + + 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', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/logging_service_v2_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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(string $billingAccount): string + { + return self::getPathTemplate('billingAccount')->render([ + 'billing_account' => $billingAccount, + ]); + } + + /** + * 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_account_log resource. + */ + public static function billingAccountLogName(string $billingAccount, string $log): string + { + return self::getPathTemplate('billingAccountLog')->render([ + 'billing_account' => $billingAccount, + 'log' => $log, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a folder + * resource. + * + * @param string $folder + * + * @return string The formatted folder resource. + */ + public static function folderName(string $folder): string + { + return self::getPathTemplate('folder')->render([ + 'folder' => $folder, + ]); + } + + /** + * 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. + */ + public static function folderLogName(string $folder, string $log): string + { + return self::getPathTemplate('folderLog')->render([ + 'folder' => $folder, + 'log' => $log, + ]); + } + + /** + * 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. + */ + public static function logName(string $project, string $log): string + { + return self::getPathTemplate('log')->render([ + 'project' => $project, + 'log' => $log, + ]); + } + + /** + * 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(string $organization): string + { + return self::getPathTemplate('organization')->render([ + 'organization' => $organization, + ]); + } + + /** + * 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. + */ + public static function organizationLogName(string $organization, string $log): string + { + return self::getPathTemplate('organizationLog')->render([ + 'organization' => $organization, + 'log' => $log, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $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(string $project, string $log): string + { + return self::getPathTemplate('projectLog')->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 + * - 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} + * - 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. + * + * @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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'logging.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes all the log entries in a log for the _Default Log Bucket. The log + * reappears if it receives new entries. Log entries written shortly before + * the delete operation might not be deleted. Entries received after the + * delete operation with a timestamp before the operation will be deleted. + * + * The async variant is {@see LoggingServiceV2Client::deleteLogAsync()} . + * + * @param DeleteLogRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteLog(DeleteLogRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteLog', $request, $callOptions)->wait(); + } + + /** + * 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). + * + * The async variant is {@see LoggingServiceV2Client::listLogEntriesAsync()} . + * + * @param ListLogEntriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLogEntries(ListLogEntriesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLogEntries', $request, $callOptions); + } + + /** + * Lists the logs in projects, organizations, folders, or billing accounts. + * Only logs that have entries are listed. + * + * The async variant is {@see LoggingServiceV2Client::listLogsAsync()} . + * + * @param ListLogsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLogs(ListLogsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLogs', $request, $callOptions); + } + + /** + * Lists the descriptors for monitored resource types used by Logging. + * + * The async variant is + * {@see LoggingServiceV2Client::listMonitoredResourceDescriptorsAsync()} . + * + * @param ListMonitoredResourceDescriptorsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listMonitoredResourceDescriptors(ListMonitoredResourceDescriptorsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListMonitoredResourceDescriptors', $request, $callOptions); + } + + /** + * Streaming read of log entries as they are ingested. Until the stream is + * terminated, it will continue reading logs. + * + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return BidiStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function tailLogEntries(array $callOptions = []): BidiStream + { + return $this->startApiCall('TailLogEntries', null, $callOptions); + } + + /** + * 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) + * + * The async variant is {@see LoggingServiceV2Client::writeLogEntriesAsync()} . + * + * @param WriteLogEntriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 WriteLogEntriesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function writeLogEntries(WriteLogEntriesRequest $request, array $callOptions = []): WriteLogEntriesResponse + { + return $this->startApiCall('WriteLogEntries', $request, $callOptions)->wait(); + } } diff --git a/Logging/src/V2/Client/MetricsServiceV2Client.php b/Logging/src/V2/Client/MetricsServiceV2Client.php index 8493f1ef838f..4b32cc62e9b1 100644 --- a/Logging/src/V2/Client/MetricsServiceV2Client.php +++ b/Logging/src/V2/Client/MetricsServiceV2Client.php @@ -24,17 +24,333 @@ namespace Google\Cloud\Logging\V2\Client; -use Google\Cloud\Logging\V2\Client\BaseClient\MetricsServiceV2BaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Logging\V2\CreateLogMetricRequest; +use Google\Cloud\Logging\V2\DeleteLogMetricRequest; +use Google\Cloud\Logging\V2\GetLogMetricRequest; +use Google\Cloud\Logging\V2\ListLogMetricsRequest; +use Google\Cloud\Logging\V2\LogMetric; +use Google\Cloud\Logging\V2\UpdateLogMetricRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for configuring logs-based metrics. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Logging\V2\MetricsServiceV2Client} for the stable implementation * * @experimental + * + * @method PromiseInterface createLogMetricAsync(CreateLogMetricRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteLogMetricAsync(DeleteLogMetricRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLogMetricAsync(GetLogMetricRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLogMetricsAsync(ListLogMetricsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateLogMetricAsync(UpdateLogMetricRequest $request, array $optionalArgs = []) */ -final class MetricsServiceV2Client extends MetricsServiceV2BaseClient +final class MetricsServiceV2Client { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see MetricsServiceV2BaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.logging.v2.MetricsServiceV2'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'logging.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + 'https://www.googleapis.com/auth/logging.admin', + 'https://www.googleapis.com/auth/logging.read', + 'https://www.googleapis.com/auth/logging.write', + ]; + + 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', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/metrics_service_v2_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a log_metric + * resource. + * + * @param string $project + * @param string $metric + * + * @return string The formatted log_metric resource. + */ + public static function logMetricName(string $project, string $metric): string + { + return self::getPathTemplate('logMetric')->render([ + 'project' => $project, + 'metric' => $metric, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->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 + * - 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. + * + * @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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'logging.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a logs-based metric. + * + * The async variant is {@see MetricsServiceV2Client::createLogMetricAsync()} . + * + * @param CreateLogMetricRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LogMetric + * + * @throws ApiException Thrown if the API call fails. + */ + public function createLogMetric(CreateLogMetricRequest $request, array $callOptions = []): LogMetric + { + return $this->startApiCall('CreateLogMetric', $request, $callOptions)->wait(); + } + + /** + * Deletes a logs-based metric. + * + * The async variant is {@see MetricsServiceV2Client::deleteLogMetricAsync()} . + * + * @param DeleteLogMetricRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteLogMetric(DeleteLogMetricRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteLogMetric', $request, $callOptions)->wait(); + } + + /** + * Gets a logs-based metric. + * + * The async variant is {@see MetricsServiceV2Client::getLogMetricAsync()} . + * + * @param GetLogMetricRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LogMetric + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLogMetric(GetLogMetricRequest $request, array $callOptions = []): LogMetric + { + return $this->startApiCall('GetLogMetric', $request, $callOptions)->wait(); + } + + /** + * Lists logs-based metrics. + * + * The async variant is {@see MetricsServiceV2Client::listLogMetricsAsync()} . + * + * @param ListLogMetricsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLogMetrics(ListLogMetricsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLogMetrics', $request, $callOptions); + } + + /** + * Creates or updates a logs-based metric. + * + * The async variant is {@see MetricsServiceV2Client::updateLogMetricAsync()} . + * + * @param UpdateLogMetricRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LogMetric + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateLogMetric(UpdateLogMetricRequest $request, array $callOptions = []): LogMetric + { + return $this->startApiCall('UpdateLogMetric', $request, $callOptions)->wait(); + } } diff --git a/ManagedIdentities/composer.json b/ManagedIdentities/composer.json index 0aef9837610e..8aaa44119cd2 100644 --- a/ManagedIdentities/composer.json +++ b/ManagedIdentities/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/ManagedIdentities/src/V1/Client/BaseClient/ManagedIdentitiesServiceBaseClient.php b/ManagedIdentities/src/V1/Client/BaseClient/ManagedIdentitiesServiceBaseClient.php deleted file mode 100644 index 0cbea39dfffe..000000000000 --- a/ManagedIdentities/src/V1/Client/BaseClient/ManagedIdentitiesServiceBaseClient.php +++ /dev/null @@ -1,559 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/managed_identities_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/managed_identities_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/managed_identities_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/managed_identities_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a domain - * resource. - * - * @param string $project - * @param string $location - * @param string $domain - * - * @return string The formatted domain resource. - */ - public static function domainName(string $project, string $location, string $domain): string - { - return self::getPathTemplate('domain')->render([ - 'project' => $project, - 'location' => $location, - 'domain' => $domain, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - domain: projects/{project}/locations/{location}/domains/{domain} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'managedidentities.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Adds an AD trust to a domain. - * - * The async variant is {@see self::attachTrustAsync()} . - * - * @param AttachTrustRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function attachTrust(AttachTrustRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AttachTrust', $request, $callOptions)->wait(); - } - - /** - * Creates a Microsoft AD domain. - * - * The async variant is {@see self::createMicrosoftAdDomainAsync()} . - * - * @param CreateMicrosoftAdDomainRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createMicrosoftAdDomain(CreateMicrosoftAdDomainRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateMicrosoftAdDomain', $request, $callOptions)->wait(); - } - - /** - * Deletes a domain. - * - * The async variant is {@see self::deleteDomainAsync()} . - * - * @param DeleteDomainRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDomain(DeleteDomainRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteDomain', $request, $callOptions)->wait(); - } - - /** - * Removes an AD trust. - * - * The async variant is {@see self::detachTrustAsync()} . - * - * @param DetachTrustRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function detachTrust(DetachTrustRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DetachTrust', $request, $callOptions)->wait(); - } - - /** - * Gets information about a domain. - * - * The async variant is {@see self::getDomainAsync()} . - * - * @param GetDomainRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Domain - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDomain(GetDomainRequest $request, array $callOptions = []): Domain - { - return $this->startApiCall('GetDomain', $request, $callOptions)->wait(); - } - - /** - * Lists domains in a project. - * - * The async variant is {@see self::listDomainsAsync()} . - * - * @param ListDomainsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDomains(ListDomainsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDomains', $request, $callOptions); - } - - /** - * Updates the DNS conditional forwarder. - * - * The async variant is {@see self::reconfigureTrustAsync()} . - * - * @param ReconfigureTrustRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function reconfigureTrust(ReconfigureTrustRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ReconfigureTrust', $request, $callOptions)->wait(); - } - - /** - * Resets a domain's administrator password. - * - * The async variant is {@see self::resetAdminPasswordAsync()} . - * - * @param ResetAdminPasswordRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ResetAdminPasswordResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function resetAdminPassword(ResetAdminPasswordRequest $request, array $callOptions = []): ResetAdminPasswordResponse - { - return $this->startApiCall('ResetAdminPassword', $request, $callOptions)->wait(); - } - - /** - * Updates the metadata and configuration of a domain. - * - * The async variant is {@see self::updateDomainAsync()} . - * - * @param UpdateDomainRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDomain(UpdateDomainRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateDomain', $request, $callOptions)->wait(); - } - - /** - * Validates a trust state, that the target domain is reachable, and that the - * target domain is able to accept incoming trust requests. - * - * The async variant is {@see self::validateTrustAsync()} . - * - * @param ValidateTrustRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function validateTrust(ValidateTrustRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ValidateTrust', $request, $callOptions)->wait(); - } -} diff --git a/ManagedIdentities/src/V1/Client/ManagedIdentitiesServiceClient.php b/ManagedIdentities/src/V1/Client/ManagedIdentitiesServiceClient.php index 843ec6eaa47a..6f6ce447e2eb 100644 --- a/ManagedIdentities/src/V1/Client/ManagedIdentitiesServiceClient.php +++ b/ManagedIdentities/src/V1/Client/ManagedIdentitiesServiceClient.php @@ -24,17 +24,540 @@ namespace Google\Cloud\ManagedIdentities\V1\Client; -use Google\Cloud\ManagedIdentities\V1\Client\BaseClient\ManagedIdentitiesServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\ManagedIdentities\V1\AttachTrustRequest; +use Google\Cloud\ManagedIdentities\V1\CreateMicrosoftAdDomainRequest; +use Google\Cloud\ManagedIdentities\V1\DeleteDomainRequest; +use Google\Cloud\ManagedIdentities\V1\DetachTrustRequest; +use Google\Cloud\ManagedIdentities\V1\Domain; +use Google\Cloud\ManagedIdentities\V1\GetDomainRequest; +use Google\Cloud\ManagedIdentities\V1\ListDomainsRequest; +use Google\Cloud\ManagedIdentities\V1\ReconfigureTrustRequest; +use Google\Cloud\ManagedIdentities\V1\ResetAdminPasswordRequest; +use Google\Cloud\ManagedIdentities\V1\ResetAdminPasswordResponse; +use Google\Cloud\ManagedIdentities\V1\UpdateDomainRequest; +use Google\Cloud\ManagedIdentities\V1\ValidateTrustRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: API Overview * - * This class is currently experimental and may be subject to changes. + * The `managedidentites.googleapis.com` service implements the Google Cloud + * Managed Identites API for identity services + * (e.g. Microsoft Active Directory). + * + * The Managed Identities service provides methods to manage + * (create/read/update/delete) domains, reset managed identities admin password, + * add/remove domain controllers in GCP regions and add/remove VPC peering. + * + * Data Model + * + * The Managed Identities service exposes the following resources: + * + * * Locations as global, named as follows: + * `projects/{project_id}/locations/global`. + * + * * Domains, named as follows: + * `/projects/{project_id}/locations/global/domain/{domain_name}`. + * + * The `{domain_name}` refers to fully qualified domain name in the customer + * project e.g. mydomain.myorganization.com, with the following restrictions: + * + * * Must contain only lowercase letters, numbers, periods and hyphens. + * * Must start with a letter. + * * Must contain between 2-64 characters. + * * Must end with a number or a letter. + * * Must not start with period. + * * First segement length (mydomain form example above) shouldn't exceed + * 15 chars. + * * The last segment cannot be fully numeric. + * * Must be unique within the customer project. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ManagedIdentities\V1\ManagedIdentitiesServiceClient} for the + * stable implementation * * @experimental + * + * @method PromiseInterface attachTrustAsync(AttachTrustRequest $request, array $optionalArgs = []) + * @method PromiseInterface createMicrosoftAdDomainAsync(CreateMicrosoftAdDomainRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDomainAsync(DeleteDomainRequest $request, array $optionalArgs = []) + * @method PromiseInterface detachTrustAsync(DetachTrustRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDomainAsync(GetDomainRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDomainsAsync(ListDomainsRequest $request, array $optionalArgs = []) + * @method PromiseInterface reconfigureTrustAsync(ReconfigureTrustRequest $request, array $optionalArgs = []) + * @method PromiseInterface resetAdminPasswordAsync(ResetAdminPasswordRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDomainAsync(UpdateDomainRequest $request, array $optionalArgs = []) + * @method PromiseInterface validateTrustAsync(ValidateTrustRequest $request, array $optionalArgs = []) */ -final class ManagedIdentitiesServiceClient extends ManagedIdentitiesServiceBaseClient +final class ManagedIdentitiesServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ManagedIdentitiesServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.managedidentities.v1.ManagedIdentitiesService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'managedidentities.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/managed_identities_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/managed_identities_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/managed_identities_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/managed_identities_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a domain + * resource. + * + * @param string $project + * @param string $location + * @param string $domain + * + * @return string The formatted domain resource. + */ + public static function domainName(string $project, string $location, string $domain): string + { + return self::getPathTemplate('domain')->render([ + 'project' => $project, + 'location' => $location, + 'domain' => $domain, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - domain: projects/{project}/locations/{location}/domains/{domain} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'managedidentities.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Adds an AD trust to a domain. + * + * The async variant is {@see ManagedIdentitiesServiceClient::attachTrustAsync()} . + * + * @param AttachTrustRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function attachTrust(AttachTrustRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AttachTrust', $request, $callOptions)->wait(); + } + + /** + * Creates a Microsoft AD domain. + * + * The async variant is + * {@see ManagedIdentitiesServiceClient::createMicrosoftAdDomainAsync()} . + * + * @param CreateMicrosoftAdDomainRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createMicrosoftAdDomain(CreateMicrosoftAdDomainRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateMicrosoftAdDomain', $request, $callOptions)->wait(); + } + + /** + * Deletes a domain. + * + * The async variant is {@see ManagedIdentitiesServiceClient::deleteDomainAsync()} + * . + * + * @param DeleteDomainRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDomain(DeleteDomainRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteDomain', $request, $callOptions)->wait(); + } + + /** + * Removes an AD trust. + * + * The async variant is {@see ManagedIdentitiesServiceClient::detachTrustAsync()} . + * + * @param DetachTrustRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function detachTrust(DetachTrustRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DetachTrust', $request, $callOptions)->wait(); + } + + /** + * Gets information about a domain. + * + * The async variant is {@see ManagedIdentitiesServiceClient::getDomainAsync()} . + * + * @param GetDomainRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Domain + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDomain(GetDomainRequest $request, array $callOptions = []): Domain + { + return $this->startApiCall('GetDomain', $request, $callOptions)->wait(); + } + + /** + * Lists domains in a project. + * + * The async variant is {@see ManagedIdentitiesServiceClient::listDomainsAsync()} . + * + * @param ListDomainsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDomains(ListDomainsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDomains', $request, $callOptions); + } + + /** + * Updates the DNS conditional forwarder. + * + * The async variant is + * {@see ManagedIdentitiesServiceClient::reconfigureTrustAsync()} . + * + * @param ReconfigureTrustRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function reconfigureTrust(ReconfigureTrustRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ReconfigureTrust', $request, $callOptions)->wait(); + } + + /** + * Resets a domain's administrator password. + * + * The async variant is + * {@see ManagedIdentitiesServiceClient::resetAdminPasswordAsync()} . + * + * @param ResetAdminPasswordRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ResetAdminPasswordResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function resetAdminPassword(ResetAdminPasswordRequest $request, array $callOptions = []): ResetAdminPasswordResponse + { + return $this->startApiCall('ResetAdminPassword', $request, $callOptions)->wait(); + } + + /** + * Updates the metadata and configuration of a domain. + * + * The async variant is {@see ManagedIdentitiesServiceClient::updateDomainAsync()} + * . + * + * @param UpdateDomainRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDomain(UpdateDomainRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateDomain', $request, $callOptions)->wait(); + } + + /** + * Validates a trust state, that the target domain is reachable, and that the + * target domain is able to accept incoming trust requests. + * + * The async variant is {@see ManagedIdentitiesServiceClient::validateTrustAsync()} + * . + * + * @param ValidateTrustRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function validateTrust(ValidateTrustRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ValidateTrust', $request, $callOptions)->wait(); + } } diff --git a/MediaTranslation/composer.json b/MediaTranslation/composer.json index a2fb1785ed4d..f174063a3414 100644 --- a/MediaTranslation/composer.json +++ b/MediaTranslation/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/MediaTranslation/src/V1beta1/Client/BaseClient/SpeechTranslationServiceBaseClient.php b/MediaTranslation/src/V1beta1/Client/BaseClient/SpeechTranslationServiceBaseClient.php deleted file mode 100644 index b765f52879a8..000000000000 --- a/MediaTranslation/src/V1beta1/Client/BaseClient/SpeechTranslationServiceBaseClient.php +++ /dev/null @@ -1,174 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/speech_translation_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/speech_translation_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/speech_translation_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/speech_translation_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'mediatranslation.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); - } - - /** - * Performs bidirectional streaming speech translation: receive results while - * sending audio. This method is only available via the gRPC API (not REST). - * - * @example samples/V1beta1/SpeechTranslationServiceClient/streaming_translate_speech.php - * - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return BidiStream - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function streamingTranslateSpeech(array $callOptions = []): BidiStream - { - return $this->startApiCall('StreamingTranslateSpeech', null, $callOptions); - } -} diff --git a/MediaTranslation/src/V1beta1/Client/SpeechTranslationServiceClient.php b/MediaTranslation/src/V1beta1/Client/SpeechTranslationServiceClient.php index c15d958ba103..9baa3a003ae6 100644 --- a/MediaTranslation/src/V1beta1/Client/SpeechTranslationServiceClient.php +++ b/MediaTranslation/src/V1beta1/Client/SpeechTranslationServiceClient.php @@ -26,17 +26,147 @@ namespace Google\Cloud\MediaTranslation\V1beta1\Client; -use Google\Cloud\MediaTranslation\V1beta1\Client\BaseClient\SpeechTranslationServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\BidiStream; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; /** - * {@inheritdoc} + * Service Description: Provides translation from/to media types. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental */ -final class SpeechTranslationServiceClient extends SpeechTranslationServiceBaseClient +final class SpeechTranslationServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SpeechTranslationServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.mediatranslation.v1beta1.SpeechTranslationService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'mediatranslation.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/speech_translation_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/speech_translation_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/speech_translation_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/speech_translation_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'mediatranslation.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); + } + + /** + * Performs bidirectional streaming speech translation: receive results while + * sending audio. This method is only available via the gRPC API (not REST). + * + * @example samples/V1beta1/SpeechTranslationServiceClient/streaming_translate_speech.php + * + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return BidiStream + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function streamingTranslateSpeech(array $callOptions = []): BidiStream + { + return $this->startApiCall('StreamingTranslateSpeech', null, $callOptions); + } } diff --git a/Memcache/composer.json b/Memcache/composer.json index 8dc0bc9f60d9..39a83442b238 100644 --- a/Memcache/composer.json +++ b/Memcache/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Memcache/src/V1/Client/BaseClient/CloudMemcacheBaseClient.php b/Memcache/src/V1/Client/BaseClient/CloudMemcacheBaseClient.php deleted file mode 100644 index 24ba2c34d617..000000000000 --- a/Memcache/src/V1/Client/BaseClient/CloudMemcacheBaseClient.php +++ /dev/null @@ -1,544 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/cloud_memcache_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/cloud_memcache_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/cloud_memcache_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/cloud_memcache_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a instance - * resource. - * - * @param string $project - * @param string $location - * @param string $instance - * - * @return string The formatted instance resource. - */ - public static function instanceName(string $project, string $location, string $instance): string - { - return self::getPathTemplate('instance')->render([ - 'project' => $project, - 'location' => $location, - 'instance' => $instance, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - instance: projects/{project}/locations/{location}/instances/{instance} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'memcache.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * `ApplyParameters` restarts the set of specified nodes in order to update - * them to the current set of parameters for the Memcached Instance. - * - * The async variant is {@see self::applyParametersAsync()} . - * - * @param ApplyParametersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function applyParameters(ApplyParametersRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ApplyParameters', $request, $callOptions)->wait(); - } - - /** - * Creates a new Instance in a given location. - * - * The async variant is {@see self::createInstanceAsync()} . - * - * @param CreateInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createInstance(CreateInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateInstance', $request, $callOptions)->wait(); - } - - /** - * Deletes a single Instance. - * - * The async variant is {@see self::deleteInstanceAsync()} . - * - * @param DeleteInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single Instance. - * - * The async variant is {@see self::getInstanceAsync()} . - * - * @param GetInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Instance - * - * @throws ApiException Thrown if the API call fails. - */ - public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance - { - return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); - } - - /** - * Lists Instances in a given location. - * - * The async variant is {@see self::listInstancesAsync()} . - * - * @param ListInstancesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listInstances(ListInstancesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListInstances', $request, $callOptions); - } - - /** - * Reschedules upcoming maintenance event. - * - * The async variant is {@see self::rescheduleMaintenanceAsync()} . - * - * @param RescheduleMaintenanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function rescheduleMaintenance(RescheduleMaintenanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RescheduleMaintenance', $request, $callOptions)->wait(); - } - - /** - * Updates an existing Instance in a given project and location. - * - * The async variant is {@see self::updateInstanceAsync()} . - * - * @param UpdateInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateInstance(UpdateInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateInstance', $request, $callOptions)->wait(); - } - - /** - * Updates the defined Memcached parameters for an existing instance. - * This method only stages the parameters, it must be followed by - * `ApplyParameters` to apply the parameters to nodes of the Memcached - * instance. - * - * The async variant is {@see self::updateParametersAsync()} . - * - * @param UpdateParametersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateParameters(UpdateParametersRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateParameters', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Memcache/src/V1/Client/CloudMemcacheClient.php b/Memcache/src/V1/Client/CloudMemcacheClient.php index a006b3176c05..3ccf52f9d461 100644 --- a/Memcache/src/V1/Client/CloudMemcacheClient.php +++ b/Memcache/src/V1/Client/CloudMemcacheClient.php @@ -24,17 +24,519 @@ namespace Google\Cloud\Memcache\V1\Client; -use Google\Cloud\Memcache\V1\Client\BaseClient\CloudMemcacheBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\Memcache\V1\ApplyParametersRequest; +use Google\Cloud\Memcache\V1\CreateInstanceRequest; +use Google\Cloud\Memcache\V1\DeleteInstanceRequest; +use Google\Cloud\Memcache\V1\GetInstanceRequest; +use Google\Cloud\Memcache\V1\Instance; +use Google\Cloud\Memcache\V1\ListInstancesRequest; +use Google\Cloud\Memcache\V1\RescheduleMaintenanceRequest; +use Google\Cloud\Memcache\V1\UpdateInstanceRequest; +use Google\Cloud\Memcache\V1\UpdateParametersRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Configures and manages Cloud Memorystore for Memcached instances. * - * This class is currently experimental and may be subject to changes. + * + * The `memcache.googleapis.com` service implements the Google Cloud Memorystore + * for Memcached API and defines the following resource model for managing + * Memorystore Memcached (also called Memcached below) instances: + * * The service works with a collection of cloud projects, named: `/projects/*` + * * Each project has a collection of available locations, named: `/locations/*` + * * Each location has a collection of Memcached instances, named: + * `/instances/*` + * * As such, Memcached instances are resources of the form: + * `/projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * + * Note that location_id must be a GCP `region`; for example: + * * `projects/my-memcached-project/locations/us-central1/instances/my-memcached` + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Memcache\V1\CloudMemcacheClient} for the stable implementation * * @experimental + * + * @method PromiseInterface applyParametersAsync(ApplyParametersRequest $request, array $optionalArgs = []) + * @method PromiseInterface createInstanceAsync(CreateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteInstanceAsync(DeleteInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInstanceAsync(GetInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInstancesAsync(ListInstancesRequest $request, array $optionalArgs = []) + * @method PromiseInterface rescheduleMaintenanceAsync(RescheduleMaintenanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateInstanceAsync(UpdateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateParametersAsync(UpdateParametersRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class CloudMemcacheClient extends CloudMemcacheBaseClient +final class CloudMemcacheClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CloudMemcacheBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.memcache.v1.CloudMemcache'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'memcache.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/cloud_memcache_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/cloud_memcache_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/cloud_memcache_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/cloud_memcache_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a instance + * resource. + * + * @param string $project + * @param string $location + * @param string $instance + * + * @return string The formatted instance resource. + */ + public static function instanceName(string $project, string $location, string $instance): string + { + return self::getPathTemplate('instance')->render([ + 'project' => $project, + 'location' => $location, + 'instance' => $instance, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - instance: projects/{project}/locations/{location}/instances/{instance} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'memcache.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * `ApplyParameters` restarts the set of specified nodes in order to update + * them to the current set of parameters for the Memcached Instance. + * + * The async variant is {@see CloudMemcacheClient::applyParametersAsync()} . + * + * @param ApplyParametersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function applyParameters(ApplyParametersRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ApplyParameters', $request, $callOptions)->wait(); + } + + /** + * Creates a new Instance in a given location. + * + * The async variant is {@see CloudMemcacheClient::createInstanceAsync()} . + * + * @param CreateInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createInstance(CreateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateInstance', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Instance. + * + * The async variant is {@see CloudMemcacheClient::deleteInstanceAsync()} . + * + * @param DeleteInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Instance. + * + * The async variant is {@see CloudMemcacheClient::getInstanceAsync()} . + * + * @param GetInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Instance + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance + { + return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); + } + + /** + * Lists Instances in a given location. + * + * The async variant is {@see CloudMemcacheClient::listInstancesAsync()} . + * + * @param ListInstancesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInstances(ListInstancesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInstances', $request, $callOptions); + } + + /** + * Reschedules upcoming maintenance event. + * + * The async variant is {@see CloudMemcacheClient::rescheduleMaintenanceAsync()} . + * + * @param RescheduleMaintenanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function rescheduleMaintenance(RescheduleMaintenanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RescheduleMaintenance', $request, $callOptions)->wait(); + } + + /** + * Updates an existing Instance in a given project and location. + * + * The async variant is {@see CloudMemcacheClient::updateInstanceAsync()} . + * + * @param UpdateInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateInstance(UpdateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateInstance', $request, $callOptions)->wait(); + } + + /** + * Updates the defined Memcached parameters for an existing instance. + * This method only stages the parameters, it must be followed by + * `ApplyParameters` to apply the parameters to nodes of the Memcached + * instance. + * + * The async variant is {@see CloudMemcacheClient::updateParametersAsync()} . + * + * @param UpdateParametersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateParameters(UpdateParametersRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateParameters', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see CloudMemcacheClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see CloudMemcacheClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/MigrationCenter/composer.json b/MigrationCenter/composer.json index eeef90b6da72..6030069b6d7f 100644 --- a/MigrationCenter/composer.json +++ b/MigrationCenter/composer.json @@ -18,7 +18,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.21.0" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/MigrationCenter/src/V1/Client/BaseClient/MigrationCenterBaseClient.php b/MigrationCenter/src/V1/Client/BaseClient/MigrationCenterBaseClient.php deleted file mode 100644 index 9de55a78d27b..000000000000 --- a/MigrationCenter/src/V1/Client/BaseClient/MigrationCenterBaseClient.php +++ /dev/null @@ -1,2158 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . - '/../../resources/migration_center_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../../resources/migration_center_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . '/../../resources/migration_center_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../../resources/migration_center_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; - $operation = new OperationResponse( - $operationName, - $this->getOperationsClient(), - $options - ); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a asset - * resource. - * - * @param string $project - * @param string $location - * @param string $asset - * - * @return string The formatted asset resource. - */ - public static function assetName( - string $project, - string $location, - string $asset - ): string { - return self::getPathTemplate('asset')->render([ - 'project' => $project, - 'location' => $location, - 'asset' => $asset, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a error_frame - * resource. - * - * @param string $project - * @param string $location - * @param string $source - * @param string $errorFrame - * - * @return string The formatted error_frame resource. - */ - public static function errorFrameName( - string $project, - string $location, - string $source, - string $errorFrame - ): string { - return self::getPathTemplate('errorFrame')->render([ - 'project' => $project, - 'location' => $location, - 'source' => $source, - 'error_frame' => $errorFrame, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a group - * resource. - * - * @param string $project - * @param string $location - * @param string $group - * - * @return string The formatted group resource. - */ - public static function groupName( - string $project, - string $location, - string $group - ): string { - return self::getPathTemplate('group')->render([ - 'project' => $project, - 'location' => $location, - 'group' => $group, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * import_data_file resource. - * - * @param string $project - * @param string $location - * @param string $importJob - * @param string $importDataFile - * - * @return string The formatted import_data_file resource. - */ - public static function importDataFileName( - string $project, - string $location, - string $importJob, - string $importDataFile - ): string { - return self::getPathTemplate('importDataFile')->render([ - 'project' => $project, - 'location' => $location, - 'import_job' => $importJob, - 'import_data_file' => $importDataFile, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a import_job - * resource. - * - * @param string $project - * @param string $location - * @param string $importJob - * - * @return string The formatted import_job resource. - */ - public static function importJobName( - string $project, - string $location, - string $importJob - ): string { - return self::getPathTemplate('importJob')->render([ - 'project' => $project, - 'location' => $location, - 'import_job' => $importJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName( - string $project, - string $location - ): string { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * preference_set resource. - * - * @param string $project - * @param string $location - * @param string $preferenceSet - * - * @return string The formatted preference_set resource. - */ - public static function preferenceSetName( - string $project, - string $location, - string $preferenceSet - ): string { - return self::getPathTemplate('preferenceSet')->render([ - 'project' => $project, - 'location' => $location, - 'preference_set' => $preferenceSet, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a report - * resource. - * - * @param string $project - * @param string $location - * @param string $reportConfig - * @param string $report - * - * @return string The formatted report resource. - */ - public static function reportName( - string $project, - string $location, - string $reportConfig, - string $report - ): string { - return self::getPathTemplate('report')->render([ - 'project' => $project, - 'location' => $location, - 'report_config' => $reportConfig, - 'report' => $report, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * report_config resource. - * - * @param string $project - * @param string $location - * @param string $reportConfig - * - * @return string The formatted report_config resource. - */ - public static function reportConfigName( - string $project, - string $location, - string $reportConfig - ): string { - return self::getPathTemplate('reportConfig')->render([ - 'project' => $project, - 'location' => $location, - 'report_config' => $reportConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a settings - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted settings resource. - */ - public static function settingsName( - string $project, - string $location - ): string { - return self::getPathTemplate('settings')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a source - * resource. - * - * @param string $project - * @param string $location - * @param string $source - * - * @return string The formatted source resource. - */ - public static function sourceName( - string $project, - string $location, - string $source - ): string { - return self::getPathTemplate('source')->render([ - 'project' => $project, - 'location' => $location, - 'source' => $source, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - asset: projects/{project}/locations/{location}/assets/{asset} - * - errorFrame: projects/{project}/locations/{location}/sources/{source}/errorFrames/{error_frame} - * - group: projects/{project}/locations/{location}/groups/{group} - * - importDataFile: projects/{project}/locations/{location}/importJobs/{import_job}/importDataFiles/{import_data_file} - * - importJob: projects/{project}/locations/{location}/importJobs/{import_job} - * - location: projects/{project}/locations/{location} - * - preferenceSet: projects/{project}/locations/{location}/preferenceSets/{preference_set} - * - report: projects/{project}/locations/{location}/reportConfigs/{report_config}/reports/{report} - * - reportConfig: projects/{project}/locations/{location}/reportConfigs/{report_config} - * - settings: projects/{project}/locations/{location}/settings - * - source: projects/{project}/locations/{location}/sources/{source} - * - * 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( - string $formattedName, - string $template = null - ): array { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'migrationcenter.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error( - 'Call to undefined method ' . __CLASS__ . "::$method()", - E_USER_ERROR - ); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Adds assets to a group. - * - * The async variant is {@see self::addAssetsToGroupAsync()} . - * - * @example samples/V1/MigrationCenterClient/add_assets_to_group.php - * - * @param AddAssetsToGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addAssetsToGroup( - AddAssetsToGroupRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'AddAssetsToGroup', - $request, - $callOptions - )->wait(); - } - - /** - * Aggregates the requested fields based on provided function. - * - * The async variant is {@see self::aggregateAssetsValuesAsync()} . - * - * @example samples/V1/MigrationCenterClient/aggregate_assets_values.php - * - * @param AggregateAssetsValuesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AggregateAssetsValuesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function aggregateAssetsValues( - AggregateAssetsValuesRequest $request, - array $callOptions = [] - ): AggregateAssetsValuesResponse { - return $this->startApiCall( - 'AggregateAssetsValues', - $request, - $callOptions - )->wait(); - } - - /** - * Deletes list of Assets. - * - * The async variant is {@see self::batchDeleteAssetsAsync()} . - * - * @example samples/V1/MigrationCenterClient/batch_delete_assets.php - * - * @param BatchDeleteAssetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchDeleteAssets( - BatchDeleteAssetsRequest $request, - array $callOptions = [] - ): void { - $this->startApiCall( - 'BatchDeleteAssets', - $request, - $callOptions - )->wait(); - } - - /** - * Updates the parameters of a list of assets. - * - * The async variant is {@see self::batchUpdateAssetsAsync()} . - * - * @example samples/V1/MigrationCenterClient/batch_update_assets.php - * - * @param BatchUpdateAssetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BatchUpdateAssetsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchUpdateAssets( - BatchUpdateAssetsRequest $request, - array $callOptions = [] - ): BatchUpdateAssetsResponse { - return $this->startApiCall( - 'BatchUpdateAssets', - $request, - $callOptions - )->wait(); - } - - /** - * Creates a new group in a given project and location. - * - * The async variant is {@see self::createGroupAsync()} . - * - * @example samples/V1/MigrationCenterClient/create_group.php - * - * @param CreateGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createGroup( - CreateGroupRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'CreateGroup', - $request, - $callOptions - )->wait(); - } - - /** - * Creates an import data file. - * - * The async variant is {@see self::createImportDataFileAsync()} . - * - * @example samples/V1/MigrationCenterClient/create_import_data_file.php - * - * @param CreateImportDataFileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createImportDataFile( - CreateImportDataFileRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'CreateImportDataFile', - $request, - $callOptions - )->wait(); - } - - /** - * Creates an import job. - * - * The async variant is {@see self::createImportJobAsync()} . - * - * @example samples/V1/MigrationCenterClient/create_import_job.php - * - * @param CreateImportJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createImportJob( - CreateImportJobRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'CreateImportJob', - $request, - $callOptions - )->wait(); - } - - /** - * Creates a new preference set in a given project and location. - * - * The async variant is {@see self::createPreferenceSetAsync()} . - * - * @example samples/V1/MigrationCenterClient/create_preference_set.php - * - * @param CreatePreferenceSetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createPreferenceSet( - CreatePreferenceSetRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'CreatePreferenceSet', - $request, - $callOptions - )->wait(); - } - - /** - * Creates a report. - * - * The async variant is {@see self::createReportAsync()} . - * - * @example samples/V1/MigrationCenterClient/create_report.php - * - * @param CreateReportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createReport( - CreateReportRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'CreateReport', - $request, - $callOptions - )->wait(); - } - - /** - * Creates a report configuration. - * - * The async variant is {@see self::createReportConfigAsync()} . - * - * @example samples/V1/MigrationCenterClient/create_report_config.php - * - * @param CreateReportConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createReportConfig( - CreateReportConfigRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'CreateReportConfig', - $request, - $callOptions - )->wait(); - } - - /** - * Creates a new source in a given project and location. - * - * The async variant is {@see self::createSourceAsync()} . - * - * @example samples/V1/MigrationCenterClient/create_source.php - * - * @param CreateSourceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSource( - CreateSourceRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'CreateSource', - $request, - $callOptions - )->wait(); - } - - /** - * Deletes an asset. - * - * The async variant is {@see self::deleteAssetAsync()} . - * - * @example samples/V1/MigrationCenterClient/delete_asset.php - * - * @param DeleteAssetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAsset( - DeleteAssetRequest $request, - array $callOptions = [] - ): void { - $this->startApiCall('DeleteAsset', $request, $callOptions)->wait(); - } - - /** - * Deletes a group. - * - * The async variant is {@see self::deleteGroupAsync()} . - * - * @example samples/V1/MigrationCenterClient/delete_group.php - * - * @param DeleteGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteGroup( - DeleteGroupRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'DeleteGroup', - $request, - $callOptions - )->wait(); - } - - /** - * Delete an import data file. - * - * The async variant is {@see self::deleteImportDataFileAsync()} . - * - * @example samples/V1/MigrationCenterClient/delete_import_data_file.php - * - * @param DeleteImportDataFileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteImportDataFile( - DeleteImportDataFileRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'DeleteImportDataFile', - $request, - $callOptions - )->wait(); - } - - /** - * Deletes an import job. - * - * The async variant is {@see self::deleteImportJobAsync()} . - * - * @example samples/V1/MigrationCenterClient/delete_import_job.php - * - * @param DeleteImportJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteImportJob( - DeleteImportJobRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'DeleteImportJob', - $request, - $callOptions - )->wait(); - } - - /** - * Deletes a preference set. - * - * The async variant is {@see self::deletePreferenceSetAsync()} . - * - * @example samples/V1/MigrationCenterClient/delete_preference_set.php - * - * @param DeletePreferenceSetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deletePreferenceSet( - DeletePreferenceSetRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'DeletePreferenceSet', - $request, - $callOptions - )->wait(); - } - - /** - * Deletes a Report. - * - * The async variant is {@see self::deleteReportAsync()} . - * - * @example samples/V1/MigrationCenterClient/delete_report.php - * - * @param DeleteReportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteReport( - DeleteReportRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'DeleteReport', - $request, - $callOptions - )->wait(); - } - - /** - * Deletes a ReportConfig. - * - * The async variant is {@see self::deleteReportConfigAsync()} . - * - * @example samples/V1/MigrationCenterClient/delete_report_config.php - * - * @param DeleteReportConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteReportConfig( - DeleteReportConfigRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'DeleteReportConfig', - $request, - $callOptions - )->wait(); - } - - /** - * Deletes a source. - * - * The async variant is {@see self::deleteSourceAsync()} . - * - * @example samples/V1/MigrationCenterClient/delete_source.php - * - * @param DeleteSourceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSource( - DeleteSourceRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'DeleteSource', - $request, - $callOptions - )->wait(); - } - - /** - * Gets the details of an asset. - * - * The async variant is {@see self::getAssetAsync()} . - * - * @example samples/V1/MigrationCenterClient/get_asset.php - * - * @param GetAssetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Asset - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAsset( - GetAssetRequest $request, - array $callOptions = [] - ): Asset { - return $this->startApiCall('GetAsset', $request, $callOptions)->wait(); - } - - /** - * Gets the details of an error frame. - * - * The async variant is {@see self::getErrorFrameAsync()} . - * - * @example samples/V1/MigrationCenterClient/get_error_frame.php - * - * @param GetErrorFrameRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ErrorFrame - * - * @throws ApiException Thrown if the API call fails. - */ - public function getErrorFrame( - GetErrorFrameRequest $request, - array $callOptions = [] - ): ErrorFrame { - return $this->startApiCall( - 'GetErrorFrame', - $request, - $callOptions - )->wait(); - } - - /** - * Gets the details of a group. - * - * The async variant is {@see self::getGroupAsync()} . - * - * @example samples/V1/MigrationCenterClient/get_group.php - * - * @param GetGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Group - * - * @throws ApiException Thrown if the API call fails. - */ - public function getGroup( - GetGroupRequest $request, - array $callOptions = [] - ): Group { - return $this->startApiCall('GetGroup', $request, $callOptions)->wait(); - } - - /** - * Gets an import data file. - * - * The async variant is {@see self::getImportDataFileAsync()} . - * - * @example samples/V1/MigrationCenterClient/get_import_data_file.php - * - * @param GetImportDataFileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ImportDataFile - * - * @throws ApiException Thrown if the API call fails. - */ - public function getImportDataFile( - GetImportDataFileRequest $request, - array $callOptions = [] - ): ImportDataFile { - return $this->startApiCall( - 'GetImportDataFile', - $request, - $callOptions - )->wait(); - } - - /** - * Gets the details of an import job. - * - * The async variant is {@see self::getImportJobAsync()} . - * - * @example samples/V1/MigrationCenterClient/get_import_job.php - * - * @param GetImportJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ImportJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function getImportJob( - GetImportJobRequest $request, - array $callOptions = [] - ): ImportJob { - return $this->startApiCall( - 'GetImportJob', - $request, - $callOptions - )->wait(); - } - - /** - * Gets the details of a preference set. - * - * The async variant is {@see self::getPreferenceSetAsync()} . - * - * @example samples/V1/MigrationCenterClient/get_preference_set.php - * - * @param GetPreferenceSetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PreferenceSet - * - * @throws ApiException Thrown if the API call fails. - */ - public function getPreferenceSet( - GetPreferenceSetRequest $request, - array $callOptions = [] - ): PreferenceSet { - return $this->startApiCall( - 'GetPreferenceSet', - $request, - $callOptions - )->wait(); - } - - /** - * Gets details of a single Report. - * - * The async variant is {@see self::getReportAsync()} . - * - * @example samples/V1/MigrationCenterClient/get_report.php - * - * @param GetReportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Report - * - * @throws ApiException Thrown if the API call fails. - */ - public function getReport( - GetReportRequest $request, - array $callOptions = [] - ): Report { - return $this->startApiCall('GetReport', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single ReportConfig. - * - * The async variant is {@see self::getReportConfigAsync()} . - * - * @example samples/V1/MigrationCenterClient/get_report_config.php - * - * @param GetReportConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ReportConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getReportConfig( - GetReportConfigRequest $request, - array $callOptions = [] - ): ReportConfig { - return $this->startApiCall( - 'GetReportConfig', - $request, - $callOptions - )->wait(); - } - - /** - * Gets the details of regional settings. - * - * The async variant is {@see self::getSettingsAsync()} . - * - * @example samples/V1/MigrationCenterClient/get_settings.php - * - * @param GetSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Settings - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSettings( - GetSettingsRequest $request, - array $callOptions = [] - ): Settings { - return $this->startApiCall( - 'GetSettings', - $request, - $callOptions - )->wait(); - } - - /** - * Gets the details of a source. - * - * The async variant is {@see self::getSourceAsync()} . - * - * @example samples/V1/MigrationCenterClient/get_source.php - * - * @param GetSourceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Source - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSource( - GetSourceRequest $request, - array $callOptions = [] - ): Source { - return $this->startApiCall('GetSource', $request, $callOptions)->wait(); - } - - /** - * Lists all the assets in a given project and location. - * - * The async variant is {@see self::listAssetsAsync()} . - * - * @example samples/V1/MigrationCenterClient/list_assets.php - * - * @param ListAssetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAssets( - ListAssetsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListAssets', $request, $callOptions); - } - - /** - * Lists all error frames in a given source and location. - * - * The async variant is {@see self::listErrorFramesAsync()} . - * - * @example samples/V1/MigrationCenterClient/list_error_frames.php - * - * @param ListErrorFramesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listErrorFrames( - ListErrorFramesRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListErrorFrames', $request, $callOptions); - } - - /** - * Lists all groups in a given project and location. - * - * The async variant is {@see self::listGroupsAsync()} . - * - * @example samples/V1/MigrationCenterClient/list_groups.php - * - * @param ListGroupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listGroups( - ListGroupsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListGroups', $request, $callOptions); - } - - /** - * List import data files. - * - * The async variant is {@see self::listImportDataFilesAsync()} . - * - * @example samples/V1/MigrationCenterClient/list_import_data_files.php - * - * @param ListImportDataFilesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listImportDataFiles( - ListImportDataFilesRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall( - 'ListImportDataFiles', - $request, - $callOptions - ); - } - - /** - * Lists all import jobs. - * - * The async variant is {@see self::listImportJobsAsync()} . - * - * @example samples/V1/MigrationCenterClient/list_import_jobs.php - * - * @param ListImportJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listImportJobs( - ListImportJobsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListImportJobs', $request, $callOptions); - } - - /** - * Lists all the preference sets in a given project and location. - * - * The async variant is {@see self::listPreferenceSetsAsync()} . - * - * @example samples/V1/MigrationCenterClient/list_preference_sets.php - * - * @param ListPreferenceSetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPreferenceSets( - ListPreferenceSetsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall( - 'ListPreferenceSets', - $request, - $callOptions - ); - } - - /** - * Lists ReportConfigs in a given project and location. - * - * The async variant is {@see self::listReportConfigsAsync()} . - * - * @example samples/V1/MigrationCenterClient/list_report_configs.php - * - * @param ListReportConfigsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listReportConfigs( - ListReportConfigsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListReportConfigs', $request, $callOptions); - } - - /** - * Lists Reports in a given ReportConfig. - * - * The async variant is {@see self::listReportsAsync()} . - * - * @example samples/V1/MigrationCenterClient/list_reports.php - * - * @param ListReportsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listReports( - ListReportsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListReports', $request, $callOptions); - } - - /** - * Lists all the sources in a given project and location. - * - * The async variant is {@see self::listSourcesAsync()} . - * - * @example samples/V1/MigrationCenterClient/list_sources.php - * - * @param ListSourcesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSources( - ListSourcesRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListSources', $request, $callOptions); - } - - /** - * Removes assets from a group. - * - * The async variant is {@see self::removeAssetsFromGroupAsync()} . - * - * @example samples/V1/MigrationCenterClient/remove_assets_from_group.php - * - * @param RemoveAssetsFromGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function removeAssetsFromGroup( - RemoveAssetsFromGroupRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'RemoveAssetsFromGroup', - $request, - $callOptions - )->wait(); - } - - /** - * Reports a set of frames. - * - * The async variant is {@see self::reportAssetFramesAsync()} . - * - * @example samples/V1/MigrationCenterClient/report_asset_frames.php - * - * @param ReportAssetFramesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ReportAssetFramesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function reportAssetFrames( - ReportAssetFramesRequest $request, - array $callOptions = [] - ): ReportAssetFramesResponse { - return $this->startApiCall( - 'ReportAssetFrames', - $request, - $callOptions - )->wait(); - } - - /** - * Runs an import job. - * - * The async variant is {@see self::runImportJobAsync()} . - * - * @example samples/V1/MigrationCenterClient/run_import_job.php - * - * @param RunImportJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function runImportJob( - RunImportJobRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'RunImportJob', - $request, - $callOptions - )->wait(); - } - - /** - * Updates the parameters of an asset. - * - * The async variant is {@see self::updateAssetAsync()} . - * - * @example samples/V1/MigrationCenterClient/update_asset.php - * - * @param UpdateAssetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Asset - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAsset( - UpdateAssetRequest $request, - array $callOptions = [] - ): Asset { - return $this->startApiCall( - 'UpdateAsset', - $request, - $callOptions - )->wait(); - } - - /** - * Updates the parameters of a group. - * - * The async variant is {@see self::updateGroupAsync()} . - * - * @example samples/V1/MigrationCenterClient/update_group.php - * - * @param UpdateGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateGroup( - UpdateGroupRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'UpdateGroup', - $request, - $callOptions - )->wait(); - } - - /** - * Updates an import job. - * - * The async variant is {@see self::updateImportJobAsync()} . - * - * @example samples/V1/MigrationCenterClient/update_import_job.php - * - * @param UpdateImportJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateImportJob( - UpdateImportJobRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'UpdateImportJob', - $request, - $callOptions - )->wait(); - } - - /** - * Updates the parameters of a preference set. - * - * The async variant is {@see self::updatePreferenceSetAsync()} . - * - * @example samples/V1/MigrationCenterClient/update_preference_set.php - * - * @param UpdatePreferenceSetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updatePreferenceSet( - UpdatePreferenceSetRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'UpdatePreferenceSet', - $request, - $callOptions - )->wait(); - } - - /** - * Updates the regional-level project settings. - * - * The async variant is {@see self::updateSettingsAsync()} . - * - * @example samples/V1/MigrationCenterClient/update_settings.php - * - * @param UpdateSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSettings( - UpdateSettingsRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'UpdateSettings', - $request, - $callOptions - )->wait(); - } - - /** - * Updates the parameters of a source. - * - * The async variant is {@see self::updateSourceAsync()} . - * - * @example samples/V1/MigrationCenterClient/update_source.php - * - * @param UpdateSourceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSource( - UpdateSourceRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'UpdateSource', - $request, - $callOptions - )->wait(); - } - - /** - * Validates an import job. - * - * The async variant is {@see self::validateImportJobAsync()} . - * - * @example samples/V1/MigrationCenterClient/validate_import_job.php - * - * @param ValidateImportJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function validateImportJob( - ValidateImportJobRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'ValidateImportJob', - $request, - $callOptions - )->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/MigrationCenterClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation( - GetLocationRequest $request, - array $callOptions = [] - ): Location { - return $this->startApiCall( - 'GetLocation', - $request, - $callOptions - )->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/MigrationCenterClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations( - ListLocationsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/MigrationCenter/src/V1/Client/MigrationCenterClient.php b/MigrationCenter/src/V1/Client/MigrationCenterClient.php index 9848cfdeb13c..aff60a6c83d8 100644 --- a/MigrationCenter/src/V1/Client/MigrationCenterClient.php +++ b/MigrationCenter/src/V1/Client/MigrationCenterClient.php @@ -24,17 +24,1834 @@ namespace Google\Cloud\MigrationCenter\V1\Client; -use Google\Cloud\MigrationCenter\V1\Client\BaseClient\MigrationCenterBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\MigrationCenter\V1\AddAssetsToGroupRequest; +use Google\Cloud\MigrationCenter\V1\AggregateAssetsValuesRequest; +use Google\Cloud\MigrationCenter\V1\AggregateAssetsValuesResponse; +use Google\Cloud\MigrationCenter\V1\Asset; +use Google\Cloud\MigrationCenter\V1\BatchDeleteAssetsRequest; +use Google\Cloud\MigrationCenter\V1\BatchUpdateAssetsRequest; +use Google\Cloud\MigrationCenter\V1\BatchUpdateAssetsResponse; +use Google\Cloud\MigrationCenter\V1\CreateGroupRequest; +use Google\Cloud\MigrationCenter\V1\CreateImportDataFileRequest; +use Google\Cloud\MigrationCenter\V1\CreateImportJobRequest; +use Google\Cloud\MigrationCenter\V1\CreatePreferenceSetRequest; +use Google\Cloud\MigrationCenter\V1\CreateReportConfigRequest; +use Google\Cloud\MigrationCenter\V1\CreateReportRequest; +use Google\Cloud\MigrationCenter\V1\CreateSourceRequest; +use Google\Cloud\MigrationCenter\V1\DeleteAssetRequest; +use Google\Cloud\MigrationCenter\V1\DeleteGroupRequest; +use Google\Cloud\MigrationCenter\V1\DeleteImportDataFileRequest; +use Google\Cloud\MigrationCenter\V1\DeleteImportJobRequest; +use Google\Cloud\MigrationCenter\V1\DeletePreferenceSetRequest; +use Google\Cloud\MigrationCenter\V1\DeleteReportConfigRequest; +use Google\Cloud\MigrationCenter\V1\DeleteReportRequest; +use Google\Cloud\MigrationCenter\V1\DeleteSourceRequest; +use Google\Cloud\MigrationCenter\V1\ErrorFrame; +use Google\Cloud\MigrationCenter\V1\GetAssetRequest; +use Google\Cloud\MigrationCenter\V1\GetErrorFrameRequest; +use Google\Cloud\MigrationCenter\V1\GetGroupRequest; +use Google\Cloud\MigrationCenter\V1\GetImportDataFileRequest; +use Google\Cloud\MigrationCenter\V1\GetImportJobRequest; +use Google\Cloud\MigrationCenter\V1\GetPreferenceSetRequest; +use Google\Cloud\MigrationCenter\V1\GetReportConfigRequest; +use Google\Cloud\MigrationCenter\V1\GetReportRequest; +use Google\Cloud\MigrationCenter\V1\GetSettingsRequest; +use Google\Cloud\MigrationCenter\V1\GetSourceRequest; +use Google\Cloud\MigrationCenter\V1\Group; +use Google\Cloud\MigrationCenter\V1\ImportDataFile; +use Google\Cloud\MigrationCenter\V1\ImportJob; +use Google\Cloud\MigrationCenter\V1\ListAssetsRequest; +use Google\Cloud\MigrationCenter\V1\ListErrorFramesRequest; +use Google\Cloud\MigrationCenter\V1\ListGroupsRequest; +use Google\Cloud\MigrationCenter\V1\ListImportDataFilesRequest; +use Google\Cloud\MigrationCenter\V1\ListImportJobsRequest; +use Google\Cloud\MigrationCenter\V1\ListPreferenceSetsRequest; +use Google\Cloud\MigrationCenter\V1\ListReportConfigsRequest; +use Google\Cloud\MigrationCenter\V1\ListReportsRequest; +use Google\Cloud\MigrationCenter\V1\ListSourcesRequest; +use Google\Cloud\MigrationCenter\V1\PreferenceSet; +use Google\Cloud\MigrationCenter\V1\RemoveAssetsFromGroupRequest; +use Google\Cloud\MigrationCenter\V1\Report; +use Google\Cloud\MigrationCenter\V1\ReportAssetFramesRequest; +use Google\Cloud\MigrationCenter\V1\ReportAssetFramesResponse; +use Google\Cloud\MigrationCenter\V1\ReportConfig; +use Google\Cloud\MigrationCenter\V1\RunImportJobRequest; +use Google\Cloud\MigrationCenter\V1\Settings; +use Google\Cloud\MigrationCenter\V1\Source; +use Google\Cloud\MigrationCenter\V1\UpdateAssetRequest; +use Google\Cloud\MigrationCenter\V1\UpdateGroupRequest; +use Google\Cloud\MigrationCenter\V1\UpdateImportJobRequest; +use Google\Cloud\MigrationCenter\V1\UpdatePreferenceSetRequest; +use Google\Cloud\MigrationCenter\V1\UpdateSettingsRequest; +use Google\Cloud\MigrationCenter\V1\UpdateSourceRequest; +use Google\Cloud\MigrationCenter\V1\ValidateImportJobRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service describing handlers for resources. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface addAssetsToGroupAsync(AddAssetsToGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface aggregateAssetsValuesAsync(AggregateAssetsValuesRequest $request, array $optionalArgs = []) + * @method PromiseInterface batchDeleteAssetsAsync(BatchDeleteAssetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface batchUpdateAssetsAsync(BatchUpdateAssetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface createGroupAsync(CreateGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface createImportDataFileAsync(CreateImportDataFileRequest $request, array $optionalArgs = []) + * @method PromiseInterface createImportJobAsync(CreateImportJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface createPreferenceSetAsync(CreatePreferenceSetRequest $request, array $optionalArgs = []) + * @method PromiseInterface createReportAsync(CreateReportRequest $request, array $optionalArgs = []) + * @method PromiseInterface createReportConfigAsync(CreateReportConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSourceAsync(CreateSourceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAssetAsync(DeleteAssetRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteGroupAsync(DeleteGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteImportDataFileAsync(DeleteImportDataFileRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteImportJobAsync(DeleteImportJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface deletePreferenceSetAsync(DeletePreferenceSetRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteReportAsync(DeleteReportRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteReportConfigAsync(DeleteReportConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSourceAsync(DeleteSourceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAssetAsync(GetAssetRequest $request, array $optionalArgs = []) + * @method PromiseInterface getErrorFrameAsync(GetErrorFrameRequest $request, array $optionalArgs = []) + * @method PromiseInterface getGroupAsync(GetGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface getImportDataFileAsync(GetImportDataFileRequest $request, array $optionalArgs = []) + * @method PromiseInterface getImportJobAsync(GetImportJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getPreferenceSetAsync(GetPreferenceSetRequest $request, array $optionalArgs = []) + * @method PromiseInterface getReportAsync(GetReportRequest $request, array $optionalArgs = []) + * @method PromiseInterface getReportConfigAsync(GetReportConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSettingsAsync(GetSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSourceAsync(GetSourceRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAssetsAsync(ListAssetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listErrorFramesAsync(ListErrorFramesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listGroupsAsync(ListGroupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listImportDataFilesAsync(ListImportDataFilesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listImportJobsAsync(ListImportJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPreferenceSetsAsync(ListPreferenceSetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listReportConfigsAsync(ListReportConfigsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listReportsAsync(ListReportsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSourcesAsync(ListSourcesRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeAssetsFromGroupAsync(RemoveAssetsFromGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface reportAssetFramesAsync(ReportAssetFramesRequest $request, array $optionalArgs = []) + * @method PromiseInterface runImportJobAsync(RunImportJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAssetAsync(UpdateAssetRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateGroupAsync(UpdateGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateImportJobAsync(UpdateImportJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface updatePreferenceSetAsync(UpdatePreferenceSetRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSettingsAsync(UpdateSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSourceAsync(UpdateSourceRequest $request, array $optionalArgs = []) + * @method PromiseInterface validateImportJobAsync(ValidateImportJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class MigrationCenterClient extends MigrationCenterBaseClient +final class MigrationCenterClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see MigrationCenterBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.migrationcenter.v1.MigrationCenter'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'migrationcenter.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/migration_center_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/migration_center_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/migration_center_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/migration_center_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a asset + * resource. + * + * @param string $project + * @param string $location + * @param string $asset + * + * @return string The formatted asset resource. + */ + public static function assetName(string $project, string $location, string $asset): string + { + return self::getPathTemplate('asset')->render([ + 'project' => $project, + 'location' => $location, + 'asset' => $asset, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a error_frame + * resource. + * + * @param string $project + * @param string $location + * @param string $source + * @param string $errorFrame + * + * @return string The formatted error_frame resource. + */ + public static function errorFrameName(string $project, string $location, string $source, string $errorFrame): string + { + return self::getPathTemplate('errorFrame')->render([ + 'project' => $project, + 'location' => $location, + 'source' => $source, + 'error_frame' => $errorFrame, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a group + * resource. + * + * @param string $project + * @param string $location + * @param string $group + * + * @return string The formatted group resource. + */ + public static function groupName(string $project, string $location, string $group): string + { + return self::getPathTemplate('group')->render([ + 'project' => $project, + 'location' => $location, + 'group' => $group, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * import_data_file resource. + * + * @param string $project + * @param string $location + * @param string $importJob + * @param string $importDataFile + * + * @return string The formatted import_data_file resource. + */ + public static function importDataFileName(string $project, string $location, string $importJob, string $importDataFile): string + { + return self::getPathTemplate('importDataFile')->render([ + 'project' => $project, + 'location' => $location, + 'import_job' => $importJob, + 'import_data_file' => $importDataFile, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a import_job + * resource. + * + * @param string $project + * @param string $location + * @param string $importJob + * + * @return string The formatted import_job resource. + */ + public static function importJobName(string $project, string $location, string $importJob): string + { + return self::getPathTemplate('importJob')->render([ + 'project' => $project, + 'location' => $location, + 'import_job' => $importJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * preference_set resource. + * + * @param string $project + * @param string $location + * @param string $preferenceSet + * + * @return string The formatted preference_set resource. + */ + public static function preferenceSetName(string $project, string $location, string $preferenceSet): string + { + return self::getPathTemplate('preferenceSet')->render([ + 'project' => $project, + 'location' => $location, + 'preference_set' => $preferenceSet, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a report + * resource. + * + * @param string $project + * @param string $location + * @param string $reportConfig + * @param string $report + * + * @return string The formatted report resource. + */ + public static function reportName(string $project, string $location, string $reportConfig, string $report): string + { + return self::getPathTemplate('report')->render([ + 'project' => $project, + 'location' => $location, + 'report_config' => $reportConfig, + 'report' => $report, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * report_config resource. + * + * @param string $project + * @param string $location + * @param string $reportConfig + * + * @return string The formatted report_config resource. + */ + public static function reportConfigName(string $project, string $location, string $reportConfig): string + { + return self::getPathTemplate('reportConfig')->render([ + 'project' => $project, + 'location' => $location, + 'report_config' => $reportConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a settings + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted settings resource. + */ + public static function settingsName(string $project, string $location): string + { + return self::getPathTemplate('settings')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a source + * resource. + * + * @param string $project + * @param string $location + * @param string $source + * + * @return string The formatted source resource. + */ + public static function sourceName(string $project, string $location, string $source): string + { + return self::getPathTemplate('source')->render([ + 'project' => $project, + 'location' => $location, + 'source' => $source, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - asset: projects/{project}/locations/{location}/assets/{asset} + * - errorFrame: projects/{project}/locations/{location}/sources/{source}/errorFrames/{error_frame} + * - group: projects/{project}/locations/{location}/groups/{group} + * - importDataFile: projects/{project}/locations/{location}/importJobs/{import_job}/importDataFiles/{import_data_file} + * - importJob: projects/{project}/locations/{location}/importJobs/{import_job} + * - location: projects/{project}/locations/{location} + * - preferenceSet: projects/{project}/locations/{location}/preferenceSets/{preference_set} + * - report: projects/{project}/locations/{location}/reportConfigs/{report_config}/reports/{report} + * - reportConfig: projects/{project}/locations/{location}/reportConfigs/{report_config} + * - settings: projects/{project}/locations/{location}/settings + * - source: projects/{project}/locations/{location}/sources/{source} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'migrationcenter.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Adds assets to a group. + * + * The async variant is {@see MigrationCenterClient::addAssetsToGroupAsync()} . + * + * @example samples/V1/MigrationCenterClient/add_assets_to_group.php + * + * @param AddAssetsToGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addAssetsToGroup(AddAssetsToGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddAssetsToGroup', $request, $callOptions)->wait(); + } + + /** + * Aggregates the requested fields based on provided function. + * + * The async variant is {@see MigrationCenterClient::aggregateAssetsValuesAsync()} + * . + * + * @example samples/V1/MigrationCenterClient/aggregate_assets_values.php + * + * @param AggregateAssetsValuesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AggregateAssetsValuesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function aggregateAssetsValues(AggregateAssetsValuesRequest $request, array $callOptions = []): AggregateAssetsValuesResponse + { + return $this->startApiCall('AggregateAssetsValues', $request, $callOptions)->wait(); + } + + /** + * Deletes list of Assets. + * + * The async variant is {@see MigrationCenterClient::batchDeleteAssetsAsync()} . + * + * @example samples/V1/MigrationCenterClient/batch_delete_assets.php + * + * @param BatchDeleteAssetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchDeleteAssets(BatchDeleteAssetsRequest $request, array $callOptions = []): void + { + $this->startApiCall('BatchDeleteAssets', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a list of assets. + * + * The async variant is {@see MigrationCenterClient::batchUpdateAssetsAsync()} . + * + * @example samples/V1/MigrationCenterClient/batch_update_assets.php + * + * @param BatchUpdateAssetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BatchUpdateAssetsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchUpdateAssets(BatchUpdateAssetsRequest $request, array $callOptions = []): BatchUpdateAssetsResponse + { + return $this->startApiCall('BatchUpdateAssets', $request, $callOptions)->wait(); + } + + /** + * Creates a new group in a given project and location. + * + * The async variant is {@see MigrationCenterClient::createGroupAsync()} . + * + * @example samples/V1/MigrationCenterClient/create_group.php + * + * @param CreateGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createGroup(CreateGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateGroup', $request, $callOptions)->wait(); + } + + /** + * Creates an import data file. + * + * The async variant is {@see MigrationCenterClient::createImportDataFileAsync()} . + * + * @example samples/V1/MigrationCenterClient/create_import_data_file.php + * + * @param CreateImportDataFileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createImportDataFile(CreateImportDataFileRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateImportDataFile', $request, $callOptions)->wait(); + } + + /** + * Creates an import job. + * + * The async variant is {@see MigrationCenterClient::createImportJobAsync()} . + * + * @example samples/V1/MigrationCenterClient/create_import_job.php + * + * @param CreateImportJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createImportJob(CreateImportJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateImportJob', $request, $callOptions)->wait(); + } + + /** + * Creates a new preference set in a given project and location. + * + * The async variant is {@see MigrationCenterClient::createPreferenceSetAsync()} . + * + * @example samples/V1/MigrationCenterClient/create_preference_set.php + * + * @param CreatePreferenceSetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createPreferenceSet(CreatePreferenceSetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreatePreferenceSet', $request, $callOptions)->wait(); + } + + /** + * Creates a report. + * + * The async variant is {@see MigrationCenterClient::createReportAsync()} . + * + * @example samples/V1/MigrationCenterClient/create_report.php + * + * @param CreateReportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createReport(CreateReportRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateReport', $request, $callOptions)->wait(); + } + + /** + * Creates a report configuration. + * + * The async variant is {@see MigrationCenterClient::createReportConfigAsync()} . + * + * @example samples/V1/MigrationCenterClient/create_report_config.php + * + * @param CreateReportConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createReportConfig(CreateReportConfigRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateReportConfig', $request, $callOptions)->wait(); + } + + /** + * Creates a new source in a given project and location. + * + * The async variant is {@see MigrationCenterClient::createSourceAsync()} . + * + * @example samples/V1/MigrationCenterClient/create_source.php + * + * @param CreateSourceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSource(CreateSourceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateSource', $request, $callOptions)->wait(); + } + + /** + * Deletes an asset. + * + * The async variant is {@see MigrationCenterClient::deleteAssetAsync()} . + * + * @example samples/V1/MigrationCenterClient/delete_asset.php + * + * @param DeleteAssetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAsset(DeleteAssetRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteAsset', $request, $callOptions)->wait(); + } + + /** + * Deletes a group. + * + * The async variant is {@see MigrationCenterClient::deleteGroupAsync()} . + * + * @example samples/V1/MigrationCenterClient/delete_group.php + * + * @param DeleteGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteGroup(DeleteGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteGroup', $request, $callOptions)->wait(); + } + + /** + * Delete an import data file. + * + * The async variant is {@see MigrationCenterClient::deleteImportDataFileAsync()} . + * + * @example samples/V1/MigrationCenterClient/delete_import_data_file.php + * + * @param DeleteImportDataFileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteImportDataFile(DeleteImportDataFileRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteImportDataFile', $request, $callOptions)->wait(); + } + + /** + * Deletes an import job. + * + * The async variant is {@see MigrationCenterClient::deleteImportJobAsync()} . + * + * @example samples/V1/MigrationCenterClient/delete_import_job.php + * + * @param DeleteImportJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteImportJob(DeleteImportJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteImportJob', $request, $callOptions)->wait(); + } + + /** + * Deletes a preference set. + * + * The async variant is {@see MigrationCenterClient::deletePreferenceSetAsync()} . + * + * @example samples/V1/MigrationCenterClient/delete_preference_set.php + * + * @param DeletePreferenceSetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deletePreferenceSet(DeletePreferenceSetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeletePreferenceSet', $request, $callOptions)->wait(); + } + + /** + * Deletes a Report. + * + * The async variant is {@see MigrationCenterClient::deleteReportAsync()} . + * + * @example samples/V1/MigrationCenterClient/delete_report.php + * + * @param DeleteReportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteReport(DeleteReportRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteReport', $request, $callOptions)->wait(); + } + + /** + * Deletes a ReportConfig. + * + * The async variant is {@see MigrationCenterClient::deleteReportConfigAsync()} . + * + * @example samples/V1/MigrationCenterClient/delete_report_config.php + * + * @param DeleteReportConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteReportConfig(DeleteReportConfigRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteReportConfig', $request, $callOptions)->wait(); + } + + /** + * Deletes a source. + * + * The async variant is {@see MigrationCenterClient::deleteSourceAsync()} . + * + * @example samples/V1/MigrationCenterClient/delete_source.php + * + * @param DeleteSourceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSource(DeleteSourceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteSource', $request, $callOptions)->wait(); + } + + /** + * Gets the details of an asset. + * + * The async variant is {@see MigrationCenterClient::getAssetAsync()} . + * + * @example samples/V1/MigrationCenterClient/get_asset.php + * + * @param GetAssetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Asset + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAsset(GetAssetRequest $request, array $callOptions = []): Asset + { + return $this->startApiCall('GetAsset', $request, $callOptions)->wait(); + } + + /** + * Gets the details of an error frame. + * + * The async variant is {@see MigrationCenterClient::getErrorFrameAsync()} . + * + * @example samples/V1/MigrationCenterClient/get_error_frame.php + * + * @param GetErrorFrameRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ErrorFrame + * + * @throws ApiException Thrown if the API call fails. + */ + public function getErrorFrame(GetErrorFrameRequest $request, array $callOptions = []): ErrorFrame + { + return $this->startApiCall('GetErrorFrame', $request, $callOptions)->wait(); + } + + /** + * Gets the details of a group. + * + * The async variant is {@see MigrationCenterClient::getGroupAsync()} . + * + * @example samples/V1/MigrationCenterClient/get_group.php + * + * @param GetGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Group + * + * @throws ApiException Thrown if the API call fails. + */ + public function getGroup(GetGroupRequest $request, array $callOptions = []): Group + { + return $this->startApiCall('GetGroup', $request, $callOptions)->wait(); + } + + /** + * Gets an import data file. + * + * The async variant is {@see MigrationCenterClient::getImportDataFileAsync()} . + * + * @example samples/V1/MigrationCenterClient/get_import_data_file.php + * + * @param GetImportDataFileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ImportDataFile + * + * @throws ApiException Thrown if the API call fails. + */ + public function getImportDataFile(GetImportDataFileRequest $request, array $callOptions = []): ImportDataFile + { + return $this->startApiCall('GetImportDataFile', $request, $callOptions)->wait(); + } + + /** + * Gets the details of an import job. + * + * The async variant is {@see MigrationCenterClient::getImportJobAsync()} . + * + * @example samples/V1/MigrationCenterClient/get_import_job.php + * + * @param GetImportJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ImportJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function getImportJob(GetImportJobRequest $request, array $callOptions = []): ImportJob + { + return $this->startApiCall('GetImportJob', $request, $callOptions)->wait(); + } + + /** + * Gets the details of a preference set. + * + * The async variant is {@see MigrationCenterClient::getPreferenceSetAsync()} . + * + * @example samples/V1/MigrationCenterClient/get_preference_set.php + * + * @param GetPreferenceSetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PreferenceSet + * + * @throws ApiException Thrown if the API call fails. + */ + public function getPreferenceSet(GetPreferenceSetRequest $request, array $callOptions = []): PreferenceSet + { + return $this->startApiCall('GetPreferenceSet', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Report. + * + * The async variant is {@see MigrationCenterClient::getReportAsync()} . + * + * @example samples/V1/MigrationCenterClient/get_report.php + * + * @param GetReportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Report + * + * @throws ApiException Thrown if the API call fails. + */ + public function getReport(GetReportRequest $request, array $callOptions = []): Report + { + return $this->startApiCall('GetReport', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single ReportConfig. + * + * The async variant is {@see MigrationCenterClient::getReportConfigAsync()} . + * + * @example samples/V1/MigrationCenterClient/get_report_config.php + * + * @param GetReportConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ReportConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getReportConfig(GetReportConfigRequest $request, array $callOptions = []): ReportConfig + { + return $this->startApiCall('GetReportConfig', $request, $callOptions)->wait(); + } + + /** + * Gets the details of regional settings. + * + * The async variant is {@see MigrationCenterClient::getSettingsAsync()} . + * + * @example samples/V1/MigrationCenterClient/get_settings.php + * + * @param GetSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Settings + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSettings(GetSettingsRequest $request, array $callOptions = []): Settings + { + return $this->startApiCall('GetSettings', $request, $callOptions)->wait(); + } + + /** + * Gets the details of a source. + * + * The async variant is {@see MigrationCenterClient::getSourceAsync()} . + * + * @example samples/V1/MigrationCenterClient/get_source.php + * + * @param GetSourceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Source + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSource(GetSourceRequest $request, array $callOptions = []): Source + { + return $this->startApiCall('GetSource', $request, $callOptions)->wait(); + } + + /** + * Lists all the assets in a given project and location. + * + * The async variant is {@see MigrationCenterClient::listAssetsAsync()} . + * + * @example samples/V1/MigrationCenterClient/list_assets.php + * + * @param ListAssetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAssets(ListAssetsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAssets', $request, $callOptions); + } + + /** + * Lists all error frames in a given source and location. + * + * The async variant is {@see MigrationCenterClient::listErrorFramesAsync()} . + * + * @example samples/V1/MigrationCenterClient/list_error_frames.php + * + * @param ListErrorFramesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listErrorFrames(ListErrorFramesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListErrorFrames', $request, $callOptions); + } + + /** + * Lists all groups in a given project and location. + * + * The async variant is {@see MigrationCenterClient::listGroupsAsync()} . + * + * @example samples/V1/MigrationCenterClient/list_groups.php + * + * @param ListGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listGroups(ListGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListGroups', $request, $callOptions); + } + + /** + * List import data files. + * + * The async variant is {@see MigrationCenterClient::listImportDataFilesAsync()} . + * + * @example samples/V1/MigrationCenterClient/list_import_data_files.php + * + * @param ListImportDataFilesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listImportDataFiles(ListImportDataFilesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListImportDataFiles', $request, $callOptions); + } + + /** + * Lists all import jobs. + * + * The async variant is {@see MigrationCenterClient::listImportJobsAsync()} . + * + * @example samples/V1/MigrationCenterClient/list_import_jobs.php + * + * @param ListImportJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listImportJobs(ListImportJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListImportJobs', $request, $callOptions); + } + + /** + * Lists all the preference sets in a given project and location. + * + * The async variant is {@see MigrationCenterClient::listPreferenceSetsAsync()} . + * + * @example samples/V1/MigrationCenterClient/list_preference_sets.php + * + * @param ListPreferenceSetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPreferenceSets(ListPreferenceSetsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPreferenceSets', $request, $callOptions); + } + + /** + * Lists ReportConfigs in a given project and location. + * + * The async variant is {@see MigrationCenterClient::listReportConfigsAsync()} . + * + * @example samples/V1/MigrationCenterClient/list_report_configs.php + * + * @param ListReportConfigsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listReportConfigs(ListReportConfigsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListReportConfigs', $request, $callOptions); + } + + /** + * Lists Reports in a given ReportConfig. + * + * The async variant is {@see MigrationCenterClient::listReportsAsync()} . + * + * @example samples/V1/MigrationCenterClient/list_reports.php + * + * @param ListReportsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listReports(ListReportsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListReports', $request, $callOptions); + } + + /** + * Lists all the sources in a given project and location. + * + * The async variant is {@see MigrationCenterClient::listSourcesAsync()} . + * + * @example samples/V1/MigrationCenterClient/list_sources.php + * + * @param ListSourcesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSources(ListSourcesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSources', $request, $callOptions); + } + + /** + * Removes assets from a group. + * + * The async variant is {@see MigrationCenterClient::removeAssetsFromGroupAsync()} + * . + * + * @example samples/V1/MigrationCenterClient/remove_assets_from_group.php + * + * @param RemoveAssetsFromGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeAssetsFromGroup(RemoveAssetsFromGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RemoveAssetsFromGroup', $request, $callOptions)->wait(); + } + + /** + * Reports a set of frames. + * + * The async variant is {@see MigrationCenterClient::reportAssetFramesAsync()} . + * + * @example samples/V1/MigrationCenterClient/report_asset_frames.php + * + * @param ReportAssetFramesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ReportAssetFramesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function reportAssetFrames(ReportAssetFramesRequest $request, array $callOptions = []): ReportAssetFramesResponse + { + return $this->startApiCall('ReportAssetFrames', $request, $callOptions)->wait(); + } + + /** + * Runs an import job. + * + * The async variant is {@see MigrationCenterClient::runImportJobAsync()} . + * + * @example samples/V1/MigrationCenterClient/run_import_job.php + * + * @param RunImportJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function runImportJob(RunImportJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RunImportJob', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of an asset. + * + * The async variant is {@see MigrationCenterClient::updateAssetAsync()} . + * + * @example samples/V1/MigrationCenterClient/update_asset.php + * + * @param UpdateAssetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Asset + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAsset(UpdateAssetRequest $request, array $callOptions = []): Asset + { + return $this->startApiCall('UpdateAsset', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a group. + * + * The async variant is {@see MigrationCenterClient::updateGroupAsync()} . + * + * @example samples/V1/MigrationCenterClient/update_group.php + * + * @param UpdateGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateGroup(UpdateGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateGroup', $request, $callOptions)->wait(); + } + + /** + * Updates an import job. + * + * The async variant is {@see MigrationCenterClient::updateImportJobAsync()} . + * + * @example samples/V1/MigrationCenterClient/update_import_job.php + * + * @param UpdateImportJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateImportJob(UpdateImportJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateImportJob', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a preference set. + * + * The async variant is {@see MigrationCenterClient::updatePreferenceSetAsync()} . + * + * @example samples/V1/MigrationCenterClient/update_preference_set.php + * + * @param UpdatePreferenceSetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updatePreferenceSet(UpdatePreferenceSetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdatePreferenceSet', $request, $callOptions)->wait(); + } + + /** + * Updates the regional-level project settings. + * + * The async variant is {@see MigrationCenterClient::updateSettingsAsync()} . + * + * @example samples/V1/MigrationCenterClient/update_settings.php + * + * @param UpdateSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSettings(UpdateSettingsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateSettings', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a source. + * + * The async variant is {@see MigrationCenterClient::updateSourceAsync()} . + * + * @example samples/V1/MigrationCenterClient/update_source.php + * + * @param UpdateSourceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSource(UpdateSourceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateSource', $request, $callOptions)->wait(); + } + + /** + * Validates an import job. + * + * The async variant is {@see MigrationCenterClient::validateImportJobAsync()} . + * + * @example samples/V1/MigrationCenterClient/validate_import_job.php + * + * @param ValidateImportJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function validateImportJob(ValidateImportJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ValidateImportJob', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see MigrationCenterClient::getLocationAsync()} . + * + * @example samples/V1/MigrationCenterClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see MigrationCenterClient::listLocationsAsync()} . + * + * @example samples/V1/MigrationCenterClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Monitoring/composer.json b/Monitoring/composer.json index 3eff3510c01a..35c78bb7d7f7 100644 --- a/Monitoring/composer.json +++ b/Monitoring/composer.json @@ -5,11 +5,11 @@ "minimum-stability": "stable", "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", - "google/cloud-core": "^1.39" + "google/cloud-core": "^1.52.7" }, "suggest": { "ext-protobuf": "Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions." diff --git a/Monitoring/src/V3/Client/AlertPolicyServiceClient.php b/Monitoring/src/V3/Client/AlertPolicyServiceClient.php index 957cd888c7cf..60f420583b3a 100644 --- a/Monitoring/src/V3/Client/AlertPolicyServiceClient.php +++ b/Monitoring/src/V3/Client/AlertPolicyServiceClient.php @@ -24,15 +24,471 @@ namespace Google\Cloud\Monitoring\V3\Client; -use Google\Cloud\Monitoring\V3\Client\BaseClient\AlertPolicyServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Monitoring\V3\AlertPolicy; +use Google\Cloud\Monitoring\V3\CreateAlertPolicyRequest; +use Google\Cloud\Monitoring\V3\DeleteAlertPolicyRequest; +use Google\Cloud\Monitoring\V3\GetAlertPolicyRequest; +use Google\Cloud\Monitoring\V3\ListAlertPoliciesRequest; +use Google\Cloud\Monitoring\V3\UpdateAlertPolicyRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The AlertPolicyService API is used to manage (list, create, delete, + * edit) alert policies in Cloud Monitoring. An alerting policy is + * a description of the conditions under which some aspect of your + * system is considered to be "unhealthy" and the ways to notify + * people or services about this state. In addition to using this API, alert + * policies can also be managed through + * [Cloud Monitoring](https://cloud.google.com/monitoring/docs/), + * which can be reached by clicking the "Monitoring" tab in + * [Cloud console](https://console.cloud.google.com/). * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Monitoring\V3\AlertPolicyServiceClient} for the stable + * implementation + * + * @method PromiseInterface createAlertPolicyAsync(CreateAlertPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAlertPolicyAsync(DeleteAlertPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAlertPolicyAsync(GetAlertPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAlertPoliciesAsync(ListAlertPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAlertPolicyAsync(UpdateAlertPolicyRequest $request, array $optionalArgs = []) */ -final class AlertPolicyServiceClient extends AlertPolicyServiceBaseClient +final class AlertPolicyServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see AlertPolicyServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.monitoring.v3.AlertPolicyService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'monitoring.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/alert_policy_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/alert_policy_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/alert_policy_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/alert_policy_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a alert_policy + * resource. + * + * @param string $project + * @param string $alertPolicy + * + * @return string The formatted alert_policy resource. + */ + public static function alertPolicyName(string $project, string $alertPolicy): string + { + return self::getPathTemplate('alertPolicy')->render([ + 'project' => $project, + 'alert_policy' => $alertPolicy, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * alert_policy_condition resource. + * + * @param string $project + * @param string $alertPolicy + * @param string $condition + * + * @return string The formatted alert_policy_condition resource. + */ + public static function alertPolicyConditionName(string $project, string $alertPolicy, string $condition): string + { + return self::getPathTemplate('alertPolicyCondition')->render([ + 'project' => $project, + 'alert_policy' => $alertPolicy, + 'condition' => $condition, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_alert_policy resource. + * + * @param string $folder + * @param string $alertPolicy + * + * @return string The formatted folder_alert_policy resource. + */ + public static function folderAlertPolicyName(string $folder, string $alertPolicy): string + { + return self::getPathTemplate('folderAlertPolicy')->render([ + 'folder' => $folder, + 'alert_policy' => $alertPolicy, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_alert_policy_condition resource. + * + * @param string $folder + * @param string $alertPolicy + * @param string $condition + * + * @return string The formatted folder_alert_policy_condition resource. + */ + public static function folderAlertPolicyConditionName(string $folder, string $alertPolicy, string $condition): string + { + return self::getPathTemplate('folderAlertPolicyCondition')->render([ + 'folder' => $folder, + 'alert_policy' => $alertPolicy, + 'condition' => $condition, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_alert_policy resource. + * + * @param string $organization + * @param string $alertPolicy + * + * @return string The formatted organization_alert_policy resource. + */ + public static function organizationAlertPolicyName(string $organization, string $alertPolicy): string + { + return self::getPathTemplate('organizationAlertPolicy')->render([ + 'organization' => $organization, + 'alert_policy' => $alertPolicy, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_alert_policy_condition resource. + * + * @param string $organization + * @param string $alertPolicy + * @param string $condition + * + * @return string The formatted organization_alert_policy_condition resource. + */ + public static function organizationAlertPolicyConditionName(string $organization, string $alertPolicy, string $condition): string + { + return self::getPathTemplate('organizationAlertPolicyCondition')->render([ + 'organization' => $organization, + 'alert_policy' => $alertPolicy, + 'condition' => $condition, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_alert_policy resource. + * + * @param string $project + * @param string $alertPolicy + * + * @return string The formatted project_alert_policy resource. + */ + public static function projectAlertPolicyName(string $project, string $alertPolicy): string + { + return self::getPathTemplate('projectAlertPolicy')->render([ + 'project' => $project, + 'alert_policy' => $alertPolicy, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_alert_policy_condition resource. + * + * @param string $project + * @param string $alertPolicy + * @param string $condition + * + * @return string The formatted project_alert_policy_condition resource. + */ + public static function projectAlertPolicyConditionName(string $project, string $alertPolicy, string $condition): string + { + return self::getPathTemplate('projectAlertPolicyCondition')->render([ + 'project' => $project, + 'alert_policy' => $alertPolicy, + 'condition' => $condition, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - alertPolicy: projects/{project}/alertPolicies/{alert_policy} + * - alertPolicyCondition: projects/{project}/alertPolicies/{alert_policy}/conditions/{condition} + * - folderAlertPolicy: folders/{folder}/alertPolicies/{alert_policy} + * - folderAlertPolicyCondition: folders/{folder}/alertPolicies/{alert_policy}/conditions/{condition} + * - organizationAlertPolicy: organizations/{organization}/alertPolicies/{alert_policy} + * - organizationAlertPolicyCondition: organizations/{organization}/alertPolicies/{alert_policy}/conditions/{condition} + * - projectAlertPolicy: projects/{project}/alertPolicies/{alert_policy} + * - projectAlertPolicyCondition: projects/{project}/alertPolicies/{alert_policy}/conditions/{condition} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'monitoring.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new alerting policy. + * + * Design your application to single-thread API calls that modify the state of + * alerting policies in a single project. This includes calls to + * CreateAlertPolicy, DeleteAlertPolicy and UpdateAlertPolicy. + * + * The async variant is {@see AlertPolicyServiceClient::createAlertPolicyAsync()} . + * + * @param CreateAlertPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AlertPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAlertPolicy(CreateAlertPolicyRequest $request, array $callOptions = []): AlertPolicy + { + return $this->startApiCall('CreateAlertPolicy', $request, $callOptions)->wait(); + } + + /** + * Deletes an alerting policy. + * + * Design your application to single-thread API calls that modify the state of + * alerting policies in a single project. This includes calls to + * CreateAlertPolicy, DeleteAlertPolicy and UpdateAlertPolicy. + * + * The async variant is {@see AlertPolicyServiceClient::deleteAlertPolicyAsync()} . + * + * @param DeleteAlertPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAlertPolicy(DeleteAlertPolicyRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteAlertPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets a single alerting policy. + * + * The async variant is {@see AlertPolicyServiceClient::getAlertPolicyAsync()} . + * + * @param GetAlertPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AlertPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAlertPolicy(GetAlertPolicyRequest $request, array $callOptions = []): AlertPolicy + { + return $this->startApiCall('GetAlertPolicy', $request, $callOptions)->wait(); + } + + /** + * Lists the existing alerting policies for the workspace. + * + * The async variant is {@see AlertPolicyServiceClient::listAlertPoliciesAsync()} . + * + * @param ListAlertPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAlertPolicies(ListAlertPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAlertPolicies', $request, $callOptions); + } + + /** + * Updates an alerting policy. You can either replace the entire policy with + * a new one or replace only certain fields in the current alerting policy by + * specifying the fields to be updated via `updateMask`. Returns the + * updated alerting policy. + * + * Design your application to single-thread API calls that modify the state of + * alerting policies in a single project. This includes calls to + * CreateAlertPolicy, DeleteAlertPolicy and UpdateAlertPolicy. + * + * The async variant is {@see AlertPolicyServiceClient::updateAlertPolicyAsync()} . + * + * @param UpdateAlertPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AlertPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAlertPolicy(UpdateAlertPolicyRequest $request, array $callOptions = []): AlertPolicy + { + return $this->startApiCall('UpdateAlertPolicy', $request, $callOptions)->wait(); + } } diff --git a/Monitoring/src/V3/Client/BaseClient/AlertPolicyServiceBaseClient.php b/Monitoring/src/V3/Client/BaseClient/AlertPolicyServiceBaseClient.php deleted file mode 100644 index dcef670a7f01..000000000000 --- a/Monitoring/src/V3/Client/BaseClient/AlertPolicyServiceBaseClient.php +++ /dev/null @@ -1,496 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/alert_policy_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/alert_policy_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/alert_policy_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/alert_policy_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a alert_policy - * resource. - * - * @param string $project - * @param string $alertPolicy - * - * @return string The formatted alert_policy resource. - */ - public static function alertPolicyName(string $project, string $alertPolicy): string - { - return self::getPathTemplate('alertPolicy')->render([ - 'project' => $project, - 'alert_policy' => $alertPolicy, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * alert_policy_condition resource. - * - * @param string $project - * @param string $alertPolicy - * @param string $condition - * - * @return string The formatted alert_policy_condition resource. - */ - public static function alertPolicyConditionName(string $project, string $alertPolicy, string $condition): string - { - return self::getPathTemplate('alertPolicyCondition')->render([ - 'project' => $project, - 'alert_policy' => $alertPolicy, - 'condition' => $condition, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_alert_policy resource. - * - * @param string $folder - * @param string $alertPolicy - * - * @return string The formatted folder_alert_policy resource. - */ - public static function folderAlertPolicyName(string $folder, string $alertPolicy): string - { - return self::getPathTemplate('folderAlertPolicy')->render([ - 'folder' => $folder, - 'alert_policy' => $alertPolicy, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_alert_policy_condition resource. - * - * @param string $folder - * @param string $alertPolicy - * @param string $condition - * - * @return string The formatted folder_alert_policy_condition resource. - */ - public static function folderAlertPolicyConditionName(string $folder, string $alertPolicy, string $condition): string - { - return self::getPathTemplate('folderAlertPolicyCondition')->render([ - 'folder' => $folder, - 'alert_policy' => $alertPolicy, - 'condition' => $condition, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_alert_policy resource. - * - * @param string $organization - * @param string $alertPolicy - * - * @return string The formatted organization_alert_policy resource. - */ - public static function organizationAlertPolicyName(string $organization, string $alertPolicy): string - { - return self::getPathTemplate('organizationAlertPolicy')->render([ - 'organization' => $organization, - 'alert_policy' => $alertPolicy, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_alert_policy_condition resource. - * - * @param string $organization - * @param string $alertPolicy - * @param string $condition - * - * @return string The formatted organization_alert_policy_condition resource. - */ - public static function organizationAlertPolicyConditionName(string $organization, string $alertPolicy, string $condition): string - { - return self::getPathTemplate('organizationAlertPolicyCondition')->render([ - 'organization' => $organization, - 'alert_policy' => $alertPolicy, - 'condition' => $condition, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_alert_policy resource. - * - * @param string $project - * @param string $alertPolicy - * - * @return string The formatted project_alert_policy resource. - */ - public static function projectAlertPolicyName(string $project, string $alertPolicy): string - { - return self::getPathTemplate('projectAlertPolicy')->render([ - 'project' => $project, - 'alert_policy' => $alertPolicy, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_alert_policy_condition resource. - * - * @param string $project - * @param string $alertPolicy - * @param string $condition - * - * @return string The formatted project_alert_policy_condition resource. - */ - public static function projectAlertPolicyConditionName(string $project, string $alertPolicy, string $condition): string - { - return self::getPathTemplate('projectAlertPolicyCondition')->render([ - 'project' => $project, - 'alert_policy' => $alertPolicy, - 'condition' => $condition, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - alertPolicy: projects/{project}/alertPolicies/{alert_policy} - * - alertPolicyCondition: projects/{project}/alertPolicies/{alert_policy}/conditions/{condition} - * - folderAlertPolicy: folders/{folder}/alertPolicies/{alert_policy} - * - folderAlertPolicyCondition: folders/{folder}/alertPolicies/{alert_policy}/conditions/{condition} - * - organizationAlertPolicy: organizations/{organization}/alertPolicies/{alert_policy} - * - organizationAlertPolicyCondition: organizations/{organization}/alertPolicies/{alert_policy}/conditions/{condition} - * - projectAlertPolicy: projects/{project}/alertPolicies/{alert_policy} - * - projectAlertPolicyCondition: projects/{project}/alertPolicies/{alert_policy}/conditions/{condition} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'monitoring.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new alerting policy. - * - * Design your application to single-thread API calls that modify the state of - * alerting policies in a single project. This includes calls to - * CreateAlertPolicy, DeleteAlertPolicy and UpdateAlertPolicy. - * - * The async variant is {@see self::createAlertPolicyAsync()} . - * - * @param CreateAlertPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AlertPolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAlertPolicy(CreateAlertPolicyRequest $request, array $callOptions = []): AlertPolicy - { - return $this->startApiCall('CreateAlertPolicy', $request, $callOptions)->wait(); - } - - /** - * Deletes an alerting policy. - * - * Design your application to single-thread API calls that modify the state of - * alerting policies in a single project. This includes calls to - * CreateAlertPolicy, DeleteAlertPolicy and UpdateAlertPolicy. - * - * The async variant is {@see self::deleteAlertPolicyAsync()} . - * - * @param DeleteAlertPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAlertPolicy(DeleteAlertPolicyRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteAlertPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets a single alerting policy. - * - * The async variant is {@see self::getAlertPolicyAsync()} . - * - * @param GetAlertPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AlertPolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAlertPolicy(GetAlertPolicyRequest $request, array $callOptions = []): AlertPolicy - { - return $this->startApiCall('GetAlertPolicy', $request, $callOptions)->wait(); - } - - /** - * Lists the existing alerting policies for the workspace. - * - * The async variant is {@see self::listAlertPoliciesAsync()} . - * - * @param ListAlertPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAlertPolicies(ListAlertPoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAlertPolicies', $request, $callOptions); - } - - /** - * Updates an alerting policy. You can either replace the entire policy with - * a new one or replace only certain fields in the current alerting policy by - * specifying the fields to be updated via `updateMask`. Returns the - * updated alerting policy. - * - * Design your application to single-thread API calls that modify the state of - * alerting policies in a single project. This includes calls to - * CreateAlertPolicy, DeleteAlertPolicy and UpdateAlertPolicy. - * - * The async variant is {@see self::updateAlertPolicyAsync()} . - * - * @param UpdateAlertPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AlertPolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAlertPolicy(UpdateAlertPolicyRequest $request, array $callOptions = []): AlertPolicy - { - return $this->startApiCall('UpdateAlertPolicy', $request, $callOptions)->wait(); - } -} diff --git a/Monitoring/src/V3/Client/BaseClient/GroupServiceBaseClient.php b/Monitoring/src/V3/Client/BaseClient/GroupServiceBaseClient.php deleted file mode 100644 index 9cd242f7873f..000000000000 --- a/Monitoring/src/V3/Client/BaseClient/GroupServiceBaseClient.php +++ /dev/null @@ -1,430 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/group_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/group_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/group_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/group_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a folder_group - * resource. - * - * @param string $folder - * @param string $group - * - * @return string The formatted folder_group resource. - */ - public static function folderGroupName(string $folder, string $group): string - { - return self::getPathTemplate('folderGroup')->render([ - 'folder' => $folder, - 'group' => $group, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a group - * resource. - * - * @param string $project - * @param string $group - * - * @return string The formatted group resource. - */ - public static function groupName(string $project, string $group): string - { - return self::getPathTemplate('group')->render([ - 'project' => $project, - 'group' => $group, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_group resource. - * - * @param string $organization - * @param string $group - * - * @return string The formatted organization_group resource. - */ - public static function organizationGroupName(string $organization, string $group): string - { - return self::getPathTemplate('organizationGroup')->render([ - 'organization' => $organization, - 'group' => $group, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_group resource. - * - * @param string $project - * @param string $group - * - * @return string The formatted project_group resource. - */ - public static function projectGroupName(string $project, string $group): string - { - return self::getPathTemplate('projectGroup')->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 - * - folderGroup: folders/{folder}/groups/{group} - * - group: projects/{project}/groups/{group} - * - organizationGroup: organizations/{organization}/groups/{group} - * - projectGroup: 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. - */ - public static function parseName(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'monitoring.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new group. - * - * The async variant is {@see self::createGroupAsync()} . - * - * @param CreateGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Group - * - * @throws ApiException Thrown if the API call fails. - */ - public function createGroup(CreateGroupRequest $request, array $callOptions = []): Group - { - return $this->startApiCall('CreateGroup', $request, $callOptions)->wait(); - } - - /** - * Deletes an existing group. - * - * The async variant is {@see self::deleteGroupAsync()} . - * - * @param DeleteGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteGroup(DeleteGroupRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteGroup', $request, $callOptions)->wait(); - } - - /** - * Gets a single group. - * - * The async variant is {@see self::getGroupAsync()} . - * - * @param GetGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Group - * - * @throws ApiException Thrown if the API call fails. - */ - public function getGroup(GetGroupRequest $request, array $callOptions = []): Group - { - return $this->startApiCall('GetGroup', $request, $callOptions)->wait(); - } - - /** - * Lists the monitored resources that are members of a group. - * - * The async variant is {@see self::listGroupMembersAsync()} . - * - * @param ListGroupMembersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listGroupMembers(ListGroupMembersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListGroupMembers', $request, $callOptions); - } - - /** - * Lists the existing groups. - * - * The async variant is {@see self::listGroupsAsync()} . - * - * @param ListGroupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listGroups(ListGroupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListGroups', $request, $callOptions); - } - - /** - * Updates an existing group. - * You can change any group attributes except `name`. - * - * The async variant is {@see self::updateGroupAsync()} . - * - * @param UpdateGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Group - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateGroup(UpdateGroupRequest $request, array $callOptions = []): Group - { - return $this->startApiCall('UpdateGroup', $request, $callOptions)->wait(); - } -} diff --git a/Monitoring/src/V3/Client/BaseClient/MetricServiceBaseClient.php b/Monitoring/src/V3/Client/BaseClient/MetricServiceBaseClient.php deleted file mode 100644 index c8afeb5e2821..000000000000 --- a/Monitoring/src/V3/Client/BaseClient/MetricServiceBaseClient.php +++ /dev/null @@ -1,648 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/metric_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/metric_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/metric_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/metric_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a folder - * resource. - * - * @param string $folder - * - * @return string The formatted folder resource. - */ - public static function folderName(string $folder): string - { - return self::getPathTemplate('folder')->render([ - 'folder' => $folder, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_metric_descriptor resource. - * - * @param string $folder - * @param string $metricDescriptor - * - * @return string The formatted folder_metric_descriptor resource. - */ - public static function folderMetricDescriptorName(string $folder, string $metricDescriptor): string - { - return self::getPathTemplate('folderMetricDescriptor')->render([ - 'folder' => $folder, - 'metric_descriptor' => $metricDescriptor, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_monitored_resource_descriptor resource. - * - * @param string $folder - * @param string $monitoredResourceDescriptor - * - * @return string The formatted folder_monitored_resource_descriptor resource. - */ - public static function folderMonitoredResourceDescriptorName(string $folder, string $monitoredResourceDescriptor): string - { - return self::getPathTemplate('folderMonitoredResourceDescriptor')->render([ - 'folder' => $folder, - 'monitored_resource_descriptor' => $monitoredResourceDescriptor, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * metric_descriptor resource. - * - * @param string $project - * @param string $metricDescriptor - * - * @return string The formatted metric_descriptor resource. - */ - public static function metricDescriptorName(string $project, string $metricDescriptor): string - { - return self::getPathTemplate('metricDescriptor')->render([ - 'project' => $project, - 'metric_descriptor' => $metricDescriptor, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * monitored_resource_descriptor resource. - * - * @param string $project - * @param string $monitoredResourceDescriptor - * - * @return string The formatted monitored_resource_descriptor resource. - */ - public static function monitoredResourceDescriptorName(string $project, string $monitoredResourceDescriptor): string - { - return self::getPathTemplate('monitoredResourceDescriptor')->render([ - 'project' => $project, - 'monitored_resource_descriptor' => $monitoredResourceDescriptor, - ]); - } - - /** - * 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(string $organization): string - { - return self::getPathTemplate('organization')->render([ - 'organization' => $organization, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_metric_descriptor resource. - * - * @param string $organization - * @param string $metricDescriptor - * - * @return string The formatted organization_metric_descriptor resource. - */ - public static function organizationMetricDescriptorName(string $organization, string $metricDescriptor): string - { - return self::getPathTemplate('organizationMetricDescriptor')->render([ - 'organization' => $organization, - 'metric_descriptor' => $metricDescriptor, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_monitored_resource_descriptor resource. - * - * @param string $organization - * @param string $monitoredResourceDescriptor - * - * @return string The formatted organization_monitored_resource_descriptor resource. - */ - public static function organizationMonitoredResourceDescriptorName(string $organization, string $monitoredResourceDescriptor): string - { - return self::getPathTemplate('organizationMonitoredResourceDescriptor')->render([ - 'organization' => $organization, - 'monitored_resource_descriptor' => $monitoredResourceDescriptor, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_metric_descriptor resource. - * - * @param string $project - * @param string $metricDescriptor - * - * @return string The formatted project_metric_descriptor resource. - */ - public static function projectMetricDescriptorName(string $project, string $metricDescriptor): string - { - return self::getPathTemplate('projectMetricDescriptor')->render([ - 'project' => $project, - 'metric_descriptor' => $metricDescriptor, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_monitored_resource_descriptor resource. - * - * @param string $project - * @param string $monitoredResourceDescriptor - * - * @return string The formatted project_monitored_resource_descriptor resource. - */ - public static function projectMonitoredResourceDescriptorName(string $project, string $monitoredResourceDescriptor): string - { - return self::getPathTemplate('projectMonitoredResourceDescriptor')->render([ - 'project' => $project, - 'monitored_resource_descriptor' => $monitoredResourceDescriptor, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a workspace - * resource. - * - * @param string $project - * - * @return string The formatted workspace resource. - */ - public static function workspaceName(string $project): string - { - return self::getPathTemplate('workspace')->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 - * - folder: folders/{folder} - * - folderMetricDescriptor: folders/{folder}/metricDescriptors/{metric_descriptor=**} - * - folderMonitoredResourceDescriptor: folders/{folder}/monitoredResourceDescriptors/{monitored_resource_descriptor} - * - metricDescriptor: projects/{project}/metricDescriptors/{metric_descriptor=**} - * - monitoredResourceDescriptor: projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor} - * - organization: organizations/{organization} - * - organizationMetricDescriptor: organizations/{organization}/metricDescriptors/{metric_descriptor=**} - * - organizationMonitoredResourceDescriptor: organizations/{organization}/monitoredResourceDescriptors/{monitored_resource_descriptor} - * - project: projects/{project} - * - projectMetricDescriptor: projects/{project}/metricDescriptors/{metric_descriptor=**} - * - projectMonitoredResourceDescriptor: projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor} - * - workspace: 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. - */ - public static function parseName(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'monitoring.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new metric descriptor. - * The creation is executed asynchronously and callers may check the returned - * operation to track its progress. - * User-created metric descriptors define - * [custom metrics](https://cloud.google.com/monitoring/custom-metrics). - * - * The async variant is {@see self::createMetricDescriptorAsync()} . - * - * @param CreateMetricDescriptorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MetricDescriptor - * - * @throws ApiException Thrown if the API call fails. - */ - public function createMetricDescriptor(CreateMetricDescriptorRequest $request, array $callOptions = []): MetricDescriptor - { - return $this->startApiCall('CreateMetricDescriptor', $request, $callOptions)->wait(); - } - - /** - * Creates or adds data to one or more service time series. A service time - * series is a time series for a metric from a Google Cloud service. The - * response is empty if all time series in the request were written. If any - * time series could not be written, a corresponding failure message is - * included in the error response. This endpoint rejects writes to - * user-defined metrics. - * This method is only for use by Google Cloud services. Use - * [projects.timeSeries.create][google.monitoring.v3.MetricService.CreateTimeSeries] - * instead. - * - * The async variant is {@see self::createServiceTimeSeriesAsync()} . - * - * @param CreateTimeSeriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function createServiceTimeSeries(CreateTimeSeriesRequest $request, array $callOptions = []): void - { - $this->startApiCall('CreateServiceTimeSeries', $request, $callOptions)->wait(); - } - - /** - * Creates or adds data to one or more time series. - * The response is empty if all time series in the request were written. - * If any time series could not be written, a corresponding failure message is - * included in the error response. - * - * The async variant is {@see self::createTimeSeriesAsync()} . - * - * @param CreateTimeSeriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTimeSeries(CreateTimeSeriesRequest $request, array $callOptions = []): void - { - $this->startApiCall('CreateTimeSeries', $request, $callOptions)->wait(); - } - - /** - * Deletes a metric descriptor. Only user-created - * [custom metrics](https://cloud.google.com/monitoring/custom-metrics) can be - * deleted. - * - * The async variant is {@see self::deleteMetricDescriptorAsync()} . - * - * @param DeleteMetricDescriptorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteMetricDescriptor(DeleteMetricDescriptorRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteMetricDescriptor', $request, $callOptions)->wait(); - } - - /** - * Gets a single metric descriptor. This method does not require a Workspace. - * - * The async variant is {@see self::getMetricDescriptorAsync()} . - * - * @param GetMetricDescriptorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MetricDescriptor - * - * @throws ApiException Thrown if the API call fails. - */ - public function getMetricDescriptor(GetMetricDescriptorRequest $request, array $callOptions = []): MetricDescriptor - { - return $this->startApiCall('GetMetricDescriptor', $request, $callOptions)->wait(); - } - - /** - * Gets a single monitored resource descriptor. This method does not require a Workspace. - * - * The async variant is {@see self::getMonitoredResourceDescriptorAsync()} . - * - * @param GetMonitoredResourceDescriptorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MonitoredResourceDescriptor - * - * @throws ApiException Thrown if the API call fails. - */ - public function getMonitoredResourceDescriptor(GetMonitoredResourceDescriptorRequest $request, array $callOptions = []): MonitoredResourceDescriptor - { - return $this->startApiCall('GetMonitoredResourceDescriptor', $request, $callOptions)->wait(); - } - - /** - * Lists metric descriptors that match a filter. This method does not require a Workspace. - * - * The async variant is {@see self::listMetricDescriptorsAsync()} . - * - * @param ListMetricDescriptorsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listMetricDescriptors(ListMetricDescriptorsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListMetricDescriptors', $request, $callOptions); - } - - /** - * Lists monitored resource descriptors that match a filter. This method does not require a Workspace. - * - * The async variant is {@see self::listMonitoredResourceDescriptorsAsync()} . - * - * @param ListMonitoredResourceDescriptorsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listMonitoredResourceDescriptors(ListMonitoredResourceDescriptorsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListMonitoredResourceDescriptors', $request, $callOptions); - } - - /** - * Lists time series that match a filter. This method does not require a Workspace. - * - * The async variant is {@see self::listTimeSeriesAsync()} . - * - * @param ListTimeSeriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTimeSeries(ListTimeSeriesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTimeSeries', $request, $callOptions); - } -} diff --git a/Monitoring/src/V3/Client/BaseClient/NotificationChannelServiceBaseClient.php b/Monitoring/src/V3/Client/BaseClient/NotificationChannelServiceBaseClient.php deleted file mode 100644 index 819ca463b6b2..000000000000 --- a/Monitoring/src/V3/Client/BaseClient/NotificationChannelServiceBaseClient.php +++ /dev/null @@ -1,646 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/notification_channel_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/notification_channel_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/notification_channel_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/notification_channel_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_channel_descriptor resource. - * - * @param string $folder - * @param string $channelDescriptor - * - * @return string The formatted folder_channel_descriptor resource. - */ - public static function folderChannelDescriptorName(string $folder, string $channelDescriptor): string - { - return self::getPathTemplate('folderChannelDescriptor')->render([ - 'folder' => $folder, - 'channel_descriptor' => $channelDescriptor, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_notification_channel resource. - * - * @param string $folder - * @param string $notificationChannel - * - * @return string The formatted folder_notification_channel resource. - */ - public static function folderNotificationChannelName(string $folder, string $notificationChannel): string - { - return self::getPathTemplate('folderNotificationChannel')->render([ - 'folder' => $folder, - 'notification_channel' => $notificationChannel, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * notification_channel resource. - * - * @param string $project - * @param string $notificationChannel - * - * @return string The formatted notification_channel resource. - */ - public static function notificationChannelName(string $project, string $notificationChannel): string - { - return self::getPathTemplate('notificationChannel')->render([ - 'project' => $project, - 'notification_channel' => $notificationChannel, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * notification_channel_descriptor resource. - * - * @param string $project - * @param string $channelDescriptor - * - * @return string The formatted notification_channel_descriptor resource. - */ - public static function notificationChannelDescriptorName(string $project, string $channelDescriptor): string - { - return self::getPathTemplate('notificationChannelDescriptor')->render([ - 'project' => $project, - 'channel_descriptor' => $channelDescriptor, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_channel_descriptor resource. - * - * @param string $organization - * @param string $channelDescriptor - * - * @return string The formatted organization_channel_descriptor resource. - */ - public static function organizationChannelDescriptorName(string $organization, string $channelDescriptor): string - { - return self::getPathTemplate('organizationChannelDescriptor')->render([ - 'organization' => $organization, - 'channel_descriptor' => $channelDescriptor, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_notification_channel resource. - * - * @param string $organization - * @param string $notificationChannel - * - * @return string The formatted organization_notification_channel resource. - */ - public static function organizationNotificationChannelName(string $organization, string $notificationChannel): string - { - return self::getPathTemplate('organizationNotificationChannel')->render([ - 'organization' => $organization, - 'notification_channel' => $notificationChannel, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_channel_descriptor resource. - * - * @param string $project - * @param string $channelDescriptor - * - * @return string The formatted project_channel_descriptor resource. - */ - public static function projectChannelDescriptorName(string $project, string $channelDescriptor): string - { - return self::getPathTemplate('projectChannelDescriptor')->render([ - 'project' => $project, - 'channel_descriptor' => $channelDescriptor, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_notification_channel resource. - * - * @param string $project - * @param string $notificationChannel - * - * @return string The formatted project_notification_channel resource. - */ - public static function projectNotificationChannelName(string $project, string $notificationChannel): string - { - return self::getPathTemplate('projectNotificationChannel')->render([ - 'project' => $project, - 'notification_channel' => $notificationChannel, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - folderChannelDescriptor: folders/{folder}/notificationChannelDescriptors/{channel_descriptor} - * - folderNotificationChannel: folders/{folder}/notificationChannels/{notification_channel} - * - notificationChannel: projects/{project}/notificationChannels/{notification_channel} - * - notificationChannelDescriptor: projects/{project}/notificationChannelDescriptors/{channel_descriptor} - * - organizationChannelDescriptor: organizations/{organization}/notificationChannelDescriptors/{channel_descriptor} - * - organizationNotificationChannel: organizations/{organization}/notificationChannels/{notification_channel} - * - projectChannelDescriptor: projects/{project}/notificationChannelDescriptors/{channel_descriptor} - * - projectNotificationChannel: projects/{project}/notificationChannels/{notification_channel} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'monitoring.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new notification channel, representing a single notification - * endpoint such as an email address, SMS number, or PagerDuty service. - * - * Design your application to single-thread API calls that modify the state of - * notification channels in a single project. This includes calls to - * CreateNotificationChannel, DeleteNotificationChannel and - * UpdateNotificationChannel. - * - * The async variant is {@see self::createNotificationChannelAsync()} . - * - * @param CreateNotificationChannelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NotificationChannel - * - * @throws ApiException Thrown if the API call fails. - */ - public function createNotificationChannel(CreateNotificationChannelRequest $request, array $callOptions = []): NotificationChannel - { - return $this->startApiCall('CreateNotificationChannel', $request, $callOptions)->wait(); - } - - /** - * Deletes a notification channel. - * - * Design your application to single-thread API calls that modify the state of - * notification channels in a single project. This includes calls to - * CreateNotificationChannel, DeleteNotificationChannel and - * UpdateNotificationChannel. - * - * The async variant is {@see self::deleteNotificationChannelAsync()} . - * - * @param DeleteNotificationChannelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteNotificationChannel(DeleteNotificationChannelRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteNotificationChannel', $request, $callOptions)->wait(); - } - - /** - * Gets a single notification channel. The channel includes the relevant - * configuration details with which the channel was created. However, the - * response may truncate or omit passwords, API keys, or other private key - * matter and thus the response may not be 100% identical to the information - * that was supplied in the call to the create method. - * - * The async variant is {@see self::getNotificationChannelAsync()} . - * - * @param GetNotificationChannelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NotificationChannel - * - * @throws ApiException Thrown if the API call fails. - */ - public function getNotificationChannel(GetNotificationChannelRequest $request, array $callOptions = []): NotificationChannel - { - return $this->startApiCall('GetNotificationChannel', $request, $callOptions)->wait(); - } - - /** - * Gets a single channel descriptor. The descriptor indicates which fields - * are expected / permitted for a notification channel of the given type. - * - * The async variant is {@see self::getNotificationChannelDescriptorAsync()} . - * - * @param GetNotificationChannelDescriptorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NotificationChannelDescriptor - * - * @throws ApiException Thrown if the API call fails. - */ - public function getNotificationChannelDescriptor(GetNotificationChannelDescriptorRequest $request, array $callOptions = []): NotificationChannelDescriptor - { - return $this->startApiCall('GetNotificationChannelDescriptor', $request, $callOptions)->wait(); - } - - /** - * Requests a verification code for an already verified channel that can then - * be used in a call to VerifyNotificationChannel() on a different channel - * with an equivalent identity in the same or in a different project. This - * makes it possible to copy a channel between projects without requiring - * manual reverification of the channel. If the channel is not in the - * verified state, this method will fail (in other words, this may only be - * used if the SendNotificationChannelVerificationCode and - * VerifyNotificationChannel paths have already been used to put the given - * channel into the verified state). - * - * There is no guarantee that the verification codes returned by this method - * will be of a similar structure or form as the ones that are delivered - * to the channel via SendNotificationChannelVerificationCode; while - * VerifyNotificationChannel() will recognize both the codes delivered via - * SendNotificationChannelVerificationCode() and returned from - * GetNotificationChannelVerificationCode(), it is typically the case that - * the verification codes delivered via - * SendNotificationChannelVerificationCode() will be shorter and also - * have a shorter expiration (e.g. codes such as "G-123456") whereas - * GetVerificationCode() will typically return a much longer, websafe base - * 64 encoded string that has a longer expiration time. - * - * The async variant is {@see self::getNotificationChannelVerificationCodeAsync()} - * . - * - * @param GetNotificationChannelVerificationCodeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GetNotificationChannelVerificationCodeResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function getNotificationChannelVerificationCode(GetNotificationChannelVerificationCodeRequest $request, array $callOptions = []): GetNotificationChannelVerificationCodeResponse - { - return $this->startApiCall('GetNotificationChannelVerificationCode', $request, $callOptions)->wait(); - } - - /** - * Lists the descriptors for supported channel types. The use of descriptors - * makes it possible for new channel types to be dynamically added. - * - * The async variant is {@see self::listNotificationChannelDescriptorsAsync()} . - * - * @param ListNotificationChannelDescriptorsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listNotificationChannelDescriptors(ListNotificationChannelDescriptorsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListNotificationChannelDescriptors', $request, $callOptions); - } - - /** - * Lists the notification channels that have been created for the project. - * To list the types of notification channels that are supported, use - * the `ListNotificationChannelDescriptors` method. - * - * The async variant is {@see self::listNotificationChannelsAsync()} . - * - * @param ListNotificationChannelsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listNotificationChannels(ListNotificationChannelsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListNotificationChannels', $request, $callOptions); - } - - /** - * Causes a verification code to be delivered to the channel. The code - * can then be supplied in `VerifyNotificationChannel` to verify the channel. - * - * The async variant is {@see self::sendNotificationChannelVerificationCodeAsync()} - * . - * - * @param SendNotificationChannelVerificationCodeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function sendNotificationChannelVerificationCode(SendNotificationChannelVerificationCodeRequest $request, array $callOptions = []): void - { - $this->startApiCall('SendNotificationChannelVerificationCode', $request, $callOptions)->wait(); - } - - /** - * Updates a notification channel. Fields not specified in the field mask - * remain unchanged. - * - * Design your application to single-thread API calls that modify the state of - * notification channels in a single project. This includes calls to - * CreateNotificationChannel, DeleteNotificationChannel and - * UpdateNotificationChannel. - * - * The async variant is {@see self::updateNotificationChannelAsync()} . - * - * @param UpdateNotificationChannelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NotificationChannel - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateNotificationChannel(UpdateNotificationChannelRequest $request, array $callOptions = []): NotificationChannel - { - return $this->startApiCall('UpdateNotificationChannel', $request, $callOptions)->wait(); - } - - /** - * Verifies a `NotificationChannel` by proving receipt of the code - * delivered to the channel as a result of calling - * `SendNotificationChannelVerificationCode`. - * - * The async variant is {@see self::verifyNotificationChannelAsync()} . - * - * @param VerifyNotificationChannelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NotificationChannel - * - * @throws ApiException Thrown if the API call fails. - */ - public function verifyNotificationChannel(VerifyNotificationChannelRequest $request, array $callOptions = []): NotificationChannel - { - return $this->startApiCall('VerifyNotificationChannel', $request, $callOptions)->wait(); - } -} diff --git a/Monitoring/src/V3/Client/BaseClient/QueryServiceBaseClient.php b/Monitoring/src/V3/Client/BaseClient/QueryServiceBaseClient.php deleted file mode 100644 index a8677d938ca2..000000000000 --- a/Monitoring/src/V3/Client/BaseClient/QueryServiceBaseClient.php +++ /dev/null @@ -1,189 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/query_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/query_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/query_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/query_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'monitoring.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Queries time series using Monitoring Query Language. This method does not require a Workspace. - * - * The async variant is {@see self::queryTimeSeriesAsync()} . - * - * @param QueryTimeSeriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function queryTimeSeries(QueryTimeSeriesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('QueryTimeSeries', $request, $callOptions); - } -} diff --git a/Monitoring/src/V3/Client/BaseClient/ServiceMonitoringServiceBaseClient.php b/Monitoring/src/V3/Client/BaseClient/ServiceMonitoringServiceBaseClient.php deleted file mode 100644 index 6db055f05641..000000000000 --- a/Monitoring/src/V3/Client/BaseClient/ServiceMonitoringServiceBaseClient.php +++ /dev/null @@ -1,605 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/service_monitoring_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/service_monitoring_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/service_monitoring_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/service_monitoring_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_service resource. - * - * @param string $folder - * @param string $service - * - * @return string The formatted folder_service resource. - */ - public static function folderServiceName(string $folder, string $service): string - { - return self::getPathTemplate('folderService')->render([ - 'folder' => $folder, - 'service' => $service, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_service_service_level_objective resource. - * - * @param string $folder - * @param string $service - * @param string $serviceLevelObjective - * - * @return string The formatted folder_service_service_level_objective resource. - */ - public static function folderServiceServiceLevelObjectiveName(string $folder, string $service, string $serviceLevelObjective): string - { - return self::getPathTemplate('folderServiceServiceLevelObjective')->render([ - 'folder' => $folder, - 'service' => $service, - 'service_level_objective' => $serviceLevelObjective, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_service resource. - * - * @param string $organization - * @param string $service - * - * @return string The formatted organization_service resource. - */ - public static function organizationServiceName(string $organization, string $service): string - { - return self::getPathTemplate('organizationService')->render([ - 'organization' => $organization, - 'service' => $service, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_service_service_level_objective resource. - * - * @param string $organization - * @param string $service - * @param string $serviceLevelObjective - * - * @return string The formatted organization_service_service_level_objective resource. - */ - public static function organizationServiceServiceLevelObjectiveName(string $organization, string $service, string $serviceLevelObjective): string - { - return self::getPathTemplate('organizationServiceServiceLevelObjective')->render([ - 'organization' => $organization, - 'service' => $service, - 'service_level_objective' => $serviceLevelObjective, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_service resource. - * - * @param string $project - * @param string $service - * - * @return string The formatted project_service resource. - */ - public static function projectServiceName(string $project, string $service): string - { - return self::getPathTemplate('projectService')->render([ - 'project' => $project, - 'service' => $service, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_service_service_level_objective resource. - * - * @param string $project - * @param string $service - * @param string $serviceLevelObjective - * - * @return string The formatted project_service_service_level_objective resource. - */ - public static function projectServiceServiceLevelObjectiveName(string $project, string $service, string $serviceLevelObjective): string - { - return self::getPathTemplate('projectServiceServiceLevelObjective')->render([ - 'project' => $project, - 'service' => $service, - 'service_level_objective' => $serviceLevelObjective, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a service - * resource. - * - * @param string $project - * @param string $service - * - * @return string The formatted service resource. - */ - public static function serviceName(string $project, string $service): string - { - return self::getPathTemplate('service')->render([ - 'project' => $project, - 'service' => $service, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * service_level_objective resource. - * - * @param string $project - * @param string $service - * @param string $serviceLevelObjective - * - * @return string The formatted service_level_objective resource. - */ - public static function serviceLevelObjectiveName(string $project, string $service, string $serviceLevelObjective): string - { - return self::getPathTemplate('serviceLevelObjective')->render([ - 'project' => $project, - 'service' => $service, - 'service_level_objective' => $serviceLevelObjective, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - folderService: folders/{folder}/services/{service} - * - folderServiceServiceLevelObjective: folders/{folder}/services/{service}/serviceLevelObjectives/{service_level_objective} - * - organizationService: organizations/{organization}/services/{service} - * - organizationServiceServiceLevelObjective: organizations/{organization}/services/{service}/serviceLevelObjectives/{service_level_objective} - * - projectService: projects/{project}/services/{service} - * - projectServiceServiceLevelObjective: projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective} - * - service: projects/{project}/services/{service} - * - serviceLevelObjective: projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'monitoring.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Create a `Service`. - * - * The async variant is {@see self::createServiceAsync()} . - * - * @param CreateServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Service - * - * @throws ApiException Thrown if the API call fails. - */ - public function createService(CreateServiceRequest $request, array $callOptions = []): Service - { - return $this->startApiCall('CreateService', $request, $callOptions)->wait(); - } - - /** - * Create a `ServiceLevelObjective` for the given `Service`. - * - * The async variant is {@see self::createServiceLevelObjectiveAsync()} . - * - * @param CreateServiceLevelObjectiveRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ServiceLevelObjective - * - * @throws ApiException Thrown if the API call fails. - */ - public function createServiceLevelObjective(CreateServiceLevelObjectiveRequest $request, array $callOptions = []): ServiceLevelObjective - { - return $this->startApiCall('CreateServiceLevelObjective', $request, $callOptions)->wait(); - } - - /** - * Soft delete this `Service`. - * - * The async variant is {@see self::deleteServiceAsync()} . - * - * @param DeleteServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteService(DeleteServiceRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteService', $request, $callOptions)->wait(); - } - - /** - * Delete the given `ServiceLevelObjective`. - * - * The async variant is {@see self::deleteServiceLevelObjectiveAsync()} . - * - * @param DeleteServiceLevelObjectiveRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteServiceLevelObjective(DeleteServiceLevelObjectiveRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteServiceLevelObjective', $request, $callOptions)->wait(); - } - - /** - * Get the named `Service`. - * - * The async variant is {@see self::getServiceAsync()} . - * - * @param GetServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Service - * - * @throws ApiException Thrown if the API call fails. - */ - public function getService(GetServiceRequest $request, array $callOptions = []): Service - { - return $this->startApiCall('GetService', $request, $callOptions)->wait(); - } - - /** - * Get a `ServiceLevelObjective` by name. - * - * The async variant is {@see self::getServiceLevelObjectiveAsync()} . - * - * @param GetServiceLevelObjectiveRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ServiceLevelObjective - * - * @throws ApiException Thrown if the API call fails. - */ - public function getServiceLevelObjective(GetServiceLevelObjectiveRequest $request, array $callOptions = []): ServiceLevelObjective - { - return $this->startApiCall('GetServiceLevelObjective', $request, $callOptions)->wait(); - } - - /** - * List the `ServiceLevelObjective`s for the given `Service`. - * - * The async variant is {@see self::listServiceLevelObjectivesAsync()} . - * - * @param ListServiceLevelObjectivesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listServiceLevelObjectives(ListServiceLevelObjectivesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListServiceLevelObjectives', $request, $callOptions); - } - - /** - * List `Service`s for this workspace. - * - * The async variant is {@see self::listServicesAsync()} . - * - * @param ListServicesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listServices(ListServicesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListServices', $request, $callOptions); - } - - /** - * Update this `Service`. - * - * The async variant is {@see self::updateServiceAsync()} . - * - * @param UpdateServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Service - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateService(UpdateServiceRequest $request, array $callOptions = []): Service - { - return $this->startApiCall('UpdateService', $request, $callOptions)->wait(); - } - - /** - * Update the given `ServiceLevelObjective`. - * - * The async variant is {@see self::updateServiceLevelObjectiveAsync()} . - * - * @param UpdateServiceLevelObjectiveRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ServiceLevelObjective - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateServiceLevelObjective(UpdateServiceLevelObjectiveRequest $request, array $callOptions = []): ServiceLevelObjective - { - return $this->startApiCall('UpdateServiceLevelObjective', $request, $callOptions)->wait(); - } -} diff --git a/Monitoring/src/V3/Client/BaseClient/SnoozeServiceBaseClient.php b/Monitoring/src/V3/Client/BaseClient/SnoozeServiceBaseClient.php deleted file mode 100644 index 2b011f559892..000000000000 --- a/Monitoring/src/V3/Client/BaseClient/SnoozeServiceBaseClient.php +++ /dev/null @@ -1,424 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/snooze_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/snooze_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/snooze_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/snooze_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a alert_policy - * resource. - * - * @param string $project - * @param string $alertPolicy - * - * @return string The formatted alert_policy resource. - */ - public static function alertPolicyName(string $project, string $alertPolicy): string - { - return self::getPathTemplate('alertPolicy')->render([ - 'project' => $project, - 'alert_policy' => $alertPolicy, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_alert_policy resource. - * - * @param string $folder - * @param string $alertPolicy - * - * @return string The formatted folder_alert_policy resource. - */ - public static function folderAlertPolicyName(string $folder, string $alertPolicy): string - { - return self::getPathTemplate('folderAlertPolicy')->render([ - 'folder' => $folder, - 'alert_policy' => $alertPolicy, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_alert_policy resource. - * - * @param string $organization - * @param string $alertPolicy - * - * @return string The formatted organization_alert_policy resource. - */ - public static function organizationAlertPolicyName(string $organization, string $alertPolicy): string - { - return self::getPathTemplate('organizationAlertPolicy')->render([ - 'organization' => $organization, - 'alert_policy' => $alertPolicy, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_alert_policy resource. - * - * @param string $project - * @param string $alertPolicy - * - * @return string The formatted project_alert_policy resource. - */ - public static function projectAlertPolicyName(string $project, string $alertPolicy): string - { - return self::getPathTemplate('projectAlertPolicy')->render([ - 'project' => $project, - 'alert_policy' => $alertPolicy, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a snooze - * resource. - * - * @param string $project - * @param string $snooze - * - * @return string The formatted snooze resource. - */ - public static function snoozeName(string $project, string $snooze): string - { - return self::getPathTemplate('snooze')->render([ - 'project' => $project, - 'snooze' => $snooze, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a workspace - * resource. - * - * @param string $project - * - * @return string The formatted workspace resource. - */ - public static function workspaceName(string $project): string - { - return self::getPathTemplate('workspace')->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 - * - alertPolicy: projects/{project}/alertPolicies/{alert_policy} - * - folderAlertPolicy: folders/{folder}/alertPolicies/{alert_policy} - * - organizationAlertPolicy: organizations/{organization}/alertPolicies/{alert_policy} - * - project: projects/{project} - * - projectAlertPolicy: projects/{project}/alertPolicies/{alert_policy} - * - snooze: projects/{project}/snoozes/{snooze} - * - workspace: 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. - */ - public static function parseName(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'monitoring.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a `Snooze` that will prevent alerts, which match the provided - * criteria, from being opened. The `Snooze` applies for a specific time - * interval. - * - * The async variant is {@see self::createSnoozeAsync()} . - * - * @param CreateSnoozeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Snooze - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSnooze(CreateSnoozeRequest $request, array $callOptions = []): Snooze - { - return $this->startApiCall('CreateSnooze', $request, $callOptions)->wait(); - } - - /** - * Retrieves a `Snooze` by `name`. - * - * The async variant is {@see self::getSnoozeAsync()} . - * - * @param GetSnoozeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Snooze - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSnooze(GetSnoozeRequest $request, array $callOptions = []): Snooze - { - return $this->startApiCall('GetSnooze', $request, $callOptions)->wait(); - } - - /** - * Lists the `Snooze`s associated with a project. Can optionally pass in - * `filter`, which specifies predicates to match `Snooze`s. - * - * The async variant is {@see self::listSnoozesAsync()} . - * - * @param ListSnoozesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSnoozes(ListSnoozesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSnoozes', $request, $callOptions); - } - - /** - * Updates a `Snooze`, identified by its `name`, with the parameters in the - * given `Snooze` object. - * - * The async variant is {@see self::updateSnoozeAsync()} . - * - * @param UpdateSnoozeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Snooze - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSnooze(UpdateSnoozeRequest $request, array $callOptions = []): Snooze - { - return $this->startApiCall('UpdateSnooze', $request, $callOptions)->wait(); - } -} diff --git a/Monitoring/src/V3/Client/BaseClient/UptimeCheckServiceBaseClient.php b/Monitoring/src/V3/Client/BaseClient/UptimeCheckServiceBaseClient.php deleted file mode 100644 index d4535f6b060d..000000000000 --- a/Monitoring/src/V3/Client/BaseClient/UptimeCheckServiceBaseClient.php +++ /dev/null @@ -1,432 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/uptime_check_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/uptime_check_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/uptime_check_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/uptime_check_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_uptime_check_config resource. - * - * @param string $folder - * @param string $uptimeCheckConfig - * - * @return string The formatted folder_uptime_check_config resource. - */ - public static function folderUptimeCheckConfigName(string $folder, string $uptimeCheckConfig): string - { - return self::getPathTemplate('folderUptimeCheckConfig')->render([ - 'folder' => $folder, - 'uptime_check_config' => $uptimeCheckConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_uptime_check_config resource. - * - * @param string $organization - * @param string $uptimeCheckConfig - * - * @return string The formatted organization_uptime_check_config resource. - */ - public static function organizationUptimeCheckConfigName(string $organization, string $uptimeCheckConfig): string - { - return self::getPathTemplate('organizationUptimeCheckConfig')->render([ - 'organization' => $organization, - 'uptime_check_config' => $uptimeCheckConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_uptime_check_config resource. - * - * @param string $project - * @param string $uptimeCheckConfig - * - * @return string The formatted project_uptime_check_config resource. - */ - public static function projectUptimeCheckConfigName(string $project, string $uptimeCheckConfig): string - { - return self::getPathTemplate('projectUptimeCheckConfig')->render([ - 'project' => $project, - 'uptime_check_config' => $uptimeCheckConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * uptime_check_config resource. - * - * @param string $project - * @param string $uptimeCheckConfig - * - * @return string The formatted uptime_check_config resource. - */ - public static function uptimeCheckConfigName(string $project, string $uptimeCheckConfig): string - { - return self::getPathTemplate('uptimeCheckConfig')->render([ - 'project' => $project, - 'uptime_check_config' => $uptimeCheckConfig, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - folderUptimeCheckConfig: folders/{folder}/uptimeCheckConfigs/{uptime_check_config} - * - organizationUptimeCheckConfig: organizations/{organization}/uptimeCheckConfigs/{uptime_check_config} - * - projectUptimeCheckConfig: projects/{project}/uptimeCheckConfigs/{uptime_check_config} - * - uptimeCheckConfig: projects/{project}/uptimeCheckConfigs/{uptime_check_config} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'monitoring.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new Uptime check configuration. - * - * The async variant is {@see self::createUptimeCheckConfigAsync()} . - * - * @param CreateUptimeCheckConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 UptimeCheckConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function createUptimeCheckConfig(CreateUptimeCheckConfigRequest $request, array $callOptions = []): UptimeCheckConfig - { - return $this->startApiCall('CreateUptimeCheckConfig', $request, $callOptions)->wait(); - } - - /** - * Deletes an Uptime check configuration. Note that this method will fail - * if the Uptime check configuration is referenced by an alert policy or - * other dependent configs that would be rendered invalid by the deletion. - * - * The async variant is {@see self::deleteUptimeCheckConfigAsync()} . - * - * @param DeleteUptimeCheckConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteUptimeCheckConfig(DeleteUptimeCheckConfigRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteUptimeCheckConfig', $request, $callOptions)->wait(); - } - - /** - * Gets a single Uptime check configuration. - * - * The async variant is {@see self::getUptimeCheckConfigAsync()} . - * - * @param GetUptimeCheckConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 UptimeCheckConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getUptimeCheckConfig(GetUptimeCheckConfigRequest $request, array $callOptions = []): UptimeCheckConfig - { - return $this->startApiCall('GetUptimeCheckConfig', $request, $callOptions)->wait(); - } - - /** - * Lists the existing valid Uptime check configurations for the project - * (leaving out any invalid configurations). - * - * The async variant is {@see self::listUptimeCheckConfigsAsync()} . - * - * @param ListUptimeCheckConfigsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listUptimeCheckConfigs(ListUptimeCheckConfigsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListUptimeCheckConfigs', $request, $callOptions); - } - - /** - * Returns the list of IP addresses that checkers run from - * - * The async variant is {@see self::listUptimeCheckIpsAsync()} . - * - * @param ListUptimeCheckIpsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listUptimeCheckIps(ListUptimeCheckIpsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListUptimeCheckIps', $request, $callOptions); - } - - /** - * Updates an Uptime check configuration. You can either replace the entire - * configuration with a new one or replace only certain fields in the current - * configuration by specifying the fields to be updated via `updateMask`. - * Returns the updated configuration. - * - * The async variant is {@see self::updateUptimeCheckConfigAsync()} . - * - * @param UpdateUptimeCheckConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 UptimeCheckConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateUptimeCheckConfig(UpdateUptimeCheckConfigRequest $request, array $callOptions = []): UptimeCheckConfig - { - return $this->startApiCall('UpdateUptimeCheckConfig', $request, $callOptions)->wait(); - } -} diff --git a/Monitoring/src/V3/Client/GroupServiceClient.php b/Monitoring/src/V3/Client/GroupServiceClient.php index c0ef8d96286f..9991c0859f9a 100644 --- a/Monitoring/src/V3/Client/GroupServiceClient.php +++ b/Monitoring/src/V3/Client/GroupServiceClient.php @@ -24,15 +24,405 @@ namespace Google\Cloud\Monitoring\V3\Client; -use Google\Cloud\Monitoring\V3\Client\BaseClient\GroupServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Monitoring\V3\CreateGroupRequest; +use Google\Cloud\Monitoring\V3\DeleteGroupRequest; +use Google\Cloud\Monitoring\V3\GetGroupRequest; +use Google\Cloud\Monitoring\V3\Group; +use Google\Cloud\Monitoring\V3\ListGroupMembersRequest; +use Google\Cloud\Monitoring\V3\ListGroupsRequest; +use Google\Cloud\Monitoring\V3\UpdateGroupRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Group API lets you inspect and manage your + * [groups](#google.monitoring.v3.Group). * - * This class is currently experimental and may be subject to changes. + * A group is a named filter that is used to identify + * a collection of monitored resources. Groups are typically used to + * mirror the physical and/or logical topology of the environment. + * Because group membership is computed dynamically, monitored + * resources that are started in the future are automatically placed + * in matching groups. By using a group to name monitored resources in, + * for example, an alert policy, the target of that alert policy is + * updated automatically as monitored resources are added and removed + * from the infrastructure. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Monitoring\V3\GroupServiceClient} for the stable implementation + * + * @method PromiseInterface createGroupAsync(CreateGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteGroupAsync(DeleteGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface getGroupAsync(GetGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface listGroupMembersAsync(ListGroupMembersRequest $request, array $optionalArgs = []) + * @method PromiseInterface listGroupsAsync(ListGroupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateGroupAsync(UpdateGroupRequest $request, array $optionalArgs = []) */ -final class GroupServiceClient extends GroupServiceBaseClient +final class GroupServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see GroupServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.monitoring.v3.GroupService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'monitoring.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/group_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/group_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/group_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/group_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a folder_group + * resource. + * + * @param string $folder + * @param string $group + * + * @return string The formatted folder_group resource. + */ + public static function folderGroupName(string $folder, string $group): string + { + return self::getPathTemplate('folderGroup')->render([ + 'folder' => $folder, + 'group' => $group, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a group + * resource. + * + * @param string $project + * @param string $group + * + * @return string The formatted group resource. + */ + public static function groupName(string $project, string $group): string + { + return self::getPathTemplate('group')->render([ + 'project' => $project, + 'group' => $group, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_group resource. + * + * @param string $organization + * @param string $group + * + * @return string The formatted organization_group resource. + */ + public static function organizationGroupName(string $organization, string $group): string + { + return self::getPathTemplate('organizationGroup')->render([ + 'organization' => $organization, + 'group' => $group, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_group resource. + * + * @param string $project + * @param string $group + * + * @return string The formatted project_group resource. + */ + public static function projectGroupName(string $project, string $group): string + { + return self::getPathTemplate('projectGroup')->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 + * - folderGroup: folders/{folder}/groups/{group} + * - group: projects/{project}/groups/{group} + * - organizationGroup: organizations/{organization}/groups/{group} + * - projectGroup: 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. + */ + public static function parseName(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'monitoring.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new group. + * + * The async variant is {@see GroupServiceClient::createGroupAsync()} . + * + * @param CreateGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Group + * + * @throws ApiException Thrown if the API call fails. + */ + public function createGroup(CreateGroupRequest $request, array $callOptions = []): Group + { + return $this->startApiCall('CreateGroup', $request, $callOptions)->wait(); + } + + /** + * Deletes an existing group. + * + * The async variant is {@see GroupServiceClient::deleteGroupAsync()} . + * + * @param DeleteGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteGroup(DeleteGroupRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteGroup', $request, $callOptions)->wait(); + } + + /** + * Gets a single group. + * + * The async variant is {@see GroupServiceClient::getGroupAsync()} . + * + * @param GetGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Group + * + * @throws ApiException Thrown if the API call fails. + */ + public function getGroup(GetGroupRequest $request, array $callOptions = []): Group + { + return $this->startApiCall('GetGroup', $request, $callOptions)->wait(); + } + + /** + * Lists the monitored resources that are members of a group. + * + * The async variant is {@see GroupServiceClient::listGroupMembersAsync()} . + * + * @param ListGroupMembersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listGroupMembers(ListGroupMembersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListGroupMembers', $request, $callOptions); + } + + /** + * Lists the existing groups. + * + * The async variant is {@see GroupServiceClient::listGroupsAsync()} . + * + * @param ListGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listGroups(ListGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListGroups', $request, $callOptions); + } + + /** + * Updates an existing group. + * You can change any group attributes except `name`. + * + * The async variant is {@see GroupServiceClient::updateGroupAsync()} . + * + * @param UpdateGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Group + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateGroup(UpdateGroupRequest $request, array $callOptions = []): Group + { + return $this->startApiCall('UpdateGroup', $request, $callOptions)->wait(); + } } diff --git a/Monitoring/src/V3/Client/MetricServiceClient.php b/Monitoring/src/V3/Client/MetricServiceClient.php index 3c8cf42fa3fa..00f8f45d0bb4 100644 --- a/Monitoring/src/V3/Client/MetricServiceClient.php +++ b/Monitoring/src/V3/Client/MetricServiceClient.php @@ -24,15 +24,626 @@ namespace Google\Cloud\Monitoring\V3\Client; -use Google\Cloud\Monitoring\V3\Client\BaseClient\MetricServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Api\MetricDescriptor; +use Google\Api\MonitoredResourceDescriptor; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Monitoring\V3\CreateMetricDescriptorRequest; +use Google\Cloud\Monitoring\V3\CreateTimeSeriesRequest; +use Google\Cloud\Monitoring\V3\DeleteMetricDescriptorRequest; +use Google\Cloud\Monitoring\V3\GetMetricDescriptorRequest; +use Google\Cloud\Monitoring\V3\GetMonitoredResourceDescriptorRequest; +use Google\Cloud\Monitoring\V3\ListMetricDescriptorsRequest; +use Google\Cloud\Monitoring\V3\ListMonitoredResourceDescriptorsRequest; +use Google\Cloud\Monitoring\V3\ListTimeSeriesRequest; +use Google\Cloud\Monitoring\V3\TimeSeries; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Manages metric descriptors, monitored resource descriptors, and + * time series data. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Monitoring\V3\MetricServiceClient} for the stable implementation + * + * @method PromiseInterface createMetricDescriptorAsync(CreateMetricDescriptorRequest $request, array $optionalArgs = []) + * @method PromiseInterface createServiceTimeSeriesAsync(CreateTimeSeriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface createTimeSeriesAsync(CreateTimeSeriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteMetricDescriptorAsync(DeleteMetricDescriptorRequest $request, array $optionalArgs = []) + * @method PromiseInterface getMetricDescriptorAsync(GetMetricDescriptorRequest $request, array $optionalArgs = []) + * @method PromiseInterface getMonitoredResourceDescriptorAsync(GetMonitoredResourceDescriptorRequest $request, array $optionalArgs = []) + * @method PromiseInterface listMetricDescriptorsAsync(ListMetricDescriptorsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listMonitoredResourceDescriptorsAsync(ListMonitoredResourceDescriptorsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTimeSeriesAsync(ListTimeSeriesRequest $request, array $optionalArgs = []) */ -final class MetricServiceClient extends MetricServiceBaseClient +final class MetricServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see MetricServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.monitoring.v3.MetricService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'monitoring.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read', + 'https://www.googleapis.com/auth/monitoring.write', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/metric_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/metric_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/metric_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/metric_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a folder + * resource. + * + * @param string $folder + * + * @return string The formatted folder resource. + */ + public static function folderName(string $folder): string + { + return self::getPathTemplate('folder')->render([ + 'folder' => $folder, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_metric_descriptor resource. + * + * @param string $folder + * @param string $metricDescriptor + * + * @return string The formatted folder_metric_descriptor resource. + */ + public static function folderMetricDescriptorName(string $folder, string $metricDescriptor): string + { + return self::getPathTemplate('folderMetricDescriptor')->render([ + 'folder' => $folder, + 'metric_descriptor' => $metricDescriptor, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_monitored_resource_descriptor resource. + * + * @param string $folder + * @param string $monitoredResourceDescriptor + * + * @return string The formatted folder_monitored_resource_descriptor resource. + */ + public static function folderMonitoredResourceDescriptorName(string $folder, string $monitoredResourceDescriptor): string + { + return self::getPathTemplate('folderMonitoredResourceDescriptor')->render([ + 'folder' => $folder, + 'monitored_resource_descriptor' => $monitoredResourceDescriptor, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * metric_descriptor resource. + * + * @param string $project + * @param string $metricDescriptor + * + * @return string The formatted metric_descriptor resource. + */ + public static function metricDescriptorName(string $project, string $metricDescriptor): string + { + return self::getPathTemplate('metricDescriptor')->render([ + 'project' => $project, + 'metric_descriptor' => $metricDescriptor, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * monitored_resource_descriptor resource. + * + * @param string $project + * @param string $monitoredResourceDescriptor + * + * @return string The formatted monitored_resource_descriptor resource. + */ + public static function monitoredResourceDescriptorName(string $project, string $monitoredResourceDescriptor): string + { + return self::getPathTemplate('monitoredResourceDescriptor')->render([ + 'project' => $project, + 'monitored_resource_descriptor' => $monitoredResourceDescriptor, + ]); + } + + /** + * 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(string $organization): string + { + return self::getPathTemplate('organization')->render([ + 'organization' => $organization, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_metric_descriptor resource. + * + * @param string $organization + * @param string $metricDescriptor + * + * @return string The formatted organization_metric_descriptor resource. + */ + public static function organizationMetricDescriptorName(string $organization, string $metricDescriptor): string + { + return self::getPathTemplate('organizationMetricDescriptor')->render([ + 'organization' => $organization, + 'metric_descriptor' => $metricDescriptor, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_monitored_resource_descriptor resource. + * + * @param string $organization + * @param string $monitoredResourceDescriptor + * + * @return string The formatted organization_monitored_resource_descriptor resource. + */ + public static function organizationMonitoredResourceDescriptorName(string $organization, string $monitoredResourceDescriptor): string + { + return self::getPathTemplate('organizationMonitoredResourceDescriptor')->render([ + 'organization' => $organization, + 'monitored_resource_descriptor' => $monitoredResourceDescriptor, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_metric_descriptor resource. + * + * @param string $project + * @param string $metricDescriptor + * + * @return string The formatted project_metric_descriptor resource. + */ + public static function projectMetricDescriptorName(string $project, string $metricDescriptor): string + { + return self::getPathTemplate('projectMetricDescriptor')->render([ + 'project' => $project, + 'metric_descriptor' => $metricDescriptor, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_monitored_resource_descriptor resource. + * + * @param string $project + * @param string $monitoredResourceDescriptor + * + * @return string The formatted project_monitored_resource_descriptor resource. + */ + public static function projectMonitoredResourceDescriptorName(string $project, string $monitoredResourceDescriptor): string + { + return self::getPathTemplate('projectMonitoredResourceDescriptor')->render([ + 'project' => $project, + 'monitored_resource_descriptor' => $monitoredResourceDescriptor, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a workspace + * resource. + * + * @param string $project + * + * @return string The formatted workspace resource. + */ + public static function workspaceName(string $project): string + { + return self::getPathTemplate('workspace')->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 + * - folder: folders/{folder} + * - folderMetricDescriptor: folders/{folder}/metricDescriptors/{metric_descriptor=**} + * - folderMonitoredResourceDescriptor: folders/{folder}/monitoredResourceDescriptors/{monitored_resource_descriptor} + * - metricDescriptor: projects/{project}/metricDescriptors/{metric_descriptor=**} + * - monitoredResourceDescriptor: projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor} + * - organization: organizations/{organization} + * - organizationMetricDescriptor: organizations/{organization}/metricDescriptors/{metric_descriptor=**} + * - organizationMonitoredResourceDescriptor: organizations/{organization}/monitoredResourceDescriptors/{monitored_resource_descriptor} + * - project: projects/{project} + * - projectMetricDescriptor: projects/{project}/metricDescriptors/{metric_descriptor=**} + * - projectMonitoredResourceDescriptor: projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor} + * - workspace: 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. + */ + public static function parseName(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'monitoring.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new metric descriptor. + * The creation is executed asynchronously and callers may check the returned + * operation to track its progress. + * User-created metric descriptors define + * [custom metrics](https://cloud.google.com/monitoring/custom-metrics). + * + * The async variant is {@see MetricServiceClient::createMetricDescriptorAsync()} . + * + * @param CreateMetricDescriptorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MetricDescriptor + * + * @throws ApiException Thrown if the API call fails. + */ + public function createMetricDescriptor(CreateMetricDescriptorRequest $request, array $callOptions = []): MetricDescriptor + { + return $this->startApiCall('CreateMetricDescriptor', $request, $callOptions)->wait(); + } + + /** + * Creates or adds data to one or more service time series. A service time + * series is a time series for a metric from a Google Cloud service. The + * response is empty if all time series in the request were written. If any + * time series could not be written, a corresponding failure message is + * included in the error response. This endpoint rejects writes to + * user-defined metrics. + * This method is only for use by Google Cloud services. Use + * [projects.timeSeries.create][google.monitoring.v3.MetricService.CreateTimeSeries] + * instead. + * + * The async variant is {@see MetricServiceClient::createServiceTimeSeriesAsync()} + * . + * + * @param CreateTimeSeriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function createServiceTimeSeries(CreateTimeSeriesRequest $request, array $callOptions = []): void + { + $this->startApiCall('CreateServiceTimeSeries', $request, $callOptions)->wait(); + } + + /** + * Creates or adds data to one or more time series. + * The response is empty if all time series in the request were written. + * If any time series could not be written, a corresponding failure message is + * included in the error response. + * + * The async variant is {@see MetricServiceClient::createTimeSeriesAsync()} . + * + * @param CreateTimeSeriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTimeSeries(CreateTimeSeriesRequest $request, array $callOptions = []): void + { + $this->startApiCall('CreateTimeSeries', $request, $callOptions)->wait(); + } + + /** + * Deletes a metric descriptor. Only user-created + * [custom metrics](https://cloud.google.com/monitoring/custom-metrics) can be + * deleted. + * + * The async variant is {@see MetricServiceClient::deleteMetricDescriptorAsync()} . + * + * @param DeleteMetricDescriptorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteMetricDescriptor(DeleteMetricDescriptorRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteMetricDescriptor', $request, $callOptions)->wait(); + } + + /** + * Gets a single metric descriptor. This method does not require a Workspace. + * + * The async variant is {@see MetricServiceClient::getMetricDescriptorAsync()} . + * + * @param GetMetricDescriptorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MetricDescriptor + * + * @throws ApiException Thrown if the API call fails. + */ + public function getMetricDescriptor(GetMetricDescriptorRequest $request, array $callOptions = []): MetricDescriptor + { + return $this->startApiCall('GetMetricDescriptor', $request, $callOptions)->wait(); + } + + /** + * Gets a single monitored resource descriptor. This method does not require a Workspace. + * + * The async variant is + * {@see MetricServiceClient::getMonitoredResourceDescriptorAsync()} . + * + * @param GetMonitoredResourceDescriptorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MonitoredResourceDescriptor + * + * @throws ApiException Thrown if the API call fails. + */ + public function getMonitoredResourceDescriptor(GetMonitoredResourceDescriptorRequest $request, array $callOptions = []): MonitoredResourceDescriptor + { + return $this->startApiCall('GetMonitoredResourceDescriptor', $request, $callOptions)->wait(); + } + + /** + * Lists metric descriptors that match a filter. This method does not require a Workspace. + * + * The async variant is {@see MetricServiceClient::listMetricDescriptorsAsync()} . + * + * @param ListMetricDescriptorsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listMetricDescriptors(ListMetricDescriptorsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListMetricDescriptors', $request, $callOptions); + } + + /** + * Lists monitored resource descriptors that match a filter. This method does not require a Workspace. + * + * The async variant is + * {@see MetricServiceClient::listMonitoredResourceDescriptorsAsync()} . + * + * @param ListMonitoredResourceDescriptorsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listMonitoredResourceDescriptors(ListMonitoredResourceDescriptorsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListMonitoredResourceDescriptors', $request, $callOptions); + } + + /** + * Lists time series that match a filter. This method does not require a Workspace. + * + * The async variant is {@see MetricServiceClient::listTimeSeriesAsync()} . + * + * @param ListTimeSeriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTimeSeries(ListTimeSeriesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTimeSeries', $request, $callOptions); + } } diff --git a/Monitoring/src/V3/Client/NotificationChannelServiceClient.php b/Monitoring/src/V3/Client/NotificationChannelServiceClient.php index 5b753b97b9c4..e784edbcfa1d 100644 --- a/Monitoring/src/V3/Client/NotificationChannelServiceClient.php +++ b/Monitoring/src/V3/Client/NotificationChannelServiceClient.php @@ -24,15 +24,633 @@ namespace Google\Cloud\Monitoring\V3\Client; -use Google\Cloud\Monitoring\V3\Client\BaseClient\NotificationChannelServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Monitoring\V3\CreateNotificationChannelRequest; +use Google\Cloud\Monitoring\V3\DeleteNotificationChannelRequest; +use Google\Cloud\Monitoring\V3\GetNotificationChannelDescriptorRequest; +use Google\Cloud\Monitoring\V3\GetNotificationChannelRequest; +use Google\Cloud\Monitoring\V3\GetNotificationChannelVerificationCodeRequest; +use Google\Cloud\Monitoring\V3\GetNotificationChannelVerificationCodeResponse; +use Google\Cloud\Monitoring\V3\ListNotificationChannelDescriptorsRequest; +use Google\Cloud\Monitoring\V3\ListNotificationChannelsRequest; +use Google\Cloud\Monitoring\V3\NotificationChannel; +use Google\Cloud\Monitoring\V3\NotificationChannelDescriptor; +use Google\Cloud\Monitoring\V3\SendNotificationChannelVerificationCodeRequest; +use Google\Cloud\Monitoring\V3\UpdateNotificationChannelRequest; +use Google\Cloud\Monitoring\V3\VerifyNotificationChannelRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Notification Channel API provides access to configuration that + * controls how messages related to incidents are sent. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Monitoring\V3\NotificationChannelServiceClient} for the stable + * implementation + * + * @method PromiseInterface createNotificationChannelAsync(CreateNotificationChannelRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteNotificationChannelAsync(DeleteNotificationChannelRequest $request, array $optionalArgs = []) + * @method PromiseInterface getNotificationChannelAsync(GetNotificationChannelRequest $request, array $optionalArgs = []) + * @method PromiseInterface getNotificationChannelDescriptorAsync(GetNotificationChannelDescriptorRequest $request, array $optionalArgs = []) + * @method PromiseInterface getNotificationChannelVerificationCodeAsync(GetNotificationChannelVerificationCodeRequest $request, array $optionalArgs = []) + * @method PromiseInterface listNotificationChannelDescriptorsAsync(ListNotificationChannelDescriptorsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listNotificationChannelsAsync(ListNotificationChannelsRequest $request, array $optionalArgs = []) + * @method PromiseInterface sendNotificationChannelVerificationCodeAsync(SendNotificationChannelVerificationCodeRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateNotificationChannelAsync(UpdateNotificationChannelRequest $request, array $optionalArgs = []) + * @method PromiseInterface verifyNotificationChannelAsync(VerifyNotificationChannelRequest $request, array $optionalArgs = []) */ -final class NotificationChannelServiceClient extends NotificationChannelServiceBaseClient +final class NotificationChannelServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see NotificationChannelServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.monitoring.v3.NotificationChannelService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'monitoring.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/notification_channel_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/notification_channel_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/notification_channel_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/notification_channel_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_channel_descriptor resource. + * + * @param string $folder + * @param string $channelDescriptor + * + * @return string The formatted folder_channel_descriptor resource. + */ + public static function folderChannelDescriptorName(string $folder, string $channelDescriptor): string + { + return self::getPathTemplate('folderChannelDescriptor')->render([ + 'folder' => $folder, + 'channel_descriptor' => $channelDescriptor, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_notification_channel resource. + * + * @param string $folder + * @param string $notificationChannel + * + * @return string The formatted folder_notification_channel resource. + */ + public static function folderNotificationChannelName(string $folder, string $notificationChannel): string + { + return self::getPathTemplate('folderNotificationChannel')->render([ + 'folder' => $folder, + 'notification_channel' => $notificationChannel, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * notification_channel resource. + * + * @param string $project + * @param string $notificationChannel + * + * @return string The formatted notification_channel resource. + */ + public static function notificationChannelName(string $project, string $notificationChannel): string + { + return self::getPathTemplate('notificationChannel')->render([ + 'project' => $project, + 'notification_channel' => $notificationChannel, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * notification_channel_descriptor resource. + * + * @param string $project + * @param string $channelDescriptor + * + * @return string The formatted notification_channel_descriptor resource. + */ + public static function notificationChannelDescriptorName(string $project, string $channelDescriptor): string + { + return self::getPathTemplate('notificationChannelDescriptor')->render([ + 'project' => $project, + 'channel_descriptor' => $channelDescriptor, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_channel_descriptor resource. + * + * @param string $organization + * @param string $channelDescriptor + * + * @return string The formatted organization_channel_descriptor resource. + */ + public static function organizationChannelDescriptorName(string $organization, string $channelDescriptor): string + { + return self::getPathTemplate('organizationChannelDescriptor')->render([ + 'organization' => $organization, + 'channel_descriptor' => $channelDescriptor, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_notification_channel resource. + * + * @param string $organization + * @param string $notificationChannel + * + * @return string The formatted organization_notification_channel resource. + */ + public static function organizationNotificationChannelName(string $organization, string $notificationChannel): string + { + return self::getPathTemplate('organizationNotificationChannel')->render([ + 'organization' => $organization, + 'notification_channel' => $notificationChannel, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_channel_descriptor resource. + * + * @param string $project + * @param string $channelDescriptor + * + * @return string The formatted project_channel_descriptor resource. + */ + public static function projectChannelDescriptorName(string $project, string $channelDescriptor): string + { + return self::getPathTemplate('projectChannelDescriptor')->render([ + 'project' => $project, + 'channel_descriptor' => $channelDescriptor, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_notification_channel resource. + * + * @param string $project + * @param string $notificationChannel + * + * @return string The formatted project_notification_channel resource. + */ + public static function projectNotificationChannelName(string $project, string $notificationChannel): string + { + return self::getPathTemplate('projectNotificationChannel')->render([ + 'project' => $project, + 'notification_channel' => $notificationChannel, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - folderChannelDescriptor: folders/{folder}/notificationChannelDescriptors/{channel_descriptor} + * - folderNotificationChannel: folders/{folder}/notificationChannels/{notification_channel} + * - notificationChannel: projects/{project}/notificationChannels/{notification_channel} + * - notificationChannelDescriptor: projects/{project}/notificationChannelDescriptors/{channel_descriptor} + * - organizationChannelDescriptor: organizations/{organization}/notificationChannelDescriptors/{channel_descriptor} + * - organizationNotificationChannel: organizations/{organization}/notificationChannels/{notification_channel} + * - projectChannelDescriptor: projects/{project}/notificationChannelDescriptors/{channel_descriptor} + * - projectNotificationChannel: projects/{project}/notificationChannels/{notification_channel} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'monitoring.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new notification channel, representing a single notification + * endpoint such as an email address, SMS number, or PagerDuty service. + * + * Design your application to single-thread API calls that modify the state of + * notification channels in a single project. This includes calls to + * CreateNotificationChannel, DeleteNotificationChannel and + * UpdateNotificationChannel. + * + * The async variant is + * {@see NotificationChannelServiceClient::createNotificationChannelAsync()} . + * + * @param CreateNotificationChannelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NotificationChannel + * + * @throws ApiException Thrown if the API call fails. + */ + public function createNotificationChannel(CreateNotificationChannelRequest $request, array $callOptions = []): NotificationChannel + { + return $this->startApiCall('CreateNotificationChannel', $request, $callOptions)->wait(); + } + + /** + * Deletes a notification channel. + * + * Design your application to single-thread API calls that modify the state of + * notification channels in a single project. This includes calls to + * CreateNotificationChannel, DeleteNotificationChannel and + * UpdateNotificationChannel. + * + * The async variant is + * {@see NotificationChannelServiceClient::deleteNotificationChannelAsync()} . + * + * @param DeleteNotificationChannelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteNotificationChannel(DeleteNotificationChannelRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteNotificationChannel', $request, $callOptions)->wait(); + } + + /** + * Gets a single notification channel. The channel includes the relevant + * configuration details with which the channel was created. However, the + * response may truncate or omit passwords, API keys, or other private key + * matter and thus the response may not be 100% identical to the information + * that was supplied in the call to the create method. + * + * The async variant is + * {@see NotificationChannelServiceClient::getNotificationChannelAsync()} . + * + * @param GetNotificationChannelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NotificationChannel + * + * @throws ApiException Thrown if the API call fails. + */ + public function getNotificationChannel(GetNotificationChannelRequest $request, array $callOptions = []): NotificationChannel + { + return $this->startApiCall('GetNotificationChannel', $request, $callOptions)->wait(); + } + + /** + * Gets a single channel descriptor. The descriptor indicates which fields + * are expected / permitted for a notification channel of the given type. + * + * The async variant is + * {@see NotificationChannelServiceClient::getNotificationChannelDescriptorAsync()} + * . + * + * @param GetNotificationChannelDescriptorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NotificationChannelDescriptor + * + * @throws ApiException Thrown if the API call fails. + */ + public function getNotificationChannelDescriptor(GetNotificationChannelDescriptorRequest $request, array $callOptions = []): NotificationChannelDescriptor + { + return $this->startApiCall('GetNotificationChannelDescriptor', $request, $callOptions)->wait(); + } + + /** + * Requests a verification code for an already verified channel that can then + * be used in a call to VerifyNotificationChannel() on a different channel + * with an equivalent identity in the same or in a different project. This + * makes it possible to copy a channel between projects without requiring + * manual reverification of the channel. If the channel is not in the + * verified state, this method will fail (in other words, this may only be + * used if the SendNotificationChannelVerificationCode and + * VerifyNotificationChannel paths have already been used to put the given + * channel into the verified state). + * + * There is no guarantee that the verification codes returned by this method + * will be of a similar structure or form as the ones that are delivered + * to the channel via SendNotificationChannelVerificationCode; while + * VerifyNotificationChannel() will recognize both the codes delivered via + * SendNotificationChannelVerificationCode() and returned from + * GetNotificationChannelVerificationCode(), it is typically the case that + * the verification codes delivered via + * SendNotificationChannelVerificationCode() will be shorter and also + * have a shorter expiration (e.g. codes such as "G-123456") whereas + * GetVerificationCode() will typically return a much longer, websafe base + * 64 encoded string that has a longer expiration time. + * + * The async variant is + * {@see NotificationChannelServiceClient::getNotificationChannelVerificationCodeAsync()} + * . + * + * @param GetNotificationChannelVerificationCodeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GetNotificationChannelVerificationCodeResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function getNotificationChannelVerificationCode(GetNotificationChannelVerificationCodeRequest $request, array $callOptions = []): GetNotificationChannelVerificationCodeResponse + { + return $this->startApiCall('GetNotificationChannelVerificationCode', $request, $callOptions)->wait(); + } + + /** + * Lists the descriptors for supported channel types. The use of descriptors + * makes it possible for new channel types to be dynamically added. + * + * The async variant is + * {@see NotificationChannelServiceClient::listNotificationChannelDescriptorsAsync()} + * . + * + * @param ListNotificationChannelDescriptorsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listNotificationChannelDescriptors(ListNotificationChannelDescriptorsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListNotificationChannelDescriptors', $request, $callOptions); + } + + /** + * Lists the notification channels that have been created for the project. + * To list the types of notification channels that are supported, use + * the `ListNotificationChannelDescriptors` method. + * + * The async variant is + * {@see NotificationChannelServiceClient::listNotificationChannelsAsync()} . + * + * @param ListNotificationChannelsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listNotificationChannels(ListNotificationChannelsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListNotificationChannels', $request, $callOptions); + } + + /** + * Causes a verification code to be delivered to the channel. The code + * can then be supplied in `VerifyNotificationChannel` to verify the channel. + * + * The async variant is + * {@see NotificationChannelServiceClient::sendNotificationChannelVerificationCodeAsync()} + * . + * + * @param SendNotificationChannelVerificationCodeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function sendNotificationChannelVerificationCode(SendNotificationChannelVerificationCodeRequest $request, array $callOptions = []): void + { + $this->startApiCall('SendNotificationChannelVerificationCode', $request, $callOptions)->wait(); + } + + /** + * Updates a notification channel. Fields not specified in the field mask + * remain unchanged. + * + * Design your application to single-thread API calls that modify the state of + * notification channels in a single project. This includes calls to + * CreateNotificationChannel, DeleteNotificationChannel and + * UpdateNotificationChannel. + * + * The async variant is + * {@see NotificationChannelServiceClient::updateNotificationChannelAsync()} . + * + * @param UpdateNotificationChannelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NotificationChannel + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateNotificationChannel(UpdateNotificationChannelRequest $request, array $callOptions = []): NotificationChannel + { + return $this->startApiCall('UpdateNotificationChannel', $request, $callOptions)->wait(); + } + + /** + * Verifies a `NotificationChannel` by proving receipt of the code + * delivered to the channel as a result of calling + * `SendNotificationChannelVerificationCode`. + * + * The async variant is + * {@see NotificationChannelServiceClient::verifyNotificationChannelAsync()} . + * + * @param VerifyNotificationChannelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NotificationChannel + * + * @throws ApiException Thrown if the API call fails. + */ + public function verifyNotificationChannel(VerifyNotificationChannelRequest $request, array $callOptions = []): NotificationChannel + { + return $this->startApiCall('VerifyNotificationChannel', $request, $callOptions)->wait(); + } } diff --git a/Monitoring/src/V3/Client/QueryServiceClient.php b/Monitoring/src/V3/Client/QueryServiceClient.php index c896c6aa34c1..127f41f7bff8 100644 --- a/Monitoring/src/V3/Client/QueryServiceClient.php +++ b/Monitoring/src/V3/Client/QueryServiceClient.php @@ -24,15 +24,164 @@ namespace Google\Cloud\Monitoring\V3\Client; -use Google\Cloud\Monitoring\V3\Client\BaseClient\QueryServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Monitoring\V3\QueryTimeSeriesRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The QueryService API is used to manage time series data in Stackdriver + * Monitoring. Time series data is a collection of data points that describes + * the time-varying values of a metric. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Monitoring\V3\QueryServiceClient} for the stable implementation + * + * @method PromiseInterface queryTimeSeriesAsync(QueryTimeSeriesRequest $request, array $optionalArgs = []) */ -final class QueryServiceClient extends QueryServiceBaseClient +final class QueryServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see QueryServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.monitoring.v3.QueryService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'monitoring.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/query_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/query_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/query_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/query_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'monitoring.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Queries time series using Monitoring Query Language. This method does not require a Workspace. + * + * The async variant is {@see QueryServiceClient::queryTimeSeriesAsync()} . + * + * @param QueryTimeSeriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function queryTimeSeries(QueryTimeSeriesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('QueryTimeSeries', $request, $callOptions); + } } diff --git a/Monitoring/src/V3/Client/ServiceMonitoringServiceClient.php b/Monitoring/src/V3/Client/ServiceMonitoringServiceClient.php index 67ad2478d33b..16931c89125e 100644 --- a/Monitoring/src/V3/Client/ServiceMonitoringServiceClient.php +++ b/Monitoring/src/V3/Client/ServiceMonitoringServiceClient.php @@ -24,15 +24,589 @@ namespace Google\Cloud\Monitoring\V3\Client; -use Google\Cloud\Monitoring\V3\Client\BaseClient\ServiceMonitoringServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Monitoring\V3\CreateServiceLevelObjectiveRequest; +use Google\Cloud\Monitoring\V3\CreateServiceRequest; +use Google\Cloud\Monitoring\V3\DeleteServiceLevelObjectiveRequest; +use Google\Cloud\Monitoring\V3\DeleteServiceRequest; +use Google\Cloud\Monitoring\V3\GetServiceLevelObjectiveRequest; +use Google\Cloud\Monitoring\V3\GetServiceRequest; +use Google\Cloud\Monitoring\V3\ListServiceLevelObjectivesRequest; +use Google\Cloud\Monitoring\V3\ListServicesRequest; +use Google\Cloud\Monitoring\V3\Service; +use Google\Cloud\Monitoring\V3\ServiceLevelObjective; +use Google\Cloud\Monitoring\V3\UpdateServiceLevelObjectiveRequest; +use Google\Cloud\Monitoring\V3\UpdateServiceRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Cloud Monitoring Service-Oriented Monitoring API has endpoints for + * managing and querying aspects of a workspace's services. These include the + * `Service`'s monitored resources, its Service-Level Objectives, and a taxonomy + * of categorized Health Metrics. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Monitoring\V3\ServiceMonitoringServiceClient} for the stable + * implementation + * + * @method PromiseInterface createServiceAsync(CreateServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface createServiceLevelObjectiveAsync(CreateServiceLevelObjectiveRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteServiceAsync(DeleteServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteServiceLevelObjectiveAsync(DeleteServiceLevelObjectiveRequest $request, array $optionalArgs = []) + * @method PromiseInterface getServiceAsync(GetServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getServiceLevelObjectiveAsync(GetServiceLevelObjectiveRequest $request, array $optionalArgs = []) + * @method PromiseInterface listServiceLevelObjectivesAsync(ListServiceLevelObjectivesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listServicesAsync(ListServicesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateServiceAsync(UpdateServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateServiceLevelObjectiveAsync(UpdateServiceLevelObjectiveRequest $request, array $optionalArgs = []) */ -final class ServiceMonitoringServiceClient extends ServiceMonitoringServiceBaseClient +final class ServiceMonitoringServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ServiceMonitoringServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.monitoring.v3.ServiceMonitoringService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'monitoring.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/service_monitoring_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/service_monitoring_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/service_monitoring_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/service_monitoring_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_service resource. + * + * @param string $folder + * @param string $service + * + * @return string The formatted folder_service resource. + */ + public static function folderServiceName(string $folder, string $service): string + { + return self::getPathTemplate('folderService')->render([ + 'folder' => $folder, + 'service' => $service, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_service_service_level_objective resource. + * + * @param string $folder + * @param string $service + * @param string $serviceLevelObjective + * + * @return string The formatted folder_service_service_level_objective resource. + */ + public static function folderServiceServiceLevelObjectiveName(string $folder, string $service, string $serviceLevelObjective): string + { + return self::getPathTemplate('folderServiceServiceLevelObjective')->render([ + 'folder' => $folder, + 'service' => $service, + 'service_level_objective' => $serviceLevelObjective, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_service resource. + * + * @param string $organization + * @param string $service + * + * @return string The formatted organization_service resource. + */ + public static function organizationServiceName(string $organization, string $service): string + { + return self::getPathTemplate('organizationService')->render([ + 'organization' => $organization, + 'service' => $service, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_service_service_level_objective resource. + * + * @param string $organization + * @param string $service + * @param string $serviceLevelObjective + * + * @return string The formatted organization_service_service_level_objective resource. + */ + public static function organizationServiceServiceLevelObjectiveName(string $organization, string $service, string $serviceLevelObjective): string + { + return self::getPathTemplate('organizationServiceServiceLevelObjective')->render([ + 'organization' => $organization, + 'service' => $service, + 'service_level_objective' => $serviceLevelObjective, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_service resource. + * + * @param string $project + * @param string $service + * + * @return string The formatted project_service resource. + */ + public static function projectServiceName(string $project, string $service): string + { + return self::getPathTemplate('projectService')->render([ + 'project' => $project, + 'service' => $service, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_service_service_level_objective resource. + * + * @param string $project + * @param string $service + * @param string $serviceLevelObjective + * + * @return string The formatted project_service_service_level_objective resource. + */ + public static function projectServiceServiceLevelObjectiveName(string $project, string $service, string $serviceLevelObjective): string + { + return self::getPathTemplate('projectServiceServiceLevelObjective')->render([ + 'project' => $project, + 'service' => $service, + 'service_level_objective' => $serviceLevelObjective, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a service + * resource. + * + * @param string $project + * @param string $service + * + * @return string The formatted service resource. + */ + public static function serviceName(string $project, string $service): string + { + return self::getPathTemplate('service')->render([ + 'project' => $project, + 'service' => $service, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * service_level_objective resource. + * + * @param string $project + * @param string $service + * @param string $serviceLevelObjective + * + * @return string The formatted service_level_objective resource. + */ + public static function serviceLevelObjectiveName(string $project, string $service, string $serviceLevelObjective): string + { + return self::getPathTemplate('serviceLevelObjective')->render([ + 'project' => $project, + 'service' => $service, + 'service_level_objective' => $serviceLevelObjective, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - folderService: folders/{folder}/services/{service} + * - folderServiceServiceLevelObjective: folders/{folder}/services/{service}/serviceLevelObjectives/{service_level_objective} + * - organizationService: organizations/{organization}/services/{service} + * - organizationServiceServiceLevelObjective: organizations/{organization}/services/{service}/serviceLevelObjectives/{service_level_objective} + * - projectService: projects/{project}/services/{service} + * - projectServiceServiceLevelObjective: projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective} + * - service: projects/{project}/services/{service} + * - serviceLevelObjective: projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'monitoring.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Create a `Service`. + * + * The async variant is {@see ServiceMonitoringServiceClient::createServiceAsync()} + * . + * + * @param CreateServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Service + * + * @throws ApiException Thrown if the API call fails. + */ + public function createService(CreateServiceRequest $request, array $callOptions = []): Service + { + return $this->startApiCall('CreateService', $request, $callOptions)->wait(); + } + + /** + * Create a `ServiceLevelObjective` for the given `Service`. + * + * The async variant is + * {@see ServiceMonitoringServiceClient::createServiceLevelObjectiveAsync()} . + * + * @param CreateServiceLevelObjectiveRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ServiceLevelObjective + * + * @throws ApiException Thrown if the API call fails. + */ + public function createServiceLevelObjective(CreateServiceLevelObjectiveRequest $request, array $callOptions = []): ServiceLevelObjective + { + return $this->startApiCall('CreateServiceLevelObjective', $request, $callOptions)->wait(); + } + + /** + * Soft delete this `Service`. + * + * The async variant is {@see ServiceMonitoringServiceClient::deleteServiceAsync()} + * . + * + * @param DeleteServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteService(DeleteServiceRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteService', $request, $callOptions)->wait(); + } + + /** + * Delete the given `ServiceLevelObjective`. + * + * The async variant is + * {@see ServiceMonitoringServiceClient::deleteServiceLevelObjectiveAsync()} . + * + * @param DeleteServiceLevelObjectiveRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteServiceLevelObjective(DeleteServiceLevelObjectiveRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteServiceLevelObjective', $request, $callOptions)->wait(); + } + + /** + * Get the named `Service`. + * + * The async variant is {@see ServiceMonitoringServiceClient::getServiceAsync()} . + * + * @param GetServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Service + * + * @throws ApiException Thrown if the API call fails. + */ + public function getService(GetServiceRequest $request, array $callOptions = []): Service + { + return $this->startApiCall('GetService', $request, $callOptions)->wait(); + } + + /** + * Get a `ServiceLevelObjective` by name. + * + * The async variant is + * {@see ServiceMonitoringServiceClient::getServiceLevelObjectiveAsync()} . + * + * @param GetServiceLevelObjectiveRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ServiceLevelObjective + * + * @throws ApiException Thrown if the API call fails. + */ + public function getServiceLevelObjective(GetServiceLevelObjectiveRequest $request, array $callOptions = []): ServiceLevelObjective + { + return $this->startApiCall('GetServiceLevelObjective', $request, $callOptions)->wait(); + } + + /** + * List the `ServiceLevelObjective`s for the given `Service`. + * + * The async variant is + * {@see ServiceMonitoringServiceClient::listServiceLevelObjectivesAsync()} . + * + * @param ListServiceLevelObjectivesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listServiceLevelObjectives(ListServiceLevelObjectivesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListServiceLevelObjectives', $request, $callOptions); + } + + /** + * List `Service`s for this workspace. + * + * The async variant is {@see ServiceMonitoringServiceClient::listServicesAsync()} + * . + * + * @param ListServicesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listServices(ListServicesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListServices', $request, $callOptions); + } + + /** + * Update this `Service`. + * + * The async variant is {@see ServiceMonitoringServiceClient::updateServiceAsync()} + * . + * + * @param UpdateServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Service + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateService(UpdateServiceRequest $request, array $callOptions = []): Service + { + return $this->startApiCall('UpdateService', $request, $callOptions)->wait(); + } + + /** + * Update the given `ServiceLevelObjective`. + * + * The async variant is + * {@see ServiceMonitoringServiceClient::updateServiceLevelObjectiveAsync()} . + * + * @param UpdateServiceLevelObjectiveRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ServiceLevelObjective + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateServiceLevelObjective(UpdateServiceLevelObjectiveRequest $request, array $callOptions = []): ServiceLevelObjective + { + return $this->startApiCall('UpdateServiceLevelObjective', $request, $callOptions)->wait(); + } } diff --git a/Monitoring/src/V3/Client/SnoozeServiceClient.php b/Monitoring/src/V3/Client/SnoozeServiceClient.php index e8c461282c61..2dc5a3c24a2e 100644 --- a/Monitoring/src/V3/Client/SnoozeServiceClient.php +++ b/Monitoring/src/V3/Client/SnoozeServiceClient.php @@ -24,15 +24,399 @@ namespace Google\Cloud\Monitoring\V3\Client; -use Google\Cloud\Monitoring\V3\Client\BaseClient\SnoozeServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Monitoring\V3\CreateSnoozeRequest; +use Google\Cloud\Monitoring\V3\GetSnoozeRequest; +use Google\Cloud\Monitoring\V3\ListSnoozesRequest; +use Google\Cloud\Monitoring\V3\Snooze; +use Google\Cloud\Monitoring\V3\UpdateSnoozeRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The SnoozeService API is used to temporarily prevent an alert policy from + * generating alerts. A Snooze is a description of the criteria under which one + * or more alert policies should not fire alerts for the specified duration. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Monitoring\V3\SnoozeServiceClient} for the stable implementation + * + * @method PromiseInterface createSnoozeAsync(CreateSnoozeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSnoozeAsync(GetSnoozeRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSnoozesAsync(ListSnoozesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSnoozeAsync(UpdateSnoozeRequest $request, array $optionalArgs = []) */ -final class SnoozeServiceClient extends SnoozeServiceBaseClient +final class SnoozeServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SnoozeServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.monitoring.v3.SnoozeService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'monitoring.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/snooze_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/snooze_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/snooze_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/snooze_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a alert_policy + * resource. + * + * @param string $project + * @param string $alertPolicy + * + * @return string The formatted alert_policy resource. + */ + public static function alertPolicyName(string $project, string $alertPolicy): string + { + return self::getPathTemplate('alertPolicy')->render([ + 'project' => $project, + 'alert_policy' => $alertPolicy, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_alert_policy resource. + * + * @param string $folder + * @param string $alertPolicy + * + * @return string The formatted folder_alert_policy resource. + */ + public static function folderAlertPolicyName(string $folder, string $alertPolicy): string + { + return self::getPathTemplate('folderAlertPolicy')->render([ + 'folder' => $folder, + 'alert_policy' => $alertPolicy, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_alert_policy resource. + * + * @param string $organization + * @param string $alertPolicy + * + * @return string The formatted organization_alert_policy resource. + */ + public static function organizationAlertPolicyName(string $organization, string $alertPolicy): string + { + return self::getPathTemplate('organizationAlertPolicy')->render([ + 'organization' => $organization, + 'alert_policy' => $alertPolicy, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_alert_policy resource. + * + * @param string $project + * @param string $alertPolicy + * + * @return string The formatted project_alert_policy resource. + */ + public static function projectAlertPolicyName(string $project, string $alertPolicy): string + { + return self::getPathTemplate('projectAlertPolicy')->render([ + 'project' => $project, + 'alert_policy' => $alertPolicy, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a snooze + * resource. + * + * @param string $project + * @param string $snooze + * + * @return string The formatted snooze resource. + */ + public static function snoozeName(string $project, string $snooze): string + { + return self::getPathTemplate('snooze')->render([ + 'project' => $project, + 'snooze' => $snooze, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a workspace + * resource. + * + * @param string $project + * + * @return string The formatted workspace resource. + */ + public static function workspaceName(string $project): string + { + return self::getPathTemplate('workspace')->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 + * - alertPolicy: projects/{project}/alertPolicies/{alert_policy} + * - folderAlertPolicy: folders/{folder}/alertPolicies/{alert_policy} + * - organizationAlertPolicy: organizations/{organization}/alertPolicies/{alert_policy} + * - project: projects/{project} + * - projectAlertPolicy: projects/{project}/alertPolicies/{alert_policy} + * - snooze: projects/{project}/snoozes/{snooze} + * - workspace: 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. + */ + public static function parseName(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'monitoring.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a `Snooze` that will prevent alerts, which match the provided + * criteria, from being opened. The `Snooze` applies for a specific time + * interval. + * + * The async variant is {@see SnoozeServiceClient::createSnoozeAsync()} . + * + * @param CreateSnoozeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Snooze + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSnooze(CreateSnoozeRequest $request, array $callOptions = []): Snooze + { + return $this->startApiCall('CreateSnooze', $request, $callOptions)->wait(); + } + + /** + * Retrieves a `Snooze` by `name`. + * + * The async variant is {@see SnoozeServiceClient::getSnoozeAsync()} . + * + * @param GetSnoozeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Snooze + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSnooze(GetSnoozeRequest $request, array $callOptions = []): Snooze + { + return $this->startApiCall('GetSnooze', $request, $callOptions)->wait(); + } + + /** + * Lists the `Snooze`s associated with a project. Can optionally pass in + * `filter`, which specifies predicates to match `Snooze`s. + * + * The async variant is {@see SnoozeServiceClient::listSnoozesAsync()} . + * + * @param ListSnoozesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSnoozes(ListSnoozesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSnoozes', $request, $callOptions); + } + + /** + * Updates a `Snooze`, identified by its `name`, with the parameters in the + * given `Snooze` object. + * + * The async variant is {@see SnoozeServiceClient::updateSnoozeAsync()} . + * + * @param UpdateSnoozeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Snooze + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSnooze(UpdateSnoozeRequest $request, array $callOptions = []): Snooze + { + return $this->startApiCall('UpdateSnooze', $request, $callOptions)->wait(); + } } diff --git a/Monitoring/src/V3/Client/UptimeCheckServiceClient.php b/Monitoring/src/V3/Client/UptimeCheckServiceClient.php index 057bc9a357d9..2d1b6a01baad 100644 --- a/Monitoring/src/V3/Client/UptimeCheckServiceClient.php +++ b/Monitoring/src/V3/Client/UptimeCheckServiceClient.php @@ -24,15 +24,413 @@ namespace Google\Cloud\Monitoring\V3\Client; -use Google\Cloud\Monitoring\V3\Client\BaseClient\UptimeCheckServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Monitoring\V3\CreateUptimeCheckConfigRequest; +use Google\Cloud\Monitoring\V3\DeleteUptimeCheckConfigRequest; +use Google\Cloud\Monitoring\V3\GetUptimeCheckConfigRequest; +use Google\Cloud\Monitoring\V3\ListUptimeCheckConfigsRequest; +use Google\Cloud\Monitoring\V3\ListUptimeCheckIpsRequest; +use Google\Cloud\Monitoring\V3\UpdateUptimeCheckConfigRequest; +use Google\Cloud\Monitoring\V3\UptimeCheckConfig; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The UptimeCheckService API is used to manage (list, create, delete, edit) + * Uptime check configurations in the Cloud Monitoring product. An Uptime + * check is a piece of configuration that determines which resources and + * services to monitor for availability. These configurations can also be + * configured interactively by navigating to the [Cloud console] + * (https://console.cloud.google.com), selecting the appropriate project, + * clicking on "Monitoring" on the left-hand side to navigate to Cloud + * Monitoring, and then clicking on "Uptime". * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Monitoring\V3\UptimeCheckServiceClient} for the stable + * implementation + * + * @method PromiseInterface createUptimeCheckConfigAsync(CreateUptimeCheckConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteUptimeCheckConfigAsync(DeleteUptimeCheckConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getUptimeCheckConfigAsync(GetUptimeCheckConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface listUptimeCheckConfigsAsync(ListUptimeCheckConfigsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listUptimeCheckIpsAsync(ListUptimeCheckIpsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateUptimeCheckConfigAsync(UpdateUptimeCheckConfigRequest $request, array $optionalArgs = []) */ -final class UptimeCheckServiceClient extends UptimeCheckServiceBaseClient +final class UptimeCheckServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see UptimeCheckServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.monitoring.v3.UptimeCheckService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'monitoring.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.read', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/uptime_check_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/uptime_check_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/uptime_check_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/uptime_check_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_uptime_check_config resource. + * + * @param string $folder + * @param string $uptimeCheckConfig + * + * @return string The formatted folder_uptime_check_config resource. + */ + public static function folderUptimeCheckConfigName(string $folder, string $uptimeCheckConfig): string + { + return self::getPathTemplate('folderUptimeCheckConfig')->render([ + 'folder' => $folder, + 'uptime_check_config' => $uptimeCheckConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_uptime_check_config resource. + * + * @param string $organization + * @param string $uptimeCheckConfig + * + * @return string The formatted organization_uptime_check_config resource. + */ + public static function organizationUptimeCheckConfigName(string $organization, string $uptimeCheckConfig): string + { + return self::getPathTemplate('organizationUptimeCheckConfig')->render([ + 'organization' => $organization, + 'uptime_check_config' => $uptimeCheckConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_uptime_check_config resource. + * + * @param string $project + * @param string $uptimeCheckConfig + * + * @return string The formatted project_uptime_check_config resource. + */ + public static function projectUptimeCheckConfigName(string $project, string $uptimeCheckConfig): string + { + return self::getPathTemplate('projectUptimeCheckConfig')->render([ + 'project' => $project, + 'uptime_check_config' => $uptimeCheckConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * uptime_check_config resource. + * + * @param string $project + * @param string $uptimeCheckConfig + * + * @return string The formatted uptime_check_config resource. + */ + public static function uptimeCheckConfigName(string $project, string $uptimeCheckConfig): string + { + return self::getPathTemplate('uptimeCheckConfig')->render([ + 'project' => $project, + 'uptime_check_config' => $uptimeCheckConfig, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - folderUptimeCheckConfig: folders/{folder}/uptimeCheckConfigs/{uptime_check_config} + * - organizationUptimeCheckConfig: organizations/{organization}/uptimeCheckConfigs/{uptime_check_config} + * - projectUptimeCheckConfig: projects/{project}/uptimeCheckConfigs/{uptime_check_config} + * - uptimeCheckConfig: projects/{project}/uptimeCheckConfigs/{uptime_check_config} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'monitoring.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new Uptime check configuration. + * + * The async variant is + * {@see UptimeCheckServiceClient::createUptimeCheckConfigAsync()} . + * + * @param CreateUptimeCheckConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 UptimeCheckConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function createUptimeCheckConfig(CreateUptimeCheckConfigRequest $request, array $callOptions = []): UptimeCheckConfig + { + return $this->startApiCall('CreateUptimeCheckConfig', $request, $callOptions)->wait(); + } + + /** + * Deletes an Uptime check configuration. Note that this method will fail + * if the Uptime check configuration is referenced by an alert policy or + * other dependent configs that would be rendered invalid by the deletion. + * + * The async variant is + * {@see UptimeCheckServiceClient::deleteUptimeCheckConfigAsync()} . + * + * @param DeleteUptimeCheckConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteUptimeCheckConfig(DeleteUptimeCheckConfigRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteUptimeCheckConfig', $request, $callOptions)->wait(); + } + + /** + * Gets a single Uptime check configuration. + * + * The async variant is + * {@see UptimeCheckServiceClient::getUptimeCheckConfigAsync()} . + * + * @param GetUptimeCheckConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 UptimeCheckConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getUptimeCheckConfig(GetUptimeCheckConfigRequest $request, array $callOptions = []): UptimeCheckConfig + { + return $this->startApiCall('GetUptimeCheckConfig', $request, $callOptions)->wait(); + } + + /** + * Lists the existing valid Uptime check configurations for the project + * (leaving out any invalid configurations). + * + * The async variant is + * {@see UptimeCheckServiceClient::listUptimeCheckConfigsAsync()} . + * + * @param ListUptimeCheckConfigsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listUptimeCheckConfigs(ListUptimeCheckConfigsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListUptimeCheckConfigs', $request, $callOptions); + } + + /** + * Returns the list of IP addresses that checkers run from + * + * The async variant is {@see UptimeCheckServiceClient::listUptimeCheckIpsAsync()} + * . + * + * @param ListUptimeCheckIpsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listUptimeCheckIps(ListUptimeCheckIpsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListUptimeCheckIps', $request, $callOptions); + } + + /** + * Updates an Uptime check configuration. You can either replace the entire + * configuration with a new one or replace only certain fields in the current + * configuration by specifying the fields to be updated via `updateMask`. + * Returns the updated configuration. + * + * The async variant is + * {@see UptimeCheckServiceClient::updateUptimeCheckConfigAsync()} . + * + * @param UpdateUptimeCheckConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 UptimeCheckConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateUptimeCheckConfig(UpdateUptimeCheckConfigRequest $request, array $callOptions = []): UptimeCheckConfig + { + return $this->startApiCall('UpdateUptimeCheckConfig', $request, $callOptions)->wait(); + } } diff --git a/NetApp/composer.json b/NetApp/composer.json index f1e9c29eb98a..833779c30731 100644 --- a/NetApp/composer.json +++ b/NetApp/composer.json @@ -18,7 +18,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.22.0" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/NetApp/src/V1/Client/BaseClient/NetAppBaseClient.php b/NetApp/src/V1/Client/BaseClient/NetAppBaseClient.php deleted file mode 100644 index fe11de852d04..000000000000 --- a/NetApp/src/V1/Client/BaseClient/NetAppBaseClient.php +++ /dev/null @@ -1,1701 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . '/../../resources/net_app_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . '/../../resources/net_app_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . '/../../resources/net_app_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../../resources/net_app_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; - $operation = new OperationResponse( - $operationName, - $this->getOperationsClient(), - $options - ); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * active_directory resource. - * - * @param string $project - * @param string $location - * @param string $activeDirectory - * - * @return string The formatted active_directory resource. - */ - public static function activeDirectoryName( - string $project, - string $location, - string $activeDirectory - ): string { - return self::getPathTemplate('activeDirectory')->render([ - 'project' => $project, - 'location' => $location, - 'active_directory' => $activeDirectory, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a kms_config - * resource. - * - * @param string $project - * @param string $location - * @param string $kmsConfig - * - * @return string The formatted kms_config resource. - */ - public static function kmsConfigName( - string $project, - string $location, - string $kmsConfig - ): string { - return self::getPathTemplate('kmsConfig')->render([ - 'project' => $project, - 'location' => $location, - 'kms_config' => $kmsConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName( - string $project, - string $location - ): string { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a network - * resource. - * - * @param string $project - * @param string $network - * - * @return string The formatted network resource. - */ - public static function networkName(string $project, string $network): string - { - return self::getPathTemplate('network')->render([ - 'project' => $project, - 'network' => $network, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a replication - * resource. - * - * @param string $project - * @param string $location - * @param string $volume - * @param string $replication - * - * @return string The formatted replication resource. - */ - public static function replicationName( - string $project, - string $location, - string $volume, - string $replication - ): string { - return self::getPathTemplate('replication')->render([ - 'project' => $project, - 'location' => $location, - 'volume' => $volume, - 'replication' => $replication, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a snapshot - * resource. - * - * @param string $project - * @param string $location - * @param string $volume - * @param string $snapshot - * - * @return string The formatted snapshot resource. - */ - public static function snapshotName( - string $project, - string $location, - string $volume, - string $snapshot - ): string { - return self::getPathTemplate('snapshot')->render([ - 'project' => $project, - 'location' => $location, - 'volume' => $volume, - 'snapshot' => $snapshot, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a storage_pool - * resource. - * - * @param string $project - * @param string $location - * @param string $storagePool - * - * @return string The formatted storage_pool resource. - */ - public static function storagePoolName( - string $project, - string $location, - string $storagePool - ): string { - return self::getPathTemplate('storagePool')->render([ - 'project' => $project, - 'location' => $location, - 'storage_pool' => $storagePool, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a volume - * resource. - * - * @param string $project - * @param string $location - * @param string $volume - * - * @return string The formatted volume resource. - */ - public static function volumeName( - string $project, - string $location, - string $volume - ): string { - return self::getPathTemplate('volume')->render([ - 'project' => $project, - 'location' => $location, - 'volume' => $volume, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - activeDirectory: projects/{project}/locations/{location}/activeDirectories/{active_directory} - * - kmsConfig: projects/{project}/locations/{location}/kmsConfigs/{kms_config} - * - location: projects/{project}/locations/{location} - * - network: projects/{project}/global/networks/{network} - * - replication: projects/{project}/locations/{location}/volumes/{volume}/replications/{replication} - * - snapshot: projects/{project}/locations/{location}/volumes/{volume}/snapshots/{snapshot} - * - storagePool: projects/{project}/locations/{location}/storagePools/{storage_pool} - * - volume: projects/{project}/locations/{location}/volumes/{volume} - * - * 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( - string $formattedName, - string $template = null - ): array { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'netapp.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error( - 'Call to undefined method ' . __CLASS__ . "::$method()", - E_USER_ERROR - ); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * CreateActiveDirectory - * Creates the active directory specified in the request. - * - * The async variant is {@see self::createActiveDirectoryAsync()} . - * - * @example samples/V1/NetAppClient/create_active_directory.php - * - * @param CreateActiveDirectoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createActiveDirectory( - CreateActiveDirectoryRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'CreateActiveDirectory', - $request, - $callOptions - )->wait(); - } - - /** - * Creates a new KMS config. - * - * The async variant is {@see self::createKmsConfigAsync()} . - * - * @example samples/V1/NetAppClient/create_kms_config.php - * - * @param CreateKmsConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createKmsConfig( - CreateKmsConfigRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'CreateKmsConfig', - $request, - $callOptions - )->wait(); - } - - /** - * Create a new replication for a volume. - * - * The async variant is {@see self::createReplicationAsync()} . - * - * @example samples/V1/NetAppClient/create_replication.php - * - * @param CreateReplicationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createReplication( - CreateReplicationRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'CreateReplication', - $request, - $callOptions - )->wait(); - } - - /** - * Create a new snapshot for a volume. - * - * The async variant is {@see self::createSnapshotAsync()} . - * - * @example samples/V1/NetAppClient/create_snapshot.php - * - * @param CreateSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSnapshot( - CreateSnapshotRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'CreateSnapshot', - $request, - $callOptions - )->wait(); - } - - /** - * Creates a new storage pool. - * - * The async variant is {@see self::createStoragePoolAsync()} . - * - * @example samples/V1/NetAppClient/create_storage_pool.php - * - * @param CreateStoragePoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createStoragePool( - CreateStoragePoolRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'CreateStoragePool', - $request, - $callOptions - )->wait(); - } - - /** - * Creates a new Volume in a given project and location. - * - * The async variant is {@see self::createVolumeAsync()} . - * - * @example samples/V1/NetAppClient/create_volume.php - * - * @param CreateVolumeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createVolume( - CreateVolumeRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'CreateVolume', - $request, - $callOptions - )->wait(); - } - - /** - * Delete the active directory specified in the request. - * - * The async variant is {@see self::deleteActiveDirectoryAsync()} . - * - * @example samples/V1/NetAppClient/delete_active_directory.php - * - * @param DeleteActiveDirectoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteActiveDirectory( - DeleteActiveDirectoryRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'DeleteActiveDirectory', - $request, - $callOptions - )->wait(); - } - - /** - * Warning! This operation will permanently delete the Kms config. - * - * The async variant is {@see self::deleteKmsConfigAsync()} . - * - * @example samples/V1/NetAppClient/delete_kms_config.php - * - * @param DeleteKmsConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteKmsConfig( - DeleteKmsConfigRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'DeleteKmsConfig', - $request, - $callOptions - )->wait(); - } - - /** - * Deletes a replication. - * - * The async variant is {@see self::deleteReplicationAsync()} . - * - * @example samples/V1/NetAppClient/delete_replication.php - * - * @param DeleteReplicationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteReplication( - DeleteReplicationRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'DeleteReplication', - $request, - $callOptions - )->wait(); - } - - /** - * Deletes a snapshot. - * - * The async variant is {@see self::deleteSnapshotAsync()} . - * - * @example samples/V1/NetAppClient/delete_snapshot.php - * - * @param DeleteSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSnapshot( - DeleteSnapshotRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'DeleteSnapshot', - $request, - $callOptions - )->wait(); - } - - /** - * Warning! This operation will permanently delete the storage pool. - * - * The async variant is {@see self::deleteStoragePoolAsync()} . - * - * @example samples/V1/NetAppClient/delete_storage_pool.php - * - * @param DeleteStoragePoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteStoragePool( - DeleteStoragePoolRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'DeleteStoragePool', - $request, - $callOptions - )->wait(); - } - - /** - * Deletes a single Volume. - * - * The async variant is {@see self::deleteVolumeAsync()} . - * - * @example samples/V1/NetAppClient/delete_volume.php - * - * @param DeleteVolumeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteVolume( - DeleteVolumeRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'DeleteVolume', - $request, - $callOptions - )->wait(); - } - - /** - * Encrypt the existing volumes without CMEK encryption with the desired the - * KMS config for the whole region. - * - * The async variant is {@see self::encryptVolumesAsync()} . - * - * @example samples/V1/NetAppClient/encrypt_volumes.php - * - * @param EncryptVolumesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function encryptVolumes( - EncryptVolumesRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'EncryptVolumes', - $request, - $callOptions - )->wait(); - } - - /** - * Describes a specified active directory. - * - * The async variant is {@see self::getActiveDirectoryAsync()} . - * - * @example samples/V1/NetAppClient/get_active_directory.php - * - * @param GetActiveDirectoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ActiveDirectory - * - * @throws ApiException Thrown if the API call fails. - */ - public function getActiveDirectory( - GetActiveDirectoryRequest $request, - array $callOptions = [] - ): ActiveDirectory { - return $this->startApiCall( - 'GetActiveDirectory', - $request, - $callOptions - )->wait(); - } - - /** - * Returns the description of the specified KMS config by kms_config_id. - * - * The async variant is {@see self::getKmsConfigAsync()} . - * - * @example samples/V1/NetAppClient/get_kms_config.php - * - * @param GetKmsConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 KmsConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getKmsConfig( - GetKmsConfigRequest $request, - array $callOptions = [] - ): KmsConfig { - return $this->startApiCall( - 'GetKmsConfig', - $request, - $callOptions - )->wait(); - } - - /** - * Describe a replication for a volume. - * - * The async variant is {@see self::getReplicationAsync()} . - * - * @example samples/V1/NetAppClient/get_replication.php - * - * @param GetReplicationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Replication - * - * @throws ApiException Thrown if the API call fails. - */ - public function getReplication( - GetReplicationRequest $request, - array $callOptions = [] - ): Replication { - return $this->startApiCall( - 'GetReplication', - $request, - $callOptions - )->wait(); - } - - /** - * Describe a snapshot for a volume. - * - * The async variant is {@see self::getSnapshotAsync()} . - * - * @example samples/V1/NetAppClient/get_snapshot.php - * - * @param GetSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Snapshot - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSnapshot( - GetSnapshotRequest $request, - array $callOptions = [] - ): Snapshot { - return $this->startApiCall( - 'GetSnapshot', - $request, - $callOptions - )->wait(); - } - - /** - * Returns the description of the specified storage pool by poolId. - * - * The async variant is {@see self::getStoragePoolAsync()} . - * - * @example samples/V1/NetAppClient/get_storage_pool.php - * - * @param GetStoragePoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 StoragePool - * - * @throws ApiException Thrown if the API call fails. - */ - public function getStoragePool( - GetStoragePoolRequest $request, - array $callOptions = [] - ): StoragePool { - return $this->startApiCall( - 'GetStoragePool', - $request, - $callOptions - )->wait(); - } - - /** - * Gets details of a single Volume. - * - * The async variant is {@see self::getVolumeAsync()} . - * - * @example samples/V1/NetAppClient/get_volume.php - * - * @param GetVolumeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Volume - * - * @throws ApiException Thrown if the API call fails. - */ - public function getVolume( - GetVolumeRequest $request, - array $callOptions = [] - ): Volume { - return $this->startApiCall('GetVolume', $request, $callOptions)->wait(); - } - - /** - * Lists active directories. - * - * The async variant is {@see self::listActiveDirectoriesAsync()} . - * - * @example samples/V1/NetAppClient/list_active_directories.php - * - * @param ListActiveDirectoriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listActiveDirectories( - ListActiveDirectoriesRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall( - 'ListActiveDirectories', - $request, - $callOptions - ); - } - - /** - * Returns descriptions of all KMS configs owned by the caller. - * - * The async variant is {@see self::listKmsConfigsAsync()} . - * - * @example samples/V1/NetAppClient/list_kms_configs.php - * - * @param ListKmsConfigsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listKmsConfigs( - ListKmsConfigsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListKmsConfigs', $request, $callOptions); - } - - /** - * Returns descriptions of all replications for a volume. - * - * The async variant is {@see self::listReplicationsAsync()} . - * - * @example samples/V1/NetAppClient/list_replications.php - * - * @param ListReplicationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listReplications( - ListReplicationsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListReplications', $request, $callOptions); - } - - /** - * Returns descriptions of all snapshots for a volume. - * - * The async variant is {@see self::listSnapshotsAsync()} . - * - * @example samples/V1/NetAppClient/list_snapshots.php - * - * @param ListSnapshotsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSnapshots( - ListSnapshotsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListSnapshots', $request, $callOptions); - } - - /** - * Returns descriptions of all storage pools owned by the caller. - * - * The async variant is {@see self::listStoragePoolsAsync()} . - * - * @example samples/V1/NetAppClient/list_storage_pools.php - * - * @param ListStoragePoolsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listStoragePools( - ListStoragePoolsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListStoragePools', $request, $callOptions); - } - - /** - * Lists Volumes in a given project. - * - * The async variant is {@see self::listVolumesAsync()} . - * - * @example samples/V1/NetAppClient/list_volumes.php - * - * @param ListVolumesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listVolumes( - ListVolumesRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListVolumes', $request, $callOptions); - } - - /** - * Resume Cross Region Replication. - * - * The async variant is {@see self::resumeReplicationAsync()} . - * - * @example samples/V1/NetAppClient/resume_replication.php - * - * @param ResumeReplicationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function resumeReplication( - ResumeReplicationRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'ResumeReplication', - $request, - $callOptions - )->wait(); - } - - /** - * Reverses direction of replication. Source becomes destination and - * destination becomes source. - * - * The async variant is {@see self::reverseReplicationDirectionAsync()} . - * - * @example samples/V1/NetAppClient/reverse_replication_direction.php - * - * @param ReverseReplicationDirectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function reverseReplicationDirection( - ReverseReplicationDirectionRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'ReverseReplicationDirection', - $request, - $callOptions - )->wait(); - } - - /** - * Revert an existing volume to a specified snapshot. - * Warning! This operation will permanently revert all changes made after the - * snapshot was created. - * - * The async variant is {@see self::revertVolumeAsync()} . - * - * @example samples/V1/NetAppClient/revert_volume.php - * - * @param RevertVolumeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function revertVolume( - RevertVolumeRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'RevertVolume', - $request, - $callOptions - )->wait(); - } - - /** - * Stop Cross Region Replication. - * - * The async variant is {@see self::stopReplicationAsync()} . - * - * @example samples/V1/NetAppClient/stop_replication.php - * - * @param StopReplicationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function stopReplication( - StopReplicationRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'StopReplication', - $request, - $callOptions - )->wait(); - } - - /** - * Update the parameters of an active directories. - * - * The async variant is {@see self::updateActiveDirectoryAsync()} . - * - * @example samples/V1/NetAppClient/update_active_directory.php - * - * @param UpdateActiveDirectoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateActiveDirectory( - UpdateActiveDirectoryRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'UpdateActiveDirectory', - $request, - $callOptions - )->wait(); - } - - /** - * Updates the Kms config properties with the full spec - * - * The async variant is {@see self::updateKmsConfigAsync()} . - * - * @example samples/V1/NetAppClient/update_kms_config.php - * - * @param UpdateKmsConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateKmsConfig( - UpdateKmsConfigRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'UpdateKmsConfig', - $request, - $callOptions - )->wait(); - } - - /** - * Updates the settings of a specific replication. - * - * The async variant is {@see self::updateReplicationAsync()} . - * - * @example samples/V1/NetAppClient/update_replication.php - * - * @param UpdateReplicationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateReplication( - UpdateReplicationRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'UpdateReplication', - $request, - $callOptions - )->wait(); - } - - /** - * Updates the settings of a specific snapshot. - * - * The async variant is {@see self::updateSnapshotAsync()} . - * - * @example samples/V1/NetAppClient/update_snapshot.php - * - * @param UpdateSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSnapshot( - UpdateSnapshotRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'UpdateSnapshot', - $request, - $callOptions - )->wait(); - } - - /** - * Updates the storage pool properties with the full spec - * - * The async variant is {@see self::updateStoragePoolAsync()} . - * - * @example samples/V1/NetAppClient/update_storage_pool.php - * - * @param UpdateStoragePoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateStoragePool( - UpdateStoragePoolRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'UpdateStoragePool', - $request, - $callOptions - )->wait(); - } - - /** - * Updates the parameters of a single Volume. - * - * The async variant is {@see self::updateVolumeAsync()} . - * - * @example samples/V1/NetAppClient/update_volume.php - * - * @param UpdateVolumeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateVolume( - UpdateVolumeRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'UpdateVolume', - $request, - $callOptions - )->wait(); - } - - /** - * Verifies KMS config reachability. - * - * The async variant is {@see self::verifyKmsConfigAsync()} . - * - * @example samples/V1/NetAppClient/verify_kms_config.php - * - * @param VerifyKmsConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 VerifyKmsConfigResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function verifyKmsConfig( - VerifyKmsConfigRequest $request, - array $callOptions = [] - ): VerifyKmsConfigResponse { - return $this->startApiCall( - 'VerifyKmsConfig', - $request, - $callOptions - )->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/NetAppClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation( - GetLocationRequest $request, - array $callOptions = [] - ): Location { - return $this->startApiCall( - 'GetLocation', - $request, - $callOptions - )->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/NetAppClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations( - ListLocationsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/NetApp/src/V1/Client/NetAppClient.php b/NetApp/src/V1/Client/NetAppClient.php index 273513dea85a..15a9fbd059df 100644 --- a/NetApp/src/V1/Client/NetAppClient.php +++ b/NetApp/src/V1/Client/NetAppClient.php @@ -24,17 +24,1437 @@ namespace Google\Cloud\NetApp\V1\Client; -use Google\Cloud\NetApp\V1\Client\BaseClient\NetAppBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\NetApp\V1\ActiveDirectory; +use Google\Cloud\NetApp\V1\CreateActiveDirectoryRequest; +use Google\Cloud\NetApp\V1\CreateKmsConfigRequest; +use Google\Cloud\NetApp\V1\CreateReplicationRequest; +use Google\Cloud\NetApp\V1\CreateSnapshotRequest; +use Google\Cloud\NetApp\V1\CreateStoragePoolRequest; +use Google\Cloud\NetApp\V1\CreateVolumeRequest; +use Google\Cloud\NetApp\V1\DeleteActiveDirectoryRequest; +use Google\Cloud\NetApp\V1\DeleteKmsConfigRequest; +use Google\Cloud\NetApp\V1\DeleteReplicationRequest; +use Google\Cloud\NetApp\V1\DeleteSnapshotRequest; +use Google\Cloud\NetApp\V1\DeleteStoragePoolRequest; +use Google\Cloud\NetApp\V1\DeleteVolumeRequest; +use Google\Cloud\NetApp\V1\EncryptVolumesRequest; +use Google\Cloud\NetApp\V1\GetActiveDirectoryRequest; +use Google\Cloud\NetApp\V1\GetKmsConfigRequest; +use Google\Cloud\NetApp\V1\GetReplicationRequest; +use Google\Cloud\NetApp\V1\GetSnapshotRequest; +use Google\Cloud\NetApp\V1\GetStoragePoolRequest; +use Google\Cloud\NetApp\V1\GetVolumeRequest; +use Google\Cloud\NetApp\V1\KmsConfig; +use Google\Cloud\NetApp\V1\ListActiveDirectoriesRequest; +use Google\Cloud\NetApp\V1\ListKmsConfigsRequest; +use Google\Cloud\NetApp\V1\ListReplicationsRequest; +use Google\Cloud\NetApp\V1\ListSnapshotsRequest; +use Google\Cloud\NetApp\V1\ListStoragePoolsRequest; +use Google\Cloud\NetApp\V1\ListVolumesRequest; +use Google\Cloud\NetApp\V1\Replication; +use Google\Cloud\NetApp\V1\ResumeReplicationRequest; +use Google\Cloud\NetApp\V1\ReverseReplicationDirectionRequest; +use Google\Cloud\NetApp\V1\RevertVolumeRequest; +use Google\Cloud\NetApp\V1\Snapshot; +use Google\Cloud\NetApp\V1\StopReplicationRequest; +use Google\Cloud\NetApp\V1\StoragePool; +use Google\Cloud\NetApp\V1\UpdateActiveDirectoryRequest; +use Google\Cloud\NetApp\V1\UpdateKmsConfigRequest; +use Google\Cloud\NetApp\V1\UpdateReplicationRequest; +use Google\Cloud\NetApp\V1\UpdateSnapshotRequest; +use Google\Cloud\NetApp\V1\UpdateStoragePoolRequest; +use Google\Cloud\NetApp\V1\UpdateVolumeRequest; +use Google\Cloud\NetApp\V1\VerifyKmsConfigRequest; +use Google\Cloud\NetApp\V1\VerifyKmsConfigResponse; +use Google\Cloud\NetApp\V1\Volume; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: NetApp Files Google Cloud Service + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createActiveDirectoryAsync(CreateActiveDirectoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface createKmsConfigAsync(CreateKmsConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface createReplicationAsync(CreateReplicationRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSnapshotAsync(CreateSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface createStoragePoolAsync(CreateStoragePoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface createVolumeAsync(CreateVolumeRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteActiveDirectoryAsync(DeleteActiveDirectoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteKmsConfigAsync(DeleteKmsConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteReplicationAsync(DeleteReplicationRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSnapshotAsync(DeleteSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteStoragePoolAsync(DeleteStoragePoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteVolumeAsync(DeleteVolumeRequest $request, array $optionalArgs = []) + * @method PromiseInterface encryptVolumesAsync(EncryptVolumesRequest $request, array $optionalArgs = []) + * @method PromiseInterface getActiveDirectoryAsync(GetActiveDirectoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface getKmsConfigAsync(GetKmsConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getReplicationAsync(GetReplicationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSnapshotAsync(GetSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface getStoragePoolAsync(GetStoragePoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface getVolumeAsync(GetVolumeRequest $request, array $optionalArgs = []) + * @method PromiseInterface listActiveDirectoriesAsync(ListActiveDirectoriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listKmsConfigsAsync(ListKmsConfigsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listReplicationsAsync(ListReplicationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSnapshotsAsync(ListSnapshotsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listStoragePoolsAsync(ListStoragePoolsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listVolumesAsync(ListVolumesRequest $request, array $optionalArgs = []) + * @method PromiseInterface resumeReplicationAsync(ResumeReplicationRequest $request, array $optionalArgs = []) + * @method PromiseInterface reverseReplicationDirectionAsync(ReverseReplicationDirectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface revertVolumeAsync(RevertVolumeRequest $request, array $optionalArgs = []) + * @method PromiseInterface stopReplicationAsync(StopReplicationRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateActiveDirectoryAsync(UpdateActiveDirectoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateKmsConfigAsync(UpdateKmsConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateReplicationAsync(UpdateReplicationRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSnapshotAsync(UpdateSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateStoragePoolAsync(UpdateStoragePoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateVolumeAsync(UpdateVolumeRequest $request, array $optionalArgs = []) + * @method PromiseInterface verifyKmsConfigAsync(VerifyKmsConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class NetAppClient extends NetAppBaseClient +final class NetAppClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see NetAppBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.netapp.v1.NetApp'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'netapp.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/net_app_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/net_app_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/net_app_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/net_app_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * active_directory resource. + * + * @param string $project + * @param string $location + * @param string $activeDirectory + * + * @return string The formatted active_directory resource. + */ + public static function activeDirectoryName(string $project, string $location, string $activeDirectory): string + { + return self::getPathTemplate('activeDirectory')->render([ + 'project' => $project, + 'location' => $location, + 'active_directory' => $activeDirectory, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a kms_config + * resource. + * + * @param string $project + * @param string $location + * @param string $kmsConfig + * + * @return string The formatted kms_config resource. + */ + public static function kmsConfigName(string $project, string $location, string $kmsConfig): string + { + return self::getPathTemplate('kmsConfig')->render([ + 'project' => $project, + 'location' => $location, + 'kms_config' => $kmsConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a network + * resource. + * + * @param string $project + * @param string $network + * + * @return string The formatted network resource. + */ + public static function networkName(string $project, string $network): string + { + return self::getPathTemplate('network')->render([ + 'project' => $project, + 'network' => $network, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a replication + * resource. + * + * @param string $project + * @param string $location + * @param string $volume + * @param string $replication + * + * @return string The formatted replication resource. + */ + public static function replicationName(string $project, string $location, string $volume, string $replication): string + { + return self::getPathTemplate('replication')->render([ + 'project' => $project, + 'location' => $location, + 'volume' => $volume, + 'replication' => $replication, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a snapshot + * resource. + * + * @param string $project + * @param string $location + * @param string $volume + * @param string $snapshot + * + * @return string The formatted snapshot resource. + */ + public static function snapshotName(string $project, string $location, string $volume, string $snapshot): string + { + return self::getPathTemplate('snapshot')->render([ + 'project' => $project, + 'location' => $location, + 'volume' => $volume, + 'snapshot' => $snapshot, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a storage_pool + * resource. + * + * @param string $project + * @param string $location + * @param string $storagePool + * + * @return string The formatted storage_pool resource. + */ + public static function storagePoolName(string $project, string $location, string $storagePool): string + { + return self::getPathTemplate('storagePool')->render([ + 'project' => $project, + 'location' => $location, + 'storage_pool' => $storagePool, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a volume + * resource. + * + * @param string $project + * @param string $location + * @param string $volume + * + * @return string The formatted volume resource. + */ + public static function volumeName(string $project, string $location, string $volume): string + { + return self::getPathTemplate('volume')->render([ + 'project' => $project, + 'location' => $location, + 'volume' => $volume, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - activeDirectory: projects/{project}/locations/{location}/activeDirectories/{active_directory} + * - kmsConfig: projects/{project}/locations/{location}/kmsConfigs/{kms_config} + * - location: projects/{project}/locations/{location} + * - network: projects/{project}/global/networks/{network} + * - replication: projects/{project}/locations/{location}/volumes/{volume}/replications/{replication} + * - snapshot: projects/{project}/locations/{location}/volumes/{volume}/snapshots/{snapshot} + * - storagePool: projects/{project}/locations/{location}/storagePools/{storage_pool} + * - volume: projects/{project}/locations/{location}/volumes/{volume} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'netapp.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * CreateActiveDirectory + * Creates the active directory specified in the request. + * + * The async variant is {@see NetAppClient::createActiveDirectoryAsync()} . + * + * @example samples/V1/NetAppClient/create_active_directory.php + * + * @param CreateActiveDirectoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createActiveDirectory(CreateActiveDirectoryRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateActiveDirectory', $request, $callOptions)->wait(); + } + + /** + * Creates a new KMS config. + * + * The async variant is {@see NetAppClient::createKmsConfigAsync()} . + * + * @example samples/V1/NetAppClient/create_kms_config.php + * + * @param CreateKmsConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createKmsConfig(CreateKmsConfigRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateKmsConfig', $request, $callOptions)->wait(); + } + + /** + * Create a new replication for a volume. + * + * The async variant is {@see NetAppClient::createReplicationAsync()} . + * + * @example samples/V1/NetAppClient/create_replication.php + * + * @param CreateReplicationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createReplication(CreateReplicationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateReplication', $request, $callOptions)->wait(); + } + + /** + * Create a new snapshot for a volume. + * + * The async variant is {@see NetAppClient::createSnapshotAsync()} . + * + * @example samples/V1/NetAppClient/create_snapshot.php + * + * @param CreateSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSnapshot(CreateSnapshotRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateSnapshot', $request, $callOptions)->wait(); + } + + /** + * Creates a new storage pool. + * + * The async variant is {@see NetAppClient::createStoragePoolAsync()} . + * + * @example samples/V1/NetAppClient/create_storage_pool.php + * + * @param CreateStoragePoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createStoragePool(CreateStoragePoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateStoragePool', $request, $callOptions)->wait(); + } + + /** + * Creates a new Volume in a given project and location. + * + * The async variant is {@see NetAppClient::createVolumeAsync()} . + * + * @example samples/V1/NetAppClient/create_volume.php + * + * @param CreateVolumeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createVolume(CreateVolumeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateVolume', $request, $callOptions)->wait(); + } + + /** + * Delete the active directory specified in the request. + * + * The async variant is {@see NetAppClient::deleteActiveDirectoryAsync()} . + * + * @example samples/V1/NetAppClient/delete_active_directory.php + * + * @param DeleteActiveDirectoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteActiveDirectory(DeleteActiveDirectoryRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteActiveDirectory', $request, $callOptions)->wait(); + } + + /** + * Warning! This operation will permanently delete the Kms config. + * + * The async variant is {@see NetAppClient::deleteKmsConfigAsync()} . + * + * @example samples/V1/NetAppClient/delete_kms_config.php + * + * @param DeleteKmsConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteKmsConfig(DeleteKmsConfigRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteKmsConfig', $request, $callOptions)->wait(); + } + + /** + * Deletes a replication. + * + * The async variant is {@see NetAppClient::deleteReplicationAsync()} . + * + * @example samples/V1/NetAppClient/delete_replication.php + * + * @param DeleteReplicationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteReplication(DeleteReplicationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteReplication', $request, $callOptions)->wait(); + } + + /** + * Deletes a snapshot. + * + * The async variant is {@see NetAppClient::deleteSnapshotAsync()} . + * + * @example samples/V1/NetAppClient/delete_snapshot.php + * + * @param DeleteSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSnapshot(DeleteSnapshotRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteSnapshot', $request, $callOptions)->wait(); + } + + /** + * Warning! This operation will permanently delete the storage pool. + * + * The async variant is {@see NetAppClient::deleteStoragePoolAsync()} . + * + * @example samples/V1/NetAppClient/delete_storage_pool.php + * + * @param DeleteStoragePoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteStoragePool(DeleteStoragePoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteStoragePool', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Volume. + * + * The async variant is {@see NetAppClient::deleteVolumeAsync()} . + * + * @example samples/V1/NetAppClient/delete_volume.php + * + * @param DeleteVolumeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteVolume(DeleteVolumeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteVolume', $request, $callOptions)->wait(); + } + + /** + * Encrypt the existing volumes without CMEK encryption with the desired the + * KMS config for the whole region. + * + * The async variant is {@see NetAppClient::encryptVolumesAsync()} . + * + * @example samples/V1/NetAppClient/encrypt_volumes.php + * + * @param EncryptVolumesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function encryptVolumes(EncryptVolumesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('EncryptVolumes', $request, $callOptions)->wait(); + } + + /** + * Describes a specified active directory. + * + * The async variant is {@see NetAppClient::getActiveDirectoryAsync()} . + * + * @example samples/V1/NetAppClient/get_active_directory.php + * + * @param GetActiveDirectoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ActiveDirectory + * + * @throws ApiException Thrown if the API call fails. + */ + public function getActiveDirectory(GetActiveDirectoryRequest $request, array $callOptions = []): ActiveDirectory + { + return $this->startApiCall('GetActiveDirectory', $request, $callOptions)->wait(); + } + + /** + * Returns the description of the specified KMS config by kms_config_id. + * + * The async variant is {@see NetAppClient::getKmsConfigAsync()} . + * + * @example samples/V1/NetAppClient/get_kms_config.php + * + * @param GetKmsConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 KmsConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getKmsConfig(GetKmsConfigRequest $request, array $callOptions = []): KmsConfig + { + return $this->startApiCall('GetKmsConfig', $request, $callOptions)->wait(); + } + + /** + * Describe a replication for a volume. + * + * The async variant is {@see NetAppClient::getReplicationAsync()} . + * + * @example samples/V1/NetAppClient/get_replication.php + * + * @param GetReplicationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Replication + * + * @throws ApiException Thrown if the API call fails. + */ + public function getReplication(GetReplicationRequest $request, array $callOptions = []): Replication + { + return $this->startApiCall('GetReplication', $request, $callOptions)->wait(); + } + + /** + * Describe a snapshot for a volume. + * + * The async variant is {@see NetAppClient::getSnapshotAsync()} . + * + * @example samples/V1/NetAppClient/get_snapshot.php + * + * @param GetSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Snapshot + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSnapshot(GetSnapshotRequest $request, array $callOptions = []): Snapshot + { + return $this->startApiCall('GetSnapshot', $request, $callOptions)->wait(); + } + + /** + * Returns the description of the specified storage pool by poolId. + * + * The async variant is {@see NetAppClient::getStoragePoolAsync()} . + * + * @example samples/V1/NetAppClient/get_storage_pool.php + * + * @param GetStoragePoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 StoragePool + * + * @throws ApiException Thrown if the API call fails. + */ + public function getStoragePool(GetStoragePoolRequest $request, array $callOptions = []): StoragePool + { + return $this->startApiCall('GetStoragePool', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Volume. + * + * The async variant is {@see NetAppClient::getVolumeAsync()} . + * + * @example samples/V1/NetAppClient/get_volume.php + * + * @param GetVolumeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Volume + * + * @throws ApiException Thrown if the API call fails. + */ + public function getVolume(GetVolumeRequest $request, array $callOptions = []): Volume + { + return $this->startApiCall('GetVolume', $request, $callOptions)->wait(); + } + + /** + * Lists active directories. + * + * The async variant is {@see NetAppClient::listActiveDirectoriesAsync()} . + * + * @example samples/V1/NetAppClient/list_active_directories.php + * + * @param ListActiveDirectoriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listActiveDirectories(ListActiveDirectoriesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListActiveDirectories', $request, $callOptions); + } + + /** + * Returns descriptions of all KMS configs owned by the caller. + * + * The async variant is {@see NetAppClient::listKmsConfigsAsync()} . + * + * @example samples/V1/NetAppClient/list_kms_configs.php + * + * @param ListKmsConfigsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listKmsConfigs(ListKmsConfigsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListKmsConfigs', $request, $callOptions); + } + + /** + * Returns descriptions of all replications for a volume. + * + * The async variant is {@see NetAppClient::listReplicationsAsync()} . + * + * @example samples/V1/NetAppClient/list_replications.php + * + * @param ListReplicationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listReplications(ListReplicationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListReplications', $request, $callOptions); + } + + /** + * Returns descriptions of all snapshots for a volume. + * + * The async variant is {@see NetAppClient::listSnapshotsAsync()} . + * + * @example samples/V1/NetAppClient/list_snapshots.php + * + * @param ListSnapshotsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSnapshots(ListSnapshotsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSnapshots', $request, $callOptions); + } + + /** + * Returns descriptions of all storage pools owned by the caller. + * + * The async variant is {@see NetAppClient::listStoragePoolsAsync()} . + * + * @example samples/V1/NetAppClient/list_storage_pools.php + * + * @param ListStoragePoolsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listStoragePools(ListStoragePoolsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListStoragePools', $request, $callOptions); + } + + /** + * Lists Volumes in a given project. + * + * The async variant is {@see NetAppClient::listVolumesAsync()} . + * + * @example samples/V1/NetAppClient/list_volumes.php + * + * @param ListVolumesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listVolumes(ListVolumesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListVolumes', $request, $callOptions); + } + + /** + * Resume Cross Region Replication. + * + * The async variant is {@see NetAppClient::resumeReplicationAsync()} . + * + * @example samples/V1/NetAppClient/resume_replication.php + * + * @param ResumeReplicationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function resumeReplication(ResumeReplicationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ResumeReplication', $request, $callOptions)->wait(); + } + + /** + * Reverses direction of replication. Source becomes destination and + * destination becomes source. + * + * The async variant is {@see NetAppClient::reverseReplicationDirectionAsync()} . + * + * @example samples/V1/NetAppClient/reverse_replication_direction.php + * + * @param ReverseReplicationDirectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function reverseReplicationDirection(ReverseReplicationDirectionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ReverseReplicationDirection', $request, $callOptions)->wait(); + } + + /** + * Revert an existing volume to a specified snapshot. + * Warning! This operation will permanently revert all changes made after the + * snapshot was created. + * + * The async variant is {@see NetAppClient::revertVolumeAsync()} . + * + * @example samples/V1/NetAppClient/revert_volume.php + * + * @param RevertVolumeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function revertVolume(RevertVolumeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RevertVolume', $request, $callOptions)->wait(); + } + + /** + * Stop Cross Region Replication. + * + * The async variant is {@see NetAppClient::stopReplicationAsync()} . + * + * @example samples/V1/NetAppClient/stop_replication.php + * + * @param StopReplicationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function stopReplication(StopReplicationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StopReplication', $request, $callOptions)->wait(); + } + + /** + * Update the parameters of an active directories. + * + * The async variant is {@see NetAppClient::updateActiveDirectoryAsync()} . + * + * @example samples/V1/NetAppClient/update_active_directory.php + * + * @param UpdateActiveDirectoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateActiveDirectory(UpdateActiveDirectoryRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateActiveDirectory', $request, $callOptions)->wait(); + } + + /** + * Updates the Kms config properties with the full spec + * + * The async variant is {@see NetAppClient::updateKmsConfigAsync()} . + * + * @example samples/V1/NetAppClient/update_kms_config.php + * + * @param UpdateKmsConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateKmsConfig(UpdateKmsConfigRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateKmsConfig', $request, $callOptions)->wait(); + } + + /** + * Updates the settings of a specific replication. + * + * The async variant is {@see NetAppClient::updateReplicationAsync()} . + * + * @example samples/V1/NetAppClient/update_replication.php + * + * @param UpdateReplicationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateReplication(UpdateReplicationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateReplication', $request, $callOptions)->wait(); + } + + /** + * Updates the settings of a specific snapshot. + * + * The async variant is {@see NetAppClient::updateSnapshotAsync()} . + * + * @example samples/V1/NetAppClient/update_snapshot.php + * + * @param UpdateSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSnapshot(UpdateSnapshotRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateSnapshot', $request, $callOptions)->wait(); + } + + /** + * Updates the storage pool properties with the full spec + * + * The async variant is {@see NetAppClient::updateStoragePoolAsync()} . + * + * @example samples/V1/NetAppClient/update_storage_pool.php + * + * @param UpdateStoragePoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateStoragePool(UpdateStoragePoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateStoragePool', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single Volume. + * + * The async variant is {@see NetAppClient::updateVolumeAsync()} . + * + * @example samples/V1/NetAppClient/update_volume.php + * + * @param UpdateVolumeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateVolume(UpdateVolumeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateVolume', $request, $callOptions)->wait(); + } + + /** + * Verifies KMS config reachability. + * + * The async variant is {@see NetAppClient::verifyKmsConfigAsync()} . + * + * @example samples/V1/NetAppClient/verify_kms_config.php + * + * @param VerifyKmsConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 VerifyKmsConfigResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function verifyKmsConfig(VerifyKmsConfigRequest $request, array $callOptions = []): VerifyKmsConfigResponse + { + return $this->startApiCall('VerifyKmsConfig', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see NetAppClient::getLocationAsync()} . + * + * @example samples/V1/NetAppClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see NetAppClient::listLocationsAsync()} . + * + * @example samples/V1/NetAppClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/NetworkConnectivity/composer.json b/NetworkConnectivity/composer.json index 2c3195342f82..dd1861766f79 100644 --- a/NetworkConnectivity/composer.json +++ b/NetworkConnectivity/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/NetworkConnectivity/src/V1/Client/BaseClient/HubServiceBaseClient.php b/NetworkConnectivity/src/V1/Client/BaseClient/HubServiceBaseClient.php deleted file mode 100644 index 13b0fbb71a41..000000000000 --- a/NetworkConnectivity/src/V1/Client/BaseClient/HubServiceBaseClient.php +++ /dev/null @@ -1,1076 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/hub_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/hub_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/hub_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/hub_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a group - * resource. - * - * @param string $project - * @param string $hub - * @param string $group - * - * @return string The formatted group resource. - */ - public static function groupName(string $project, string $hub, string $group): string - { - return self::getPathTemplate('group')->render([ - 'project' => $project, - 'hub' => $hub, - 'group' => $group, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a hub - * resource. - * - * @param string $project - * @param string $hub - * - * @return string The formatted hub resource. - */ - public static function hubName(string $project, string $hub): string - { - return self::getPathTemplate('hub')->render([ - 'project' => $project, - 'hub' => $hub, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a hub_route - * resource. - * - * @param string $project - * @param string $hub - * @param string $routeTable - * @param string $route - * - * @return string The formatted hub_route resource. - */ - public static function hubRouteName(string $project, string $hub, string $routeTable, string $route): string - { - return self::getPathTemplate('hubRoute')->render([ - 'project' => $project, - 'hub' => $hub, - 'route_table' => $routeTable, - 'route' => $route, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a instance - * resource. - * - * @param string $project - * @param string $zone - * @param string $instance - * - * @return string The formatted instance resource. - */ - public static function instanceName(string $project, string $zone, string $instance): string - { - return self::getPathTemplate('instance')->render([ - 'project' => $project, - 'zone' => $zone, - 'instance' => $instance, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * interconnect_attachment resource. - * - * @param string $project - * @param string $region - * @param string $resourceId - * - * @return string The formatted interconnect_attachment resource. - */ - public static function interconnectAttachmentName(string $project, string $region, string $resourceId): string - { - return self::getPathTemplate('interconnectAttachment')->render([ - 'project' => $project, - 'region' => $region, - 'resource_id' => $resourceId, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a network - * resource. - * - * @param string $project - * @param string $resourceId - * - * @return string The formatted network resource. - */ - public static function networkName(string $project, string $resourceId): string - { - return self::getPathTemplate('network')->render([ - 'project' => $project, - 'resource_id' => $resourceId, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a route_table - * resource. - * - * @param string $project - * @param string $hub - * @param string $routeTable - * - * @return string The formatted route_table resource. - */ - public static function routeTableName(string $project, string $hub, string $routeTable): string - { - return self::getPathTemplate('routeTable')->render([ - 'project' => $project, - 'hub' => $hub, - 'route_table' => $routeTable, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a spoke - * resource. - * - * @param string $project - * @param string $location - * @param string $spoke - * - * @return string The formatted spoke resource. - */ - public static function spokeName(string $project, string $location, string $spoke): string - { - return self::getPathTemplate('spoke')->render([ - 'project' => $project, - 'location' => $location, - 'spoke' => $spoke, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a vpn_tunnel - * resource. - * - * @param string $project - * @param string $region - * @param string $resourceId - * - * @return string The formatted vpn_tunnel resource. - */ - public static function vpnTunnelName(string $project, string $region, string $resourceId): string - { - return self::getPathTemplate('vpnTunnel')->render([ - 'project' => $project, - 'region' => $region, - 'resource_id' => $resourceId, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - group: projects/{project}/locations/global/hubs/{hub}/groups/{group} - * - hub: projects/{project}/locations/global/hubs/{hub} - * - hubRoute: projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}/routes/{route} - * - instance: projects/{project}/zones/{zone}/instances/{instance} - * - interconnectAttachment: projects/{project}/regions/{region}/interconnectAttachments/{resource_id} - * - location: projects/{project}/locations/{location} - * - network: projects/{project}/global/networks/{resource_id} - * - routeTable: projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table} - * - spoke: projects/{project}/locations/{location}/spokes/{spoke} - * - vpnTunnel: projects/{project}/regions/{region}/vpnTunnels/{resource_id} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'networkconnectivity.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Accepts a proposal to attach a Network Connectivity Center spoke - * to a hub. - * - * The async variant is {@see self::acceptHubSpokeAsync()} . - * - * @param AcceptHubSpokeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function acceptHubSpoke(AcceptHubSpokeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AcceptHubSpoke', $request, $callOptions)->wait(); - } - - /** - * Creates a new Network Connectivity Center hub in the specified project. - * - * The async variant is {@see self::createHubAsync()} . - * - * @param CreateHubRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createHub(CreateHubRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateHub', $request, $callOptions)->wait(); - } - - /** - * Creates a Network Connectivity Center spoke. - * - * The async variant is {@see self::createSpokeAsync()} . - * - * @param CreateSpokeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSpoke(CreateSpokeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateSpoke', $request, $callOptions)->wait(); - } - - /** - * Deletes a Network Connectivity Center hub. - * - * The async variant is {@see self::deleteHubAsync()} . - * - * @param DeleteHubRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteHub(DeleteHubRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteHub', $request, $callOptions)->wait(); - } - - /** - * Deletes a Network Connectivity Center spoke. - * - * The async variant is {@see self::deleteSpokeAsync()} . - * - * @param DeleteSpokeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSpoke(DeleteSpokeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteSpoke', $request, $callOptions)->wait(); - } - - /** - * Gets details about a Network Connectivity Center group. - * - * The async variant is {@see self::getGroupAsync()} . - * - * @param GetGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Group - * - * @throws ApiException Thrown if the API call fails. - */ - public function getGroup(GetGroupRequest $request, array $callOptions = []): Group - { - return $this->startApiCall('GetGroup', $request, $callOptions)->wait(); - } - - /** - * Gets details about a Network Connectivity Center hub. - * - * The async variant is {@see self::getHubAsync()} . - * - * @param GetHubRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Hub - * - * @throws ApiException Thrown if the API call fails. - */ - public function getHub(GetHubRequest $request, array $callOptions = []): Hub - { - return $this->startApiCall('GetHub', $request, $callOptions)->wait(); - } - - /** - * Gets details about the specified route. - * - * The async variant is {@see self::getRouteAsync()} . - * - * @param GetRouteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Route - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRoute(GetRouteRequest $request, array $callOptions = []): Route - { - return $this->startApiCall('GetRoute', $request, $callOptions)->wait(); - } - - /** - * Gets details about a Network Connectivity Center route table. - * - * The async variant is {@see self::getRouteTableAsync()} . - * - * @param GetRouteTableRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RouteTable - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRouteTable(GetRouteTableRequest $request, array $callOptions = []): RouteTable - { - return $this->startApiCall('GetRouteTable', $request, $callOptions)->wait(); - } - - /** - * Gets details about a Network Connectivity Center spoke. - * - * The async variant is {@see self::getSpokeAsync()} . - * - * @param GetSpokeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Spoke - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSpoke(GetSpokeRequest $request, array $callOptions = []): Spoke - { - return $this->startApiCall('GetSpoke', $request, $callOptions)->wait(); - } - - /** - * Lists groups in a given hub. - * - * The async variant is {@see self::listGroupsAsync()} . - * - * @param ListGroupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listGroups(ListGroupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListGroups', $request, $callOptions); - } - - /** - * Lists the Network Connectivity Center spokes associated with a - * specified hub and location. The list includes both spokes that are attached - * to the hub and spokes that have been proposed but not yet accepted. - * - * The async variant is {@see self::listHubSpokesAsync()} . - * - * @param ListHubSpokesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listHubSpokes(ListHubSpokesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListHubSpokes', $request, $callOptions); - } - - /** - * Lists the Network Connectivity Center hubs associated with a given project. - * - * The async variant is {@see self::listHubsAsync()} . - * - * @param ListHubsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listHubs(ListHubsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListHubs', $request, $callOptions); - } - - /** - * Lists route tables in a given project. - * - * The async variant is {@see self::listRouteTablesAsync()} . - * - * @param ListRouteTablesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listRouteTables(ListRouteTablesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListRouteTables', $request, $callOptions); - } - - /** - * Lists routes in a given project. - * - * The async variant is {@see self::listRoutesAsync()} . - * - * @param ListRoutesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listRoutes(ListRoutesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListRoutes', $request, $callOptions); - } - - /** - * Lists the Network Connectivity Center spokes in a specified project and - * location. - * - * The async variant is {@see self::listSpokesAsync()} . - * - * @param ListSpokesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSpokes(ListSpokesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSpokes', $request, $callOptions); - } - - /** - * Rejects a Network Connectivity Center spoke from being attached to a hub. - * If the spoke was previously in the `ACTIVE` state, it - * transitions to the `INACTIVE` state and is no longer able to - * connect to other spokes that are attached to the hub. - * - * The async variant is {@see self::rejectHubSpokeAsync()} . - * - * @param RejectHubSpokeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function rejectHubSpoke(RejectHubSpokeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RejectHubSpoke', $request, $callOptions)->wait(); - } - - /** - * Updates the description and/or labels of a Network Connectivity Center - * hub. - * - * The async variant is {@see self::updateHubAsync()} . - * - * @param UpdateHubRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateHub(UpdateHubRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateHub', $request, $callOptions)->wait(); - } - - /** - * Updates the parameters of a Network Connectivity Center spoke. - * - * The async variant is {@see self::updateSpokeAsync()} . - * - * @param UpdateSpokeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSpoke(UpdateSpokeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateSpoke', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/NetworkConnectivity/src/V1/Client/BaseClient/PolicyBasedRoutingServiceBaseClient.php b/NetworkConnectivity/src/V1/Client/BaseClient/PolicyBasedRoutingServiceBaseClient.php deleted file mode 100644 index 016aa975a78d..000000000000 --- a/NetworkConnectivity/src/V1/Client/BaseClient/PolicyBasedRoutingServiceBaseClient.php +++ /dev/null @@ -1,531 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/policy_based_routing_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/policy_based_routing_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/policy_based_routing_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/policy_based_routing_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a network - * resource. - * - * @param string $project - * @param string $resourceId - * - * @return string The formatted network resource. - */ - public static function networkName(string $project, string $resourceId): string - { - return self::getPathTemplate('network')->render([ - 'project' => $project, - 'resource_id' => $resourceId, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * policy_based_route resource. - * - * @param string $project - * @param string $policyBasedRoute - * - * @return string The formatted policy_based_route resource. - */ - public static function policyBasedRouteName(string $project, string $policyBasedRoute): string - { - return self::getPathTemplate('policyBasedRoute')->render([ - 'project' => $project, - 'policy_based_route' => $policyBasedRoute, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - location: projects/{project}/locations/{location} - * - network: projects/{project}/global/networks/{resource_id} - * - policyBasedRoute: projects/{project}/locations/global/PolicyBasedRoutes/{policy_based_route} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'networkconnectivity.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new PolicyBasedRoute in a given project and location. - * - * The async variant is {@see self::createPolicyBasedRouteAsync()} . - * - * @param CreatePolicyBasedRouteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createPolicyBasedRoute(CreatePolicyBasedRouteRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreatePolicyBasedRoute', $request, $callOptions)->wait(); - } - - /** - * Deletes a single PolicyBasedRoute. - * - * The async variant is {@see self::deletePolicyBasedRouteAsync()} . - * - * @param DeletePolicyBasedRouteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deletePolicyBasedRoute(DeletePolicyBasedRouteRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeletePolicyBasedRoute', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single PolicyBasedRoute. - * - * The async variant is {@see self::getPolicyBasedRouteAsync()} . - * - * @param GetPolicyBasedRouteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PolicyBasedRoute - * - * @throws ApiException Thrown if the API call fails. - */ - public function getPolicyBasedRoute(GetPolicyBasedRouteRequest $request, array $callOptions = []): PolicyBasedRoute - { - return $this->startApiCall('GetPolicyBasedRoute', $request, $callOptions)->wait(); - } - - /** - * Lists PolicyBasedRoutes in a given project and location. - * - * The async variant is {@see self::listPolicyBasedRoutesAsync()} . - * - * @param ListPolicyBasedRoutesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPolicyBasedRoutes(ListPolicyBasedRoutesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPolicyBasedRoutes', $request, $callOptions); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/NetworkConnectivity/src/V1/Client/HubServiceClient.php b/NetworkConnectivity/src/V1/Client/HubServiceClient.php index d6731f42cff9..dd4daa7ece59 100644 --- a/NetworkConnectivity/src/V1/Client/HubServiceClient.php +++ b/NetworkConnectivity/src/V1/Client/HubServiceClient.php @@ -24,17 +24,1051 @@ namespace Google\Cloud\NetworkConnectivity\V1\Client; -use Google\Cloud\NetworkConnectivity\V1\Client\BaseClient\HubServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\NetworkConnectivity\V1\AcceptHubSpokeRequest; +use Google\Cloud\NetworkConnectivity\V1\CreateHubRequest; +use Google\Cloud\NetworkConnectivity\V1\CreateSpokeRequest; +use Google\Cloud\NetworkConnectivity\V1\DeleteHubRequest; +use Google\Cloud\NetworkConnectivity\V1\DeleteSpokeRequest; +use Google\Cloud\NetworkConnectivity\V1\GetGroupRequest; +use Google\Cloud\NetworkConnectivity\V1\GetHubRequest; +use Google\Cloud\NetworkConnectivity\V1\GetRouteRequest; +use Google\Cloud\NetworkConnectivity\V1\GetRouteTableRequest; +use Google\Cloud\NetworkConnectivity\V1\GetSpokeRequest; +use Google\Cloud\NetworkConnectivity\V1\Group; +use Google\Cloud\NetworkConnectivity\V1\Hub; +use Google\Cloud\NetworkConnectivity\V1\ListGroupsRequest; +use Google\Cloud\NetworkConnectivity\V1\ListHubSpokesRequest; +use Google\Cloud\NetworkConnectivity\V1\ListHubsRequest; +use Google\Cloud\NetworkConnectivity\V1\ListRouteTablesRequest; +use Google\Cloud\NetworkConnectivity\V1\ListRoutesRequest; +use Google\Cloud\NetworkConnectivity\V1\ListSpokesRequest; +use Google\Cloud\NetworkConnectivity\V1\RejectHubSpokeRequest; +use Google\Cloud\NetworkConnectivity\V1\Route; +use Google\Cloud\NetworkConnectivity\V1\RouteTable; +use Google\Cloud\NetworkConnectivity\V1\Spoke; +use Google\Cloud\NetworkConnectivity\V1\UpdateHubRequest; +use Google\Cloud\NetworkConnectivity\V1\UpdateSpokeRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Network Connectivity Center is a hub-and-spoke abstraction for network + * connectivity management in Google Cloud. It reduces operational complexity + * through a simple, centralized connectivity management model. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\NetworkConnectivity\V1\HubServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface acceptHubSpokeAsync(AcceptHubSpokeRequest $request, array $optionalArgs = []) + * @method PromiseInterface createHubAsync(CreateHubRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSpokeAsync(CreateSpokeRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteHubAsync(DeleteHubRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSpokeAsync(DeleteSpokeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getGroupAsync(GetGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface getHubAsync(GetHubRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRouteAsync(GetRouteRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRouteTableAsync(GetRouteTableRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSpokeAsync(GetSpokeRequest $request, array $optionalArgs = []) + * @method PromiseInterface listGroupsAsync(ListGroupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listHubSpokesAsync(ListHubSpokesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listHubsAsync(ListHubsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listRouteTablesAsync(ListRouteTablesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listRoutesAsync(ListRoutesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSpokesAsync(ListSpokesRequest $request, array $optionalArgs = []) + * @method PromiseInterface rejectHubSpokeAsync(RejectHubSpokeRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateHubAsync(UpdateHubRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSpokeAsync(UpdateSpokeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class HubServiceClient extends HubServiceBaseClient +final class HubServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see HubServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.networkconnectivity.v1.HubService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'networkconnectivity.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/hub_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/hub_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/hub_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/hub_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a group + * resource. + * + * @param string $project + * @param string $hub + * @param string $group + * + * @return string The formatted group resource. + */ + public static function groupName(string $project, string $hub, string $group): string + { + return self::getPathTemplate('group')->render([ + 'project' => $project, + 'hub' => $hub, + 'group' => $group, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a hub + * resource. + * + * @param string $project + * @param string $hub + * + * @return string The formatted hub resource. + */ + public static function hubName(string $project, string $hub): string + { + return self::getPathTemplate('hub')->render([ + 'project' => $project, + 'hub' => $hub, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a hub_route + * resource. + * + * @param string $project + * @param string $hub + * @param string $routeTable + * @param string $route + * + * @return string The formatted hub_route resource. + */ + public static function hubRouteName(string $project, string $hub, string $routeTable, string $route): string + { + return self::getPathTemplate('hubRoute')->render([ + 'project' => $project, + 'hub' => $hub, + 'route_table' => $routeTable, + 'route' => $route, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a instance + * resource. + * + * @param string $project + * @param string $zone + * @param string $instance + * + * @return string The formatted instance resource. + */ + public static function instanceName(string $project, string $zone, string $instance): string + { + return self::getPathTemplate('instance')->render([ + 'project' => $project, + 'zone' => $zone, + 'instance' => $instance, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * interconnect_attachment resource. + * + * @param string $project + * @param string $region + * @param string $resourceId + * + * @return string The formatted interconnect_attachment resource. + */ + public static function interconnectAttachmentName(string $project, string $region, string $resourceId): string + { + return self::getPathTemplate('interconnectAttachment')->render([ + 'project' => $project, + 'region' => $region, + 'resource_id' => $resourceId, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a network + * resource. + * + * @param string $project + * @param string $resourceId + * + * @return string The formatted network resource. + */ + public static function networkName(string $project, string $resourceId): string + { + return self::getPathTemplate('network')->render([ + 'project' => $project, + 'resource_id' => $resourceId, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a route_table + * resource. + * + * @param string $project + * @param string $hub + * @param string $routeTable + * + * @return string The formatted route_table resource. + */ + public static function routeTableName(string $project, string $hub, string $routeTable): string + { + return self::getPathTemplate('routeTable')->render([ + 'project' => $project, + 'hub' => $hub, + 'route_table' => $routeTable, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a spoke + * resource. + * + * @param string $project + * @param string $location + * @param string $spoke + * + * @return string The formatted spoke resource. + */ + public static function spokeName(string $project, string $location, string $spoke): string + { + return self::getPathTemplate('spoke')->render([ + 'project' => $project, + 'location' => $location, + 'spoke' => $spoke, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a vpn_tunnel + * resource. + * + * @param string $project + * @param string $region + * @param string $resourceId + * + * @return string The formatted vpn_tunnel resource. + */ + public static function vpnTunnelName(string $project, string $region, string $resourceId): string + { + return self::getPathTemplate('vpnTunnel')->render([ + 'project' => $project, + 'region' => $region, + 'resource_id' => $resourceId, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - group: projects/{project}/locations/global/hubs/{hub}/groups/{group} + * - hub: projects/{project}/locations/global/hubs/{hub} + * - hubRoute: projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table}/routes/{route} + * - instance: projects/{project}/zones/{zone}/instances/{instance} + * - interconnectAttachment: projects/{project}/regions/{region}/interconnectAttachments/{resource_id} + * - location: projects/{project}/locations/{location} + * - network: projects/{project}/global/networks/{resource_id} + * - routeTable: projects/{project}/locations/global/hubs/{hub}/routeTables/{route_table} + * - spoke: projects/{project}/locations/{location}/spokes/{spoke} + * - vpnTunnel: projects/{project}/regions/{region}/vpnTunnels/{resource_id} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'networkconnectivity.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Accepts a proposal to attach a Network Connectivity Center spoke + * to a hub. + * + * The async variant is {@see HubServiceClient::acceptHubSpokeAsync()} . + * + * @param AcceptHubSpokeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function acceptHubSpoke(AcceptHubSpokeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AcceptHubSpoke', $request, $callOptions)->wait(); + } + + /** + * Creates a new Network Connectivity Center hub in the specified project. + * + * The async variant is {@see HubServiceClient::createHubAsync()} . + * + * @param CreateHubRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createHub(CreateHubRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateHub', $request, $callOptions)->wait(); + } + + /** + * Creates a Network Connectivity Center spoke. + * + * The async variant is {@see HubServiceClient::createSpokeAsync()} . + * + * @param CreateSpokeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSpoke(CreateSpokeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateSpoke', $request, $callOptions)->wait(); + } + + /** + * Deletes a Network Connectivity Center hub. + * + * The async variant is {@see HubServiceClient::deleteHubAsync()} . + * + * @param DeleteHubRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteHub(DeleteHubRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteHub', $request, $callOptions)->wait(); + } + + /** + * Deletes a Network Connectivity Center spoke. + * + * The async variant is {@see HubServiceClient::deleteSpokeAsync()} . + * + * @param DeleteSpokeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSpoke(DeleteSpokeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteSpoke', $request, $callOptions)->wait(); + } + + /** + * Gets details about a Network Connectivity Center group. + * + * The async variant is {@see HubServiceClient::getGroupAsync()} . + * + * @param GetGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Group + * + * @throws ApiException Thrown if the API call fails. + */ + public function getGroup(GetGroupRequest $request, array $callOptions = []): Group + { + return $this->startApiCall('GetGroup', $request, $callOptions)->wait(); + } + + /** + * Gets details about a Network Connectivity Center hub. + * + * The async variant is {@see HubServiceClient::getHubAsync()} . + * + * @param GetHubRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Hub + * + * @throws ApiException Thrown if the API call fails. + */ + public function getHub(GetHubRequest $request, array $callOptions = []): Hub + { + return $this->startApiCall('GetHub', $request, $callOptions)->wait(); + } + + /** + * Gets details about the specified route. + * + * The async variant is {@see HubServiceClient::getRouteAsync()} . + * + * @param GetRouteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Route + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRoute(GetRouteRequest $request, array $callOptions = []): Route + { + return $this->startApiCall('GetRoute', $request, $callOptions)->wait(); + } + + /** + * Gets details about a Network Connectivity Center route table. + * + * The async variant is {@see HubServiceClient::getRouteTableAsync()} . + * + * @param GetRouteTableRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RouteTable + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRouteTable(GetRouteTableRequest $request, array $callOptions = []): RouteTable + { + return $this->startApiCall('GetRouteTable', $request, $callOptions)->wait(); + } + + /** + * Gets details about a Network Connectivity Center spoke. + * + * The async variant is {@see HubServiceClient::getSpokeAsync()} . + * + * @param GetSpokeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Spoke + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSpoke(GetSpokeRequest $request, array $callOptions = []): Spoke + { + return $this->startApiCall('GetSpoke', $request, $callOptions)->wait(); + } + + /** + * Lists groups in a given hub. + * + * The async variant is {@see HubServiceClient::listGroupsAsync()} . + * + * @param ListGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listGroups(ListGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListGroups', $request, $callOptions); + } + + /** + * Lists the Network Connectivity Center spokes associated with a + * specified hub and location. The list includes both spokes that are attached + * to the hub and spokes that have been proposed but not yet accepted. + * + * The async variant is {@see HubServiceClient::listHubSpokesAsync()} . + * + * @param ListHubSpokesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listHubSpokes(ListHubSpokesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListHubSpokes', $request, $callOptions); + } + + /** + * Lists the Network Connectivity Center hubs associated with a given project. + * + * The async variant is {@see HubServiceClient::listHubsAsync()} . + * + * @param ListHubsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listHubs(ListHubsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListHubs', $request, $callOptions); + } + + /** + * Lists route tables in a given project. + * + * The async variant is {@see HubServiceClient::listRouteTablesAsync()} . + * + * @param ListRouteTablesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listRouteTables(ListRouteTablesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListRouteTables', $request, $callOptions); + } + + /** + * Lists routes in a given project. + * + * The async variant is {@see HubServiceClient::listRoutesAsync()} . + * + * @param ListRoutesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listRoutes(ListRoutesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListRoutes', $request, $callOptions); + } + + /** + * Lists the Network Connectivity Center spokes in a specified project and + * location. + * + * The async variant is {@see HubServiceClient::listSpokesAsync()} . + * + * @param ListSpokesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSpokes(ListSpokesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSpokes', $request, $callOptions); + } + + /** + * Rejects a Network Connectivity Center spoke from being attached to a hub. + * If the spoke was previously in the `ACTIVE` state, it + * transitions to the `INACTIVE` state and is no longer able to + * connect to other spokes that are attached to the hub. + * + * The async variant is {@see HubServiceClient::rejectHubSpokeAsync()} . + * + * @param RejectHubSpokeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function rejectHubSpoke(RejectHubSpokeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RejectHubSpoke', $request, $callOptions)->wait(); + } + + /** + * Updates the description and/or labels of a Network Connectivity Center + * hub. + * + * The async variant is {@see HubServiceClient::updateHubAsync()} . + * + * @param UpdateHubRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateHub(UpdateHubRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateHub', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a Network Connectivity Center spoke. + * + * The async variant is {@see HubServiceClient::updateSpokeAsync()} . + * + * @param UpdateSpokeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSpoke(UpdateSpokeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateSpoke', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see HubServiceClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see HubServiceClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see HubServiceClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see HubServiceClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see HubServiceClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/NetworkConnectivity/src/V1/Client/PolicyBasedRoutingServiceClient.php b/NetworkConnectivity/src/V1/Client/PolicyBasedRoutingServiceClient.php index 617b98885061..0dc65ba9b4d9 100644 --- a/NetworkConnectivity/src/V1/Client/PolicyBasedRoutingServiceClient.php +++ b/NetworkConnectivity/src/V1/Client/PolicyBasedRoutingServiceClient.php @@ -24,17 +24,515 @@ namespace Google\Cloud\NetworkConnectivity\V1\Client; -use Google\Cloud\NetworkConnectivity\V1\Client\BaseClient\PolicyBasedRoutingServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\NetworkConnectivity\V1\CreatePolicyBasedRouteRequest; +use Google\Cloud\NetworkConnectivity\V1\DeletePolicyBasedRouteRequest; +use Google\Cloud\NetworkConnectivity\V1\GetPolicyBasedRouteRequest; +use Google\Cloud\NetworkConnectivity\V1\ListPolicyBasedRoutesRequest; +use Google\Cloud\NetworkConnectivity\V1\PolicyBasedRoute; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Policy-Based Routing allows GCP customers to specify flexibile routing + * policies for Layer 4 traffic traversing through the connected service. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\NetworkConnectivity\V1\PolicyBasedRoutingServiceClient} for the + * stable implementation * * @experimental + * + * @method PromiseInterface createPolicyBasedRouteAsync(CreatePolicyBasedRouteRequest $request, array $optionalArgs = []) + * @method PromiseInterface deletePolicyBasedRouteAsync(DeletePolicyBasedRouteRequest $request, array $optionalArgs = []) + * @method PromiseInterface getPolicyBasedRouteAsync(GetPolicyBasedRouteRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPolicyBasedRoutesAsync(ListPolicyBasedRoutesRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class PolicyBasedRoutingServiceClient extends PolicyBasedRoutingServiceBaseClient +final class PolicyBasedRoutingServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see PolicyBasedRoutingServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.networkconnectivity.v1.PolicyBasedRoutingService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'networkconnectivity.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/policy_based_routing_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/policy_based_routing_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/policy_based_routing_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/policy_based_routing_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a network + * resource. + * + * @param string $project + * @param string $resourceId + * + * @return string The formatted network resource. + */ + public static function networkName(string $project, string $resourceId): string + { + return self::getPathTemplate('network')->render([ + 'project' => $project, + 'resource_id' => $resourceId, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * policy_based_route resource. + * + * @param string $project + * @param string $policyBasedRoute + * + * @return string The formatted policy_based_route resource. + */ + public static function policyBasedRouteName(string $project, string $policyBasedRoute): string + { + return self::getPathTemplate('policyBasedRoute')->render([ + 'project' => $project, + 'policy_based_route' => $policyBasedRoute, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - location: projects/{project}/locations/{location} + * - network: projects/{project}/global/networks/{resource_id} + * - policyBasedRoute: projects/{project}/locations/global/PolicyBasedRoutes/{policy_based_route} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'networkconnectivity.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new PolicyBasedRoute in a given project and location. + * + * The async variant is + * {@see PolicyBasedRoutingServiceClient::createPolicyBasedRouteAsync()} . + * + * @param CreatePolicyBasedRouteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createPolicyBasedRoute(CreatePolicyBasedRouteRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreatePolicyBasedRoute', $request, $callOptions)->wait(); + } + + /** + * Deletes a single PolicyBasedRoute. + * + * The async variant is + * {@see PolicyBasedRoutingServiceClient::deletePolicyBasedRouteAsync()} . + * + * @param DeletePolicyBasedRouteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deletePolicyBasedRoute(DeletePolicyBasedRouteRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeletePolicyBasedRoute', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single PolicyBasedRoute. + * + * The async variant is + * {@see PolicyBasedRoutingServiceClient::getPolicyBasedRouteAsync()} . + * + * @param GetPolicyBasedRouteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PolicyBasedRoute + * + * @throws ApiException Thrown if the API call fails. + */ + public function getPolicyBasedRoute(GetPolicyBasedRouteRequest $request, array $callOptions = []): PolicyBasedRoute + { + return $this->startApiCall('GetPolicyBasedRoute', $request, $callOptions)->wait(); + } + + /** + * Lists PolicyBasedRoutes in a given project and location. + * + * The async variant is + * {@see PolicyBasedRoutingServiceClient::listPolicyBasedRoutesAsync()} . + * + * @param ListPolicyBasedRoutesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPolicyBasedRoutes(ListPolicyBasedRoutesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPolicyBasedRoutes', $request, $callOptions); + } + + /** + * Gets information about a location. + * + * The async variant is {@see PolicyBasedRoutingServiceClient::getLocationAsync()} + * . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is + * {@see PolicyBasedRoutingServiceClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see PolicyBasedRoutingServiceClient::getIamPolicyAsync()} + * . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see PolicyBasedRoutingServiceClient::setIamPolicyAsync()} + * . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is + * {@see PolicyBasedRoutingServiceClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/NetworkManagement/composer.json b/NetworkManagement/composer.json index 6872a5af550e..33b64de03743 100644 --- a/NetworkManagement/composer.json +++ b/NetworkManagement/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/NetworkManagement/src/V1/Client/BaseClient/ReachabilityServiceBaseClient.php b/NetworkManagement/src/V1/Client/BaseClient/ReachabilityServiceBaseClient.php deleted file mode 100644 index ab477a1d47d2..000000000000 --- a/NetworkManagement/src/V1/Client/BaseClient/ReachabilityServiceBaseClient.php +++ /dev/null @@ -1,445 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/reachability_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/reachability_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/reachability_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/reachability_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * connectivity_test resource. - * - * @param string $project - * @param string $test - * - * @return string The formatted connectivity_test resource. - */ - public static function connectivityTestName(string $project, string $test): string - { - return self::getPathTemplate('connectivityTest')->render([ - 'project' => $project, - 'test' => $test, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - connectivityTest: projects/{project}/locations/global/connectivityTests/{test} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'networkmanagement.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new Connectivity Test. - * After you create a test, the reachability analysis is performed as part - * of the long running operation, which completes when the analysis completes. - * - * If the endpoint specifications in `ConnectivityTest` are invalid - * (for example, containing non-existent resources in the network, or you - * don't have read permissions to the network configurations of listed - * projects), then the reachability result returns a value of `UNKNOWN`. - * - * If the endpoint specifications in `ConnectivityTest` are - * incomplete, the reachability result returns a value of - * AMBIGUOUS. For more information, - * see the Connectivity Test documentation. - * - * The async variant is {@see self::createConnectivityTestAsync()} . - * - * @param CreateConnectivityTestRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createConnectivityTest(CreateConnectivityTestRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateConnectivityTest', $request, $callOptions)->wait(); - } - - /** - * Deletes a specific `ConnectivityTest`. - * - * The async variant is {@see self::deleteConnectivityTestAsync()} . - * - * @param DeleteConnectivityTestRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteConnectivityTest(DeleteConnectivityTestRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteConnectivityTest', $request, $callOptions)->wait(); - } - - /** - * Gets the details of a specific Connectivity Test. - * - * The async variant is {@see self::getConnectivityTestAsync()} . - * - * @param GetConnectivityTestRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ConnectivityTest - * - * @throws ApiException Thrown if the API call fails. - */ - public function getConnectivityTest(GetConnectivityTestRequest $request, array $callOptions = []): ConnectivityTest - { - return $this->startApiCall('GetConnectivityTest', $request, $callOptions)->wait(); - } - - /** - * Lists all Connectivity Tests owned by a project. - * - * The async variant is {@see self::listConnectivityTestsAsync()} . - * - * @param ListConnectivityTestsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listConnectivityTests(ListConnectivityTestsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListConnectivityTests', $request, $callOptions); - } - - /** - * Rerun an existing `ConnectivityTest`. - * After the user triggers the rerun, the reachability analysis is performed - * as part of the long running operation, which completes when the analysis - * completes. - * - * Even though the test configuration remains the same, the reachability - * result may change due to underlying network configuration changes. - * - * If the endpoint specifications in `ConnectivityTest` become invalid (for - * example, specified resources are deleted in the network, or you lost - * read permissions to the network configurations of listed projects), then - * the reachability result returns a value of `UNKNOWN`. - * - * The async variant is {@see self::rerunConnectivityTestAsync()} . - * - * @param RerunConnectivityTestRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function rerunConnectivityTest(RerunConnectivityTestRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RerunConnectivityTest', $request, $callOptions)->wait(); - } - - /** - * Updates the configuration of an existing `ConnectivityTest`. - * After you update a test, the reachability analysis is performed as part - * of the long running operation, which completes when the analysis completes. - * The Reachability state in the test resource is updated with the new result. - * - * If the endpoint specifications in `ConnectivityTest` are invalid - * (for example, they contain non-existent resources in the network, or the - * user does not have read permissions to the network configurations of - * listed projects), then the reachability result returns a value of - * UNKNOWN. - * - * If the endpoint specifications in `ConnectivityTest` are incomplete, the - * reachability result returns a value of `AMBIGUOUS`. See the documentation - * in `ConnectivityTest` for for more details. - * - * The async variant is {@see self::updateConnectivityTestAsync()} . - * - * @param UpdateConnectivityTestRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateConnectivityTest(UpdateConnectivityTestRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateConnectivityTest', $request, $callOptions)->wait(); - } -} diff --git a/NetworkManagement/src/V1/Client/ReachabilityServiceClient.php b/NetworkManagement/src/V1/Client/ReachabilityServiceClient.php index 1c7e44b6c1b1..4dc073b9963b 100644 --- a/NetworkManagement/src/V1/Client/ReachabilityServiceClient.php +++ b/NetworkManagement/src/V1/Client/ReachabilityServiceClient.php @@ -24,17 +24,426 @@ namespace Google\Cloud\NetworkManagement\V1\Client; -use Google\Cloud\NetworkManagement\V1\Client\BaseClient\ReachabilityServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\NetworkManagement\V1\ConnectivityTest; +use Google\Cloud\NetworkManagement\V1\CreateConnectivityTestRequest; +use Google\Cloud\NetworkManagement\V1\DeleteConnectivityTestRequest; +use Google\Cloud\NetworkManagement\V1\GetConnectivityTestRequest; +use Google\Cloud\NetworkManagement\V1\ListConnectivityTestsRequest; +use Google\Cloud\NetworkManagement\V1\RerunConnectivityTestRequest; +use Google\Cloud\NetworkManagement\V1\UpdateConnectivityTestRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Reachability service in the Google Cloud Network Management API provides + * services that analyze the reachability within a single Google Virtual Private + * Cloud (VPC) network, between peered VPC networks, between VPC and on-premises + * networks, or between VPC networks and internet hosts. A reachability analysis + * is based on Google Cloud network configurations. * - * This class is currently experimental and may be subject to changes. + * You can use the analysis results to verify these configurations and + * to troubleshoot connectivity issues. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\NetworkManagement\V1\ReachabilityServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createConnectivityTestAsync(CreateConnectivityTestRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteConnectivityTestAsync(DeleteConnectivityTestRequest $request, array $optionalArgs = []) + * @method PromiseInterface getConnectivityTestAsync(GetConnectivityTestRequest $request, array $optionalArgs = []) + * @method PromiseInterface listConnectivityTestsAsync(ListConnectivityTestsRequest $request, array $optionalArgs = []) + * @method PromiseInterface rerunConnectivityTestAsync(RerunConnectivityTestRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateConnectivityTestAsync(UpdateConnectivityTestRequest $request, array $optionalArgs = []) */ -final class ReachabilityServiceClient extends ReachabilityServiceBaseClient +final class ReachabilityServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ReachabilityServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.networkmanagement.v1.ReachabilityService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'networkmanagement.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/reachability_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/reachability_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/reachability_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/reachability_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * connectivity_test resource. + * + * @param string $project + * @param string $test + * + * @return string The formatted connectivity_test resource. + */ + public static function connectivityTestName(string $project, string $test): string + { + return self::getPathTemplate('connectivityTest')->render([ + 'project' => $project, + 'test' => $test, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - connectivityTest: projects/{project}/locations/global/connectivityTests/{test} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'networkmanagement.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new Connectivity Test. + * After you create a test, the reachability analysis is performed as part + * of the long running operation, which completes when the analysis completes. + * + * If the endpoint specifications in `ConnectivityTest` are invalid + * (for example, containing non-existent resources in the network, or you + * don't have read permissions to the network configurations of listed + * projects), then the reachability result returns a value of `UNKNOWN`. + * + * If the endpoint specifications in `ConnectivityTest` are + * incomplete, the reachability result returns a value of + * AMBIGUOUS. For more information, + * see the Connectivity Test documentation. + * + * The async variant is + * {@see ReachabilityServiceClient::createConnectivityTestAsync()} . + * + * @param CreateConnectivityTestRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createConnectivityTest(CreateConnectivityTestRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateConnectivityTest', $request, $callOptions)->wait(); + } + + /** + * Deletes a specific `ConnectivityTest`. + * + * The async variant is + * {@see ReachabilityServiceClient::deleteConnectivityTestAsync()} . + * + * @param DeleteConnectivityTestRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteConnectivityTest(DeleteConnectivityTestRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteConnectivityTest', $request, $callOptions)->wait(); + } + + /** + * Gets the details of a specific Connectivity Test. + * + * The async variant is + * {@see ReachabilityServiceClient::getConnectivityTestAsync()} . + * + * @param GetConnectivityTestRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ConnectivityTest + * + * @throws ApiException Thrown if the API call fails. + */ + public function getConnectivityTest(GetConnectivityTestRequest $request, array $callOptions = []): ConnectivityTest + { + return $this->startApiCall('GetConnectivityTest', $request, $callOptions)->wait(); + } + + /** + * Lists all Connectivity Tests owned by a project. + * + * The async variant is + * {@see ReachabilityServiceClient::listConnectivityTestsAsync()} . + * + * @param ListConnectivityTestsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listConnectivityTests(ListConnectivityTestsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListConnectivityTests', $request, $callOptions); + } + + /** + * Rerun an existing `ConnectivityTest`. + * After the user triggers the rerun, the reachability analysis is performed + * as part of the long running operation, which completes when the analysis + * completes. + * + * Even though the test configuration remains the same, the reachability + * result may change due to underlying network configuration changes. + * + * If the endpoint specifications in `ConnectivityTest` become invalid (for + * example, specified resources are deleted in the network, or you lost + * read permissions to the network configurations of listed projects), then + * the reachability result returns a value of `UNKNOWN`. + * + * The async variant is + * {@see ReachabilityServiceClient::rerunConnectivityTestAsync()} . + * + * @param RerunConnectivityTestRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function rerunConnectivityTest(RerunConnectivityTestRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RerunConnectivityTest', $request, $callOptions)->wait(); + } + + /** + * Updates the configuration of an existing `ConnectivityTest`. + * After you update a test, the reachability analysis is performed as part + * of the long running operation, which completes when the analysis completes. + * The Reachability state in the test resource is updated with the new result. + * + * If the endpoint specifications in `ConnectivityTest` are invalid + * (for example, they contain non-existent resources in the network, or the + * user does not have read permissions to the network configurations of + * listed projects), then the reachability result returns a value of + * UNKNOWN. + * + * If the endpoint specifications in `ConnectivityTest` are incomplete, the + * reachability result returns a value of `AMBIGUOUS`. See the documentation + * in `ConnectivityTest` for for more details. + * + * The async variant is + * {@see ReachabilityServiceClient::updateConnectivityTestAsync()} . + * + * @param UpdateConnectivityTestRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateConnectivityTest(UpdateConnectivityTestRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateConnectivityTest', $request, $callOptions)->wait(); + } } diff --git a/NetworkSecurity/composer.json b/NetworkSecurity/composer.json index e60169904b76..9807cf47dcfc 100644 --- a/NetworkSecurity/composer.json +++ b/NetworkSecurity/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/NetworkSecurity/src/V1/Client/BaseClient/NetworkSecurityBaseClient.php b/NetworkSecurity/src/V1/Client/BaseClient/NetworkSecurityBaseClient.php deleted file mode 100644 index 1c204197653d..000000000000 --- a/NetworkSecurity/src/V1/Client/BaseClient/NetworkSecurityBaseClient.php +++ /dev/null @@ -1,882 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/network_security_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/network_security_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/network_security_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/network_security_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * authorization_policy resource. - * - * @param string $project - * @param string $location - * @param string $authorizationPolicy - * - * @return string The formatted authorization_policy resource. - */ - public static function authorizationPolicyName(string $project, string $location, string $authorizationPolicy): string - { - return self::getPathTemplate('authorizationPolicy')->render([ - 'project' => $project, - 'location' => $location, - 'authorization_policy' => $authorizationPolicy, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * client_tls_policy resource. - * - * @param string $project - * @param string $location - * @param string $clientTlsPolicy - * - * @return string The formatted client_tls_policy resource. - */ - public static function clientTlsPolicyName(string $project, string $location, string $clientTlsPolicy): string - { - return self::getPathTemplate('clientTlsPolicy')->render([ - 'project' => $project, - 'location' => $location, - 'client_tls_policy' => $clientTlsPolicy, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * server_tls_policy resource. - * - * @param string $project - * @param string $location - * @param string $serverTlsPolicy - * - * @return string The formatted server_tls_policy resource. - */ - public static function serverTlsPolicyName(string $project, string $location, string $serverTlsPolicy): string - { - return self::getPathTemplate('serverTlsPolicy')->render([ - 'project' => $project, - 'location' => $location, - 'server_tls_policy' => $serverTlsPolicy, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - authorizationPolicy: projects/{project}/locations/{location}/authorizationPolicies/{authorization_policy} - * - clientTlsPolicy: projects/{project}/locations/{location}/clientTlsPolicies/{client_tls_policy} - * - location: projects/{project}/locations/{location} - * - serverTlsPolicy: projects/{project}/locations/{location}/serverTlsPolicies/{server_tls_policy} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'networksecurity.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new AuthorizationPolicy in a given project and location. - * - * The async variant is {@see self::createAuthorizationPolicyAsync()} . - * - * @example samples/V1/NetworkSecurityClient/create_authorization_policy.php - * - * @param CreateAuthorizationPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAuthorizationPolicy(CreateAuthorizationPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateAuthorizationPolicy', $request, $callOptions)->wait(); - } - - /** - * Creates a new ClientTlsPolicy in a given project and location. - * - * The async variant is {@see self::createClientTlsPolicyAsync()} . - * - * @example samples/V1/NetworkSecurityClient/create_client_tls_policy.php - * - * @param CreateClientTlsPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createClientTlsPolicy(CreateClientTlsPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateClientTlsPolicy', $request, $callOptions)->wait(); - } - - /** - * Creates a new ServerTlsPolicy in a given project and location. - * - * The async variant is {@see self::createServerTlsPolicyAsync()} . - * - * @example samples/V1/NetworkSecurityClient/create_server_tls_policy.php - * - * @param CreateServerTlsPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createServerTlsPolicy(CreateServerTlsPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateServerTlsPolicy', $request, $callOptions)->wait(); - } - - /** - * Deletes a single AuthorizationPolicy. - * - * The async variant is {@see self::deleteAuthorizationPolicyAsync()} . - * - * @example samples/V1/NetworkSecurityClient/delete_authorization_policy.php - * - * @param DeleteAuthorizationPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAuthorizationPolicy(DeleteAuthorizationPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteAuthorizationPolicy', $request, $callOptions)->wait(); - } - - /** - * Deletes a single ClientTlsPolicy. - * - * The async variant is {@see self::deleteClientTlsPolicyAsync()} . - * - * @example samples/V1/NetworkSecurityClient/delete_client_tls_policy.php - * - * @param DeleteClientTlsPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteClientTlsPolicy(DeleteClientTlsPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteClientTlsPolicy', $request, $callOptions)->wait(); - } - - /** - * Deletes a single ServerTlsPolicy. - * - * The async variant is {@see self::deleteServerTlsPolicyAsync()} . - * - * @example samples/V1/NetworkSecurityClient/delete_server_tls_policy.php - * - * @param DeleteServerTlsPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteServerTlsPolicy(DeleteServerTlsPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteServerTlsPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single AuthorizationPolicy. - * - * The async variant is {@see self::getAuthorizationPolicyAsync()} . - * - * @example samples/V1/NetworkSecurityClient/get_authorization_policy.php - * - * @param GetAuthorizationPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AuthorizationPolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAuthorizationPolicy(GetAuthorizationPolicyRequest $request, array $callOptions = []): AuthorizationPolicy - { - return $this->startApiCall('GetAuthorizationPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single ClientTlsPolicy. - * - * The async variant is {@see self::getClientTlsPolicyAsync()} . - * - * @example samples/V1/NetworkSecurityClient/get_client_tls_policy.php - * - * @param GetClientTlsPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ClientTlsPolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getClientTlsPolicy(GetClientTlsPolicyRequest $request, array $callOptions = []): ClientTlsPolicy - { - return $this->startApiCall('GetClientTlsPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single ServerTlsPolicy. - * - * The async variant is {@see self::getServerTlsPolicyAsync()} . - * - * @example samples/V1/NetworkSecurityClient/get_server_tls_policy.php - * - * @param GetServerTlsPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ServerTlsPolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getServerTlsPolicy(GetServerTlsPolicyRequest $request, array $callOptions = []): ServerTlsPolicy - { - return $this->startApiCall('GetServerTlsPolicy', $request, $callOptions)->wait(); - } - - /** - * Lists AuthorizationPolicies in a given project and location. - * - * The async variant is {@see self::listAuthorizationPoliciesAsync()} . - * - * @example samples/V1/NetworkSecurityClient/list_authorization_policies.php - * - * @param ListAuthorizationPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAuthorizationPolicies(ListAuthorizationPoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAuthorizationPolicies', $request, $callOptions); - } - - /** - * Lists ClientTlsPolicies in a given project and location. - * - * The async variant is {@see self::listClientTlsPoliciesAsync()} . - * - * @example samples/V1/NetworkSecurityClient/list_client_tls_policies.php - * - * @param ListClientTlsPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listClientTlsPolicies(ListClientTlsPoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListClientTlsPolicies', $request, $callOptions); - } - - /** - * Lists ServerTlsPolicies in a given project and location. - * - * The async variant is {@see self::listServerTlsPoliciesAsync()} . - * - * @example samples/V1/NetworkSecurityClient/list_server_tls_policies.php - * - * @param ListServerTlsPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listServerTlsPolicies(ListServerTlsPoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListServerTlsPolicies', $request, $callOptions); - } - - /** - * Updates the parameters of a single AuthorizationPolicy. - * - * The async variant is {@see self::updateAuthorizationPolicyAsync()} . - * - * @example samples/V1/NetworkSecurityClient/update_authorization_policy.php - * - * @param UpdateAuthorizationPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAuthorizationPolicy(UpdateAuthorizationPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateAuthorizationPolicy', $request, $callOptions)->wait(); - } - - /** - * Updates the parameters of a single ClientTlsPolicy. - * - * The async variant is {@see self::updateClientTlsPolicyAsync()} . - * - * @example samples/V1/NetworkSecurityClient/update_client_tls_policy.php - * - * @param UpdateClientTlsPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateClientTlsPolicy(UpdateClientTlsPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateClientTlsPolicy', $request, $callOptions)->wait(); - } - - /** - * Updates the parameters of a single ServerTlsPolicy. - * - * The async variant is {@see self::updateServerTlsPolicyAsync()} . - * - * @example samples/V1/NetworkSecurityClient/update_server_tls_policy.php - * - * @param UpdateServerTlsPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateServerTlsPolicy(UpdateServerTlsPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateServerTlsPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/NetworkSecurityClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/NetworkSecurityClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/NetworkSecurityClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/NetworkSecurityClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/NetworkSecurityClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/NetworkSecurity/src/V1/Client/NetworkSecurityClient.php b/NetworkSecurity/src/V1/Client/NetworkSecurityClient.php index f24fcd567be6..31675eddac7d 100644 --- a/NetworkSecurity/src/V1/Client/NetworkSecurityClient.php +++ b/NetworkSecurity/src/V1/Client/NetworkSecurityClient.php @@ -24,17 +24,870 @@ namespace Google\Cloud\NetworkSecurity\V1\Client; -use Google\Cloud\NetworkSecurity\V1\Client\BaseClient\NetworkSecurityBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\NetworkSecurity\V1\AuthorizationPolicy; +use Google\Cloud\NetworkSecurity\V1\ClientTlsPolicy; +use Google\Cloud\NetworkSecurity\V1\CreateAuthorizationPolicyRequest; +use Google\Cloud\NetworkSecurity\V1\CreateClientTlsPolicyRequest; +use Google\Cloud\NetworkSecurity\V1\CreateServerTlsPolicyRequest; +use Google\Cloud\NetworkSecurity\V1\DeleteAuthorizationPolicyRequest; +use Google\Cloud\NetworkSecurity\V1\DeleteClientTlsPolicyRequest; +use Google\Cloud\NetworkSecurity\V1\DeleteServerTlsPolicyRequest; +use Google\Cloud\NetworkSecurity\V1\GetAuthorizationPolicyRequest; +use Google\Cloud\NetworkSecurity\V1\GetClientTlsPolicyRequest; +use Google\Cloud\NetworkSecurity\V1\GetServerTlsPolicyRequest; +use Google\Cloud\NetworkSecurity\V1\ListAuthorizationPoliciesRequest; +use Google\Cloud\NetworkSecurity\V1\ListClientTlsPoliciesRequest; +use Google\Cloud\NetworkSecurity\V1\ListServerTlsPoliciesRequest; +use Google\Cloud\NetworkSecurity\V1\ServerTlsPolicy; +use Google\Cloud\NetworkSecurity\V1\UpdateAuthorizationPolicyRequest; +use Google\Cloud\NetworkSecurity\V1\UpdateClientTlsPolicyRequest; +use Google\Cloud\NetworkSecurity\V1\UpdateServerTlsPolicyRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Network Security API provides resources to configure authentication and + * authorization policies. Refer to per API resource documentation for more + * information. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createAuthorizationPolicyAsync(CreateAuthorizationPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface createClientTlsPolicyAsync(CreateClientTlsPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface createServerTlsPolicyAsync(CreateServerTlsPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAuthorizationPolicyAsync(DeleteAuthorizationPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteClientTlsPolicyAsync(DeleteClientTlsPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteServerTlsPolicyAsync(DeleteServerTlsPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAuthorizationPolicyAsync(GetAuthorizationPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getClientTlsPolicyAsync(GetClientTlsPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getServerTlsPolicyAsync(GetServerTlsPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAuthorizationPoliciesAsync(ListAuthorizationPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listClientTlsPoliciesAsync(ListClientTlsPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listServerTlsPoliciesAsync(ListServerTlsPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAuthorizationPolicyAsync(UpdateAuthorizationPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateClientTlsPolicyAsync(UpdateClientTlsPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateServerTlsPolicyAsync(UpdateServerTlsPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class NetworkSecurityClient extends NetworkSecurityBaseClient +final class NetworkSecurityClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see NetworkSecurityBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.networksecurity.v1.NetworkSecurity'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'networksecurity.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/network_security_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/network_security_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/network_security_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/network_security_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * authorization_policy resource. + * + * @param string $project + * @param string $location + * @param string $authorizationPolicy + * + * @return string The formatted authorization_policy resource. + */ + public static function authorizationPolicyName(string $project, string $location, string $authorizationPolicy): string + { + return self::getPathTemplate('authorizationPolicy')->render([ + 'project' => $project, + 'location' => $location, + 'authorization_policy' => $authorizationPolicy, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * client_tls_policy resource. + * + * @param string $project + * @param string $location + * @param string $clientTlsPolicy + * + * @return string The formatted client_tls_policy resource. + */ + public static function clientTlsPolicyName(string $project, string $location, string $clientTlsPolicy): string + { + return self::getPathTemplate('clientTlsPolicy')->render([ + 'project' => $project, + 'location' => $location, + 'client_tls_policy' => $clientTlsPolicy, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * server_tls_policy resource. + * + * @param string $project + * @param string $location + * @param string $serverTlsPolicy + * + * @return string The formatted server_tls_policy resource. + */ + public static function serverTlsPolicyName(string $project, string $location, string $serverTlsPolicy): string + { + return self::getPathTemplate('serverTlsPolicy')->render([ + 'project' => $project, + 'location' => $location, + 'server_tls_policy' => $serverTlsPolicy, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - authorizationPolicy: projects/{project}/locations/{location}/authorizationPolicies/{authorization_policy} + * - clientTlsPolicy: projects/{project}/locations/{location}/clientTlsPolicies/{client_tls_policy} + * - location: projects/{project}/locations/{location} + * - serverTlsPolicy: projects/{project}/locations/{location}/serverTlsPolicies/{server_tls_policy} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'networksecurity.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new AuthorizationPolicy in a given project and location. + * + * The async variant is + * {@see NetworkSecurityClient::createAuthorizationPolicyAsync()} . + * + * @example samples/V1/NetworkSecurityClient/create_authorization_policy.php + * + * @param CreateAuthorizationPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAuthorizationPolicy(CreateAuthorizationPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateAuthorizationPolicy', $request, $callOptions)->wait(); + } + + /** + * Creates a new ClientTlsPolicy in a given project and location. + * + * The async variant is {@see NetworkSecurityClient::createClientTlsPolicyAsync()} + * . + * + * @example samples/V1/NetworkSecurityClient/create_client_tls_policy.php + * + * @param CreateClientTlsPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createClientTlsPolicy(CreateClientTlsPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateClientTlsPolicy', $request, $callOptions)->wait(); + } + + /** + * Creates a new ServerTlsPolicy in a given project and location. + * + * The async variant is {@see NetworkSecurityClient::createServerTlsPolicyAsync()} + * . + * + * @example samples/V1/NetworkSecurityClient/create_server_tls_policy.php + * + * @param CreateServerTlsPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createServerTlsPolicy(CreateServerTlsPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateServerTlsPolicy', $request, $callOptions)->wait(); + } + + /** + * Deletes a single AuthorizationPolicy. + * + * The async variant is + * {@see NetworkSecurityClient::deleteAuthorizationPolicyAsync()} . + * + * @example samples/V1/NetworkSecurityClient/delete_authorization_policy.php + * + * @param DeleteAuthorizationPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAuthorizationPolicy(DeleteAuthorizationPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteAuthorizationPolicy', $request, $callOptions)->wait(); + } + + /** + * Deletes a single ClientTlsPolicy. + * + * The async variant is {@see NetworkSecurityClient::deleteClientTlsPolicyAsync()} + * . + * + * @example samples/V1/NetworkSecurityClient/delete_client_tls_policy.php + * + * @param DeleteClientTlsPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteClientTlsPolicy(DeleteClientTlsPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteClientTlsPolicy', $request, $callOptions)->wait(); + } + + /** + * Deletes a single ServerTlsPolicy. + * + * The async variant is {@see NetworkSecurityClient::deleteServerTlsPolicyAsync()} + * . + * + * @example samples/V1/NetworkSecurityClient/delete_server_tls_policy.php + * + * @param DeleteServerTlsPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteServerTlsPolicy(DeleteServerTlsPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteServerTlsPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single AuthorizationPolicy. + * + * The async variant is {@see NetworkSecurityClient::getAuthorizationPolicyAsync()} + * . + * + * @example samples/V1/NetworkSecurityClient/get_authorization_policy.php + * + * @param GetAuthorizationPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AuthorizationPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAuthorizationPolicy(GetAuthorizationPolicyRequest $request, array $callOptions = []): AuthorizationPolicy + { + return $this->startApiCall('GetAuthorizationPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single ClientTlsPolicy. + * + * The async variant is {@see NetworkSecurityClient::getClientTlsPolicyAsync()} . + * + * @example samples/V1/NetworkSecurityClient/get_client_tls_policy.php + * + * @param GetClientTlsPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ClientTlsPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getClientTlsPolicy(GetClientTlsPolicyRequest $request, array $callOptions = []): ClientTlsPolicy + { + return $this->startApiCall('GetClientTlsPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single ServerTlsPolicy. + * + * The async variant is {@see NetworkSecurityClient::getServerTlsPolicyAsync()} . + * + * @example samples/V1/NetworkSecurityClient/get_server_tls_policy.php + * + * @param GetServerTlsPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ServerTlsPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getServerTlsPolicy(GetServerTlsPolicyRequest $request, array $callOptions = []): ServerTlsPolicy + { + return $this->startApiCall('GetServerTlsPolicy', $request, $callOptions)->wait(); + } + + /** + * Lists AuthorizationPolicies in a given project and location. + * + * The async variant is + * {@see NetworkSecurityClient::listAuthorizationPoliciesAsync()} . + * + * @example samples/V1/NetworkSecurityClient/list_authorization_policies.php + * + * @param ListAuthorizationPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAuthorizationPolicies(ListAuthorizationPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAuthorizationPolicies', $request, $callOptions); + } + + /** + * Lists ClientTlsPolicies in a given project and location. + * + * The async variant is {@see NetworkSecurityClient::listClientTlsPoliciesAsync()} + * . + * + * @example samples/V1/NetworkSecurityClient/list_client_tls_policies.php + * + * @param ListClientTlsPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listClientTlsPolicies(ListClientTlsPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListClientTlsPolicies', $request, $callOptions); + } + + /** + * Lists ServerTlsPolicies in a given project and location. + * + * The async variant is {@see NetworkSecurityClient::listServerTlsPoliciesAsync()} + * . + * + * @example samples/V1/NetworkSecurityClient/list_server_tls_policies.php + * + * @param ListServerTlsPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listServerTlsPolicies(ListServerTlsPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListServerTlsPolicies', $request, $callOptions); + } + + /** + * Updates the parameters of a single AuthorizationPolicy. + * + * The async variant is + * {@see NetworkSecurityClient::updateAuthorizationPolicyAsync()} . + * + * @example samples/V1/NetworkSecurityClient/update_authorization_policy.php + * + * @param UpdateAuthorizationPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAuthorizationPolicy(UpdateAuthorizationPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateAuthorizationPolicy', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single ClientTlsPolicy. + * + * The async variant is {@see NetworkSecurityClient::updateClientTlsPolicyAsync()} + * . + * + * @example samples/V1/NetworkSecurityClient/update_client_tls_policy.php + * + * @param UpdateClientTlsPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateClientTlsPolicy(UpdateClientTlsPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateClientTlsPolicy', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single ServerTlsPolicy. + * + * The async variant is {@see NetworkSecurityClient::updateServerTlsPolicyAsync()} + * . + * + * @example samples/V1/NetworkSecurityClient/update_server_tls_policy.php + * + * @param UpdateServerTlsPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateServerTlsPolicy(UpdateServerTlsPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateServerTlsPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see NetworkSecurityClient::getLocationAsync()} . + * + * @example samples/V1/NetworkSecurityClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see NetworkSecurityClient::listLocationsAsync()} . + * + * @example samples/V1/NetworkSecurityClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see NetworkSecurityClient::getIamPolicyAsync()} . + * + * @example samples/V1/NetworkSecurityClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see NetworkSecurityClient::setIamPolicyAsync()} . + * + * @example samples/V1/NetworkSecurityClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see NetworkSecurityClient::testIamPermissionsAsync()} . + * + * @example samples/V1/NetworkSecurityClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Notebooks/composer.json b/Notebooks/composer.json index f4c965cff814..5a02157df912 100644 --- a/Notebooks/composer.json +++ b/Notebooks/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Notebooks/src/V1/Client/BaseClient/ManagedNotebookServiceBaseClient.php b/Notebooks/src/V1/Client/BaseClient/ManagedNotebookServiceBaseClient.php deleted file mode 100644 index 523918b62eef..000000000000 --- a/Notebooks/src/V1/Client/BaseClient/ManagedNotebookServiceBaseClient.php +++ /dev/null @@ -1,793 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/managed_notebook_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/managed_notebook_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/managed_notebook_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/managed_notebook_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a runtime - * resource. - * - * @param string $project - * @param string $location - * @param string $runtime - * - * @return string The formatted runtime resource. - */ - public static function runtimeName(string $project, string $location, string $runtime): string - { - return self::getPathTemplate('runtime')->render([ - 'project' => $project, - 'location' => $location, - 'runtime' => $runtime, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - location: projects/{project}/locations/{location} - * - runtime: projects/{project}/locations/{location}/runtimes/{runtime} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'notebooks.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new Runtime in a given project and location. - * - * The async variant is {@see self::createRuntimeAsync()} . - * - * @example samples/V1/ManagedNotebookServiceClient/create_runtime.php - * - * @param CreateRuntimeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createRuntime(CreateRuntimeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateRuntime', $request, $callOptions)->wait(); - } - - /** - * Deletes a single Runtime. - * - * The async variant is {@see self::deleteRuntimeAsync()} . - * - * @example samples/V1/ManagedNotebookServiceClient/delete_runtime.php - * - * @param DeleteRuntimeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteRuntime(DeleteRuntimeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteRuntime', $request, $callOptions)->wait(); - } - - /** - * Creates a Diagnostic File and runs Diagnostic Tool given a Runtime. - * - * The async variant is {@see self::diagnoseRuntimeAsync()} . - * - * @example samples/V1/ManagedNotebookServiceClient/diagnose_runtime.php - * - * @param DiagnoseRuntimeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function diagnoseRuntime(DiagnoseRuntimeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DiagnoseRuntime', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single Runtime. The location must be a regional endpoint - * rather than zonal. - * - * The async variant is {@see self::getRuntimeAsync()} . - * - * @example samples/V1/ManagedNotebookServiceClient/get_runtime.php - * - * @param GetRuntimeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Runtime - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRuntime(GetRuntimeRequest $request, array $callOptions = []): Runtime - { - return $this->startApiCall('GetRuntime', $request, $callOptions)->wait(); - } - - /** - * Lists Runtimes in a given project and location. - * - * The async variant is {@see self::listRuntimesAsync()} . - * - * @example samples/V1/ManagedNotebookServiceClient/list_runtimes.php - * - * @param ListRuntimesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listRuntimes(ListRuntimesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListRuntimes', $request, $callOptions); - } - - /** - * Gets an access token for the consumer service account that the customer - * attached to the runtime. Only accessible from the tenant instance. - * - * The async variant is {@see self::refreshRuntimeTokenInternalAsync()} . - * - * @example samples/V1/ManagedNotebookServiceClient/refresh_runtime_token_internal.php - * - * @param RefreshRuntimeTokenInternalRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RefreshRuntimeTokenInternalResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function refreshRuntimeTokenInternal(RefreshRuntimeTokenInternalRequest $request, array $callOptions = []): RefreshRuntimeTokenInternalResponse - { - return $this->startApiCall('RefreshRuntimeTokenInternal', $request, $callOptions)->wait(); - } - - /** - * Report and process a runtime event. - * - * The async variant is {@see self::reportRuntimeEventAsync()} . - * - * @example samples/V1/ManagedNotebookServiceClient/report_runtime_event.php - * - * @param ReportRuntimeEventRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function reportRuntimeEvent(ReportRuntimeEventRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ReportRuntimeEvent', $request, $callOptions)->wait(); - } - - /** - * Resets a Managed Notebook Runtime. - * - * The async variant is {@see self::resetRuntimeAsync()} . - * - * @example samples/V1/ManagedNotebookServiceClient/reset_runtime.php - * - * @param ResetRuntimeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function resetRuntime(ResetRuntimeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ResetRuntime', $request, $callOptions)->wait(); - } - - /** - * Starts a Managed Notebook Runtime. - * Perform "Start" on GPU instances; "Resume" on CPU instances - * See: - * https://cloud.google.com/compute/docs/instances/stop-start-instance - * https://cloud.google.com/compute/docs/instances/suspend-resume-instance - * - * The async variant is {@see self::startRuntimeAsync()} . - * - * @example samples/V1/ManagedNotebookServiceClient/start_runtime.php - * - * @param StartRuntimeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function startRuntime(StartRuntimeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StartRuntime', $request, $callOptions)->wait(); - } - - /** - * Stops a Managed Notebook Runtime. - * Perform "Stop" on GPU instances; "Suspend" on CPU instances - * See: - * https://cloud.google.com/compute/docs/instances/stop-start-instance - * https://cloud.google.com/compute/docs/instances/suspend-resume-instance - * - * The async variant is {@see self::stopRuntimeAsync()} . - * - * @example samples/V1/ManagedNotebookServiceClient/stop_runtime.php - * - * @param StopRuntimeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function stopRuntime(StopRuntimeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StopRuntime', $request, $callOptions)->wait(); - } - - /** - * Switch a Managed Notebook Runtime. - * - * The async variant is {@see self::switchRuntimeAsync()} . - * - * @example samples/V1/ManagedNotebookServiceClient/switch_runtime.php - * - * @param SwitchRuntimeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function switchRuntime(SwitchRuntimeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SwitchRuntime', $request, $callOptions)->wait(); - } - - /** - * Update Notebook Runtime configuration. - * - * The async variant is {@see self::updateRuntimeAsync()} . - * - * @example samples/V1/ManagedNotebookServiceClient/update_runtime.php - * - * @param UpdateRuntimeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateRuntime(UpdateRuntimeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateRuntime', $request, $callOptions)->wait(); - } - - /** - * Upgrades a Managed Notebook Runtime to the latest version. - * - * The async variant is {@see self::upgradeRuntimeAsync()} . - * - * @example samples/V1/ManagedNotebookServiceClient/upgrade_runtime.php - * - * @param UpgradeRuntimeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function upgradeRuntime(UpgradeRuntimeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpgradeRuntime', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/ManagedNotebookServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/ManagedNotebookServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/ManagedNotebookServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/ManagedNotebookServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/ManagedNotebookServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Notebooks/src/V1/Client/BaseClient/NotebookServiceBaseClient.php b/Notebooks/src/V1/Client/BaseClient/NotebookServiceBaseClient.php deleted file mode 100644 index 6632a2498ee0..000000000000 --- a/Notebooks/src/V1/Client/BaseClient/NotebookServiceBaseClient.php +++ /dev/null @@ -1,1441 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/notebook_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/notebook_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/notebook_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/notebook_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a environment - * resource. - * - * @param string $project - * @param string $environment - * - * @return string The formatted environment resource. - */ - public static function environmentName(string $project, string $environment): string - { - return self::getPathTemplate('environment')->render([ - 'project' => $project, - 'environment' => $environment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a execution - * resource. - * - * @param string $project - * @param string $location - * @param string $execution - * - * @return string The formatted execution resource. - */ - public static function executionName(string $project, string $location, string $execution): string - { - return self::getPathTemplate('execution')->render([ - 'project' => $project, - 'location' => $location, - 'execution' => $execution, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a instance - * resource. - * - * @param string $project - * @param string $instance - * - * @return string The formatted instance resource. - */ - public static function instanceName(string $project, string $instance): string - { - return self::getPathTemplate('instance')->render([ - 'project' => $project, - 'instance' => $instance, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a schedule - * resource. - * - * @param string $project - * @param string $location - * @param string $schedule - * - * @return string The formatted schedule resource. - */ - public static function scheduleName(string $project, string $location, string $schedule): string - { - return self::getPathTemplate('schedule')->render([ - 'project' => $project, - 'location' => $location, - 'schedule' => $schedule, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a tensorboard - * resource. - * - * @param string $project - * @param string $location - * @param string $tensorboard - * - * @return string The formatted tensorboard resource. - */ - public static function tensorboardName(string $project, string $location, string $tensorboard): string - { - return self::getPathTemplate('tensorboard')->render([ - 'project' => $project, - 'location' => $location, - 'tensorboard' => $tensorboard, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - environment: projects/{project}/environments/{environment} - * - execution: projects/{project}/location/{location}/executions/{execution} - * - instance: projects/{project}/instances/{instance} - * - schedule: projects/{project}/location/{location}/schedules/{schedule} - * - tensorboard: projects/{project}/locations/{location}/tensorboards/{tensorboard} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'notebooks.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new Environment. - * - * The async variant is {@see self::createEnvironmentAsync()} . - * - * @example samples/V1/NotebookServiceClient/create_environment.php - * - * @param CreateEnvironmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createEnvironment(CreateEnvironmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateEnvironment', $request, $callOptions)->wait(); - } - - /** - * Creates a new Execution in a given project and location. - * - * The async variant is {@see self::createExecutionAsync()} . - * - * @example samples/V1/NotebookServiceClient/create_execution.php - * - * @param CreateExecutionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createExecution(CreateExecutionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateExecution', $request, $callOptions)->wait(); - } - - /** - * Creates a new Instance in a given project and location. - * - * The async variant is {@see self::createInstanceAsync()} . - * - * @example samples/V1/NotebookServiceClient/create_instance.php - * - * @param CreateInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createInstance(CreateInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateInstance', $request, $callOptions)->wait(); - } - - /** - * Creates a new Scheduled Notebook in a given project and location. - * - * The async variant is {@see self::createScheduleAsync()} . - * - * @example samples/V1/NotebookServiceClient/create_schedule.php - * - * @param CreateScheduleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSchedule(CreateScheduleRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateSchedule', $request, $callOptions)->wait(); - } - - /** - * Deletes a single Environment. - * - * The async variant is {@see self::deleteEnvironmentAsync()} . - * - * @example samples/V1/NotebookServiceClient/delete_environment.php - * - * @param DeleteEnvironmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteEnvironment(DeleteEnvironmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteEnvironment', $request, $callOptions)->wait(); - } - - /** - * Deletes execution - * - * The async variant is {@see self::deleteExecutionAsync()} . - * - * @example samples/V1/NotebookServiceClient/delete_execution.php - * - * @param DeleteExecutionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteExecution(DeleteExecutionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteExecution', $request, $callOptions)->wait(); - } - - /** - * Deletes a single Instance. - * - * The async variant is {@see self::deleteInstanceAsync()} . - * - * @example samples/V1/NotebookServiceClient/delete_instance.php - * - * @param DeleteInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); - } - - /** - * Deletes schedule and all underlying jobs - * - * The async variant is {@see self::deleteScheduleAsync()} . - * - * @example samples/V1/NotebookServiceClient/delete_schedule.php - * - * @param DeleteScheduleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSchedule(DeleteScheduleRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteSchedule', $request, $callOptions)->wait(); - } - - /** - * Creates a Diagnostic File and runs Diagnostic Tool given an Instance. - * - * The async variant is {@see self::diagnoseInstanceAsync()} . - * - * @example samples/V1/NotebookServiceClient/diagnose_instance.php - * - * @param DiagnoseInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function diagnoseInstance(DiagnoseInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DiagnoseInstance', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single Environment. - * - * The async variant is {@see self::getEnvironmentAsync()} . - * - * @example samples/V1/NotebookServiceClient/get_environment.php - * - * @param GetEnvironmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Environment - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEnvironment(GetEnvironmentRequest $request, array $callOptions = []): Environment - { - return $this->startApiCall('GetEnvironment', $request, $callOptions)->wait(); - } - - /** - * Gets details of executions - * - * The async variant is {@see self::getExecutionAsync()} . - * - * @example samples/V1/NotebookServiceClient/get_execution.php - * - * @param GetExecutionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Execution - * - * @throws ApiException Thrown if the API call fails. - */ - public function getExecution(GetExecutionRequest $request, array $callOptions = []): Execution - { - return $this->startApiCall('GetExecution', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single Instance. - * - * The async variant is {@see self::getInstanceAsync()} . - * - * @example samples/V1/NotebookServiceClient/get_instance.php - * - * @param GetInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Instance - * - * @throws ApiException Thrown if the API call fails. - */ - public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance - { - return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); - } - - /** - * Check if a notebook instance is healthy. - * - * The async variant is {@see self::getInstanceHealthAsync()} . - * - * @example samples/V1/NotebookServiceClient/get_instance_health.php - * - * @param GetInstanceHealthRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GetInstanceHealthResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function getInstanceHealth(GetInstanceHealthRequest $request, array $callOptions = []): GetInstanceHealthResponse - { - return $this->startApiCall('GetInstanceHealth', $request, $callOptions)->wait(); - } - - /** - * Gets details of schedule - * - * The async variant is {@see self::getScheduleAsync()} . - * - * @example samples/V1/NotebookServiceClient/get_schedule.php - * - * @param GetScheduleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Schedule - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSchedule(GetScheduleRequest $request, array $callOptions = []): Schedule - { - return $this->startApiCall('GetSchedule', $request, $callOptions)->wait(); - } - - /** - * Check if a notebook instance is upgradable. - * - * The async variant is {@see self::isInstanceUpgradeableAsync()} . - * - * @example samples/V1/NotebookServiceClient/is_instance_upgradeable.php - * - * @param IsInstanceUpgradeableRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 IsInstanceUpgradeableResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function isInstanceUpgradeable(IsInstanceUpgradeableRequest $request, array $callOptions = []): IsInstanceUpgradeableResponse - { - return $this->startApiCall('IsInstanceUpgradeable', $request, $callOptions)->wait(); - } - - /** - * Lists environments in a project. - * - * The async variant is {@see self::listEnvironmentsAsync()} . - * - * @example samples/V1/NotebookServiceClient/list_environments.php - * - * @param ListEnvironmentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listEnvironments(ListEnvironmentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListEnvironments', $request, $callOptions); - } - - /** - * Lists executions in a given project and location - * - * The async variant is {@see self::listExecutionsAsync()} . - * - * @example samples/V1/NotebookServiceClient/list_executions.php - * - * @param ListExecutionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listExecutions(ListExecutionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListExecutions', $request, $callOptions); - } - - /** - * Lists instances in a given project and location. - * - * The async variant is {@see self::listInstancesAsync()} . - * - * @example samples/V1/NotebookServiceClient/list_instances.php - * - * @param ListInstancesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listInstances(ListInstancesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListInstances', $request, $callOptions); - } - - /** - * Lists schedules in a given project and location. - * - * The async variant is {@see self::listSchedulesAsync()} . - * - * @example samples/V1/NotebookServiceClient/list_schedules.php - * - * @param ListSchedulesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSchedules(ListSchedulesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSchedules', $request, $callOptions); - } - - /** - * Registers an existing legacy notebook instance to the Notebooks API server. - * Legacy instances are instances created with the legacy Compute Engine - * calls. They are not manageable by the Notebooks API out of the box. This - * call makes these instances manageable by the Notebooks API. - * - * The async variant is {@see self::registerInstanceAsync()} . - * - * @example samples/V1/NotebookServiceClient/register_instance.php - * - * @param RegisterInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function registerInstance(RegisterInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RegisterInstance', $request, $callOptions)->wait(); - } - - /** - * Allows notebook instances to - * report their latest instance information to the Notebooks - * API server. The server will merge the reported information to - * the instance metadata store. Do not use this method directly. - * - * The async variant is {@see self::reportInstanceInfoAsync()} . - * - * @example samples/V1/NotebookServiceClient/report_instance_info.php - * - * @param ReportInstanceInfoRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function reportInstanceInfo(ReportInstanceInfoRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ReportInstanceInfo', $request, $callOptions)->wait(); - } - - /** - * Resets a notebook instance. - * - * The async variant is {@see self::resetInstanceAsync()} . - * - * @example samples/V1/NotebookServiceClient/reset_instance.php - * - * @param ResetInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function resetInstance(ResetInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ResetInstance', $request, $callOptions)->wait(); - } - - /** - * Rollbacks a notebook instance to the previous version. - * - * The async variant is {@see self::rollbackInstanceAsync()} . - * - * @example samples/V1/NotebookServiceClient/rollback_instance.php - * - * @param RollbackInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function rollbackInstance(RollbackInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RollbackInstance', $request, $callOptions)->wait(); - } - - /** - * Updates the guest accelerators of a single Instance. - * - * The async variant is {@see self::setInstanceAcceleratorAsync()} . - * - * @example samples/V1/NotebookServiceClient/set_instance_accelerator.php - * - * @param SetInstanceAcceleratorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setInstanceAccelerator(SetInstanceAcceleratorRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetInstanceAccelerator', $request, $callOptions)->wait(); - } - - /** - * Replaces all the labels of an Instance. - * - * The async variant is {@see self::setInstanceLabelsAsync()} . - * - * @example samples/V1/NotebookServiceClient/set_instance_labels.php - * - * @param SetInstanceLabelsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setInstanceLabels(SetInstanceLabelsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetInstanceLabels', $request, $callOptions)->wait(); - } - - /** - * Updates the machine type of a single Instance. - * - * The async variant is {@see self::setInstanceMachineTypeAsync()} . - * - * @example samples/V1/NotebookServiceClient/set_instance_machine_type.php - * - * @param SetInstanceMachineTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setInstanceMachineType(SetInstanceMachineTypeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetInstanceMachineType', $request, $callOptions)->wait(); - } - - /** - * Starts a notebook instance. - * - * The async variant is {@see self::startInstanceAsync()} . - * - * @example samples/V1/NotebookServiceClient/start_instance.php - * - * @param StartInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function startInstance(StartInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StartInstance', $request, $callOptions)->wait(); - } - - /** - * Stops a notebook instance. - * - * The async variant is {@see self::stopInstanceAsync()} . - * - * @example samples/V1/NotebookServiceClient/stop_instance.php - * - * @param StopInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function stopInstance(StopInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StopInstance', $request, $callOptions)->wait(); - } - - /** - * Triggers execution of an existing schedule. - * - * The async variant is {@see self::triggerScheduleAsync()} . - * - * @example samples/V1/NotebookServiceClient/trigger_schedule.php - * - * @param TriggerScheduleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function triggerSchedule(TriggerScheduleRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('TriggerSchedule', $request, $callOptions)->wait(); - } - - /** - * Update Notebook Instance configurations. - * - * The async variant is {@see self::updateInstanceConfigAsync()} . - * - * @example samples/V1/NotebookServiceClient/update_instance_config.php - * - * @param UpdateInstanceConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateInstanceConfig(UpdateInstanceConfigRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateInstanceConfig', $request, $callOptions)->wait(); - } - - /** - * Add/update metadata items for an instance. - * - * The async variant is {@see self::updateInstanceMetadataItemsAsync()} . - * - * @example samples/V1/NotebookServiceClient/update_instance_metadata_items.php - * - * @param UpdateInstanceMetadataItemsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 UpdateInstanceMetadataItemsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateInstanceMetadataItems(UpdateInstanceMetadataItemsRequest $request, array $callOptions = []): UpdateInstanceMetadataItemsResponse - { - return $this->startApiCall('UpdateInstanceMetadataItems', $request, $callOptions)->wait(); - } - - /** - * Updates the Shielded instance configuration of a single Instance. - * - * The async variant is {@see self::updateShieldedInstanceConfigAsync()} . - * - * @example samples/V1/NotebookServiceClient/update_shielded_instance_config.php - * - * @param UpdateShieldedInstanceConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateShieldedInstanceConfig(UpdateShieldedInstanceConfigRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateShieldedInstanceConfig', $request, $callOptions)->wait(); - } - - /** - * Upgrades a notebook instance to the latest version. - * - * The async variant is {@see self::upgradeInstanceAsync()} . - * - * @example samples/V1/NotebookServiceClient/upgrade_instance.php - * - * @param UpgradeInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function upgradeInstance(UpgradeInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpgradeInstance', $request, $callOptions)->wait(); - } - - /** - * Allows notebook instances to - * call this endpoint to upgrade themselves. Do not use this method directly. - * - * The async variant is {@see self::upgradeInstanceInternalAsync()} . - * - * @example samples/V1/NotebookServiceClient/upgrade_instance_internal.php - * - * @param UpgradeInstanceInternalRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function upgradeInstanceInternal(UpgradeInstanceInternalRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpgradeInstanceInternal', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/NotebookServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/NotebookServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/NotebookServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/NotebookServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/NotebookServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/Notebooks/src/V1/Client/ManagedNotebookServiceClient.php b/Notebooks/src/V1/Client/ManagedNotebookServiceClient.php index e2cad09dca5c..50654bc9f6f9 100644 --- a/Notebooks/src/V1/Client/ManagedNotebookServiceClient.php +++ b/Notebooks/src/V1/Client/ManagedNotebookServiceClient.php @@ -24,17 +24,773 @@ namespace Google\Cloud\Notebooks\V1\Client; -use Google\Cloud\Notebooks\V1\Client\BaseClient\ManagedNotebookServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\Notebooks\V1\CreateRuntimeRequest; +use Google\Cloud\Notebooks\V1\DeleteRuntimeRequest; +use Google\Cloud\Notebooks\V1\DiagnoseRuntimeRequest; +use Google\Cloud\Notebooks\V1\GetRuntimeRequest; +use Google\Cloud\Notebooks\V1\ListRuntimesRequest; +use Google\Cloud\Notebooks\V1\RefreshRuntimeTokenInternalRequest; +use Google\Cloud\Notebooks\V1\RefreshRuntimeTokenInternalResponse; +use Google\Cloud\Notebooks\V1\ReportRuntimeEventRequest; +use Google\Cloud\Notebooks\V1\ResetRuntimeRequest; +use Google\Cloud\Notebooks\V1\Runtime; +use Google\Cloud\Notebooks\V1\StartRuntimeRequest; +use Google\Cloud\Notebooks\V1\StopRuntimeRequest; +use Google\Cloud\Notebooks\V1\SwitchRuntimeRequest; +use Google\Cloud\Notebooks\V1\UpdateRuntimeRequest; +use Google\Cloud\Notebooks\V1\UpgradeRuntimeRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: API v1 service for Managed Notebooks. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createRuntimeAsync(CreateRuntimeRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteRuntimeAsync(DeleteRuntimeRequest $request, array $optionalArgs = []) + * @method PromiseInterface diagnoseRuntimeAsync(DiagnoseRuntimeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRuntimeAsync(GetRuntimeRequest $request, array $optionalArgs = []) + * @method PromiseInterface listRuntimesAsync(ListRuntimesRequest $request, array $optionalArgs = []) + * @method PromiseInterface refreshRuntimeTokenInternalAsync(RefreshRuntimeTokenInternalRequest $request, array $optionalArgs = []) + * @method PromiseInterface reportRuntimeEventAsync(ReportRuntimeEventRequest $request, array $optionalArgs = []) + * @method PromiseInterface resetRuntimeAsync(ResetRuntimeRequest $request, array $optionalArgs = []) + * @method PromiseInterface startRuntimeAsync(StartRuntimeRequest $request, array $optionalArgs = []) + * @method PromiseInterface stopRuntimeAsync(StopRuntimeRequest $request, array $optionalArgs = []) + * @method PromiseInterface switchRuntimeAsync(SwitchRuntimeRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateRuntimeAsync(UpdateRuntimeRequest $request, array $optionalArgs = []) + * @method PromiseInterface upgradeRuntimeAsync(UpgradeRuntimeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class ManagedNotebookServiceClient extends ManagedNotebookServiceBaseClient +final class ManagedNotebookServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ManagedNotebookServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.notebooks.v1.ManagedNotebookService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'notebooks.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/managed_notebook_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/managed_notebook_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/managed_notebook_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/managed_notebook_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a runtime + * resource. + * + * @param string $project + * @param string $location + * @param string $runtime + * + * @return string The formatted runtime resource. + */ + public static function runtimeName(string $project, string $location, string $runtime): string + { + return self::getPathTemplate('runtime')->render([ + 'project' => $project, + 'location' => $location, + 'runtime' => $runtime, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - location: projects/{project}/locations/{location} + * - runtime: projects/{project}/locations/{location}/runtimes/{runtime} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'notebooks.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new Runtime in a given project and location. + * + * The async variant is {@see ManagedNotebookServiceClient::createRuntimeAsync()} . + * + * @example samples/V1/ManagedNotebookServiceClient/create_runtime.php + * + * @param CreateRuntimeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createRuntime(CreateRuntimeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateRuntime', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Runtime. + * + * The async variant is {@see ManagedNotebookServiceClient::deleteRuntimeAsync()} . + * + * @example samples/V1/ManagedNotebookServiceClient/delete_runtime.php + * + * @param DeleteRuntimeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteRuntime(DeleteRuntimeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteRuntime', $request, $callOptions)->wait(); + } + + /** + * Creates a Diagnostic File and runs Diagnostic Tool given a Runtime. + * + * The async variant is {@see ManagedNotebookServiceClient::diagnoseRuntimeAsync()} + * . + * + * @example samples/V1/ManagedNotebookServiceClient/diagnose_runtime.php + * + * @param DiagnoseRuntimeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function diagnoseRuntime(DiagnoseRuntimeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DiagnoseRuntime', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Runtime. The location must be a regional endpoint + * rather than zonal. + * + * The async variant is {@see ManagedNotebookServiceClient::getRuntimeAsync()} . + * + * @example samples/V1/ManagedNotebookServiceClient/get_runtime.php + * + * @param GetRuntimeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Runtime + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRuntime(GetRuntimeRequest $request, array $callOptions = []): Runtime + { + return $this->startApiCall('GetRuntime', $request, $callOptions)->wait(); + } + + /** + * Lists Runtimes in a given project and location. + * + * The async variant is {@see ManagedNotebookServiceClient::listRuntimesAsync()} . + * + * @example samples/V1/ManagedNotebookServiceClient/list_runtimes.php + * + * @param ListRuntimesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listRuntimes(ListRuntimesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListRuntimes', $request, $callOptions); + } + + /** + * Gets an access token for the consumer service account that the customer + * attached to the runtime. Only accessible from the tenant instance. + * + * The async variant is + * {@see ManagedNotebookServiceClient::refreshRuntimeTokenInternalAsync()} . + * + * @example samples/V1/ManagedNotebookServiceClient/refresh_runtime_token_internal.php + * + * @param RefreshRuntimeTokenInternalRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RefreshRuntimeTokenInternalResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function refreshRuntimeTokenInternal(RefreshRuntimeTokenInternalRequest $request, array $callOptions = []): RefreshRuntimeTokenInternalResponse + { + return $this->startApiCall('RefreshRuntimeTokenInternal', $request, $callOptions)->wait(); + } + + /** + * Report and process a runtime event. + * + * The async variant is + * {@see ManagedNotebookServiceClient::reportRuntimeEventAsync()} . + * + * @example samples/V1/ManagedNotebookServiceClient/report_runtime_event.php + * + * @param ReportRuntimeEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function reportRuntimeEvent(ReportRuntimeEventRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ReportRuntimeEvent', $request, $callOptions)->wait(); + } + + /** + * Resets a Managed Notebook Runtime. + * + * The async variant is {@see ManagedNotebookServiceClient::resetRuntimeAsync()} . + * + * @example samples/V1/ManagedNotebookServiceClient/reset_runtime.php + * + * @param ResetRuntimeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function resetRuntime(ResetRuntimeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ResetRuntime', $request, $callOptions)->wait(); + } + + /** + * Starts a Managed Notebook Runtime. + * Perform "Start" on GPU instances; "Resume" on CPU instances + * See: + * https://cloud.google.com/compute/docs/instances/stop-start-instance + * https://cloud.google.com/compute/docs/instances/suspend-resume-instance + * + * The async variant is {@see ManagedNotebookServiceClient::startRuntimeAsync()} . + * + * @example samples/V1/ManagedNotebookServiceClient/start_runtime.php + * + * @param StartRuntimeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function startRuntime(StartRuntimeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StartRuntime', $request, $callOptions)->wait(); + } + + /** + * Stops a Managed Notebook Runtime. + * Perform "Stop" on GPU instances; "Suspend" on CPU instances + * See: + * https://cloud.google.com/compute/docs/instances/stop-start-instance + * https://cloud.google.com/compute/docs/instances/suspend-resume-instance + * + * The async variant is {@see ManagedNotebookServiceClient::stopRuntimeAsync()} . + * + * @example samples/V1/ManagedNotebookServiceClient/stop_runtime.php + * + * @param StopRuntimeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function stopRuntime(StopRuntimeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StopRuntime', $request, $callOptions)->wait(); + } + + /** + * Switch a Managed Notebook Runtime. + * + * The async variant is {@see ManagedNotebookServiceClient::switchRuntimeAsync()} . + * + * @example samples/V1/ManagedNotebookServiceClient/switch_runtime.php + * + * @param SwitchRuntimeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function switchRuntime(SwitchRuntimeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SwitchRuntime', $request, $callOptions)->wait(); + } + + /** + * Update Notebook Runtime configuration. + * + * The async variant is {@see ManagedNotebookServiceClient::updateRuntimeAsync()} . + * + * @example samples/V1/ManagedNotebookServiceClient/update_runtime.php + * + * @param UpdateRuntimeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateRuntime(UpdateRuntimeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateRuntime', $request, $callOptions)->wait(); + } + + /** + * Upgrades a Managed Notebook Runtime to the latest version. + * + * The async variant is {@see ManagedNotebookServiceClient::upgradeRuntimeAsync()} + * . + * + * @example samples/V1/ManagedNotebookServiceClient/upgrade_runtime.php + * + * @param UpgradeRuntimeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function upgradeRuntime(UpgradeRuntimeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpgradeRuntime', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see ManagedNotebookServiceClient::getLocationAsync()} . + * + * @example samples/V1/ManagedNotebookServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see ManagedNotebookServiceClient::listLocationsAsync()} . + * + * @example samples/V1/ManagedNotebookServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see ManagedNotebookServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/ManagedNotebookServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see ManagedNotebookServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/ManagedNotebookServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is + * {@see ManagedNotebookServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/ManagedNotebookServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Notebooks/src/V1/Client/NotebookServiceClient.php b/Notebooks/src/V1/Client/NotebookServiceClient.php index 20126a22cabb..3776cbd0f842 100644 --- a/Notebooks/src/V1/Client/NotebookServiceClient.php +++ b/Notebooks/src/V1/Client/NotebookServiceClient.php @@ -24,17 +24,1422 @@ namespace Google\Cloud\Notebooks\V1\Client; -use Google\Cloud\Notebooks\V1\Client\BaseClient\NotebookServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\Notebooks\V1\CreateEnvironmentRequest; +use Google\Cloud\Notebooks\V1\CreateExecutionRequest; +use Google\Cloud\Notebooks\V1\CreateInstanceRequest; +use Google\Cloud\Notebooks\V1\CreateScheduleRequest; +use Google\Cloud\Notebooks\V1\DeleteEnvironmentRequest; +use Google\Cloud\Notebooks\V1\DeleteExecutionRequest; +use Google\Cloud\Notebooks\V1\DeleteInstanceRequest; +use Google\Cloud\Notebooks\V1\DeleteScheduleRequest; +use Google\Cloud\Notebooks\V1\DiagnoseInstanceRequest; +use Google\Cloud\Notebooks\V1\Environment; +use Google\Cloud\Notebooks\V1\Execution; +use Google\Cloud\Notebooks\V1\GetEnvironmentRequest; +use Google\Cloud\Notebooks\V1\GetExecutionRequest; +use Google\Cloud\Notebooks\V1\GetInstanceHealthRequest; +use Google\Cloud\Notebooks\V1\GetInstanceHealthResponse; +use Google\Cloud\Notebooks\V1\GetInstanceRequest; +use Google\Cloud\Notebooks\V1\GetScheduleRequest; +use Google\Cloud\Notebooks\V1\Instance; +use Google\Cloud\Notebooks\V1\IsInstanceUpgradeableRequest; +use Google\Cloud\Notebooks\V1\IsInstanceUpgradeableResponse; +use Google\Cloud\Notebooks\V1\ListEnvironmentsRequest; +use Google\Cloud\Notebooks\V1\ListExecutionsRequest; +use Google\Cloud\Notebooks\V1\ListInstancesRequest; +use Google\Cloud\Notebooks\V1\ListSchedulesRequest; +use Google\Cloud\Notebooks\V1\RegisterInstanceRequest; +use Google\Cloud\Notebooks\V1\ReportInstanceInfoRequest; +use Google\Cloud\Notebooks\V1\ResetInstanceRequest; +use Google\Cloud\Notebooks\V1\RollbackInstanceRequest; +use Google\Cloud\Notebooks\V1\Schedule; +use Google\Cloud\Notebooks\V1\SetInstanceAcceleratorRequest; +use Google\Cloud\Notebooks\V1\SetInstanceLabelsRequest; +use Google\Cloud\Notebooks\V1\SetInstanceMachineTypeRequest; +use Google\Cloud\Notebooks\V1\StartInstanceRequest; +use Google\Cloud\Notebooks\V1\StopInstanceRequest; +use Google\Cloud\Notebooks\V1\TriggerScheduleRequest; +use Google\Cloud\Notebooks\V1\UpdateInstanceConfigRequest; +use Google\Cloud\Notebooks\V1\UpdateInstanceMetadataItemsRequest; +use Google\Cloud\Notebooks\V1\UpdateInstanceMetadataItemsResponse; +use Google\Cloud\Notebooks\V1\UpdateShieldedInstanceConfigRequest; +use Google\Cloud\Notebooks\V1\UpgradeInstanceInternalRequest; +use Google\Cloud\Notebooks\V1\UpgradeInstanceRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: API v1 service for Cloud AI Platform Notebooks. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createEnvironmentAsync(CreateEnvironmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface createExecutionAsync(CreateExecutionRequest $request, array $optionalArgs = []) + * @method PromiseInterface createInstanceAsync(CreateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface createScheduleAsync(CreateScheduleRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteEnvironmentAsync(DeleteEnvironmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteExecutionAsync(DeleteExecutionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteInstanceAsync(DeleteInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteScheduleAsync(DeleteScheduleRequest $request, array $optionalArgs = []) + * @method PromiseInterface diagnoseInstanceAsync(DiagnoseInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEnvironmentAsync(GetEnvironmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getExecutionAsync(GetExecutionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInstanceAsync(GetInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInstanceHealthAsync(GetInstanceHealthRequest $request, array $optionalArgs = []) + * @method PromiseInterface getScheduleAsync(GetScheduleRequest $request, array $optionalArgs = []) + * @method PromiseInterface isInstanceUpgradeableAsync(IsInstanceUpgradeableRequest $request, array $optionalArgs = []) + * @method PromiseInterface listEnvironmentsAsync(ListEnvironmentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listExecutionsAsync(ListExecutionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInstancesAsync(ListInstancesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSchedulesAsync(ListSchedulesRequest $request, array $optionalArgs = []) + * @method PromiseInterface registerInstanceAsync(RegisterInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface reportInstanceInfoAsync(ReportInstanceInfoRequest $request, array $optionalArgs = []) + * @method PromiseInterface resetInstanceAsync(ResetInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface rollbackInstanceAsync(RollbackInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface setInstanceAcceleratorAsync(SetInstanceAcceleratorRequest $request, array $optionalArgs = []) + * @method PromiseInterface setInstanceLabelsAsync(SetInstanceLabelsRequest $request, array $optionalArgs = []) + * @method PromiseInterface setInstanceMachineTypeAsync(SetInstanceMachineTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface startInstanceAsync(StartInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface stopInstanceAsync(StopInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface triggerScheduleAsync(TriggerScheduleRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateInstanceConfigAsync(UpdateInstanceConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateInstanceMetadataItemsAsync(UpdateInstanceMetadataItemsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateShieldedInstanceConfigAsync(UpdateShieldedInstanceConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface upgradeInstanceAsync(UpgradeInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface upgradeInstanceInternalAsync(UpgradeInstanceInternalRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class NotebookServiceClient extends NotebookServiceBaseClient +final class NotebookServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see NotebookServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.notebooks.v1.NotebookService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'notebooks.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/notebook_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/notebook_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/notebook_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/notebook_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a environment + * resource. + * + * @param string $project + * @param string $environment + * + * @return string The formatted environment resource. + */ + public static function environmentName(string $project, string $environment): string + { + return self::getPathTemplate('environment')->render([ + 'project' => $project, + 'environment' => $environment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a execution + * resource. + * + * @param string $project + * @param string $location + * @param string $execution + * + * @return string The formatted execution resource. + */ + public static function executionName(string $project, string $location, string $execution): string + { + return self::getPathTemplate('execution')->render([ + 'project' => $project, + 'location' => $location, + 'execution' => $execution, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a instance + * resource. + * + * @param string $project + * @param string $instance + * + * @return string The formatted instance resource. + */ + public static function instanceName(string $project, string $instance): string + { + return self::getPathTemplate('instance')->render([ + 'project' => $project, + 'instance' => $instance, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a schedule + * resource. + * + * @param string $project + * @param string $location + * @param string $schedule + * + * @return string The formatted schedule resource. + */ + public static function scheduleName(string $project, string $location, string $schedule): string + { + return self::getPathTemplate('schedule')->render([ + 'project' => $project, + 'location' => $location, + 'schedule' => $schedule, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a tensorboard + * resource. + * + * @param string $project + * @param string $location + * @param string $tensorboard + * + * @return string The formatted tensorboard resource. + */ + public static function tensorboardName(string $project, string $location, string $tensorboard): string + { + return self::getPathTemplate('tensorboard')->render([ + 'project' => $project, + 'location' => $location, + 'tensorboard' => $tensorboard, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - environment: projects/{project}/environments/{environment} + * - execution: projects/{project}/location/{location}/executions/{execution} + * - instance: projects/{project}/instances/{instance} + * - schedule: projects/{project}/location/{location}/schedules/{schedule} + * - tensorboard: projects/{project}/locations/{location}/tensorboards/{tensorboard} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'notebooks.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new Environment. + * + * The async variant is {@see NotebookServiceClient::createEnvironmentAsync()} . + * + * @example samples/V1/NotebookServiceClient/create_environment.php + * + * @param CreateEnvironmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createEnvironment(CreateEnvironmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateEnvironment', $request, $callOptions)->wait(); + } + + /** + * Creates a new Execution in a given project and location. + * + * The async variant is {@see NotebookServiceClient::createExecutionAsync()} . + * + * @example samples/V1/NotebookServiceClient/create_execution.php + * + * @param CreateExecutionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createExecution(CreateExecutionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateExecution', $request, $callOptions)->wait(); + } + + /** + * Creates a new Instance in a given project and location. + * + * The async variant is {@see NotebookServiceClient::createInstanceAsync()} . + * + * @example samples/V1/NotebookServiceClient/create_instance.php + * + * @param CreateInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createInstance(CreateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateInstance', $request, $callOptions)->wait(); + } + + /** + * Creates a new Scheduled Notebook in a given project and location. + * + * The async variant is {@see NotebookServiceClient::createScheduleAsync()} . + * + * @example samples/V1/NotebookServiceClient/create_schedule.php + * + * @param CreateScheduleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSchedule(CreateScheduleRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateSchedule', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Environment. + * + * The async variant is {@see NotebookServiceClient::deleteEnvironmentAsync()} . + * + * @example samples/V1/NotebookServiceClient/delete_environment.php + * + * @param DeleteEnvironmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteEnvironment(DeleteEnvironmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteEnvironment', $request, $callOptions)->wait(); + } + + /** + * Deletes execution + * + * The async variant is {@see NotebookServiceClient::deleteExecutionAsync()} . + * + * @example samples/V1/NotebookServiceClient/delete_execution.php + * + * @param DeleteExecutionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteExecution(DeleteExecutionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteExecution', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Instance. + * + * The async variant is {@see NotebookServiceClient::deleteInstanceAsync()} . + * + * @example samples/V1/NotebookServiceClient/delete_instance.php + * + * @param DeleteInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); + } + + /** + * Deletes schedule and all underlying jobs + * + * The async variant is {@see NotebookServiceClient::deleteScheduleAsync()} . + * + * @example samples/V1/NotebookServiceClient/delete_schedule.php + * + * @param DeleteScheduleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSchedule(DeleteScheduleRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteSchedule', $request, $callOptions)->wait(); + } + + /** + * Creates a Diagnostic File and runs Diagnostic Tool given an Instance. + * + * The async variant is {@see NotebookServiceClient::diagnoseInstanceAsync()} . + * + * @example samples/V1/NotebookServiceClient/diagnose_instance.php + * + * @param DiagnoseInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function diagnoseInstance(DiagnoseInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DiagnoseInstance', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Environment. + * + * The async variant is {@see NotebookServiceClient::getEnvironmentAsync()} . + * + * @example samples/V1/NotebookServiceClient/get_environment.php + * + * @param GetEnvironmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Environment + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEnvironment(GetEnvironmentRequest $request, array $callOptions = []): Environment + { + return $this->startApiCall('GetEnvironment', $request, $callOptions)->wait(); + } + + /** + * Gets details of executions + * + * The async variant is {@see NotebookServiceClient::getExecutionAsync()} . + * + * @example samples/V1/NotebookServiceClient/get_execution.php + * + * @param GetExecutionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Execution + * + * @throws ApiException Thrown if the API call fails. + */ + public function getExecution(GetExecutionRequest $request, array $callOptions = []): Execution + { + return $this->startApiCall('GetExecution', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Instance. + * + * The async variant is {@see NotebookServiceClient::getInstanceAsync()} . + * + * @example samples/V1/NotebookServiceClient/get_instance.php + * + * @param GetInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Instance + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance + { + return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); + } + + /** + * Check if a notebook instance is healthy. + * + * The async variant is {@see NotebookServiceClient::getInstanceHealthAsync()} . + * + * @example samples/V1/NotebookServiceClient/get_instance_health.php + * + * @param GetInstanceHealthRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GetInstanceHealthResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInstanceHealth(GetInstanceHealthRequest $request, array $callOptions = []): GetInstanceHealthResponse + { + return $this->startApiCall('GetInstanceHealth', $request, $callOptions)->wait(); + } + + /** + * Gets details of schedule + * + * The async variant is {@see NotebookServiceClient::getScheduleAsync()} . + * + * @example samples/V1/NotebookServiceClient/get_schedule.php + * + * @param GetScheduleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Schedule + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSchedule(GetScheduleRequest $request, array $callOptions = []): Schedule + { + return $this->startApiCall('GetSchedule', $request, $callOptions)->wait(); + } + + /** + * Check if a notebook instance is upgradable. + * + * The async variant is {@see NotebookServiceClient::isInstanceUpgradeableAsync()} + * . + * + * @example samples/V1/NotebookServiceClient/is_instance_upgradeable.php + * + * @param IsInstanceUpgradeableRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 IsInstanceUpgradeableResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function isInstanceUpgradeable(IsInstanceUpgradeableRequest $request, array $callOptions = []): IsInstanceUpgradeableResponse + { + return $this->startApiCall('IsInstanceUpgradeable', $request, $callOptions)->wait(); + } + + /** + * Lists environments in a project. + * + * The async variant is {@see NotebookServiceClient::listEnvironmentsAsync()} . + * + * @example samples/V1/NotebookServiceClient/list_environments.php + * + * @param ListEnvironmentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listEnvironments(ListEnvironmentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEnvironments', $request, $callOptions); + } + + /** + * Lists executions in a given project and location + * + * The async variant is {@see NotebookServiceClient::listExecutionsAsync()} . + * + * @example samples/V1/NotebookServiceClient/list_executions.php + * + * @param ListExecutionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listExecutions(ListExecutionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListExecutions', $request, $callOptions); + } + + /** + * Lists instances in a given project and location. + * + * The async variant is {@see NotebookServiceClient::listInstancesAsync()} . + * + * @example samples/V1/NotebookServiceClient/list_instances.php + * + * @param ListInstancesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInstances(ListInstancesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInstances', $request, $callOptions); + } + + /** + * Lists schedules in a given project and location. + * + * The async variant is {@see NotebookServiceClient::listSchedulesAsync()} . + * + * @example samples/V1/NotebookServiceClient/list_schedules.php + * + * @param ListSchedulesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSchedules(ListSchedulesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSchedules', $request, $callOptions); + } + + /** + * Registers an existing legacy notebook instance to the Notebooks API server. + * Legacy instances are instances created with the legacy Compute Engine + * calls. They are not manageable by the Notebooks API out of the box. This + * call makes these instances manageable by the Notebooks API. + * + * The async variant is {@see NotebookServiceClient::registerInstanceAsync()} . + * + * @example samples/V1/NotebookServiceClient/register_instance.php + * + * @param RegisterInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function registerInstance(RegisterInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RegisterInstance', $request, $callOptions)->wait(); + } + + /** + * Allows notebook instances to + * report their latest instance information to the Notebooks + * API server. The server will merge the reported information to + * the instance metadata store. Do not use this method directly. + * + * The async variant is {@see NotebookServiceClient::reportInstanceInfoAsync()} . + * + * @example samples/V1/NotebookServiceClient/report_instance_info.php + * + * @param ReportInstanceInfoRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function reportInstanceInfo(ReportInstanceInfoRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ReportInstanceInfo', $request, $callOptions)->wait(); + } + + /** + * Resets a notebook instance. + * + * The async variant is {@see NotebookServiceClient::resetInstanceAsync()} . + * + * @example samples/V1/NotebookServiceClient/reset_instance.php + * + * @param ResetInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function resetInstance(ResetInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ResetInstance', $request, $callOptions)->wait(); + } + + /** + * Rollbacks a notebook instance to the previous version. + * + * The async variant is {@see NotebookServiceClient::rollbackInstanceAsync()} . + * + * @example samples/V1/NotebookServiceClient/rollback_instance.php + * + * @param RollbackInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function rollbackInstance(RollbackInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RollbackInstance', $request, $callOptions)->wait(); + } + + /** + * Updates the guest accelerators of a single Instance. + * + * The async variant is {@see NotebookServiceClient::setInstanceAcceleratorAsync()} + * . + * + * @example samples/V1/NotebookServiceClient/set_instance_accelerator.php + * + * @param SetInstanceAcceleratorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setInstanceAccelerator(SetInstanceAcceleratorRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetInstanceAccelerator', $request, $callOptions)->wait(); + } + + /** + * Replaces all the labels of an Instance. + * + * The async variant is {@see NotebookServiceClient::setInstanceLabelsAsync()} . + * + * @example samples/V1/NotebookServiceClient/set_instance_labels.php + * + * @param SetInstanceLabelsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setInstanceLabels(SetInstanceLabelsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetInstanceLabels', $request, $callOptions)->wait(); + } + + /** + * Updates the machine type of a single Instance. + * + * The async variant is {@see NotebookServiceClient::setInstanceMachineTypeAsync()} + * . + * + * @example samples/V1/NotebookServiceClient/set_instance_machine_type.php + * + * @param SetInstanceMachineTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setInstanceMachineType(SetInstanceMachineTypeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetInstanceMachineType', $request, $callOptions)->wait(); + } + + /** + * Starts a notebook instance. + * + * The async variant is {@see NotebookServiceClient::startInstanceAsync()} . + * + * @example samples/V1/NotebookServiceClient/start_instance.php + * + * @param StartInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function startInstance(StartInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StartInstance', $request, $callOptions)->wait(); + } + + /** + * Stops a notebook instance. + * + * The async variant is {@see NotebookServiceClient::stopInstanceAsync()} . + * + * @example samples/V1/NotebookServiceClient/stop_instance.php + * + * @param StopInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function stopInstance(StopInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StopInstance', $request, $callOptions)->wait(); + } + + /** + * Triggers execution of an existing schedule. + * + * The async variant is {@see NotebookServiceClient::triggerScheduleAsync()} . + * + * @example samples/V1/NotebookServiceClient/trigger_schedule.php + * + * @param TriggerScheduleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function triggerSchedule(TriggerScheduleRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('TriggerSchedule', $request, $callOptions)->wait(); + } + + /** + * Update Notebook Instance configurations. + * + * The async variant is {@see NotebookServiceClient::updateInstanceConfigAsync()} . + * + * @example samples/V1/NotebookServiceClient/update_instance_config.php + * + * @param UpdateInstanceConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateInstanceConfig(UpdateInstanceConfigRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateInstanceConfig', $request, $callOptions)->wait(); + } + + /** + * Add/update metadata items for an instance. + * + * The async variant is + * {@see NotebookServiceClient::updateInstanceMetadataItemsAsync()} . + * + * @example samples/V1/NotebookServiceClient/update_instance_metadata_items.php + * + * @param UpdateInstanceMetadataItemsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 UpdateInstanceMetadataItemsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateInstanceMetadataItems(UpdateInstanceMetadataItemsRequest $request, array $callOptions = []): UpdateInstanceMetadataItemsResponse + { + return $this->startApiCall('UpdateInstanceMetadataItems', $request, $callOptions)->wait(); + } + + /** + * Updates the Shielded instance configuration of a single Instance. + * + * The async variant is + * {@see NotebookServiceClient::updateShieldedInstanceConfigAsync()} . + * + * @example samples/V1/NotebookServiceClient/update_shielded_instance_config.php + * + * @param UpdateShieldedInstanceConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateShieldedInstanceConfig(UpdateShieldedInstanceConfigRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateShieldedInstanceConfig', $request, $callOptions)->wait(); + } + + /** + * Upgrades a notebook instance to the latest version. + * + * The async variant is {@see NotebookServiceClient::upgradeInstanceAsync()} . + * + * @example samples/V1/NotebookServiceClient/upgrade_instance.php + * + * @param UpgradeInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function upgradeInstance(UpgradeInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpgradeInstance', $request, $callOptions)->wait(); + } + + /** + * Allows notebook instances to + * call this endpoint to upgrade themselves. Do not use this method directly. + * + * The async variant is + * {@see NotebookServiceClient::upgradeInstanceInternalAsync()} . + * + * @example samples/V1/NotebookServiceClient/upgrade_instance_internal.php + * + * @param UpgradeInstanceInternalRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function upgradeInstanceInternal(UpgradeInstanceInternalRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpgradeInstanceInternal', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see NotebookServiceClient::getLocationAsync()} . + * + * @example samples/V1/NotebookServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see NotebookServiceClient::listLocationsAsync()} . + * + * @example samples/V1/NotebookServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see NotebookServiceClient::getIamPolicyAsync()} . + * + * @example samples/V1/NotebookServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see NotebookServiceClient::setIamPolicyAsync()} . + * + * @example samples/V1/NotebookServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see NotebookServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V1/NotebookServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Notebooks/src/V2/AcceleratorConfig.php b/Notebooks/src/V2/AcceleratorConfig.php index bef92e9d19fb..870a9eb04930 100644 --- a/Notebooks/src/V2/AcceleratorConfig.php +++ b/Notebooks/src/V2/AcceleratorConfig.php @@ -25,13 +25,13 @@ class AcceleratorConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.notebooks.v2.AcceleratorConfig.AcceleratorType type = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $type = 0; + private $type = 0; /** * Optional. Count of cores of this accelerator. * * Generated from protobuf field int64 core_count = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $core_count = 0; + private $core_count = 0; /** * Constructor. diff --git a/Notebooks/src/V2/AcceleratorConfig/AcceleratorType.php b/Notebooks/src/V2/AcceleratorConfig/AcceleratorType.php index ff2bb8d5584b..c1f2b8471a7f 100644 --- a/Notebooks/src/V2/AcceleratorConfig/AcceleratorType.php +++ b/Notebooks/src/V2/AcceleratorConfig/AcceleratorType.php @@ -116,4 +116,6 @@ public static function value($name) } } +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(AcceleratorType::class, \Google\Cloud\Notebooks\V2\AcceleratorConfig_AcceleratorType::class); diff --git a/Notebooks/src/V2/BootDisk.php b/Notebooks/src/V2/BootDisk.php index fde8f7d94633..d4ae28e419c9 100644 --- a/Notebooks/src/V2/BootDisk.php +++ b/Notebooks/src/V2/BootDisk.php @@ -22,20 +22,20 @@ class BootDisk extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 disk_size_gb = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $disk_size_gb = 0; + private $disk_size_gb = 0; /** * Optional. Indicates the type of the disk. * * Generated from protobuf field .google.cloud.notebooks.v2.DiskType disk_type = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $disk_type = 0; + private $disk_type = 0; /** * Optional. Input only. Disk encryption method used on the boot and data * disks, defaults to GMEK. * * Generated from protobuf field .google.cloud.notebooks.v2.DiskEncryption disk_encryption = 3 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = OPTIONAL]; */ - protected $disk_encryption = 0; + private $disk_encryption = 0; /** * Optional. Input only. The KMS key used to encrypt the disks, only * applicable if disk_encryption is CMEK. Format: @@ -44,7 +44,7 @@ class BootDisk extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string kms_key = 4 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = OPTIONAL]; */ - protected $kms_key = ''; + private $kms_key = ''; /** * Constructor. diff --git a/Notebooks/src/V2/CheckInstanceUpgradabilityRequest.php b/Notebooks/src/V2/CheckInstanceUpgradabilityRequest.php index 14ad3c7b8c7b..1a662e1f909e 100644 --- a/Notebooks/src/V2/CheckInstanceUpgradabilityRequest.php +++ b/Notebooks/src/V2/CheckInstanceUpgradabilityRequest.php @@ -21,7 +21,7 @@ class CheckInstanceUpgradabilityRequest extends \Google\Protobuf\Internal\Messag * * Generated from protobuf field string notebook_instance = 1 [(.google.api.field_behavior) = REQUIRED]; */ - protected $notebook_instance = ''; + private $notebook_instance = ''; /** * Constructor. diff --git a/Notebooks/src/V2/CheckInstanceUpgradabilityResponse.php b/Notebooks/src/V2/CheckInstanceUpgradabilityResponse.php index fa10bb6afe87..b4d14e76bc15 100644 --- a/Notebooks/src/V2/CheckInstanceUpgradabilityResponse.php +++ b/Notebooks/src/V2/CheckInstanceUpgradabilityResponse.php @@ -20,20 +20,20 @@ class CheckInstanceUpgradabilityResponse extends \Google\Protobuf\Internal\Messa * * Generated from protobuf field bool upgradeable = 1; */ - protected $upgradeable = false; + private $upgradeable = false; /** * The version this instance will be upgraded to if calling the upgrade * endpoint. This field will only be populated if field upgradeable is true. * * Generated from protobuf field string upgrade_version = 2; */ - protected $upgrade_version = ''; + private $upgrade_version = ''; /** * Additional information about upgrade. * * Generated from protobuf field string upgrade_info = 3; */ - protected $upgrade_info = ''; + private $upgrade_info = ''; /** * The new image self link this instance will be upgraded to if calling the * upgrade endpoint. This field will only be populated if field upgradeable @@ -41,7 +41,7 @@ class CheckInstanceUpgradabilityResponse extends \Google\Protobuf\Internal\Messa * * Generated from protobuf field string upgrade_image = 4; */ - protected $upgrade_image = ''; + private $upgrade_image = ''; /** * Constructor. diff --git a/Notebooks/src/V2/Client/BaseClient/NotebookServiceBaseClient.php b/Notebooks/src/V2/Client/BaseClient/NotebookServiceBaseClient.php deleted file mode 100644 index 53c3efab44d9..000000000000 --- a/Notebooks/src/V2/Client/BaseClient/NotebookServiceBaseClient.php +++ /dev/null @@ -1,873 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . - '/../../resources/notebook_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../../resources/notebook_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . '/../../resources/notebook_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../../resources/notebook_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; - $operation = new OperationResponse( - $operationName, - $this->getOperationsClient(), - $options - ); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a instance - * resource. - * - * @param string $project - * @param string $location - * @param string $instance - * - * @return string The formatted instance resource. - */ - public static function instanceName( - string $project, - string $location, - string $instance - ): string { - return self::getPathTemplate('instance')->render([ - 'project' => $project, - 'location' => $location, - 'instance' => $instance, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName( - string $project, - string $location - ): string { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - instance: projects/{project}/locations/{location}/instances/{instance} - * - location: projects/{project}/locations/{location} - * - * 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( - string $formattedName, - string $template = null - ): array { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'notebooks.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error( - 'Call to undefined method ' . __CLASS__ . "::$method()", - E_USER_ERROR - ); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Checks whether a notebook instance is upgradable. - * - * The async variant is {@see self::checkInstanceUpgradabilityAsync()} . - * - * @example samples/V2/NotebookServiceClient/check_instance_upgradability.php - * - * @param CheckInstanceUpgradabilityRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CheckInstanceUpgradabilityResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function checkInstanceUpgradability( - CheckInstanceUpgradabilityRequest $request, - array $callOptions = [] - ): CheckInstanceUpgradabilityResponse { - return $this->startApiCall( - 'CheckInstanceUpgradability', - $request, - $callOptions - )->wait(); - } - - /** - * Creates a new Instance in a given project and location. - * - * The async variant is {@see self::createInstanceAsync()} . - * - * @example samples/V2/NotebookServiceClient/create_instance.php - * - * @param CreateInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createInstance( - CreateInstanceRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'CreateInstance', - $request, - $callOptions - )->wait(); - } - - /** - * Deletes a single Instance. - * - * The async variant is {@see self::deleteInstanceAsync()} . - * - * @example samples/V2/NotebookServiceClient/delete_instance.php - * - * @param DeleteInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteInstance( - DeleteInstanceRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'DeleteInstance', - $request, - $callOptions - )->wait(); - } - - /** - * Creates a Diagnostic File and runs Diagnostic Tool given an Instance. - * - * The async variant is {@see self::diagnoseInstanceAsync()} . - * - * @example samples/V2/NotebookServiceClient/diagnose_instance.php - * - * @param DiagnoseInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function diagnoseInstance( - DiagnoseInstanceRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'DiagnoseInstance', - $request, - $callOptions - )->wait(); - } - - /** - * Gets details of a single Instance. - * - * The async variant is {@see self::getInstanceAsync()} . - * - * @example samples/V2/NotebookServiceClient/get_instance.php - * - * @param GetInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Instance - * - * @throws ApiException Thrown if the API call fails. - */ - public function getInstance( - GetInstanceRequest $request, - array $callOptions = [] - ): Instance { - return $this->startApiCall( - 'GetInstance', - $request, - $callOptions - )->wait(); - } - - /** - * Lists instances in a given project and location. - * - * The async variant is {@see self::listInstancesAsync()} . - * - * @example samples/V2/NotebookServiceClient/list_instances.php - * - * @param ListInstancesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listInstances( - ListInstancesRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListInstances', $request, $callOptions); - } - - /** - * Resets a notebook instance. - * - * The async variant is {@see self::resetInstanceAsync()} . - * - * @example samples/V2/NotebookServiceClient/reset_instance.php - * - * @param ResetInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function resetInstance( - ResetInstanceRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'ResetInstance', - $request, - $callOptions - )->wait(); - } - - /** - * Rollbacks a notebook instance to the previous version. - * - * The async variant is {@see self::rollbackInstanceAsync()} . - * - * @example samples/V2/NotebookServiceClient/rollback_instance.php - * - * @param RollbackInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function rollbackInstance( - RollbackInstanceRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'RollbackInstance', - $request, - $callOptions - )->wait(); - } - - /** - * Starts a notebook instance. - * - * The async variant is {@see self::startInstanceAsync()} . - * - * @example samples/V2/NotebookServiceClient/start_instance.php - * - * @param StartInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function startInstance( - StartInstanceRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'StartInstance', - $request, - $callOptions - )->wait(); - } - - /** - * Stops a notebook instance. - * - * The async variant is {@see self::stopInstanceAsync()} . - * - * @example samples/V2/NotebookServiceClient/stop_instance.php - * - * @param StopInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function stopInstance( - StopInstanceRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'StopInstance', - $request, - $callOptions - )->wait(); - } - - /** - * UpdateInstance updates an Instance. - * - * The async variant is {@see self::updateInstanceAsync()} . - * - * @example samples/V2/NotebookServiceClient/update_instance.php - * - * @param UpdateInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateInstance( - UpdateInstanceRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'UpdateInstance', - $request, - $callOptions - )->wait(); - } - - /** - * Upgrades a notebook instance to the latest version. - * - * The async variant is {@see self::upgradeInstanceAsync()} . - * - * @example samples/V2/NotebookServiceClient/upgrade_instance.php - * - * @param UpgradeInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function upgradeInstance( - UpgradeInstanceRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'UpgradeInstance', - $request, - $callOptions - )->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V2/NotebookServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation( - GetLocationRequest $request, - array $callOptions = [] - ): Location { - return $this->startApiCall( - 'GetLocation', - $request, - $callOptions - )->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V2/NotebookServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations( - ListLocationsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V2/NotebookServiceClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy( - GetIamPolicyRequest $request, - array $callOptions = [] - ): Policy { - return $this->startApiCall( - 'GetIamPolicy', - $request, - $callOptions - )->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V2/NotebookServiceClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy( - SetIamPolicyRequest $request, - array $callOptions = [] - ): Policy { - return $this->startApiCall( - 'SetIamPolicy', - $request, - $callOptions - )->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V2/NotebookServiceClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions( - TestIamPermissionsRequest $request, - array $callOptions = [] - ): TestIamPermissionsResponse { - return $this->startApiCall( - 'TestIamPermissions', - $request, - $callOptions - )->wait(); - } -} diff --git a/Notebooks/src/V2/Client/NotebookServiceClient.php b/Notebooks/src/V2/Client/NotebookServiceClient.php index 2515802ef768..138ff9c1d5af 100644 --- a/Notebooks/src/V2/Client/NotebookServiceClient.php +++ b/Notebooks/src/V2/Client/NotebookServiceClient.php @@ -24,17 +24,731 @@ namespace Google\Cloud\Notebooks\V2\Client; -use Google\Cloud\Notebooks\V2\Client\BaseClient\NotebookServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\Notebooks\V2\CheckInstanceUpgradabilityRequest; +use Google\Cloud\Notebooks\V2\CheckInstanceUpgradabilityResponse; +use Google\Cloud\Notebooks\V2\CreateInstanceRequest; +use Google\Cloud\Notebooks\V2\DeleteInstanceRequest; +use Google\Cloud\Notebooks\V2\DiagnoseInstanceRequest; +use Google\Cloud\Notebooks\V2\GetInstanceRequest; +use Google\Cloud\Notebooks\V2\Instance; +use Google\Cloud\Notebooks\V2\ListInstancesRequest; +use Google\Cloud\Notebooks\V2\ResetInstanceRequest; +use Google\Cloud\Notebooks\V2\RollbackInstanceRequest; +use Google\Cloud\Notebooks\V2\StartInstanceRequest; +use Google\Cloud\Notebooks\V2\StopInstanceRequest; +use Google\Cloud\Notebooks\V2\UpdateInstanceRequest; +use Google\Cloud\Notebooks\V2\UpgradeInstanceRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: API v2 service for Workbench Notebooks Instances. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface checkInstanceUpgradabilityAsync(CheckInstanceUpgradabilityRequest $request, array $optionalArgs = []) + * @method PromiseInterface createInstanceAsync(CreateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteInstanceAsync(DeleteInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface diagnoseInstanceAsync(DiagnoseInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInstanceAsync(GetInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInstancesAsync(ListInstancesRequest $request, array $optionalArgs = []) + * @method PromiseInterface resetInstanceAsync(ResetInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface rollbackInstanceAsync(RollbackInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface startInstanceAsync(StartInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface stopInstanceAsync(StopInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateInstanceAsync(UpdateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface upgradeInstanceAsync(UpgradeInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class NotebookServiceClient extends NotebookServiceBaseClient +final class NotebookServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see NotebookServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.notebooks.v2.NotebookService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'notebooks.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/notebook_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/notebook_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/notebook_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/notebook_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a instance + * resource. + * + * @param string $project + * @param string $location + * @param string $instance + * + * @return string The formatted instance resource. + */ + public static function instanceName(string $project, string $location, string $instance): string + { + return self::getPathTemplate('instance')->render([ + 'project' => $project, + 'location' => $location, + 'instance' => $instance, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - instance: projects/{project}/locations/{location}/instances/{instance} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'notebooks.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Checks whether a notebook instance is upgradable. + * + * The async variant is + * {@see NotebookServiceClient::checkInstanceUpgradabilityAsync()} . + * + * @example samples/V2/NotebookServiceClient/check_instance_upgradability.php + * + * @param CheckInstanceUpgradabilityRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CheckInstanceUpgradabilityResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function checkInstanceUpgradability(CheckInstanceUpgradabilityRequest $request, array $callOptions = []): CheckInstanceUpgradabilityResponse + { + return $this->startApiCall('CheckInstanceUpgradability', $request, $callOptions)->wait(); + } + + /** + * Creates a new Instance in a given project and location. + * + * The async variant is {@see NotebookServiceClient::createInstanceAsync()} . + * + * @example samples/V2/NotebookServiceClient/create_instance.php + * + * @param CreateInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createInstance(CreateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateInstance', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Instance. + * + * The async variant is {@see NotebookServiceClient::deleteInstanceAsync()} . + * + * @example samples/V2/NotebookServiceClient/delete_instance.php + * + * @param DeleteInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); + } + + /** + * Creates a Diagnostic File and runs Diagnostic Tool given an Instance. + * + * The async variant is {@see NotebookServiceClient::diagnoseInstanceAsync()} . + * + * @example samples/V2/NotebookServiceClient/diagnose_instance.php + * + * @param DiagnoseInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function diagnoseInstance(DiagnoseInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DiagnoseInstance', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Instance. + * + * The async variant is {@see NotebookServiceClient::getInstanceAsync()} . + * + * @example samples/V2/NotebookServiceClient/get_instance.php + * + * @param GetInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Instance + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance + { + return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); + } + + /** + * Lists instances in a given project and location. + * + * The async variant is {@see NotebookServiceClient::listInstancesAsync()} . + * + * @example samples/V2/NotebookServiceClient/list_instances.php + * + * @param ListInstancesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInstances(ListInstancesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInstances', $request, $callOptions); + } + + /** + * Resets a notebook instance. + * + * The async variant is {@see NotebookServiceClient::resetInstanceAsync()} . + * + * @example samples/V2/NotebookServiceClient/reset_instance.php + * + * @param ResetInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function resetInstance(ResetInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ResetInstance', $request, $callOptions)->wait(); + } + + /** + * Rollbacks a notebook instance to the previous version. + * + * The async variant is {@see NotebookServiceClient::rollbackInstanceAsync()} . + * + * @example samples/V2/NotebookServiceClient/rollback_instance.php + * + * @param RollbackInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function rollbackInstance(RollbackInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RollbackInstance', $request, $callOptions)->wait(); + } + + /** + * Starts a notebook instance. + * + * The async variant is {@see NotebookServiceClient::startInstanceAsync()} . + * + * @example samples/V2/NotebookServiceClient/start_instance.php + * + * @param StartInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function startInstance(StartInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StartInstance', $request, $callOptions)->wait(); + } + + /** + * Stops a notebook instance. + * + * The async variant is {@see NotebookServiceClient::stopInstanceAsync()} . + * + * @example samples/V2/NotebookServiceClient/stop_instance.php + * + * @param StopInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function stopInstance(StopInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StopInstance', $request, $callOptions)->wait(); + } + + /** + * UpdateInstance updates an Instance. + * + * The async variant is {@see NotebookServiceClient::updateInstanceAsync()} . + * + * @example samples/V2/NotebookServiceClient/update_instance.php + * + * @param UpdateInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateInstance(UpdateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateInstance', $request, $callOptions)->wait(); + } + + /** + * Upgrades a notebook instance to the latest version. + * + * The async variant is {@see NotebookServiceClient::upgradeInstanceAsync()} . + * + * @example samples/V2/NotebookServiceClient/upgrade_instance.php + * + * @param UpgradeInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function upgradeInstance(UpgradeInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpgradeInstance', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see NotebookServiceClient::getLocationAsync()} . + * + * @example samples/V2/NotebookServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see NotebookServiceClient::listLocationsAsync()} . + * + * @example samples/V2/NotebookServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see NotebookServiceClient::getIamPolicyAsync()} . + * + * @example samples/V2/NotebookServiceClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see NotebookServiceClient::setIamPolicyAsync()} . + * + * @example samples/V2/NotebookServiceClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see NotebookServiceClient::testIamPermissionsAsync()} . + * + * @example samples/V2/NotebookServiceClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/Notebooks/src/V2/ContainerImage.php b/Notebooks/src/V2/ContainerImage.php index 72e77b2eb0b6..d24175bf1a10 100644 --- a/Notebooks/src/V2/ContainerImage.php +++ b/Notebooks/src/V2/ContainerImage.php @@ -22,14 +22,14 @@ class ContainerImage extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string repository = 1 [(.google.api.field_behavior) = REQUIRED]; */ - protected $repository = ''; + private $repository = ''; /** * Optional. The tag of the container image. If not specified, this defaults * to the latest tag. * * Generated from protobuf field string tag = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $tag = ''; + private $tag = ''; /** * Constructor. diff --git a/Notebooks/src/V2/CreateInstanceRequest.php b/Notebooks/src/V2/CreateInstanceRequest.php index 305567395f86..d68a1dcc72bb 100644 --- a/Notebooks/src/V2/CreateInstanceRequest.php +++ b/Notebooks/src/V2/CreateInstanceRequest.php @@ -21,25 +21,25 @@ class CreateInstanceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - protected $parent = ''; + private $parent = ''; /** * Required. User-defined unique ID of this instance. * * Generated from protobuf field string instance_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - protected $instance_id = ''; + private $instance_id = ''; /** * Required. The instance to be created. * * Generated from protobuf field .google.cloud.notebooks.v2.Instance instance = 3 [(.google.api.field_behavior) = REQUIRED]; */ - protected $instance = null; + private $instance = null; /** * Optional. Idempotent request UUID. * * Generated from protobuf field string request_id = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $request_id = ''; + private $request_id = ''; /** * @param string $parent Required. Format: diff --git a/Notebooks/src/V2/DataDisk.php b/Notebooks/src/V2/DataDisk.php index 670f178b50a0..78cc27f40674 100644 --- a/Notebooks/src/V2/DataDisk.php +++ b/Notebooks/src/V2/DataDisk.php @@ -21,20 +21,20 @@ class DataDisk extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 disk_size_gb = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $disk_size_gb = 0; + private $disk_size_gb = 0; /** * Optional. Input only. Indicates the type of the disk. * * Generated from protobuf field .google.cloud.notebooks.v2.DiskType disk_type = 2 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = OPTIONAL]; */ - protected $disk_type = 0; + private $disk_type = 0; /** * Optional. Input only. Disk encryption method used on the boot and data * disks, defaults to GMEK. * * Generated from protobuf field .google.cloud.notebooks.v2.DiskEncryption disk_encryption = 5 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = OPTIONAL]; */ - protected $disk_encryption = 0; + private $disk_encryption = 0; /** * Optional. Input only. The KMS key used to encrypt the disks, only * applicable if disk_encryption is CMEK. Format: @@ -43,7 +43,7 @@ class DataDisk extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string kms_key = 6 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = OPTIONAL]; */ - protected $kms_key = ''; + private $kms_key = ''; /** * Constructor. diff --git a/Notebooks/src/V2/DeleteInstanceRequest.php b/Notebooks/src/V2/DeleteInstanceRequest.php index 6eb1f755fd45..c71f7d7da60e 100644 --- a/Notebooks/src/V2/DeleteInstanceRequest.php +++ b/Notebooks/src/V2/DeleteInstanceRequest.php @@ -21,13 +21,13 @@ class DeleteInstanceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - protected $name = ''; + private $name = ''; /** * Optional. Idempotent request UUID. * * Generated from protobuf field string request_id = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $request_id = ''; + private $request_id = ''; /** * @param string $name Required. Format: diff --git a/Notebooks/src/V2/DiagnoseInstanceRequest.php b/Notebooks/src/V2/DiagnoseInstanceRequest.php index bf8021ecb723..697edf89add1 100644 --- a/Notebooks/src/V2/DiagnoseInstanceRequest.php +++ b/Notebooks/src/V2/DiagnoseInstanceRequest.php @@ -21,19 +21,19 @@ class DiagnoseInstanceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - protected $name = ''; + private $name = ''; /** * Required. Defines flags that are used to run the diagnostic tool * * Generated from protobuf field .google.cloud.notebooks.v2.DiagnosticConfig diagnostic_config = 2 [(.google.api.field_behavior) = REQUIRED]; */ - protected $diagnostic_config = null; + private $diagnostic_config = null; /** * Optional. Maxmium amount of time in minutes before the operation times out. * * Generated from protobuf field int32 timeout_minutes = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $timeout_minutes = 0; + private $timeout_minutes = 0; /** * @param string $name Required. Format: diff --git a/Notebooks/src/V2/DiagnosticConfig.php b/Notebooks/src/V2/DiagnosticConfig.php index 23d388e99653..b4aa1e72a4cd 100644 --- a/Notebooks/src/V2/DiagnosticConfig.php +++ b/Notebooks/src/V2/DiagnosticConfig.php @@ -30,7 +30,7 @@ class DiagnosticConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string gcs_bucket = 1 [(.google.api.field_behavior) = REQUIRED]; */ - protected $gcs_bucket = ''; + private $gcs_bucket = ''; /** * Optional. Defines the relative storage path in the Cloud Storage bucket * where the diagnostic logs will be written: Default path will be the root @@ -40,25 +40,25 @@ class DiagnosticConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string relative_path = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $relative_path = ''; + private $relative_path = ''; /** * Optional. Enables flag to repair service for instance * * Generated from protobuf field bool enable_repair_flag = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $enable_repair_flag = false; + private $enable_repair_flag = false; /** * Optional. Enables flag to capture packets from the instance for 30 seconds * * Generated from protobuf field bool enable_packet_capture_flag = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $enable_packet_capture_flag = false; + private $enable_packet_capture_flag = false; /** * Optional. Enables flag to copy all `/home/jupyter` folder contents * * Generated from protobuf field bool enable_copy_home_files_flag = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $enable_copy_home_files_flag = false; + private $enable_copy_home_files_flag = false; /** * Constructor. diff --git a/Notebooks/src/V2/Event.php b/Notebooks/src/V2/Event.php index 9214bd704974..f1ff6f0c3d98 100644 --- a/Notebooks/src/V2/Event.php +++ b/Notebooks/src/V2/Event.php @@ -20,13 +20,13 @@ class Event extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp report_time = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $report_time = null; + private $report_time = null; /** * Optional. Event type. * * Generated from protobuf field .google.cloud.notebooks.v2.Event.EventType type = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $type = 0; + private $type = 0; /** * Optional. Event details. This field is used to pass event information. * diff --git a/Notebooks/src/V2/Event/EventType.php b/Notebooks/src/V2/Event/EventType.php index d5db26d5f066..d99ae420a4ac 100644 --- a/Notebooks/src/V2/Event/EventType.php +++ b/Notebooks/src/V2/Event/EventType.php @@ -88,4 +88,6 @@ public static function value($name) } } +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(EventType::class, \Google\Cloud\Notebooks\V2\Event_EventType::class); diff --git a/Notebooks/src/V2/GPUDriverConfig.php b/Notebooks/src/V2/GPUDriverConfig.php index e7b276edeb92..37a58d278c37 100644 --- a/Notebooks/src/V2/GPUDriverConfig.php +++ b/Notebooks/src/V2/GPUDriverConfig.php @@ -22,7 +22,7 @@ class GPUDriverConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool enable_gpu_driver = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $enable_gpu_driver = false; + private $enable_gpu_driver = false; /** * Optional. Specify a custom Cloud Storage path where the GPU driver is * stored. If not specified, we'll automatically choose from official GPU @@ -30,7 +30,7 @@ class GPUDriverConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string custom_gpu_driver_path = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $custom_gpu_driver_path = ''; + private $custom_gpu_driver_path = ''; /** * Constructor. diff --git a/Notebooks/src/V2/GceSetup.php b/Notebooks/src/V2/GceSetup.php index 4865a23b99cd..64d6c174d11b 100644 --- a/Notebooks/src/V2/GceSetup.php +++ b/Notebooks/src/V2/GceSetup.php @@ -22,7 +22,7 @@ class GceSetup extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string machine_type = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $machine_type = ''; + private $machine_type = ''; /** * Optional. The hardware accelerators used on this instance. If you use * accelerators, make sure that your configuration has @@ -45,7 +45,7 @@ class GceSetup extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.notebooks.v2.BootDisk boot_disk = 6 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $boot_disk = null; + private $boot_disk = null; /** * Optional. Data disks attached to the VM instance. * Currently supports only one data disk. @@ -60,7 +60,7 @@ class GceSetup extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.notebooks.v2.ShieldedInstanceConfig shielded_instance_config = 8 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $shielded_instance_config = null; + private $shielded_instance_config = null; /** * Optional. The network interfaces for the VM. * Supports only one interface. @@ -73,7 +73,7 @@ class GceSetup extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool disable_public_ip = 10 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $disable_public_ip = false; + private $disable_public_ip = false; /** * Optional. The Compute Engine tags to add to runtime (see [Tagging * instances](https://cloud.google.com/compute/docs/label-or-tag-resources#tags)). @@ -93,13 +93,13 @@ class GceSetup extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool enable_ip_forwarding = 13 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $enable_ip_forwarding = false; + private $enable_ip_forwarding = false; /** * Optional. Configuration for GPU drivers. * * Generated from protobuf field .google.cloud.notebooks.v2.GPUDriverConfig gpu_driver_config = 14 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $gpu_driver_config = null; + private $gpu_driver_config = null; protected $image; /** diff --git a/Notebooks/src/V2/GetInstanceRequest.php b/Notebooks/src/V2/GetInstanceRequest.php index c33d67eee7dd..c949da8ffe72 100644 --- a/Notebooks/src/V2/GetInstanceRequest.php +++ b/Notebooks/src/V2/GetInstanceRequest.php @@ -21,7 +21,7 @@ class GetInstanceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - protected $name = ''; + private $name = ''; /** * @param string $name Required. Format: diff --git a/Notebooks/src/V2/Instance.php b/Notebooks/src/V2/Instance.php index fac652448bdc..d0f4bb53825a 100644 --- a/Notebooks/src/V2/Instance.php +++ b/Notebooks/src/V2/Instance.php @@ -21,14 +21,14 @@ class Instance extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - protected $name = ''; + private $name = ''; /** * Output only. The proxy endpoint that is used to access the Jupyter * notebook. * * Generated from protobuf field string proxy_uri = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - protected $proxy_uri = ''; + private $proxy_uri = ''; /** * Optional. Input only. The owner of this instance after creation. Format: * `alias@example.com` @@ -45,13 +45,13 @@ class Instance extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string creator = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - protected $creator = ''; + private $creator = ''; /** * Output only. The state of this instance. * * Generated from protobuf field .google.cloud.notebooks.v2.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - protected $state = 0; + private $state = 0; /** * Output only. The upgrade history of this instance. * @@ -63,13 +63,13 @@ class Instance extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string id = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - protected $id = ''; + private $id = ''; /** * Output only. Instance health_state. * * Generated from protobuf field .google.cloud.notebooks.v2.HealthState health_state = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - protected $health_state = 0; + private $health_state = 0; /** * Output only. Additional information about instance health. * Example: @@ -89,19 +89,19 @@ class Instance extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 11 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - protected $create_time = null; + private $create_time = null; /** * Output only. Instance update time. * * Generated from protobuf field .google.protobuf.Timestamp update_time = 12 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - protected $update_time = null; + private $update_time = null; /** * Optional. If true, the notebook instance will not register with the proxy. * * Generated from protobuf field bool disable_proxy_access = 13 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $disable_proxy_access = false; + private $disable_proxy_access = false; /** * Optional. Labels to apply to this instance. * These can be later modified by the UpdateInstance method. diff --git a/Notebooks/src/V2/ListInstancesRequest.php b/Notebooks/src/V2/ListInstancesRequest.php index debdf1761f08..d85952fde233 100644 --- a/Notebooks/src/V2/ListInstancesRequest.php +++ b/Notebooks/src/V2/ListInstancesRequest.php @@ -21,33 +21,33 @@ class ListInstancesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - protected $parent = ''; + private $parent = ''; /** * Optional. Maximum return size of the list call. * * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $page_size = 0; + private $page_size = 0; /** * Optional. A previous returned page token that can be used to continue * listing from the last result. * * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $page_token = ''; + private $page_token = ''; /** * Optional. Sort results. Supported values are "name", "name desc" or "" * (unsorted). * * Generated from protobuf field string order_by = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $order_by = ''; + private $order_by = ''; /** * Optional. List filter. * * Generated from protobuf field string filter = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $filter = ''; + private $filter = ''; /** * @param string $parent Required. Format: diff --git a/Notebooks/src/V2/ListInstancesResponse.php b/Notebooks/src/V2/ListInstancesResponse.php index 0a01d401ae79..33e576fcf4a8 100644 --- a/Notebooks/src/V2/ListInstancesResponse.php +++ b/Notebooks/src/V2/ListInstancesResponse.php @@ -27,7 +27,7 @@ class ListInstancesResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - protected $next_page_token = ''; + private $next_page_token = ''; /** * Locations that could not be reached. For example, * ['us-west1-a', 'us-central1-b']. diff --git a/Notebooks/src/V2/NetworkInterface.php b/Notebooks/src/V2/NetworkInterface.php index 66f44bc6a3bf..d40d88375389 100644 --- a/Notebooks/src/V2/NetworkInterface.php +++ b/Notebooks/src/V2/NetworkInterface.php @@ -22,7 +22,7 @@ class NetworkInterface extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string network = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $network = ''; + private $network = ''; /** * Optional. The name of the subnet that this VM instance is in. * Format: @@ -30,14 +30,14 @@ class NetworkInterface extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string subnet = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $subnet = ''; + private $subnet = ''; /** * Optional. The type of vNIC to be used on this interface. This may be gVNIC * or VirtioNet. * * Generated from protobuf field .google.cloud.notebooks.v2.NetworkInterface.NicType nic_type = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $nic_type = 0; + private $nic_type = 0; /** * Constructor. diff --git a/Notebooks/src/V2/NetworkInterface/NicType.php b/Notebooks/src/V2/NetworkInterface/NicType.php index 781be1f53db4..d8ddfee35971 100644 --- a/Notebooks/src/V2/NetworkInterface/NicType.php +++ b/Notebooks/src/V2/NetworkInterface/NicType.php @@ -60,4 +60,6 @@ public static function value($name) } } +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(NicType::class, \Google\Cloud\Notebooks\V2\NetworkInterface_NicType::class); diff --git a/Notebooks/src/V2/OperationMetadata.php b/Notebooks/src/V2/OperationMetadata.php index 501b362e7d4f..d7da26dee06b 100644 --- a/Notebooks/src/V2/OperationMetadata.php +++ b/Notebooks/src/V2/OperationMetadata.php @@ -20,31 +20,31 @@ class OperationMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 1; */ - protected $create_time = null; + private $create_time = null; /** * The time the operation finished running. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 2; */ - protected $end_time = null; + private $end_time = null; /** * Server-defined resource path for the target of the operation. * * Generated from protobuf field string target = 3; */ - protected $target = ''; + private $target = ''; /** * Name of the verb executed by the operation. * * Generated from protobuf field string verb = 4; */ - protected $verb = ''; + private $verb = ''; /** * Human-readable status of the operation, if any. * * Generated from protobuf field string status_message = 5; */ - protected $status_message = ''; + private $status_message = ''; /** * Identifies whether the user has requested cancellation * of the operation. Operations that have successfully been cancelled @@ -54,19 +54,19 @@ class OperationMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool requested_cancellation = 6; */ - protected $requested_cancellation = false; + private $requested_cancellation = false; /** * API version used to start the operation. * * Generated from protobuf field string api_version = 7; */ - protected $api_version = ''; + private $api_version = ''; /** * API endpoint name of this operation. * * Generated from protobuf field string endpoint = 8; */ - protected $endpoint = ''; + private $endpoint = ''; /** * Constructor. diff --git a/Notebooks/src/V2/ResetInstanceRequest.php b/Notebooks/src/V2/ResetInstanceRequest.php index b76c5142315b..ab94d9c712b4 100644 --- a/Notebooks/src/V2/ResetInstanceRequest.php +++ b/Notebooks/src/V2/ResetInstanceRequest.php @@ -21,7 +21,7 @@ class ResetInstanceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - protected $name = ''; + private $name = ''; /** * Constructor. diff --git a/Notebooks/src/V2/RollbackInstanceRequest.php b/Notebooks/src/V2/RollbackInstanceRequest.php index 77824123e24e..1306dbe4eff3 100644 --- a/Notebooks/src/V2/RollbackInstanceRequest.php +++ b/Notebooks/src/V2/RollbackInstanceRequest.php @@ -21,20 +21,20 @@ class RollbackInstanceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - protected $name = ''; + private $name = ''; /** * Required. The snapshot for rollback. * Example: "projects/test-project/global/snapshots/krwlzipynril". * * Generated from protobuf field string target_snapshot = 2 [(.google.api.field_behavior) = REQUIRED]; */ - protected $target_snapshot = ''; + private $target_snapshot = ''; /** * Required. Output only. Revision Id * * Generated from protobuf field string revision_id = 3 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.field_behavior) = REQUIRED]; */ - protected $revision_id = ''; + private $revision_id = ''; /** * Constructor. diff --git a/Notebooks/src/V2/ServiceAccount.php b/Notebooks/src/V2/ServiceAccount.php index 8016666a9a2f..d9639890b7e1 100644 --- a/Notebooks/src/V2/ServiceAccount.php +++ b/Notebooks/src/V2/ServiceAccount.php @@ -20,7 +20,7 @@ class ServiceAccount extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string email = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $email = ''; + private $email = ''; /** * Output only. The list of scopes to be made available for this service * account. Set by the CLH to https://www.googleapis.com/auth/cloud-platform diff --git a/Notebooks/src/V2/ShieldedInstanceConfig.php b/Notebooks/src/V2/ShieldedInstanceConfig.php index 911a41c87c93..9b7d58f14662 100644 --- a/Notebooks/src/V2/ShieldedInstanceConfig.php +++ b/Notebooks/src/V2/ShieldedInstanceConfig.php @@ -26,14 +26,14 @@ class ShieldedInstanceConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool enable_secure_boot = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $enable_secure_boot = false; + private $enable_secure_boot = false; /** * Optional. Defines whether the VM instance has the vTPM enabled. Enabled by * default. * * Generated from protobuf field bool enable_vtpm = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $enable_vtpm = false; + private $enable_vtpm = false; /** * Optional. Defines whether the VM instance has integrity monitoring enabled. * Enables monitoring and attestation of the boot integrity of the VM @@ -43,7 +43,7 @@ class ShieldedInstanceConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool enable_integrity_monitoring = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $enable_integrity_monitoring = false; + private $enable_integrity_monitoring = false; /** * Constructor. diff --git a/Notebooks/src/V2/StartInstanceRequest.php b/Notebooks/src/V2/StartInstanceRequest.php index 41021273b9d3..97dc82f8fcf4 100644 --- a/Notebooks/src/V2/StartInstanceRequest.php +++ b/Notebooks/src/V2/StartInstanceRequest.php @@ -21,7 +21,7 @@ class StartInstanceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - protected $name = ''; + private $name = ''; /** * Constructor. diff --git a/Notebooks/src/V2/StopInstanceRequest.php b/Notebooks/src/V2/StopInstanceRequest.php index b3ae64046da9..29385a867d5c 100644 --- a/Notebooks/src/V2/StopInstanceRequest.php +++ b/Notebooks/src/V2/StopInstanceRequest.php @@ -21,7 +21,7 @@ class StopInstanceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - protected $name = ''; + private $name = ''; /** * Constructor. diff --git a/Notebooks/src/V2/UpdateInstanceRequest.php b/Notebooks/src/V2/UpdateInstanceRequest.php index 7ded465f5ce2..8a60c44c5eea 100644 --- a/Notebooks/src/V2/UpdateInstanceRequest.php +++ b/Notebooks/src/V2/UpdateInstanceRequest.php @@ -20,19 +20,19 @@ class UpdateInstanceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.cloud.notebooks.v2.Instance instance = 1 [(.google.api.field_behavior) = REQUIRED]; */ - protected $instance = null; + private $instance = null; /** * Required. Mask used to update an instance * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; */ - protected $update_mask = null; + private $update_mask = null; /** * Optional. Idempotent request UUID. * * Generated from protobuf field string request_id = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $request_id = ''; + private $request_id = ''; /** * @param \Google\Cloud\Notebooks\V2\Instance $instance Required. A representation of an instance. diff --git a/Notebooks/src/V2/UpgradeHistoryEntry.php b/Notebooks/src/V2/UpgradeHistoryEntry.php index 01fdd5a03451..a5978b95453f 100644 --- a/Notebooks/src/V2/UpgradeHistoryEntry.php +++ b/Notebooks/src/V2/UpgradeHistoryEntry.php @@ -21,55 +21,55 @@ class UpgradeHistoryEntry extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string snapshot = 1 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $snapshot = ''; + private $snapshot = ''; /** * Optional. The VM image before this instance upgrade. * * Generated from protobuf field string vm_image = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $vm_image = ''; + private $vm_image = ''; /** * Optional. The container image before this instance upgrade. * * Generated from protobuf field string container_image = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $container_image = ''; + private $container_image = ''; /** * Optional. The framework of this notebook instance. * * Generated from protobuf field string framework = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $framework = ''; + private $framework = ''; /** * Optional. The version of the notebook instance before this upgrade. * * Generated from protobuf field string version = 5 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $version = ''; + private $version = ''; /** * Output only. The state of this instance upgrade history entry. * * Generated from protobuf field .google.cloud.notebooks.v2.UpgradeHistoryEntry.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - protected $state = 0; + private $state = 0; /** * Immutable. The time that this instance upgrade history entry is created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 7 [(.google.api.field_behavior) = IMMUTABLE]; */ - protected $create_time = null; + private $create_time = null; /** * Optional. Action. Rolloback or Upgrade. * * Generated from protobuf field .google.cloud.notebooks.v2.UpgradeHistoryEntry.Action action = 8 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $action = 0; + private $action = 0; /** * Optional. Target VM Version, like m63. * * Generated from protobuf field string target_version = 9 [(.google.api.field_behavior) = OPTIONAL]; */ - protected $target_version = ''; + private $target_version = ''; /** * Constructor. diff --git a/Notebooks/src/V2/UpgradeHistoryEntry/Action.php b/Notebooks/src/V2/UpgradeHistoryEntry/Action.php index 9a466c032959..563ca0f0e2ef 100644 --- a/Notebooks/src/V2/UpgradeHistoryEntry/Action.php +++ b/Notebooks/src/V2/UpgradeHistoryEntry/Action.php @@ -59,4 +59,6 @@ public static function value($name) } } +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Action::class, \Google\Cloud\Notebooks\V2\UpgradeHistoryEntry_Action::class); diff --git a/Notebooks/src/V2/UpgradeHistoryEntry/State.php b/Notebooks/src/V2/UpgradeHistoryEntry/State.php index dcba7619f3eb..b1760831b649 100644 --- a/Notebooks/src/V2/UpgradeHistoryEntry/State.php +++ b/Notebooks/src/V2/UpgradeHistoryEntry/State.php @@ -66,4 +66,6 @@ public static function value($name) } } +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(State::class, \Google\Cloud\Notebooks\V2\UpgradeHistoryEntry_State::class); diff --git a/Notebooks/src/V2/UpgradeInstanceRequest.php b/Notebooks/src/V2/UpgradeInstanceRequest.php index 7335c3fdaa52..7be594b1ca14 100644 --- a/Notebooks/src/V2/UpgradeInstanceRequest.php +++ b/Notebooks/src/V2/UpgradeInstanceRequest.php @@ -21,7 +21,7 @@ class UpgradeInstanceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ - protected $name = ''; + private $name = ''; /** * Constructor. diff --git a/Notebooks/src/V2/VmImage.php b/Notebooks/src/V2/VmImage.php index e1b2043b1087..3a77d0cde504 100644 --- a/Notebooks/src/V2/VmImage.php +++ b/Notebooks/src/V2/VmImage.php @@ -22,7 +22,7 @@ class VmImage extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string project = 1 [(.google.api.field_behavior) = REQUIRED]; */ - protected $project = ''; + private $project = ''; protected $image; /** diff --git a/Optimization/composer.json b/Optimization/composer.json index 97dcad1ae04d..7d9a98f58957 100644 --- a/Optimization/composer.json +++ b/Optimization/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Optimization/metadata/V1/FleetRouting.php b/Optimization/metadata/V1/FleetRouting.php index 0ce0dc08ce44..ea2c734a395a 100644 Binary files a/Optimization/metadata/V1/FleetRouting.php and b/Optimization/metadata/V1/FleetRouting.php differ diff --git a/Optimization/src/V1/Client/BaseClient/FleetRoutingBaseClient.php b/Optimization/src/V1/Client/BaseClient/FleetRoutingBaseClient.php deleted file mode 100644 index 9ee8e46c1599..000000000000 --- a/Optimization/src/V1/Client/BaseClient/FleetRoutingBaseClient.php +++ /dev/null @@ -1,291 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/fleet_routing_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/fleet_routing_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/fleet_routing_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/fleet_routing_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'cloudoptimization.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Optimizes vehicle tours for one or more `OptimizeToursRequest` - * messages as a batch. - * - * This method is a Long Running Operation (LRO). The inputs for optimization - * (`OptimizeToursRequest` messages) and outputs (`OptimizeToursResponse` - * messages) are read/written from/to Cloud Storage in user-specified - * format. Like the `OptimizeTours` method, each `OptimizeToursRequest` - * contains a `ShipmentModel` and returns an `OptimizeToursResponse` - * containing `ShipmentRoute`s, which are a set of routes to be performed by - * vehicles minimizing the overall cost. - * - * The async variant is {@see self::batchOptimizeToursAsync()} . - * - * @example samples/V1/FleetRoutingClient/batch_optimize_tours.php - * - * @param BatchOptimizeToursRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchOptimizeTours(BatchOptimizeToursRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BatchOptimizeTours', $request, $callOptions)->wait(); - } - - /** - * Sends an `OptimizeToursRequest` containing a `ShipmentModel` and returns an - * `OptimizeToursResponse` containing `ShipmentRoute`s, which are a set of - * routes to be performed by vehicles minimizing the overall cost. - * - * A `ShipmentModel` model consists mainly of `Shipment`s that need to be - * carried out and `Vehicle`s that can be used to transport the `Shipment`s. - * The `ShipmentRoute`s assign `Shipment`s to `Vehicle`s. More specifically, - * they assign a series of `Visit`s to each vehicle, where a `Visit` - * corresponds to a `VisitRequest`, which is a pickup or delivery for a - * `Shipment`. - * - * The goal is to provide an assignment of `ShipmentRoute`s to `Vehicle`s that - * minimizes the total cost where cost has many components defined in the - * `ShipmentModel`. - * - * The async variant is {@see self::optimizeToursAsync()} . - * - * @example samples/V1/FleetRoutingClient/optimize_tours.php - * - * @param OptimizeToursRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OptimizeToursResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function optimizeTours(OptimizeToursRequest $request, array $callOptions = []): OptimizeToursResponse - { - return $this->startApiCall('OptimizeTours', $request, $callOptions)->wait(); - } -} diff --git a/Optimization/src/V1/Client/FleetRoutingClient.php b/Optimization/src/V1/Client/FleetRoutingClient.php index c830867e8ca7..b50ea4876830 100644 --- a/Optimization/src/V1/Client/FleetRoutingClient.php +++ b/Optimization/src/V1/Client/FleetRoutingClient.php @@ -24,17 +24,266 @@ namespace Google\Cloud\Optimization\V1\Client; -use Google\Cloud\Optimization\V1\Client\BaseClient\FleetRoutingBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Optimization\V1\BatchOptimizeToursRequest; +use Google\Cloud\Optimization\V1\OptimizeToursRequest; +use Google\Cloud\Optimization\V1\OptimizeToursResponse; +use Google\Cloud\Optimization\V1\ShipmentRoute; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service for optimizing vehicle tours. * - * This class is currently experimental and may be subject to changes. + * Validity of certain types of fields: + * + * * `google.protobuf.Timestamp` + * * Times are in Unix time: seconds since 1970-01-01T00:00:00+00:00. + * * seconds must be in [0, 253402300799], + * i.e. in [1970-01-01T00:00:00+00:00, 9999-12-31T23:59:59+00:00]. + * * nanos must be unset or set to 0. + * * `google.protobuf.Duration` + * * seconds must be in [0, 253402300799], + * i.e. in [1970-01-01T00:00:00+00:00, 9999-12-31T23:59:59+00:00]. + * * nanos must be unset or set to 0. + * * `google.type.LatLng` + * * latitude must be in [-90.0, 90.0]. + * * longitude must be in [-180.0, 180.0]. + * * at least one of latitude and longitude must be non-zero. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Optimization\V1\FleetRoutingClient} for the stable implementation * * @experimental + * + * @method PromiseInterface batchOptimizeToursAsync(BatchOptimizeToursRequest $request, array $optionalArgs = []) + * @method PromiseInterface optimizeToursAsync(OptimizeToursRequest $request, array $optionalArgs = []) */ -final class FleetRoutingClient extends FleetRoutingBaseClient +final class FleetRoutingClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see FleetRoutingBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.optimization.v1.FleetRouting'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudoptimization.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/fleet_routing_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/fleet_routing_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/fleet_routing_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/fleet_routing_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'cloudoptimization.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Optimizes vehicle tours for one or more `OptimizeToursRequest` + * messages as a batch. + * + * This method is a Long Running Operation (LRO). The inputs for optimization + * (`OptimizeToursRequest` messages) and outputs (`OptimizeToursResponse` + * messages) are read/written from/to Cloud Storage in user-specified + * format. Like the `OptimizeTours` method, each `OptimizeToursRequest` + * contains a `ShipmentModel` and returns an `OptimizeToursResponse` + * containing `ShipmentRoute`s, which are a set of routes to be performed by + * vehicles minimizing the overall cost. + * + * The async variant is {@see FleetRoutingClient::batchOptimizeToursAsync()} . + * + * @example samples/V1/FleetRoutingClient/batch_optimize_tours.php + * + * @param BatchOptimizeToursRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchOptimizeTours(BatchOptimizeToursRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchOptimizeTours', $request, $callOptions)->wait(); + } + + /** + * Sends an `OptimizeToursRequest` containing a `ShipmentModel` and returns an + * `OptimizeToursResponse` containing `ShipmentRoute`s, which are a set of + * routes to be performed by vehicles minimizing the overall cost. + * + * A `ShipmentModel` model consists mainly of `Shipment`s that need to be + * carried out and `Vehicle`s that can be used to transport the `Shipment`s. + * The `ShipmentRoute`s assign `Shipment`s to `Vehicle`s. More specifically, + * they assign a series of `Visit`s to each vehicle, where a `Visit` + * corresponds to a `VisitRequest`, which is a pickup or delivery for a + * `Shipment`. + * + * The goal is to provide an assignment of `ShipmentRoute`s to `Vehicle`s that + * minimizes the total cost where cost has many components defined in the + * `ShipmentModel`. + * + * The async variant is {@see FleetRoutingClient::optimizeToursAsync()} . + * + * @example samples/V1/FleetRoutingClient/optimize_tours.php + * + * @param OptimizeToursRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OptimizeToursResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function optimizeTours(OptimizeToursRequest $request, array $callOptions = []): OptimizeToursResponse + { + return $this->startApiCall('OptimizeTours', $request, $callOptions)->wait(); + } } diff --git a/Optimization/src/V1/OptimizeToursValidationError.php b/Optimization/src/V1/OptimizeToursValidationError.php index 5a49b73de432..e12b4554d7fe 100644 --- a/Optimization/src/V1/OptimizeToursValidationError.php +++ b/Optimization/src/V1/OptimizeToursValidationError.php @@ -202,6 +202,13 @@ class OptimizeToursValidationError extends \Google\Protobuf\Internal\Message * * VISIT_REQUEST_DURATION_NEGATIVE_OR_NAN = 4404; * * VISIT_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4405; * * PRECEDENCE_ERROR = 46; + * * PRECEDENCE_RULE_MISSING_FIRST_INDEX = 4600; + * * PRECEDENCE_RULE_MISSING_SECOND_INDEX = 4601; + * * PRECEDENCE_RULE_FIRST_INDEX_OUT_OF_BOUNDS = 4602; + * * PRECEDENCE_RULE_SECOND_INDEX_OUT_OF_BOUNDS = 4603; + * * PRECEDENCE_RULE_DUPLICATE_INDEX = 4604; + * * PRECEDENCE_RULE_INEXISTENT_FIRST_VISIT_REQUEST = 4605; + * * PRECEDENCE_RULE_INEXISTENT_SECOND_VISIT_REQUEST = 4606; * * BREAK_ERROR = 48; * * BREAK_RULE_EMPTY = 4800; * * BREAK_REQUEST_UNSPECIFIED_DURATION = 4801; @@ -483,6 +490,13 @@ class OptimizeToursValidationError extends \Google\Protobuf\Internal\Message * * VISIT_REQUEST_DURATION_NEGATIVE_OR_NAN = 4404; * * VISIT_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4405; * * PRECEDENCE_ERROR = 46; + * * PRECEDENCE_RULE_MISSING_FIRST_INDEX = 4600; + * * PRECEDENCE_RULE_MISSING_SECOND_INDEX = 4601; + * * PRECEDENCE_RULE_FIRST_INDEX_OUT_OF_BOUNDS = 4602; + * * PRECEDENCE_RULE_SECOND_INDEX_OUT_OF_BOUNDS = 4603; + * * PRECEDENCE_RULE_DUPLICATE_INDEX = 4604; + * * PRECEDENCE_RULE_INEXISTENT_FIRST_VISIT_REQUEST = 4605; + * * PRECEDENCE_RULE_INEXISTENT_SECOND_VISIT_REQUEST = 4606; * * BREAK_ERROR = 48; * * BREAK_RULE_EMPTY = 4800; * * BREAK_REQUEST_UNSPECIFIED_DURATION = 4801; @@ -744,6 +758,13 @@ public function __construct($data = NULL) { * * VISIT_REQUEST_DURATION_NEGATIVE_OR_NAN = 4404; * * VISIT_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4405; * * PRECEDENCE_ERROR = 46; + * * PRECEDENCE_RULE_MISSING_FIRST_INDEX = 4600; + * * PRECEDENCE_RULE_MISSING_SECOND_INDEX = 4601; + * * PRECEDENCE_RULE_FIRST_INDEX_OUT_OF_BOUNDS = 4602; + * * PRECEDENCE_RULE_SECOND_INDEX_OUT_OF_BOUNDS = 4603; + * * PRECEDENCE_RULE_DUPLICATE_INDEX = 4604; + * * PRECEDENCE_RULE_INEXISTENT_FIRST_VISIT_REQUEST = 4605; + * * PRECEDENCE_RULE_INEXISTENT_SECOND_VISIT_REQUEST = 4606; * * BREAK_ERROR = 48; * * BREAK_RULE_EMPTY = 4800; * * BREAK_REQUEST_UNSPECIFIED_DURATION = 4801; @@ -985,6 +1006,13 @@ public function getCode() * * VISIT_REQUEST_DURATION_NEGATIVE_OR_NAN = 4404; * * VISIT_REQUEST_DURATION_EXCEEDS_GLOBAL_DURATION = 4405; * * PRECEDENCE_ERROR = 46; + * * PRECEDENCE_RULE_MISSING_FIRST_INDEX = 4600; + * * PRECEDENCE_RULE_MISSING_SECOND_INDEX = 4601; + * * PRECEDENCE_RULE_FIRST_INDEX_OUT_OF_BOUNDS = 4602; + * * PRECEDENCE_RULE_SECOND_INDEX_OUT_OF_BOUNDS = 4603; + * * PRECEDENCE_RULE_DUPLICATE_INDEX = 4604; + * * PRECEDENCE_RULE_INEXISTENT_FIRST_VISIT_REQUEST = 4605; + * * PRECEDENCE_RULE_INEXISTENT_SECOND_VISIT_REQUEST = 4606; * * BREAK_ERROR = 48; * * BREAK_RULE_EMPTY = 4800; * * BREAK_REQUEST_UNSPECIFIED_DURATION = 4801; diff --git a/Optimization/src/V1/RouteModifiers.php b/Optimization/src/V1/RouteModifiers.php new file mode 100644 index 000000000000..4c356775bd52 --- /dev/null +++ b/Optimization/src/V1/RouteModifiers.php @@ -0,0 +1,204 @@ +google.cloud.optimization.v1.RouteModifiers + */ +class RouteModifiers extends \Google\Protobuf\Internal\Message +{ + /** + * Specifies whether to avoid toll roads where reasonable. Preference will be + * given to routes not containing toll roads. Applies only to motorized travel + * modes. + * + * Generated from protobuf field bool avoid_tolls = 2; + */ + private $avoid_tolls = false; + /** + * Specifies whether to avoid highways where reasonable. Preference will be + * given to routes not containing highways. Applies only to motorized travel + * modes. + * + * Generated from protobuf field bool avoid_highways = 3; + */ + private $avoid_highways = false; + /** + * Specifies whether to avoid ferries where reasonable. Preference will be + * given to routes not containing travel by ferries. Applies only to motorized + * travel modes. + * + * Generated from protobuf field bool avoid_ferries = 4; + */ + private $avoid_ferries = false; + /** + * Optional. Specifies whether to avoid navigating indoors where reasonable. + * Preference will be given to routes not containing indoor navigation. + * Applies only to the `WALKING` travel mode. + * + * Generated from protobuf field bool avoid_indoor = 5 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $avoid_indoor = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type bool $avoid_tolls + * Specifies whether to avoid toll roads where reasonable. Preference will be + * given to routes not containing toll roads. Applies only to motorized travel + * modes. + * @type bool $avoid_highways + * Specifies whether to avoid highways where reasonable. Preference will be + * given to routes not containing highways. Applies only to motorized travel + * modes. + * @type bool $avoid_ferries + * Specifies whether to avoid ferries where reasonable. Preference will be + * given to routes not containing travel by ferries. Applies only to motorized + * travel modes. + * @type bool $avoid_indoor + * Optional. Specifies whether to avoid navigating indoors where reasonable. + * Preference will be given to routes not containing indoor navigation. + * Applies only to the `WALKING` travel mode. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Optimization\V1\FleetRouting::initOnce(); + parent::__construct($data); + } + + /** + * Specifies whether to avoid toll roads where reasonable. Preference will be + * given to routes not containing toll roads. Applies only to motorized travel + * modes. + * + * Generated from protobuf field bool avoid_tolls = 2; + * @return bool + */ + public function getAvoidTolls() + { + return $this->avoid_tolls; + } + + /** + * Specifies whether to avoid toll roads where reasonable. Preference will be + * given to routes not containing toll roads. Applies only to motorized travel + * modes. + * + * Generated from protobuf field bool avoid_tolls = 2; + * @param bool $var + * @return $this + */ + public function setAvoidTolls($var) + { + GPBUtil::checkBool($var); + $this->avoid_tolls = $var; + + return $this; + } + + /** + * Specifies whether to avoid highways where reasonable. Preference will be + * given to routes not containing highways. Applies only to motorized travel + * modes. + * + * Generated from protobuf field bool avoid_highways = 3; + * @return bool + */ + public function getAvoidHighways() + { + return $this->avoid_highways; + } + + /** + * Specifies whether to avoid highways where reasonable. Preference will be + * given to routes not containing highways. Applies only to motorized travel + * modes. + * + * Generated from protobuf field bool avoid_highways = 3; + * @param bool $var + * @return $this + */ + public function setAvoidHighways($var) + { + GPBUtil::checkBool($var); + $this->avoid_highways = $var; + + return $this; + } + + /** + * Specifies whether to avoid ferries where reasonable. Preference will be + * given to routes not containing travel by ferries. Applies only to motorized + * travel modes. + * + * Generated from protobuf field bool avoid_ferries = 4; + * @return bool + */ + public function getAvoidFerries() + { + return $this->avoid_ferries; + } + + /** + * Specifies whether to avoid ferries where reasonable. Preference will be + * given to routes not containing travel by ferries. Applies only to motorized + * travel modes. + * + * Generated from protobuf field bool avoid_ferries = 4; + * @param bool $var + * @return $this + */ + public function setAvoidFerries($var) + { + GPBUtil::checkBool($var); + $this->avoid_ferries = $var; + + return $this; + } + + /** + * Optional. Specifies whether to avoid navigating indoors where reasonable. + * Preference will be given to routes not containing indoor navigation. + * Applies only to the `WALKING` travel mode. + * + * Generated from protobuf field bool avoid_indoor = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @return bool + */ + public function getAvoidIndoor() + { + return $this->avoid_indoor; + } + + /** + * Optional. Specifies whether to avoid navigating indoors where reasonable. + * Preference will be given to routes not containing indoor navigation. + * Applies only to the `WALKING` travel mode. + * + * Generated from protobuf field bool avoid_indoor = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @param bool $var + * @return $this + */ + public function setAvoidIndoor($var) + { + GPBUtil::checkBool($var); + $this->avoid_indoor = $var; + + return $this; + } + +} + diff --git a/Optimization/src/V1/Vehicle.php b/Optimization/src/V1/Vehicle.php index 9d2bb70128d5..b5dbb09f5210 100644 --- a/Optimization/src/V1/Vehicle.php +++ b/Optimization/src/V1/Vehicle.php @@ -24,6 +24,13 @@ class Vehicle extends \Google\Protobuf\Internal\Message * Generated from protobuf field .google.cloud.optimization.v1.Vehicle.TravelMode travel_mode = 1; */ private $travel_mode = 0; + /** + * Optional. A set of conditions to satisfy that affect the way routes are + * calculated for the given vehicle. + * + * Generated from protobuf field .google.cloud.optimization.v1.RouteModifiers route_modifiers = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $route_modifiers = null; /** * Geographic location where the vehicle starts before picking up any * shipments. If not specified, the vehicle starts at its first pickup. @@ -308,6 +315,9 @@ class Vehicle extends \Google\Protobuf\Internal\Message * @type int $travel_mode * The travel mode which affects the roads usable by the vehicle and its * speed. See also `travel_duration_multiple`. + * @type \Google\Cloud\Optimization\V1\RouteModifiers $route_modifiers + * Optional. A set of conditions to satisfy that affect the way routes are + * calculated for the given vehicle. * @type \Google\Type\LatLng $start_location * Geographic location where the vehicle starts before picking up any * shipments. If not specified, the vehicle starts at its first pickup. @@ -505,6 +515,44 @@ public function setTravelMode($var) return $this; } + /** + * Optional. A set of conditions to satisfy that affect the way routes are + * calculated for the given vehicle. + * + * Generated from protobuf field .google.cloud.optimization.v1.RouteModifiers route_modifiers = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Optimization\V1\RouteModifiers|null + */ + public function getRouteModifiers() + { + return $this->route_modifiers; + } + + public function hasRouteModifiers() + { + return isset($this->route_modifiers); + } + + public function clearRouteModifiers() + { + unset($this->route_modifiers); + } + + /** + * Optional. A set of conditions to satisfy that affect the way routes are + * calculated for the given vehicle. + * + * Generated from protobuf field .google.cloud.optimization.v1.RouteModifiers route_modifiers = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Optimization\V1\RouteModifiers $var + * @return $this + */ + public function setRouteModifiers($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Optimization\V1\RouteModifiers::class); + $this->route_modifiers = $var; + + return $this; + } + /** * Geographic location where the vehicle starts before picking up any * shipments. If not specified, the vehicle starts at its first pickup. diff --git a/OrchestrationAirflow/composer.json b/OrchestrationAirflow/composer.json index 61032ca386ea..348cfc4418a7 100644 --- a/OrchestrationAirflow/composer.json +++ b/OrchestrationAirflow/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/OrchestrationAirflow/src/V1/Client/BaseClient/EnvironmentsBaseClient.php b/OrchestrationAirflow/src/V1/Client/BaseClient/EnvironmentsBaseClient.php deleted file mode 100644 index 874e321759d6..000000000000 --- a/OrchestrationAirflow/src/V1/Client/BaseClient/EnvironmentsBaseClient.php +++ /dev/null @@ -1,570 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/environments_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/environments_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/environments_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/environments_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a environment - * resource. - * - * @param string $project - * @param string $location - * @param string $environment - * - * @return string The formatted environment resource. - */ - public static function environmentName(string $project, string $location, string $environment): string - { - return self::getPathTemplate('environment')->render([ - 'project' => $project, - 'location' => $location, - 'environment' => $environment, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - environment: projects/{project}/locations/{location}/environments/{environment} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'composer.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Create a new environment. - * - * The async variant is {@see self::createEnvironmentAsync()} . - * - * @param CreateEnvironmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createEnvironment(CreateEnvironmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateEnvironment', $request, $callOptions)->wait(); - } - - /** - * Triggers database failover (only for highly resilient environments). - * - * The async variant is {@see self::databaseFailoverAsync()} . - * - * @param DatabaseFailoverRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function databaseFailover(DatabaseFailoverRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DatabaseFailover', $request, $callOptions)->wait(); - } - - /** - * Delete an environment. - * - * The async variant is {@see self::deleteEnvironmentAsync()} . - * - * @param DeleteEnvironmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteEnvironment(DeleteEnvironmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteEnvironment', $request, $callOptions)->wait(); - } - - /** - * Executes Airflow CLI command. - * - * The async variant is {@see self::executeAirflowCommandAsync()} . - * - * @param ExecuteAirflowCommandRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ExecuteAirflowCommandResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function executeAirflowCommand(ExecuteAirflowCommandRequest $request, array $callOptions = []): ExecuteAirflowCommandResponse - { - return $this->startApiCall('ExecuteAirflowCommand', $request, $callOptions)->wait(); - } - - /** - * Fetches database properties. - * - * The async variant is {@see self::fetchDatabasePropertiesAsync()} . - * - * @param FetchDatabasePropertiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FetchDatabasePropertiesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function fetchDatabaseProperties(FetchDatabasePropertiesRequest $request, array $callOptions = []): FetchDatabasePropertiesResponse - { - return $this->startApiCall('FetchDatabaseProperties', $request, $callOptions)->wait(); - } - - /** - * Get an existing environment. - * - * The async variant is {@see self::getEnvironmentAsync()} . - * - * @param GetEnvironmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Environment - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEnvironment(GetEnvironmentRequest $request, array $callOptions = []): Environment - { - return $this->startApiCall('GetEnvironment', $request, $callOptions)->wait(); - } - - /** - * List environments. - * - * The async variant is {@see self::listEnvironmentsAsync()} . - * - * @param ListEnvironmentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listEnvironments(ListEnvironmentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListEnvironments', $request, $callOptions); - } - - /** - * Loads a snapshot of a Cloud Composer environment. - * - * As a result of this operation, a snapshot of environment's specified in - * LoadSnapshotRequest is loaded into the environment. - * - * The async variant is {@see self::loadSnapshotAsync()} . - * - * @param LoadSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function loadSnapshot(LoadSnapshotRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('LoadSnapshot', $request, $callOptions)->wait(); - } - - /** - * Polls Airflow CLI command execution and fetches logs. - * - * The async variant is {@see self::pollAirflowCommandAsync()} . - * - * @param PollAirflowCommandRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PollAirflowCommandResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function pollAirflowCommand(PollAirflowCommandRequest $request, array $callOptions = []): PollAirflowCommandResponse - { - return $this->startApiCall('PollAirflowCommand', $request, $callOptions)->wait(); - } - - /** - * Creates a snapshots of a Cloud Composer environment. - * - * As a result of this operation, snapshot of environment's state is stored - * in a location specified in the SaveSnapshotRequest. - * - * The async variant is {@see self::saveSnapshotAsync()} . - * - * @param SaveSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function saveSnapshot(SaveSnapshotRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SaveSnapshot', $request, $callOptions)->wait(); - } - - /** - * Stops Airflow CLI command execution. - * - * The async variant is {@see self::stopAirflowCommandAsync()} . - * - * @param StopAirflowCommandRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 StopAirflowCommandResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function stopAirflowCommand(StopAirflowCommandRequest $request, array $callOptions = []): StopAirflowCommandResponse - { - return $this->startApiCall('StopAirflowCommand', $request, $callOptions)->wait(); - } - - /** - * Update an environment. - * - * The async variant is {@see self::updateEnvironmentAsync()} . - * - * @param UpdateEnvironmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateEnvironment(UpdateEnvironmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateEnvironment', $request, $callOptions)->wait(); - } -} diff --git a/OrchestrationAirflow/src/V1/Client/BaseClient/ImageVersionsBaseClient.php b/OrchestrationAirflow/src/V1/Client/BaseClient/ImageVersionsBaseClient.php deleted file mode 100644 index 106f01243fea..000000000000 --- a/OrchestrationAirflow/src/V1/Client/BaseClient/ImageVersionsBaseClient.php +++ /dev/null @@ -1,188 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/image_versions_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/image_versions_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/image_versions_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/image_versions_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'composer.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * List ImageVersions for provided location. - * - * The async variant is {@see self::listImageVersionsAsync()} . - * - * @param ListImageVersionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listImageVersions(ListImageVersionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListImageVersions', $request, $callOptions); - } -} diff --git a/OrchestrationAirflow/src/V1/Client/EnvironmentsClient.php b/OrchestrationAirflow/src/V1/Client/EnvironmentsClient.php index 10daba2fad56..a111856c1534 100644 --- a/OrchestrationAirflow/src/V1/Client/EnvironmentsClient.php +++ b/OrchestrationAirflow/src/V1/Client/EnvironmentsClient.php @@ -24,17 +24,545 @@ namespace Google\Cloud\Orchestration\Airflow\Service\V1\Client; -use Google\Cloud\Orchestration\Airflow\Service\V1\Client\BaseClient\EnvironmentsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Orchestration\Airflow\Service\V1\CreateEnvironmentRequest; +use Google\Cloud\Orchestration\Airflow\Service\V1\DatabaseFailoverRequest; +use Google\Cloud\Orchestration\Airflow\Service\V1\DeleteEnvironmentRequest; +use Google\Cloud\Orchestration\Airflow\Service\V1\Environment; +use Google\Cloud\Orchestration\Airflow\Service\V1\ExecuteAirflowCommandRequest; +use Google\Cloud\Orchestration\Airflow\Service\V1\ExecuteAirflowCommandResponse; +use Google\Cloud\Orchestration\Airflow\Service\V1\FetchDatabasePropertiesRequest; +use Google\Cloud\Orchestration\Airflow\Service\V1\FetchDatabasePropertiesResponse; +use Google\Cloud\Orchestration\Airflow\Service\V1\GetEnvironmentRequest; +use Google\Cloud\Orchestration\Airflow\Service\V1\ListEnvironmentsRequest; +use Google\Cloud\Orchestration\Airflow\Service\V1\LoadSnapshotRequest; +use Google\Cloud\Orchestration\Airflow\Service\V1\PollAirflowCommandRequest; +use Google\Cloud\Orchestration\Airflow\Service\V1\PollAirflowCommandResponse; +use Google\Cloud\Orchestration\Airflow\Service\V1\SaveSnapshotRequest; +use Google\Cloud\Orchestration\Airflow\Service\V1\StopAirflowCommandRequest; +use Google\Cloud\Orchestration\Airflow\Service\V1\StopAirflowCommandResponse; +use Google\Cloud\Orchestration\Airflow\Service\V1\UpdateEnvironmentRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Managed Apache Airflow Environments. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Orchestration\Airflow\Service\V1\EnvironmentsClient} for the + * stable implementation * * @experimental + * + * @method PromiseInterface createEnvironmentAsync(CreateEnvironmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface databaseFailoverAsync(DatabaseFailoverRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteEnvironmentAsync(DeleteEnvironmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface executeAirflowCommandAsync(ExecuteAirflowCommandRequest $request, array $optionalArgs = []) + * @method PromiseInterface fetchDatabasePropertiesAsync(FetchDatabasePropertiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEnvironmentAsync(GetEnvironmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface listEnvironmentsAsync(ListEnvironmentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface loadSnapshotAsync(LoadSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface pollAirflowCommandAsync(PollAirflowCommandRequest $request, array $optionalArgs = []) + * @method PromiseInterface saveSnapshotAsync(SaveSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface stopAirflowCommandAsync(StopAirflowCommandRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateEnvironmentAsync(UpdateEnvironmentRequest $request, array $optionalArgs = []) */ -final class EnvironmentsClient extends EnvironmentsBaseClient +final class EnvironmentsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see EnvironmentsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.orchestration.airflow.service.v1.Environments'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'composer.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/environments_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/environments_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/environments_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/environments_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a environment + * resource. + * + * @param string $project + * @param string $location + * @param string $environment + * + * @return string The formatted environment resource. + */ + public static function environmentName(string $project, string $location, string $environment): string + { + return self::getPathTemplate('environment')->render([ + 'project' => $project, + 'location' => $location, + 'environment' => $environment, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - environment: projects/{project}/locations/{location}/environments/{environment} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'composer.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Create a new environment. + * + * The async variant is {@see EnvironmentsClient::createEnvironmentAsync()} . + * + * @param CreateEnvironmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createEnvironment(CreateEnvironmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateEnvironment', $request, $callOptions)->wait(); + } + + /** + * Triggers database failover (only for highly resilient environments). + * + * The async variant is {@see EnvironmentsClient::databaseFailoverAsync()} . + * + * @param DatabaseFailoverRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function databaseFailover(DatabaseFailoverRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DatabaseFailover', $request, $callOptions)->wait(); + } + + /** + * Delete an environment. + * + * The async variant is {@see EnvironmentsClient::deleteEnvironmentAsync()} . + * + * @param DeleteEnvironmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteEnvironment(DeleteEnvironmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteEnvironment', $request, $callOptions)->wait(); + } + + /** + * Executes Airflow CLI command. + * + * The async variant is {@see EnvironmentsClient::executeAirflowCommandAsync()} . + * + * @param ExecuteAirflowCommandRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ExecuteAirflowCommandResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function executeAirflowCommand(ExecuteAirflowCommandRequest $request, array $callOptions = []): ExecuteAirflowCommandResponse + { + return $this->startApiCall('ExecuteAirflowCommand', $request, $callOptions)->wait(); + } + + /** + * Fetches database properties. + * + * The async variant is {@see EnvironmentsClient::fetchDatabasePropertiesAsync()} . + * + * @param FetchDatabasePropertiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FetchDatabasePropertiesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function fetchDatabaseProperties(FetchDatabasePropertiesRequest $request, array $callOptions = []): FetchDatabasePropertiesResponse + { + return $this->startApiCall('FetchDatabaseProperties', $request, $callOptions)->wait(); + } + + /** + * Get an existing environment. + * + * The async variant is {@see EnvironmentsClient::getEnvironmentAsync()} . + * + * @param GetEnvironmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Environment + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEnvironment(GetEnvironmentRequest $request, array $callOptions = []): Environment + { + return $this->startApiCall('GetEnvironment', $request, $callOptions)->wait(); + } + + /** + * List environments. + * + * The async variant is {@see EnvironmentsClient::listEnvironmentsAsync()} . + * + * @param ListEnvironmentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listEnvironments(ListEnvironmentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEnvironments', $request, $callOptions); + } + + /** + * Loads a snapshot of a Cloud Composer environment. + * + * As a result of this operation, a snapshot of environment's specified in + * LoadSnapshotRequest is loaded into the environment. + * + * The async variant is {@see EnvironmentsClient::loadSnapshotAsync()} . + * + * @param LoadSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function loadSnapshot(LoadSnapshotRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('LoadSnapshot', $request, $callOptions)->wait(); + } + + /** + * Polls Airflow CLI command execution and fetches logs. + * + * The async variant is {@see EnvironmentsClient::pollAirflowCommandAsync()} . + * + * @param PollAirflowCommandRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PollAirflowCommandResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function pollAirflowCommand(PollAirflowCommandRequest $request, array $callOptions = []): PollAirflowCommandResponse + { + return $this->startApiCall('PollAirflowCommand', $request, $callOptions)->wait(); + } + + /** + * Creates a snapshots of a Cloud Composer environment. + * + * As a result of this operation, snapshot of environment's state is stored + * in a location specified in the SaveSnapshotRequest. + * + * The async variant is {@see EnvironmentsClient::saveSnapshotAsync()} . + * + * @param SaveSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function saveSnapshot(SaveSnapshotRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SaveSnapshot', $request, $callOptions)->wait(); + } + + /** + * Stops Airflow CLI command execution. + * + * The async variant is {@see EnvironmentsClient::stopAirflowCommandAsync()} . + * + * @param StopAirflowCommandRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 StopAirflowCommandResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function stopAirflowCommand(StopAirflowCommandRequest $request, array $callOptions = []): StopAirflowCommandResponse + { + return $this->startApiCall('StopAirflowCommand', $request, $callOptions)->wait(); + } + + /** + * Update an environment. + * + * The async variant is {@see EnvironmentsClient::updateEnvironmentAsync()} . + * + * @param UpdateEnvironmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateEnvironment(UpdateEnvironmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateEnvironment', $request, $callOptions)->wait(); + } } diff --git a/OrchestrationAirflow/src/V1/Client/ImageVersionsClient.php b/OrchestrationAirflow/src/V1/Client/ImageVersionsClient.php index f38500b454eb..a25c7933f126 100644 --- a/OrchestrationAirflow/src/V1/Client/ImageVersionsClient.php +++ b/OrchestrationAirflow/src/V1/Client/ImageVersionsClient.php @@ -24,17 +24,163 @@ namespace Google\Cloud\Orchestration\Airflow\Service\V1\Client; -use Google\Cloud\Orchestration\Airflow\Service\V1\Client\BaseClient\ImageVersionsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Orchestration\Airflow\Service\V1\ListImageVersionsRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Readonly service to query available ImageVersions. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Orchestration\Airflow\Service\V1\ImageVersionsClient} for the + * stable implementation * * @experimental + * + * @method PromiseInterface listImageVersionsAsync(ListImageVersionsRequest $request, array $optionalArgs = []) */ -final class ImageVersionsClient extends ImageVersionsBaseClient +final class ImageVersionsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ImageVersionsBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.orchestration.airflow.service.v1.ImageVersions'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'composer.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/image_versions_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/image_versions_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/image_versions_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/image_versions_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'composer.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * List ImageVersions for provided location. + * + * The async variant is {@see ImageVersionsClient::listImageVersionsAsync()} . + * + * @param ListImageVersionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listImageVersions(ListImageVersionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListImageVersions', $request, $callOptions); + } } diff --git a/OrgPolicy/composer.json b/OrgPolicy/composer.json index 615a8f0d50d4..349261a6a2f2 100644 --- a/OrgPolicy/composer.json +++ b/OrgPolicy/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/OrgPolicy/src/V2/Client/BaseClient/OrgPolicyBaseClient.php b/OrgPolicy/src/V2/Client/BaseClient/OrgPolicyBaseClient.php deleted file mode 100644 index bdf3320403f5..000000000000 --- a/OrgPolicy/src/V2/Client/BaseClient/OrgPolicyBaseClient.php +++ /dev/null @@ -1,550 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/org_policy_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/org_policy_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/org_policy_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/org_policy_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a folder - * resource. - * - * @param string $folder - * - * @return string The formatted folder resource. - */ - public static function folderName(string $folder): string - { - return self::getPathTemplate('folder')->render([ - 'folder' => $folder, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_policy resource. - * - * @param string $folder - * @param string $policy - * - * @return string The formatted folder_policy resource. - */ - public static function folderPolicyName(string $folder, string $policy): string - { - return self::getPathTemplate('folderPolicy')->render([ - 'folder' => $folder, - 'policy' => $policy, - ]); - } - - /** - * 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(string $organization): string - { - return self::getPathTemplate('organization')->render([ - 'organization' => $organization, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_policy resource. - * - * @param string $organization - * @param string $policy - * - * @return string The formatted organization_policy resource. - */ - public static function organizationPolicyName(string $organization, string $policy): string - { - return self::getPathTemplate('organizationPolicy')->render([ - 'organization' => $organization, - 'policy' => $policy, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a policy - * resource. - * - * @param string $project - * @param string $policy - * - * @return string The formatted policy resource. - */ - public static function policyName(string $project, string $policy): string - { - return self::getPathTemplate('policy')->render([ - 'project' => $project, - 'policy' => $policy, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_policy resource. - * - * @param string $project - * @param string $policy - * - * @return string The formatted project_policy resource. - */ - public static function projectPolicyName(string $project, string $policy): string - { - return self::getPathTemplate('projectPolicy')->render([ - 'project' => $project, - 'policy' => $policy, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - folder: folders/{folder} - * - folderPolicy: folders/{folder}/policies/{policy} - * - organization: organizations/{organization} - * - organizationPolicy: organizations/{organization}/policies/{policy} - * - policy: projects/{project}/policies/{policy} - * - project: projects/{project} - * - projectPolicy: projects/{project}/policies/{policy} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'orgpolicy.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a Policy. - * - * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the - * constraint does not exist. - * Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the - * policy already exists on the given Cloud resource. - * - * The async variant is {@see self::createPolicyAsync()} . - * - * @example samples/V2/OrgPolicyClient/create_policy.php - * - * @param CreatePolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function createPolicy(CreatePolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('CreatePolicy', $request, $callOptions)->wait(); - } - - /** - * Deletes a Policy. - * - * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the - * constraint or Org Policy does not exist. - * - * The async variant is {@see self::deletePolicyAsync()} . - * - * @example samples/V2/OrgPolicyClient/delete_policy.php - * - * @param DeletePolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deletePolicy(DeletePolicyRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeletePolicy', $request, $callOptions)->wait(); - } - - /** - * Gets the effective `Policy` on a resource. This is the result of merging - * `Policies` in the resource hierarchy and evaluating conditions. The - * returned `Policy` will not have an `etag` or `condition` set because it is - * a computed `Policy` across multiple resources. - * Subtrees of Resource Manager resource hierarchy with 'under:' prefix will - * not be expanded. - * - * The async variant is {@see self::getEffectivePolicyAsync()} . - * - * @example samples/V2/OrgPolicyClient/get_effective_policy.php - * - * @param GetEffectivePolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEffectivePolicy(GetEffectivePolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetEffectivePolicy', $request, $callOptions)->wait(); - } - - /** - * Gets a `Policy` on a resource. - * - * If no `Policy` is set on the resource, NOT_FOUND is returned. The - * `etag` value can be used with `UpdatePolicy()` to update a - * `Policy` during read-modify-write. - * - * The async variant is {@see self::getPolicyAsync()} . - * - * @example samples/V2/OrgPolicyClient/get_policy.php - * - * @param GetPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getPolicy(GetPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetPolicy', $request, $callOptions)->wait(); - } - - /** - * Lists `Constraints` that could be applied on the specified resource. - * - * The async variant is {@see self::listConstraintsAsync()} . - * - * @example samples/V2/OrgPolicyClient/list_constraints.php - * - * @param ListConstraintsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listConstraints(ListConstraintsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListConstraints', $request, $callOptions); - } - - /** - * Retrieves all of the `Policies` that exist on a particular resource. - * - * The async variant is {@see self::listPoliciesAsync()} . - * - * @example samples/V2/OrgPolicyClient/list_policies.php - * - * @param ListPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPolicies(ListPoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPolicies', $request, $callOptions); - } - - /** - * Updates a Policy. - * - * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the - * constraint or the policy do not exist. - * Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag - * supplied in the request does not match the persisted etag of the policy - * - * Note: the supplied policy will perform a full overwrite of all - * fields. - * - * The async variant is {@see self::updatePolicyAsync()} . - * - * @example samples/V2/OrgPolicyClient/update_policy.php - * - * @param UpdatePolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function updatePolicy(UpdatePolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('UpdatePolicy', $request, $callOptions)->wait(); - } -} diff --git a/OrgPolicy/src/V2/Client/OrgPolicyClient.php b/OrgPolicy/src/V2/Client/OrgPolicyClient.php index a23a2cdf9f96..f1fcb608df4c 100644 --- a/OrgPolicy/src/V2/Client/OrgPolicyClient.php +++ b/OrgPolicy/src/V2/Client/OrgPolicyClient.php @@ -24,17 +24,525 @@ namespace Google\Cloud\OrgPolicy\V2\Client; -use Google\Cloud\OrgPolicy\V2\Client\BaseClient\OrgPolicyBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\OrgPolicy\V2\CreatePolicyRequest; +use Google\Cloud\OrgPolicy\V2\DeletePolicyRequest; +use Google\Cloud\OrgPolicy\V2\GetEffectivePolicyRequest; +use Google\Cloud\OrgPolicy\V2\GetPolicyRequest; +use Google\Cloud\OrgPolicy\V2\ListConstraintsRequest; +use Google\Cloud\OrgPolicy\V2\ListPoliciesRequest; +use Google\Cloud\OrgPolicy\V2\Policy; +use Google\Cloud\OrgPolicy\V2\UpdatePolicyRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: An interface for managing organization policies. * - * This class is currently experimental and may be subject to changes. + * The Cloud Org Policy service provides a simple mechanism for organizations to + * restrict the allowed configurations across their entire Cloud Resource + * hierarchy. + * + * You can use a `policy` to configure restrictions in Cloud resources. For + * example, you can enforce a `policy` that restricts which Google + * Cloud Platform APIs can be activated in a certain part of your resource + * hierarchy, or prevents serial port access to VM instances in a particular + * folder. + * + * `Policies` are inherited down through the resource hierarchy. A `policy` + * applied to a parent resource automatically applies to all its child resources + * unless overridden with a `policy` lower in the hierarchy. + * + * A `constraint` defines an aspect of a resource's configuration that can be + * controlled by an organization's policy administrator. `Policies` are a + * collection of `constraints` that defines their allowable configuration on a + * particular resource and its child resources. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\OrgPolicy\V2\OrgPolicyClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createPolicyAsync(CreatePolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deletePolicyAsync(DeletePolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEffectivePolicyAsync(GetEffectivePolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getPolicyAsync(GetPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listConstraintsAsync(ListConstraintsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPoliciesAsync(ListPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updatePolicyAsync(UpdatePolicyRequest $request, array $optionalArgs = []) */ -final class OrgPolicyClient extends OrgPolicyBaseClient +final class OrgPolicyClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see OrgPolicyBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.orgpolicy.v2.OrgPolicy'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'orgpolicy.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/org_policy_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/org_policy_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/org_policy_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/org_policy_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a folder + * resource. + * + * @param string $folder + * + * @return string The formatted folder resource. + */ + public static function folderName(string $folder): string + { + return self::getPathTemplate('folder')->render([ + 'folder' => $folder, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_policy resource. + * + * @param string $folder + * @param string $policy + * + * @return string The formatted folder_policy resource. + */ + public static function folderPolicyName(string $folder, string $policy): string + { + return self::getPathTemplate('folderPolicy')->render([ + 'folder' => $folder, + 'policy' => $policy, + ]); + } + + /** + * 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(string $organization): string + { + return self::getPathTemplate('organization')->render([ + 'organization' => $organization, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_policy resource. + * + * @param string $organization + * @param string $policy + * + * @return string The formatted organization_policy resource. + */ + public static function organizationPolicyName(string $organization, string $policy): string + { + return self::getPathTemplate('organizationPolicy')->render([ + 'organization' => $organization, + 'policy' => $policy, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a policy + * resource. + * + * @param string $project + * @param string $policy + * + * @return string The formatted policy resource. + */ + public static function policyName(string $project, string $policy): string + { + return self::getPathTemplate('policy')->render([ + 'project' => $project, + 'policy' => $policy, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_policy resource. + * + * @param string $project + * @param string $policy + * + * @return string The formatted project_policy resource. + */ + public static function projectPolicyName(string $project, string $policy): string + { + return self::getPathTemplate('projectPolicy')->render([ + 'project' => $project, + 'policy' => $policy, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - folder: folders/{folder} + * - folderPolicy: folders/{folder}/policies/{policy} + * - organization: organizations/{organization} + * - organizationPolicy: organizations/{organization}/policies/{policy} + * - policy: projects/{project}/policies/{policy} + * - project: projects/{project} + * - projectPolicy: projects/{project}/policies/{policy} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'orgpolicy.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a Policy. + * + * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the + * constraint does not exist. + * Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the + * policy already exists on the given Cloud resource. + * + * The async variant is {@see OrgPolicyClient::createPolicyAsync()} . + * + * @example samples/V2/OrgPolicyClient/create_policy.php + * + * @param CreatePolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function createPolicy(CreatePolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('CreatePolicy', $request, $callOptions)->wait(); + } + + /** + * Deletes a Policy. + * + * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the + * constraint or Org Policy does not exist. + * + * The async variant is {@see OrgPolicyClient::deletePolicyAsync()} . + * + * @example samples/V2/OrgPolicyClient/delete_policy.php + * + * @param DeletePolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deletePolicy(DeletePolicyRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeletePolicy', $request, $callOptions)->wait(); + } + + /** + * Gets the effective `Policy` on a resource. This is the result of merging + * `Policies` in the resource hierarchy and evaluating conditions. The + * returned `Policy` will not have an `etag` or `condition` set because it is + * a computed `Policy` across multiple resources. + * Subtrees of Resource Manager resource hierarchy with 'under:' prefix will + * not be expanded. + * + * The async variant is {@see OrgPolicyClient::getEffectivePolicyAsync()} . + * + * @example samples/V2/OrgPolicyClient/get_effective_policy.php + * + * @param GetEffectivePolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEffectivePolicy(GetEffectivePolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetEffectivePolicy', $request, $callOptions)->wait(); + } + + /** + * Gets a `Policy` on a resource. + * + * If no `Policy` is set on the resource, NOT_FOUND is returned. The + * `etag` value can be used with `UpdatePolicy()` to update a + * `Policy` during read-modify-write. + * + * The async variant is {@see OrgPolicyClient::getPolicyAsync()} . + * + * @example samples/V2/OrgPolicyClient/get_policy.php + * + * @param GetPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getPolicy(GetPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetPolicy', $request, $callOptions)->wait(); + } + + /** + * Lists `Constraints` that could be applied on the specified resource. + * + * The async variant is {@see OrgPolicyClient::listConstraintsAsync()} . + * + * @example samples/V2/OrgPolicyClient/list_constraints.php + * + * @param ListConstraintsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listConstraints(ListConstraintsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListConstraints', $request, $callOptions); + } + + /** + * Retrieves all of the `Policies` that exist on a particular resource. + * + * The async variant is {@see OrgPolicyClient::listPoliciesAsync()} . + * + * @example samples/V2/OrgPolicyClient/list_policies.php + * + * @param ListPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPolicies(ListPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPolicies', $request, $callOptions); + } + + /** + * Updates a Policy. + * + * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the + * constraint or the policy do not exist. + * Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag + * supplied in the request does not match the persisted etag of the policy + * + * Note: the supplied policy will perform a full overwrite of all + * fields. + * + * The async variant is {@see OrgPolicyClient::updatePolicyAsync()} . + * + * @example samples/V2/OrgPolicyClient/update_policy.php + * + * @param UpdatePolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function updatePolicy(UpdatePolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('UpdatePolicy', $request, $callOptions)->wait(); + } } diff --git a/OsConfig/composer.json b/OsConfig/composer.json index ffe968e23b09..fd3532c64494 100644 --- a/OsConfig/composer.json +++ b/OsConfig/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/OsConfig/src/V1/Client/BaseClient/OsConfigServiceBaseClient.php b/OsConfig/src/V1/Client/BaseClient/OsConfigServiceBaseClient.php deleted file mode 100644 index 3751546cd29e..000000000000 --- a/OsConfig/src/V1/Client/BaseClient/OsConfigServiceBaseClient.php +++ /dev/null @@ -1,562 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/os_config_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/os_config_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/os_config_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/os_config_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * patch_deployment resource. - * - * @param string $project - * @param string $patchDeployment - * - * @return string The formatted patch_deployment resource. - */ - public static function patchDeploymentName(string $project, string $patchDeployment): string - { - return self::getPathTemplate('patchDeployment')->render([ - 'project' => $project, - 'patch_deployment' => $patchDeployment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a patch_job - * resource. - * - * @param string $project - * @param string $patchJob - * - * @return string The formatted patch_job resource. - */ - public static function patchJobName(string $project, string $patchJob): string - { - return self::getPathTemplate('patchJob')->render([ - 'project' => $project, - 'patch_job' => $patchJob, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->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 - * - patchDeployment: projects/{project}/patchDeployments/{patch_deployment} - * - patchJob: projects/{project}/patchJobs/{patch_job} - * - 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. - */ - public static function parseName(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'osconfig.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Cancel a patch job. The patch job must be active. Canceled patch jobs - * cannot be restarted. - * - * The async variant is {@see self::cancelPatchJobAsync()} . - * - * @param CancelPatchJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PatchJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function cancelPatchJob(CancelPatchJobRequest $request, array $callOptions = []): PatchJob - { - return $this->startApiCall('CancelPatchJob', $request, $callOptions)->wait(); - } - - /** - * Create an OS Config patch deployment. - * - * The async variant is {@see self::createPatchDeploymentAsync()} . - * - * @param CreatePatchDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PatchDeployment - * - * @throws ApiException Thrown if the API call fails. - */ - public function createPatchDeployment(CreatePatchDeploymentRequest $request, array $callOptions = []): PatchDeployment - { - return $this->startApiCall('CreatePatchDeployment', $request, $callOptions)->wait(); - } - - /** - * Delete an OS Config patch deployment. - * - * The async variant is {@see self::deletePatchDeploymentAsync()} . - * - * @param DeletePatchDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deletePatchDeployment(DeletePatchDeploymentRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeletePatchDeployment', $request, $callOptions)->wait(); - } - - /** - * Patch VM instances by creating and running a patch job. - * - * The async variant is {@see self::executePatchJobAsync()} . - * - * @param ExecutePatchJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PatchJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function executePatchJob(ExecutePatchJobRequest $request, array $callOptions = []): PatchJob - { - return $this->startApiCall('ExecutePatchJob', $request, $callOptions)->wait(); - } - - /** - * Get an OS Config patch deployment. - * - * The async variant is {@see self::getPatchDeploymentAsync()} . - * - * @param GetPatchDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PatchDeployment - * - * @throws ApiException Thrown if the API call fails. - */ - public function getPatchDeployment(GetPatchDeploymentRequest $request, array $callOptions = []): PatchDeployment - { - return $this->startApiCall('GetPatchDeployment', $request, $callOptions)->wait(); - } - - /** - * Get the patch job. This can be used to track the progress of an - * ongoing patch job or review the details of completed jobs. - * - * The async variant is {@see self::getPatchJobAsync()} . - * - * @param GetPatchJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PatchJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function getPatchJob(GetPatchJobRequest $request, array $callOptions = []): PatchJob - { - return $this->startApiCall('GetPatchJob', $request, $callOptions)->wait(); - } - - /** - * Get a page of OS Config patch deployments. - * - * The async variant is {@see self::listPatchDeploymentsAsync()} . - * - * @param ListPatchDeploymentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPatchDeployments(ListPatchDeploymentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPatchDeployments', $request, $callOptions); - } - - /** - * Get a list of instance details for a given patch job. - * - * The async variant is {@see self::listPatchJobInstanceDetailsAsync()} . - * - * @param ListPatchJobInstanceDetailsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPatchJobInstanceDetails(ListPatchJobInstanceDetailsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPatchJobInstanceDetails', $request, $callOptions); - } - - /** - * Get a list of patch jobs. - * - * The async variant is {@see self::listPatchJobsAsync()} . - * - * @param ListPatchJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPatchJobs(ListPatchJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPatchJobs', $request, $callOptions); - } - - /** - * Change state of patch deployment to "PAUSED". - * Patch deployment in paused state doesn't generate patch jobs. - * - * The async variant is {@see self::pausePatchDeploymentAsync()} . - * - * @param PausePatchDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PatchDeployment - * - * @throws ApiException Thrown if the API call fails. - */ - public function pausePatchDeployment(PausePatchDeploymentRequest $request, array $callOptions = []): PatchDeployment - { - return $this->startApiCall('PausePatchDeployment', $request, $callOptions)->wait(); - } - - /** - * Change state of patch deployment back to "ACTIVE". - * Patch deployment in active state continues to generate patch jobs. - * - * The async variant is {@see self::resumePatchDeploymentAsync()} . - * - * @param ResumePatchDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PatchDeployment - * - * @throws ApiException Thrown if the API call fails. - */ - public function resumePatchDeployment(ResumePatchDeploymentRequest $request, array $callOptions = []): PatchDeployment - { - return $this->startApiCall('ResumePatchDeployment', $request, $callOptions)->wait(); - } - - /** - * Update an OS Config patch deployment. - * - * The async variant is {@see self::updatePatchDeploymentAsync()} . - * - * @param UpdatePatchDeploymentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PatchDeployment - * - * @throws ApiException Thrown if the API call fails. - */ - public function updatePatchDeployment(UpdatePatchDeploymentRequest $request, array $callOptions = []): PatchDeployment - { - return $this->startApiCall('UpdatePatchDeployment', $request, $callOptions)->wait(); - } -} diff --git a/OsConfig/src/V1/Client/BaseClient/OsConfigZonalServiceBaseClient.php b/OsConfig/src/V1/Client/BaseClient/OsConfigZonalServiceBaseClient.php deleted file mode 100644 index a1a240121a28..000000000000 --- a/OsConfig/src/V1/Client/BaseClient/OsConfigZonalServiceBaseClient.php +++ /dev/null @@ -1,765 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/os_config_zonal_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/os_config_zonal_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/os_config_zonal_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/os_config_zonal_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a instance - * resource. - * - * @param string $project - * @param string $zone - * @param string $instance - * - * @return string The formatted instance resource. - */ - public static function instanceName(string $project, string $zone, string $instance): string - { - return self::getPathTemplate('instance')->render([ - 'project' => $project, - 'zone' => $zone, - 'instance' => $instance, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * instance_os_policy_assignment resource. - * - * @param string $project - * @param string $location - * @param string $instance - * @param string $assignment - * - * @return string The formatted instance_os_policy_assignment resource. - */ - public static function instanceOSPolicyAssignmentName(string $project, string $location, string $instance, string $assignment): string - { - return self::getPathTemplate('instanceOSPolicyAssignment')->render([ - 'project' => $project, - 'location' => $location, - 'instance' => $instance, - 'assignment' => $assignment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a inventory - * resource. - * - * @param string $project - * @param string $location - * @param string $instance - * - * @return string The formatted inventory resource. - */ - public static function inventoryName(string $project, string $location, string $instance): string - { - return self::getPathTemplate('inventory')->render([ - 'project' => $project, - 'location' => $location, - 'instance' => $instance, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * os_policy_assignment resource. - * - * @param string $project - * @param string $location - * @param string $osPolicyAssignment - * - * @return string The formatted os_policy_assignment resource. - */ - public static function oSPolicyAssignmentName(string $project, string $location, string $osPolicyAssignment): string - { - return self::getPathTemplate('oSPolicyAssignment')->render([ - 'project' => $project, - 'location' => $location, - 'os_policy_assignment' => $osPolicyAssignment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * os_policy_assignment_report resource. - * - * @param string $project - * @param string $location - * @param string $instance - * @param string $assignment - * - * @return string The formatted os_policy_assignment_report resource. - */ - public static function oSPolicyAssignmentReportName(string $project, string $location, string $instance, string $assignment): string - { - return self::getPathTemplate('oSPolicyAssignmentReport')->render([ - 'project' => $project, - 'location' => $location, - 'instance' => $instance, - 'assignment' => $assignment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_instance resource. - * - * @param string $project - * @param string $location - * @param string $instance - * - * @return string The formatted project_location_instance resource. - */ - public static function projectLocationInstanceName(string $project, string $location, string $instance): string - { - return self::getPathTemplate('projectLocationInstance')->render([ - 'project' => $project, - 'location' => $location, - 'instance' => $instance, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_zone_instance resource. - * - * @param string $project - * @param string $zone - * @param string $instance - * - * @return string The formatted project_zone_instance resource. - */ - public static function projectZoneInstanceName(string $project, string $zone, string $instance): string - { - return self::getPathTemplate('projectZoneInstance')->render([ - 'project' => $project, - 'zone' => $zone, - 'instance' => $instance, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * vulnerability_report resource. - * - * @param string $project - * @param string $location - * @param string $instance - * - * @return string The formatted vulnerability_report resource. - */ - public static function vulnerabilityReportName(string $project, string $location, string $instance): string - { - return self::getPathTemplate('vulnerabilityReport')->render([ - 'project' => $project, - 'location' => $location, - 'instance' => $instance, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - instance: projects/{project}/zones/{zone}/instances/{instance} - * - instanceOSPolicyAssignment: projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment} - * - inventory: projects/{project}/locations/{location}/instances/{instance}/inventory - * - location: projects/{project}/locations/{location} - * - oSPolicyAssignment: projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment} - * - oSPolicyAssignmentReport: projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report - * - projectLocationInstance: projects/{project}/locations/{location}/instances/{instance} - * - projectZoneInstance: projects/{project}/zones/{zone}/instances/{instance} - * - vulnerabilityReport: projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'osconfig.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Create an OS policy assignment. - * - * This method also creates the first revision of the OS policy assignment. - * - * This method returns a long running operation (LRO) that contains the - * rollout details. The rollout can be cancelled by cancelling the LRO. - * - * For more information, see [Method: - * projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel). - * - * The async variant is {@see self::createOSPolicyAssignmentAsync()} . - * - * @param CreateOSPolicyAssignmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createOSPolicyAssignment(CreateOSPolicyAssignmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateOSPolicyAssignment', $request, $callOptions)->wait(); - } - - /** - * Delete the OS policy assignment. - * - * This method creates a new revision of the OS policy assignment. - * - * This method returns a long running operation (LRO) that contains the - * rollout details. The rollout can be cancelled by cancelling the LRO. - * - * If the LRO completes and is not cancelled, all revisions associated with - * the OS policy assignment are deleted. - * - * For more information, see [Method: - * projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel). - * - * The async variant is {@see self::deleteOSPolicyAssignmentAsync()} . - * - * @param DeleteOSPolicyAssignmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteOSPolicyAssignment(DeleteOSPolicyAssignmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteOSPolicyAssignment', $request, $callOptions)->wait(); - } - - /** - * Get inventory data for the specified VM instance. If the VM has no - * associated inventory, the message `NOT_FOUND` is returned. - * - * The async variant is {@see self::getInventoryAsync()} . - * - * @param GetInventoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Inventory - * - * @throws ApiException Thrown if the API call fails. - */ - public function getInventory(GetInventoryRequest $request, array $callOptions = []): Inventory - { - return $this->startApiCall('GetInventory', $request, $callOptions)->wait(); - } - - /** - * Retrieve an existing OS policy assignment. - * - * This method always returns the latest revision. In order to retrieve a - * previous revision of the assignment, also provide the revision ID in the - * `name` parameter. - * - * The async variant is {@see self::getOSPolicyAssignmentAsync()} . - * - * @param GetOSPolicyAssignmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OSPolicyAssignment - * - * @throws ApiException Thrown if the API call fails. - */ - public function getOSPolicyAssignment(GetOSPolicyAssignmentRequest $request, array $callOptions = []): OSPolicyAssignment - { - return $this->startApiCall('GetOSPolicyAssignment', $request, $callOptions)->wait(); - } - - /** - * Get the OS policy asssignment report for the specified Compute Engine VM - * instance. - * - * The async variant is {@see self::getOSPolicyAssignmentReportAsync()} . - * - * @param GetOSPolicyAssignmentReportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OSPolicyAssignmentReport - * - * @throws ApiException Thrown if the API call fails. - */ - public function getOSPolicyAssignmentReport(GetOSPolicyAssignmentReportRequest $request, array $callOptions = []): OSPolicyAssignmentReport - { - return $this->startApiCall('GetOSPolicyAssignmentReport', $request, $callOptions)->wait(); - } - - /** - * Gets the vulnerability report for the specified VM instance. Only VMs with - * inventory data have vulnerability reports associated with them. - * - * The async variant is {@see self::getVulnerabilityReportAsync()} . - * - * @param GetVulnerabilityReportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 VulnerabilityReport - * - * @throws ApiException Thrown if the API call fails. - */ - public function getVulnerabilityReport(GetVulnerabilityReportRequest $request, array $callOptions = []): VulnerabilityReport - { - return $this->startApiCall('GetVulnerabilityReport', $request, $callOptions)->wait(); - } - - /** - * List inventory data for all VM instances in the specified zone. - * - * The async variant is {@see self::listInventoriesAsync()} . - * - * @param ListInventoriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listInventories(ListInventoriesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListInventories', $request, $callOptions); - } - - /** - * List OS policy asssignment reports for all Compute Engine VM instances in - * the specified zone. - * - * The async variant is {@see self::listOSPolicyAssignmentReportsAsync()} . - * - * @param ListOSPolicyAssignmentReportsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listOSPolicyAssignmentReports(ListOSPolicyAssignmentReportsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListOSPolicyAssignmentReports', $request, $callOptions); - } - - /** - * List the OS policy assignment revisions for a given OS policy assignment. - * - * The async variant is {@see self::listOSPolicyAssignmentRevisionsAsync()} . - * - * @param ListOSPolicyAssignmentRevisionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listOSPolicyAssignmentRevisions(ListOSPolicyAssignmentRevisionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListOSPolicyAssignmentRevisions', $request, $callOptions); - } - - /** - * List the OS policy assignments under the parent resource. - * - * For each OS policy assignment, the latest revision is returned. - * - * The async variant is {@see self::listOSPolicyAssignmentsAsync()} . - * - * @param ListOSPolicyAssignmentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listOSPolicyAssignments(ListOSPolicyAssignmentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListOSPolicyAssignments', $request, $callOptions); - } - - /** - * List vulnerability reports for all VM instances in the specified zone. - * - * The async variant is {@see self::listVulnerabilityReportsAsync()} . - * - * @param ListVulnerabilityReportsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listVulnerabilityReports(ListVulnerabilityReportsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListVulnerabilityReports', $request, $callOptions); - } - - /** - * Update an existing OS policy assignment. - * - * This method creates a new revision of the OS policy assignment. - * - * This method returns a long running operation (LRO) that contains the - * rollout details. The rollout can be cancelled by cancelling the LRO. - * - * For more information, see [Method: - * projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel). - * - * The async variant is {@see self::updateOSPolicyAssignmentAsync()} . - * - * @param UpdateOSPolicyAssignmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateOSPolicyAssignment(UpdateOSPolicyAssignmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateOSPolicyAssignment', $request, $callOptions)->wait(); - } -} diff --git a/OsConfig/src/V1/Client/OsConfigServiceClient.php b/OsConfig/src/V1/Client/OsConfigServiceClient.php index 3a8b4f944027..edc8011a4d06 100644 --- a/OsConfig/src/V1/Client/OsConfigServiceClient.php +++ b/OsConfig/src/V1/Client/OsConfigServiceClient.php @@ -24,17 +24,542 @@ namespace Google\Cloud\OsConfig\V1\Client; -use Google\Cloud\OsConfig\V1\Client\BaseClient\OsConfigServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\OsConfig\V1\CancelPatchJobRequest; +use Google\Cloud\OsConfig\V1\CreatePatchDeploymentRequest; +use Google\Cloud\OsConfig\V1\DeletePatchDeploymentRequest; +use Google\Cloud\OsConfig\V1\ExecutePatchJobRequest; +use Google\Cloud\OsConfig\V1\GetPatchDeploymentRequest; +use Google\Cloud\OsConfig\V1\GetPatchJobRequest; +use Google\Cloud\OsConfig\V1\ListPatchDeploymentsRequest; +use Google\Cloud\OsConfig\V1\ListPatchJobInstanceDetailsRequest; +use Google\Cloud\OsConfig\V1\ListPatchJobsRequest; +use Google\Cloud\OsConfig\V1\PatchDeployment; +use Google\Cloud\OsConfig\V1\PatchJob; +use Google\Cloud\OsConfig\V1\PausePatchDeploymentRequest; +use Google\Cloud\OsConfig\V1\ResumePatchDeploymentRequest; +use Google\Cloud\OsConfig\V1\UpdatePatchDeploymentRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: OS Config API * - * This class is currently experimental and may be subject to changes. + * The OS Config service is a server-side component that you can use to + * manage package installations and patch jobs for virtual machine instances. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\OsConfig\V1\OsConfigServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface cancelPatchJobAsync(CancelPatchJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface createPatchDeploymentAsync(CreatePatchDeploymentRequest $request, array $optionalArgs = []) + * @method PromiseInterface deletePatchDeploymentAsync(DeletePatchDeploymentRequest $request, array $optionalArgs = []) + * @method PromiseInterface executePatchJobAsync(ExecutePatchJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getPatchDeploymentAsync(GetPatchDeploymentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getPatchJobAsync(GetPatchJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPatchDeploymentsAsync(ListPatchDeploymentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPatchJobInstanceDetailsAsync(ListPatchJobInstanceDetailsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPatchJobsAsync(ListPatchJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface pausePatchDeploymentAsync(PausePatchDeploymentRequest $request, array $optionalArgs = []) + * @method PromiseInterface resumePatchDeploymentAsync(ResumePatchDeploymentRequest $request, array $optionalArgs = []) + * @method PromiseInterface updatePatchDeploymentAsync(UpdatePatchDeploymentRequest $request, array $optionalArgs = []) */ -class OsConfigServiceClient extends OsConfigServiceBaseClient +class OsConfigServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see OsConfigServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.osconfig.v1.OsConfigService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'osconfig.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/os_config_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/os_config_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/os_config_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/os_config_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * patch_deployment resource. + * + * @param string $project + * @param string $patchDeployment + * + * @return string The formatted patch_deployment resource. + */ + public static function patchDeploymentName(string $project, string $patchDeployment): string + { + return self::getPathTemplate('patchDeployment')->render([ + 'project' => $project, + 'patch_deployment' => $patchDeployment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a patch_job + * resource. + * + * @param string $project + * @param string $patchJob + * + * @return string The formatted patch_job resource. + */ + public static function patchJobName(string $project, string $patchJob): string + { + return self::getPathTemplate('patchJob')->render([ + 'project' => $project, + 'patch_job' => $patchJob, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->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 + * - patchDeployment: projects/{project}/patchDeployments/{patch_deployment} + * - patchJob: projects/{project}/patchJobs/{patch_job} + * - 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. + */ + public static function parseName(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'osconfig.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Cancel a patch job. The patch job must be active. Canceled patch jobs + * cannot be restarted. + * + * The async variant is {@see OsConfigServiceClient::cancelPatchJobAsync()} . + * + * @param CancelPatchJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PatchJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function cancelPatchJob(CancelPatchJobRequest $request, array $callOptions = []): PatchJob + { + return $this->startApiCall('CancelPatchJob', $request, $callOptions)->wait(); + } + + /** + * Create an OS Config patch deployment. + * + * The async variant is {@see OsConfigServiceClient::createPatchDeploymentAsync()} + * . + * + * @param CreatePatchDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PatchDeployment + * + * @throws ApiException Thrown if the API call fails. + */ + public function createPatchDeployment(CreatePatchDeploymentRequest $request, array $callOptions = []): PatchDeployment + { + return $this->startApiCall('CreatePatchDeployment', $request, $callOptions)->wait(); + } + + /** + * Delete an OS Config patch deployment. + * + * The async variant is {@see OsConfigServiceClient::deletePatchDeploymentAsync()} + * . + * + * @param DeletePatchDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deletePatchDeployment(DeletePatchDeploymentRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeletePatchDeployment', $request, $callOptions)->wait(); + } + + /** + * Patch VM instances by creating and running a patch job. + * + * The async variant is {@see OsConfigServiceClient::executePatchJobAsync()} . + * + * @param ExecutePatchJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PatchJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function executePatchJob(ExecutePatchJobRequest $request, array $callOptions = []): PatchJob + { + return $this->startApiCall('ExecutePatchJob', $request, $callOptions)->wait(); + } + + /** + * Get an OS Config patch deployment. + * + * The async variant is {@see OsConfigServiceClient::getPatchDeploymentAsync()} . + * + * @param GetPatchDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PatchDeployment + * + * @throws ApiException Thrown if the API call fails. + */ + public function getPatchDeployment(GetPatchDeploymentRequest $request, array $callOptions = []): PatchDeployment + { + return $this->startApiCall('GetPatchDeployment', $request, $callOptions)->wait(); + } + + /** + * Get the patch job. This can be used to track the progress of an + * ongoing patch job or review the details of completed jobs. + * + * The async variant is {@see OsConfigServiceClient::getPatchJobAsync()} . + * + * @param GetPatchJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PatchJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function getPatchJob(GetPatchJobRequest $request, array $callOptions = []): PatchJob + { + return $this->startApiCall('GetPatchJob', $request, $callOptions)->wait(); + } + + /** + * Get a page of OS Config patch deployments. + * + * The async variant is {@see OsConfigServiceClient::listPatchDeploymentsAsync()} . + * + * @param ListPatchDeploymentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPatchDeployments(ListPatchDeploymentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPatchDeployments', $request, $callOptions); + } + + /** + * Get a list of instance details for a given patch job. + * + * The async variant is + * {@see OsConfigServiceClient::listPatchJobInstanceDetailsAsync()} . + * + * @param ListPatchJobInstanceDetailsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPatchJobInstanceDetails(ListPatchJobInstanceDetailsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPatchJobInstanceDetails', $request, $callOptions); + } + + /** + * Get a list of patch jobs. + * + * The async variant is {@see OsConfigServiceClient::listPatchJobsAsync()} . + * + * @param ListPatchJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPatchJobs(ListPatchJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPatchJobs', $request, $callOptions); + } + + /** + * Change state of patch deployment to "PAUSED". + * Patch deployment in paused state doesn't generate patch jobs. + * + * The async variant is {@see OsConfigServiceClient::pausePatchDeploymentAsync()} . + * + * @param PausePatchDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PatchDeployment + * + * @throws ApiException Thrown if the API call fails. + */ + public function pausePatchDeployment(PausePatchDeploymentRequest $request, array $callOptions = []): PatchDeployment + { + return $this->startApiCall('PausePatchDeployment', $request, $callOptions)->wait(); + } + + /** + * Change state of patch deployment back to "ACTIVE". + * Patch deployment in active state continues to generate patch jobs. + * + * The async variant is {@see OsConfigServiceClient::resumePatchDeploymentAsync()} + * . + * + * @param ResumePatchDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PatchDeployment + * + * @throws ApiException Thrown if the API call fails. + */ + public function resumePatchDeployment(ResumePatchDeploymentRequest $request, array $callOptions = []): PatchDeployment + { + return $this->startApiCall('ResumePatchDeployment', $request, $callOptions)->wait(); + } + + /** + * Update an OS Config patch deployment. + * + * The async variant is {@see OsConfigServiceClient::updatePatchDeploymentAsync()} + * . + * + * @param UpdatePatchDeploymentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PatchDeployment + * + * @throws ApiException Thrown if the API call fails. + */ + public function updatePatchDeployment(UpdatePatchDeploymentRequest $request, array $callOptions = []): PatchDeployment + { + return $this->startApiCall('UpdatePatchDeployment', $request, $callOptions)->wait(); + } } diff --git a/OsConfig/src/V1/Client/OsConfigZonalServiceClient.php b/OsConfig/src/V1/Client/OsConfigZonalServiceClient.php index 6ceee849f94e..041ec32c5378 100644 --- a/OsConfig/src/V1/Client/OsConfigZonalServiceClient.php +++ b/OsConfig/src/V1/Client/OsConfigZonalServiceClient.php @@ -24,17 +24,750 @@ namespace Google\Cloud\OsConfig\V1\Client; -use Google\Cloud\OsConfig\V1\Client\BaseClient\OsConfigZonalServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\OsConfig\V1\CreateOSPolicyAssignmentRequest; +use Google\Cloud\OsConfig\V1\DeleteOSPolicyAssignmentRequest; +use Google\Cloud\OsConfig\V1\GetInventoryRequest; +use Google\Cloud\OsConfig\V1\GetOSPolicyAssignmentReportRequest; +use Google\Cloud\OsConfig\V1\GetOSPolicyAssignmentRequest; +use Google\Cloud\OsConfig\V1\GetVulnerabilityReportRequest; +use Google\Cloud\OsConfig\V1\Inventory; +use Google\Cloud\OsConfig\V1\ListInventoriesRequest; +use Google\Cloud\OsConfig\V1\ListOSPolicyAssignmentReportsRequest; +use Google\Cloud\OsConfig\V1\ListOSPolicyAssignmentRevisionsRequest; +use Google\Cloud\OsConfig\V1\ListOSPolicyAssignmentsRequest; +use Google\Cloud\OsConfig\V1\ListVulnerabilityReportsRequest; +use Google\Cloud\OsConfig\V1\OSPolicyAssignment; +use Google\Cloud\OsConfig\V1\OSPolicyAssignmentReport; +use Google\Cloud\OsConfig\V1\UpdateOSPolicyAssignmentRequest; +use Google\Cloud\OsConfig\V1\VulnerabilityReport; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Zonal OS Config API * - * This class is currently experimental and may be subject to changes. + * The OS Config service is the server-side component that allows users to + * manage package installations and patch jobs for Compute Engine VM instances. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\OsConfig\V1\OsConfigZonalServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createOSPolicyAssignmentAsync(CreateOSPolicyAssignmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteOSPolicyAssignmentAsync(DeleteOSPolicyAssignmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInventoryAsync(GetInventoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface getOSPolicyAssignmentAsync(GetOSPolicyAssignmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getOSPolicyAssignmentReportAsync(GetOSPolicyAssignmentReportRequest $request, array $optionalArgs = []) + * @method PromiseInterface getVulnerabilityReportAsync(GetVulnerabilityReportRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInventoriesAsync(ListInventoriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listOSPolicyAssignmentReportsAsync(ListOSPolicyAssignmentReportsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listOSPolicyAssignmentRevisionsAsync(ListOSPolicyAssignmentRevisionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listOSPolicyAssignmentsAsync(ListOSPolicyAssignmentsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listVulnerabilityReportsAsync(ListVulnerabilityReportsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateOSPolicyAssignmentAsync(UpdateOSPolicyAssignmentRequest $request, array $optionalArgs = []) */ -class OsConfigZonalServiceClient extends OsConfigZonalServiceBaseClient +class OsConfigZonalServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see OsConfigZonalServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.osconfig.v1.OsConfigZonalService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'osconfig.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/os_config_zonal_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/os_config_zonal_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/os_config_zonal_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/os_config_zonal_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a instance + * resource. + * + * @param string $project + * @param string $zone + * @param string $instance + * + * @return string The formatted instance resource. + */ + public static function instanceName(string $project, string $zone, string $instance): string + { + return self::getPathTemplate('instance')->render([ + 'project' => $project, + 'zone' => $zone, + 'instance' => $instance, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * instance_os_policy_assignment resource. + * + * @param string $project + * @param string $location + * @param string $instance + * @param string $assignment + * + * @return string The formatted instance_os_policy_assignment resource. + */ + public static function instanceOSPolicyAssignmentName(string $project, string $location, string $instance, string $assignment): string + { + return self::getPathTemplate('instanceOSPolicyAssignment')->render([ + 'project' => $project, + 'location' => $location, + 'instance' => $instance, + 'assignment' => $assignment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a inventory + * resource. + * + * @param string $project + * @param string $location + * @param string $instance + * + * @return string The formatted inventory resource. + */ + public static function inventoryName(string $project, string $location, string $instance): string + { + return self::getPathTemplate('inventory')->render([ + 'project' => $project, + 'location' => $location, + 'instance' => $instance, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * os_policy_assignment resource. + * + * @param string $project + * @param string $location + * @param string $osPolicyAssignment + * + * @return string The formatted os_policy_assignment resource. + */ + public static function oSPolicyAssignmentName(string $project, string $location, string $osPolicyAssignment): string + { + return self::getPathTemplate('oSPolicyAssignment')->render([ + 'project' => $project, + 'location' => $location, + 'os_policy_assignment' => $osPolicyAssignment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * os_policy_assignment_report resource. + * + * @param string $project + * @param string $location + * @param string $instance + * @param string $assignment + * + * @return string The formatted os_policy_assignment_report resource. + */ + public static function oSPolicyAssignmentReportName(string $project, string $location, string $instance, string $assignment): string + { + return self::getPathTemplate('oSPolicyAssignmentReport')->render([ + 'project' => $project, + 'location' => $location, + 'instance' => $instance, + 'assignment' => $assignment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_instance resource. + * + * @param string $project + * @param string $location + * @param string $instance + * + * @return string The formatted project_location_instance resource. + */ + public static function projectLocationInstanceName(string $project, string $location, string $instance): string + { + return self::getPathTemplate('projectLocationInstance')->render([ + 'project' => $project, + 'location' => $location, + 'instance' => $instance, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_zone_instance resource. + * + * @param string $project + * @param string $zone + * @param string $instance + * + * @return string The formatted project_zone_instance resource. + */ + public static function projectZoneInstanceName(string $project, string $zone, string $instance): string + { + return self::getPathTemplate('projectZoneInstance')->render([ + 'project' => $project, + 'zone' => $zone, + 'instance' => $instance, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * vulnerability_report resource. + * + * @param string $project + * @param string $location + * @param string $instance + * + * @return string The formatted vulnerability_report resource. + */ + public static function vulnerabilityReportName(string $project, string $location, string $instance): string + { + return self::getPathTemplate('vulnerabilityReport')->render([ + 'project' => $project, + 'location' => $location, + 'instance' => $instance, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - instance: projects/{project}/zones/{zone}/instances/{instance} + * - instanceOSPolicyAssignment: projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment} + * - inventory: projects/{project}/locations/{location}/instances/{instance}/inventory + * - location: projects/{project}/locations/{location} + * - oSPolicyAssignment: projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment} + * - oSPolicyAssignmentReport: projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report + * - projectLocationInstance: projects/{project}/locations/{location}/instances/{instance} + * - projectZoneInstance: projects/{project}/zones/{zone}/instances/{instance} + * - vulnerabilityReport: projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'osconfig.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Create an OS policy assignment. + * + * This method also creates the first revision of the OS policy assignment. + * + * This method returns a long running operation (LRO) that contains the + * rollout details. The rollout can be cancelled by cancelling the LRO. + * + * For more information, see [Method: + * projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel). + * + * The async variant is + * {@see OsConfigZonalServiceClient::createOSPolicyAssignmentAsync()} . + * + * @param CreateOSPolicyAssignmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createOSPolicyAssignment(CreateOSPolicyAssignmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateOSPolicyAssignment', $request, $callOptions)->wait(); + } + + /** + * Delete the OS policy assignment. + * + * This method creates a new revision of the OS policy assignment. + * + * This method returns a long running operation (LRO) that contains the + * rollout details. The rollout can be cancelled by cancelling the LRO. + * + * If the LRO completes and is not cancelled, all revisions associated with + * the OS policy assignment are deleted. + * + * For more information, see [Method: + * projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel). + * + * The async variant is + * {@see OsConfigZonalServiceClient::deleteOSPolicyAssignmentAsync()} . + * + * @param DeleteOSPolicyAssignmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteOSPolicyAssignment(DeleteOSPolicyAssignmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteOSPolicyAssignment', $request, $callOptions)->wait(); + } + + /** + * Get inventory data for the specified VM instance. If the VM has no + * associated inventory, the message `NOT_FOUND` is returned. + * + * The async variant is {@see OsConfigZonalServiceClient::getInventoryAsync()} . + * + * @param GetInventoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Inventory + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInventory(GetInventoryRequest $request, array $callOptions = []): Inventory + { + return $this->startApiCall('GetInventory', $request, $callOptions)->wait(); + } + + /** + * Retrieve an existing OS policy assignment. + * + * This method always returns the latest revision. In order to retrieve a + * previous revision of the assignment, also provide the revision ID in the + * `name` parameter. + * + * The async variant is + * {@see OsConfigZonalServiceClient::getOSPolicyAssignmentAsync()} . + * + * @param GetOSPolicyAssignmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OSPolicyAssignment + * + * @throws ApiException Thrown if the API call fails. + */ + public function getOSPolicyAssignment(GetOSPolicyAssignmentRequest $request, array $callOptions = []): OSPolicyAssignment + { + return $this->startApiCall('GetOSPolicyAssignment', $request, $callOptions)->wait(); + } + + /** + * Get the OS policy asssignment report for the specified Compute Engine VM + * instance. + * + * The async variant is + * {@see OsConfigZonalServiceClient::getOSPolicyAssignmentReportAsync()} . + * + * @param GetOSPolicyAssignmentReportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OSPolicyAssignmentReport + * + * @throws ApiException Thrown if the API call fails. + */ + public function getOSPolicyAssignmentReport(GetOSPolicyAssignmentReportRequest $request, array $callOptions = []): OSPolicyAssignmentReport + { + return $this->startApiCall('GetOSPolicyAssignmentReport', $request, $callOptions)->wait(); + } + + /** + * Gets the vulnerability report for the specified VM instance. Only VMs with + * inventory data have vulnerability reports associated with them. + * + * The async variant is + * {@see OsConfigZonalServiceClient::getVulnerabilityReportAsync()} . + * + * @param GetVulnerabilityReportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 VulnerabilityReport + * + * @throws ApiException Thrown if the API call fails. + */ + public function getVulnerabilityReport(GetVulnerabilityReportRequest $request, array $callOptions = []): VulnerabilityReport + { + return $this->startApiCall('GetVulnerabilityReport', $request, $callOptions)->wait(); + } + + /** + * List inventory data for all VM instances in the specified zone. + * + * The async variant is {@see OsConfigZonalServiceClient::listInventoriesAsync()} . + * + * @param ListInventoriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInventories(ListInventoriesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInventories', $request, $callOptions); + } + + /** + * List OS policy asssignment reports for all Compute Engine VM instances in + * the specified zone. + * + * The async variant is + * {@see OsConfigZonalServiceClient::listOSPolicyAssignmentReportsAsync()} . + * + * @param ListOSPolicyAssignmentReportsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listOSPolicyAssignmentReports(ListOSPolicyAssignmentReportsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListOSPolicyAssignmentReports', $request, $callOptions); + } + + /** + * List the OS policy assignment revisions for a given OS policy assignment. + * + * The async variant is + * {@see OsConfigZonalServiceClient::listOSPolicyAssignmentRevisionsAsync()} . + * + * @param ListOSPolicyAssignmentRevisionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listOSPolicyAssignmentRevisions(ListOSPolicyAssignmentRevisionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListOSPolicyAssignmentRevisions', $request, $callOptions); + } + + /** + * List the OS policy assignments under the parent resource. + * + * For each OS policy assignment, the latest revision is returned. + * + * The async variant is + * {@see OsConfigZonalServiceClient::listOSPolicyAssignmentsAsync()} . + * + * @param ListOSPolicyAssignmentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listOSPolicyAssignments(ListOSPolicyAssignmentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListOSPolicyAssignments', $request, $callOptions); + } + + /** + * List vulnerability reports for all VM instances in the specified zone. + * + * The async variant is + * {@see OsConfigZonalServiceClient::listVulnerabilityReportsAsync()} . + * + * @param ListVulnerabilityReportsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listVulnerabilityReports(ListVulnerabilityReportsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListVulnerabilityReports', $request, $callOptions); + } + + /** + * Update an existing OS policy assignment. + * + * This method creates a new revision of the OS policy assignment. + * + * This method returns a long running operation (LRO) that contains the + * rollout details. The rollout can be cancelled by cancelling the LRO. + * + * For more information, see [Method: + * projects.locations.osPolicyAssignments.operations.cancel](https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.osPolicyAssignments.operations/cancel). + * + * The async variant is + * {@see OsConfigZonalServiceClient::updateOSPolicyAssignmentAsync()} . + * + * @param UpdateOSPolicyAssignmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateOSPolicyAssignment(UpdateOSPolicyAssignmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateOSPolicyAssignment', $request, $callOptions)->wait(); + } } diff --git a/OsLogin/composer.json b/OsLogin/composer.json index 4193675d80e7..cb055787aa72 100644 --- a/OsLogin/composer.json +++ b/OsLogin/composer.json @@ -19,11 +19,11 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", - "google/cloud-core": "^1.39" + "google/cloud-core": "^1.52.7" }, "suggest": { "ext-protobuf": "Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions." diff --git a/OsLogin/src/V1/Client/BaseClient/OsLoginServiceBaseClient.php b/OsLogin/src/V1/Client/BaseClient/OsLoginServiceBaseClient.php deleted file mode 100644 index 80a73e938835..000000000000 --- a/OsLogin/src/V1/Client/BaseClient/OsLoginServiceBaseClient.php +++ /dev/null @@ -1,433 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/os_login_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/os_login_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/os_login_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/os_login_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * posix_account resource. - * - * @param string $user - * @param string $project - * - * @return string The formatted posix_account resource. - */ - public static function posixAccountName(string $user, string $project): string - { - return self::getPathTemplate('posixAccount')->render([ - 'user' => $user, - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * ssh_public_key resource. - * - * @param string $user - * @param string $fingerprint - * - * @return string The formatted ssh_public_key resource. - */ - public static function sshPublicKeyName(string $user, string $fingerprint): string - { - return self::getPathTemplate('sshPublicKey')->render([ - 'user' => $user, - 'fingerprint' => $fingerprint, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a user - * resource. - * - * @param string $user - * - * @return string The formatted user resource. - */ - public static function userName(string $user): string - { - return self::getPathTemplate('user')->render([ - 'user' => $user, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - posixAccount: users/{user}/projects/{project} - * - sshPublicKey: users/{user}/sshPublicKeys/{fingerprint} - * - user: users/{user} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'oslogin.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Create an SSH public key - * - * The async variant is {@see self::createSshPublicKeyAsync()} . - * - * @param CreateSshPublicKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SshPublicKey - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSshPublicKey(CreateSshPublicKeyRequest $request, array $callOptions = []): SshPublicKey - { - return $this->startApiCall('CreateSshPublicKey', $request, $callOptions)->wait(); - } - - /** - * Deletes a POSIX account. - * - * The async variant is {@see self::deletePosixAccountAsync()} . - * - * @param DeletePosixAccountRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deletePosixAccount(DeletePosixAccountRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeletePosixAccount', $request, $callOptions)->wait(); - } - - /** - * Deletes an SSH public key. - * - * The async variant is {@see self::deleteSshPublicKeyAsync()} . - * - * @param DeleteSshPublicKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSshPublicKey(DeleteSshPublicKeyRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteSshPublicKey', $request, $callOptions)->wait(); - } - - /** - * Retrieves the profile information used for logging in to a virtual machine - * on Google Compute Engine. - * - * The async variant is {@see self::getLoginProfileAsync()} . - * - * @param GetLoginProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LoginProfile - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLoginProfile(GetLoginProfileRequest $request, array $callOptions = []): LoginProfile - { - return $this->startApiCall('GetLoginProfile', $request, $callOptions)->wait(); - } - - /** - * Retrieves an SSH public key. - * - * The async variant is {@see self::getSshPublicKeyAsync()} . - * - * @param GetSshPublicKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SshPublicKey - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSshPublicKey(GetSshPublicKeyRequest $request, array $callOptions = []): SshPublicKey - { - return $this->startApiCall('GetSshPublicKey', $request, $callOptions)->wait(); - } - - /** - * Adds an SSH public key and returns the profile information. Default POSIX - * account information is set when no username and UID exist as part of the - * login profile. - * - * The async variant is {@see self::importSshPublicKeyAsync()} . - * - * @param ImportSshPublicKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ImportSshPublicKeyResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function importSshPublicKey(ImportSshPublicKeyRequest $request, array $callOptions = []): ImportSshPublicKeyResponse - { - return $this->startApiCall('ImportSshPublicKey', $request, $callOptions)->wait(); - } - - /** - * Updates an SSH public key and returns the profile information. This method - * supports patch semantics. - * - * The async variant is {@see self::updateSshPublicKeyAsync()} . - * - * @param UpdateSshPublicKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SshPublicKey - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSshPublicKey(UpdateSshPublicKeyRequest $request, array $callOptions = []): SshPublicKey - { - return $this->startApiCall('UpdateSshPublicKey', $request, $callOptions)->wait(); - } -} diff --git a/OsLogin/src/V1/Client/OsLoginServiceClient.php b/OsLogin/src/V1/Client/OsLoginServiceClient.php index 24a088db57d2..85f45490bb95 100644 --- a/OsLogin/src/V1/Client/OsLoginServiceClient.php +++ b/OsLogin/src/V1/Client/OsLoginServiceClient.php @@ -24,17 +24,408 @@ namespace Google\Cloud\OsLogin\V1\Client; -use Google\Cloud\OsLogin\V1\Client\BaseClient\OsLoginServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\OsLogin\Common\SshPublicKey; +use Google\Cloud\OsLogin\V1\CreateSshPublicKeyRequest; +use Google\Cloud\OsLogin\V1\DeletePosixAccountRequest; +use Google\Cloud\OsLogin\V1\DeleteSshPublicKeyRequest; +use Google\Cloud\OsLogin\V1\GetLoginProfileRequest; +use Google\Cloud\OsLogin\V1\GetSshPublicKeyRequest; +use Google\Cloud\OsLogin\V1\ImportSshPublicKeyRequest; +use Google\Cloud\OsLogin\V1\ImportSshPublicKeyResponse; +use Google\Cloud\OsLogin\V1\LoginProfile; +use Google\Cloud\OsLogin\V1\UpdateSshPublicKeyRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Cloud OS Login API * - * This class is currently experimental and may be subject to changes. + * The Cloud OS Login API allows you to manage users and their associated SSH + * public keys for logging into virtual machines on Google Cloud Platform. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\OsLogin\V1\OsLoginServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createSshPublicKeyAsync(CreateSshPublicKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deletePosixAccountAsync(DeletePosixAccountRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSshPublicKeyAsync(DeleteSshPublicKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLoginProfileAsync(GetLoginProfileRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSshPublicKeyAsync(GetSshPublicKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface importSshPublicKeyAsync(ImportSshPublicKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSshPublicKeyAsync(UpdateSshPublicKeyRequest $request, array $optionalArgs = []) */ -class OsLoginServiceClient extends OsLoginServiceBaseClient +class OsLoginServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see OsLoginServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.oslogin.v1.OsLoginService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'oslogin.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/compute.readonly', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/os_login_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/os_login_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/os_login_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/os_login_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * posix_account resource. + * + * @param string $user + * @param string $project + * + * @return string The formatted posix_account resource. + */ + public static function posixAccountName(string $user, string $project): string + { + return self::getPathTemplate('posixAccount')->render([ + 'user' => $user, + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * ssh_public_key resource. + * + * @param string $user + * @param string $fingerprint + * + * @return string The formatted ssh_public_key resource. + */ + public static function sshPublicKeyName(string $user, string $fingerprint): string + { + return self::getPathTemplate('sshPublicKey')->render([ + 'user' => $user, + 'fingerprint' => $fingerprint, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a user + * resource. + * + * @param string $user + * + * @return string The formatted user resource. + */ + public static function userName(string $user): string + { + return self::getPathTemplate('user')->render([ + 'user' => $user, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - posixAccount: users/{user}/projects/{project} + * - sshPublicKey: users/{user}/sshPublicKeys/{fingerprint} + * - user: users/{user} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'oslogin.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Create an SSH public key + * + * The async variant is {@see OsLoginServiceClient::createSshPublicKeyAsync()} . + * + * @param CreateSshPublicKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SshPublicKey + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSshPublicKey(CreateSshPublicKeyRequest $request, array $callOptions = []): SshPublicKey + { + return $this->startApiCall('CreateSshPublicKey', $request, $callOptions)->wait(); + } + + /** + * Deletes a POSIX account. + * + * The async variant is {@see OsLoginServiceClient::deletePosixAccountAsync()} . + * + * @param DeletePosixAccountRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deletePosixAccount(DeletePosixAccountRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeletePosixAccount', $request, $callOptions)->wait(); + } + + /** + * Deletes an SSH public key. + * + * The async variant is {@see OsLoginServiceClient::deleteSshPublicKeyAsync()} . + * + * @param DeleteSshPublicKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSshPublicKey(DeleteSshPublicKeyRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteSshPublicKey', $request, $callOptions)->wait(); + } + + /** + * Retrieves the profile information used for logging in to a virtual machine + * on Google Compute Engine. + * + * The async variant is {@see OsLoginServiceClient::getLoginProfileAsync()} . + * + * @param GetLoginProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LoginProfile + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLoginProfile(GetLoginProfileRequest $request, array $callOptions = []): LoginProfile + { + return $this->startApiCall('GetLoginProfile', $request, $callOptions)->wait(); + } + + /** + * Retrieves an SSH public key. + * + * The async variant is {@see OsLoginServiceClient::getSshPublicKeyAsync()} . + * + * @param GetSshPublicKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SshPublicKey + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSshPublicKey(GetSshPublicKeyRequest $request, array $callOptions = []): SshPublicKey + { + return $this->startApiCall('GetSshPublicKey', $request, $callOptions)->wait(); + } + + /** + * Adds an SSH public key and returns the profile information. Default POSIX + * account information is set when no username and UID exist as part of the + * login profile. + * + * The async variant is {@see OsLoginServiceClient::importSshPublicKeyAsync()} . + * + * @param ImportSshPublicKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ImportSshPublicKeyResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importSshPublicKey(ImportSshPublicKeyRequest $request, array $callOptions = []): ImportSshPublicKeyResponse + { + return $this->startApiCall('ImportSshPublicKey', $request, $callOptions)->wait(); + } + + /** + * Updates an SSH public key and returns the profile information. This method + * supports patch semantics. + * + * The async variant is {@see OsLoginServiceClient::updateSshPublicKeyAsync()} . + * + * @param UpdateSshPublicKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SshPublicKey + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSshPublicKey(UpdateSshPublicKeyRequest $request, array $callOptions = []): SshPublicKey + { + return $this->startApiCall('UpdateSshPublicKey', $request, $callOptions)->wait(); + } } diff --git a/OsLogin/src/V1beta/SecurityKey.php b/OsLogin/src/V1beta/SecurityKey.php index ed29de53b48d..3c142fe34602 100644 --- a/OsLogin/src/V1beta/SecurityKey.php +++ b/OsLogin/src/V1beta/SecurityKey.php @@ -28,6 +28,12 @@ class SecurityKey extends \Google\Protobuf\Internal\Message * Generated from protobuf field string private_key = 2; */ private $private_key = ''; + /** + * The security key nickname explicitly set by the user. + * + * Generated from protobuf field optional string device_nickname = 5; + */ + private $device_nickname = null; protected $protocol_type; /** @@ -45,6 +51,8 @@ class SecurityKey extends \Google\Protobuf\Internal\Message * The U2F protocol type. * @type \Google\Cloud\OsLogin\V1beta\WebAuthn $web_authn * The Web Authentication protocol type. + * @type string $device_nickname + * The security key nickname explicitly set by the user. * } */ public function __construct($data = NULL) { @@ -168,6 +176,42 @@ public function setWebAuthn($var) return $this; } + /** + * The security key nickname explicitly set by the user. + * + * Generated from protobuf field optional string device_nickname = 5; + * @return string + */ + public function getDeviceNickname() + { + return isset($this->device_nickname) ? $this->device_nickname : ''; + } + + public function hasDeviceNickname() + { + return isset($this->device_nickname); + } + + public function clearDeviceNickname() + { + unset($this->device_nickname); + } + + /** + * The security key nickname explicitly set by the user. + * + * Generated from protobuf field optional string device_nickname = 5; + * @param string $var + * @return $this + */ + public function setDeviceNickname($var) + { + GPBUtil::checkString($var, True); + $this->device_nickname = $var; + + return $this; + } + /** * @return string */ diff --git a/OsLogin/src/V1beta/resources/os_login_service_rest_client_config.php b/OsLogin/src/V1beta/resources/os_login_service_rest_client_config.php index f4f224d5c68c..6e60ed77a8db 100644 --- a/OsLogin/src/V1beta/resources/os_login_service_rest_client_config.php +++ b/OsLogin/src/V1beta/resources/os_login_service_rest_client_config.php @@ -75,6 +75,13 @@ 'method' => 'post', 'uriTemplate' => '/v1beta/{parent=users/*/projects/*/zones/*}:signSshPublicKey', 'body' => '*', + 'additionalBindings' => [ + [ + 'method' => 'post', + 'uriTemplate' => '/v1beta/{parent=users/*/projects/*/locations/*}:signSshPublicKey', + 'body' => '*', + ], + ], 'placeholders' => [ 'parent' => [ 'getters' => [ diff --git a/PolicySimulator/composer.json b/PolicySimulator/composer.json index ee7f680421f1..a24260d3b216 100644 --- a/PolicySimulator/composer.json +++ b/PolicySimulator/composer.json @@ -18,7 +18,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.22.0" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/PolicySimulator/src/V1/Client/BaseClient/SimulatorBaseClient.php b/PolicySimulator/src/V1/Client/BaseClient/SimulatorBaseClient.php deleted file mode 100644 index 5f21198eb100..000000000000 --- a/PolicySimulator/src/V1/Client/BaseClient/SimulatorBaseClient.php +++ /dev/null @@ -1,443 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . '/../../resources/simulator_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . '/../../resources/simulator_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . '/../../resources/simulator_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../../resources/simulator_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; - $operation = new OperationResponse( - $operationName, - $this->getOperationsClient(), - $options - ); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_location_replay resource. - * - * @param string $folder - * @param string $location - * @param string $replay - * - * @return string The formatted folder_location_replay resource. - */ - public static function folderLocationReplayName( - string $folder, - string $location, - string $replay - ): string { - return self::getPathTemplate('folderLocationReplay')->render([ - 'folder' => $folder, - 'location' => $location, - 'replay' => $replay, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_location_replay resource. - * - * @param string $organization - * @param string $location - * @param string $replay - * - * @return string The formatted organization_location_replay resource. - */ - public static function organizationLocationReplayName( - string $organization, - string $location, - string $replay - ): string { - return self::getPathTemplate('organizationLocationReplay')->render([ - 'organization' => $organization, - 'location' => $location, - 'replay' => $replay, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_replay resource. - * - * @param string $project - * @param string $location - * @param string $replay - * - * @return string The formatted project_location_replay resource. - */ - public static function projectLocationReplayName( - string $project, - string $location, - string $replay - ): string { - return self::getPathTemplate('projectLocationReplay')->render([ - 'project' => $project, - 'location' => $location, - 'replay' => $replay, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a replay - * resource. - * - * @param string $project - * @param string $location - * @param string $replay - * - * @return string The formatted replay resource. - */ - public static function replayName( - string $project, - string $location, - string $replay - ): string { - return self::getPathTemplate('replay')->render([ - 'project' => $project, - 'location' => $location, - 'replay' => $replay, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - folderLocationReplay: folders/{folder}/locations/{location}/replays/{replay} - * - organizationLocationReplay: organizations/{organization}/locations/{location}/replays/{replay} - * - projectLocationReplay: projects/{project}/locations/{location}/replays/{replay} - * - replay: projects/{project}/locations/{location}/replays/{replay} - * - * 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( - string $formattedName, - string $template = null - ): array { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'policysimulator.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error( - 'Call to undefined method ' . __CLASS__ . "::$method()", - E_USER_ERROR - ); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates and starts a [Replay][google.cloud.policysimulator.v1.Replay] using - * the given [ReplayConfig][google.cloud.policysimulator.v1.ReplayConfig]. - * - * The async variant is {@see self::createReplayAsync()} . - * - * @example samples/V1/SimulatorClient/create_replay.php - * - * @param CreateReplayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createReplay( - CreateReplayRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'CreateReplay', - $request, - $callOptions - )->wait(); - } - - /** - * Gets the specified [Replay][google.cloud.policysimulator.v1.Replay]. Each - * `Replay` is available for at least 7 days. - * - * The async variant is {@see self::getReplayAsync()} . - * - * @example samples/V1/SimulatorClient/get_replay.php - * - * @param GetReplayRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Replay - * - * @throws ApiException Thrown if the API call fails. - */ - public function getReplay( - GetReplayRequest $request, - array $callOptions = [] - ): Replay { - return $this->startApiCall('GetReplay', $request, $callOptions)->wait(); - } - - /** - * Lists the results of running a - * [Replay][google.cloud.policysimulator.v1.Replay]. - * - * The async variant is {@see self::listReplayResultsAsync()} . - * - * @example samples/V1/SimulatorClient/list_replay_results.php - * - * @param ListReplayResultsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listReplayResults( - ListReplayResultsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListReplayResults', $request, $callOptions); - } -} diff --git a/PolicySimulator/src/V1/Client/SimulatorClient.php b/PolicySimulator/src/V1/Client/SimulatorClient.php index c67eb6f9e73e..32fa127cc901 100644 --- a/PolicySimulator/src/V1/Client/SimulatorClient.php +++ b/PolicySimulator/src/V1/Client/SimulatorClient.php @@ -24,17 +24,379 @@ namespace Google\Cloud\PolicySimulator\V1\Client; -use Google\Cloud\PolicySimulator\V1\Client\BaseClient\SimulatorBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\PolicySimulator\V1\CreateReplayRequest; +use Google\Cloud\PolicySimulator\V1\GetReplayRequest; +use Google\Cloud\PolicySimulator\V1\ListReplayResultsRequest; +use Google\Cloud\PolicySimulator\V1\Replay; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Policy Simulator API service. + * + * Policy Simulator is a collection of endpoints for creating, running, and + * viewing a [Replay][google.cloud.policysimulator.v1.Replay]. A + * [Replay][google.cloud.policysimulator.v1.Replay] is a type of simulation that + * lets you see how your principals' access to resources might change if you + * changed your IAM policy. + * + * During a [Replay][google.cloud.policysimulator.v1.Replay], Policy Simulator + * re-evaluates, or replays, past access attempts under both the current policy + * and your proposed policy, and compares those results to determine how your + * principals' access might change under the proposed policy. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createReplayAsync(CreateReplayRequest $request, array $optionalArgs = []) + * @method PromiseInterface getReplayAsync(GetReplayRequest $request, array $optionalArgs = []) + * @method PromiseInterface listReplayResultsAsync(ListReplayResultsRequest $request, array $optionalArgs = []) */ -final class SimulatorClient extends SimulatorBaseClient +final class SimulatorClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SimulatorBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.policysimulator.v1.Simulator'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'policysimulator.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/simulator_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/simulator_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/simulator_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/simulator_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_location_replay resource. + * + * @param string $folder + * @param string $location + * @param string $replay + * + * @return string The formatted folder_location_replay resource. + */ + public static function folderLocationReplayName(string $folder, string $location, string $replay): string + { + return self::getPathTemplate('folderLocationReplay')->render([ + 'folder' => $folder, + 'location' => $location, + 'replay' => $replay, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_location_replay resource. + * + * @param string $organization + * @param string $location + * @param string $replay + * + * @return string The formatted organization_location_replay resource. + */ + public static function organizationLocationReplayName(string $organization, string $location, string $replay): string + { + return self::getPathTemplate('organizationLocationReplay')->render([ + 'organization' => $organization, + 'location' => $location, + 'replay' => $replay, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_replay resource. + * + * @param string $project + * @param string $location + * @param string $replay + * + * @return string The formatted project_location_replay resource. + */ + public static function projectLocationReplayName(string $project, string $location, string $replay): string + { + return self::getPathTemplate('projectLocationReplay')->render([ + 'project' => $project, + 'location' => $location, + 'replay' => $replay, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a replay + * resource. + * + * @param string $project + * @param string $location + * @param string $replay + * + * @return string The formatted replay resource. + */ + public static function replayName(string $project, string $location, string $replay): string + { + return self::getPathTemplate('replay')->render([ + 'project' => $project, + 'location' => $location, + 'replay' => $replay, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - folderLocationReplay: folders/{folder}/locations/{location}/replays/{replay} + * - organizationLocationReplay: organizations/{organization}/locations/{location}/replays/{replay} + * - projectLocationReplay: projects/{project}/locations/{location}/replays/{replay} + * - replay: projects/{project}/locations/{location}/replays/{replay} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'policysimulator.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates and starts a [Replay][google.cloud.policysimulator.v1.Replay] using + * the given [ReplayConfig][google.cloud.policysimulator.v1.ReplayConfig]. + * + * The async variant is {@see SimulatorClient::createReplayAsync()} . + * + * @example samples/V1/SimulatorClient/create_replay.php + * + * @param CreateReplayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createReplay(CreateReplayRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateReplay', $request, $callOptions)->wait(); + } + + /** + * Gets the specified [Replay][google.cloud.policysimulator.v1.Replay]. Each + * `Replay` is available for at least 7 days. + * + * The async variant is {@see SimulatorClient::getReplayAsync()} . + * + * @example samples/V1/SimulatorClient/get_replay.php + * + * @param GetReplayRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Replay + * + * @throws ApiException Thrown if the API call fails. + */ + public function getReplay(GetReplayRequest $request, array $callOptions = []): Replay + { + return $this->startApiCall('GetReplay', $request, $callOptions)->wait(); + } + + /** + * Lists the results of running a + * [Replay][google.cloud.policysimulator.v1.Replay]. + * + * The async variant is {@see SimulatorClient::listReplayResultsAsync()} . + * + * @example samples/V1/SimulatorClient/list_replay_results.php + * + * @param ListReplayResultsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listReplayResults(ListReplayResultsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListReplayResults', $request, $callOptions); + } } diff --git a/PolicyTroubleshooter/composer.json b/PolicyTroubleshooter/composer.json index cdc90d89763f..b50198fcbfb3 100644 --- a/PolicyTroubleshooter/composer.json +++ b/PolicyTroubleshooter/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/PolicyTroubleshooter/src/V1/Client/BaseClient/IamCheckerBaseClient.php b/PolicyTroubleshooter/src/V1/Client/BaseClient/IamCheckerBaseClient.php deleted file mode 100644 index ed6eedf206f6..000000000000 --- a/PolicyTroubleshooter/src/V1/Client/BaseClient/IamCheckerBaseClient.php +++ /dev/null @@ -1,192 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/iam_checker_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/iam_checker_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/iam_checker_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/iam_checker_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'policytroubleshooter.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Checks whether a principal has a specific permission for a specific - * resource, and explains why the principal does or does not have that - * permission. - * - * The async variant is {@see self::troubleshootIamPolicyAsync()} . - * - * @param TroubleshootIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TroubleshootIamPolicyResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function troubleshootIamPolicy(TroubleshootIamPolicyRequest $request, array $callOptions = []): TroubleshootIamPolicyResponse - { - return $this->startApiCall('TroubleshootIamPolicy', $request, $callOptions)->wait(); - } -} diff --git a/PolicyTroubleshooter/src/V1/Client/IamCheckerClient.php b/PolicyTroubleshooter/src/V1/Client/IamCheckerClient.php index 496ded9bb29e..5eadc4fb660f 100644 --- a/PolicyTroubleshooter/src/V1/Client/IamCheckerClient.php +++ b/PolicyTroubleshooter/src/V1/Client/IamCheckerClient.php @@ -24,17 +24,167 @@ namespace Google\Cloud\PolicyTroubleshooter\V1\Client; -use Google\Cloud\PolicyTroubleshooter\V1\Client\BaseClient\IamCheckerBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\PolicyTroubleshooter\V1\TroubleshootIamPolicyRequest; +use Google\Cloud\PolicyTroubleshooter\V1\TroubleshootIamPolicyResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: IAM Policy Troubleshooter service. * - * This class is currently experimental and may be subject to changes. + * This service helps you troubleshoot access issues for Google Cloud resources. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\PolicyTroubleshooter\V1\IamCheckerClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface troubleshootIamPolicyAsync(TroubleshootIamPolicyRequest $request, array $optionalArgs = []) */ -final class IamCheckerClient extends IamCheckerBaseClient +final class IamCheckerClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see IamCheckerBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.policytroubleshooter.v1.IamChecker'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'policytroubleshooter.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/iam_checker_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/iam_checker_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/iam_checker_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/iam_checker_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'policytroubleshooter.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Checks whether a principal has a specific permission for a specific + * resource, and explains why the principal does or does not have that + * permission. + * + * The async variant is {@see IamCheckerClient::troubleshootIamPolicyAsync()} . + * + * @param TroubleshootIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TroubleshootIamPolicyResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function troubleshootIamPolicy(TroubleshootIamPolicyRequest $request, array $callOptions = []): TroubleshootIamPolicyResponse + { + return $this->startApiCall('TroubleshootIamPolicy', $request, $callOptions)->wait(); + } } diff --git a/PolicyTroubleshooterIam/composer.json b/PolicyTroubleshooterIam/composer.json index 7ccb15f32240..2421738542a7 100644 --- a/PolicyTroubleshooterIam/composer.json +++ b/PolicyTroubleshooterIam/composer.json @@ -18,7 +18,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.22.0", + "google/gax": "^1.24.0", "google/cloud-iam": "^0.4.0" }, "require-dev": { diff --git a/PolicyTroubleshooterIam/src/V3/Client/BaseClient/PolicyTroubleshooterBaseClient.php b/PolicyTroubleshooterIam/src/V3/Client/BaseClient/PolicyTroubleshooterBaseClient.php deleted file mode 100644 index 0085921677c0..000000000000 --- a/PolicyTroubleshooterIam/src/V3/Client/BaseClient/PolicyTroubleshooterBaseClient.php +++ /dev/null @@ -1,210 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . - '/../../resources/policy_troubleshooter_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../../resources/policy_troubleshooter_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . - '/../../resources/policy_troubleshooter_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../../resources/policy_troubleshooter_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'policytroubleshooter.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error( - 'Call to undefined method ' . __CLASS__ . "::$method()", - E_USER_ERROR - ); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Checks whether a principal has a specific permission for a specific - * resource, and explains why the principal does or doesn't have that - * permission. - * - * The async variant is {@see self::troubleshootIamPolicyAsync()} . - * - * @example samples/V3/PolicyTroubleshooterClient/troubleshoot_iam_policy.php - * - * @param TroubleshootIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TroubleshootIamPolicyResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function troubleshootIamPolicy( - TroubleshootIamPolicyRequest $request, - array $callOptions = [] - ): TroubleshootIamPolicyResponse { - return $this->startApiCall( - 'TroubleshootIamPolicy', - $request, - $callOptions - )->wait(); - } -} diff --git a/PolicyTroubleshooterIam/src/V3/Client/PolicyTroubleshooterClient.php b/PolicyTroubleshooterIam/src/V3/Client/PolicyTroubleshooterClient.php index 098770fac0d4..4a323a67c6ab 100644 --- a/PolicyTroubleshooterIam/src/V3/Client/PolicyTroubleshooterClient.php +++ b/PolicyTroubleshooterIam/src/V3/Client/PolicyTroubleshooterClient.php @@ -24,17 +24,168 @@ namespace Google\Cloud\PolicyTroubleshooter\Iam\V3\Client; -use Google\Cloud\PolicyTroubleshooter\Iam\V3\Client\BaseClient\PolicyTroubleshooterBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\PolicyTroubleshooter\Iam\V3\TroubleshootIamPolicyRequest; +use Google\Cloud\PolicyTroubleshooter\Iam\V3\TroubleshootIamPolicyResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: IAM Policy Troubleshooter service. + * + * This service helps you troubleshoot access issues for Google Cloud resources. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface troubleshootIamPolicyAsync(TroubleshootIamPolicyRequest $request, array $optionalArgs = []) */ -final class PolicyTroubleshooterClient extends PolicyTroubleshooterBaseClient +final class PolicyTroubleshooterClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see PolicyTroubleshooterBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.policytroubleshooter.iam.v3.PolicyTroubleshooter'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'policytroubleshooter.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/policy_troubleshooter_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/policy_troubleshooter_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/policy_troubleshooter_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/policy_troubleshooter_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'policytroubleshooter.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Checks whether a principal has a specific permission for a specific + * resource, and explains why the principal does or doesn't have that + * permission. + * + * The async variant is + * {@see PolicyTroubleshooterClient::troubleshootIamPolicyAsync()} . + * + * @example samples/V3/PolicyTroubleshooterClient/troubleshoot_iam_policy.php + * + * @param TroubleshootIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TroubleshootIamPolicyResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function troubleshootIamPolicy(TroubleshootIamPolicyRequest $request, array $callOptions = []): TroubleshootIamPolicyResponse + { + return $this->startApiCall('TroubleshootIamPolicy', $request, $callOptions)->wait(); + } } diff --git a/PrivateCatalog/composer.json b/PrivateCatalog/composer.json index 3806bcdf6610..dc6f83165b7f 100644 --- a/PrivateCatalog/composer.json +++ b/PrivateCatalog/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/PrivateCatalog/src/V1beta1/Client/BaseClient/PrivateCatalogBaseClient.php b/PrivateCatalog/src/V1beta1/Client/BaseClient/PrivateCatalogBaseClient.php deleted file mode 100644 index 1949fab70fab..000000000000 --- a/PrivateCatalog/src/V1beta1/Client/BaseClient/PrivateCatalogBaseClient.php +++ /dev/null @@ -1,277 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/private_catalog_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/private_catalog_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/private_catalog_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/private_catalog_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'cloudprivatecatalog.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); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Search [Catalog][google.cloud.privatecatalog.v1beta1.Catalog] resources that consumers have access to, within the - * scope of the consumer cloud resource hierarchy context. - * - * The async variant is {@see self::searchCatalogsAsync()} . - * - * @example samples/V1beta1/PrivateCatalogClient/search_catalogs.php - * - * @param SearchCatalogsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function searchCatalogs(SearchCatalogsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchCatalogs', $request, $callOptions); - } - - /** - * Search [Product][google.cloud.privatecatalog.v1beta1.Product] resources that consumers have access to, within the - * scope of the consumer cloud resource hierarchy context. - * - * The async variant is {@see self::searchProductsAsync()} . - * - * @example samples/V1beta1/PrivateCatalogClient/search_products.php - * - * @param SearchProductsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function searchProducts(SearchProductsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchProducts', $request, $callOptions); - } - - /** - * Search [Version][google.cloud.privatecatalog.v1beta1.Version] resources that consumers have access to, within the - * scope of the consumer cloud resource hierarchy context. - * - * The async variant is {@see self::searchVersionsAsync()} . - * - * @example samples/V1beta1/PrivateCatalogClient/search_versions.php - * - * @param SearchVersionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function searchVersions(SearchVersionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchVersions', $request, $callOptions); - } -} diff --git a/PrivateCatalog/src/V1beta1/Client/PrivateCatalogClient.php b/PrivateCatalog/src/V1beta1/Client/PrivateCatalogClient.php index ba068a903df9..f1dc7be0d757 100644 --- a/PrivateCatalog/src/V1beta1/Client/PrivateCatalogClient.php +++ b/PrivateCatalog/src/V1beta1/Client/PrivateCatalogClient.php @@ -26,17 +26,250 @@ namespace Google\Cloud\PrivateCatalog\V1beta1\Client; -use Google\Cloud\PrivateCatalog\V1beta1\Client\BaseClient\PrivateCatalogBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\PrivateCatalog\V1beta1\SearchCatalogsRequest; +use Google\Cloud\PrivateCatalog\V1beta1\SearchProductsRequest; +use Google\Cloud\PrivateCatalog\V1beta1\SearchVersionsRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: `PrivateCatalog` allows catalog consumers to retrieve `Catalog`, `Product` + * and `Version` resources under a target resource context. + * + * `Catalog` is computed based on the [Association][]s linked to the target + * resource and its ancestors. Each association's + * [google.cloud.privatecatalogproducer.v1beta.Catalog][] is transformed into a + * `Catalog`. If multiple associations have the same parent + * [google.cloud.privatecatalogproducer.v1beta.Catalog][], they are + * de-duplicated into one `Catalog`. Users must have + * `cloudprivatecatalog.catalogTargets.get` IAM permission on the resource + * context in order to access catalogs. `Catalog` contains the resource name and + * a subset of data of the original + * [google.cloud.privatecatalogproducer.v1beta.Catalog][]. + * + * `Product` is child resource of the catalog. A `Product` contains the resource + * name and a subset of the data of the original + * [google.cloud.privatecatalogproducer.v1beta.Product][]. + * + * `Version` is child resource of the product. A `Version` contains the resource + * name and a subset of the data of the original + * [google.cloud.privatecatalogproducer.v1beta.Version][]. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface searchCatalogsAsync(SearchCatalogsRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchProductsAsync(SearchProductsRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchVersionsAsync(SearchVersionsRequest $request, array $optionalArgs = []) */ -final class PrivateCatalogClient extends PrivateCatalogBaseClient +final class PrivateCatalogClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see PrivateCatalogBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.privatecatalog.v1beta1.PrivateCatalog'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudprivatecatalog.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/private_catalog_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/private_catalog_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/private_catalog_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/private_catalog_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'cloudprivatecatalog.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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Search [Catalog][google.cloud.privatecatalog.v1beta1.Catalog] resources that consumers have access to, within the + * scope of the consumer cloud resource hierarchy context. + * + * The async variant is {@see PrivateCatalogClient::searchCatalogsAsync()} . + * + * @example samples/V1beta1/PrivateCatalogClient/search_catalogs.php + * + * @param SearchCatalogsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function searchCatalogs(SearchCatalogsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchCatalogs', $request, $callOptions); + } + + /** + * Search [Product][google.cloud.privatecatalog.v1beta1.Product] resources that consumers have access to, within the + * scope of the consumer cloud resource hierarchy context. + * + * The async variant is {@see PrivateCatalogClient::searchProductsAsync()} . + * + * @example samples/V1beta1/PrivateCatalogClient/search_products.php + * + * @param SearchProductsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function searchProducts(SearchProductsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchProducts', $request, $callOptions); + } + + /** + * Search [Version][google.cloud.privatecatalog.v1beta1.Version] resources that consumers have access to, within the + * scope of the consumer cloud resource hierarchy context. + * + * The async variant is {@see PrivateCatalogClient::searchVersionsAsync()} . + * + * @example samples/V1beta1/PrivateCatalogClient/search_versions.php + * + * @param SearchVersionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function searchVersions(SearchVersionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchVersions', $request, $callOptions); + } } diff --git a/Profiler/composer.json b/Profiler/composer.json index c344930fb604..bc334b6b20e5 100644 --- a/Profiler/composer.json +++ b/Profiler/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Profiler/src/V2/Client/BaseClient/ProfilerServiceBaseClient.php b/Profiler/src/V2/Client/BaseClient/ProfilerServiceBaseClient.php deleted file mode 100644 index 32d32846b230..000000000000 --- a/Profiler/src/V2/Client/BaseClient/ProfilerServiceBaseClient.php +++ /dev/null @@ -1,328 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/profiler_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/profiler_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/profiler_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/profiler_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a profile - * resource. - * - * @param string $project - * @param string $profile - * - * @return string The formatted profile resource. - */ - public static function profileName(string $project, string $profile): string - { - return self::getPathTemplate('profile')->render([ - 'project' => $project, - 'profile' => $profile, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->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 - * - profile: projects/{project}/profiles/{profile} - * - 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. - */ - public static function parseName(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudprofiler.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * CreateOfflineProfile creates a new profile resource in the offline mode. - * The client provides the profile to create along with the profile bytes, the - * server records it. - * - * The async variant is {@see self::createOfflineProfileAsync()} . - * - * @param CreateOfflineProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Profile - * - * @throws ApiException Thrown if the API call fails. - */ - public function createOfflineProfile(CreateOfflineProfileRequest $request, array $callOptions = []): Profile - { - return $this->startApiCall('CreateOfflineProfile', $request, $callOptions)->wait(); - } - - /** - * CreateProfile creates a new profile resource in the online mode. - * - * The server ensures that the new profiles are created at a constant rate per - * deployment, so the creation request may hang for some time until the next - * profile session is available. - * - * The request may fail with ABORTED error if the creation is not available - * within ~1m, the response will indicate the duration of the backoff the - * client should take before attempting creating a profile again. The backoff - * duration is returned in google.rpc.RetryInfo extension on the response - * status. To a gRPC client, the extension will be return as a - * binary-serialized proto in the trailing metadata item named - * "google.rpc.retryinfo-bin". - * - * - * The async variant is {@see self::createProfileAsync()} . - * - * @param CreateProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Profile - * - * @throws ApiException Thrown if the API call fails. - */ - public function createProfile(CreateProfileRequest $request, array $callOptions = []): Profile - { - return $this->startApiCall('CreateProfile', $request, $callOptions)->wait(); - } - - /** - * UpdateProfile updates the profile bytes and labels on the profile resource - * created in the online mode. Updating the bytes for profiles created in the - * offline mode is currently not supported: the profile content must be - * provided at the time of the profile creation. - * - * The async variant is {@see self::updateProfileAsync()} . - * - * @param UpdateProfileRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Profile - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateProfile(UpdateProfileRequest $request, array $callOptions = []): Profile - { - return $this->startApiCall('UpdateProfile', $request, $callOptions)->wait(); - } -} diff --git a/Profiler/src/V2/Client/ProfilerServiceClient.php b/Profiler/src/V2/Client/ProfilerServiceClient.php index 0c8040197521..85d9e32a227c 100644 --- a/Profiler/src/V2/Client/ProfilerServiceClient.php +++ b/Profiler/src/V2/Client/ProfilerServiceClient.php @@ -24,17 +24,303 @@ namespace Google\Cloud\Profiler\V2\Client; -use Google\Cloud\Profiler\V2\Client\BaseClient\ProfilerServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Profiler\V2\CreateOfflineProfileRequest; +use Google\Cloud\Profiler\V2\CreateProfileRequest; +use Google\Cloud\Profiler\V2\Profile; +use Google\Cloud\Profiler\V2\UpdateProfileRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Manage the collection of continuous profiling data provided by profiling + * agents running in the cloud or by an offline provider of profiling data. * - * This class is currently experimental and may be subject to changes. + * General guidelines: + * * Profiles for a single deployment must be created in ascending time order. + * * Profiles can be created in either online or offline mode, see below. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Profiler\V2\ProfilerServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createOfflineProfileAsync(CreateOfflineProfileRequest $request, array $optionalArgs = []) + * @method PromiseInterface createProfileAsync(CreateProfileRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateProfileAsync(UpdateProfileRequest $request, array $optionalArgs = []) */ -final class ProfilerServiceClient extends ProfilerServiceBaseClient +final class ProfilerServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ProfilerServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.devtools.cloudprofiler.v2.ProfilerService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudprofiler.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/monitoring', + 'https://www.googleapis.com/auth/monitoring.write', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/profiler_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/profiler_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/profiler_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/profiler_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a profile + * resource. + * + * @param string $project + * @param string $profile + * + * @return string The formatted profile resource. + */ + public static function profileName(string $project, string $profile): string + { + return self::getPathTemplate('profile')->render([ + 'project' => $project, + 'profile' => $profile, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->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 + * - profile: projects/{project}/profiles/{profile} + * - 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. + */ + public static function parseName(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudprofiler.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * CreateOfflineProfile creates a new profile resource in the offline mode. + * The client provides the profile to create along with the profile bytes, the + * server records it. + * + * The async variant is {@see ProfilerServiceClient::createOfflineProfileAsync()} . + * + * @param CreateOfflineProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Profile + * + * @throws ApiException Thrown if the API call fails. + */ + public function createOfflineProfile(CreateOfflineProfileRequest $request, array $callOptions = []): Profile + { + return $this->startApiCall('CreateOfflineProfile', $request, $callOptions)->wait(); + } + + /** + * CreateProfile creates a new profile resource in the online mode. + * + * The server ensures that the new profiles are created at a constant rate per + * deployment, so the creation request may hang for some time until the next + * profile session is available. + * + * The request may fail with ABORTED error if the creation is not available + * within ~1m, the response will indicate the duration of the backoff the + * client should take before attempting creating a profile again. The backoff + * duration is returned in google.rpc.RetryInfo extension on the response + * status. To a gRPC client, the extension will be return as a + * binary-serialized proto in the trailing metadata item named + * "google.rpc.retryinfo-bin". + * + * + * The async variant is {@see ProfilerServiceClient::createProfileAsync()} . + * + * @param CreateProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Profile + * + * @throws ApiException Thrown if the API call fails. + */ + public function createProfile(CreateProfileRequest $request, array $callOptions = []): Profile + { + return $this->startApiCall('CreateProfile', $request, $callOptions)->wait(); + } + + /** + * UpdateProfile updates the profile bytes and labels on the profile resource + * created in the online mode. Updating the bytes for profiles created in the + * offline mode is currently not supported: the profile content must be + * provided at the time of the profile creation. + * + * The async variant is {@see ProfilerServiceClient::updateProfileAsync()} . + * + * @param UpdateProfileRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Profile + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateProfile(UpdateProfileRequest $request, array $callOptions = []): Profile + { + return $this->startApiCall('UpdateProfile', $request, $callOptions)->wait(); + } } diff --git a/PubSub/composer.json b/PubSub/composer.json index 62a2df96a85e..66e1b130da56 100644 --- a/PubSub/composer.json +++ b/PubSub/composer.json @@ -5,8 +5,8 @@ "minimum-stability": "stable", "require": { "php": ">=7.4", - "google/cloud-core": "^1.46", - "google/gax": "^1.19.1" + "google/cloud-core": "^1.52.7", + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", diff --git a/PubSub/src/V1/Client/BaseClient/PublisherBaseClient.php b/PubSub/src/V1/Client/BaseClient/PublisherBaseClient.php deleted file mode 100644 index d7b77fee9209..000000000000 --- a/PubSub/src/V1/Client/BaseClient/PublisherBaseClient.php +++ /dev/null @@ -1,632 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/publisher_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/publisher_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/publisher_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/publisher_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * _deleted-topic_ resource. - * - * @return string The formatted _deleted-topic_ resource. - */ - public static function deletedTopicName(): string - { - return self::getPathTemplate('deletedTopic')->render([]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_topic resource. - * - * @param string $project - * @param string $topic - * - * @return string The formatted project_topic resource. - */ - public static function projectTopicName(string $project, string $topic): string - { - return self::getPathTemplate('projectTopic')->render([ - 'project' => $project, - 'topic' => $topic, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a schema - * resource. - * - * @param string $project - * @param string $schema - * - * @return string The formatted schema resource. - */ - public static function schemaName(string $project, string $schema): string - { - return self::getPathTemplate('schema')->render([ - 'project' => $project, - 'schema' => $schema, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a subscription - * resource. - * - * @param string $project - * @param string $subscription - * - * @return string The formatted subscription resource. - */ - public static function subscriptionName(string $project, string $subscription): string - { - return self::getPathTemplate('subscription')->render([ - 'project' => $project, - 'subscription' => $subscription, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a topic - * resource. - * - * @param string $project - * @param string $topic - * - * @return string The formatted topic resource. - */ - public static function topicName(string $project, string $topic): string - { - return self::getPathTemplate('topic')->render([ - 'project' => $project, - 'topic' => $topic, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - deletedTopic: _deleted-topic_ - * - project: projects/{project} - * - projectTopic: projects/{project}/topics/{topic} - * - schema: projects/{project}/schemas/{schema} - * - subscription: projects/{project}/subscriptions/{subscription} - * - topic: projects/{project}/topics/{topic} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'pubsub.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates the given topic with the given name. See the [resource name rules] - * (https://cloud.google.com/pubsub/docs/admin#resource_names). - * - * The async variant is {@see self::createTopicAsync()} . - * - * @param Topic $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Topic - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTopic(Topic $request, array $callOptions = []): Topic - { - return $this->startApiCall('CreateTopic', $request, $callOptions)->wait(); - } - - /** - * Deletes the topic with the given name. Returns `NOT_FOUND` if the topic - * does not exist. After a topic is deleted, a new topic may be created with - * the same name; this is an entirely new topic with none of the old - * configuration or subscriptions. Existing subscriptions to this topic are - * not deleted, but their `topic` field is set to `_deleted-topic_`. - * - * The async variant is {@see self::deleteTopicAsync()} . - * - * @param DeleteTopicRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTopic(DeleteTopicRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteTopic', $request, $callOptions)->wait(); - } - - /** - * Detaches a subscription from this topic. All messages retained in the - * subscription are dropped. Subsequent `Pull` and `StreamingPull` requests - * will return FAILED_PRECONDITION. If the subscription is a push - * subscription, pushes to the endpoint will stop. - * - * The async variant is {@see self::detachSubscriptionAsync()} . - * - * @param DetachSubscriptionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DetachSubscriptionResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function detachSubscription(DetachSubscriptionRequest $request, array $callOptions = []): DetachSubscriptionResponse - { - return $this->startApiCall('DetachSubscription', $request, $callOptions)->wait(); - } - - /** - * Gets the configuration of a topic. - * - * The async variant is {@see self::getTopicAsync()} . - * - * @param GetTopicRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Topic - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTopic(GetTopicRequest $request, array $callOptions = []): Topic - { - return $this->startApiCall('GetTopic', $request, $callOptions)->wait(); - } - - /** - * Lists the names of the snapshots on this topic. Snapshots are used in - * [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, - * which allow you to manage message acknowledgments in bulk. That is, you can - * set the acknowledgment state of messages in an existing subscription to the - * state captured by a snapshot. - * - * The async variant is {@see self::listTopicSnapshotsAsync()} . - * - * @param ListTopicSnapshotsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTopicSnapshots(ListTopicSnapshotsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTopicSnapshots', $request, $callOptions); - } - - /** - * Lists the names of the attached subscriptions on this topic. - * - * The async variant is {@see self::listTopicSubscriptionsAsync()} . - * - * @param ListTopicSubscriptionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTopicSubscriptions(ListTopicSubscriptionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTopicSubscriptions', $request, $callOptions); - } - - /** - * Lists matching topics. - * - * The async variant is {@see self::listTopicsAsync()} . - * - * @param ListTopicsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTopics(ListTopicsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTopics', $request, $callOptions); - } - - /** - * Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic - * does not exist. - * - * The async variant is {@see self::publishAsync()} . - * - * @param PublishRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PublishResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function publish(PublishRequest $request, array $callOptions = []): PublishResponse - { - return $this->startApiCall('Publish', $request, $callOptions)->wait(); - } - - /** - * Updates an existing topic. Note that certain properties of a - * topic are not modifiable. - * - * The async variant is {@see self::updateTopicAsync()} . - * - * @param UpdateTopicRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Topic - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateTopic(UpdateTopicRequest $request, array $callOptions = []): Topic - { - return $this->startApiCall('UpdateTopic', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/PubSub/src/V1/Client/BaseClient/SchemaServiceBaseClient.php b/PubSub/src/V1/Client/BaseClient/SchemaServiceBaseClient.php deleted file mode 100644 index 2cd4d921be40..000000000000 --- a/PubSub/src/V1/Client/BaseClient/SchemaServiceBaseClient.php +++ /dev/null @@ -1,578 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/schema_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/schema_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/schema_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/schema_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a schema - * resource. - * - * @param string $project - * @param string $schema - * - * @return string The formatted schema resource. - */ - public static function schemaName(string $project, string $schema): string - { - return self::getPathTemplate('schema')->render([ - 'project' => $project, - 'schema' => $schema, - ]); - } - - /** - * 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} - * - schema: projects/{project}/schemas/{schema} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'pubsub.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Commits a new schema revision to an existing schema. - * - * The async variant is {@see self::commitSchemaAsync()} . - * - * @param CommitSchemaRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Schema - * - * @throws ApiException Thrown if the API call fails. - */ - public function commitSchema(CommitSchemaRequest $request, array $callOptions = []): Schema - { - return $this->startApiCall('CommitSchema', $request, $callOptions)->wait(); - } - - /** - * Creates a schema. - * - * The async variant is {@see self::createSchemaAsync()} . - * - * @param CreateSchemaRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Schema - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSchema(CreateSchemaRequest $request, array $callOptions = []): Schema - { - return $this->startApiCall('CreateSchema', $request, $callOptions)->wait(); - } - - /** - * Deletes a schema. - * - * The async variant is {@see self::deleteSchemaAsync()} . - * - * @param DeleteSchemaRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSchema(DeleteSchemaRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteSchema', $request, $callOptions)->wait(); - } - - /** - * Deletes a specific schema revision. - * - * The async variant is {@see self::deleteSchemaRevisionAsync()} . - * - * @param DeleteSchemaRevisionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Schema - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSchemaRevision(DeleteSchemaRevisionRequest $request, array $callOptions = []): Schema - { - return $this->startApiCall('DeleteSchemaRevision', $request, $callOptions)->wait(); - } - - /** - * Gets a schema. - * - * The async variant is {@see self::getSchemaAsync()} . - * - * @param GetSchemaRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Schema - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSchema(GetSchemaRequest $request, array $callOptions = []): Schema - { - return $this->startApiCall('GetSchema', $request, $callOptions)->wait(); - } - - /** - * Lists all schema revisions for the named schema. - * - * The async variant is {@see self::listSchemaRevisionsAsync()} . - * - * @param ListSchemaRevisionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSchemaRevisions(ListSchemaRevisionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSchemaRevisions', $request, $callOptions); - } - - /** - * Lists schemas in a project. - * - * The async variant is {@see self::listSchemasAsync()} . - * - * @param ListSchemasRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSchemas(ListSchemasRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSchemas', $request, $callOptions); - } - - /** - * Creates a new schema revision that is a copy of the provided revision_id. - * - * The async variant is {@see self::rollbackSchemaAsync()} . - * - * @param RollbackSchemaRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Schema - * - * @throws ApiException Thrown if the API call fails. - */ - public function rollbackSchema(RollbackSchemaRequest $request, array $callOptions = []): Schema - { - return $this->startApiCall('RollbackSchema', $request, $callOptions)->wait(); - } - - /** - * Validates a message against a schema. - * - * The async variant is {@see self::validateMessageAsync()} . - * - * @param ValidateMessageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ValidateMessageResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function validateMessage(ValidateMessageRequest $request, array $callOptions = []): ValidateMessageResponse - { - return $this->startApiCall('ValidateMessage', $request, $callOptions)->wait(); - } - - /** - * Validates a schema. - * - * The async variant is {@see self::validateSchemaAsync()} . - * - * @param ValidateSchemaRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ValidateSchemaResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function validateSchema(ValidateSchemaRequest $request, array $callOptions = []): ValidateSchemaResponse - { - return $this->startApiCall('ValidateSchema', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/PubSub/src/V1/Client/BaseClient/SubscriberBaseClient.php b/PubSub/src/V1/Client/BaseClient/SubscriberBaseClient.php deleted file mode 100644 index 8e71f6b20b21..000000000000 --- a/PubSub/src/V1/Client/BaseClient/SubscriberBaseClient.php +++ /dev/null @@ -1,865 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/subscriber_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/subscriber_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/subscriber_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/subscriber_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * _deleted-topic_ resource. - * - * @return string The formatted _deleted-topic_ resource. - */ - public static function deletedTopicName(): string - { - return self::getPathTemplate('deletedTopic')->render([]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_topic resource. - * - * @param string $project - * @param string $topic - * - * @return string The formatted project_topic resource. - */ - public static function projectTopicName(string $project, string $topic): string - { - return self::getPathTemplate('projectTopic')->render([ - 'project' => $project, - 'topic' => $topic, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a snapshot - * resource. - * - * @param string $project - * @param string $snapshot - * - * @return string The formatted snapshot resource. - */ - public static function snapshotName(string $project, string $snapshot): string - { - return self::getPathTemplate('snapshot')->render([ - 'project' => $project, - 'snapshot' => $snapshot, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a subscription - * resource. - * - * @param string $project - * @param string $subscription - * - * @return string The formatted subscription resource. - */ - public static function subscriptionName(string $project, string $subscription): string - { - return self::getPathTemplate('subscription')->render([ - 'project' => $project, - 'subscription' => $subscription, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a topic - * resource. - * - * @param string $project - * @param string $topic - * - * @return string The formatted topic resource. - */ - public static function topicName(string $project, string $topic): string - { - return self::getPathTemplate('topic')->render([ - 'project' => $project, - 'topic' => $topic, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - deletedTopic: _deleted-topic_ - * - project: projects/{project} - * - projectTopic: projects/{project}/topics/{topic} - * - snapshot: projects/{project}/snapshots/{snapshot} - * - subscription: projects/{project}/subscriptions/{subscription} - * - topic: projects/{project}/topics/{topic} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'pubsub.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Acknowledges the messages associated with the `ack_ids` in the - * `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages - * from the subscription. - * - * Acknowledging a message whose ack deadline has expired may succeed, - * but such a message may be redelivered later. Acknowledging a message more - * than once will not result in an error. - * - * The async variant is {@see self::acknowledgeAsync()} . - * - * @param AcknowledgeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function acknowledge(AcknowledgeRequest $request, array $callOptions = []): void - { - $this->startApiCall('Acknowledge', $request, $callOptions)->wait(); - } - - /** - * Creates a snapshot from the requested subscription. Snapshots are used in - * [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, - * which allow you to manage message acknowledgments in bulk. That is, you can - * set the acknowledgment state of messages in an existing subscription to the - * state captured by a snapshot. - * If the snapshot already exists, returns `ALREADY_EXISTS`. - * If the requested subscription doesn't exist, returns `NOT_FOUND`. - * If the backlog in the subscription is too old -- and the resulting snapshot - * would expire in less than 1 hour -- then `FAILED_PRECONDITION` is returned. - * See also the `Snapshot.expire_time` field. If the name is not provided in - * the request, the server will assign a random - * name for this snapshot on the same project as the subscription, conforming - * to the [resource name format] - * (https://cloud.google.com/pubsub/docs/admin#resource_names). The - * generated name is populated in the returned Snapshot object. Note that for - * REST API requests, you must specify a name in the request. - * - * The async variant is {@see self::createSnapshotAsync()} . - * - * @param CreateSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Snapshot - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSnapshot(CreateSnapshotRequest $request, array $callOptions = []): Snapshot - { - return $this->startApiCall('CreateSnapshot', $request, $callOptions)->wait(); - } - - /** - * Creates a subscription to a given topic. See the [resource name rules] - * (https://cloud.google.com/pubsub/docs/admin#resource_names). - * If the subscription already exists, returns `ALREADY_EXISTS`. - * If the corresponding topic doesn't exist, returns `NOT_FOUND`. - * - * If the name is not provided in the request, the server will assign a random - * name for this subscription on the same project as the topic, conforming - * to the [resource name format] - * (https://cloud.google.com/pubsub/docs/admin#resource_names). The generated - * name is populated in the returned Subscription object. Note that for REST - * API requests, you must specify a name in the request. - * - * The async variant is {@see self::createSubscriptionAsync()} . - * - * @param Subscription $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Subscription - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSubscription(Subscription $request, array $callOptions = []): Subscription - { - return $this->startApiCall('CreateSubscription', $request, $callOptions)->wait(); - } - - /** - * Removes an existing snapshot. Snapshots are used in [Seek] - * (https://cloud.google.com/pubsub/docs/replay-overview) operations, which - * allow you to manage message acknowledgments in bulk. That is, you can set - * the acknowledgment state of messages in an existing subscription to the - * state captured by a snapshot. - * When the snapshot is deleted, all messages retained in the snapshot - * are immediately dropped. After a snapshot is deleted, a new one may be - * created with the same name, but the new one has no association with the old - * snapshot or its subscription, unless the same subscription is specified. - * - * The async variant is {@see self::deleteSnapshotAsync()} . - * - * @param DeleteSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSnapshot(DeleteSnapshotRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteSnapshot', $request, $callOptions)->wait(); - } - - /** - * Deletes an existing subscription. All messages retained in the subscription - * are immediately dropped. Calls to `Pull` after deletion will return - * `NOT_FOUND`. After a subscription is deleted, a new one may be created with - * the same name, but the new one has no association with the old - * subscription or its topic unless the same topic is specified. - * - * The async variant is {@see self::deleteSubscriptionAsync()} . - * - * @param DeleteSubscriptionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSubscription(DeleteSubscriptionRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteSubscription', $request, $callOptions)->wait(); - } - - /** - * Gets the configuration details of a snapshot. Snapshots are used in - * [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, - * which allow you to manage message acknowledgments in bulk. That is, you can - * set the acknowledgment state of messages in an existing subscription to the - * state captured by a snapshot. - * - * The async variant is {@see self::getSnapshotAsync()} . - * - * @param GetSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Snapshot - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSnapshot(GetSnapshotRequest $request, array $callOptions = []): Snapshot - { - return $this->startApiCall('GetSnapshot', $request, $callOptions)->wait(); - } - - /** - * Gets the configuration details of a subscription. - * - * The async variant is {@see self::getSubscriptionAsync()} . - * - * @param GetSubscriptionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Subscription - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSubscription(GetSubscriptionRequest $request, array $callOptions = []): Subscription - { - return $this->startApiCall('GetSubscription', $request, $callOptions)->wait(); - } - - /** - * Lists the existing snapshots. Snapshots are used in [Seek]( - * https://cloud.google.com/pubsub/docs/replay-overview) operations, which - * allow you to manage message acknowledgments in bulk. That is, you can set - * the acknowledgment state of messages in an existing subscription to the - * state captured by a snapshot. - * - * The async variant is {@see self::listSnapshotsAsync()} . - * - * @param ListSnapshotsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSnapshots(ListSnapshotsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSnapshots', $request, $callOptions); - } - - /** - * Lists matching subscriptions. - * - * The async variant is {@see self::listSubscriptionsAsync()} . - * - * @param ListSubscriptionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSubscriptions(ListSubscriptionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSubscriptions', $request, $callOptions); - } - - /** - * Modifies the ack deadline for a specific message. This method is useful - * to indicate that more time is needed to process a message by the - * subscriber, or to make the message available for redelivery if the - * processing was interrupted. Note that this does not modify the - * subscription-level `ackDeadlineSeconds` used for subsequent messages. - * - * The async variant is {@see self::modifyAckDeadlineAsync()} . - * - * @param ModifyAckDeadlineRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function modifyAckDeadline(ModifyAckDeadlineRequest $request, array $callOptions = []): void - { - $this->startApiCall('ModifyAckDeadline', $request, $callOptions)->wait(); - } - - /** - * Modifies the `PushConfig` for a specified subscription. - * - * This may be used to change a push subscription to a pull one (signified by - * an empty `PushConfig`) or vice versa, or change the endpoint URL and other - * attributes of a push subscription. Messages will accumulate for delivery - * continuously through the call regardless of changes to the `PushConfig`. - * - * The async variant is {@see self::modifyPushConfigAsync()} . - * - * @param ModifyPushConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function modifyPushConfig(ModifyPushConfigRequest $request, array $callOptions = []): void - { - $this->startApiCall('ModifyPushConfig', $request, $callOptions)->wait(); - } - - /** - * Pulls messages from the server. - * - * The async variant is {@see self::pullAsync()} . - * - * @param PullRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PullResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function pull(PullRequest $request, array $callOptions = []): PullResponse - { - return $this->startApiCall('Pull', $request, $callOptions)->wait(); - } - - /** - * Seeks an existing subscription to a point in time or to a given snapshot, - * whichever is provided in the request. Snapshots are used in [Seek] - * (https://cloud.google.com/pubsub/docs/replay-overview) operations, which - * allow you to manage message acknowledgments in bulk. That is, you can set - * the acknowledgment state of messages in an existing subscription to the - * state captured by a snapshot. Note that both the subscription and the - * snapshot must be on the same topic. - * - * The async variant is {@see self::seekAsync()} . - * - * @param SeekRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SeekResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function seek(SeekRequest $request, array $callOptions = []): SeekResponse - { - return $this->startApiCall('Seek', $request, $callOptions)->wait(); - } - - /** - * Establishes a stream with the server, which sends messages down to the - * client. The client streams acknowledgements and ack deadline modifications - * back to the server. The server will close the stream and return the status - * on any error. The server may close the stream with status `UNAVAILABLE` to - * reassign server-side resources, in which case, the client should - * re-establish the stream. Flow control can be achieved by configuring the - * underlying RPC channel. - * - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return BidiStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function streamingPull(array $callOptions = []): BidiStream - { - return $this->startApiCall('StreamingPull', null, $callOptions); - } - - /** - * Updates an existing snapshot. Snapshots are used in - * [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, - * which allow you to manage message acknowledgments in bulk. That is, you can - * set the acknowledgment state of messages in an existing subscription to the - * state captured by a snapshot. - * - * The async variant is {@see self::updateSnapshotAsync()} . - * - * @param UpdateSnapshotRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Snapshot - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSnapshot(UpdateSnapshotRequest $request, array $callOptions = []): Snapshot - { - return $this->startApiCall('UpdateSnapshot', $request, $callOptions)->wait(); - } - - /** - * Updates an existing subscription. Note that certain properties of a - * subscription, such as its topic, are not modifiable. - * - * The async variant is {@see self::updateSubscriptionAsync()} . - * - * @param UpdateSubscriptionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Subscription - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSubscription(UpdateSubscriptionRequest $request, array $callOptions = []): Subscription - { - return $this->startApiCall('UpdateSubscription', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/PubSub/src/V1/Client/PublisherClient.php b/PubSub/src/V1/Client/PublisherClient.php index 80f22781de9b..d12919331424 100644 --- a/PubSub/src/V1/Client/PublisherClient.php +++ b/PubSub/src/V1/Client/PublisherClient.php @@ -24,17 +24,607 @@ namespace Google\Cloud\PubSub\V1\Client; -use Google\Cloud\PubSub\V1\Client\BaseClient\PublisherBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\PubSub\V1\DeleteTopicRequest; +use Google\Cloud\PubSub\V1\DetachSubscriptionRequest; +use Google\Cloud\PubSub\V1\DetachSubscriptionResponse; +use Google\Cloud\PubSub\V1\GetTopicRequest; +use Google\Cloud\PubSub\V1\ListTopicSnapshotsRequest; +use Google\Cloud\PubSub\V1\ListTopicSubscriptionsRequest; +use Google\Cloud\PubSub\V1\ListTopicsRequest; +use Google\Cloud\PubSub\V1\PublishRequest; +use Google\Cloud\PubSub\V1\PublishResponse; +use Google\Cloud\PubSub\V1\Topic; +use Google\Cloud\PubSub\V1\UpdateTopicRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The service that an application uses to manipulate topics, and to send + * messages to a topic. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\PubSub\V1\PublisherClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createTopicAsync(Topic $request, array $optionalArgs = []) + * @method PromiseInterface deleteTopicAsync(DeleteTopicRequest $request, array $optionalArgs = []) + * @method PromiseInterface detachSubscriptionAsync(DetachSubscriptionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTopicAsync(GetTopicRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTopicSnapshotsAsync(ListTopicSnapshotsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTopicSubscriptionsAsync(ListTopicSubscriptionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTopicsAsync(ListTopicsRequest $request, array $optionalArgs = []) + * @method PromiseInterface publishAsync(PublishRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateTopicAsync(UpdateTopicRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class PublisherClient extends PublisherBaseClient +final class PublisherClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see PublisherBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.pubsub.v1.Publisher'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'pubsub.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/pubsub', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/publisher_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/publisher_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/publisher_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/publisher_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * _deleted-topic_ resource. + * + * @return string The formatted _deleted-topic_ resource. + */ + public static function deletedTopicName(): string + { + return self::getPathTemplate('deletedTopic')->render([]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_topic resource. + * + * @param string $project + * @param string $topic + * + * @return string The formatted project_topic resource. + */ + public static function projectTopicName(string $project, string $topic): string + { + return self::getPathTemplate('projectTopic')->render([ + 'project' => $project, + 'topic' => $topic, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a schema + * resource. + * + * @param string $project + * @param string $schema + * + * @return string The formatted schema resource. + */ + public static function schemaName(string $project, string $schema): string + { + return self::getPathTemplate('schema')->render([ + 'project' => $project, + 'schema' => $schema, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a subscription + * resource. + * + * @param string $project + * @param string $subscription + * + * @return string The formatted subscription resource. + */ + public static function subscriptionName(string $project, string $subscription): string + { + return self::getPathTemplate('subscription')->render([ + 'project' => $project, + 'subscription' => $subscription, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a topic + * resource. + * + * @param string $project + * @param string $topic + * + * @return string The formatted topic resource. + */ + public static function topicName(string $project, string $topic): string + { + return self::getPathTemplate('topic')->render([ + 'project' => $project, + 'topic' => $topic, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - deletedTopic: _deleted-topic_ + * - project: projects/{project} + * - projectTopic: projects/{project}/topics/{topic} + * - schema: projects/{project}/schemas/{schema} + * - subscription: projects/{project}/subscriptions/{subscription} + * - topic: projects/{project}/topics/{topic} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'pubsub.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates the given topic with the given name. See the [resource name rules] + * (https://cloud.google.com/pubsub/docs/admin#resource_names). + * + * The async variant is {@see PublisherClient::createTopicAsync()} . + * + * @param Topic $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Topic + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTopic(Topic $request, array $callOptions = []): Topic + { + return $this->startApiCall('CreateTopic', $request, $callOptions)->wait(); + } + + /** + * Deletes the topic with the given name. Returns `NOT_FOUND` if the topic + * does not exist. After a topic is deleted, a new topic may be created with + * the same name; this is an entirely new topic with none of the old + * configuration or subscriptions. Existing subscriptions to this topic are + * not deleted, but their `topic` field is set to `_deleted-topic_`. + * + * The async variant is {@see PublisherClient::deleteTopicAsync()} . + * + * @param DeleteTopicRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTopic(DeleteTopicRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteTopic', $request, $callOptions)->wait(); + } + + /** + * Detaches a subscription from this topic. All messages retained in the + * subscription are dropped. Subsequent `Pull` and `StreamingPull` requests + * will return FAILED_PRECONDITION. If the subscription is a push + * subscription, pushes to the endpoint will stop. + * + * The async variant is {@see PublisherClient::detachSubscriptionAsync()} . + * + * @param DetachSubscriptionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DetachSubscriptionResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function detachSubscription(DetachSubscriptionRequest $request, array $callOptions = []): DetachSubscriptionResponse + { + return $this->startApiCall('DetachSubscription', $request, $callOptions)->wait(); + } + + /** + * Gets the configuration of a topic. + * + * The async variant is {@see PublisherClient::getTopicAsync()} . + * + * @param GetTopicRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Topic + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTopic(GetTopicRequest $request, array $callOptions = []): Topic + { + return $this->startApiCall('GetTopic', $request, $callOptions)->wait(); + } + + /** + * Lists the names of the snapshots on this topic. Snapshots are used in + * [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, + * which allow you to manage message acknowledgments in bulk. That is, you can + * set the acknowledgment state of messages in an existing subscription to the + * state captured by a snapshot. + * + * The async variant is {@see PublisherClient::listTopicSnapshotsAsync()} . + * + * @param ListTopicSnapshotsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTopicSnapshots(ListTopicSnapshotsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTopicSnapshots', $request, $callOptions); + } + + /** + * Lists the names of the attached subscriptions on this topic. + * + * The async variant is {@see PublisherClient::listTopicSubscriptionsAsync()} . + * + * @param ListTopicSubscriptionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTopicSubscriptions(ListTopicSubscriptionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTopicSubscriptions', $request, $callOptions); + } + + /** + * Lists matching topics. + * + * The async variant is {@see PublisherClient::listTopicsAsync()} . + * + * @param ListTopicsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTopics(ListTopicsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTopics', $request, $callOptions); + } + + /** + * Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic + * does not exist. + * + * The async variant is {@see PublisherClient::publishAsync()} . + * + * @param PublishRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PublishResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function publish(PublishRequest $request, array $callOptions = []): PublishResponse + { + return $this->startApiCall('Publish', $request, $callOptions)->wait(); + } + + /** + * Updates an existing topic. Note that certain properties of a + * topic are not modifiable. + * + * The async variant is {@see PublisherClient::updateTopicAsync()} . + * + * @param UpdateTopicRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Topic + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTopic(UpdateTopicRequest $request, array $callOptions = []): Topic + { + return $this->startApiCall('UpdateTopic', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see PublisherClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see PublisherClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see PublisherClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/PubSub/src/V1/Client/SchemaServiceClient.php b/PubSub/src/V1/Client/SchemaServiceClient.php index 9fde6a04e2e0..39bbbeff6133 100644 --- a/PubSub/src/V1/Client/SchemaServiceClient.php +++ b/PubSub/src/V1/Client/SchemaServiceClient.php @@ -24,17 +24,553 @@ namespace Google\Cloud\PubSub\V1\Client; -use Google\Cloud\PubSub\V1\Client\BaseClient\SchemaServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\PubSub\V1\CommitSchemaRequest; +use Google\Cloud\PubSub\V1\CreateSchemaRequest; +use Google\Cloud\PubSub\V1\DeleteSchemaRequest; +use Google\Cloud\PubSub\V1\DeleteSchemaRevisionRequest; +use Google\Cloud\PubSub\V1\GetSchemaRequest; +use Google\Cloud\PubSub\V1\ListSchemaRevisionsRequest; +use Google\Cloud\PubSub\V1\ListSchemasRequest; +use Google\Cloud\PubSub\V1\RollbackSchemaRequest; +use Google\Cloud\PubSub\V1\Schema; +use Google\Cloud\PubSub\V1\ValidateMessageRequest; +use Google\Cloud\PubSub\V1\ValidateMessageResponse; +use Google\Cloud\PubSub\V1\ValidateSchemaRequest; +use Google\Cloud\PubSub\V1\ValidateSchemaResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for doing schema-related operations. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\PubSub\V1\SchemaServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface commitSchemaAsync(CommitSchemaRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSchemaAsync(CreateSchemaRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSchemaAsync(DeleteSchemaRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSchemaRevisionAsync(DeleteSchemaRevisionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSchemaAsync(GetSchemaRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSchemaRevisionsAsync(ListSchemaRevisionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSchemasAsync(ListSchemasRequest $request, array $optionalArgs = []) + * @method PromiseInterface rollbackSchemaAsync(RollbackSchemaRequest $request, array $optionalArgs = []) + * @method PromiseInterface validateMessageAsync(ValidateMessageRequest $request, array $optionalArgs = []) + * @method PromiseInterface validateSchemaAsync(ValidateSchemaRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class SchemaServiceClient extends SchemaServiceBaseClient +final class SchemaServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SchemaServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.pubsub.v1.SchemaService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'pubsub.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/pubsub', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/schema_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/schema_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/schema_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/schema_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a schema + * resource. + * + * @param string $project + * @param string $schema + * + * @return string The formatted schema resource. + */ + public static function schemaName(string $project, string $schema): string + { + return self::getPathTemplate('schema')->render([ + 'project' => $project, + 'schema' => $schema, + ]); + } + + /** + * 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} + * - schema: projects/{project}/schemas/{schema} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'pubsub.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Commits a new schema revision to an existing schema. + * + * The async variant is {@see SchemaServiceClient::commitSchemaAsync()} . + * + * @param CommitSchemaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Schema + * + * @throws ApiException Thrown if the API call fails. + */ + public function commitSchema(CommitSchemaRequest $request, array $callOptions = []): Schema + { + return $this->startApiCall('CommitSchema', $request, $callOptions)->wait(); + } + + /** + * Creates a schema. + * + * The async variant is {@see SchemaServiceClient::createSchemaAsync()} . + * + * @param CreateSchemaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Schema + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSchema(CreateSchemaRequest $request, array $callOptions = []): Schema + { + return $this->startApiCall('CreateSchema', $request, $callOptions)->wait(); + } + + /** + * Deletes a schema. + * + * The async variant is {@see SchemaServiceClient::deleteSchemaAsync()} . + * + * @param DeleteSchemaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSchema(DeleteSchemaRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteSchema', $request, $callOptions)->wait(); + } + + /** + * Deletes a specific schema revision. + * + * The async variant is {@see SchemaServiceClient::deleteSchemaRevisionAsync()} . + * + * @param DeleteSchemaRevisionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Schema + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSchemaRevision(DeleteSchemaRevisionRequest $request, array $callOptions = []): Schema + { + return $this->startApiCall('DeleteSchemaRevision', $request, $callOptions)->wait(); + } + + /** + * Gets a schema. + * + * The async variant is {@see SchemaServiceClient::getSchemaAsync()} . + * + * @param GetSchemaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Schema + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSchema(GetSchemaRequest $request, array $callOptions = []): Schema + { + return $this->startApiCall('GetSchema', $request, $callOptions)->wait(); + } + + /** + * Lists all schema revisions for the named schema. + * + * The async variant is {@see SchemaServiceClient::listSchemaRevisionsAsync()} . + * + * @param ListSchemaRevisionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSchemaRevisions(ListSchemaRevisionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSchemaRevisions', $request, $callOptions); + } + + /** + * Lists schemas in a project. + * + * The async variant is {@see SchemaServiceClient::listSchemasAsync()} . + * + * @param ListSchemasRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSchemas(ListSchemasRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSchemas', $request, $callOptions); + } + + /** + * Creates a new schema revision that is a copy of the provided revision_id. + * + * The async variant is {@see SchemaServiceClient::rollbackSchemaAsync()} . + * + * @param RollbackSchemaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Schema + * + * @throws ApiException Thrown if the API call fails. + */ + public function rollbackSchema(RollbackSchemaRequest $request, array $callOptions = []): Schema + { + return $this->startApiCall('RollbackSchema', $request, $callOptions)->wait(); + } + + /** + * Validates a message against a schema. + * + * The async variant is {@see SchemaServiceClient::validateMessageAsync()} . + * + * @param ValidateMessageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ValidateMessageResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function validateMessage(ValidateMessageRequest $request, array $callOptions = []): ValidateMessageResponse + { + return $this->startApiCall('ValidateMessage', $request, $callOptions)->wait(); + } + + /** + * Validates a schema. + * + * The async variant is {@see SchemaServiceClient::validateSchemaAsync()} . + * + * @param ValidateSchemaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ValidateSchemaResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function validateSchema(ValidateSchemaRequest $request, array $callOptions = []): ValidateSchemaResponse + { + return $this->startApiCall('ValidateSchema', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see SchemaServiceClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see SchemaServiceClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see SchemaServiceClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/PubSub/src/V1/Client/SubscriberClient.php b/PubSub/src/V1/Client/SubscriberClient.php index 06ed9b47c4b9..340b80e4206e 100644 --- a/PubSub/src/V1/Client/SubscriberClient.php +++ b/PubSub/src/V1/Client/SubscriberClient.php @@ -24,17 +24,840 @@ namespace Google\Cloud\PubSub\V1\Client; -use Google\Cloud\PubSub\V1\Client\BaseClient\SubscriberBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\BidiStream; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\PubSub\V1\AcknowledgeRequest; +use Google\Cloud\PubSub\V1\CreateSnapshotRequest; +use Google\Cloud\PubSub\V1\DeleteSnapshotRequest; +use Google\Cloud\PubSub\V1\DeleteSubscriptionRequest; +use Google\Cloud\PubSub\V1\GetSnapshotRequest; +use Google\Cloud\PubSub\V1\GetSubscriptionRequest; +use Google\Cloud\PubSub\V1\ListSnapshotsRequest; +use Google\Cloud\PubSub\V1\ListSubscriptionsRequest; +use Google\Cloud\PubSub\V1\ModifyAckDeadlineRequest; +use Google\Cloud\PubSub\V1\ModifyPushConfigRequest; +use Google\Cloud\PubSub\V1\PullRequest; +use Google\Cloud\PubSub\V1\PullResponse; +use Google\Cloud\PubSub\V1\SeekRequest; +use Google\Cloud\PubSub\V1\SeekResponse; +use Google\Cloud\PubSub\V1\Snapshot; +use Google\Cloud\PubSub\V1\Subscription; +use Google\Cloud\PubSub\V1\UpdateSnapshotRequest; +use Google\Cloud\PubSub\V1\UpdateSubscriptionRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The service that an application uses to manipulate subscriptions and to + * consume messages from a subscription via the `Pull` method or by + * establishing a bi-directional stream using the `StreamingPull` method. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\PubSub\V1\SubscriberClient} for the stable implementation * * @experimental + * + * @method PromiseInterface acknowledgeAsync(AcknowledgeRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSnapshotAsync(CreateSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSubscriptionAsync(Subscription $request, array $optionalArgs = []) + * @method PromiseInterface deleteSnapshotAsync(DeleteSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSubscriptionAsync(DeleteSubscriptionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSnapshotAsync(GetSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSubscriptionAsync(GetSubscriptionRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSnapshotsAsync(ListSnapshotsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSubscriptionsAsync(ListSubscriptionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface modifyAckDeadlineAsync(ModifyAckDeadlineRequest $request, array $optionalArgs = []) + * @method PromiseInterface modifyPushConfigAsync(ModifyPushConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface pullAsync(PullRequest $request, array $optionalArgs = []) + * @method PromiseInterface seekAsync(SeekRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSnapshotAsync(UpdateSnapshotRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSubscriptionAsync(UpdateSubscriptionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class SubscriberClient extends SubscriberBaseClient +final class SubscriberClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SubscriberBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.pubsub.v1.Subscriber'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'pubsub.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/pubsub', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/subscriber_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/subscriber_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/subscriber_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/subscriber_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * _deleted-topic_ resource. + * + * @return string The formatted _deleted-topic_ resource. + */ + public static function deletedTopicName(): string + { + return self::getPathTemplate('deletedTopic')->render([]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_topic resource. + * + * @param string $project + * @param string $topic + * + * @return string The formatted project_topic resource. + */ + public static function projectTopicName(string $project, string $topic): string + { + return self::getPathTemplate('projectTopic')->render([ + 'project' => $project, + 'topic' => $topic, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a snapshot + * resource. + * + * @param string $project + * @param string $snapshot + * + * @return string The formatted snapshot resource. + */ + public static function snapshotName(string $project, string $snapshot): string + { + return self::getPathTemplate('snapshot')->render([ + 'project' => $project, + 'snapshot' => $snapshot, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a subscription + * resource. + * + * @param string $project + * @param string $subscription + * + * @return string The formatted subscription resource. + */ + public static function subscriptionName(string $project, string $subscription): string + { + return self::getPathTemplate('subscription')->render([ + 'project' => $project, + 'subscription' => $subscription, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a topic + * resource. + * + * @param string $project + * @param string $topic + * + * @return string The formatted topic resource. + */ + public static function topicName(string $project, string $topic): string + { + return self::getPathTemplate('topic')->render([ + 'project' => $project, + 'topic' => $topic, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - deletedTopic: _deleted-topic_ + * - project: projects/{project} + * - projectTopic: projects/{project}/topics/{topic} + * - snapshot: projects/{project}/snapshots/{snapshot} + * - subscription: projects/{project}/subscriptions/{subscription} + * - topic: projects/{project}/topics/{topic} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'pubsub.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Acknowledges the messages associated with the `ack_ids` in the + * `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages + * from the subscription. + * + * Acknowledging a message whose ack deadline has expired may succeed, + * but such a message may be redelivered later. Acknowledging a message more + * than once will not result in an error. + * + * The async variant is {@see SubscriberClient::acknowledgeAsync()} . + * + * @param AcknowledgeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function acknowledge(AcknowledgeRequest $request, array $callOptions = []): void + { + $this->startApiCall('Acknowledge', $request, $callOptions)->wait(); + } + + /** + * Creates a snapshot from the requested subscription. Snapshots are used in + * [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, + * which allow you to manage message acknowledgments in bulk. That is, you can + * set the acknowledgment state of messages in an existing subscription to the + * state captured by a snapshot. + * If the snapshot already exists, returns `ALREADY_EXISTS`. + * If the requested subscription doesn't exist, returns `NOT_FOUND`. + * If the backlog in the subscription is too old -- and the resulting snapshot + * would expire in less than 1 hour -- then `FAILED_PRECONDITION` is returned. + * See also the `Snapshot.expire_time` field. If the name is not provided in + * the request, the server will assign a random + * name for this snapshot on the same project as the subscription, conforming + * to the [resource name format] + * (https://cloud.google.com/pubsub/docs/admin#resource_names). The + * generated name is populated in the returned Snapshot object. Note that for + * REST API requests, you must specify a name in the request. + * + * The async variant is {@see SubscriberClient::createSnapshotAsync()} . + * + * @param CreateSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Snapshot + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSnapshot(CreateSnapshotRequest $request, array $callOptions = []): Snapshot + { + return $this->startApiCall('CreateSnapshot', $request, $callOptions)->wait(); + } + + /** + * Creates a subscription to a given topic. See the [resource name rules] + * (https://cloud.google.com/pubsub/docs/admin#resource_names). + * If the subscription already exists, returns `ALREADY_EXISTS`. + * If the corresponding topic doesn't exist, returns `NOT_FOUND`. + * + * If the name is not provided in the request, the server will assign a random + * name for this subscription on the same project as the topic, conforming + * to the [resource name format] + * (https://cloud.google.com/pubsub/docs/admin#resource_names). The generated + * name is populated in the returned Subscription object. Note that for REST + * API requests, you must specify a name in the request. + * + * The async variant is {@see SubscriberClient::createSubscriptionAsync()} . + * + * @param Subscription $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Subscription + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSubscription(Subscription $request, array $callOptions = []): Subscription + { + return $this->startApiCall('CreateSubscription', $request, $callOptions)->wait(); + } + + /** + * Removes an existing snapshot. Snapshots are used in [Seek] + * (https://cloud.google.com/pubsub/docs/replay-overview) operations, which + * allow you to manage message acknowledgments in bulk. That is, you can set + * the acknowledgment state of messages in an existing subscription to the + * state captured by a snapshot. + * When the snapshot is deleted, all messages retained in the snapshot + * are immediately dropped. After a snapshot is deleted, a new one may be + * created with the same name, but the new one has no association with the old + * snapshot or its subscription, unless the same subscription is specified. + * + * The async variant is {@see SubscriberClient::deleteSnapshotAsync()} . + * + * @param DeleteSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSnapshot(DeleteSnapshotRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteSnapshot', $request, $callOptions)->wait(); + } + + /** + * Deletes an existing subscription. All messages retained in the subscription + * are immediately dropped. Calls to `Pull` after deletion will return + * `NOT_FOUND`. After a subscription is deleted, a new one may be created with + * the same name, but the new one has no association with the old + * subscription or its topic unless the same topic is specified. + * + * The async variant is {@see SubscriberClient::deleteSubscriptionAsync()} . + * + * @param DeleteSubscriptionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSubscription(DeleteSubscriptionRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteSubscription', $request, $callOptions)->wait(); + } + + /** + * Gets the configuration details of a snapshot. Snapshots are used in + * [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, + * which allow you to manage message acknowledgments in bulk. That is, you can + * set the acknowledgment state of messages in an existing subscription to the + * state captured by a snapshot. + * + * The async variant is {@see SubscriberClient::getSnapshotAsync()} . + * + * @param GetSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Snapshot + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSnapshot(GetSnapshotRequest $request, array $callOptions = []): Snapshot + { + return $this->startApiCall('GetSnapshot', $request, $callOptions)->wait(); + } + + /** + * Gets the configuration details of a subscription. + * + * The async variant is {@see SubscriberClient::getSubscriptionAsync()} . + * + * @param GetSubscriptionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Subscription + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSubscription(GetSubscriptionRequest $request, array $callOptions = []): Subscription + { + return $this->startApiCall('GetSubscription', $request, $callOptions)->wait(); + } + + /** + * Lists the existing snapshots. Snapshots are used in [Seek]( + * https://cloud.google.com/pubsub/docs/replay-overview) operations, which + * allow you to manage message acknowledgments in bulk. That is, you can set + * the acknowledgment state of messages in an existing subscription to the + * state captured by a snapshot. + * + * The async variant is {@see SubscriberClient::listSnapshotsAsync()} . + * + * @param ListSnapshotsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSnapshots(ListSnapshotsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSnapshots', $request, $callOptions); + } + + /** + * Lists matching subscriptions. + * + * The async variant is {@see SubscriberClient::listSubscriptionsAsync()} . + * + * @param ListSubscriptionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSubscriptions(ListSubscriptionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSubscriptions', $request, $callOptions); + } + + /** + * Modifies the ack deadline for a specific message. This method is useful + * to indicate that more time is needed to process a message by the + * subscriber, or to make the message available for redelivery if the + * processing was interrupted. Note that this does not modify the + * subscription-level `ackDeadlineSeconds` used for subsequent messages. + * + * The async variant is {@see SubscriberClient::modifyAckDeadlineAsync()} . + * + * @param ModifyAckDeadlineRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function modifyAckDeadline(ModifyAckDeadlineRequest $request, array $callOptions = []): void + { + $this->startApiCall('ModifyAckDeadline', $request, $callOptions)->wait(); + } + + /** + * Modifies the `PushConfig` for a specified subscription. + * + * This may be used to change a push subscription to a pull one (signified by + * an empty `PushConfig`) or vice versa, or change the endpoint URL and other + * attributes of a push subscription. Messages will accumulate for delivery + * continuously through the call regardless of changes to the `PushConfig`. + * + * The async variant is {@see SubscriberClient::modifyPushConfigAsync()} . + * + * @param ModifyPushConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function modifyPushConfig(ModifyPushConfigRequest $request, array $callOptions = []): void + { + $this->startApiCall('ModifyPushConfig', $request, $callOptions)->wait(); + } + + /** + * Pulls messages from the server. + * + * The async variant is {@see SubscriberClient::pullAsync()} . + * + * @param PullRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PullResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function pull(PullRequest $request, array $callOptions = []): PullResponse + { + return $this->startApiCall('Pull', $request, $callOptions)->wait(); + } + + /** + * Seeks an existing subscription to a point in time or to a given snapshot, + * whichever is provided in the request. Snapshots are used in [Seek] + * (https://cloud.google.com/pubsub/docs/replay-overview) operations, which + * allow you to manage message acknowledgments in bulk. That is, you can set + * the acknowledgment state of messages in an existing subscription to the + * state captured by a snapshot. Note that both the subscription and the + * snapshot must be on the same topic. + * + * The async variant is {@see SubscriberClient::seekAsync()} . + * + * @param SeekRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SeekResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function seek(SeekRequest $request, array $callOptions = []): SeekResponse + { + return $this->startApiCall('Seek', $request, $callOptions)->wait(); + } + + /** + * Establishes a stream with the server, which sends messages down to the + * client. The client streams acknowledgements and ack deadline modifications + * back to the server. The server will close the stream and return the status + * on any error. The server may close the stream with status `UNAVAILABLE` to + * reassign server-side resources, in which case, the client should + * re-establish the stream. Flow control can be achieved by configuring the + * underlying RPC channel. + * + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return BidiStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function streamingPull(array $callOptions = []): BidiStream + { + return $this->startApiCall('StreamingPull', null, $callOptions); + } + + /** + * Updates an existing snapshot. Snapshots are used in + * [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, + * which allow you to manage message acknowledgments in bulk. That is, you can + * set the acknowledgment state of messages in an existing subscription to the + * state captured by a snapshot. + * + * The async variant is {@see SubscriberClient::updateSnapshotAsync()} . + * + * @param UpdateSnapshotRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Snapshot + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSnapshot(UpdateSnapshotRequest $request, array $callOptions = []): Snapshot + { + return $this->startApiCall('UpdateSnapshot', $request, $callOptions)->wait(); + } + + /** + * Updates an existing subscription. Note that certain properties of a + * subscription, such as its topic, are not modifiable. + * + * The async variant is {@see SubscriberClient::updateSubscriptionAsync()} . + * + * @param UpdateSubscriptionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Subscription + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSubscription(UpdateSubscriptionRequest $request, array $callOptions = []): Subscription + { + return $this->startApiCall('UpdateSubscription', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see SubscriberClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see SubscriberClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see SubscriberClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/RapidMigrationAssessment/composer.json b/RapidMigrationAssessment/composer.json index f08f6e87f3d6..db3d5a5857dd 100644 --- a/RapidMigrationAssessment/composer.json +++ b/RapidMigrationAssessment/composer.json @@ -18,7 +18,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.20.0" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/RapidMigrationAssessment/src/V1/Client/BaseClient/RapidMigrationAssessmentBaseClient.php b/RapidMigrationAssessment/src/V1/Client/BaseClient/RapidMigrationAssessmentBaseClient.php deleted file mode 100644 index 8c53bd9a641e..000000000000 --- a/RapidMigrationAssessment/src/V1/Client/BaseClient/RapidMigrationAssessmentBaseClient.php +++ /dev/null @@ -1,716 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . - '/../../resources/rapid_migration_assessment_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../../resources/rapid_migration_assessment_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . - '/../../resources/rapid_migration_assessment_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../../resources/rapid_migration_assessment_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) - ? $this->descriptors[$methodName]['longRunning'] - : []; - $operation = new OperationResponse( - $operationName, - $this->getOperationsClient(), - $options - ); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a annotation - * resource. - * - * @param string $project - * @param string $location - * @param string $annotation - * - * @return string The formatted annotation resource. - */ - public static function annotationName( - string $project, - string $location, - string $annotation - ): string { - return self::getPathTemplate('annotation')->render([ - 'project' => $project, - 'location' => $location, - 'annotation' => $annotation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a collector - * resource. - * - * @param string $project - * @param string $location - * @param string $collector - * - * @return string The formatted collector resource. - */ - public static function collectorName( - string $project, - string $location, - string $collector - ): string { - return self::getPathTemplate('collector')->render([ - 'project' => $project, - 'location' => $location, - 'collector' => $collector, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName( - string $project, - string $location - ): string { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - annotation: projects/{project}/locations/{location}/annotations/{annotation} - * - collector: projects/{project}/locations/{location}/collectors/{collector} - * - location: projects/{project}/locations/{location} - * - * 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( - string $formattedName, - string $template = null - ): array { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'rapidmigrationassessment.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error( - 'Call to undefined method ' . __CLASS__ . "::$method()", - E_USER_ERROR - ); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates an Annotation - * - * The async variant is {@see self::createAnnotationAsync()} . - * - * @example samples/V1/RapidMigrationAssessmentClient/create_annotation.php - * - * @param CreateAnnotationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAnnotation( - CreateAnnotationRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'CreateAnnotation', - $request, - $callOptions - )->wait(); - } - - /** - * Create a Collector to manage the on-prem appliance which collects - * information about Customer assets. - * - * The async variant is {@see self::createCollectorAsync()} . - * - * @example samples/V1/RapidMigrationAssessmentClient/create_collector.php - * - * @param CreateCollectorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCollector( - CreateCollectorRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'CreateCollector', - $request, - $callOptions - )->wait(); - } - - /** - * Deletes a single Collector - changes state of collector to "Deleting". - * Background jobs does final deletion thorugh producer api. - * - * The async variant is {@see self::deleteCollectorAsync()} . - * - * @example samples/V1/RapidMigrationAssessmentClient/delete_collector.php - * - * @param DeleteCollectorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteCollector( - DeleteCollectorRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'DeleteCollector', - $request, - $callOptions - )->wait(); - } - - /** - * Gets details of a single Annotation. - * - * The async variant is {@see self::getAnnotationAsync()} . - * - * @example samples/V1/RapidMigrationAssessmentClient/get_annotation.php - * - * @param GetAnnotationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Annotation - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAnnotation( - GetAnnotationRequest $request, - array $callOptions = [] - ): Annotation { - return $this->startApiCall( - 'GetAnnotation', - $request, - $callOptions - )->wait(); - } - - /** - * Gets details of a single Collector. - * - * The async variant is {@see self::getCollectorAsync()} . - * - * @example samples/V1/RapidMigrationAssessmentClient/get_collector.php - * - * @param GetCollectorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Collector - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCollector( - GetCollectorRequest $request, - array $callOptions = [] - ): Collector { - return $this->startApiCall( - 'GetCollector', - $request, - $callOptions - )->wait(); - } - - /** - * Lists Collectors in a given project and location. - * - * The async variant is {@see self::listCollectorsAsync()} . - * - * @example samples/V1/RapidMigrationAssessmentClient/list_collectors.php - * - * @param ListCollectorsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCollectors( - ListCollectorsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListCollectors', $request, $callOptions); - } - - /** - * Pauses the given collector. - * - * The async variant is {@see self::pauseCollectorAsync()} . - * - * @example samples/V1/RapidMigrationAssessmentClient/pause_collector.php - * - * @param PauseCollectorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function pauseCollector( - PauseCollectorRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'PauseCollector', - $request, - $callOptions - )->wait(); - } - - /** - * Registers the given collector. - * - * The async variant is {@see self::registerCollectorAsync()} . - * - * @example samples/V1/RapidMigrationAssessmentClient/register_collector.php - * - * @param RegisterCollectorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function registerCollector( - RegisterCollectorRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'RegisterCollector', - $request, - $callOptions - )->wait(); - } - - /** - * Resumes the given collector. - * - * The async variant is {@see self::resumeCollectorAsync()} . - * - * @example samples/V1/RapidMigrationAssessmentClient/resume_collector.php - * - * @param ResumeCollectorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function resumeCollector( - ResumeCollectorRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'ResumeCollector', - $request, - $callOptions - )->wait(); - } - - /** - * Updates the parameters of a single Collector. - * - * The async variant is {@see self::updateCollectorAsync()} . - * - * @example samples/V1/RapidMigrationAssessmentClient/update_collector.php - * - * @param UpdateCollectorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCollector( - UpdateCollectorRequest $request, - array $callOptions = [] - ): OperationResponse { - return $this->startApiCall( - 'UpdateCollector', - $request, - $callOptions - )->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/RapidMigrationAssessmentClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation( - GetLocationRequest $request, - array $callOptions = [] - ): Location { - return $this->startApiCall( - 'GetLocation', - $request, - $callOptions - )->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/RapidMigrationAssessmentClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations( - ListLocationsRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/RapidMigrationAssessment/src/V1/Client/RapidMigrationAssessmentClient.php b/RapidMigrationAssessment/src/V1/Client/RapidMigrationAssessmentClient.php index eceaf43984bc..28c7371fab86 100644 --- a/RapidMigrationAssessment/src/V1/Client/RapidMigrationAssessmentClient.php +++ b/RapidMigrationAssessment/src/V1/Client/RapidMigrationAssessmentClient.php @@ -24,17 +24,610 @@ namespace Google\Cloud\RapidMigrationAssessment\V1\Client; -use Google\Cloud\RapidMigrationAssessment\V1\Client\BaseClient\RapidMigrationAssessmentBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\RapidMigrationAssessment\V1\Annotation; +use Google\Cloud\RapidMigrationAssessment\V1\Collector; +use Google\Cloud\RapidMigrationAssessment\V1\CreateAnnotationRequest; +use Google\Cloud\RapidMigrationAssessment\V1\CreateCollectorRequest; +use Google\Cloud\RapidMigrationAssessment\V1\DeleteCollectorRequest; +use Google\Cloud\RapidMigrationAssessment\V1\GetAnnotationRequest; +use Google\Cloud\RapidMigrationAssessment\V1\GetCollectorRequest; +use Google\Cloud\RapidMigrationAssessment\V1\ListCollectorsRequest; +use Google\Cloud\RapidMigrationAssessment\V1\PauseCollectorRequest; +use Google\Cloud\RapidMigrationAssessment\V1\RegisterCollectorRequest; +use Google\Cloud\RapidMigrationAssessment\V1\ResumeCollectorRequest; +use Google\Cloud\RapidMigrationAssessment\V1\UpdateCollectorRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service describing handlers for resources. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createAnnotationAsync(CreateAnnotationRequest $request, array $optionalArgs = []) + * @method PromiseInterface createCollectorAsync(CreateCollectorRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteCollectorAsync(DeleteCollectorRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAnnotationAsync(GetAnnotationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCollectorAsync(GetCollectorRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCollectorsAsync(ListCollectorsRequest $request, array $optionalArgs = []) + * @method PromiseInterface pauseCollectorAsync(PauseCollectorRequest $request, array $optionalArgs = []) + * @method PromiseInterface registerCollectorAsync(RegisterCollectorRequest $request, array $optionalArgs = []) + * @method PromiseInterface resumeCollectorAsync(ResumeCollectorRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCollectorAsync(UpdateCollectorRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class RapidMigrationAssessmentClient extends RapidMigrationAssessmentBaseClient +final class RapidMigrationAssessmentClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RapidMigrationAssessmentBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.rapidmigrationassessment.v1.RapidMigrationAssessment'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'rapidmigrationassessment.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/rapid_migration_assessment_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/rapid_migration_assessment_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/rapid_migration_assessment_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/rapid_migration_assessment_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a annotation + * resource. + * + * @param string $project + * @param string $location + * @param string $annotation + * + * @return string The formatted annotation resource. + */ + public static function annotationName(string $project, string $location, string $annotation): string + { + return self::getPathTemplate('annotation')->render([ + 'project' => $project, + 'location' => $location, + 'annotation' => $annotation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a collector + * resource. + * + * @param string $project + * @param string $location + * @param string $collector + * + * @return string The formatted collector resource. + */ + public static function collectorName(string $project, string $location, string $collector): string + { + return self::getPathTemplate('collector')->render([ + 'project' => $project, + 'location' => $location, + 'collector' => $collector, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - annotation: projects/{project}/locations/{location}/annotations/{annotation} + * - collector: projects/{project}/locations/{location}/collectors/{collector} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'rapidmigrationassessment.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates an Annotation + * + * The async variant is + * {@see RapidMigrationAssessmentClient::createAnnotationAsync()} . + * + * @example samples/V1/RapidMigrationAssessmentClient/create_annotation.php + * + * @param CreateAnnotationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAnnotation(CreateAnnotationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateAnnotation', $request, $callOptions)->wait(); + } + + /** + * Create a Collector to manage the on-prem appliance which collects + * information about Customer assets. + * + * The async variant is + * {@see RapidMigrationAssessmentClient::createCollectorAsync()} . + * + * @example samples/V1/RapidMigrationAssessmentClient/create_collector.php + * + * @param CreateCollectorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCollector(CreateCollectorRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateCollector', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Collector - changes state of collector to "Deleting". + * Background jobs does final deletion thorugh producer api. + * + * The async variant is + * {@see RapidMigrationAssessmentClient::deleteCollectorAsync()} . + * + * @example samples/V1/RapidMigrationAssessmentClient/delete_collector.php + * + * @param DeleteCollectorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteCollector(DeleteCollectorRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteCollector', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Annotation. + * + * The async variant is {@see RapidMigrationAssessmentClient::getAnnotationAsync()} + * . + * + * @example samples/V1/RapidMigrationAssessmentClient/get_annotation.php + * + * @param GetAnnotationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Annotation + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAnnotation(GetAnnotationRequest $request, array $callOptions = []): Annotation + { + return $this->startApiCall('GetAnnotation', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Collector. + * + * The async variant is {@see RapidMigrationAssessmentClient::getCollectorAsync()} + * . + * + * @example samples/V1/RapidMigrationAssessmentClient/get_collector.php + * + * @param GetCollectorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Collector + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCollector(GetCollectorRequest $request, array $callOptions = []): Collector + { + return $this->startApiCall('GetCollector', $request, $callOptions)->wait(); + } + + /** + * Lists Collectors in a given project and location. + * + * The async variant is + * {@see RapidMigrationAssessmentClient::listCollectorsAsync()} . + * + * @example samples/V1/RapidMigrationAssessmentClient/list_collectors.php + * + * @param ListCollectorsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCollectors(ListCollectorsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCollectors', $request, $callOptions); + } + + /** + * Pauses the given collector. + * + * The async variant is + * {@see RapidMigrationAssessmentClient::pauseCollectorAsync()} . + * + * @example samples/V1/RapidMigrationAssessmentClient/pause_collector.php + * + * @param PauseCollectorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function pauseCollector(PauseCollectorRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('PauseCollector', $request, $callOptions)->wait(); + } + + /** + * Registers the given collector. + * + * The async variant is + * {@see RapidMigrationAssessmentClient::registerCollectorAsync()} . + * + * @example samples/V1/RapidMigrationAssessmentClient/register_collector.php + * + * @param RegisterCollectorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function registerCollector(RegisterCollectorRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RegisterCollector', $request, $callOptions)->wait(); + } + + /** + * Resumes the given collector. + * + * The async variant is + * {@see RapidMigrationAssessmentClient::resumeCollectorAsync()} . + * + * @example samples/V1/RapidMigrationAssessmentClient/resume_collector.php + * + * @param ResumeCollectorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function resumeCollector(ResumeCollectorRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ResumeCollector', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single Collector. + * + * The async variant is + * {@see RapidMigrationAssessmentClient::updateCollectorAsync()} . + * + * @example samples/V1/RapidMigrationAssessmentClient/update_collector.php + * + * @param UpdateCollectorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCollector(UpdateCollectorRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateCollector', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see RapidMigrationAssessmentClient::getLocationAsync()} . + * + * @example samples/V1/RapidMigrationAssessmentClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see RapidMigrationAssessmentClient::listLocationsAsync()} + * . + * + * @example samples/V1/RapidMigrationAssessmentClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/RecaptchaEnterprise/VERSION b/RecaptchaEnterprise/VERSION index 9df886c42a1e..bc80560fad66 100644 --- a/RecaptchaEnterprise/VERSION +++ b/RecaptchaEnterprise/VERSION @@ -1 +1 @@ -1.4.2 +1.5.0 diff --git a/RecaptchaEnterprise/composer.json b/RecaptchaEnterprise/composer.json index 3cb5f6abb88f..2aa95d355f32 100644 --- a/RecaptchaEnterprise/composer.json +++ b/RecaptchaEnterprise/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/RecaptchaEnterprise/metadata/V1/Recaptchaenterprise.php b/RecaptchaEnterprise/metadata/V1/Recaptchaenterprise.php index 26688a445009..fb73b9cae59b 100644 Binary files a/RecaptchaEnterprise/metadata/V1/Recaptchaenterprise.php and b/RecaptchaEnterprise/metadata/V1/Recaptchaenterprise.php differ diff --git a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/annotate_assessment.php b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/annotate_assessment.php index dff007885da7..d36307bd057b 100644 --- a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/annotate_assessment.php +++ b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/annotate_assessment.php @@ -33,7 +33,7 @@ * on whether the event turned out to be authentic or fraudulent. * * @param string $formattedName The resource name of the Assessment, in the format - * "projects/{project}/assessments/{assessment}". Please see + * `projects/{project}/assessments/{assessment}`. Please see * {@see RecaptchaEnterpriseServiceClient::assessmentName()} for help formatting this field. * @param int $annotation Optional. The annotation that will be assigned to the Event. This field can * be left empty to provide reasons that apply to an event without concluding diff --git a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/create_assessment.php b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/create_assessment.php index 4b0ff7a75b8e..23223805303b 100644 --- a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/create_assessment.php +++ b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/create_assessment.php @@ -31,7 +31,7 @@ * Creates an Assessment of the likelihood an event is legitimate. * * @param string $formattedParent The name of the project in which the assessment will be created, - * in the format "projects/{project}". Please see + * in the format `projects/{project}`. Please see * {@see RecaptchaEnterpriseServiceClient::projectName()} for help formatting this field. */ function create_assessment_sample(string $formattedParent): void diff --git a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/create_firewall_policy.php b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/create_firewall_policy.php new file mode 100644 index 000000000000..e7d88e842616 --- /dev/null +++ b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/create_firewall_policy.php @@ -0,0 +1,75 @@ +createFirewallPolicy( + $formattedParent, + $firewallPolicy + ); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = RecaptchaEnterpriseServiceClient::projectName('[PROJECT]'); + + create_firewall_policy_sample($formattedParent); +} +// [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateFirewallPolicy_sync] diff --git a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/create_key.php b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/create_key.php index 2d9821f9d876..4ca30880cc87 100644 --- a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/create_key.php +++ b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/create_key.php @@ -31,7 +31,7 @@ * Creates a new reCAPTCHA Enterprise key. * * @param string $formattedParent The name of the project in which the key will be created, in the - * format "projects/{project}". Please see + * format `projects/{project}`. Please see * {@see RecaptchaEnterpriseServiceClient::projectName()} for help formatting this field. */ function create_key_sample(string $formattedParent): void diff --git a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/delete_firewall_policy.php b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/delete_firewall_policy.php new file mode 100644 index 000000000000..abf2ab495135 --- /dev/null +++ b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/delete_firewall_policy.php @@ -0,0 +1,68 @@ +deleteFirewallPolicy($formattedName); + printf('Call completed successfully.' . PHP_EOL); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedName = RecaptchaEnterpriseServiceClient::firewallPolicyName( + '[PROJECT]', + '[FIREWALLPOLICY]' + ); + + delete_firewall_policy_sample($formattedName); +} +// [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteFirewallPolicy_sync] diff --git a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/delete_key.php b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/delete_key.php index 3005b428b913..c3713e62b35a 100644 --- a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/delete_key.php +++ b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/delete_key.php @@ -30,7 +30,7 @@ * Deletes the specified key. * * @param string $formattedName The name of the key to be deleted, in the format - * "projects/{project}/keys/{key}". Please see + * `projects/{project}/keys/{key}`. Please see * {@see RecaptchaEnterpriseServiceClient::keyName()} for help formatting this field. */ function delete_key_sample(string $formattedName): void diff --git a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/get_firewall_policy.php b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/get_firewall_policy.php new file mode 100644 index 000000000000..e268c35843a8 --- /dev/null +++ b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/get_firewall_policy.php @@ -0,0 +1,70 @@ +getFirewallPolicy($formattedName); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedName = RecaptchaEnterpriseServiceClient::firewallPolicyName( + '[PROJECT]', + '[FIREWALLPOLICY]' + ); + + get_firewall_policy_sample($formattedName); +} +// [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetFirewallPolicy_sync] diff --git a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/get_key.php b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/get_key.php index 279c38c219d5..2b2c189cce17 100644 --- a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/get_key.php +++ b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/get_key.php @@ -31,7 +31,7 @@ * Returns the specified key. * * @param string $formattedName The name of the requested key, in the format - * "projects/{project}/keys/{key}". Please see + * `projects/{project}/keys/{key}`. Please see * {@see RecaptchaEnterpriseServiceClient::keyName()} for help formatting this field. */ function get_key_sample(string $formattedName): void diff --git a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/get_metrics.php b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/get_metrics.php index b0eed488b366..6db489596c6e 100644 --- a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/get_metrics.php +++ b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/get_metrics.php @@ -32,7 +32,7 @@ * dashboards. * * @param string $formattedName The name of the requested metrics, in the format - * "projects/{project}/keys/{key}/metrics". Please see + * `projects/{project}/keys/{key}/metrics`. Please see * {@see RecaptchaEnterpriseServiceClient::metricsName()} for help formatting this field. */ function get_metrics_sample(string $formattedName): void diff --git a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/list_firewall_policies.php b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/list_firewall_policies.php new file mode 100644 index 000000000000..8b8cd5a81717 --- /dev/null +++ b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/list_firewall_policies.php @@ -0,0 +1,72 @@ +listFirewallPolicies($formattedParent); + + /** @var FirewallPolicy $element */ + foreach ($response as $element) { + printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = RecaptchaEnterpriseServiceClient::projectName('[PROJECT]'); + + list_firewall_policies_sample($formattedParent); +} +// [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListFirewallPolicies_sync] diff --git a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/list_keys.php b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/list_keys.php index 5e8e7e6d2ce6..1a095fdd94de 100644 --- a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/list_keys.php +++ b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/list_keys.php @@ -32,7 +32,7 @@ * Returns the list of all keys that belong to a project. * * @param string $formattedParent The name of the project that contains the keys that will be - * listed, in the format "projects/{project}". Please see + * listed, in the format `projects/{project}`. Please see * {@see RecaptchaEnterpriseServiceClient::projectName()} for help formatting this field. */ function list_keys_sample(string $formattedParent): void diff --git a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/list_related_account_groups.php b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/list_related_account_groups.php index 9b33c5608caf..a9995d7767e3 100644 --- a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/list_related_account_groups.php +++ b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/list_related_account_groups.php @@ -32,7 +32,7 @@ * List groups of related accounts. * * @param string $formattedParent The name of the project to list related account groups from, in - * the format "projects/{project}". Please see + * the format `projects/{project}`. Please see * {@see RecaptchaEnterpriseServiceClient::projectName()} for help formatting this field. */ function list_related_account_groups_sample(string $formattedParent): void diff --git a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/migrate_key.php b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/migrate_key.php index 373707b905a8..de94d6626c1a 100644 --- a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/migrate_key.php +++ b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/migrate_key.php @@ -31,12 +31,12 @@ * Migrates an existing key from reCAPTCHA to reCAPTCHA Enterprise. * Once a key is migrated, it can be used from either product. SiteVerify * requests are billed as CreateAssessment calls. You must be - * authenticated as one of the current owners of the reCAPTCHA Site Key, and + * authenticated as one of the current owners of the reCAPTCHA Key, and * your user must have the reCAPTCHA Enterprise Admin IAM role in the * destination project. * * @param string $formattedName The name of the key to be migrated, in the format - * "projects/{project}/keys/{key}". Please see + * `projects/{project}/keys/{key}`. Please see * {@see RecaptchaEnterpriseServiceClient::keyName()} for help formatting this field. */ function migrate_key_sample(string $formattedName): void diff --git a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/retrieve_legacy_secret_key.php b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/retrieve_legacy_secret_key.php index 5d0c98fa4762..9141cfc6e5f0 100644 --- a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/retrieve_legacy_secret_key.php +++ b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/retrieve_legacy_secret_key.php @@ -33,7 +33,7 @@ * legacy reCAPTCHA. * * @param string $formattedKey The public key name linked to the requested secret key in the - * format "projects/{project}/keys/{key}". Please see + * format `projects/{project}/keys/{key}`. Please see * {@see RecaptchaEnterpriseServiceClient::keyName()} for help formatting this field. */ function retrieve_legacy_secret_key_sample(string $formattedKey): void diff --git a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/search_related_account_group_memberships.php b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/search_related_account_group_memberships.php index c967ba2fade9..068e311d1518 100644 --- a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/search_related_account_group_memberships.php +++ b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/search_related_account_group_memberships.php @@ -33,7 +33,7 @@ * * @param string $formattedProject The name of the project to search related account group * memberships from. Specify the project name in the following format: - * "projects/{project}". Please see + * `projects/{project}`. Please see * {@see RecaptchaEnterpriseServiceClient::relatedAccountGroupName()} for help formatting this field. */ function search_related_account_group_memberships_sample(string $formattedProject): void diff --git a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/update_firewall_policy.php b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/update_firewall_policy.php new file mode 100644 index 000000000000..72e18aa7f6df --- /dev/null +++ b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/update_firewall_policy.php @@ -0,0 +1,56 @@ +updateFirewallPolicy($firewallPolicy); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_UpdateFirewallPolicy_sync] diff --git a/RecaptchaEnterprise/src/V1/AndroidKeySettings.php b/RecaptchaEnterprise/src/V1/AndroidKeySettings.php index 1d20768e449c..caa6d695edf4 100644 --- a/RecaptchaEnterprise/src/V1/AndroidKeySettings.php +++ b/RecaptchaEnterprise/src/V1/AndroidKeySettings.php @@ -28,6 +28,13 @@ class AndroidKeySettings extends \Google\Protobuf\Internal\Message * Generated from protobuf field repeated string allowed_package_names = 1; */ private $allowed_package_names; + /** + * Set to true for keys that are used in an Android application that is + * available for download in app stores in addition to the Google Play Store. + * + * Generated from protobuf field bool support_non_google_app_store_distribution = 3; + */ + private $support_non_google_app_store_distribution = false; /** * Constructor. @@ -40,6 +47,9 @@ class AndroidKeySettings extends \Google\Protobuf\Internal\Message * @type array|\Google\Protobuf\Internal\RepeatedField $allowed_package_names * Android package names of apps allowed to use the key. * Example: 'com.companyname.appname' + * @type bool $support_non_google_app_store_distribution + * Set to true for keys that are used in an Android application that is + * available for download in app stores in addition to the Google Play Store. * } */ public function __construct($data = NULL) { @@ -101,5 +111,33 @@ public function setAllowedPackageNames($var) return $this; } + /** + * Set to true for keys that are used in an Android application that is + * available for download in app stores in addition to the Google Play Store. + * + * Generated from protobuf field bool support_non_google_app_store_distribution = 3; + * @return bool + */ + public function getSupportNonGoogleAppStoreDistribution() + { + return $this->support_non_google_app_store_distribution; + } + + /** + * Set to true for keys that are used in an Android application that is + * available for download in app stores in addition to the Google Play Store. + * + * Generated from protobuf field bool support_non_google_app_store_distribution = 3; + * @param bool $var + * @return $this + */ + public function setSupportNonGoogleAppStoreDistribution($var) + { + GPBUtil::checkBool($var); + $this->support_non_google_app_store_distribution = $var; + + return $this; + } + } diff --git a/RecaptchaEnterprise/src/V1/AnnotateAssessmentRequest.php b/RecaptchaEnterprise/src/V1/AnnotateAssessmentRequest.php index 2aa1e9841220..4efeb7c85141 100644 --- a/RecaptchaEnterprise/src/V1/AnnotateAssessmentRequest.php +++ b/RecaptchaEnterprise/src/V1/AnnotateAssessmentRequest.php @@ -17,7 +17,7 @@ class AnnotateAssessmentRequest extends \Google\Protobuf\Internal\Message { /** * Required. The resource name of the Assessment, in the format - * "projects/{project}/assessments/{assessment}". + * `projects/{project}/assessments/{assessment}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ @@ -57,7 +57,7 @@ class AnnotateAssessmentRequest extends \Google\Protobuf\Internal\Message /** * @param string $name Required. The resource name of the Assessment, in the format - * "projects/{project}/assessments/{assessment}". Please see + * `projects/{project}/assessments/{assessment}`. Please see * {@see RecaptchaEnterpriseServiceClient::assessmentName()} for help formatting this field. * @param int $annotation Optional. The annotation that will be assigned to the Event. This field can * be left empty to provide reasons that apply to an event without concluding @@ -83,7 +83,7 @@ public static function build(string $name, int $annotation): self * * @type string $name * Required. The resource name of the Assessment, in the format - * "projects/{project}/assessments/{assessment}". + * `projects/{project}/assessments/{assessment}`. * @type int $annotation * Optional. The annotation that will be assigned to the Event. This field can * be left empty to provide reasons that apply to an event without concluding @@ -109,7 +109,7 @@ public function __construct($data = NULL) { /** * Required. The resource name of the Assessment, in the format - * "projects/{project}/assessments/{assessment}". + * `projects/{project}/assessments/{assessment}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @return string @@ -121,7 +121,7 @@ public function getName() /** * Required. The resource name of the Assessment, in the format - * "projects/{project}/assessments/{assessment}". + * `projects/{project}/assessments/{assessment}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @param string $var diff --git a/RecaptchaEnterprise/src/V1/AppleDeveloperId.php b/RecaptchaEnterprise/src/V1/AppleDeveloperId.php new file mode 100644 index 000000000000..0fe0003d5482 --- /dev/null +++ b/RecaptchaEnterprise/src/V1/AppleDeveloperId.php @@ -0,0 +1,147 @@ +google.cloud.recaptchaenterprise.v1.AppleDeveloperId + */ +class AppleDeveloperId extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Input only. A private key (downloaded as a text file with a .p8 + * file extension) generated for your Apple Developer account. Ensure that + * Apple DeviceCheck is enabled for the private key. + * + * Generated from protobuf field string private_key = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.field_behavior) = INPUT_ONLY]; + */ + private $private_key = ''; + /** + * Required. The Apple developer key ID (10-character string). + * + * Generated from protobuf field string key_id = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $key_id = ''; + /** + * Required. The Apple team ID (10-character string) owning the provisioning + * profile used to build your application. + * + * Generated from protobuf field string team_id = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + private $team_id = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $private_key + * Required. Input only. A private key (downloaded as a text file with a .p8 + * file extension) generated for your Apple Developer account. Ensure that + * Apple DeviceCheck is enabled for the private key. + * @type string $key_id + * Required. The Apple developer key ID (10-character string). + * @type string $team_id + * Required. The Apple team ID (10-character string) owning the provisioning + * profile used to build your application. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + + /** + * Required. Input only. A private key (downloaded as a text file with a .p8 + * file extension) generated for your Apple Developer account. Ensure that + * Apple DeviceCheck is enabled for the private key. + * + * Generated from protobuf field string private_key = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.field_behavior) = INPUT_ONLY]; + * @return string + */ + public function getPrivateKey() + { + return $this->private_key; + } + + /** + * Required. Input only. A private key (downloaded as a text file with a .p8 + * file extension) generated for your Apple Developer account. Ensure that + * Apple DeviceCheck is enabled for the private key. + * + * Generated from protobuf field string private_key = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.field_behavior) = INPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setPrivateKey($var) + { + GPBUtil::checkString($var, True); + $this->private_key = $var; + + return $this; + } + + /** + * Required. The Apple developer key ID (10-character string). + * + * Generated from protobuf field string key_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getKeyId() + { + return $this->key_id; + } + + /** + * Required. The Apple developer key ID (10-character string). + * + * Generated from protobuf field string key_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setKeyId($var) + { + GPBUtil::checkString($var, True); + $this->key_id = $var; + + return $this; + } + + /** + * Required. The Apple team ID (10-character string) owning the provisioning + * profile used to build your application. + * + * Generated from protobuf field string team_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getTeamId() + { + return $this->team_id; + } + + /** + * Required. The Apple team ID (10-character string) owning the provisioning + * profile used to build your application. + * + * Generated from protobuf field string team_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setTeamId($var) + { + GPBUtil::checkString($var, True); + $this->team_id = $var; + + return $this; + } + +} + diff --git a/RecaptchaEnterprise/src/V1/Assessment.php b/RecaptchaEnterprise/src/V1/Assessment.php index 6cf185900bdd..10f4781a8549 100644 --- a/RecaptchaEnterprise/src/V1/Assessment.php +++ b/RecaptchaEnterprise/src/V1/Assessment.php @@ -17,7 +17,7 @@ class Assessment extends \Google\Protobuf\Internal\Message { /** * Output only. The resource name for the Assessment in the format - * "projects/{project}/assessments/{assessment}". + * `projects/{project}/assessments/{assessment}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ @@ -61,12 +61,26 @@ class Assessment extends \Google\Protobuf\Internal\Message * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.PrivatePasswordLeakVerification private_password_leak_verification = 8; */ private $private_password_leak_verification = null; + /** + * Assessment returned when firewall policies belonging to the project are + * evaluated using the field firewall_policy_evaluation. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallPolicyAssessment firewall_policy_assessment = 10; + */ + private $firewall_policy_assessment = null; /** * Assessment returned by Fraud Prevention when TransactionData is provided. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FraudPreventionAssessment fraud_prevention_assessment = 11; */ private $fraud_prevention_assessment = null; + /** + * Output only. Fraud Signals specific to the users involved in a payment + * transaction. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FraudSignals fraud_signals = 13 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $fraud_signals = null; /** * Constructor. @@ -76,7 +90,7 @@ class Assessment extends \Google\Protobuf\Internal\Message * * @type string $name * Output only. The resource name for the Assessment in the format - * "projects/{project}/assessments/{assessment}". + * `projects/{project}/assessments/{assessment}`. * @type \Google\Cloud\RecaptchaEnterprise\V1\Event $event * The event being assessed. * @type \Google\Cloud\RecaptchaEnterprise\V1\RiskAnalysis $risk_analysis @@ -92,8 +106,14 @@ class Assessment extends \Google\Protobuf\Internal\Message * @type \Google\Cloud\RecaptchaEnterprise\V1\PrivatePasswordLeakVerification $private_password_leak_verification * The private password leak verification field contains the parameters that * are used to to check for leaks privately without sharing user credentials. + * @type \Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicyAssessment $firewall_policy_assessment + * Assessment returned when firewall policies belonging to the project are + * evaluated using the field firewall_policy_evaluation. * @type \Google\Cloud\RecaptchaEnterprise\V1\FraudPreventionAssessment $fraud_prevention_assessment * Assessment returned by Fraud Prevention when TransactionData is provided. + * @type \Google\Cloud\RecaptchaEnterprise\V1\FraudSignals $fraud_signals + * Output only. Fraud Signals specific to the users involved in a payment + * transaction. * } */ public function __construct($data = NULL) { @@ -103,7 +123,7 @@ public function __construct($data = NULL) { /** * Output only. The resource name for the Assessment in the format - * "projects/{project}/assessments/{assessment}". + * `projects/{project}/assessments/{assessment}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @return string @@ -115,7 +135,7 @@ public function getName() /** * Output only. The resource name for the Assessment in the format - * "projects/{project}/assessments/{assessment}". + * `projects/{project}/assessments/{assessment}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param string $var @@ -351,6 +371,44 @@ public function setPrivatePasswordLeakVerification($var) return $this; } + /** + * Assessment returned when firewall policies belonging to the project are + * evaluated using the field firewall_policy_evaluation. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallPolicyAssessment firewall_policy_assessment = 10; + * @return \Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicyAssessment|null + */ + public function getFirewallPolicyAssessment() + { + return $this->firewall_policy_assessment; + } + + public function hasFirewallPolicyAssessment() + { + return isset($this->firewall_policy_assessment); + } + + public function clearFirewallPolicyAssessment() + { + unset($this->firewall_policy_assessment); + } + + /** + * Assessment returned when firewall policies belonging to the project are + * evaluated using the field firewall_policy_evaluation. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallPolicyAssessment firewall_policy_assessment = 10; + * @param \Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicyAssessment $var + * @return $this + */ + public function setFirewallPolicyAssessment($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicyAssessment::class); + $this->firewall_policy_assessment = $var; + + return $this; + } + /** * Assessment returned by Fraud Prevention when TransactionData is provided. * @@ -387,5 +445,43 @@ public function setFraudPreventionAssessment($var) return $this; } + /** + * Output only. Fraud Signals specific to the users involved in a payment + * transaction. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FraudSignals fraud_signals = 13 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Cloud\RecaptchaEnterprise\V1\FraudSignals|null + */ + public function getFraudSignals() + { + return $this->fraud_signals; + } + + public function hasFraudSignals() + { + return isset($this->fraud_signals); + } + + public function clearFraudSignals() + { + unset($this->fraud_signals); + } + + /** + * Output only. Fraud Signals specific to the users involved in a payment + * transaction. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FraudSignals fraud_signals = 13 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Cloud\RecaptchaEnterprise\V1\FraudSignals $var + * @return $this + */ + public function setFraudSignals($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\RecaptchaEnterprise\V1\FraudSignals::class); + $this->fraud_signals = $var; + + return $this; + } + } diff --git a/RecaptchaEnterprise/src/V1/Client/BaseClient/RecaptchaEnterpriseServiceBaseClient.php b/RecaptchaEnterprise/src/V1/Client/BaseClient/RecaptchaEnterpriseServiceBaseClient.php deleted file mode 100644 index 586a9831f5b6..000000000000 --- a/RecaptchaEnterprise/src/V1/Client/BaseClient/RecaptchaEnterpriseServiceBaseClient.php +++ /dev/null @@ -1,630 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/recaptcha_enterprise_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/recaptcha_enterprise_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/recaptcha_enterprise_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/recaptcha_enterprise_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a assessment - * resource. - * - * @param string $project - * @param string $assessment - * - * @return string The formatted assessment resource. - */ - public static function assessmentName(string $project, string $assessment): string - { - return self::getPathTemplate('assessment')->render([ - 'project' => $project, - 'assessment' => $assessment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a key - * resource. - * - * @param string $project - * @param string $key - * - * @return string The formatted key resource. - */ - public static function keyName(string $project, string $key): string - { - return self::getPathTemplate('key')->render([ - 'project' => $project, - 'key' => $key, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a metrics - * resource. - * - * @param string $project - * @param string $key - * - * @return string The formatted metrics resource. - */ - public static function metricsName(string $project, string $key): string - { - return self::getPathTemplate('metrics')->render([ - 'project' => $project, - 'key' => $key, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * related_account_group resource. - * - * @param string $project - * @param string $relatedaccountgroup - * - * @return string The formatted related_account_group resource. - */ - public static function relatedAccountGroupName(string $project, string $relatedaccountgroup): string - { - return self::getPathTemplate('relatedAccountGroup')->render([ - 'project' => $project, - 'relatedaccountgroup' => $relatedaccountgroup, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - assessment: projects/{project}/assessments/{assessment} - * - key: projects/{project}/keys/{key} - * - metrics: projects/{project}/keys/{key}/metrics - * - project: projects/{project} - * - relatedAccountGroup: projects/{project}/relatedaccountgroups/{relatedaccountgroup} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'recaptchaenterprise.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Annotates a previously created Assessment to provide additional information - * on whether the event turned out to be authentic or fraudulent. - * - * The async variant is {@see self::annotateAssessmentAsync()} . - * - * @param AnnotateAssessmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AnnotateAssessmentResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function annotateAssessment(AnnotateAssessmentRequest $request, array $callOptions = []): AnnotateAssessmentResponse - { - return $this->startApiCall('AnnotateAssessment', $request, $callOptions)->wait(); - } - - /** - * Creates an Assessment of the likelihood an event is legitimate. - * - * The async variant is {@see self::createAssessmentAsync()} . - * - * @param CreateAssessmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Assessment - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAssessment(CreateAssessmentRequest $request, array $callOptions = []): Assessment - { - return $this->startApiCall('CreateAssessment', $request, $callOptions)->wait(); - } - - /** - * Creates a new reCAPTCHA Enterprise key. - * - * The async variant is {@see self::createKeyAsync()} . - * - * @param CreateKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Key - * - * @throws ApiException Thrown if the API call fails. - */ - public function createKey(CreateKeyRequest $request, array $callOptions = []): Key - { - return $this->startApiCall('CreateKey', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified key. - * - * The async variant is {@see self::deleteKeyAsync()} . - * - * @param DeleteKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteKey(DeleteKeyRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteKey', $request, $callOptions)->wait(); - } - - /** - * Returns the specified key. - * - * The async variant is {@see self::getKeyAsync()} . - * - * @param GetKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Key - * - * @throws ApiException Thrown if the API call fails. - */ - public function getKey(GetKeyRequest $request, array $callOptions = []): Key - { - return $this->startApiCall('GetKey', $request, $callOptions)->wait(); - } - - /** - * Get some aggregated metrics for a Key. This data can be used to build - * dashboards. - * - * The async variant is {@see self::getMetricsAsync()} . - * - * @param GetMetricsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Metrics - * - * @throws ApiException Thrown if the API call fails. - */ - public function getMetrics(GetMetricsRequest $request, array $callOptions = []): Metrics - { - return $this->startApiCall('GetMetrics', $request, $callOptions)->wait(); - } - - /** - * Returns the list of all keys that belong to a project. - * - * The async variant is {@see self::listKeysAsync()} . - * - * @param ListKeysRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listKeys(ListKeysRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListKeys', $request, $callOptions); - } - - /** - * Get memberships in a group of related accounts. - * - * The async variant is {@see self::listRelatedAccountGroupMembershipsAsync()} . - * - * @param ListRelatedAccountGroupMembershipsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listRelatedAccountGroupMemberships(ListRelatedAccountGroupMembershipsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListRelatedAccountGroupMemberships', $request, $callOptions); - } - - /** - * List groups of related accounts. - * - * The async variant is {@see self::listRelatedAccountGroupsAsync()} . - * - * @param ListRelatedAccountGroupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listRelatedAccountGroups(ListRelatedAccountGroupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListRelatedAccountGroups', $request, $callOptions); - } - - /** - * Migrates an existing key from reCAPTCHA to reCAPTCHA Enterprise. - * Once a key is migrated, it can be used from either product. SiteVerify - * requests are billed as CreateAssessment calls. You must be - * authenticated as one of the current owners of the reCAPTCHA Site Key, and - * your user must have the reCAPTCHA Enterprise Admin IAM role in the - * destination project. - * - * The async variant is {@see self::migrateKeyAsync()} . - * - * @param MigrateKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Key - * - * @throws ApiException Thrown if the API call fails. - */ - public function migrateKey(MigrateKeyRequest $request, array $callOptions = []): Key - { - return $this->startApiCall('MigrateKey', $request, $callOptions)->wait(); - } - - /** - * Returns the secret key related to the specified public key. - * You must use the legacy secret key only in a 3rd party integration with - * legacy reCAPTCHA. - * - * The async variant is {@see self::retrieveLegacySecretKeyAsync()} . - * - * @param RetrieveLegacySecretKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RetrieveLegacySecretKeyResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function retrieveLegacySecretKey(RetrieveLegacySecretKeyRequest $request, array $callOptions = []): RetrieveLegacySecretKeyResponse - { - return $this->startApiCall('RetrieveLegacySecretKey', $request, $callOptions)->wait(); - } - - /** - * Search group memberships related to a given account. - * - * The async variant is {@see self::searchRelatedAccountGroupMembershipsAsync()} . - * - * @param SearchRelatedAccountGroupMembershipsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchRelatedAccountGroupMemberships(SearchRelatedAccountGroupMembershipsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchRelatedAccountGroupMemberships', $request, $callOptions); - } - - /** - * Updates the specified key. - * - * The async variant is {@see self::updateKeyAsync()} . - * - * @param UpdateKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Key - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateKey(UpdateKeyRequest $request, array $callOptions = []): Key - { - return $this->startApiCall('UpdateKey', $request, $callOptions)->wait(); - } -} diff --git a/RecaptchaEnterprise/src/V1/Client/RecaptchaEnterpriseServiceClient.php b/RecaptchaEnterprise/src/V1/Client/RecaptchaEnterpriseServiceClient.php index 52b7bf3b4d8b..759b20393081 100644 --- a/RecaptchaEnterprise/src/V1/Client/RecaptchaEnterpriseServiceClient.php +++ b/RecaptchaEnterprise/src/V1/Client/RecaptchaEnterpriseServiceClient.php @@ -24,17 +24,769 @@ namespace Google\Cloud\RecaptchaEnterprise\V1\Client; -use Google\Cloud\RecaptchaEnterprise\V1\Client\BaseClient\RecaptchaEnterpriseServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\RecaptchaEnterprise\V1\AnnotateAssessmentRequest; +use Google\Cloud\RecaptchaEnterprise\V1\AnnotateAssessmentResponse; +use Google\Cloud\RecaptchaEnterprise\V1\Assessment; +use Google\Cloud\RecaptchaEnterprise\V1\CreateAssessmentRequest; +use Google\Cloud\RecaptchaEnterprise\V1\CreateFirewallPolicyRequest; +use Google\Cloud\RecaptchaEnterprise\V1\CreateKeyRequest; +use Google\Cloud\RecaptchaEnterprise\V1\DeleteFirewallPolicyRequest; +use Google\Cloud\RecaptchaEnterprise\V1\DeleteKeyRequest; +use Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy; +use Google\Cloud\RecaptchaEnterprise\V1\GetFirewallPolicyRequest; +use Google\Cloud\RecaptchaEnterprise\V1\GetKeyRequest; +use Google\Cloud\RecaptchaEnterprise\V1\GetMetricsRequest; +use Google\Cloud\RecaptchaEnterprise\V1\Key; +use Google\Cloud\RecaptchaEnterprise\V1\ListFirewallPoliciesRequest; +use Google\Cloud\RecaptchaEnterprise\V1\ListKeysRequest; +use Google\Cloud\RecaptchaEnterprise\V1\ListRelatedAccountGroupMembershipsRequest; +use Google\Cloud\RecaptchaEnterprise\V1\ListRelatedAccountGroupsRequest; +use Google\Cloud\RecaptchaEnterprise\V1\Metrics; +use Google\Cloud\RecaptchaEnterprise\V1\MigrateKeyRequest; +use Google\Cloud\RecaptchaEnterprise\V1\RetrieveLegacySecretKeyRequest; +use Google\Cloud\RecaptchaEnterprise\V1\RetrieveLegacySecretKeyResponse; +use Google\Cloud\RecaptchaEnterprise\V1\SearchRelatedAccountGroupMembershipsRequest; +use Google\Cloud\RecaptchaEnterprise\V1\UpdateFirewallPolicyRequest; +use Google\Cloud\RecaptchaEnterprise\V1\UpdateKeyRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service to determine the likelihood an event is legitimate. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient} for the + * stable implementation * * @experimental + * + * @method PromiseInterface annotateAssessmentAsync(AnnotateAssessmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface createAssessmentAsync(CreateAssessmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface createFirewallPolicyAsync(CreateFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface createKeyAsync(CreateKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteFirewallPolicyAsync(DeleteFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteKeyAsync(DeleteKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getFirewallPolicyAsync(GetFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getKeyAsync(GetKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getMetricsAsync(GetMetricsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listFirewallPoliciesAsync(ListFirewallPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listKeysAsync(ListKeysRequest $request, array $optionalArgs = []) + * @method PromiseInterface listRelatedAccountGroupMembershipsAsync(ListRelatedAccountGroupMembershipsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listRelatedAccountGroupsAsync(ListRelatedAccountGroupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface migrateKeyAsync(MigrateKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface retrieveLegacySecretKeyAsync(RetrieveLegacySecretKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchRelatedAccountGroupMembershipsAsync(SearchRelatedAccountGroupMembershipsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateFirewallPolicyAsync(UpdateFirewallPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateKeyAsync(UpdateKeyRequest $request, array $optionalArgs = []) */ -final class RecaptchaEnterpriseServiceClient extends RecaptchaEnterpriseServiceBaseClient +final class RecaptchaEnterpriseServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RecaptchaEnterpriseServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'recaptchaenterprise.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/recaptcha_enterprise_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/recaptcha_enterprise_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/recaptcha_enterprise_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/recaptcha_enterprise_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a assessment + * resource. + * + * @param string $project + * @param string $assessment + * + * @return string The formatted assessment resource. + */ + public static function assessmentName(string $project, string $assessment): string + { + return self::getPathTemplate('assessment')->render([ + 'project' => $project, + 'assessment' => $assessment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * firewall_policy resource. + * + * @param string $project + * @param string $firewallpolicy + * + * @return string The formatted firewall_policy resource. + */ + public static function firewallPolicyName(string $project, string $firewallpolicy): string + { + return self::getPathTemplate('firewallPolicy')->render([ + 'project' => $project, + 'firewallpolicy' => $firewallpolicy, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a key + * resource. + * + * @param string $project + * @param string $key + * + * @return string The formatted key resource. + */ + public static function keyName(string $project, string $key): string + { + return self::getPathTemplate('key')->render([ + 'project' => $project, + 'key' => $key, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a metrics + * resource. + * + * @param string $project + * @param string $key + * + * @return string The formatted metrics resource. + */ + public static function metricsName(string $project, string $key): string + { + return self::getPathTemplate('metrics')->render([ + 'project' => $project, + 'key' => $key, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * related_account_group resource. + * + * @param string $project + * @param string $relatedaccountgroup + * + * @return string The formatted related_account_group resource. + */ + public static function relatedAccountGroupName(string $project, string $relatedaccountgroup): string + { + return self::getPathTemplate('relatedAccountGroup')->render([ + 'project' => $project, + 'relatedaccountgroup' => $relatedaccountgroup, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - assessment: projects/{project}/assessments/{assessment} + * - firewallPolicy: projects/{project}/firewallpolicies/{firewallpolicy} + * - key: projects/{project}/keys/{key} + * - metrics: projects/{project}/keys/{key}/metrics + * - project: projects/{project} + * - relatedAccountGroup: projects/{project}/relatedaccountgroups/{relatedaccountgroup} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'recaptchaenterprise.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Annotates a previously created Assessment to provide additional information + * on whether the event turned out to be authentic or fraudulent. + * + * The async variant is + * {@see RecaptchaEnterpriseServiceClient::annotateAssessmentAsync()} . + * + * @param AnnotateAssessmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AnnotateAssessmentResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function annotateAssessment(AnnotateAssessmentRequest $request, array $callOptions = []): AnnotateAssessmentResponse + { + return $this->startApiCall('AnnotateAssessment', $request, $callOptions)->wait(); + } + + /** + * Creates an Assessment of the likelihood an event is legitimate. + * + * The async variant is + * {@see RecaptchaEnterpriseServiceClient::createAssessmentAsync()} . + * + * @param CreateAssessmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Assessment + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAssessment(CreateAssessmentRequest $request, array $callOptions = []): Assessment + { + return $this->startApiCall('CreateAssessment', $request, $callOptions)->wait(); + } + + /** + * Creates a new FirewallPolicy, specifying conditions at which reCAPTCHA + * Enterprise actions can be executed. + * A project may have a maximum of 1000 policies. + * + * The async variant is + * {@see RecaptchaEnterpriseServiceClient::createFirewallPolicyAsync()} . + * + * @param CreateFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FirewallPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function createFirewallPolicy(CreateFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicy + { + return $this->startApiCall('CreateFirewallPolicy', $request, $callOptions)->wait(); + } + + /** + * Creates a new reCAPTCHA Enterprise key. + * + * The async variant is {@see RecaptchaEnterpriseServiceClient::createKeyAsync()} . + * + * @param CreateKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Key + * + * @throws ApiException Thrown if the API call fails. + */ + public function createKey(CreateKeyRequest $request, array $callOptions = []): Key + { + return $this->startApiCall('CreateKey', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified firewall policy. + * + * The async variant is + * {@see RecaptchaEnterpriseServiceClient::deleteFirewallPolicyAsync()} . + * + * @param DeleteFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteFirewallPolicy(DeleteFirewallPolicyRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteFirewallPolicy', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified key. + * + * The async variant is {@see RecaptchaEnterpriseServiceClient::deleteKeyAsync()} . + * + * @param DeleteKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteKey(DeleteKeyRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteKey', $request, $callOptions)->wait(); + } + + /** + * Returns the specified firewall policy. + * + * The async variant is + * {@see RecaptchaEnterpriseServiceClient::getFirewallPolicyAsync()} . + * + * @param GetFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FirewallPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getFirewallPolicy(GetFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicy + { + return $this->startApiCall('GetFirewallPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns the specified key. + * + * The async variant is {@see RecaptchaEnterpriseServiceClient::getKeyAsync()} . + * + * @param GetKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Key + * + * @throws ApiException Thrown if the API call fails. + */ + public function getKey(GetKeyRequest $request, array $callOptions = []): Key + { + return $this->startApiCall('GetKey', $request, $callOptions)->wait(); + } + + /** + * Get some aggregated metrics for a Key. This data can be used to build + * dashboards. + * + * The async variant is {@see RecaptchaEnterpriseServiceClient::getMetricsAsync()} + * . + * + * @param GetMetricsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Metrics + * + * @throws ApiException Thrown if the API call fails. + */ + public function getMetrics(GetMetricsRequest $request, array $callOptions = []): Metrics + { + return $this->startApiCall('GetMetrics', $request, $callOptions)->wait(); + } + + /** + * Returns the list of all firewall policies that belong to a project. + * + * The async variant is + * {@see RecaptchaEnterpriseServiceClient::listFirewallPoliciesAsync()} . + * + * @param ListFirewallPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listFirewallPolicies(ListFirewallPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListFirewallPolicies', $request, $callOptions); + } + + /** + * Returns the list of all keys that belong to a project. + * + * The async variant is {@see RecaptchaEnterpriseServiceClient::listKeysAsync()} . + * + * @param ListKeysRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listKeys(ListKeysRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListKeys', $request, $callOptions); + } + + /** + * Get memberships in a group of related accounts. + * + * The async variant is + * {@see RecaptchaEnterpriseServiceClient::listRelatedAccountGroupMembershipsAsync()} + * . + * + * @param ListRelatedAccountGroupMembershipsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listRelatedAccountGroupMemberships(ListRelatedAccountGroupMembershipsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListRelatedAccountGroupMemberships', $request, $callOptions); + } + + /** + * List groups of related accounts. + * + * The async variant is + * {@see RecaptchaEnterpriseServiceClient::listRelatedAccountGroupsAsync()} . + * + * @param ListRelatedAccountGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listRelatedAccountGroups(ListRelatedAccountGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListRelatedAccountGroups', $request, $callOptions); + } + + /** + * Migrates an existing key from reCAPTCHA to reCAPTCHA Enterprise. + * Once a key is migrated, it can be used from either product. SiteVerify + * requests are billed as CreateAssessment calls. You must be + * authenticated as one of the current owners of the reCAPTCHA Key, and + * your user must have the reCAPTCHA Enterprise Admin IAM role in the + * destination project. + * + * The async variant is {@see RecaptchaEnterpriseServiceClient::migrateKeyAsync()} + * . + * + * @param MigrateKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Key + * + * @throws ApiException Thrown if the API call fails. + */ + public function migrateKey(MigrateKeyRequest $request, array $callOptions = []): Key + { + return $this->startApiCall('MigrateKey', $request, $callOptions)->wait(); + } + + /** + * Returns the secret key related to the specified public key. + * You must use the legacy secret key only in a 3rd party integration with + * legacy reCAPTCHA. + * + * The async variant is + * {@see RecaptchaEnterpriseServiceClient::retrieveLegacySecretKeyAsync()} . + * + * @param RetrieveLegacySecretKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RetrieveLegacySecretKeyResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function retrieveLegacySecretKey(RetrieveLegacySecretKeyRequest $request, array $callOptions = []): RetrieveLegacySecretKeyResponse + { + return $this->startApiCall('RetrieveLegacySecretKey', $request, $callOptions)->wait(); + } + + /** + * Search group memberships related to a given account. + * + * The async variant is + * {@see RecaptchaEnterpriseServiceClient::searchRelatedAccountGroupMembershipsAsync()} + * . + * + * @param SearchRelatedAccountGroupMembershipsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchRelatedAccountGroupMemberships(SearchRelatedAccountGroupMembershipsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchRelatedAccountGroupMemberships', $request, $callOptions); + } + + /** + * Updates the specified firewall policy. + * + * The async variant is + * {@see RecaptchaEnterpriseServiceClient::updateFirewallPolicyAsync()} . + * + * @param UpdateFirewallPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FirewallPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateFirewallPolicy(UpdateFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicy + { + return $this->startApiCall('UpdateFirewallPolicy', $request, $callOptions)->wait(); + } + + /** + * Updates the specified key. + * + * The async variant is {@see RecaptchaEnterpriseServiceClient::updateKeyAsync()} . + * + * @param UpdateKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Key + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateKey(UpdateKeyRequest $request, array $callOptions = []): Key + { + return $this->startApiCall('UpdateKey', $request, $callOptions)->wait(); + } } diff --git a/RecaptchaEnterprise/src/V1/CreateAssessmentRequest.php b/RecaptchaEnterprise/src/V1/CreateAssessmentRequest.php index 353bec55fc9c..ddead1aa3779 100644 --- a/RecaptchaEnterprise/src/V1/CreateAssessmentRequest.php +++ b/RecaptchaEnterprise/src/V1/CreateAssessmentRequest.php @@ -17,7 +17,7 @@ class CreateAssessmentRequest extends \Google\Protobuf\Internal\Message { /** * Required. The name of the project in which the assessment will be created, - * in the format "projects/{project}". + * in the format `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ @@ -31,7 +31,7 @@ class CreateAssessmentRequest extends \Google\Protobuf\Internal\Message /** * @param string $parent Required. The name of the project in which the assessment will be created, - * in the format "projects/{project}". Please see + * in the format `projects/{project}`. Please see * {@see RecaptchaEnterpriseServiceClient::projectName()} for help formatting this field. * @param \Google\Cloud\RecaptchaEnterprise\V1\Assessment $assessment Required. The assessment details. * @@ -54,7 +54,7 @@ public static function build(string $parent, \Google\Cloud\RecaptchaEnterprise\V * * @type string $parent * Required. The name of the project in which the assessment will be created, - * in the format "projects/{project}". + * in the format `projects/{project}`. * @type \Google\Cloud\RecaptchaEnterprise\V1\Assessment $assessment * Required. The assessment details. * } @@ -66,7 +66,7 @@ public function __construct($data = NULL) { /** * Required. The name of the project in which the assessment will be created, - * in the format "projects/{project}". + * in the format `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @return string @@ -78,7 +78,7 @@ public function getParent() /** * Required. The name of the project in which the assessment will be created, - * in the format "projects/{project}". + * in the format `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @param string $var diff --git a/RecaptchaEnterprise/src/V1/CreateFirewallPolicyRequest.php b/RecaptchaEnterprise/src/V1/CreateFirewallPolicyRequest.php new file mode 100644 index 000000000000..d74794853ef8 --- /dev/null +++ b/RecaptchaEnterprise/src/V1/CreateFirewallPolicyRequest.php @@ -0,0 +1,132 @@ +google.cloud.recaptchaenterprise.v1.CreateFirewallPolicyRequest + */ +class CreateFirewallPolicyRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the project this policy will apply to, in the format + * `projects/{project}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * Required. Information to create the policy. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallPolicy firewall_policy = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $firewall_policy = null; + + /** + * @param string $parent Required. The name of the project this policy will apply to, in the format + * `projects/{project}`. Please see + * {@see RecaptchaEnterpriseServiceClient::projectName()} for help formatting this field. + * @param \Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy $firewallPolicy Required. Information to create the policy. + * + * @return \Google\Cloud\RecaptchaEnterprise\V1\CreateFirewallPolicyRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy $firewallPolicy): self + { + return (new self()) + ->setParent($parent) + ->setFirewallPolicy($firewallPolicy); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The name of the project this policy will apply to, in the format + * `projects/{project}`. + * @type \Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy $firewall_policy + * Required. Information to create the policy. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the project this policy will apply to, in the format + * `projects/{project}`. + * + * 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 name of the project this policy will apply to, in the format + * `projects/{project}`. + * + * 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. Information to create the policy. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallPolicy firewall_policy = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy|null + */ + public function getFirewallPolicy() + { + return $this->firewall_policy; + } + + public function hasFirewallPolicy() + { + return isset($this->firewall_policy); + } + + public function clearFirewallPolicy() + { + unset($this->firewall_policy); + } + + /** + * Required. Information to create the policy. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallPolicy firewall_policy = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy $var + * @return $this + */ + public function setFirewallPolicy($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy::class); + $this->firewall_policy = $var; + + return $this; + } + +} + diff --git a/RecaptchaEnterprise/src/V1/CreateKeyRequest.php b/RecaptchaEnterprise/src/V1/CreateKeyRequest.php index 1bde61dec231..b89c9a437faa 100644 --- a/RecaptchaEnterprise/src/V1/CreateKeyRequest.php +++ b/RecaptchaEnterprise/src/V1/CreateKeyRequest.php @@ -17,7 +17,7 @@ class CreateKeyRequest extends \Google\Protobuf\Internal\Message { /** * Required. The name of the project in which the key will be created, in the - * format "projects/{project}". + * format `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ @@ -31,7 +31,7 @@ class CreateKeyRequest extends \Google\Protobuf\Internal\Message /** * @param string $parent Required. The name of the project in which the key will be created, in the - * format "projects/{project}". Please see + * format `projects/{project}`. Please see * {@see RecaptchaEnterpriseServiceClient::projectName()} for help formatting this field. * @param \Google\Cloud\RecaptchaEnterprise\V1\Key $key Required. Information to create a reCAPTCHA Enterprise key. * @@ -54,7 +54,7 @@ public static function build(string $parent, \Google\Cloud\RecaptchaEnterprise\V * * @type string $parent * Required. The name of the project in which the key will be created, in the - * format "projects/{project}". + * format `projects/{project}`. * @type \Google\Cloud\RecaptchaEnterprise\V1\Key $key * Required. Information to create a reCAPTCHA Enterprise key. * } @@ -66,7 +66,7 @@ public function __construct($data = NULL) { /** * Required. The name of the project in which the key will be created, in the - * format "projects/{project}". + * format `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @return string @@ -78,7 +78,7 @@ public function getParent() /** * Required. The name of the project in which the key will be created, in the - * format "projects/{project}". + * format `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @param string $var diff --git a/RecaptchaEnterprise/src/V1/DeleteFirewallPolicyRequest.php b/RecaptchaEnterprise/src/V1/DeleteFirewallPolicyRequest.php new file mode 100644 index 000000000000..68f7f056da66 --- /dev/null +++ b/RecaptchaEnterprise/src/V1/DeleteFirewallPolicyRequest.php @@ -0,0 +1,86 @@ +google.cloud.recaptchaenterprise.v1.DeleteFirewallPolicyRequest + */ +class DeleteFirewallPolicyRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the policy to be deleted, in the format + * `projects/{project}/firewallpolicies/{firewallpolicy}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * @param string $name Required. The name of the policy to be deleted, in the format + * `projects/{project}/firewallpolicies/{firewallpolicy}`. Please see + * {@see RecaptchaEnterpriseServiceClient::firewallPolicyName()} for help formatting this field. + * + * @return \Google\Cloud\RecaptchaEnterprise\V1\DeleteFirewallPolicyRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The name of the policy to be deleted, in the format + * `projects/{project}/firewallpolicies/{firewallpolicy}`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the policy to be deleted, in the format + * `projects/{project}/firewallpolicies/{firewallpolicy}`. + * + * 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 name of the policy to be deleted, in the format + * `projects/{project}/firewallpolicies/{firewallpolicy}`. + * + * 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/RecaptchaEnterprise/src/V1/DeleteKeyRequest.php b/RecaptchaEnterprise/src/V1/DeleteKeyRequest.php index 71955e07debc..e565b6bb36e7 100644 --- a/RecaptchaEnterprise/src/V1/DeleteKeyRequest.php +++ b/RecaptchaEnterprise/src/V1/DeleteKeyRequest.php @@ -17,7 +17,7 @@ class DeleteKeyRequest extends \Google\Protobuf\Internal\Message { /** * Required. The name of the key to be deleted, in the format - * "projects/{project}/keys/{key}". + * `projects/{project}/keys/{key}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ @@ -25,7 +25,7 @@ class DeleteKeyRequest extends \Google\Protobuf\Internal\Message /** * @param string $name Required. The name of the key to be deleted, in the format - * "projects/{project}/keys/{key}". Please see + * `projects/{project}/keys/{key}`. Please see * {@see RecaptchaEnterpriseServiceClient::keyName()} for help formatting this field. * * @return \Google\Cloud\RecaptchaEnterprise\V1\DeleteKeyRequest @@ -46,7 +46,7 @@ public static function build(string $name): self * * @type string $name * Required. The name of the key to be deleted, in the format - * "projects/{project}/keys/{key}". + * `projects/{project}/keys/{key}`. * } */ public function __construct($data = NULL) { @@ -56,7 +56,7 @@ public function __construct($data = NULL) { /** * Required. The name of the key to be deleted, in the format - * "projects/{project}/keys/{key}". + * `projects/{project}/keys/{key}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @return string @@ -68,7 +68,7 @@ public function getName() /** * Required. The name of the key to be deleted, in the format - * "projects/{project}/keys/{key}". + * `projects/{project}/keys/{key}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @param string $var diff --git a/RecaptchaEnterprise/src/V1/Event.php b/RecaptchaEnterprise/src/V1/Event.php index 9e996c29fa20..f85e5443e8a3 100644 --- a/RecaptchaEnterprise/src/V1/Event.php +++ b/RecaptchaEnterprise/src/V1/Event.php @@ -58,6 +58,48 @@ class Event extends \Google\Protobuf\Internal\Message * Generated from protobuf field bytes hashed_account_id = 6 [(.google.api.field_behavior) = OPTIONAL]; */ private $hashed_account_id = ''; + /** + * Optional. Flag for a reCAPTCHA express request for an assessment without a + * token. If enabled, `site_key` must reference a SCORE key with WAF feature + * set to EXPRESS. + * + * Generated from protobuf field bool express = 14 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $express = false; + /** + * Optional. The URI resource the user requested that triggered an assessment. + * + * Generated from protobuf field string requested_uri = 8 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $requested_uri = ''; + /** + * Optional. Flag for running WAF token assessment. + * If enabled, the token must be specified, and have been created by a + * WAF-enabled key. + * + * Generated from protobuf field bool waf_token_assessment = 9 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $waf_token_assessment = false; + /** + * Optional. Optional JA3 fingerprint for SSL clients. + * + * Generated from protobuf field string ja3 = 10 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $ja3 = ''; + /** + * Optional. HTTP header information about the request. + * + * Generated from protobuf field repeated string headers = 11 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $headers; + /** + * Optional. Flag for enabling firewall policy config assessment. + * If this flag is enabled, the firewall policy will be evaluated and a + * suggested firewall action will be returned in the response. + * + * Generated from protobuf field bool firewall_policy_evaluation = 12 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $firewall_policy_evaluation = false; /** * Optional. Data describing a payment transaction to be assessed. Sending * this data enables reCAPTCHA Enterprise Fraud Prevention and the @@ -92,6 +134,24 @@ class Event extends \Google\Protobuf\Internal\Message * @type string $hashed_account_id * Optional. Unique stable hashed user identifier for the request. The * identifier must be hashed using hmac-sha256 with stable secret. + * @type bool $express + * Optional. Flag for a reCAPTCHA express request for an assessment without a + * token. If enabled, `site_key` must reference a SCORE key with WAF feature + * set to EXPRESS. + * @type string $requested_uri + * Optional. The URI resource the user requested that triggered an assessment. + * @type bool $waf_token_assessment + * Optional. Flag for running WAF token assessment. + * If enabled, the token must be specified, and have been created by a + * WAF-enabled key. + * @type string $ja3 + * Optional. Optional JA3 fingerprint for SSL clients. + * @type array|\Google\Protobuf\Internal\RepeatedField $headers + * Optional. HTTP header information about the request. + * @type bool $firewall_policy_evaluation + * Optional. Flag for enabling firewall policy config assessment. + * If this flag is enabled, the firewall policy will be evaluated and a + * suggested firewall action will be returned in the response. * @type \Google\Cloud\RecaptchaEnterprise\V1\TransactionData $transaction_data * Optional. Data describing a payment transaction to be assessed. Sending * this data enables reCAPTCHA Enterprise Fraud Prevention and the @@ -273,6 +333,174 @@ public function setHashedAccountId($var) return $this; } + /** + * Optional. Flag for a reCAPTCHA express request for an assessment without a + * token. If enabled, `site_key` must reference a SCORE key with WAF feature + * set to EXPRESS. + * + * Generated from protobuf field bool express = 14 [(.google.api.field_behavior) = OPTIONAL]; + * @return bool + */ + public function getExpress() + { + return $this->express; + } + + /** + * Optional. Flag for a reCAPTCHA express request for an assessment without a + * token. If enabled, `site_key` must reference a SCORE key with WAF feature + * set to EXPRESS. + * + * Generated from protobuf field bool express = 14 [(.google.api.field_behavior) = OPTIONAL]; + * @param bool $var + * @return $this + */ + public function setExpress($var) + { + GPBUtil::checkBool($var); + $this->express = $var; + + return $this; + } + + /** + * Optional. The URI resource the user requested that triggered an assessment. + * + * Generated from protobuf field string requested_uri = 8 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getRequestedUri() + { + return $this->requested_uri; + } + + /** + * Optional. The URI resource the user requested that triggered an assessment. + * + * Generated from protobuf field string requested_uri = 8 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setRequestedUri($var) + { + GPBUtil::checkString($var, True); + $this->requested_uri = $var; + + return $this; + } + + /** + * Optional. Flag for running WAF token assessment. + * If enabled, the token must be specified, and have been created by a + * WAF-enabled key. + * + * Generated from protobuf field bool waf_token_assessment = 9 [(.google.api.field_behavior) = OPTIONAL]; + * @return bool + */ + public function getWafTokenAssessment() + { + return $this->waf_token_assessment; + } + + /** + * Optional. Flag for running WAF token assessment. + * If enabled, the token must be specified, and have been created by a + * WAF-enabled key. + * + * Generated from protobuf field bool waf_token_assessment = 9 [(.google.api.field_behavior) = OPTIONAL]; + * @param bool $var + * @return $this + */ + public function setWafTokenAssessment($var) + { + GPBUtil::checkBool($var); + $this->waf_token_assessment = $var; + + return $this; + } + + /** + * Optional. Optional JA3 fingerprint for SSL clients. + * + * Generated from protobuf field string ja3 = 10 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getJa3() + { + return $this->ja3; + } + + /** + * Optional. Optional JA3 fingerprint for SSL clients. + * + * Generated from protobuf field string ja3 = 10 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setJa3($var) + { + GPBUtil::checkString($var, True); + $this->ja3 = $var; + + return $this; + } + + /** + * Optional. HTTP header information about the request. + * + * Generated from protobuf field repeated string headers = 11 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getHeaders() + { + return $this->headers; + } + + /** + * Optional. HTTP header information about the request. + * + * Generated from protobuf field repeated string headers = 11 [(.google.api.field_behavior) = OPTIONAL]; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setHeaders($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->headers = $arr; + + return $this; + } + + /** + * Optional. Flag for enabling firewall policy config assessment. + * If this flag is enabled, the firewall policy will be evaluated and a + * suggested firewall action will be returned in the response. + * + * Generated from protobuf field bool firewall_policy_evaluation = 12 [(.google.api.field_behavior) = OPTIONAL]; + * @return bool + */ + public function getFirewallPolicyEvaluation() + { + return $this->firewall_policy_evaluation; + } + + /** + * Optional. Flag for enabling firewall policy config assessment. + * If this flag is enabled, the firewall policy will be evaluated and a + * suggested firewall action will be returned in the response. + * + * Generated from protobuf field bool firewall_policy_evaluation = 12 [(.google.api.field_behavior) = OPTIONAL]; + * @param bool $var + * @return $this + */ + public function setFirewallPolicyEvaluation($var) + { + GPBUtil::checkBool($var); + $this->firewall_policy_evaluation = $var; + + return $this; + } + /** * Optional. Data describing a payment transaction to be assessed. Sending * this data enables reCAPTCHA Enterprise Fraud Prevention and the diff --git a/RecaptchaEnterprise/src/V1/FirewallAction.php b/RecaptchaEnterprise/src/V1/FirewallAction.php new file mode 100644 index 000000000000..9be6d77d7dbd --- /dev/null +++ b/RecaptchaEnterprise/src/V1/FirewallAction.php @@ -0,0 +1,223 @@ +google.cloud.recaptchaenterprise.v1.FirewallAction + */ +class FirewallAction extends \Google\Protobuf\Internal\Message +{ + protected $firewall_action_oneof; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\AllowAction $allow + * The user request did not match any policy and should be allowed + * access to the requested resource. + * @type \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\BlockAction $block + * This action will deny access to a given page. The user will get an HTTP + * error code. + * @type \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\RedirectAction $redirect + * This action will redirect the request to a ReCaptcha interstitial to + * attach a token. + * @type \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\SubstituteAction $substitute + * This action will transparently serve a different page to an offending + * user. + * @type \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\SetHeaderAction $set_header + * This action will set a custom header but allow the request to continue + * to the customer backend. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + + /** + * The user request did not match any policy and should be allowed + * access to the requested resource. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallAction.AllowAction allow = 1; + * @return \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\AllowAction|null + */ + public function getAllow() + { + return $this->readOneof(1); + } + + public function hasAllow() + { + return $this->hasOneof(1); + } + + /** + * The user request did not match any policy and should be allowed + * access to the requested resource. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallAction.AllowAction allow = 1; + * @param \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\AllowAction $var + * @return $this + */ + public function setAllow($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\AllowAction::class); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * This action will deny access to a given page. The user will get an HTTP + * error code. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallAction.BlockAction block = 2; + * @return \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\BlockAction|null + */ + public function getBlock() + { + return $this->readOneof(2); + } + + public function hasBlock() + { + return $this->hasOneof(2); + } + + /** + * This action will deny access to a given page. The user will get an HTTP + * error code. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallAction.BlockAction block = 2; + * @param \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\BlockAction $var + * @return $this + */ + public function setBlock($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\BlockAction::class); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * This action will redirect the request to a ReCaptcha interstitial to + * attach a token. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallAction.RedirectAction redirect = 5; + * @return \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\RedirectAction|null + */ + public function getRedirect() + { + return $this->readOneof(5); + } + + public function hasRedirect() + { + return $this->hasOneof(5); + } + + /** + * This action will redirect the request to a ReCaptcha interstitial to + * attach a token. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallAction.RedirectAction redirect = 5; + * @param \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\RedirectAction $var + * @return $this + */ + public function setRedirect($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\RedirectAction::class); + $this->writeOneof(5, $var); + + return $this; + } + + /** + * This action will transparently serve a different page to an offending + * user. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallAction.SubstituteAction substitute = 3; + * @return \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\SubstituteAction|null + */ + public function getSubstitute() + { + return $this->readOneof(3); + } + + public function hasSubstitute() + { + return $this->hasOneof(3); + } + + /** + * This action will transparently serve a different page to an offending + * user. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallAction.SubstituteAction substitute = 3; + * @param \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\SubstituteAction $var + * @return $this + */ + public function setSubstitute($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\SubstituteAction::class); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * This action will set a custom header but allow the request to continue + * to the customer backend. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallAction.SetHeaderAction set_header = 4; + * @return \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\SetHeaderAction|null + */ + public function getSetHeader() + { + return $this->readOneof(4); + } + + public function hasSetHeader() + { + return $this->hasOneof(4); + } + + /** + * This action will set a custom header but allow the request to continue + * to the customer backend. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallAction.SetHeaderAction set_header = 4; + * @param \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\SetHeaderAction $var + * @return $this + */ + public function setSetHeader($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\SetHeaderAction::class); + $this->writeOneof(4, $var); + + return $this; + } + + /** + * @return string + */ + public function getFirewallActionOneof() + { + return $this->whichOneof("firewall_action_oneof"); + } + +} + diff --git a/RecaptchaEnterprise/src/V1/FirewallAction/AllowAction.php b/RecaptchaEnterprise/src/V1/FirewallAction/AllowAction.php new file mode 100644 index 000000000000..20547eb88cfb --- /dev/null +++ b/RecaptchaEnterprise/src/V1/FirewallAction/AllowAction.php @@ -0,0 +1,36 @@ +google.cloud.recaptchaenterprise.v1.FirewallAction.AllowAction + */ +class AllowAction extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(AllowAction::class, \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction_AllowAction::class); + diff --git a/RecaptchaEnterprise/src/V1/FirewallAction/BlockAction.php b/RecaptchaEnterprise/src/V1/FirewallAction/BlockAction.php new file mode 100644 index 000000000000..a8793c63387b --- /dev/null +++ b/RecaptchaEnterprise/src/V1/FirewallAction/BlockAction.php @@ -0,0 +1,37 @@ +google.cloud.recaptchaenterprise.v1.FirewallAction.BlockAction + */ +class BlockAction extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(BlockAction::class, \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction_BlockAction::class); + diff --git a/RecaptchaEnterprise/src/V1/FirewallAction/RedirectAction.php b/RecaptchaEnterprise/src/V1/FirewallAction/RedirectAction.php new file mode 100644 index 000000000000..6151c5b27f83 --- /dev/null +++ b/RecaptchaEnterprise/src/V1/FirewallAction/RedirectAction.php @@ -0,0 +1,37 @@ +google.cloud.recaptchaenterprise.v1.FirewallAction.RedirectAction + */ +class RedirectAction extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(RedirectAction::class, \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction_RedirectAction::class); + diff --git a/RecaptchaEnterprise/src/V1/FirewallAction/SetHeaderAction.php b/RecaptchaEnterprise/src/V1/FirewallAction/SetHeaderAction.php new file mode 100644 index 000000000000..78b9409cc827 --- /dev/null +++ b/RecaptchaEnterprise/src/V1/FirewallAction/SetHeaderAction.php @@ -0,0 +1,106 @@ +google.cloud.recaptchaenterprise.v1.FirewallAction.SetHeaderAction + */ +class SetHeaderAction extends \Google\Protobuf\Internal\Message +{ + /** + * The header key to set in the request to the backend server. + * + * Generated from protobuf field string key = 1; + */ + private $key = ''; + /** + * The header value to set in the request to the backend server. + * + * Generated from protobuf field string value = 2; + */ + private $value = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $key + * The header key to set in the request to the backend server. + * @type string $value + * The header value to set in the request to the backend server. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + + /** + * The header key to set in the request to the backend server. + * + * Generated from protobuf field string key = 1; + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * The header key to set in the request to the backend server. + * + * Generated from protobuf field string key = 1; + * @param string $var + * @return $this + */ + public function setKey($var) + { + GPBUtil::checkString($var, True); + $this->key = $var; + + return $this; + } + + /** + * The header value to set in the request to the backend server. + * + * Generated from protobuf field string value = 2; + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * The header value to set in the request to the backend server. + * + * Generated from protobuf field string value = 2; + * @param string $var + * @return $this + */ + public function setValue($var) + { + GPBUtil::checkString($var, True); + $this->value = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(SetHeaderAction::class, \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction_SetHeaderAction::class); + diff --git a/RecaptchaEnterprise/src/V1/FirewallAction/SubstituteAction.php b/RecaptchaEnterprise/src/V1/FirewallAction/SubstituteAction.php new file mode 100644 index 000000000000..0eafd65aaceb --- /dev/null +++ b/RecaptchaEnterprise/src/V1/FirewallAction/SubstituteAction.php @@ -0,0 +1,75 @@ +google.cloud.recaptchaenterprise.v1.FirewallAction.SubstituteAction + */ +class SubstituteAction extends \Google\Protobuf\Internal\Message +{ + /** + * The address to redirect to. The target is a relative path in the + * current host. Example: "/blog/404.html". + * + * Generated from protobuf field string path = 1; + */ + private $path = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $path + * The address to redirect to. The target is a relative path in the + * current host. Example: "/blog/404.html". + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + + /** + * The address to redirect to. The target is a relative path in the + * current host. Example: "/blog/404.html". + * + * Generated from protobuf field string path = 1; + * @return string + */ + public function getPath() + { + return $this->path; + } + + /** + * The address to redirect to. The target is a relative path in the + * current host. Example: "/blog/404.html". + * + * Generated from protobuf field string path = 1; + * @param string $var + * @return $this + */ + public function setPath($var) + { + GPBUtil::checkString($var, True); + $this->path = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(SubstituteAction::class, \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction_SubstituteAction::class); + diff --git a/RecaptchaEnterprise/src/V1/FirewallPolicy.php b/RecaptchaEnterprise/src/V1/FirewallPolicy.php new file mode 100644 index 000000000000..f09ac473def6 --- /dev/null +++ b/RecaptchaEnterprise/src/V1/FirewallPolicy.php @@ -0,0 +1,272 @@ +google.cloud.recaptchaenterprise.v1.FirewallPolicy + */ +class FirewallPolicy extends \Google\Protobuf\Internal\Message +{ + /** + * The resource name for the FirewallPolicy in the format + * `projects/{project}/firewallpolicies/{firewallpolicy}`. + * + * Generated from protobuf field string name = 1; + */ + private $name = ''; + /** + * A description of what this policy aims to achieve, for convenience + * purposes. The description can at most include 256 UTF-8 characters. + * + * Generated from protobuf field string description = 2; + */ + private $description = ''; + /** + * The path for which this policy applies, specified as a glob pattern. + * For more information on glob, see the [manual + * page](https://man7.org/linux/man-pages/man7/glob.7.html). + * A path has a max length of 200 characters. + * + * Generated from protobuf field string path = 4; + */ + private $path = ''; + /** + * A CEL (Common Expression Language) conditional expression that specifies if + * this policy applies to an incoming user request. If this condition + * evaluates to true and the requested path matched the path pattern, the + * associated actions should be executed by the caller. The condition string + * is checked for CEL syntax correctness on creation. For more information, + * see the [CEL spec](https://github.com/google/cel-spec) and its [language + * definition](https://github.com/google/cel-spec/blob/master/doc/langdef.md). + * A condition has a max length of 500 characters. + * + * Generated from protobuf field string condition = 5; + */ + private $condition = ''; + /** + * The actions that the caller should take regarding user access. + * There should be at most one terminal action. A terminal action is any + * action that forces a response, such as `AllowAction`, + * `BlockAction` or `SubstituteAction`. + * Zero or more non-terminal actions such as `SetHeader` might be + * specified. A single policy can contain up to 16 actions. + * + * Generated from protobuf field repeated .google.cloud.recaptchaenterprise.v1.FirewallAction actions = 6; + */ + private $actions; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * The resource name for the FirewallPolicy in the format + * `projects/{project}/firewallpolicies/{firewallpolicy}`. + * @type string $description + * A description of what this policy aims to achieve, for convenience + * purposes. The description can at most include 256 UTF-8 characters. + * @type string $path + * The path for which this policy applies, specified as a glob pattern. + * For more information on glob, see the [manual + * page](https://man7.org/linux/man-pages/man7/glob.7.html). + * A path has a max length of 200 characters. + * @type string $condition + * A CEL (Common Expression Language) conditional expression that specifies if + * this policy applies to an incoming user request. If this condition + * evaluates to true and the requested path matched the path pattern, the + * associated actions should be executed by the caller. The condition string + * is checked for CEL syntax correctness on creation. For more information, + * see the [CEL spec](https://github.com/google/cel-spec) and its [language + * definition](https://github.com/google/cel-spec/blob/master/doc/langdef.md). + * A condition has a max length of 500 characters. + * @type array<\Google\Cloud\RecaptchaEnterprise\V1\FirewallAction>|\Google\Protobuf\Internal\RepeatedField $actions + * The actions that the caller should take regarding user access. + * There should be at most one terminal action. A terminal action is any + * action that forces a response, such as `AllowAction`, + * `BlockAction` or `SubstituteAction`. + * Zero or more non-terminal actions such as `SetHeader` might be + * specified. A single policy can contain up to 16 actions. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + + /** + * The resource name for the FirewallPolicy in the format + * `projects/{project}/firewallpolicies/{firewallpolicy}`. + * + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * The resource name for the FirewallPolicy in the format + * `projects/{project}/firewallpolicies/{firewallpolicy}`. + * + * 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; + } + + /** + * A description of what this policy aims to achieve, for convenience + * purposes. The description can at most include 256 UTF-8 characters. + * + * Generated from protobuf field string description = 2; + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * A description of what this policy aims to achieve, for convenience + * purposes. The description can at most include 256 UTF-8 characters. + * + * Generated from protobuf field string description = 2; + * @param string $var + * @return $this + */ + public function setDescription($var) + { + GPBUtil::checkString($var, True); + $this->description = $var; + + return $this; + } + + /** + * The path for which this policy applies, specified as a glob pattern. + * For more information on glob, see the [manual + * page](https://man7.org/linux/man-pages/man7/glob.7.html). + * A path has a max length of 200 characters. + * + * Generated from protobuf field string path = 4; + * @return string + */ + public function getPath() + { + return $this->path; + } + + /** + * The path for which this policy applies, specified as a glob pattern. + * For more information on glob, see the [manual + * page](https://man7.org/linux/man-pages/man7/glob.7.html). + * A path has a max length of 200 characters. + * + * Generated from protobuf field string path = 4; + * @param string $var + * @return $this + */ + public function setPath($var) + { + GPBUtil::checkString($var, True); + $this->path = $var; + + return $this; + } + + /** + * A CEL (Common Expression Language) conditional expression that specifies if + * this policy applies to an incoming user request. If this condition + * evaluates to true and the requested path matched the path pattern, the + * associated actions should be executed by the caller. The condition string + * is checked for CEL syntax correctness on creation. For more information, + * see the [CEL spec](https://github.com/google/cel-spec) and its [language + * definition](https://github.com/google/cel-spec/blob/master/doc/langdef.md). + * A condition has a max length of 500 characters. + * + * Generated from protobuf field string condition = 5; + * @return string + */ + public function getCondition() + { + return $this->condition; + } + + /** + * A CEL (Common Expression Language) conditional expression that specifies if + * this policy applies to an incoming user request. If this condition + * evaluates to true and the requested path matched the path pattern, the + * associated actions should be executed by the caller. The condition string + * is checked for CEL syntax correctness on creation. For more information, + * see the [CEL spec](https://github.com/google/cel-spec) and its [language + * definition](https://github.com/google/cel-spec/blob/master/doc/langdef.md). + * A condition has a max length of 500 characters. + * + * Generated from protobuf field string condition = 5; + * @param string $var + * @return $this + */ + public function setCondition($var) + { + GPBUtil::checkString($var, True); + $this->condition = $var; + + return $this; + } + + /** + * The actions that the caller should take regarding user access. + * There should be at most one terminal action. A terminal action is any + * action that forces a response, such as `AllowAction`, + * `BlockAction` or `SubstituteAction`. + * Zero or more non-terminal actions such as `SetHeader` might be + * specified. A single policy can contain up to 16 actions. + * + * Generated from protobuf field repeated .google.cloud.recaptchaenterprise.v1.FirewallAction actions = 6; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getActions() + { + return $this->actions; + } + + /** + * The actions that the caller should take regarding user access. + * There should be at most one terminal action. A terminal action is any + * action that forces a response, such as `AllowAction`, + * `BlockAction` or `SubstituteAction`. + * Zero or more non-terminal actions such as `SetHeader` might be + * specified. A single policy can contain up to 16 actions. + * + * Generated from protobuf field repeated .google.cloud.recaptchaenterprise.v1.FirewallAction actions = 6; + * @param array<\Google\Cloud\RecaptchaEnterprise\V1\FirewallAction>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setActions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction::class); + $this->actions = $arr; + + return $this; + } + +} + diff --git a/RecaptchaEnterprise/src/V1/FirewallPolicyAssessment.php b/RecaptchaEnterprise/src/V1/FirewallPolicyAssessment.php new file mode 100644 index 000000000000..5292d4661b1b --- /dev/null +++ b/RecaptchaEnterprise/src/V1/FirewallPolicyAssessment.php @@ -0,0 +1,133 @@ +google.cloud.recaptchaenterprise.v1.FirewallPolicyAssessment + */ +class FirewallPolicyAssessment extends \Google\Protobuf\Internal\Message +{ + /** + * If the processing of a policy config fails, an error will be populated + * and the firewall_policy will be left empty. + * + * Generated from protobuf field .google.rpc.Status error = 5; + */ + private $error = null; + /** + * Output only. The policy that matched the request. If more than one policy + * may match, this is the first match. If no policy matches the incoming + * request, the policy field will be left empty. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallPolicy firewall_policy = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $firewall_policy = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Rpc\Status $error + * If the processing of a policy config fails, an error will be populated + * and the firewall_policy will be left empty. + * @type \Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy $firewall_policy + * Output only. The policy that matched the request. If more than one policy + * may match, this is the first match. If no policy matches the incoming + * request, the policy field will be left empty. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + + /** + * If the processing of a policy config fails, an error will be populated + * and the firewall_policy will be left empty. + * + * Generated from protobuf field .google.rpc.Status error = 5; + * @return \Google\Rpc\Status|null + */ + public function getError() + { + return $this->error; + } + + public function hasError() + { + return isset($this->error); + } + + public function clearError() + { + unset($this->error); + } + + /** + * If the processing of a policy config fails, an error will be populated + * and the firewall_policy will be left empty. + * + * Generated from protobuf field .google.rpc.Status error = 5; + * @param \Google\Rpc\Status $var + * @return $this + */ + public function setError($var) + { + GPBUtil::checkMessage($var, \Google\Rpc\Status::class); + $this->error = $var; + + return $this; + } + + /** + * Output only. The policy that matched the request. If more than one policy + * may match, this is the first match. If no policy matches the incoming + * request, the policy field will be left empty. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallPolicy firewall_policy = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy|null + */ + public function getFirewallPolicy() + { + return $this->firewall_policy; + } + + public function hasFirewallPolicy() + { + return isset($this->firewall_policy); + } + + public function clearFirewallPolicy() + { + unset($this->firewall_policy); + } + + /** + * Output only. The policy that matched the request. If more than one policy + * may match, this is the first match. If no policy matches the incoming + * request, the policy field will be left empty. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallPolicy firewall_policy = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy $var + * @return $this + */ + public function setFirewallPolicy($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy::class); + $this->firewall_policy = $var; + + return $this; + } + +} + diff --git a/RecaptchaEnterprise/src/V1/FraudPreventionAssessment.php b/RecaptchaEnterprise/src/V1/FraudPreventionAssessment.php index 0b5eca6a3270..5e7bd63e3ace 100644 --- a/RecaptchaEnterprise/src/V1/FraudPreventionAssessment.php +++ b/RecaptchaEnterprise/src/V1/FraudPreventionAssessment.php @@ -16,8 +16,9 @@ class FraudPreventionAssessment extends \Google\Protobuf\Internal\Message { /** - * Probability (0-1) of this transaction being fraudulent. Summarizes the - * combined risk of attack vectors below. + * Probability of this transaction being fraudulent. Summarizes the combined + * risk of attack vectors below. + * Values are from 0.0 (lowest) to 1.0 (highest). * * Generated from protobuf field float transaction_risk = 1; */ @@ -35,6 +36,12 @@ class FraudPreventionAssessment extends \Google\Protobuf\Internal\Message * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FraudPreventionAssessment.CardTestingVerdict card_testing_verdict = 3; */ private $card_testing_verdict = null; + /** + * Assessment of this transaction for behavioral trust. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FraudPreventionAssessment.BehavioralTrustVerdict behavioral_trust_verdict = 4; + */ + private $behavioral_trust_verdict = null; /** * Constructor. @@ -43,13 +50,16 @@ class FraudPreventionAssessment extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type float $transaction_risk - * Probability (0-1) of this transaction being fraudulent. Summarizes the - * combined risk of attack vectors below. + * Probability of this transaction being fraudulent. Summarizes the combined + * risk of attack vectors below. + * Values are from 0.0 (lowest) to 1.0 (highest). * @type \Google\Cloud\RecaptchaEnterprise\V1\FraudPreventionAssessment\StolenInstrumentVerdict $stolen_instrument_verdict * Assessment of this transaction for risk of a stolen instrument. * @type \Google\Cloud\RecaptchaEnterprise\V1\FraudPreventionAssessment\CardTestingVerdict $card_testing_verdict * Assessment of this transaction for risk of being part of a card testing * attack. + * @type \Google\Cloud\RecaptchaEnterprise\V1\FraudPreventionAssessment\BehavioralTrustVerdict $behavioral_trust_verdict + * Assessment of this transaction for behavioral trust. * } */ public function __construct($data = NULL) { @@ -58,8 +68,9 @@ public function __construct($data = NULL) { } /** - * Probability (0-1) of this transaction being fraudulent. Summarizes the - * combined risk of attack vectors below. + * Probability of this transaction being fraudulent. Summarizes the combined + * risk of attack vectors below. + * Values are from 0.0 (lowest) to 1.0 (highest). * * Generated from protobuf field float transaction_risk = 1; * @return float @@ -70,8 +81,9 @@ public function getTransactionRisk() } /** - * Probability (0-1) of this transaction being fraudulent. Summarizes the - * combined risk of attack vectors below. + * Probability of this transaction being fraudulent. Summarizes the combined + * risk of attack vectors below. + * Values are from 0.0 (lowest) to 1.0 (highest). * * Generated from protobuf field float transaction_risk = 1; * @param float $var @@ -159,5 +171,41 @@ public function setCardTestingVerdict($var) return $this; } + /** + * Assessment of this transaction for behavioral trust. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FraudPreventionAssessment.BehavioralTrustVerdict behavioral_trust_verdict = 4; + * @return \Google\Cloud\RecaptchaEnterprise\V1\FraudPreventionAssessment\BehavioralTrustVerdict|null + */ + public function getBehavioralTrustVerdict() + { + return $this->behavioral_trust_verdict; + } + + public function hasBehavioralTrustVerdict() + { + return isset($this->behavioral_trust_verdict); + } + + public function clearBehavioralTrustVerdict() + { + unset($this->behavioral_trust_verdict); + } + + /** + * Assessment of this transaction for behavioral trust. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FraudPreventionAssessment.BehavioralTrustVerdict behavioral_trust_verdict = 4; + * @param \Google\Cloud\RecaptchaEnterprise\V1\FraudPreventionAssessment\BehavioralTrustVerdict $var + * @return $this + */ + public function setBehavioralTrustVerdict($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\RecaptchaEnterprise\V1\FraudPreventionAssessment\BehavioralTrustVerdict::class); + $this->behavioral_trust_verdict = $var; + + return $this; + } + } diff --git a/RecaptchaEnterprise/src/V1/FraudPreventionAssessment/BehavioralTrustVerdict.php b/RecaptchaEnterprise/src/V1/FraudPreventionAssessment/BehavioralTrustVerdict.php new file mode 100644 index 000000000000..bebd7270e8b9 --- /dev/null +++ b/RecaptchaEnterprise/src/V1/FraudPreventionAssessment/BehavioralTrustVerdict.php @@ -0,0 +1,78 @@ +google.cloud.recaptchaenterprise.v1.FraudPreventionAssessment.BehavioralTrustVerdict + */ +class BehavioralTrustVerdict extends \Google\Protobuf\Internal\Message +{ + /** + * Probability of this transaction attempt being executed in a behaviorally + * trustworthy way. + * Values are from 0.0 (lowest) to 1.0 (highest). + * + * Generated from protobuf field float trust = 1; + */ + private $trust = 0.0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type float $trust + * Probability of this transaction attempt being executed in a behaviorally + * trustworthy way. + * Values are from 0.0 (lowest) to 1.0 (highest). + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + + /** + * Probability of this transaction attempt being executed in a behaviorally + * trustworthy way. + * Values are from 0.0 (lowest) to 1.0 (highest). + * + * Generated from protobuf field float trust = 1; + * @return float + */ + public function getTrust() + { + return $this->trust; + } + + /** + * Probability of this transaction attempt being executed in a behaviorally + * trustworthy way. + * Values are from 0.0 (lowest) to 1.0 (highest). + * + * Generated from protobuf field float trust = 1; + * @param float $var + * @return $this + */ + public function setTrust($var) + { + GPBUtil::checkFloat($var); + $this->trust = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(BehavioralTrustVerdict::class, \Google\Cloud\RecaptchaEnterprise\V1\FraudPreventionAssessment_BehavioralTrustVerdict::class); + diff --git a/RecaptchaEnterprise/src/V1/FraudPreventionAssessment/CardTestingVerdict.php b/RecaptchaEnterprise/src/V1/FraudPreventionAssessment/CardTestingVerdict.php index e14a2c3c23f4..e540829398ba 100644 --- a/RecaptchaEnterprise/src/V1/FraudPreventionAssessment/CardTestingVerdict.php +++ b/RecaptchaEnterprise/src/V1/FraudPreventionAssessment/CardTestingVerdict.php @@ -17,8 +17,9 @@ class CardTestingVerdict extends \Google\Protobuf\Internal\Message { /** - * Probability (0-1) of this transaction attempt being part of a card - * testing attack. + * Probability of this transaction attempt being part of a card testing + * attack. + * Values are from 0.0 (lowest) to 1.0 (highest). * * Generated from protobuf field float risk = 1; */ @@ -31,8 +32,9 @@ class CardTestingVerdict extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type float $risk - * Probability (0-1) of this transaction attempt being part of a card - * testing attack. + * Probability of this transaction attempt being part of a card testing + * attack. + * Values are from 0.0 (lowest) to 1.0 (highest). * } */ public function __construct($data = NULL) { @@ -41,8 +43,9 @@ public function __construct($data = NULL) { } /** - * Probability (0-1) of this transaction attempt being part of a card - * testing attack. + * Probability of this transaction attempt being part of a card testing + * attack. + * Values are from 0.0 (lowest) to 1.0 (highest). * * Generated from protobuf field float risk = 1; * @return float @@ -53,8 +56,9 @@ public function getRisk() } /** - * Probability (0-1) of this transaction attempt being part of a card - * testing attack. + * Probability of this transaction attempt being part of a card testing + * attack. + * Values are from 0.0 (lowest) to 1.0 (highest). * * Generated from protobuf field float risk = 1; * @param float $var diff --git a/RecaptchaEnterprise/src/V1/FraudPreventionAssessment/StolenInstrumentVerdict.php b/RecaptchaEnterprise/src/V1/FraudPreventionAssessment/StolenInstrumentVerdict.php index 353e9217d867..ce29a1c5e7c8 100644 --- a/RecaptchaEnterprise/src/V1/FraudPreventionAssessment/StolenInstrumentVerdict.php +++ b/RecaptchaEnterprise/src/V1/FraudPreventionAssessment/StolenInstrumentVerdict.php @@ -17,8 +17,8 @@ class StolenInstrumentVerdict extends \Google\Protobuf\Internal\Message { /** - * Probability (0-1) of this transaction being executed with a stolen - * instrument. + * Probability of this transaction being executed with a stolen instrument. + * Values are from 0.0 (lowest) to 1.0 (highest). * * Generated from protobuf field float risk = 1; */ @@ -31,8 +31,8 @@ class StolenInstrumentVerdict extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type float $risk - * Probability (0-1) of this transaction being executed with a stolen - * instrument. + * Probability of this transaction being executed with a stolen instrument. + * Values are from 0.0 (lowest) to 1.0 (highest). * } */ public function __construct($data = NULL) { @@ -41,8 +41,8 @@ public function __construct($data = NULL) { } /** - * Probability (0-1) of this transaction being executed with a stolen - * instrument. + * Probability of this transaction being executed with a stolen instrument. + * Values are from 0.0 (lowest) to 1.0 (highest). * * Generated from protobuf field float risk = 1; * @return float @@ -53,8 +53,8 @@ public function getRisk() } /** - * Probability (0-1) of this transaction being executed with a stolen - * instrument. + * Probability of this transaction being executed with a stolen instrument. + * Values are from 0.0 (lowest) to 1.0 (highest). * * Generated from protobuf field float risk = 1; * @param float $var diff --git a/RecaptchaEnterprise/src/V1/FraudSignals.php b/RecaptchaEnterprise/src/V1/FraudSignals.php new file mode 100644 index 000000000000..9cb26f7f2093 --- /dev/null +++ b/RecaptchaEnterprise/src/V1/FraudSignals.php @@ -0,0 +1,125 @@ +google.cloud.recaptchaenterprise.v1.FraudSignals + */ +class FraudSignals extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. Signals describing the end user in this transaction. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FraudSignals.UserSignals user_signals = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $user_signals = null; + /** + * Output only. Signals describing the payment card or cards used in this + * transaction. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FraudSignals.CardSignals card_signals = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $card_signals = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\RecaptchaEnterprise\V1\FraudSignals\UserSignals $user_signals + * Output only. Signals describing the end user in this transaction. + * @type \Google\Cloud\RecaptchaEnterprise\V1\FraudSignals\CardSignals $card_signals + * Output only. Signals describing the payment card or cards used in this + * transaction. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + + /** + * Output only. Signals describing the end user in this transaction. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FraudSignals.UserSignals user_signals = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Cloud\RecaptchaEnterprise\V1\FraudSignals\UserSignals|null + */ + public function getUserSignals() + { + return $this->user_signals; + } + + public function hasUserSignals() + { + return isset($this->user_signals); + } + + public function clearUserSignals() + { + unset($this->user_signals); + } + + /** + * Output only. Signals describing the end user in this transaction. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FraudSignals.UserSignals user_signals = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Cloud\RecaptchaEnterprise\V1\FraudSignals\UserSignals $var + * @return $this + */ + public function setUserSignals($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\RecaptchaEnterprise\V1\FraudSignals\UserSignals::class); + $this->user_signals = $var; + + return $this; + } + + /** + * Output only. Signals describing the payment card or cards used in this + * transaction. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FraudSignals.CardSignals card_signals = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Cloud\RecaptchaEnterprise\V1\FraudSignals\CardSignals|null + */ + public function getCardSignals() + { + return $this->card_signals; + } + + public function hasCardSignals() + { + return isset($this->card_signals); + } + + public function clearCardSignals() + { + unset($this->card_signals); + } + + /** + * Output only. Signals describing the payment card or cards used in this + * transaction. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FraudSignals.CardSignals card_signals = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Cloud\RecaptchaEnterprise\V1\FraudSignals\CardSignals $var + * @return $this + */ + public function setCardSignals($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\RecaptchaEnterprise\V1\FraudSignals\CardSignals::class); + $this->card_signals = $var; + + return $this; + } + +} + diff --git a/RecaptchaEnterprise/src/V1/FraudSignals/CardSignals.php b/RecaptchaEnterprise/src/V1/FraudSignals/CardSignals.php new file mode 100644 index 000000000000..1c6e40b18d82 --- /dev/null +++ b/RecaptchaEnterprise/src/V1/FraudSignals/CardSignals.php @@ -0,0 +1,70 @@ +google.cloud.recaptchaenterprise.v1.FraudSignals.CardSignals + */ +class CardSignals extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. The labels for the payment card in this transaction. + * + * Generated from protobuf field repeated .google.cloud.recaptchaenterprise.v1.FraudSignals.CardSignals.CardLabel card_labels = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $card_labels; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array|\Google\Protobuf\Internal\RepeatedField $card_labels + * Output only. The labels for the payment card in this transaction. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + + /** + * Output only. The labels for the payment card in this transaction. + * + * Generated from protobuf field repeated .google.cloud.recaptchaenterprise.v1.FraudSignals.CardSignals.CardLabel card_labels = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getCardLabels() + { + return $this->card_labels; + } + + /** + * Output only. The labels for the payment card in this transaction. + * + * Generated from protobuf field repeated .google.cloud.recaptchaenterprise.v1.FraudSignals.CardSignals.CardLabel card_labels = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setCardLabels($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Cloud\RecaptchaEnterprise\V1\FraudSignals\CardSignals\CardLabel::class); + $this->card_labels = $arr; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(CardSignals::class, \Google\Cloud\RecaptchaEnterprise\V1\FraudSignals_CardSignals::class); + diff --git a/RecaptchaEnterprise/src/V1/FraudSignals/CardSignals/CardLabel.php b/RecaptchaEnterprise/src/V1/FraudSignals/CardSignals/CardLabel.php new file mode 100644 index 000000000000..e3e8e94649f8 --- /dev/null +++ b/RecaptchaEnterprise/src/V1/FraudSignals/CardSignals/CardLabel.php @@ -0,0 +1,74 @@ +google.cloud.recaptchaenterprise.v1.FraudSignals.CardSignals.CardLabel + */ +class CardLabel +{ + /** + * No label specified. + * + * Generated from protobuf enum CARD_LABEL_UNSPECIFIED = 0; + */ + const CARD_LABEL_UNSPECIFIED = 0; + /** + * This card has been detected as prepaid. + * + * Generated from protobuf enum PREPAID = 1; + */ + const PREPAID = 1; + /** + * This card has been detected as virtual, such as a card number generated + * for a single transaction or merchant. + * + * Generated from protobuf enum VIRTUAL = 2; + */ + const VIRTUAL = 2; + /** + * This card has been detected as being used in an unexpected geographic + * location. + * + * Generated from protobuf enum UNEXPECTED_LOCATION = 3; + */ + const UNEXPECTED_LOCATION = 3; + + private static $valueToName = [ + self::CARD_LABEL_UNSPECIFIED => 'CARD_LABEL_UNSPECIFIED', + self::PREPAID => 'PREPAID', + self::VIRTUAL => 'VIRTUAL', + self::UNEXPECTED_LOCATION => 'UNEXPECTED_LOCATION', + ]; + + 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(CardLabel::class, \Google\Cloud\RecaptchaEnterprise\V1\FraudSignals_CardSignals_CardLabel::class); + diff --git a/RecaptchaEnterprise/src/V1/FraudSignals/UserSignals.php b/RecaptchaEnterprise/src/V1/FraudSignals/UserSignals.php new file mode 100644 index 000000000000..32ec35065412 --- /dev/null +++ b/RecaptchaEnterprise/src/V1/FraudSignals/UserSignals.php @@ -0,0 +1,116 @@ +google.cloud.recaptchaenterprise.v1.FraudSignals.UserSignals + */ +class UserSignals extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. This user (based on email, phone, and other identifiers) has + * been seen on the internet for at least this number of days. + * + * Generated from protobuf field int32 active_days_lower_bound = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $active_days_lower_bound = 0; + /** + * Output only. Likelihood (from 0.0 to 1.0) this user includes synthetic + * components in their identity, such as a randomly generated email address, + * temporary phone number, or fake shipping address. + * + * Generated from protobuf field float synthetic_risk = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $synthetic_risk = 0.0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $active_days_lower_bound + * Output only. This user (based on email, phone, and other identifiers) has + * been seen on the internet for at least this number of days. + * @type float $synthetic_risk + * Output only. Likelihood (from 0.0 to 1.0) this user includes synthetic + * components in their identity, such as a randomly generated email address, + * temporary phone number, or fake shipping address. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + + /** + * Output only. This user (based on email, phone, and other identifiers) has + * been seen on the internet for at least this number of days. + * + * Generated from protobuf field int32 active_days_lower_bound = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getActiveDaysLowerBound() + { + return $this->active_days_lower_bound; + } + + /** + * Output only. This user (based on email, phone, and other identifiers) has + * been seen on the internet for at least this number of days. + * + * Generated from protobuf field int32 active_days_lower_bound = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setActiveDaysLowerBound($var) + { + GPBUtil::checkInt32($var); + $this->active_days_lower_bound = $var; + + return $this; + } + + /** + * Output only. Likelihood (from 0.0 to 1.0) this user includes synthetic + * components in their identity, such as a randomly generated email address, + * temporary phone number, or fake shipping address. + * + * Generated from protobuf field float synthetic_risk = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return float + */ + public function getSyntheticRisk() + { + return $this->synthetic_risk; + } + + /** + * Output only. Likelihood (from 0.0 to 1.0) this user includes synthetic + * components in their identity, such as a randomly generated email address, + * temporary phone number, or fake shipping address. + * + * Generated from protobuf field float synthetic_risk = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param float $var + * @return $this + */ + public function setSyntheticRisk($var) + { + GPBUtil::checkFloat($var); + $this->synthetic_risk = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(UserSignals::class, \Google\Cloud\RecaptchaEnterprise\V1\FraudSignals_UserSignals::class); + diff --git a/RecaptchaEnterprise/src/V1/Gapic/RecaptchaEnterpriseServiceGapicClient.php b/RecaptchaEnterprise/src/V1/Gapic/RecaptchaEnterpriseServiceGapicClient.php index 5aaf7902074b..672aad6b1c36 100644 --- a/RecaptchaEnterprise/src/V1/Gapic/RecaptchaEnterpriseServiceGapicClient.php +++ b/RecaptchaEnterprise/src/V1/Gapic/RecaptchaEnterpriseServiceGapicClient.php @@ -38,11 +38,17 @@ use Google\Cloud\RecaptchaEnterprise\V1\AnnotateAssessmentResponse; use Google\Cloud\RecaptchaEnterprise\V1\Assessment; use Google\Cloud\RecaptchaEnterprise\V1\CreateAssessmentRequest; +use Google\Cloud\RecaptchaEnterprise\V1\CreateFirewallPolicyRequest; use Google\Cloud\RecaptchaEnterprise\V1\CreateKeyRequest; +use Google\Cloud\RecaptchaEnterprise\V1\DeleteFirewallPolicyRequest; use Google\Cloud\RecaptchaEnterprise\V1\DeleteKeyRequest; +use Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy; +use Google\Cloud\RecaptchaEnterprise\V1\GetFirewallPolicyRequest; use Google\Cloud\RecaptchaEnterprise\V1\GetKeyRequest; use Google\Cloud\RecaptchaEnterprise\V1\GetMetricsRequest; use Google\Cloud\RecaptchaEnterprise\V1\Key; +use Google\Cloud\RecaptchaEnterprise\V1\ListFirewallPoliciesRequest; +use Google\Cloud\RecaptchaEnterprise\V1\ListFirewallPoliciesResponse; use Google\Cloud\RecaptchaEnterprise\V1\ListKeysRequest; use Google\Cloud\RecaptchaEnterprise\V1\ListKeysResponse; use Google\Cloud\RecaptchaEnterprise\V1\ListRelatedAccountGroupMembershipsRequest; @@ -56,6 +62,7 @@ use Google\Cloud\RecaptchaEnterprise\V1\SearchRelatedAccountGroupMembershipsRequest; use Google\Cloud\RecaptchaEnterprise\V1\SearchRelatedAccountGroupMembershipsResponse; use Google\Cloud\RecaptchaEnterprise\V1\TransactionEvent; +use Google\Cloud\RecaptchaEnterprise\V1\UpdateFirewallPolicyRequest; use Google\Cloud\RecaptchaEnterprise\V1\UpdateKeyRequest; use Google\Protobuf\FieldMask; use Google\Protobuf\GPBEmpty; @@ -109,6 +116,8 @@ class RecaptchaEnterpriseServiceGapicClient private static $assessmentNameTemplate; + private static $firewallPolicyNameTemplate; + private static $keyNameTemplate; private static $metricsNameTemplate; @@ -158,6 +167,17 @@ private static function getAssessmentNameTemplate() return self::$assessmentNameTemplate; } + private static function getFirewallPolicyNameTemplate() + { + if (self::$firewallPolicyNameTemplate == null) { + self::$firewallPolicyNameTemplate = new PathTemplate( + 'projects/{project}/firewallpolicies/{firewallpolicy}' + ); + } + + return self::$firewallPolicyNameTemplate; + } + private static function getKeyNameTemplate() { if (self::$keyNameTemplate == null) { @@ -205,6 +225,7 @@ private static function getPathTemplateMap() if (self::$pathTemplateMap == null) { self::$pathTemplateMap = [ 'assessment' => self::getAssessmentNameTemplate(), + 'firewallPolicy' => self::getFirewallPolicyNameTemplate(), 'key' => self::getKeyNameTemplate(), 'metrics' => self::getMetricsNameTemplate(), 'project' => self::getProjectNameTemplate(), @@ -232,6 +253,23 @@ public static function assessmentName($project, $assessment) ]); } + /** + * Formats a string containing the fully-qualified path to represent a + * firewall_policy resource. + * + * @param string $project + * @param string $firewallpolicy + * + * @return string The formatted firewall_policy resource. + */ + public static function firewallPolicyName($project, $firewallpolicy) + { + return self::getFirewallPolicyNameTemplate()->render([ + 'project' => $project, + 'firewallpolicy' => $firewallpolicy, + ]); + } + /** * Formats a string containing the fully-qualified path to represent a key * resource. @@ -305,6 +343,7 @@ public static function relatedAccountGroupName( * The following name formats are supported: * Template: Pattern * - assessment: projects/{project}/assessments/{assessment} + * - firewallPolicy: projects/{project}/firewallpolicies/{firewallpolicy} * - key: projects/{project}/keys/{key} * - metrics: projects/{project}/keys/{key}/metrics * - project: projects/{project} @@ -426,7 +465,7 @@ public function __construct(array $options = []) * ``` * * @param string $name Required. The resource name of the Assessment, in the format - * "projects/{project}/assessments/{assessment}". + * `projects/{project}/assessments/{assessment}`. * @param int $annotation Optional. The annotation that will be assigned to the Event. This field can * be left empty to provide reasons that apply to an event without concluding * whether the event is legitimate or fraudulent. @@ -509,7 +548,7 @@ public function annotateAssessment( * ``` * * @param string $parent Required. The name of the project in which the assessment will be created, - * in the format "projects/{project}". + * in the format `projects/{project}`. * @param Assessment $assessment Required. The assessment details. * @param array $optionalArgs { * Optional. @@ -548,6 +587,63 @@ public function createAssessment( )->wait(); } + /** + * Creates a new FirewallPolicy, specifying conditions at which reCAPTCHA + * Enterprise actions can be executed. + * A project may have a maximum of 1000 policies. + * + * Sample code: + * ``` + * $recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient(); + * try { + * $formattedParent = $recaptchaEnterpriseServiceClient->projectName('[PROJECT]'); + * $firewallPolicy = new FirewallPolicy(); + * $response = $recaptchaEnterpriseServiceClient->createFirewallPolicy($formattedParent, $firewallPolicy); + * } finally { + * $recaptchaEnterpriseServiceClient->close(); + * } + * ``` + * + * @param string $parent Required. The name of the project this policy will apply to, in the format + * `projects/{project}`. + * @param FirewallPolicy $firewallPolicy Required. Information to create the policy. + * @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\RecaptchaEnterprise\V1\FirewallPolicy + * + * @throws ApiException if the remote call fails + */ + public function createFirewallPolicy( + $parent, + $firewallPolicy, + array $optionalArgs = [] + ) { + $request = new CreateFirewallPolicyRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $request->setFirewallPolicy($firewallPolicy); + $requestParamHeaders['parent'] = $parent; + $requestParams = new RequestParamsHeaderDescriptor( + $requestParamHeaders + ); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + return $this->startCall( + 'CreateFirewallPolicy', + FirewallPolicy::class, + $optionalArgs, + $request + )->wait(); + } + /** * Creates a new reCAPTCHA Enterprise key. * @@ -564,7 +660,7 @@ public function createAssessment( * ``` * * @param string $parent Required. The name of the project in which the key will be created, in the - * format "projects/{project}". + * format `projects/{project}`. * @param Key $key Required. Information to create a reCAPTCHA Enterprise key. * @param array $optionalArgs { * Optional. @@ -600,6 +696,53 @@ public function createKey($parent, $key, array $optionalArgs = []) )->wait(); } + /** + * Deletes the specified firewall policy. + * + * Sample code: + * ``` + * $recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient(); + * try { + * $formattedName = $recaptchaEnterpriseServiceClient->firewallPolicyName('[PROJECT]', '[FIREWALLPOLICY]'); + * $recaptchaEnterpriseServiceClient->deleteFirewallPolicy($formattedName); + * } finally { + * $recaptchaEnterpriseServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the policy to be deleted, in the format + * `projects/{project}/firewallpolicies/{firewallpolicy}`. + * @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. + * } + * + * @throws ApiException if the remote call fails + */ + public function deleteFirewallPolicy($name, array $optionalArgs = []) + { + $request = new DeleteFirewallPolicyRequest(); + $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( + 'DeleteFirewallPolicy', + GPBEmpty::class, + $optionalArgs, + $request + )->wait(); + } + /** * Deletes the specified key. * @@ -615,7 +758,7 @@ public function createKey($parent, $key, array $optionalArgs = []) * ``` * * @param string $name Required. The name of the key to be deleted, in the format - * "projects/{project}/keys/{key}". + * `projects/{project}/keys/{key}`. * @param array $optionalArgs { * Optional. * @@ -647,6 +790,55 @@ public function deleteKey($name, array $optionalArgs = []) )->wait(); } + /** + * Returns the specified firewall policy. + * + * Sample code: + * ``` + * $recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient(); + * try { + * $formattedName = $recaptchaEnterpriseServiceClient->firewallPolicyName('[PROJECT]', '[FIREWALLPOLICY]'); + * $response = $recaptchaEnterpriseServiceClient->getFirewallPolicy($formattedName); + * } finally { + * $recaptchaEnterpriseServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the requested policy, in the format + * `projects/{project}/firewallpolicies/{firewallpolicy}`. + * @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\RecaptchaEnterprise\V1\FirewallPolicy + * + * @throws ApiException if the remote call fails + */ + public function getFirewallPolicy($name, array $optionalArgs = []) + { + $request = new GetFirewallPolicyRequest(); + $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( + 'GetFirewallPolicy', + FirewallPolicy::class, + $optionalArgs, + $request + )->wait(); + } + /** * Returns the specified key. * @@ -662,7 +854,7 @@ public function deleteKey($name, array $optionalArgs = []) * ``` * * @param string $name Required. The name of the requested key, in the format - * "projects/{project}/keys/{key}". + * `projects/{project}/keys/{key}`. * @param array $optionalArgs { * Optional. * @@ -712,7 +904,7 @@ public function getKey($name, array $optionalArgs = []) * ``` * * @param string $name Required. The name of the requested metrics, in the format - * "projects/{project}/keys/{key}/metrics". + * `projects/{project}/keys/{key}/metrics`. * @param array $optionalArgs { * Optional. * @@ -746,6 +938,84 @@ public function getMetrics($name, array $optionalArgs = []) )->wait(); } + /** + * Returns the list of all firewall policies that belong to a project. + * + * Sample code: + * ``` + * $recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient(); + * try { + * $formattedParent = $recaptchaEnterpriseServiceClient->projectName('[PROJECT]'); + * // Iterate over pages of elements + * $pagedResponse = $recaptchaEnterpriseServiceClient->listFirewallPolicies($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $recaptchaEnterpriseServiceClient->listFirewallPolicies($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $recaptchaEnterpriseServiceClient->close(); + * } + * ``` + * + * @param string $parent Required. The name of the project to list the policies for, in the format + * `projects/{project}`. + * @param array $optionalArgs { + * 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. + * @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 + */ + public function listFirewallPolicies($parent, array $optionalArgs = []) + { + $request = new ListFirewallPoliciesRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + 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( + 'ListFirewallPolicies', + $optionalArgs, + ListFirewallPoliciesResponse::class, + $request + ); + } + /** * Returns the list of all keys that belong to a project. * @@ -773,7 +1043,7 @@ public function getMetrics($name, array $optionalArgs = []) * ``` * * @param string $parent Required. The name of the project that contains the keys that will be - * listed, in the format "projects/{project}". + * listed, in the format `projects/{project}`. * @param array $optionalArgs { * Optional. * @@ -931,7 +1201,7 @@ public function listRelatedAccountGroupMemberships( * ``` * * @param string $parent Required. The name of the project to list related account groups from, in - * the format "projects/{project}". + * the format `projects/{project}`. * @param array $optionalArgs { * Optional. * @@ -986,7 +1256,7 @@ public function listRelatedAccountGroups($parent, array $optionalArgs = []) * Migrates an existing key from reCAPTCHA to reCAPTCHA Enterprise. * Once a key is migrated, it can be used from either product. SiteVerify * requests are billed as CreateAssessment calls. You must be - * authenticated as one of the current owners of the reCAPTCHA Site Key, and + * authenticated as one of the current owners of the reCAPTCHA Key, and * your user must have the reCAPTCHA Enterprise Admin IAM role in the * destination project. * @@ -1002,7 +1272,7 @@ public function listRelatedAccountGroups($parent, array $optionalArgs = []) * ``` * * @param string $name Required. The name of the key to be migrated, in the format - * "projects/{project}/keys/{key}". + * `projects/{project}/keys/{key}`. * @param array $optionalArgs { * Optional. * @@ -1066,7 +1336,7 @@ public function migrateKey($name, array $optionalArgs = []) * ``` * * @param string $key Required. The public key name linked to the requested secret key in the - * format "projects/{project}/keys/{key}". + * format `projects/{project}/keys/{key}`. * @param array $optionalArgs { * Optional. * @@ -1128,13 +1398,13 @@ public function retrieveLegacySecretKey($key, array $optionalArgs = []) * * @param string $project Required. The name of the project to search related account group * memberships from. Specify the project name in the following format: - * "projects/{project}". + * `projects/{project}`. * @param array $optionalArgs { * Optional. * * @type string $hashedAccountId - * Optional. The unique stable hashed user identifier we should search - * connections to. The identifier should correspond to a `hashed_account_id` + * Optional. The unique stable hashed user identifier used to search + * connections. The identifier should correspond to a `hashed_account_id` * provided in a previous `CreateAssessment` or `AnnotateAssessment` call. * @type int $pageSize * The maximum number of resources contained in the underlying API @@ -1189,6 +1459,65 @@ public function searchRelatedAccountGroupMemberships( ); } + /** + * Updates the specified firewall policy. + * + * Sample code: + * ``` + * $recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient(); + * try { + * $firewallPolicy = new FirewallPolicy(); + * $response = $recaptchaEnterpriseServiceClient->updateFirewallPolicy($firewallPolicy); + * } finally { + * $recaptchaEnterpriseServiceClient->close(); + * } + * ``` + * + * @param FirewallPolicy $firewallPolicy Required. The policy to update. + * @param array $optionalArgs { + * Optional. + * + * @type FieldMask $updateMask + * Optional. The mask to control which fields of the policy get updated. If + * the mask is not present, all fields will be updated. + * @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\RecaptchaEnterprise\V1\FirewallPolicy + * + * @throws ApiException if the remote call fails + */ + public function updateFirewallPolicy( + $firewallPolicy, + array $optionalArgs = [] + ) { + $request = new UpdateFirewallPolicyRequest(); + $requestParamHeaders = []; + $request->setFirewallPolicy($firewallPolicy); + $requestParamHeaders[ + 'firewall_policy.name' + ] = $firewallPolicy->getName(); + if (isset($optionalArgs['updateMask'])) { + $request->setUpdateMask($optionalArgs['updateMask']); + } + + $requestParams = new RequestParamsHeaderDescriptor( + $requestParamHeaders + ); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + return $this->startCall( + 'UpdateFirewallPolicy', + FirewallPolicy::class, + $optionalArgs, + $request + )->wait(); + } + /** * Updates the specified key. * diff --git a/RecaptchaEnterprise/src/V1/GetFirewallPolicyRequest.php b/RecaptchaEnterprise/src/V1/GetFirewallPolicyRequest.php new file mode 100644 index 000000000000..03898abbcf6c --- /dev/null +++ b/RecaptchaEnterprise/src/V1/GetFirewallPolicyRequest.php @@ -0,0 +1,86 @@ +google.cloud.recaptchaenterprise.v1.GetFirewallPolicyRequest + */ +class GetFirewallPolicyRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the requested policy, in the format + * `projects/{project}/firewallpolicies/{firewallpolicy}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + + /** + * @param string $name Required. The name of the requested policy, in the format + * `projects/{project}/firewallpolicies/{firewallpolicy}`. Please see + * {@see RecaptchaEnterpriseServiceClient::firewallPolicyName()} for help formatting this field. + * + * @return \Google\Cloud\RecaptchaEnterprise\V1\GetFirewallPolicyRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The name of the requested policy, in the format + * `projects/{project}/firewallpolicies/{firewallpolicy}`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the requested policy, in the format + * `projects/{project}/firewallpolicies/{firewallpolicy}`. + * + * 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 name of the requested policy, in the format + * `projects/{project}/firewallpolicies/{firewallpolicy}`. + * + * 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/RecaptchaEnterprise/src/V1/GetKeyRequest.php b/RecaptchaEnterprise/src/V1/GetKeyRequest.php index 7587184fbe86..fca87a2af202 100644 --- a/RecaptchaEnterprise/src/V1/GetKeyRequest.php +++ b/RecaptchaEnterprise/src/V1/GetKeyRequest.php @@ -17,7 +17,7 @@ class GetKeyRequest extends \Google\Protobuf\Internal\Message { /** * Required. The name of the requested key, in the format - * "projects/{project}/keys/{key}". + * `projects/{project}/keys/{key}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ @@ -25,7 +25,7 @@ class GetKeyRequest extends \Google\Protobuf\Internal\Message /** * @param string $name Required. The name of the requested key, in the format - * "projects/{project}/keys/{key}". Please see + * `projects/{project}/keys/{key}`. Please see * {@see RecaptchaEnterpriseServiceClient::keyName()} for help formatting this field. * * @return \Google\Cloud\RecaptchaEnterprise\V1\GetKeyRequest @@ -46,7 +46,7 @@ public static function build(string $name): self * * @type string $name * Required. The name of the requested key, in the format - * "projects/{project}/keys/{key}". + * `projects/{project}/keys/{key}`. * } */ public function __construct($data = NULL) { @@ -56,7 +56,7 @@ public function __construct($data = NULL) { /** * Required. The name of the requested key, in the format - * "projects/{project}/keys/{key}". + * `projects/{project}/keys/{key}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @return string @@ -68,7 +68,7 @@ public function getName() /** * Required. The name of the requested key, in the format - * "projects/{project}/keys/{key}". + * `projects/{project}/keys/{key}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @param string $var diff --git a/RecaptchaEnterprise/src/V1/GetMetricsRequest.php b/RecaptchaEnterprise/src/V1/GetMetricsRequest.php index 889a4e6b3d36..0399533668b4 100644 --- a/RecaptchaEnterprise/src/V1/GetMetricsRequest.php +++ b/RecaptchaEnterprise/src/V1/GetMetricsRequest.php @@ -17,7 +17,7 @@ class GetMetricsRequest extends \Google\Protobuf\Internal\Message { /** * Required. The name of the requested metrics, in the format - * "projects/{project}/keys/{key}/metrics". + * `projects/{project}/keys/{key}/metrics`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ @@ -25,7 +25,7 @@ class GetMetricsRequest extends \Google\Protobuf\Internal\Message /** * @param string $name Required. The name of the requested metrics, in the format - * "projects/{project}/keys/{key}/metrics". Please see + * `projects/{project}/keys/{key}/metrics`. Please see * {@see RecaptchaEnterpriseServiceClient::metricsName()} for help formatting this field. * * @return \Google\Cloud\RecaptchaEnterprise\V1\GetMetricsRequest @@ -46,7 +46,7 @@ public static function build(string $name): self * * @type string $name * Required. The name of the requested metrics, in the format - * "projects/{project}/keys/{key}/metrics". + * `projects/{project}/keys/{key}/metrics`. * } */ public function __construct($data = NULL) { @@ -56,7 +56,7 @@ public function __construct($data = NULL) { /** * Required. The name of the requested metrics, in the format - * "projects/{project}/keys/{key}/metrics". + * `projects/{project}/keys/{key}/metrics`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @return string @@ -68,7 +68,7 @@ public function getName() /** * Required. The name of the requested metrics, in the format - * "projects/{project}/keys/{key}/metrics". + * `projects/{project}/keys/{key}/metrics`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @param string $var diff --git a/RecaptchaEnterprise/src/V1/IOSKeySettings.php b/RecaptchaEnterprise/src/V1/IOSKeySettings.php index b0123146c811..a35e132ed640 100644 --- a/RecaptchaEnterprise/src/V1/IOSKeySettings.php +++ b/RecaptchaEnterprise/src/V1/IOSKeySettings.php @@ -28,6 +28,16 @@ class IOSKeySettings extends \Google\Protobuf\Internal\Message * Generated from protobuf field repeated string allowed_bundle_ids = 1; */ private $allowed_bundle_ids; + /** + * Apple Developer account details for the app that is protected by the + * reCAPTCHA Key. reCAPTCHA Enterprise leverages platform-specific checks like + * Apple App Attest and Apple DeviceCheck to protect your app from abuse. + * Providing these fields allows reCAPTCHA Enterprise to get a better + * assessment of the integrity of your app. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.AppleDeveloperId apple_developer_id = 3; + */ + private $apple_developer_id = null; /** * Constructor. @@ -40,6 +50,12 @@ class IOSKeySettings extends \Google\Protobuf\Internal\Message * @type array|\Google\Protobuf\Internal\RepeatedField $allowed_bundle_ids * iOS bundle ids of apps allowed to use the key. * Example: 'com.companyname.productname.appname' + * @type \Google\Cloud\RecaptchaEnterprise\V1\AppleDeveloperId $apple_developer_id + * Apple Developer account details for the app that is protected by the + * reCAPTCHA Key. reCAPTCHA Enterprise leverages platform-specific checks like + * Apple App Attest and Apple DeviceCheck to protect your app from abuse. + * Providing these fields allows reCAPTCHA Enterprise to get a better + * assessment of the integrity of your app. * } */ public function __construct($data = NULL) { @@ -101,5 +117,49 @@ public function setAllowedBundleIds($var) return $this; } + /** + * Apple Developer account details for the app that is protected by the + * reCAPTCHA Key. reCAPTCHA Enterprise leverages platform-specific checks like + * Apple App Attest and Apple DeviceCheck to protect your app from abuse. + * Providing these fields allows reCAPTCHA Enterprise to get a better + * assessment of the integrity of your app. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.AppleDeveloperId apple_developer_id = 3; + * @return \Google\Cloud\RecaptchaEnterprise\V1\AppleDeveloperId|null + */ + public function getAppleDeveloperId() + { + return $this->apple_developer_id; + } + + public function hasAppleDeveloperId() + { + return isset($this->apple_developer_id); + } + + public function clearAppleDeveloperId() + { + unset($this->apple_developer_id); + } + + /** + * Apple Developer account details for the app that is protected by the + * reCAPTCHA Key. reCAPTCHA Enterprise leverages platform-specific checks like + * Apple App Attest and Apple DeviceCheck to protect your app from abuse. + * Providing these fields allows reCAPTCHA Enterprise to get a better + * assessment of the integrity of your app. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.AppleDeveloperId apple_developer_id = 3; + * @param \Google\Cloud\RecaptchaEnterprise\V1\AppleDeveloperId $var + * @return $this + */ + public function setAppleDeveloperId($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\RecaptchaEnterprise\V1\AppleDeveloperId::class); + $this->apple_developer_id = $var; + + return $this; + } + } diff --git a/RecaptchaEnterprise/src/V1/Key.php b/RecaptchaEnterprise/src/V1/Key.php index aebb1c846df7..55fbd91acd6f 100644 --- a/RecaptchaEnterprise/src/V1/Key.php +++ b/RecaptchaEnterprise/src/V1/Key.php @@ -18,7 +18,7 @@ class Key extends \Google\Protobuf\Internal\Message { /** * The resource name for the Key in the format - * "projects/{project}/keys/{key}". + * `projects/{project}/keys/{key}`. * * Generated from protobuf field string name = 1; */ @@ -30,14 +30,14 @@ class Key extends \Google\Protobuf\Internal\Message */ private $display_name = ''; /** - * See - * Creating and managing labels. + * See [Creating and managing labels] + * (https://cloud.google.com/recaptcha-enterprise/docs/labels). * * Generated from protobuf field map labels = 6; */ private $labels; /** - * Output only. The timestamp corresponding to the creation of this Key. + * Output only. The timestamp corresponding to the creation of this key. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ @@ -64,7 +64,7 @@ class Key extends \Google\Protobuf\Internal\Message * * @type string $name * The resource name for the Key in the format - * "projects/{project}/keys/{key}". + * `projects/{project}/keys/{key}`. * @type string $display_name * Human-readable display name of this key. Modifiable by user. * @type \Google\Cloud\RecaptchaEnterprise\V1\WebKeySettings $web_settings @@ -74,10 +74,10 @@ class Key extends \Google\Protobuf\Internal\Message * @type \Google\Cloud\RecaptchaEnterprise\V1\IOSKeySettings $ios_settings * Settings for keys that can be used by iOS apps. * @type array|\Google\Protobuf\Internal\MapField $labels - * See - * Creating and managing labels. + * See [Creating and managing labels] + * (https://cloud.google.com/recaptcha-enterprise/docs/labels). * @type \Google\Protobuf\Timestamp $create_time - * Output only. The timestamp corresponding to the creation of this Key. + * Output only. The timestamp corresponding to the creation of this key. * @type \Google\Cloud\RecaptchaEnterprise\V1\TestingOptions $testing_options * Options for user acceptance testing. * @type \Google\Cloud\RecaptchaEnterprise\V1\WafSettings $waf_settings @@ -91,7 +91,7 @@ public function __construct($data = NULL) { /** * The resource name for the Key in the format - * "projects/{project}/keys/{key}". + * `projects/{project}/keys/{key}`. * * Generated from protobuf field string name = 1; * @return string @@ -103,7 +103,7 @@ public function getName() /** * The resource name for the Key in the format - * "projects/{project}/keys/{key}". + * `projects/{project}/keys/{key}`. * * Generated from protobuf field string name = 1; * @param string $var @@ -237,8 +237,8 @@ public function setIosSettings($var) } /** - * See - * Creating and managing labels. + * See [Creating and managing labels] + * (https://cloud.google.com/recaptcha-enterprise/docs/labels). * * Generated from protobuf field map labels = 6; * @return \Google\Protobuf\Internal\MapField @@ -249,8 +249,8 @@ public function getLabels() } /** - * See - * Creating and managing labels. + * See [Creating and managing labels] + * (https://cloud.google.com/recaptcha-enterprise/docs/labels). * * Generated from protobuf field map labels = 6; * @param array|\Google\Protobuf\Internal\MapField $var @@ -265,7 +265,7 @@ public function setLabels($var) } /** - * Output only. The timestamp corresponding to the creation of this Key. + * Output only. The timestamp corresponding to the creation of this key. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @return \Google\Protobuf\Timestamp|null @@ -286,7 +286,7 @@ public function clearCreateTime() } /** - * Output only. The timestamp corresponding to the creation of this Key. + * Output only. The timestamp corresponding to the creation of this key. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param \Google\Protobuf\Timestamp $var diff --git a/RecaptchaEnterprise/src/V1/ListFirewallPoliciesRequest.php b/RecaptchaEnterprise/src/V1/ListFirewallPoliciesRequest.php new file mode 100644 index 000000000000..ace00b7b8506 --- /dev/null +++ b/RecaptchaEnterprise/src/V1/ListFirewallPoliciesRequest.php @@ -0,0 +1,162 @@ +google.cloud.recaptchaenterprise.v1.ListFirewallPoliciesRequest + */ +class ListFirewallPoliciesRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the project to list the policies for, in the format + * `projects/{project}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * Optional. The maximum number of policies to return. Default is 10. Max + * limit is 1000. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_size = 0; + /** + * Optional. The next_page_token value returned from a previous. + * ListFirewallPoliciesRequest, if any. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_token = ''; + + /** + * @param string $parent Required. The name of the project to list the policies for, in the format + * `projects/{project}`. Please see + * {@see RecaptchaEnterpriseServiceClient::projectName()} for help formatting this field. + * + * @return \Google\Cloud\RecaptchaEnterprise\V1\ListFirewallPoliciesRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The name of the project to list the policies for, in the format + * `projects/{project}`. + * @type int $page_size + * Optional. The maximum number of policies to return. Default is 10. Max + * limit is 1000. + * @type string $page_token + * Optional. The next_page_token value returned from a previous. + * ListFirewallPoliciesRequest, if any. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the project to list the policies for, in the format + * `projects/{project}`. + * + * 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 name of the project to list the policies for, in the format + * `projects/{project}`. + * + * 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. The maximum number of policies to return. Default is 10. Max + * limit is 1000. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Optional. The maximum number of policies to return. Default is 10. Max + * limit is 1000. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * Optional. The next_page_token value returned from a previous. + * ListFirewallPoliciesRequest, if any. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * Optional. The next_page_token value returned from a previous. + * ListFirewallPoliciesRequest, if any. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/RecaptchaEnterprise/src/V1/ListFirewallPoliciesResponse.php b/RecaptchaEnterprise/src/V1/ListFirewallPoliciesResponse.php new file mode 100644 index 000000000000..c70d5fc76668 --- /dev/null +++ b/RecaptchaEnterprise/src/V1/ListFirewallPoliciesResponse.php @@ -0,0 +1,105 @@ +google.cloud.recaptchaenterprise.v1.ListFirewallPoliciesResponse + */ +class ListFirewallPoliciesResponse extends \Google\Protobuf\Internal\Message +{ + /** + * Policy details. + * + * Generated from protobuf field repeated .google.cloud.recaptchaenterprise.v1.FirewallPolicy firewall_policies = 1; + */ + private $firewall_policies; + /** + * Token to retrieve the next page of results. It is set to empty if no + * policies remain in results. + * + * 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 array<\Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy>|\Google\Protobuf\Internal\RepeatedField $firewall_policies + * Policy details. + * @type string $next_page_token + * Token to retrieve the next page of results. It is set to empty if no + * policies remain in results. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + + /** + * Policy details. + * + * Generated from protobuf field repeated .google.cloud.recaptchaenterprise.v1.FirewallPolicy firewall_policies = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getFirewallPolicies() + { + return $this->firewall_policies; + } + + /** + * Policy details. + * + * Generated from protobuf field repeated .google.cloud.recaptchaenterprise.v1.FirewallPolicy firewall_policies = 1; + * @param array<\Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setFirewallPolicies($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy::class); + $this->firewall_policies = $arr; + + return $this; + } + + /** + * Token to retrieve the next page of results. It is set to empty if no + * policies remain in results. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * Token to retrieve the next page of results. It is set to empty if no + * policies remain in results. + * + * 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/RecaptchaEnterprise/src/V1/ListKeysRequest.php b/RecaptchaEnterprise/src/V1/ListKeysRequest.php index e7036553055d..24a5cf31d2e7 100644 --- a/RecaptchaEnterprise/src/V1/ListKeysRequest.php +++ b/RecaptchaEnterprise/src/V1/ListKeysRequest.php @@ -17,7 +17,7 @@ class ListKeysRequest extends \Google\Protobuf\Internal\Message { /** * Required. The name of the project that contains the keys that will be - * listed, in the format "projects/{project}". + * listed, in the format `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ @@ -39,7 +39,7 @@ class ListKeysRequest extends \Google\Protobuf\Internal\Message /** * @param string $parent Required. The name of the project that contains the keys that will be - * listed, in the format "projects/{project}". Please see + * listed, in the format `projects/{project}`. Please see * {@see RecaptchaEnterpriseServiceClient::projectName()} for help formatting this field. * * @return \Google\Cloud\RecaptchaEnterprise\V1\ListKeysRequest @@ -60,7 +60,7 @@ public static function build(string $parent): self * * @type string $parent * Required. The name of the project that contains the keys that will be - * listed, in the format "projects/{project}". + * listed, in the format `projects/{project}`. * @type int $page_size * Optional. The maximum number of keys to return. Default is 10. Max limit is * 1000. @@ -76,7 +76,7 @@ public function __construct($data = NULL) { /** * Required. The name of the project that contains the keys that will be - * listed, in the format "projects/{project}". + * listed, in the format `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @return string @@ -88,7 +88,7 @@ public function getParent() /** * Required. The name of the project that contains the keys that will be - * listed, in the format "projects/{project}". + * listed, in the format `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @param string $var diff --git a/RecaptchaEnterprise/src/V1/ListRelatedAccountGroupsRequest.php b/RecaptchaEnterprise/src/V1/ListRelatedAccountGroupsRequest.php index 0f7bdaf35d2d..bd825a077316 100644 --- a/RecaptchaEnterprise/src/V1/ListRelatedAccountGroupsRequest.php +++ b/RecaptchaEnterprise/src/V1/ListRelatedAccountGroupsRequest.php @@ -17,7 +17,7 @@ class ListRelatedAccountGroupsRequest extends \Google\Protobuf\Internal\Message { /** * Required. The name of the project to list related account groups from, in - * the format "projects/{project}". + * the format `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ @@ -43,7 +43,7 @@ class ListRelatedAccountGroupsRequest extends \Google\Protobuf\Internal\Message /** * @param string $parent Required. The name of the project to list related account groups from, in - * the format "projects/{project}". Please see + * the format `projects/{project}`. Please see * {@see RecaptchaEnterpriseServiceClient::projectName()} for help formatting this field. * * @return \Google\Cloud\RecaptchaEnterprise\V1\ListRelatedAccountGroupsRequest @@ -64,7 +64,7 @@ public static function build(string $parent): self * * @type string $parent * Required. The name of the project to list related account groups from, in - * the format "projects/{project}". + * the format `projects/{project}`. * @type int $page_size * Optional. The maximum number of groups to return. The service might return * fewer than this value. If unspecified, at most 50 groups are returned. The @@ -84,7 +84,7 @@ public function __construct($data = NULL) { /** * Required. The name of the project to list related account groups from, in - * the format "projects/{project}". + * the format `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @return string @@ -96,7 +96,7 @@ public function getParent() /** * Required. The name of the project to list related account groups from, in - * the format "projects/{project}". + * the format `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @param string $var diff --git a/RecaptchaEnterprise/src/V1/Metrics.php b/RecaptchaEnterprise/src/V1/Metrics.php index 35a5ee657854..e77dc315b39c 100644 --- a/RecaptchaEnterprise/src/V1/Metrics.php +++ b/RecaptchaEnterprise/src/V1/Metrics.php @@ -17,7 +17,7 @@ class Metrics extends \Google\Protobuf\Internal\Message { /** * Output only. The name of the metrics, in the format - * "projects/{project}/keys/{key}/metrics". + * `projects/{project}/keys/{key}/metrics`. * * Generated from protobuf field string name = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ @@ -52,7 +52,7 @@ class Metrics extends \Google\Protobuf\Internal\Message * * @type string $name * Output only. The name of the metrics, in the format - * "projects/{project}/keys/{key}/metrics". + * `projects/{project}/keys/{key}/metrics`. * @type \Google\Protobuf\Timestamp $start_time * Inclusive start time aligned to a day (UTC). * @type array<\Google\Cloud\RecaptchaEnterprise\V1\ScoreMetrics>|\Google\Protobuf\Internal\RepeatedField $score_metrics @@ -71,7 +71,7 @@ public function __construct($data = NULL) { /** * Output only. The name of the metrics, in the format - * "projects/{project}/keys/{key}/metrics". + * `projects/{project}/keys/{key}/metrics`. * * Generated from protobuf field string name = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @return string @@ -83,7 +83,7 @@ public function getName() /** * Output only. The name of the metrics, in the format - * "projects/{project}/keys/{key}/metrics". + * `projects/{project}/keys/{key}/metrics`. * * Generated from protobuf field string name = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param string $var diff --git a/RecaptchaEnterprise/src/V1/MigrateKeyRequest.php b/RecaptchaEnterprise/src/V1/MigrateKeyRequest.php index 0798019e9197..ece1b72ec05d 100644 --- a/RecaptchaEnterprise/src/V1/MigrateKeyRequest.php +++ b/RecaptchaEnterprise/src/V1/MigrateKeyRequest.php @@ -17,7 +17,7 @@ class MigrateKeyRequest extends \Google\Protobuf\Internal\Message { /** * Required. The name of the key to be migrated, in the format - * "projects/{project}/keys/{key}". + * `projects/{project}/keys/{key}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ @@ -44,7 +44,7 @@ class MigrateKeyRequest extends \Google\Protobuf\Internal\Message * * @type string $name * Required. The name of the key to be migrated, in the format - * "projects/{project}/keys/{key}". + * `projects/{project}/keys/{key}`. * @type bool $skip_billing_check * Optional. If true, skips the billing check. * A reCAPTCHA Enterprise key or migrated key behaves differently than a @@ -63,7 +63,7 @@ public function __construct($data = NULL) { /** * Required. The name of the key to be migrated, in the format - * "projects/{project}/keys/{key}". + * `projects/{project}/keys/{key}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @return string @@ -75,7 +75,7 @@ public function getName() /** * Required. The name of the key to be migrated, in the format - * "projects/{project}/keys/{key}". + * `projects/{project}/keys/{key}`. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @param string $var diff --git a/RecaptchaEnterprise/src/V1/RetrieveLegacySecretKeyRequest.php b/RecaptchaEnterprise/src/V1/RetrieveLegacySecretKeyRequest.php index fba8c84f6628..ae333114d96b 100644 --- a/RecaptchaEnterprise/src/V1/RetrieveLegacySecretKeyRequest.php +++ b/RecaptchaEnterprise/src/V1/RetrieveLegacySecretKeyRequest.php @@ -17,7 +17,7 @@ class RetrieveLegacySecretKeyRequest extends \Google\Protobuf\Internal\Message { /** * Required. The public key name linked to the requested secret key in the - * format "projects/{project}/keys/{key}". + * format `projects/{project}/keys/{key}`. * * Generated from protobuf field string key = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ @@ -25,7 +25,7 @@ class RetrieveLegacySecretKeyRequest extends \Google\Protobuf\Internal\Message /** * @param string $key Required. The public key name linked to the requested secret key in the - * format "projects/{project}/keys/{key}". Please see + * format `projects/{project}/keys/{key}`. Please see * {@see RecaptchaEnterpriseServiceClient::keyName()} for help formatting this field. * * @return \Google\Cloud\RecaptchaEnterprise\V1\RetrieveLegacySecretKeyRequest @@ -46,7 +46,7 @@ public static function build(string $key): self * * @type string $key * Required. The public key name linked to the requested secret key in the - * format "projects/{project}/keys/{key}". + * format `projects/{project}/keys/{key}`. * } */ public function __construct($data = NULL) { @@ -56,7 +56,7 @@ public function __construct($data = NULL) { /** * Required. The public key name linked to the requested secret key in the - * format "projects/{project}/keys/{key}". + * format `projects/{project}/keys/{key}`. * * Generated from protobuf field string key = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @return string @@ -68,7 +68,7 @@ public function getKey() /** * Required. The public key name linked to the requested secret key in the - * format "projects/{project}/keys/{key}". + * format `projects/{project}/keys/{key}`. * * Generated from protobuf field string key = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @param string $var diff --git a/RecaptchaEnterprise/src/V1/RiskAnalysis.php b/RecaptchaEnterprise/src/V1/RiskAnalysis.php index ab604a9e7b00..cc8f0efff2fd 100644 --- a/RecaptchaEnterprise/src/V1/RiskAnalysis.php +++ b/RecaptchaEnterprise/src/V1/RiskAnalysis.php @@ -29,6 +29,13 @@ class RiskAnalysis extends \Google\Protobuf\Internal\Message * Generated from protobuf field repeated .google.cloud.recaptchaenterprise.v1.RiskAnalysis.ClassificationReason reasons = 2; */ private $reasons; + /** + * Extended verdict reasons to be used for experimentation only. The set of + * possible reasons is subject to change. + * + * Generated from protobuf field repeated string extended_verdict_reasons = 3; + */ + private $extended_verdict_reasons; /** * Constructor. @@ -42,6 +49,9 @@ class RiskAnalysis extends \Google\Protobuf\Internal\Message * non-legitimate traffic). * @type array|\Google\Protobuf\Internal\RepeatedField $reasons * Reasons contributing to the risk analysis verdict. + * @type array|\Google\Protobuf\Internal\RepeatedField $extended_verdict_reasons + * Extended verdict reasons to be used for experimentation only. The set of + * possible reasons is subject to change. * } */ public function __construct($data = NULL) { @@ -105,5 +115,33 @@ public function setReasons($var) return $this; } + /** + * Extended verdict reasons to be used for experimentation only. The set of + * possible reasons is subject to change. + * + * Generated from protobuf field repeated string extended_verdict_reasons = 3; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getExtendedVerdictReasons() + { + return $this->extended_verdict_reasons; + } + + /** + * Extended verdict reasons to be used for experimentation only. The set of + * possible reasons is subject to change. + * + * Generated from protobuf field repeated string extended_verdict_reasons = 3; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setExtendedVerdictReasons($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->extended_verdict_reasons = $arr; + + return $this; + } + } diff --git a/RecaptchaEnterprise/src/V1/SearchRelatedAccountGroupMembershipsRequest.php b/RecaptchaEnterprise/src/V1/SearchRelatedAccountGroupMembershipsRequest.php index 701b440cf5c2..4bbaaf39b3dc 100644 --- a/RecaptchaEnterprise/src/V1/SearchRelatedAccountGroupMembershipsRequest.php +++ b/RecaptchaEnterprise/src/V1/SearchRelatedAccountGroupMembershipsRequest.php @@ -18,14 +18,14 @@ class SearchRelatedAccountGroupMembershipsRequest extends \Google\Protobuf\Inter /** * Required. The name of the project to search related account group * memberships from. Specify the project name in the following format: - * "projects/{project}". + * `projects/{project}`. * * Generated from protobuf field string project = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ private $project = ''; /** - * Optional. The unique stable hashed user identifier we should search - * connections to. The identifier should correspond to a `hashed_account_id` + * Optional. The unique stable hashed user identifier used to search + * connections. The identifier should correspond to a `hashed_account_id` * provided in a previous `CreateAssessment` or `AnnotateAssessment` call. * * Generated from protobuf field bytes hashed_account_id = 2 [(.google.api.field_behavior) = OPTIONAL]; @@ -54,10 +54,10 @@ class SearchRelatedAccountGroupMembershipsRequest extends \Google\Protobuf\Inter /** * @param string $project Required. The name of the project to search related account group * memberships from. Specify the project name in the following format: - * "projects/{project}". Please see + * `projects/{project}`. Please see * {@see RecaptchaEnterpriseServiceClient::relatedAccountGroupName()} for help formatting this field. - * @param string $hashedAccountId Optional. The unique stable hashed user identifier we should search - * connections to. The identifier should correspond to a `hashed_account_id` + * @param string $hashedAccountId Optional. The unique stable hashed user identifier used to search + * connections. The identifier should correspond to a `hashed_account_id` * provided in a previous `CreateAssessment` or `AnnotateAssessment` call. * * @return \Google\Cloud\RecaptchaEnterprise\V1\SearchRelatedAccountGroupMembershipsRequest @@ -80,10 +80,10 @@ public static function build(string $project, string $hashedAccountId): self * @type string $project * Required. The name of the project to search related account group * memberships from. Specify the project name in the following format: - * "projects/{project}". + * `projects/{project}`. * @type string $hashed_account_id - * Optional. The unique stable hashed user identifier we should search - * connections to. The identifier should correspond to a `hashed_account_id` + * Optional. The unique stable hashed user identifier used to search + * connections. The identifier should correspond to a `hashed_account_id` * provided in a previous `CreateAssessment` or `AnnotateAssessment` call. * @type int $page_size * Optional. The maximum number of groups to return. The service might return @@ -106,7 +106,7 @@ public function __construct($data = NULL) { /** * Required. The name of the project to search related account group * memberships from. Specify the project name in the following format: - * "projects/{project}". + * `projects/{project}`. * * Generated from protobuf field string project = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @return string @@ -119,7 +119,7 @@ public function getProject() /** * Required. The name of the project to search related account group * memberships from. Specify the project name in the following format: - * "projects/{project}". + * `projects/{project}`. * * Generated from protobuf field string project = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { * @param string $var @@ -134,8 +134,8 @@ public function setProject($var) } /** - * Optional. The unique stable hashed user identifier we should search - * connections to. The identifier should correspond to a `hashed_account_id` + * Optional. The unique stable hashed user identifier used to search + * connections. The identifier should correspond to a `hashed_account_id` * provided in a previous `CreateAssessment` or `AnnotateAssessment` call. * * Generated from protobuf field bytes hashed_account_id = 2 [(.google.api.field_behavior) = OPTIONAL]; @@ -147,8 +147,8 @@ public function getHashedAccountId() } /** - * Optional. The unique stable hashed user identifier we should search - * connections to. The identifier should correspond to a `hashed_account_id` + * Optional. The unique stable hashed user identifier used to search + * connections. The identifier should correspond to a `hashed_account_id` * provided in a previous `CreateAssessment` or `AnnotateAssessment` call. * * Generated from protobuf field bytes hashed_account_id = 2 [(.google.api.field_behavior) = OPTIONAL]; diff --git a/RecaptchaEnterprise/src/V1/UpdateFirewallPolicyRequest.php b/RecaptchaEnterprise/src/V1/UpdateFirewallPolicyRequest.php new file mode 100644 index 000000000000..b6550d492de4 --- /dev/null +++ b/RecaptchaEnterprise/src/V1/UpdateFirewallPolicyRequest.php @@ -0,0 +1,141 @@ +google.cloud.recaptchaenterprise.v1.UpdateFirewallPolicyRequest + */ +class UpdateFirewallPolicyRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The policy to update. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallPolicy firewall_policy = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $firewall_policy = null; + /** + * Optional. The mask to control which fields of the policy get updated. If + * the mask is not present, all fields will be updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $update_mask = null; + + /** + * @param \Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy $firewallPolicy Required. The policy to update. + * @param \Google\Protobuf\FieldMask $updateMask Optional. The mask to control which fields of the policy get updated. If + * the mask is not present, all fields will be updated. + * + * @return \Google\Cloud\RecaptchaEnterprise\V1\UpdateFirewallPolicyRequest + * + * @experimental + */ + public static function build(\Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy $firewallPolicy, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setFirewallPolicy($firewallPolicy) + ->setUpdateMask($updateMask); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy $firewall_policy + * Required. The policy to update. + * @type \Google\Protobuf\FieldMask $update_mask + * Optional. The mask to control which fields of the policy get updated. If + * the mask is not present, all fields will be updated. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + + /** + * Required. The policy to update. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallPolicy firewall_policy = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy|null + */ + public function getFirewallPolicy() + { + return $this->firewall_policy; + } + + public function hasFirewallPolicy() + { + return isset($this->firewall_policy); + } + + public function clearFirewallPolicy() + { + unset($this->firewall_policy); + } + + /** + * Required. The policy to update. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallPolicy firewall_policy = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy $var + * @return $this + */ + public function setFirewallPolicy($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy::class); + $this->firewall_policy = $var; + + return $this; + } + + /** + * Optional. The mask to control which fields of the policy get updated. If + * the mask is not present, all fields will be updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.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. The mask to control which fields of the policy get updated. If + * the mask is not present, all fields will be updated. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.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/RecaptchaEnterprise/src/V1/WafSettings/WafFeature.php b/RecaptchaEnterprise/src/V1/WafSettings/WafFeature.php index e7197bd4b6de..8971ae15d176 100644 --- a/RecaptchaEnterprise/src/V1/WafSettings/WafFeature.php +++ b/RecaptchaEnterprise/src/V1/WafSettings/WafFeature.php @@ -39,12 +39,20 @@ class WafFeature * Generated from protobuf enum ACTION_TOKEN = 3; */ const ACTION_TOKEN = 3; + /** + * Use reCAPTCHA WAF express protection to protect any content other than + * web pages, like APIs and IoT devices. + * + * Generated from protobuf enum EXPRESS = 5; + */ + const EXPRESS = 5; private static $valueToName = [ self::WAF_FEATURE_UNSPECIFIED => 'WAF_FEATURE_UNSPECIFIED', self::CHALLENGE_PAGE => 'CHALLENGE_PAGE', self::SESSION_TOKEN => 'SESSION_TOKEN', self::ACTION_TOKEN => 'ACTION_TOKEN', + self::EXPRESS => 'EXPRESS', ]; public static function name($value) diff --git a/RecaptchaEnterprise/src/V1/WafSettings/WafService.php b/RecaptchaEnterprise/src/V1/WafSettings/WafService.php index f7f9ae8ae04e..b89f29a25f53 100644 --- a/RecaptchaEnterprise/src/V1/WafSettings/WafService.php +++ b/RecaptchaEnterprise/src/V1/WafSettings/WafService.php @@ -25,10 +25,17 @@ class WafService * Generated from protobuf enum CA = 1; */ const CA = 1; + /** + * Fastly + * + * Generated from protobuf enum FASTLY = 3; + */ + const FASTLY = 3; private static $valueToName = [ self::WAF_SERVICE_UNSPECIFIED => 'WAF_SERVICE_UNSPECIFIED', self::CA => 'CA', + self::FASTLY => 'FASTLY', ]; public static function name($value) diff --git a/RecaptchaEnterprise/src/V1/gapic_metadata.json b/RecaptchaEnterprise/src/V1/gapic_metadata.json index fb90aa8b78ed..46923bad379c 100644 --- a/RecaptchaEnterprise/src/V1/gapic_metadata.json +++ b/RecaptchaEnterprise/src/V1/gapic_metadata.json @@ -20,16 +20,31 @@ "createAssessment" ] }, + "CreateFirewallPolicy": { + "methods": [ + "createFirewallPolicy" + ] + }, "CreateKey": { "methods": [ "createKey" ] }, + "DeleteFirewallPolicy": { + "methods": [ + "deleteFirewallPolicy" + ] + }, "DeleteKey": { "methods": [ "deleteKey" ] }, + "GetFirewallPolicy": { + "methods": [ + "getFirewallPolicy" + ] + }, "GetKey": { "methods": [ "getKey" @@ -40,6 +55,11 @@ "getMetrics" ] }, + "ListFirewallPolicies": { + "methods": [ + "listFirewallPolicies" + ] + }, "ListKeys": { "methods": [ "listKeys" @@ -70,6 +90,11 @@ "searchRelatedAccountGroupMemberships" ] }, + "UpdateFirewallPolicy": { + "methods": [ + "updateFirewallPolicy" + ] + }, "UpdateKey": { "methods": [ "updateKey" diff --git a/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_client_config.json b/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_client_config.json index 83e0ee493029..6959e390064a 100644 --- a/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_client_config.json +++ b/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_client_config.json @@ -36,16 +36,31 @@ "retry_codes_name": "no_retry_1_codes", "retry_params_name": "no_retry_1_params" }, + "CreateFirewallPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "CreateKey": { "timeout_millis": 600000, "retry_codes_name": "no_retry_1_codes", "retry_params_name": "no_retry_1_params" }, + "DeleteFirewallPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "DeleteKey": { "timeout_millis": 600000, "retry_codes_name": "no_retry_1_codes", "retry_params_name": "no_retry_1_params" }, + "GetFirewallPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "GetKey": { "timeout_millis": 600000, "retry_codes_name": "no_retry_1_codes", @@ -56,6 +71,11 @@ "retry_codes_name": "no_retry_codes", "retry_params_name": "no_retry_params" }, + "ListFirewallPolicies": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "ListKeys": { "timeout_millis": 600000, "retry_codes_name": "no_retry_1_codes", @@ -86,6 +106,11 @@ "retry_codes_name": "no_retry_codes", "retry_params_name": "no_retry_params" }, + "UpdateFirewallPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "UpdateKey": { "timeout_millis": 600000, "retry_codes_name": "no_retry_1_codes", diff --git a/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_descriptor_config.php b/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_descriptor_config.php index 950aaa7abbdc..57a2ab2249e4 100644 --- a/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_descriptor_config.php +++ b/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_descriptor_config.php @@ -27,6 +27,18 @@ ], ], ], + 'CreateFirewallPolicy' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], 'CreateKey' => [ 'callType' => \Google\ApiCore\Call::UNARY_CALL, 'responseType' => 'Google\Cloud\RecaptchaEnterprise\V1\Key', @@ -39,6 +51,18 @@ ], ], ], + 'DeleteFirewallPolicy' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'DeleteKey' => [ 'callType' => \Google\ApiCore\Call::UNARY_CALL, 'responseType' => 'Google\Protobuf\GPBEmpty', @@ -51,6 +75,18 @@ ], ], ], + 'GetFirewallPolicy' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'GetKey' => [ 'callType' => \Google\ApiCore\Call::UNARY_CALL, 'responseType' => 'Google\Cloud\RecaptchaEnterprise\V1\Key', @@ -75,6 +111,26 @@ ], ], ], + 'ListFirewallPolicies' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getFirewallPolicies', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\RecaptchaEnterprise\V1\ListFirewallPoliciesResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], 'ListKeys' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', @@ -179,6 +235,19 @@ ], ], ], + 'UpdateFirewallPolicy' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy', + 'headerParams' => [ + [ + 'keyName' => 'firewall_policy.name', + 'fieldAccessors' => [ + 'getFirewallPolicy', + 'getName', + ], + ], + ], + ], 'UpdateKey' => [ 'callType' => \Google\ApiCore\Call::UNARY_CALL, 'responseType' => 'Google\Cloud\RecaptchaEnterprise\V1\Key', @@ -194,6 +263,7 @@ ], 'templateMap' => [ 'assessment' => 'projects/{project}/assessments/{assessment}', + 'firewallPolicy' => 'projects/{project}/firewallpolicies/{firewallpolicy}', 'key' => 'projects/{project}/keys/{key}', 'metrics' => 'projects/{project}/keys/{key}/metrics', 'project' => 'projects/{project}', diff --git a/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_rest_client_config.php b/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_rest_client_config.php index f77548797720..be34edbcc6f1 100644 --- a/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_rest_client_config.php +++ b/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_rest_client_config.php @@ -27,6 +27,18 @@ ], ], ], + 'CreateFirewallPolicy' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{parent=projects/*}/firewallpolicies', + 'body' => 'firewall_policy', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], 'CreateKey' => [ 'method' => 'post', 'uriTemplate' => '/v1/{parent=projects/*}/keys', @@ -39,6 +51,17 @@ ], ], ], + 'DeleteFirewallPolicy' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/firewallpolicies/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], 'DeleteKey' => [ 'method' => 'delete', 'uriTemplate' => '/v1/{name=projects/*/keys/*}', @@ -50,6 +73,17 @@ ], ], ], + 'GetFirewallPolicy' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/firewallpolicies/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], 'GetKey' => [ 'method' => 'get', 'uriTemplate' => '/v1/{name=projects/*/keys/*}', @@ -72,6 +106,17 @@ ], ], ], + 'ListFirewallPolicies' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*}/firewallpolicies', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], 'ListKeys' => [ 'method' => 'get', 'uriTemplate' => '/v1/{parent=projects/*}/keys', @@ -140,6 +185,19 @@ ], ], ], + 'UpdateFirewallPolicy' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1/{firewall_policy.name=projects/*/firewallpolicies/*}', + 'body' => 'firewall_policy', + 'placeholders' => [ + 'firewall_policy.name' => [ + 'getters' => [ + 'getFirewallPolicy', + 'getName', + ], + ], + ], + ], 'UpdateKey' => [ 'method' => 'patch', 'uriTemplate' => '/v1/{key.name=projects/*/keys/*}', diff --git a/RecaptchaEnterprise/tests/Unit/V1/Client/RecaptchaEnterpriseServiceClientTest.php b/RecaptchaEnterprise/tests/Unit/V1/Client/RecaptchaEnterpriseServiceClientTest.php index 87537cbb7c77..8351c0914cc2 100644 --- a/RecaptchaEnterprise/tests/Unit/V1/Client/RecaptchaEnterpriseServiceClientTest.php +++ b/RecaptchaEnterprise/tests/Unit/V1/Client/RecaptchaEnterpriseServiceClientTest.php @@ -32,11 +32,17 @@ use Google\Cloud\RecaptchaEnterprise\V1\Assessment; use Google\Cloud\RecaptchaEnterprise\V1\Client\RecaptchaEnterpriseServiceClient; use Google\Cloud\RecaptchaEnterprise\V1\CreateAssessmentRequest; +use Google\Cloud\RecaptchaEnterprise\V1\CreateFirewallPolicyRequest; use Google\Cloud\RecaptchaEnterprise\V1\CreateKeyRequest; +use Google\Cloud\RecaptchaEnterprise\V1\DeleteFirewallPolicyRequest; use Google\Cloud\RecaptchaEnterprise\V1\DeleteKeyRequest; +use Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy; +use Google\Cloud\RecaptchaEnterprise\V1\GetFirewallPolicyRequest; use Google\Cloud\RecaptchaEnterprise\V1\GetKeyRequest; use Google\Cloud\RecaptchaEnterprise\V1\GetMetricsRequest; use Google\Cloud\RecaptchaEnterprise\V1\Key; +use Google\Cloud\RecaptchaEnterprise\V1\ListFirewallPoliciesRequest; +use Google\Cloud\RecaptchaEnterprise\V1\ListFirewallPoliciesResponse; use Google\Cloud\RecaptchaEnterprise\V1\ListKeysRequest; use Google\Cloud\RecaptchaEnterprise\V1\ListKeysResponse; use Google\Cloud\RecaptchaEnterprise\V1\ListRelatedAccountGroupMembershipsRequest; @@ -51,6 +57,7 @@ use Google\Cloud\RecaptchaEnterprise\V1\RetrieveLegacySecretKeyResponse; use Google\Cloud\RecaptchaEnterprise\V1\SearchRelatedAccountGroupMembershipsRequest; use Google\Cloud\RecaptchaEnterprise\V1\SearchRelatedAccountGroupMembershipsResponse; +use Google\Cloud\RecaptchaEnterprise\V1\UpdateFirewallPolicyRequest; use Google\Cloud\RecaptchaEnterprise\V1\UpdateKeyRequest; use Google\Protobuf\GPBEmpty; use Google\Rpc\Code; @@ -222,6 +229,82 @@ public function createAssessmentExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function createFirewallPolicyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $description = 'description-1724546052'; + $path = 'path3433509'; + $condition = 'condition-861311717'; + $expectedResponse = new FirewallPolicy(); + $expectedResponse->setName($name); + $expectedResponse->setDescription($description); + $expectedResponse->setPath($path); + $expectedResponse->setCondition($condition); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $firewallPolicy = new FirewallPolicy(); + $request = (new CreateFirewallPolicyRequest()) + ->setParent($formattedParent) + ->setFirewallPolicy($firewallPolicy); + $response = $gapicClient->createFirewallPolicy($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/CreateFirewallPolicy', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getFirewallPolicy(); + $this->assertProtobufEquals($firewallPolicy, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createFirewallPolicyExceptionTest() + { + $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 + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $firewallPolicy = new FirewallPolicy(); + $request = (new CreateFirewallPolicyRequest()) + ->setParent($formattedParent) + ->setFirewallPolicy($firewallPolicy); + try { + $gapicClient->createFirewallPolicy($request); + // 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 createKeyTest() { @@ -294,6 +377,67 @@ public function createKeyExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function deleteFirewallPolicyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->firewallPolicyName('[PROJECT]', '[FIREWALLPOLICY]'); + $request = (new DeleteFirewallPolicyRequest()) + ->setName($formattedName); + $gapicClient->deleteFirewallPolicy($request); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/DeleteFirewallPolicy', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteFirewallPolicyExceptionTest() + { + $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 + $formattedName = $gapicClient->firewallPolicyName('[PROJECT]', '[FIREWALLPOLICY]'); + $request = (new DeleteFirewallPolicyRequest()) + ->setName($formattedName); + try { + $gapicClient->deleteFirewallPolicy($request); + // 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 deleteKeyTest() { @@ -355,6 +499,76 @@ public function deleteKeyExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function getFirewallPolicyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $description = 'description-1724546052'; + $path = 'path3433509'; + $condition = 'condition-861311717'; + $expectedResponse = new FirewallPolicy(); + $expectedResponse->setName($name2); + $expectedResponse->setDescription($description); + $expectedResponse->setPath($path); + $expectedResponse->setCondition($condition); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->firewallPolicyName('[PROJECT]', '[FIREWALLPOLICY]'); + $request = (new GetFirewallPolicyRequest()) + ->setName($formattedName); + $response = $gapicClient->getFirewallPolicy($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/GetFirewallPolicy', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getFirewallPolicyExceptionTest() + { + $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 + $formattedName = $gapicClient->firewallPolicyName('[PROJECT]', '[FIREWALLPOLICY]'); + $request = (new GetFirewallPolicyRequest()) + ->setName($formattedName); + try { + $gapicClient->getFirewallPolicy($request); + // 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 getKeyTest() { @@ -485,6 +699,78 @@ public function getMetricsExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function listFirewallPoliciesTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $firewallPoliciesElement = new FirewallPolicy(); + $firewallPolicies = [ + $firewallPoliciesElement, + ]; + $expectedResponse = new ListFirewallPoliciesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setFirewallPolicies($firewallPolicies); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $request = (new ListFirewallPoliciesRequest()) + ->setParent($formattedParent); + $response = $gapicClient->listFirewallPolicies($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getFirewallPolicies()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/ListFirewallPolicies', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listFirewallPoliciesExceptionTest() + { + $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 + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $request = (new ListFirewallPoliciesRequest()) + ->setParent($formattedParent); + try { + $gapicClient->listFirewallPolicies($request); + // 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 listKeysTest() { @@ -903,6 +1189,76 @@ public function searchRelatedAccountGroupMembershipsExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function updateFirewallPolicyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $description = 'description-1724546052'; + $path = 'path3433509'; + $condition = 'condition-861311717'; + $expectedResponse = new FirewallPolicy(); + $expectedResponse->setName($name); + $expectedResponse->setDescription($description); + $expectedResponse->setPath($path); + $expectedResponse->setCondition($condition); + $transport->addResponse($expectedResponse); + // Mock request + $firewallPolicy = new FirewallPolicy(); + $request = (new UpdateFirewallPolicyRequest()) + ->setFirewallPolicy($firewallPolicy); + $response = $gapicClient->updateFirewallPolicy($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/UpdateFirewallPolicy', $actualFuncCall); + $actualValue = $actualRequestObject->getFirewallPolicy(); + $this->assertProtobufEquals($firewallPolicy, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateFirewallPolicyExceptionTest() + { + $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 + $firewallPolicy = new FirewallPolicy(); + $request = (new UpdateFirewallPolicyRequest()) + ->setFirewallPolicy($firewallPolicy); + try { + $gapicClient->updateFirewallPolicy($request); + // 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 updateKeyTest() { diff --git a/RecaptchaEnterprise/tests/Unit/V1/RecaptchaEnterpriseServiceClientTest.php b/RecaptchaEnterprise/tests/Unit/V1/RecaptchaEnterpriseServiceClientTest.php index e18701b4b9cf..2b7c30ac45fe 100644 --- a/RecaptchaEnterprise/tests/Unit/V1/RecaptchaEnterpriseServiceClientTest.php +++ b/RecaptchaEnterprise/tests/Unit/V1/RecaptchaEnterpriseServiceClientTest.php @@ -29,7 +29,9 @@ use Google\Cloud\RecaptchaEnterprise\V1\AnnotateAssessmentRequest\Annotation; use Google\Cloud\RecaptchaEnterprise\V1\AnnotateAssessmentResponse; use Google\Cloud\RecaptchaEnterprise\V1\Assessment; +use Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy; use Google\Cloud\RecaptchaEnterprise\V1\Key; +use Google\Cloud\RecaptchaEnterprise\V1\ListFirewallPoliciesResponse; use Google\Cloud\RecaptchaEnterprise\V1\ListKeysResponse; use Google\Cloud\RecaptchaEnterprise\V1\ListRelatedAccountGroupMembershipsResponse; use Google\Cloud\RecaptchaEnterprise\V1\ListRelatedAccountGroupsResponse; @@ -197,6 +199,76 @@ public function createAssessmentExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function createFirewallPolicyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $description = 'description-1724546052'; + $path = 'path3433509'; + $condition = 'condition-861311717'; + $expectedResponse = new FirewallPolicy(); + $expectedResponse->setName($name); + $expectedResponse->setDescription($description); + $expectedResponse->setPath($path); + $expectedResponse->setCondition($condition); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $firewallPolicy = new FirewallPolicy(); + $response = $gapicClient->createFirewallPolicy($formattedParent, $firewallPolicy); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/CreateFirewallPolicy', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualRequestObject->getFirewallPolicy(); + $this->assertProtobufEquals($firewallPolicy, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function createFirewallPolicyExceptionTest() + { + $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 + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $firewallPolicy = new FirewallPolicy(); + try { + $gapicClient->createFirewallPolicy($formattedParent, $firewallPolicy); + // 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 createKeyTest() { @@ -263,6 +335,63 @@ public function createKeyExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function deleteFirewallPolicyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->firewallPolicyName('[PROJECT]', '[FIREWALLPOLICY]'); + $gapicClient->deleteFirewallPolicy($formattedName); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/DeleteFirewallPolicy', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteFirewallPolicyExceptionTest() + { + $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 + $formattedName = $gapicClient->firewallPolicyName('[PROJECT]', '[FIREWALLPOLICY]'); + try { + $gapicClient->deleteFirewallPolicy($formattedName); + // 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 deleteKeyTest() { @@ -320,6 +449,72 @@ public function deleteKeyExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function getFirewallPolicyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $description = 'description-1724546052'; + $path = 'path3433509'; + $condition = 'condition-861311717'; + $expectedResponse = new FirewallPolicy(); + $expectedResponse->setName($name2); + $expectedResponse->setDescription($description); + $expectedResponse->setPath($path); + $expectedResponse->setCondition($condition); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->firewallPolicyName('[PROJECT]', '[FIREWALLPOLICY]'); + $response = $gapicClient->getFirewallPolicy($formattedName); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/GetFirewallPolicy', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getFirewallPolicyExceptionTest() + { + $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 + $formattedName = $gapicClient->firewallPolicyName('[PROJECT]', '[FIREWALLPOLICY]'); + try { + $gapicClient->getFirewallPolicy($formattedName); + // 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 getKeyTest() { @@ -442,6 +637,74 @@ public function getMetricsExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function listFirewallPoliciesTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $firewallPoliciesElement = new FirewallPolicy(); + $firewallPolicies = [ + $firewallPoliciesElement, + ]; + $expectedResponse = new ListFirewallPoliciesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setFirewallPolicies($firewallPolicies); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->projectName('[PROJECT]'); + $response = $gapicClient->listFirewallPolicies($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getFirewallPolicies()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/ListFirewallPolicies', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listFirewallPoliciesExceptionTest() + { + $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 + $formattedParent = $gapicClient->projectName('[PROJECT]'); + try { + $gapicClient->listFirewallPolicies($formattedParent); + // 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 listKeysTest() { @@ -836,6 +1099,72 @@ public function searchRelatedAccountGroupMembershipsExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function updateFirewallPolicyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $description = 'description-1724546052'; + $path = 'path3433509'; + $condition = 'condition-861311717'; + $expectedResponse = new FirewallPolicy(); + $expectedResponse->setName($name); + $expectedResponse->setDescription($description); + $expectedResponse->setPath($path); + $expectedResponse->setCondition($condition); + $transport->addResponse($expectedResponse); + // Mock request + $firewallPolicy = new FirewallPolicy(); + $response = $gapicClient->updateFirewallPolicy($firewallPolicy); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/UpdateFirewallPolicy', $actualFuncCall); + $actualValue = $actualRequestObject->getFirewallPolicy(); + $this->assertProtobufEquals($firewallPolicy, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function updateFirewallPolicyExceptionTest() + { + $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 + $firewallPolicy = new FirewallPolicy(); + try { + $gapicClient->updateFirewallPolicy($firewallPolicy); + // 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 updateKeyTest() { diff --git a/RecommendationEngine/composer.json b/RecommendationEngine/composer.json index 24606f9be258..b97352f70345 100644 --- a/RecommendationEngine/composer.json +++ b/RecommendationEngine/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/RecommendationEngine/src/V1beta1/Client/BaseClient/CatalogServiceBaseClient.php b/RecommendationEngine/src/V1beta1/Client/BaseClient/CatalogServiceBaseClient.php deleted file mode 100644 index 38fafaff6157..000000000000 --- a/RecommendationEngine/src/V1beta1/Client/BaseClient/CatalogServiceBaseClient.php +++ /dev/null @@ -1,466 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/catalog_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/catalog_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/catalog_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/catalog_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - * - * @experimental - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - * - * @experimental - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a catalog - * resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * - * @return string The formatted catalog resource. - * - * @experimental - */ - public static function catalogName(string $project, string $location, string $catalog): string - { - return self::getPathTemplate('catalog')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * catalog_item_path resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * @param string $catalogItemPath - * - * @return string The formatted catalog_item_path resource. - * - * @experimental - */ - public static function catalogItemPathName(string $project, string $location, string $catalog, string $catalogItemPath): string - { - return self::getPathTemplate('catalogItemPath')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - 'catalog_item_path' => $catalogItemPath, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - catalog: projects/{project}/locations/{location}/catalogs/{catalog} - * - catalogItemPath: projects/{project}/locations/{location}/catalogs/{catalog}/catalogItems/{catalog_item_path} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'recommendationengine.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); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a catalog item. - * - * The async variant is {@see self::createCatalogItemAsync()} . - * - * @example samples/V1beta1/CatalogServiceClient/create_catalog_item.php - * - * @param CreateCatalogItemRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CatalogItem - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createCatalogItem(CreateCatalogItemRequest $request, array $callOptions = []): CatalogItem - { - return $this->startApiCall('CreateCatalogItem', $request, $callOptions)->wait(); - } - - /** - * Deletes a catalog item. - * - * The async variant is {@see self::deleteCatalogItemAsync()} . - * - * @example samples/V1beta1/CatalogServiceClient/delete_catalog_item.php - * - * @param DeleteCatalogItemRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deleteCatalogItem(DeleteCatalogItemRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteCatalogItem', $request, $callOptions)->wait(); - } - - /** - * Gets a specific catalog item. - * - * The async variant is {@see self::getCatalogItemAsync()} . - * - * @example samples/V1beta1/CatalogServiceClient/get_catalog_item.php - * - * @param GetCatalogItemRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CatalogItem - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function getCatalogItem(GetCatalogItemRequest $request, array $callOptions = []): CatalogItem - { - return $this->startApiCall('GetCatalogItem', $request, $callOptions)->wait(); - } - - /** - * Bulk import of multiple catalog items. Request processing may be - * synchronous. No partial updating supported. Non-existing items will be - * created. - * - * Operation.response is of type ImportResponse. Note that it is - * possible for a subset of the items to be successfully updated. - * - * The async variant is {@see self::importCatalogItemsAsync()} . - * - * @example samples/V1beta1/CatalogServiceClient/import_catalog_items.php - * - * @param ImportCatalogItemsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function importCatalogItems(ImportCatalogItemsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ImportCatalogItems', $request, $callOptions)->wait(); - } - - /** - * Gets a list of catalog items. - * - * The async variant is {@see self::listCatalogItemsAsync()} . - * - * @example samples/V1beta1/CatalogServiceClient/list_catalog_items.php - * - * @param ListCatalogItemsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listCatalogItems(ListCatalogItemsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCatalogItems', $request, $callOptions); - } - - /** - * Updates a catalog item. Partial updating is supported. Non-existing - * items will be created. - * - * The async variant is {@see self::updateCatalogItemAsync()} . - * - * @example samples/V1beta1/CatalogServiceClient/update_catalog_item.php - * - * @param UpdateCatalogItemRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CatalogItem - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function updateCatalogItem(UpdateCatalogItemRequest $request, array $callOptions = []): CatalogItem - { - return $this->startApiCall('UpdateCatalogItem', $request, $callOptions)->wait(); - } -} diff --git a/RecommendationEngine/src/V1beta1/Client/BaseClient/PredictionApiKeyRegistryBaseClient.php b/RecommendationEngine/src/V1beta1/Client/BaseClient/PredictionApiKeyRegistryBaseClient.php deleted file mode 100644 index 5996cb17054d..000000000000 --- a/RecommendationEngine/src/V1beta1/Client/BaseClient/PredictionApiKeyRegistryBaseClient.php +++ /dev/null @@ -1,339 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/prediction_api_key_registry_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/prediction_api_key_registry_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/prediction_api_key_registry_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/prediction_api_key_registry_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a event_store - * resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * @param string $eventStore - * - * @return string The formatted event_store resource. - * - * @experimental - */ - public static function eventStoreName(string $project, string $location, string $catalog, string $eventStore): string - { - return self::getPathTemplate('eventStore')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - 'event_store' => $eventStore, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * prediction_api_key_registration resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * @param string $eventStore - * @param string $predictionApiKeyRegistration - * - * @return string The formatted prediction_api_key_registration resource. - * - * @experimental - */ - public static function predictionApiKeyRegistrationName(string $project, string $location, string $catalog, string $eventStore, string $predictionApiKeyRegistration): string - { - return self::getPathTemplate('predictionApiKeyRegistration')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - 'event_store' => $eventStore, - 'prediction_api_key_registration' => $predictionApiKeyRegistration, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - eventStore: projects/{project}/locations/{location}/catalogs/{catalog}/eventStores/{event_store} - * - predictionApiKeyRegistration: projects/{project}/locations/{location}/catalogs/{catalog}/eventStores/{event_store}/predictionApiKeyRegistrations/{prediction_api_key_registration} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'recommendationengine.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); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Register an API key for use with predict method. - * - * The async variant is {@see self::createPredictionApiKeyRegistrationAsync()} . - * - * @example samples/V1beta1/PredictionApiKeyRegistryClient/create_prediction_api_key_registration.php - * - * @param CreatePredictionApiKeyRegistrationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PredictionApiKeyRegistration - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createPredictionApiKeyRegistration(CreatePredictionApiKeyRegistrationRequest $request, array $callOptions = []): PredictionApiKeyRegistration - { - return $this->startApiCall('CreatePredictionApiKeyRegistration', $request, $callOptions)->wait(); - } - - /** - * Unregister an apiKey from using for predict method. - * - * The async variant is {@see self::deletePredictionApiKeyRegistrationAsync()} . - * - * @example samples/V1beta1/PredictionApiKeyRegistryClient/delete_prediction_api_key_registration.php - * - * @param DeletePredictionApiKeyRegistrationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function deletePredictionApiKeyRegistration(DeletePredictionApiKeyRegistrationRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeletePredictionApiKeyRegistration', $request, $callOptions)->wait(); - } - - /** - * List the registered apiKeys for use with predict method. - * - * The async variant is {@see self::listPredictionApiKeyRegistrationsAsync()} . - * - * @example samples/V1beta1/PredictionApiKeyRegistryClient/list_prediction_api_key_registrations.php - * - * @param ListPredictionApiKeyRegistrationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listPredictionApiKeyRegistrations(ListPredictionApiKeyRegistrationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPredictionApiKeyRegistrations', $request, $callOptions); - } -} diff --git a/RecommendationEngine/src/V1beta1/Client/BaseClient/PredictionServiceBaseClient.php b/RecommendationEngine/src/V1beta1/Client/BaseClient/PredictionServiceBaseClient.php deleted file mode 100644 index d2e32bd3d303..000000000000 --- a/RecommendationEngine/src/V1beta1/Client/BaseClient/PredictionServiceBaseClient.php +++ /dev/null @@ -1,255 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/prediction_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/prediction_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/prediction_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/prediction_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a placement - * resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * @param string $eventStore - * @param string $placement - * - * @return string The formatted placement resource. - * - * @experimental - */ - public static function placementName(string $project, string $location, string $catalog, string $eventStore, string $placement): string - { - return self::getPathTemplate('placement')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - 'event_store' => $eventStore, - 'placement' => $placement, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - placement: projects/{project}/locations/{location}/catalogs/{catalog}/eventStores/{event_store}/placements/{placement} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'recommendationengine.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); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Makes a recommendation prediction. If using API Key based authentication, - * the API Key must be registered using the - * [PredictionApiKeyRegistry][google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry] - * service. [Learn more](https://cloud.google.com/recommendations-ai/docs/setting-up#register-key). - * - * The async variant is {@see self::predictAsync()} . - * - * @example samples/V1beta1/PredictionServiceClient/predict.php - * - * @param PredictRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function predict(PredictRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('Predict', $request, $callOptions); - } -} diff --git a/RecommendationEngine/src/V1beta1/Client/BaseClient/UserEventServiceBaseClient.php b/RecommendationEngine/src/V1beta1/Client/BaseClient/UserEventServiceBaseClient.php deleted file mode 100644 index 4e2b2e8b5b74..000000000000 --- a/RecommendationEngine/src/V1beta1/Client/BaseClient/UserEventServiceBaseClient.php +++ /dev/null @@ -1,425 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/user_event_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/user_event_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/user_event_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/user_event_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - * - * @experimental - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - * - * @experimental - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a event_store - * resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * @param string $eventStore - * - * @return string The formatted event_store resource. - * - * @experimental - */ - public static function eventStoreName(string $project, string $location, string $catalog, string $eventStore): string - { - return self::getPathTemplate('eventStore')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - 'event_store' => $eventStore, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - eventStore: projects/{project}/locations/{location}/catalogs/{catalog}/eventStores/{event_store} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'recommendationengine.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); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Writes a single user event from the browser. This uses a GET request to - * due to browser restriction of POST-ing to a 3rd party domain. - * - * This method is used only by the Recommendations AI JavaScript pixel. - * Users should not call this method directly. - * - * The async variant is {@see self::collectUserEventAsync()} . - * - * @example samples/V1beta1/UserEventServiceClient/collect_user_event.php - * - * @param CollectUserEventRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 HttpBody - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function collectUserEvent(CollectUserEventRequest $request, array $callOptions = []): HttpBody - { - return $this->startApiCall('CollectUserEvent', $request, $callOptions)->wait(); - } - - /** - * Bulk import of User events. Request processing might be - * synchronous. Events that already exist are skipped. - * Use this method for backfilling historical user events. - * - * Operation.response is of type ImportResponse. Note that it is - * possible for a subset of the items to be successfully inserted. - * Operation.metadata is of type ImportMetadata. - * - * The async variant is {@see self::importUserEventsAsync()} . - * - * @example samples/V1beta1/UserEventServiceClient/import_user_events.php - * - * @param ImportUserEventsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function importUserEvents(ImportUserEventsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ImportUserEvents', $request, $callOptions)->wait(); - } - - /** - * Gets a list of user events within a time range, with potential filtering. - * - * The async variant is {@see self::listUserEventsAsync()} . - * - * @example samples/V1beta1/UserEventServiceClient/list_user_events.php - * - * @param ListUserEventsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function listUserEvents(ListUserEventsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListUserEvents', $request, $callOptions); - } - - /** - * Deletes permanently all user events specified by the filter provided. - * Depending on the number of events specified by the filter, this operation - * could take hours or days to complete. To test a filter, use the list - * command first. - * - * The async variant is {@see self::purgeUserEventsAsync()} . - * - * @example samples/V1beta1/UserEventServiceClient/purge_user_events.php - * - * @param PurgeUserEventsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function purgeUserEvents(PurgeUserEventsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('PurgeUserEvents', $request, $callOptions)->wait(); - } - - /** - * Writes a single user event. - * - * The async variant is {@see self::writeUserEventAsync()} . - * - * @example samples/V1beta1/UserEventServiceClient/write_user_event.php - * - * @param WriteUserEventRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 UserEvent - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function writeUserEvent(WriteUserEventRequest $request, array $callOptions = []): UserEvent - { - return $this->startApiCall('WriteUserEvent', $request, $callOptions)->wait(); - } -} diff --git a/RecommendationEngine/src/V1beta1/Client/CatalogServiceClient.php b/RecommendationEngine/src/V1beta1/Client/CatalogServiceClient.php index 00593a1be823..89ccf375bdc2 100644 --- a/RecommendationEngine/src/V1beta1/Client/CatalogServiceClient.php +++ b/RecommendationEngine/src/V1beta1/Client/CatalogServiceClient.php @@ -26,17 +26,439 @@ namespace Google\Cloud\RecommendationEngine\V1beta1\Client; -use Google\Cloud\RecommendationEngine\V1beta1\Client\BaseClient\CatalogServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\RecommendationEngine\V1beta1\CatalogItem; +use Google\Cloud\RecommendationEngine\V1beta1\CreateCatalogItemRequest; +use Google\Cloud\RecommendationEngine\V1beta1\DeleteCatalogItemRequest; +use Google\Cloud\RecommendationEngine\V1beta1\GetCatalogItemRequest; +use Google\Cloud\RecommendationEngine\V1beta1\ImportCatalogItemsRequest; +use Google\Cloud\RecommendationEngine\V1beta1\ListCatalogItemsRequest; +use Google\Cloud\RecommendationEngine\V1beta1\UpdateCatalogItemRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for ingesting catalog information of the customer's website. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createCatalogItemAsync(CreateCatalogItemRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteCatalogItemAsync(DeleteCatalogItemRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCatalogItemAsync(GetCatalogItemRequest $request, array $optionalArgs = []) + * @method PromiseInterface importCatalogItemsAsync(ImportCatalogItemsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCatalogItemsAsync(ListCatalogItemsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCatalogItemAsync(UpdateCatalogItemRequest $request, array $optionalArgs = []) */ -final class CatalogServiceClient extends CatalogServiceBaseClient +final class CatalogServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CatalogServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.recommendationengine.v1beta1.CatalogService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'recommendationengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/catalog_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/catalog_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/catalog_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/catalog_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + * + * @experimental + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + * + * @experimental + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a catalog + * resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * + * @return string The formatted catalog resource. + * + * @experimental + */ + public static function catalogName(string $project, string $location, string $catalog): string + { + return self::getPathTemplate('catalog')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * catalog_item_path resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * @param string $catalogItemPath + * + * @return string The formatted catalog_item_path resource. + * + * @experimental + */ + public static function catalogItemPathName(string $project, string $location, string $catalog, string $catalogItemPath): string + { + return self::getPathTemplate('catalogItemPath')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + 'catalog_item_path' => $catalogItemPath, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - catalog: projects/{project}/locations/{location}/catalogs/{catalog} + * - catalogItemPath: projects/{project}/locations/{location}/catalogs/{catalog}/catalogItems/{catalog_item_path} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'recommendationengine.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); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a catalog item. + * + * The async variant is {@see CatalogServiceClient::createCatalogItemAsync()} . + * + * @example samples/V1beta1/CatalogServiceClient/create_catalog_item.php + * + * @param CreateCatalogItemRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CatalogItem + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createCatalogItem(CreateCatalogItemRequest $request, array $callOptions = []): CatalogItem + { + return $this->startApiCall('CreateCatalogItem', $request, $callOptions)->wait(); + } + + /** + * Deletes a catalog item. + * + * The async variant is {@see CatalogServiceClient::deleteCatalogItemAsync()} . + * + * @example samples/V1beta1/CatalogServiceClient/delete_catalog_item.php + * + * @param DeleteCatalogItemRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deleteCatalogItem(DeleteCatalogItemRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteCatalogItem', $request, $callOptions)->wait(); + } + + /** + * Gets a specific catalog item. + * + * The async variant is {@see CatalogServiceClient::getCatalogItemAsync()} . + * + * @example samples/V1beta1/CatalogServiceClient/get_catalog_item.php + * + * @param GetCatalogItemRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CatalogItem + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function getCatalogItem(GetCatalogItemRequest $request, array $callOptions = []): CatalogItem + { + return $this->startApiCall('GetCatalogItem', $request, $callOptions)->wait(); + } + + /** + * Bulk import of multiple catalog items. Request processing may be + * synchronous. No partial updating supported. Non-existing items will be + * created. + * + * Operation.response is of type ImportResponse. Note that it is + * possible for a subset of the items to be successfully updated. + * + * The async variant is {@see CatalogServiceClient::importCatalogItemsAsync()} . + * + * @example samples/V1beta1/CatalogServiceClient/import_catalog_items.php + * + * @param ImportCatalogItemsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function importCatalogItems(ImportCatalogItemsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportCatalogItems', $request, $callOptions)->wait(); + } + + /** + * Gets a list of catalog items. + * + * The async variant is {@see CatalogServiceClient::listCatalogItemsAsync()} . + * + * @example samples/V1beta1/CatalogServiceClient/list_catalog_items.php + * + * @param ListCatalogItemsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listCatalogItems(ListCatalogItemsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCatalogItems', $request, $callOptions); + } + + /** + * Updates a catalog item. Partial updating is supported. Non-existing + * items will be created. + * + * The async variant is {@see CatalogServiceClient::updateCatalogItemAsync()} . + * + * @example samples/V1beta1/CatalogServiceClient/update_catalog_item.php + * + * @param UpdateCatalogItemRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CatalogItem + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function updateCatalogItem(UpdateCatalogItemRequest $request, array $callOptions = []): CatalogItem + { + return $this->startApiCall('UpdateCatalogItem', $request, $callOptions)->wait(); + } } diff --git a/RecommendationEngine/src/V1beta1/Client/PredictionApiKeyRegistryClient.php b/RecommendationEngine/src/V1beta1/Client/PredictionApiKeyRegistryClient.php index 9f68c559dcb8..ebebd476c007 100644 --- a/RecommendationEngine/src/V1beta1/Client/PredictionApiKeyRegistryClient.php +++ b/RecommendationEngine/src/V1beta1/Client/PredictionApiKeyRegistryClient.php @@ -26,17 +26,318 @@ namespace Google\Cloud\RecommendationEngine\V1beta1\Client; -use Google\Cloud\RecommendationEngine\V1beta1\Client\BaseClient\PredictionApiKeyRegistryBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\RecommendationEngine\V1beta1\CreatePredictionApiKeyRegistrationRequest; +use Google\Cloud\RecommendationEngine\V1beta1\DeletePredictionApiKeyRegistrationRequest; +use Google\Cloud\RecommendationEngine\V1beta1\ListPredictionApiKeyRegistrationsRequest; +use Google\Cloud\RecommendationEngine\V1beta1\PredictionApiKeyRegistration; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for registering API keys for use with the `predict` method. If you + * use an API key to request predictions, you must first register the API key. + * Otherwise, your prediction request is rejected. If you use OAuth to + * authenticate your `predict` method call, you do not need to register an API + * key. You can register up to 20 API keys per project. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createPredictionApiKeyRegistrationAsync(CreatePredictionApiKeyRegistrationRequest $request, array $optionalArgs = []) + * @method PromiseInterface deletePredictionApiKeyRegistrationAsync(DeletePredictionApiKeyRegistrationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPredictionApiKeyRegistrationsAsync(ListPredictionApiKeyRegistrationsRequest $request, array $optionalArgs = []) */ -final class PredictionApiKeyRegistryClient extends PredictionApiKeyRegistryBaseClient +final class PredictionApiKeyRegistryClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see PredictionApiKeyRegistryBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'recommendationengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/prediction_api_key_registry_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/prediction_api_key_registry_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/prediction_api_key_registry_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/prediction_api_key_registry_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a event_store + * resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * @param string $eventStore + * + * @return string The formatted event_store resource. + * + * @experimental + */ + public static function eventStoreName(string $project, string $location, string $catalog, string $eventStore): string + { + return self::getPathTemplate('eventStore')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + 'event_store' => $eventStore, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * prediction_api_key_registration resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * @param string $eventStore + * @param string $predictionApiKeyRegistration + * + * @return string The formatted prediction_api_key_registration resource. + * + * @experimental + */ + public static function predictionApiKeyRegistrationName(string $project, string $location, string $catalog, string $eventStore, string $predictionApiKeyRegistration): string + { + return self::getPathTemplate('predictionApiKeyRegistration')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + 'event_store' => $eventStore, + 'prediction_api_key_registration' => $predictionApiKeyRegistration, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - eventStore: projects/{project}/locations/{location}/catalogs/{catalog}/eventStores/{event_store} + * - predictionApiKeyRegistration: projects/{project}/locations/{location}/catalogs/{catalog}/eventStores/{event_store}/predictionApiKeyRegistrations/{prediction_api_key_registration} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'recommendationengine.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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Register an API key for use with predict method. + * + * The async variant is + * {@see PredictionApiKeyRegistryClient::createPredictionApiKeyRegistrationAsync()} + * . + * + * @example samples/V1beta1/PredictionApiKeyRegistryClient/create_prediction_api_key_registration.php + * + * @param CreatePredictionApiKeyRegistrationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PredictionApiKeyRegistration + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createPredictionApiKeyRegistration(CreatePredictionApiKeyRegistrationRequest $request, array $callOptions = []): PredictionApiKeyRegistration + { + return $this->startApiCall('CreatePredictionApiKeyRegistration', $request, $callOptions)->wait(); + } + + /** + * Unregister an apiKey from using for predict method. + * + * The async variant is + * {@see PredictionApiKeyRegistryClient::deletePredictionApiKeyRegistrationAsync()} + * . + * + * @example samples/V1beta1/PredictionApiKeyRegistryClient/delete_prediction_api_key_registration.php + * + * @param DeletePredictionApiKeyRegistrationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function deletePredictionApiKeyRegistration(DeletePredictionApiKeyRegistrationRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeletePredictionApiKeyRegistration', $request, $callOptions)->wait(); + } + + /** + * List the registered apiKeys for use with predict method. + * + * The async variant is + * {@see PredictionApiKeyRegistryClient::listPredictionApiKeyRegistrationsAsync()} + * . + * + * @example samples/V1beta1/PredictionApiKeyRegistryClient/list_prediction_api_key_registrations.php + * + * @param ListPredictionApiKeyRegistrationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listPredictionApiKeyRegistrations(ListPredictionApiKeyRegistrationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPredictionApiKeyRegistrations', $request, $callOptions); + } } diff --git a/RecommendationEngine/src/V1beta1/Client/PredictionServiceClient.php b/RecommendationEngine/src/V1beta1/Client/PredictionServiceClient.php index c2542f0cedd0..3410e02726bb 100644 --- a/RecommendationEngine/src/V1beta1/Client/PredictionServiceClient.php +++ b/RecommendationEngine/src/V1beta1/Client/PredictionServiceClient.php @@ -26,17 +26,228 @@ namespace Google\Cloud\RecommendationEngine\V1beta1\Client; -use Google\Cloud\RecommendationEngine\V1beta1\Client\BaseClient\PredictionServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\RecommendationEngine\V1beta1\PredictRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for making recommendation prediction. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface predictAsync(PredictRequest $request, array $optionalArgs = []) */ -final class PredictionServiceClient extends PredictionServiceBaseClient +final class PredictionServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see PredictionServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.recommendationengine.v1beta1.PredictionService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'recommendationengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/prediction_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/prediction_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/prediction_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/prediction_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a placement + * resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * @param string $eventStore + * @param string $placement + * + * @return string The formatted placement resource. + * + * @experimental + */ + public static function placementName(string $project, string $location, string $catalog, string $eventStore, string $placement): string + { + return self::getPathTemplate('placement')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + 'event_store' => $eventStore, + 'placement' => $placement, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - placement: projects/{project}/locations/{location}/catalogs/{catalog}/eventStores/{event_store}/placements/{placement} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'recommendationengine.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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Makes a recommendation prediction. If using API Key based authentication, + * the API Key must be registered using the + * [PredictionApiKeyRegistry][google.cloud.recommendationengine.v1beta1.PredictionApiKeyRegistry] + * service. [Learn more](https://cloud.google.com/recommendations-ai/docs/setting-up#register-key). + * + * The async variant is {@see PredictionServiceClient::predictAsync()} . + * + * @example samples/V1beta1/PredictionServiceClient/predict.php + * + * @param PredictRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function predict(PredictRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('Predict', $request, $callOptions); + } } diff --git a/RecommendationEngine/src/V1beta1/Client/UserEventServiceClient.php b/RecommendationEngine/src/V1beta1/Client/UserEventServiceClient.php index 6be4555233b0..f3b9f488aa57 100644 --- a/RecommendationEngine/src/V1beta1/Client/UserEventServiceClient.php +++ b/RecommendationEngine/src/V1beta1/Client/UserEventServiceClient.php @@ -26,17 +26,398 @@ namespace Google\Cloud\RecommendationEngine\V1beta1\Client; -use Google\Cloud\RecommendationEngine\V1beta1\Client\BaseClient\UserEventServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Api\HttpBody; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\RecommendationEngine\V1beta1\CollectUserEventRequest; +use Google\Cloud\RecommendationEngine\V1beta1\ImportMetadata; +use Google\Cloud\RecommendationEngine\V1beta1\ImportUserEventsRequest; +use Google\Cloud\RecommendationEngine\V1beta1\ListUserEventsRequest; +use Google\Cloud\RecommendationEngine\V1beta1\PurgeUserEventsRequest; +use Google\Cloud\RecommendationEngine\V1beta1\UserEvent; +use Google\Cloud\RecommendationEngine\V1beta1\WriteUserEventRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for ingesting end user actions on the customer website. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface collectUserEventAsync(CollectUserEventRequest $request, array $optionalArgs = []) + * @method PromiseInterface importUserEventsAsync(ImportUserEventsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listUserEventsAsync(ListUserEventsRequest $request, array $optionalArgs = []) + * @method PromiseInterface purgeUserEventsAsync(PurgeUserEventsRequest $request, array $optionalArgs = []) + * @method PromiseInterface writeUserEventAsync(WriteUserEventRequest $request, array $optionalArgs = []) */ -final class UserEventServiceClient extends UserEventServiceBaseClient +final class UserEventServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see UserEventServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.recommendationengine.v1beta1.UserEventService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'recommendationengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/user_event_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/user_event_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/user_event_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/user_event_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + * + * @experimental + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + * + * @experimental + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a event_store + * resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * @param string $eventStore + * + * @return string The formatted event_store resource. + * + * @experimental + */ + public static function eventStoreName(string $project, string $location, string $catalog, string $eventStore): string + { + return self::getPathTemplate('eventStore')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + 'event_store' => $eventStore, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - eventStore: projects/{project}/locations/{location}/catalogs/{catalog}/eventStores/{event_store} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'recommendationengine.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); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Writes a single user event from the browser. This uses a GET request to + * due to browser restriction of POST-ing to a 3rd party domain. + * + * This method is used only by the Recommendations AI JavaScript pixel. + * Users should not call this method directly. + * + * The async variant is {@see UserEventServiceClient::collectUserEventAsync()} . + * + * @example samples/V1beta1/UserEventServiceClient/collect_user_event.php + * + * @param CollectUserEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 HttpBody + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function collectUserEvent(CollectUserEventRequest $request, array $callOptions = []): HttpBody + { + return $this->startApiCall('CollectUserEvent', $request, $callOptions)->wait(); + } + + /** + * Bulk import of User events. Request processing might be + * synchronous. Events that already exist are skipped. + * Use this method for backfilling historical user events. + * + * Operation.response is of type ImportResponse. Note that it is + * possible for a subset of the items to be successfully inserted. + * Operation.metadata is of type ImportMetadata. + * + * The async variant is {@see UserEventServiceClient::importUserEventsAsync()} . + * + * @example samples/V1beta1/UserEventServiceClient/import_user_events.php + * + * @param ImportUserEventsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function importUserEvents(ImportUserEventsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportUserEvents', $request, $callOptions)->wait(); + } + + /** + * Gets a list of user events within a time range, with potential filtering. + * + * The async variant is {@see UserEventServiceClient::listUserEventsAsync()} . + * + * @example samples/V1beta1/UserEventServiceClient/list_user_events.php + * + * @param ListUserEventsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function listUserEvents(ListUserEventsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListUserEvents', $request, $callOptions); + } + + /** + * Deletes permanently all user events specified by the filter provided. + * Depending on the number of events specified by the filter, this operation + * could take hours or days to complete. To test a filter, use the list + * command first. + * + * The async variant is {@see UserEventServiceClient::purgeUserEventsAsync()} . + * + * @example samples/V1beta1/UserEventServiceClient/purge_user_events.php + * + * @param PurgeUserEventsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function purgeUserEvents(PurgeUserEventsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('PurgeUserEvents', $request, $callOptions)->wait(); + } + + /** + * Writes a single user event. + * + * The async variant is {@see UserEventServiceClient::writeUserEventAsync()} . + * + * @example samples/V1beta1/UserEventServiceClient/write_user_event.php + * + * @param WriteUserEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 UserEvent + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function writeUserEvent(WriteUserEventRequest $request, array $callOptions = []): UserEvent + { + return $this->startApiCall('WriteUserEvent', $request, $callOptions)->wait(); + } } diff --git a/Recommender/composer.json b/Recommender/composer.json index 453cd95a9327..cc64ebccb040 100644 --- a/Recommender/composer.json +++ b/Recommender/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Recommender/src/V1/Client/BaseClient/RecommenderBaseClient.php b/Recommender/src/V1/Client/BaseClient/RecommenderBaseClient.php deleted file mode 100644 index 93403cd64e32..000000000000 --- a/Recommender/src/V1/Client/BaseClient/RecommenderBaseClient.php +++ /dev/null @@ -1,1166 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/recommender_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/recommender_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/recommender_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/recommender_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * billing_account_location_insight_type resource. - * - * @param string $billingAccount - * @param string $location - * @param string $insightType - * - * @return string The formatted billing_account_location_insight_type resource. - */ - public static function billingAccountLocationInsightTypeName(string $billingAccount, string $location, string $insightType): string - { - return self::getPathTemplate('billingAccountLocationInsightType')->render([ - 'billing_account' => $billingAccount, - 'location' => $location, - 'insight_type' => $insightType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * billing_account_location_insight_type_config resource. - * - * @param string $billingAccount - * @param string $location - * @param string $insightType - * - * @return string The formatted billing_account_location_insight_type_config resource. - */ - public static function billingAccountLocationInsightTypeConfigName(string $billingAccount, string $location, string $insightType): string - { - return self::getPathTemplate('billingAccountLocationInsightTypeConfig')->render([ - 'billing_account' => $billingAccount, - 'location' => $location, - 'insight_type' => $insightType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * billing_account_location_insight_type_insight resource. - * - * @param string $billingAccount - * @param string $location - * @param string $insightType - * @param string $insight - * - * @return string The formatted billing_account_location_insight_type_insight resource. - */ - public static function billingAccountLocationInsightTypeInsightName(string $billingAccount, string $location, string $insightType, string $insight): string - { - return self::getPathTemplate('billingAccountLocationInsightTypeInsight')->render([ - 'billing_account' => $billingAccount, - 'location' => $location, - 'insight_type' => $insightType, - 'insight' => $insight, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * billing_account_location_recommender resource. - * - * @param string $billingAccount - * @param string $location - * @param string $recommender - * - * @return string The formatted billing_account_location_recommender resource. - */ - public static function billingAccountLocationRecommenderName(string $billingAccount, string $location, string $recommender): string - { - return self::getPathTemplate('billingAccountLocationRecommender')->render([ - 'billing_account' => $billingAccount, - 'location' => $location, - 'recommender' => $recommender, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * billing_account_location_recommender_config resource. - * - * @param string $billingAccount - * @param string $location - * @param string $recommender - * - * @return string The formatted billing_account_location_recommender_config resource. - */ - public static function billingAccountLocationRecommenderConfigName(string $billingAccount, string $location, string $recommender): string - { - return self::getPathTemplate('billingAccountLocationRecommenderConfig')->render([ - 'billing_account' => $billingAccount, - 'location' => $location, - 'recommender' => $recommender, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * billing_account_location_recommender_recommendation resource. - * - * @param string $billingAccount - * @param string $location - * @param string $recommender - * @param string $recommendation - * - * @return string The formatted billing_account_location_recommender_recommendation resource. - */ - public static function billingAccountLocationRecommenderRecommendationName(string $billingAccount, string $location, string $recommender, string $recommendation): string - { - return self::getPathTemplate('billingAccountLocationRecommenderRecommendation')->render([ - 'billing_account' => $billingAccount, - 'location' => $location, - 'recommender' => $recommender, - 'recommendation' => $recommendation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_location_insight_type resource. - * - * @param string $folder - * @param string $location - * @param string $insightType - * - * @return string The formatted folder_location_insight_type resource. - */ - public static function folderLocationInsightTypeName(string $folder, string $location, string $insightType): string - { - return self::getPathTemplate('folderLocationInsightType')->render([ - 'folder' => $folder, - 'location' => $location, - 'insight_type' => $insightType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_location_insight_type_insight resource. - * - * @param string $folder - * @param string $location - * @param string $insightType - * @param string $insight - * - * @return string The formatted folder_location_insight_type_insight resource. - */ - public static function folderLocationInsightTypeInsightName(string $folder, string $location, string $insightType, string $insight): string - { - return self::getPathTemplate('folderLocationInsightTypeInsight')->render([ - 'folder' => $folder, - 'location' => $location, - 'insight_type' => $insightType, - 'insight' => $insight, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_location_recommender resource. - * - * @param string $folder - * @param string $location - * @param string $recommender - * - * @return string The formatted folder_location_recommender resource. - */ - public static function folderLocationRecommenderName(string $folder, string $location, string $recommender): string - { - return self::getPathTemplate('folderLocationRecommender')->render([ - 'folder' => $folder, - 'location' => $location, - 'recommender' => $recommender, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_location_recommender_recommendation resource. - * - * @param string $folder - * @param string $location - * @param string $recommender - * @param string $recommendation - * - * @return string The formatted folder_location_recommender_recommendation resource. - */ - public static function folderLocationRecommenderRecommendationName(string $folder, string $location, string $recommender, string $recommendation): string - { - return self::getPathTemplate('folderLocationRecommenderRecommendation')->render([ - 'folder' => $folder, - 'location' => $location, - 'recommender' => $recommender, - 'recommendation' => $recommendation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a insight - * resource. - * - * @param string $project - * @param string $location - * @param string $insightType - * @param string $insight - * - * @return string The formatted insight resource. - */ - public static function insightName(string $project, string $location, string $insightType, string $insight): string - { - return self::getPathTemplate('insight')->render([ - 'project' => $project, - 'location' => $location, - 'insight_type' => $insightType, - 'insight' => $insight, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a insight_type - * resource. - * - * @param string $project - * @param string $location - * @param string $insightType - * - * @return string The formatted insight_type resource. - */ - public static function insightTypeName(string $project, string $location, string $insightType): string - { - return self::getPathTemplate('insightType')->render([ - 'project' => $project, - 'location' => $location, - 'insight_type' => $insightType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * insight_type_config resource. - * - * @param string $project - * @param string $location - * @param string $insightType - * - * @return string The formatted insight_type_config resource. - */ - public static function insightTypeConfigName(string $project, string $location, string $insightType): string - { - return self::getPathTemplate('insightTypeConfig')->render([ - 'project' => $project, - 'location' => $location, - 'insight_type' => $insightType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_location_insight_type resource. - * - * @param string $organization - * @param string $location - * @param string $insightType - * - * @return string The formatted organization_location_insight_type resource. - */ - public static function organizationLocationInsightTypeName(string $organization, string $location, string $insightType): string - { - return self::getPathTemplate('organizationLocationInsightType')->render([ - 'organization' => $organization, - 'location' => $location, - 'insight_type' => $insightType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_location_insight_type_config resource. - * - * @param string $organization - * @param string $location - * @param string $insightType - * - * @return string The formatted organization_location_insight_type_config resource. - */ - public static function organizationLocationInsightTypeConfigName(string $organization, string $location, string $insightType): string - { - return self::getPathTemplate('organizationLocationInsightTypeConfig')->render([ - 'organization' => $organization, - 'location' => $location, - 'insight_type' => $insightType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_location_insight_type_insight resource. - * - * @param string $organization - * @param string $location - * @param string $insightType - * @param string $insight - * - * @return string The formatted organization_location_insight_type_insight resource. - */ - public static function organizationLocationInsightTypeInsightName(string $organization, string $location, string $insightType, string $insight): string - { - return self::getPathTemplate('organizationLocationInsightTypeInsight')->render([ - 'organization' => $organization, - 'location' => $location, - 'insight_type' => $insightType, - 'insight' => $insight, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_location_recommender resource. - * - * @param string $organization - * @param string $location - * @param string $recommender - * - * @return string The formatted organization_location_recommender resource. - */ - public static function organizationLocationRecommenderName(string $organization, string $location, string $recommender): string - { - return self::getPathTemplate('organizationLocationRecommender')->render([ - 'organization' => $organization, - 'location' => $location, - 'recommender' => $recommender, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_location_recommender_config resource. - * - * @param string $organization - * @param string $location - * @param string $recommender - * - * @return string The formatted organization_location_recommender_config resource. - */ - public static function organizationLocationRecommenderConfigName(string $organization, string $location, string $recommender): string - { - return self::getPathTemplate('organizationLocationRecommenderConfig')->render([ - 'organization' => $organization, - 'location' => $location, - 'recommender' => $recommender, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_location_recommender_recommendation resource. - * - * @param string $organization - * @param string $location - * @param string $recommender - * @param string $recommendation - * - * @return string The formatted organization_location_recommender_recommendation resource. - */ - public static function organizationLocationRecommenderRecommendationName(string $organization, string $location, string $recommender, string $recommendation): string - { - return self::getPathTemplate('organizationLocationRecommenderRecommendation')->render([ - 'organization' => $organization, - 'location' => $location, - 'recommender' => $recommender, - 'recommendation' => $recommendation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_insight_type resource. - * - * @param string $project - * @param string $location - * @param string $insightType - * - * @return string The formatted project_location_insight_type resource. - */ - public static function projectLocationInsightTypeName(string $project, string $location, string $insightType): string - { - return self::getPathTemplate('projectLocationInsightType')->render([ - 'project' => $project, - 'location' => $location, - 'insight_type' => $insightType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_insight_type_config resource. - * - * @param string $project - * @param string $location - * @param string $insightType - * - * @return string The formatted project_location_insight_type_config resource. - */ - public static function projectLocationInsightTypeConfigName(string $project, string $location, string $insightType): string - { - return self::getPathTemplate('projectLocationInsightTypeConfig')->render([ - 'project' => $project, - 'location' => $location, - 'insight_type' => $insightType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_insight_type_insight resource. - * - * @param string $project - * @param string $location - * @param string $insightType - * @param string $insight - * - * @return string The formatted project_location_insight_type_insight resource. - */ - public static function projectLocationInsightTypeInsightName(string $project, string $location, string $insightType, string $insight): string - { - return self::getPathTemplate('projectLocationInsightTypeInsight')->render([ - 'project' => $project, - 'location' => $location, - 'insight_type' => $insightType, - 'insight' => $insight, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_recommender resource. - * - * @param string $project - * @param string $location - * @param string $recommender - * - * @return string The formatted project_location_recommender resource. - */ - public static function projectLocationRecommenderName(string $project, string $location, string $recommender): string - { - return self::getPathTemplate('projectLocationRecommender')->render([ - 'project' => $project, - 'location' => $location, - 'recommender' => $recommender, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_recommender_config resource. - * - * @param string $project - * @param string $location - * @param string $recommender - * - * @return string The formatted project_location_recommender_config resource. - */ - public static function projectLocationRecommenderConfigName(string $project, string $location, string $recommender): string - { - return self::getPathTemplate('projectLocationRecommenderConfig')->render([ - 'project' => $project, - 'location' => $location, - 'recommender' => $recommender, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_recommender_recommendation resource. - * - * @param string $project - * @param string $location - * @param string $recommender - * @param string $recommendation - * - * @return string The formatted project_location_recommender_recommendation resource. - */ - public static function projectLocationRecommenderRecommendationName(string $project, string $location, string $recommender, string $recommendation): string - { - return self::getPathTemplate('projectLocationRecommenderRecommendation')->render([ - 'project' => $project, - 'location' => $location, - 'recommender' => $recommender, - 'recommendation' => $recommendation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * recommendation resource. - * - * @param string $project - * @param string $location - * @param string $recommender - * @param string $recommendation - * - * @return string The formatted recommendation resource. - */ - public static function recommendationName(string $project, string $location, string $recommender, string $recommendation): string - { - return self::getPathTemplate('recommendation')->render([ - 'project' => $project, - 'location' => $location, - 'recommender' => $recommender, - 'recommendation' => $recommendation, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a recommender - * resource. - * - * @param string $project - * @param string $location - * @param string $recommender - * - * @return string The formatted recommender resource. - */ - public static function recommenderName(string $project, string $location, string $recommender): string - { - return self::getPathTemplate('recommender')->render([ - 'project' => $project, - 'location' => $location, - 'recommender' => $recommender, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * recommender_config resource. - * - * @param string $project - * @param string $location - * @param string $recommender - * - * @return string The formatted recommender_config resource. - */ - public static function recommenderConfigName(string $project, string $location, string $recommender): string - { - return self::getPathTemplate('recommenderConfig')->render([ - 'project' => $project, - 'location' => $location, - 'recommender' => $recommender, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - billingAccountLocationInsightType: billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type} - * - billingAccountLocationInsightTypeConfig: billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}/config - * - billingAccountLocationInsightTypeInsight: billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}/insights/{insight} - * - billingAccountLocationRecommender: billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender} - * - billingAccountLocationRecommenderConfig: billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}/config - * - billingAccountLocationRecommenderRecommendation: billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation} - * - folderLocationInsightType: folders/{folder}/locations/{location}/insightTypes/{insight_type} - * - folderLocationInsightTypeInsight: folders/{folder}/locations/{location}/insightTypes/{insight_type}/insights/{insight} - * - folderLocationRecommender: folders/{folder}/locations/{location}/recommenders/{recommender} - * - folderLocationRecommenderRecommendation: folders/{folder}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation} - * - insight: projects/{project}/locations/{location}/insightTypes/{insight_type}/insights/{insight} - * - insightType: projects/{project}/locations/{location}/insightTypes/{insight_type} - * - insightTypeConfig: projects/{project}/locations/{location}/insightTypes/{insight_type}/config - * - organizationLocationInsightType: organizations/{organization}/locations/{location}/insightTypes/{insight_type} - * - organizationLocationInsightTypeConfig: organizations/{organization}/locations/{location}/insightTypes/{insight_type}/config - * - organizationLocationInsightTypeInsight: organizations/{organization}/locations/{location}/insightTypes/{insight_type}/insights/{insight} - * - organizationLocationRecommender: organizations/{organization}/locations/{location}/recommenders/{recommender} - * - organizationLocationRecommenderConfig: organizations/{organization}/locations/{location}/recommenders/{recommender}/config - * - organizationLocationRecommenderRecommendation: organizations/{organization}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation} - * - projectLocationInsightType: projects/{project}/locations/{location}/insightTypes/{insight_type} - * - projectLocationInsightTypeConfig: projects/{project}/locations/{location}/insightTypes/{insight_type}/config - * - projectLocationInsightTypeInsight: projects/{project}/locations/{location}/insightTypes/{insight_type}/insights/{insight} - * - projectLocationRecommender: projects/{project}/locations/{location}/recommenders/{recommender} - * - projectLocationRecommenderConfig: projects/{project}/locations/{location}/recommenders/{recommender}/config - * - projectLocationRecommenderRecommendation: projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation} - * - recommendation: projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation} - * - recommender: projects/{project}/locations/{location}/recommenders/{recommender} - * - recommenderConfig: projects/{project}/locations/{location}/recommenders/{recommender}/config - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'recommender.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Gets the requested insight. Requires the recommender.*.get IAM permission - * for the specified insight type. - * - * The async variant is {@see self::getInsightAsync()} . - * - * @param GetInsightRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Insight - * - * @throws ApiException Thrown if the API call fails. - */ - public function getInsight(GetInsightRequest $request, array $callOptions = []): Insight - { - return $this->startApiCall('GetInsight', $request, $callOptions)->wait(); - } - - /** - * Gets the requested InsightTypeConfig. There is only one instance of the - * config for each InsightType. - * - * The async variant is {@see self::getInsightTypeConfigAsync()} . - * - * @param GetInsightTypeConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InsightTypeConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getInsightTypeConfig(GetInsightTypeConfigRequest $request, array $callOptions = []): InsightTypeConfig - { - return $this->startApiCall('GetInsightTypeConfig', $request, $callOptions)->wait(); - } - - /** - * Gets the requested recommendation. Requires the recommender.*.get - * IAM permission for the specified recommender. - * - * The async variant is {@see self::getRecommendationAsync()} . - * - * @param GetRecommendationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Recommendation - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRecommendation(GetRecommendationRequest $request, array $callOptions = []): Recommendation - { - return $this->startApiCall('GetRecommendation', $request, $callOptions)->wait(); - } - - /** - * Gets the requested Recommender Config. There is only one instance of the - * config for each Recommender. - * - * The async variant is {@see self::getRecommenderConfigAsync()} . - * - * @param GetRecommenderConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RecommenderConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRecommenderConfig(GetRecommenderConfigRequest $request, array $callOptions = []): RecommenderConfig - { - return $this->startApiCall('GetRecommenderConfig', $request, $callOptions)->wait(); - } - - /** - * Lists insights for the specified Cloud Resource. Requires the - * recommender.*.list IAM permission for the specified insight type. - * - * The async variant is {@see self::listInsightsAsync()} . - * - * @param ListInsightsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listInsights(ListInsightsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListInsights', $request, $callOptions); - } - - /** - * Lists recommendations for the specified Cloud Resource. Requires the - * recommender.*.list IAM permission for the specified recommender. - * - * The async variant is {@see self::listRecommendationsAsync()} . - * - * @param ListRecommendationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listRecommendations(ListRecommendationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListRecommendations', $request, $callOptions); - } - - /** - * Marks the Insight State as Accepted. Users can use this method to - * indicate to the Recommender API that they have applied some action based - * on the insight. This stops the insight content from being updated. - * - * MarkInsightAccepted can be applied to insights in ACTIVE state. Requires - * the recommender.*.update IAM permission for the specified insight. - * - * The async variant is {@see self::markInsightAcceptedAsync()} . - * - * @param MarkInsightAcceptedRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Insight - * - * @throws ApiException Thrown if the API call fails. - */ - public function markInsightAccepted(MarkInsightAcceptedRequest $request, array $callOptions = []): Insight - { - return $this->startApiCall('MarkInsightAccepted', $request, $callOptions)->wait(); - } - - /** - * Marks the Recommendation State as Claimed. Users can use this method to - * indicate to the Recommender API that they are starting to apply the - * recommendation themselves. This stops the recommendation content from being - * updated. Associated insights are frozen and placed in the ACCEPTED state. - * - * MarkRecommendationClaimed can be applied to recommendations in CLAIMED, - * SUCCEEDED, FAILED, or ACTIVE state. - * - * Requires the recommender.*.update IAM permission for the specified - * recommender. - * - * The async variant is {@see self::markRecommendationClaimedAsync()} . - * - * @param MarkRecommendationClaimedRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Recommendation - * - * @throws ApiException Thrown if the API call fails. - */ - public function markRecommendationClaimed(MarkRecommendationClaimedRequest $request, array $callOptions = []): Recommendation - { - return $this->startApiCall('MarkRecommendationClaimed', $request, $callOptions)->wait(); - } - - /** - * Mark the Recommendation State as Dismissed. Users can use this method to - * indicate to the Recommender API that an ACTIVE recommendation has to - * be marked back as DISMISSED. - * - * MarkRecommendationDismissed can be applied to recommendations in ACTIVE - * state. - * - * Requires the recommender.*.update IAM permission for the specified - * recommender. - * - * The async variant is {@see self::markRecommendationDismissedAsync()} . - * - * @param MarkRecommendationDismissedRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Recommendation - * - * @throws ApiException Thrown if the API call fails. - */ - public function markRecommendationDismissed(MarkRecommendationDismissedRequest $request, array $callOptions = []): Recommendation - { - return $this->startApiCall('MarkRecommendationDismissed', $request, $callOptions)->wait(); - } - - /** - * Marks the Recommendation State as Failed. Users can use this method to - * indicate to the Recommender API that they have applied the recommendation - * themselves, and the operation failed. This stops the recommendation content - * from being updated. Associated insights are frozen and placed in the - * ACCEPTED state. - * - * MarkRecommendationFailed can be applied to recommendations in ACTIVE, - * CLAIMED, SUCCEEDED, or FAILED state. - * - * Requires the recommender.*.update IAM permission for the specified - * recommender. - * - * The async variant is {@see self::markRecommendationFailedAsync()} . - * - * @param MarkRecommendationFailedRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Recommendation - * - * @throws ApiException Thrown if the API call fails. - */ - public function markRecommendationFailed(MarkRecommendationFailedRequest $request, array $callOptions = []): Recommendation - { - return $this->startApiCall('MarkRecommendationFailed', $request, $callOptions)->wait(); - } - - /** - * Marks the Recommendation State as Succeeded. Users can use this method to - * indicate to the Recommender API that they have applied the recommendation - * themselves, and the operation was successful. This stops the recommendation - * content from being updated. Associated insights are frozen and placed in - * the ACCEPTED state. - * - * MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, - * CLAIMED, SUCCEEDED, or FAILED state. - * - * Requires the recommender.*.update IAM permission for the specified - * recommender. - * - * The async variant is {@see self::markRecommendationSucceededAsync()} . - * - * @param MarkRecommendationSucceededRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Recommendation - * - * @throws ApiException Thrown if the API call fails. - */ - public function markRecommendationSucceeded(MarkRecommendationSucceededRequest $request, array $callOptions = []): Recommendation - { - return $this->startApiCall('MarkRecommendationSucceeded', $request, $callOptions)->wait(); - } - - /** - * Updates an InsightTypeConfig change. This will create a new revision of the - * config. - * - * The async variant is {@see self::updateInsightTypeConfigAsync()} . - * - * @param UpdateInsightTypeConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InsightTypeConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateInsightTypeConfig(UpdateInsightTypeConfigRequest $request, array $callOptions = []): InsightTypeConfig - { - return $this->startApiCall('UpdateInsightTypeConfig', $request, $callOptions)->wait(); - } - - /** - * Updates a Recommender Config. This will create a new revision of the - * config. - * - * The async variant is {@see self::updateRecommenderConfigAsync()} . - * - * @param UpdateRecommenderConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RecommenderConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateRecommenderConfig(UpdateRecommenderConfigRequest $request, array $callOptions = []): RecommenderConfig - { - return $this->startApiCall('UpdateRecommenderConfig', $request, $callOptions)->wait(); - } -} diff --git a/Recommender/src/V1/Client/RecommenderClient.php b/Recommender/src/V1/Client/RecommenderClient.php index da1d25df517d..c9b9e3ad9e6b 100644 --- a/Recommender/src/V1/Client/RecommenderClient.php +++ b/Recommender/src/V1/Client/RecommenderClient.php @@ -24,17 +24,1144 @@ namespace Google\Cloud\Recommender\V1\Client; -use Google\Cloud\Recommender\V1\Client\BaseClient\RecommenderBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Recommender\V1\GetInsightRequest; +use Google\Cloud\Recommender\V1\GetInsightTypeConfigRequest; +use Google\Cloud\Recommender\V1\GetRecommendationRequest; +use Google\Cloud\Recommender\V1\GetRecommenderConfigRequest; +use Google\Cloud\Recommender\V1\Insight; +use Google\Cloud\Recommender\V1\InsightTypeConfig; +use Google\Cloud\Recommender\V1\ListInsightsRequest; +use Google\Cloud\Recommender\V1\ListRecommendationsRequest; +use Google\Cloud\Recommender\V1\MarkInsightAcceptedRequest; +use Google\Cloud\Recommender\V1\MarkRecommendationClaimedRequest; +use Google\Cloud\Recommender\V1\MarkRecommendationDismissedRequest; +use Google\Cloud\Recommender\V1\MarkRecommendationFailedRequest; +use Google\Cloud\Recommender\V1\MarkRecommendationSucceededRequest; +use Google\Cloud\Recommender\V1\Recommendation; +use Google\Cloud\Recommender\V1\RecommenderConfig; +use Google\Cloud\Recommender\V1\UpdateInsightTypeConfigRequest; +use Google\Cloud\Recommender\V1\UpdateRecommenderConfigRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Provides insights and recommendations for cloud customers for various + * categories like performance optimization, cost savings, reliability, feature + * discovery, etc. Insights and recommendations are generated automatically + * based on analysis of user resources, configuration and monitoring metrics. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Recommender\V1\RecommenderClient} for the stable implementation * * @experimental + * + * @method PromiseInterface getInsightAsync(GetInsightRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInsightTypeConfigAsync(GetInsightTypeConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRecommendationAsync(GetRecommendationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRecommenderConfigAsync(GetRecommenderConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInsightsAsync(ListInsightsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listRecommendationsAsync(ListRecommendationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface markInsightAcceptedAsync(MarkInsightAcceptedRequest $request, array $optionalArgs = []) + * @method PromiseInterface markRecommendationClaimedAsync(MarkRecommendationClaimedRequest $request, array $optionalArgs = []) + * @method PromiseInterface markRecommendationDismissedAsync(MarkRecommendationDismissedRequest $request, array $optionalArgs = []) + * @method PromiseInterface markRecommendationFailedAsync(MarkRecommendationFailedRequest $request, array $optionalArgs = []) + * @method PromiseInterface markRecommendationSucceededAsync(MarkRecommendationSucceededRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateInsightTypeConfigAsync(UpdateInsightTypeConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateRecommenderConfigAsync(UpdateRecommenderConfigRequest $request, array $optionalArgs = []) */ -final class RecommenderClient extends RecommenderBaseClient +final class RecommenderClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RecommenderBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.recommender.v1.Recommender'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'recommender.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/recommender_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/recommender_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/recommender_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/recommender_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * billing_account_location_insight_type resource. + * + * @param string $billingAccount + * @param string $location + * @param string $insightType + * + * @return string The formatted billing_account_location_insight_type resource. + */ + public static function billingAccountLocationInsightTypeName(string $billingAccount, string $location, string $insightType): string + { + return self::getPathTemplate('billingAccountLocationInsightType')->render([ + 'billing_account' => $billingAccount, + 'location' => $location, + 'insight_type' => $insightType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * billing_account_location_insight_type_config resource. + * + * @param string $billingAccount + * @param string $location + * @param string $insightType + * + * @return string The formatted billing_account_location_insight_type_config resource. + */ + public static function billingAccountLocationInsightTypeConfigName(string $billingAccount, string $location, string $insightType): string + { + return self::getPathTemplate('billingAccountLocationInsightTypeConfig')->render([ + 'billing_account' => $billingAccount, + 'location' => $location, + 'insight_type' => $insightType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * billing_account_location_insight_type_insight resource. + * + * @param string $billingAccount + * @param string $location + * @param string $insightType + * @param string $insight + * + * @return string The formatted billing_account_location_insight_type_insight resource. + */ + public static function billingAccountLocationInsightTypeInsightName(string $billingAccount, string $location, string $insightType, string $insight): string + { + return self::getPathTemplate('billingAccountLocationInsightTypeInsight')->render([ + 'billing_account' => $billingAccount, + 'location' => $location, + 'insight_type' => $insightType, + 'insight' => $insight, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * billing_account_location_recommender resource. + * + * @param string $billingAccount + * @param string $location + * @param string $recommender + * + * @return string The formatted billing_account_location_recommender resource. + */ + public static function billingAccountLocationRecommenderName(string $billingAccount, string $location, string $recommender): string + { + return self::getPathTemplate('billingAccountLocationRecommender')->render([ + 'billing_account' => $billingAccount, + 'location' => $location, + 'recommender' => $recommender, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * billing_account_location_recommender_config resource. + * + * @param string $billingAccount + * @param string $location + * @param string $recommender + * + * @return string The formatted billing_account_location_recommender_config resource. + */ + public static function billingAccountLocationRecommenderConfigName(string $billingAccount, string $location, string $recommender): string + { + return self::getPathTemplate('billingAccountLocationRecommenderConfig')->render([ + 'billing_account' => $billingAccount, + 'location' => $location, + 'recommender' => $recommender, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * billing_account_location_recommender_recommendation resource. + * + * @param string $billingAccount + * @param string $location + * @param string $recommender + * @param string $recommendation + * + * @return string The formatted billing_account_location_recommender_recommendation resource. + */ + public static function billingAccountLocationRecommenderRecommendationName(string $billingAccount, string $location, string $recommender, string $recommendation): string + { + return self::getPathTemplate('billingAccountLocationRecommenderRecommendation')->render([ + 'billing_account' => $billingAccount, + 'location' => $location, + 'recommender' => $recommender, + 'recommendation' => $recommendation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_location_insight_type resource. + * + * @param string $folder + * @param string $location + * @param string $insightType + * + * @return string The formatted folder_location_insight_type resource. + */ + public static function folderLocationInsightTypeName(string $folder, string $location, string $insightType): string + { + return self::getPathTemplate('folderLocationInsightType')->render([ + 'folder' => $folder, + 'location' => $location, + 'insight_type' => $insightType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_location_insight_type_insight resource. + * + * @param string $folder + * @param string $location + * @param string $insightType + * @param string $insight + * + * @return string The formatted folder_location_insight_type_insight resource. + */ + public static function folderLocationInsightTypeInsightName(string $folder, string $location, string $insightType, string $insight): string + { + return self::getPathTemplate('folderLocationInsightTypeInsight')->render([ + 'folder' => $folder, + 'location' => $location, + 'insight_type' => $insightType, + 'insight' => $insight, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_location_recommender resource. + * + * @param string $folder + * @param string $location + * @param string $recommender + * + * @return string The formatted folder_location_recommender resource. + */ + public static function folderLocationRecommenderName(string $folder, string $location, string $recommender): string + { + return self::getPathTemplate('folderLocationRecommender')->render([ + 'folder' => $folder, + 'location' => $location, + 'recommender' => $recommender, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_location_recommender_recommendation resource. + * + * @param string $folder + * @param string $location + * @param string $recommender + * @param string $recommendation + * + * @return string The formatted folder_location_recommender_recommendation resource. + */ + public static function folderLocationRecommenderRecommendationName(string $folder, string $location, string $recommender, string $recommendation): string + { + return self::getPathTemplate('folderLocationRecommenderRecommendation')->render([ + 'folder' => $folder, + 'location' => $location, + 'recommender' => $recommender, + 'recommendation' => $recommendation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a insight + * resource. + * + * @param string $project + * @param string $location + * @param string $insightType + * @param string $insight + * + * @return string The formatted insight resource. + */ + public static function insightName(string $project, string $location, string $insightType, string $insight): string + { + return self::getPathTemplate('insight')->render([ + 'project' => $project, + 'location' => $location, + 'insight_type' => $insightType, + 'insight' => $insight, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a insight_type + * resource. + * + * @param string $project + * @param string $location + * @param string $insightType + * + * @return string The formatted insight_type resource. + */ + public static function insightTypeName(string $project, string $location, string $insightType): string + { + return self::getPathTemplate('insightType')->render([ + 'project' => $project, + 'location' => $location, + 'insight_type' => $insightType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * insight_type_config resource. + * + * @param string $project + * @param string $location + * @param string $insightType + * + * @return string The formatted insight_type_config resource. + */ + public static function insightTypeConfigName(string $project, string $location, string $insightType): string + { + return self::getPathTemplate('insightTypeConfig')->render([ + 'project' => $project, + 'location' => $location, + 'insight_type' => $insightType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_location_insight_type resource. + * + * @param string $organization + * @param string $location + * @param string $insightType + * + * @return string The formatted organization_location_insight_type resource. + */ + public static function organizationLocationInsightTypeName(string $organization, string $location, string $insightType): string + { + return self::getPathTemplate('organizationLocationInsightType')->render([ + 'organization' => $organization, + 'location' => $location, + 'insight_type' => $insightType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_location_insight_type_config resource. + * + * @param string $organization + * @param string $location + * @param string $insightType + * + * @return string The formatted organization_location_insight_type_config resource. + */ + public static function organizationLocationInsightTypeConfigName(string $organization, string $location, string $insightType): string + { + return self::getPathTemplate('organizationLocationInsightTypeConfig')->render([ + 'organization' => $organization, + 'location' => $location, + 'insight_type' => $insightType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_location_insight_type_insight resource. + * + * @param string $organization + * @param string $location + * @param string $insightType + * @param string $insight + * + * @return string The formatted organization_location_insight_type_insight resource. + */ + public static function organizationLocationInsightTypeInsightName(string $organization, string $location, string $insightType, string $insight): string + { + return self::getPathTemplate('organizationLocationInsightTypeInsight')->render([ + 'organization' => $organization, + 'location' => $location, + 'insight_type' => $insightType, + 'insight' => $insight, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_location_recommender resource. + * + * @param string $organization + * @param string $location + * @param string $recommender + * + * @return string The formatted organization_location_recommender resource. + */ + public static function organizationLocationRecommenderName(string $organization, string $location, string $recommender): string + { + return self::getPathTemplate('organizationLocationRecommender')->render([ + 'organization' => $organization, + 'location' => $location, + 'recommender' => $recommender, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_location_recommender_config resource. + * + * @param string $organization + * @param string $location + * @param string $recommender + * + * @return string The formatted organization_location_recommender_config resource. + */ + public static function organizationLocationRecommenderConfigName(string $organization, string $location, string $recommender): string + { + return self::getPathTemplate('organizationLocationRecommenderConfig')->render([ + 'organization' => $organization, + 'location' => $location, + 'recommender' => $recommender, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_location_recommender_recommendation resource. + * + * @param string $organization + * @param string $location + * @param string $recommender + * @param string $recommendation + * + * @return string The formatted organization_location_recommender_recommendation resource. + */ + public static function organizationLocationRecommenderRecommendationName(string $organization, string $location, string $recommender, string $recommendation): string + { + return self::getPathTemplate('organizationLocationRecommenderRecommendation')->render([ + 'organization' => $organization, + 'location' => $location, + 'recommender' => $recommender, + 'recommendation' => $recommendation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_insight_type resource. + * + * @param string $project + * @param string $location + * @param string $insightType + * + * @return string The formatted project_location_insight_type resource. + */ + public static function projectLocationInsightTypeName(string $project, string $location, string $insightType): string + { + return self::getPathTemplate('projectLocationInsightType')->render([ + 'project' => $project, + 'location' => $location, + 'insight_type' => $insightType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_insight_type_config resource. + * + * @param string $project + * @param string $location + * @param string $insightType + * + * @return string The formatted project_location_insight_type_config resource. + */ + public static function projectLocationInsightTypeConfigName(string $project, string $location, string $insightType): string + { + return self::getPathTemplate('projectLocationInsightTypeConfig')->render([ + 'project' => $project, + 'location' => $location, + 'insight_type' => $insightType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_insight_type_insight resource. + * + * @param string $project + * @param string $location + * @param string $insightType + * @param string $insight + * + * @return string The formatted project_location_insight_type_insight resource. + */ + public static function projectLocationInsightTypeInsightName(string $project, string $location, string $insightType, string $insight): string + { + return self::getPathTemplate('projectLocationInsightTypeInsight')->render([ + 'project' => $project, + 'location' => $location, + 'insight_type' => $insightType, + 'insight' => $insight, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_recommender resource. + * + * @param string $project + * @param string $location + * @param string $recommender + * + * @return string The formatted project_location_recommender resource. + */ + public static function projectLocationRecommenderName(string $project, string $location, string $recommender): string + { + return self::getPathTemplate('projectLocationRecommender')->render([ + 'project' => $project, + 'location' => $location, + 'recommender' => $recommender, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_recommender_config resource. + * + * @param string $project + * @param string $location + * @param string $recommender + * + * @return string The formatted project_location_recommender_config resource. + */ + public static function projectLocationRecommenderConfigName(string $project, string $location, string $recommender): string + { + return self::getPathTemplate('projectLocationRecommenderConfig')->render([ + 'project' => $project, + 'location' => $location, + 'recommender' => $recommender, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_recommender_recommendation resource. + * + * @param string $project + * @param string $location + * @param string $recommender + * @param string $recommendation + * + * @return string The formatted project_location_recommender_recommendation resource. + */ + public static function projectLocationRecommenderRecommendationName(string $project, string $location, string $recommender, string $recommendation): string + { + return self::getPathTemplate('projectLocationRecommenderRecommendation')->render([ + 'project' => $project, + 'location' => $location, + 'recommender' => $recommender, + 'recommendation' => $recommendation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * recommendation resource. + * + * @param string $project + * @param string $location + * @param string $recommender + * @param string $recommendation + * + * @return string The formatted recommendation resource. + */ + public static function recommendationName(string $project, string $location, string $recommender, string $recommendation): string + { + return self::getPathTemplate('recommendation')->render([ + 'project' => $project, + 'location' => $location, + 'recommender' => $recommender, + 'recommendation' => $recommendation, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a recommender + * resource. + * + * @param string $project + * @param string $location + * @param string $recommender + * + * @return string The formatted recommender resource. + */ + public static function recommenderName(string $project, string $location, string $recommender): string + { + return self::getPathTemplate('recommender')->render([ + 'project' => $project, + 'location' => $location, + 'recommender' => $recommender, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * recommender_config resource. + * + * @param string $project + * @param string $location + * @param string $recommender + * + * @return string The formatted recommender_config resource. + */ + public static function recommenderConfigName(string $project, string $location, string $recommender): string + { + return self::getPathTemplate('recommenderConfig')->render([ + 'project' => $project, + 'location' => $location, + 'recommender' => $recommender, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - billingAccountLocationInsightType: billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type} + * - billingAccountLocationInsightTypeConfig: billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}/config + * - billingAccountLocationInsightTypeInsight: billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}/insights/{insight} + * - billingAccountLocationRecommender: billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender} + * - billingAccountLocationRecommenderConfig: billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}/config + * - billingAccountLocationRecommenderRecommendation: billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation} + * - folderLocationInsightType: folders/{folder}/locations/{location}/insightTypes/{insight_type} + * - folderLocationInsightTypeInsight: folders/{folder}/locations/{location}/insightTypes/{insight_type}/insights/{insight} + * - folderLocationRecommender: folders/{folder}/locations/{location}/recommenders/{recommender} + * - folderLocationRecommenderRecommendation: folders/{folder}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation} + * - insight: projects/{project}/locations/{location}/insightTypes/{insight_type}/insights/{insight} + * - insightType: projects/{project}/locations/{location}/insightTypes/{insight_type} + * - insightTypeConfig: projects/{project}/locations/{location}/insightTypes/{insight_type}/config + * - organizationLocationInsightType: organizations/{organization}/locations/{location}/insightTypes/{insight_type} + * - organizationLocationInsightTypeConfig: organizations/{organization}/locations/{location}/insightTypes/{insight_type}/config + * - organizationLocationInsightTypeInsight: organizations/{organization}/locations/{location}/insightTypes/{insight_type}/insights/{insight} + * - organizationLocationRecommender: organizations/{organization}/locations/{location}/recommenders/{recommender} + * - organizationLocationRecommenderConfig: organizations/{organization}/locations/{location}/recommenders/{recommender}/config + * - organizationLocationRecommenderRecommendation: organizations/{organization}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation} + * - projectLocationInsightType: projects/{project}/locations/{location}/insightTypes/{insight_type} + * - projectLocationInsightTypeConfig: projects/{project}/locations/{location}/insightTypes/{insight_type}/config + * - projectLocationInsightTypeInsight: projects/{project}/locations/{location}/insightTypes/{insight_type}/insights/{insight} + * - projectLocationRecommender: projects/{project}/locations/{location}/recommenders/{recommender} + * - projectLocationRecommenderConfig: projects/{project}/locations/{location}/recommenders/{recommender}/config + * - projectLocationRecommenderRecommendation: projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation} + * - recommendation: projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation} + * - recommender: projects/{project}/locations/{location}/recommenders/{recommender} + * - recommenderConfig: projects/{project}/locations/{location}/recommenders/{recommender}/config + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'recommender.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Gets the requested insight. Requires the recommender.*.get IAM permission + * for the specified insight type. + * + * The async variant is {@see RecommenderClient::getInsightAsync()} . + * + * @param GetInsightRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Insight + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInsight(GetInsightRequest $request, array $callOptions = []): Insight + { + return $this->startApiCall('GetInsight', $request, $callOptions)->wait(); + } + + /** + * Gets the requested InsightTypeConfig. There is only one instance of the + * config for each InsightType. + * + * The async variant is {@see RecommenderClient::getInsightTypeConfigAsync()} . + * + * @param GetInsightTypeConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InsightTypeConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInsightTypeConfig(GetInsightTypeConfigRequest $request, array $callOptions = []): InsightTypeConfig + { + return $this->startApiCall('GetInsightTypeConfig', $request, $callOptions)->wait(); + } + + /** + * Gets the requested recommendation. Requires the recommender.*.get + * IAM permission for the specified recommender. + * + * The async variant is {@see RecommenderClient::getRecommendationAsync()} . + * + * @param GetRecommendationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Recommendation + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRecommendation(GetRecommendationRequest $request, array $callOptions = []): Recommendation + { + return $this->startApiCall('GetRecommendation', $request, $callOptions)->wait(); + } + + /** + * Gets the requested Recommender Config. There is only one instance of the + * config for each Recommender. + * + * The async variant is {@see RecommenderClient::getRecommenderConfigAsync()} . + * + * @param GetRecommenderConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RecommenderConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRecommenderConfig(GetRecommenderConfigRequest $request, array $callOptions = []): RecommenderConfig + { + return $this->startApiCall('GetRecommenderConfig', $request, $callOptions)->wait(); + } + + /** + * Lists insights for the specified Cloud Resource. Requires the + * recommender.*.list IAM permission for the specified insight type. + * + * The async variant is {@see RecommenderClient::listInsightsAsync()} . + * + * @param ListInsightsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInsights(ListInsightsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInsights', $request, $callOptions); + } + + /** + * Lists recommendations for the specified Cloud Resource. Requires the + * recommender.*.list IAM permission for the specified recommender. + * + * The async variant is {@see RecommenderClient::listRecommendationsAsync()} . + * + * @param ListRecommendationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listRecommendations(ListRecommendationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListRecommendations', $request, $callOptions); + } + + /** + * Marks the Insight State as Accepted. Users can use this method to + * indicate to the Recommender API that they have applied some action based + * on the insight. This stops the insight content from being updated. + * + * MarkInsightAccepted can be applied to insights in ACTIVE state. Requires + * the recommender.*.update IAM permission for the specified insight. + * + * The async variant is {@see RecommenderClient::markInsightAcceptedAsync()} . + * + * @param MarkInsightAcceptedRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Insight + * + * @throws ApiException Thrown if the API call fails. + */ + public function markInsightAccepted(MarkInsightAcceptedRequest $request, array $callOptions = []): Insight + { + return $this->startApiCall('MarkInsightAccepted', $request, $callOptions)->wait(); + } + + /** + * Marks the Recommendation State as Claimed. Users can use this method to + * indicate to the Recommender API that they are starting to apply the + * recommendation themselves. This stops the recommendation content from being + * updated. Associated insights are frozen and placed in the ACCEPTED state. + * + * MarkRecommendationClaimed can be applied to recommendations in CLAIMED, + * SUCCEEDED, FAILED, or ACTIVE state. + * + * Requires the recommender.*.update IAM permission for the specified + * recommender. + * + * The async variant is {@see RecommenderClient::markRecommendationClaimedAsync()} + * . + * + * @param MarkRecommendationClaimedRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Recommendation + * + * @throws ApiException Thrown if the API call fails. + */ + public function markRecommendationClaimed(MarkRecommendationClaimedRequest $request, array $callOptions = []): Recommendation + { + return $this->startApiCall('MarkRecommendationClaimed', $request, $callOptions)->wait(); + } + + /** + * Mark the Recommendation State as Dismissed. Users can use this method to + * indicate to the Recommender API that an ACTIVE recommendation has to + * be marked back as DISMISSED. + * + * MarkRecommendationDismissed can be applied to recommendations in ACTIVE + * state. + * + * Requires the recommender.*.update IAM permission for the specified + * recommender. + * + * The async variant is + * {@see RecommenderClient::markRecommendationDismissedAsync()} . + * + * @param MarkRecommendationDismissedRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Recommendation + * + * @throws ApiException Thrown if the API call fails. + */ + public function markRecommendationDismissed(MarkRecommendationDismissedRequest $request, array $callOptions = []): Recommendation + { + return $this->startApiCall('MarkRecommendationDismissed', $request, $callOptions)->wait(); + } + + /** + * Marks the Recommendation State as Failed. Users can use this method to + * indicate to the Recommender API that they have applied the recommendation + * themselves, and the operation failed. This stops the recommendation content + * from being updated. Associated insights are frozen and placed in the + * ACCEPTED state. + * + * MarkRecommendationFailed can be applied to recommendations in ACTIVE, + * CLAIMED, SUCCEEDED, or FAILED state. + * + * Requires the recommender.*.update IAM permission for the specified + * recommender. + * + * The async variant is {@see RecommenderClient::markRecommendationFailedAsync()} . + * + * @param MarkRecommendationFailedRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Recommendation + * + * @throws ApiException Thrown if the API call fails. + */ + public function markRecommendationFailed(MarkRecommendationFailedRequest $request, array $callOptions = []): Recommendation + { + return $this->startApiCall('MarkRecommendationFailed', $request, $callOptions)->wait(); + } + + /** + * Marks the Recommendation State as Succeeded. Users can use this method to + * indicate to the Recommender API that they have applied the recommendation + * themselves, and the operation was successful. This stops the recommendation + * content from being updated. Associated insights are frozen and placed in + * the ACCEPTED state. + * + * MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, + * CLAIMED, SUCCEEDED, or FAILED state. + * + * Requires the recommender.*.update IAM permission for the specified + * recommender. + * + * The async variant is + * {@see RecommenderClient::markRecommendationSucceededAsync()} . + * + * @param MarkRecommendationSucceededRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Recommendation + * + * @throws ApiException Thrown if the API call fails. + */ + public function markRecommendationSucceeded(MarkRecommendationSucceededRequest $request, array $callOptions = []): Recommendation + { + return $this->startApiCall('MarkRecommendationSucceeded', $request, $callOptions)->wait(); + } + + /** + * Updates an InsightTypeConfig change. This will create a new revision of the + * config. + * + * The async variant is {@see RecommenderClient::updateInsightTypeConfigAsync()} . + * + * @param UpdateInsightTypeConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InsightTypeConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateInsightTypeConfig(UpdateInsightTypeConfigRequest $request, array $callOptions = []): InsightTypeConfig + { + return $this->startApiCall('UpdateInsightTypeConfig', $request, $callOptions)->wait(); + } + + /** + * Updates a Recommender Config. This will create a new revision of the + * config. + * + * The async variant is {@see RecommenderClient::updateRecommenderConfigAsync()} . + * + * @param UpdateRecommenderConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RecommenderConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateRecommenderConfig(UpdateRecommenderConfigRequest $request, array $callOptions = []): RecommenderConfig + { + return $this->startApiCall('UpdateRecommenderConfig', $request, $callOptions)->wait(); + } } diff --git a/Redis/composer.json b/Redis/composer.json index e14b0805cef5..fe34c9057c2c 100644 --- a/Redis/composer.json +++ b/Redis/composer.json @@ -20,11 +20,11 @@ "require": { "php": ">=7.4", "ext-grpc": "*", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", - "google/cloud-core": "^1.39" + "google/cloud-core": "^1.52.7" }, "suggest": { "ext-grpc": "Enables use of gRPC, a universal high-performance RPC framework created by Google." diff --git a/Redis/src/V1/Client/BaseClient/CloudRedisBaseClient.php b/Redis/src/V1/Client/BaseClient/CloudRedisBaseClient.php deleted file mode 100644 index b4a542fa31ac..000000000000 --- a/Redis/src/V1/Client/BaseClient/CloudRedisBaseClient.php +++ /dev/null @@ -1,660 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/cloud_redis_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/cloud_redis_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/cloud_redis_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/cloud_redis_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a instance - * resource. - * - * @param string $project - * @param string $location - * @param string $instance - * - * @return string The formatted instance resource. - */ - public static function instanceName(string $project, string $location, string $instance): string - { - return self::getPathTemplate('instance')->render([ - 'project' => $project, - 'location' => $location, - 'instance' => $instance, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - instance: projects/{project}/locations/{location}/instances/{instance} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'redis.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a Redis instance based on the specified tier and memory size. - * - * By default, the instance is accessible from the project's - * [default network](https://cloud.google.com/vpc/docs/vpc). - * - * The creation is executed asynchronously and callers may check the returned - * operation to track its progress. Once the operation is completed the Redis - * instance will be fully functional. Completed longrunning.Operation will - * contain the new instance object in the response field. - * - * The returned operation is automatically deleted after a few hours, so there - * is no need to call DeleteOperation. - * - * The async variant is {@see self::createInstanceAsync()} . - * - * @param CreateInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createInstance(CreateInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateInstance', $request, $callOptions)->wait(); - } - - /** - * Deletes a specific Redis instance. Instance stops serving and data is - * deleted. - * - * The async variant is {@see self::deleteInstanceAsync()} . - * - * @param DeleteInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); - } - - /** - * Export Redis instance data into a Redis RDB format file in Cloud Storage. - * - * Redis will continue serving during this operation. - * - * The returned operation is automatically deleted after a few hours, so - * there is no need to call DeleteOperation. - * - * The async variant is {@see self::exportInstanceAsync()} . - * - * @param ExportInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function exportInstance(ExportInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ExportInstance', $request, $callOptions)->wait(); - } - - /** - * Initiates a failover of the primary node to current replica node for a - * specific STANDARD tier Cloud Memorystore for Redis instance. - * - * The async variant is {@see self::failoverInstanceAsync()} . - * - * @param FailoverInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function failoverInstance(FailoverInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('FailoverInstance', $request, $callOptions)->wait(); - } - - /** - * Gets the details of a specific Redis instance. - * - * The async variant is {@see self::getInstanceAsync()} . - * - * @param GetInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Instance - * - * @throws ApiException Thrown if the API call fails. - */ - public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance - { - return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); - } - - /** - * Gets the AUTH string for a Redis instance. If AUTH is not enabled for the - * instance the response will be empty. This information is not included in - * the details returned to GetInstance. - * - * The async variant is {@see self::getInstanceAuthStringAsync()} . - * - * @param GetInstanceAuthStringRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InstanceAuthString - * - * @throws ApiException Thrown if the API call fails. - */ - public function getInstanceAuthString(GetInstanceAuthStringRequest $request, array $callOptions = []): InstanceAuthString - { - return $this->startApiCall('GetInstanceAuthString', $request, $callOptions)->wait(); - } - - /** - * Import a Redis RDB snapshot file from Cloud Storage into a Redis instance. - * - * Redis may stop serving during this operation. Instance state will be - * IMPORTING for entire operation. When complete, the instance will contain - * only data from the imported file. - * - * The returned operation is automatically deleted after a few hours, so - * there is no need to call DeleteOperation. - * - * The async variant is {@see self::importInstanceAsync()} . - * - * @param ImportInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function importInstance(ImportInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ImportInstance', $request, $callOptions)->wait(); - } - - /** - * Lists all Redis instances owned by a project in either the specified - * location (region) or all locations. - * - * The location should have the following format: - * - * * `projects/{project_id}/locations/{location_id}` - * - * If `location_id` is specified as `-` (wildcard), then all regions - * available to the project are queried, and the results are aggregated. - * - * The async variant is {@see self::listInstancesAsync()} . - * - * @param ListInstancesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listInstances(ListInstancesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListInstances', $request, $callOptions); - } - - /** - * Reschedule maintenance for a given instance in a given project and - * location. - * - * The async variant is {@see self::rescheduleMaintenanceAsync()} . - * - * @param RescheduleMaintenanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function rescheduleMaintenance(RescheduleMaintenanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RescheduleMaintenance', $request, $callOptions)->wait(); - } - - /** - * Updates the metadata and configuration of a specific Redis instance. - * - * Completed longrunning.Operation will contain the new instance object - * in the response field. The returned operation is automatically deleted - * after a few hours, so there is no need to call DeleteOperation. - * - * The async variant is {@see self::updateInstanceAsync()} . - * - * @param UpdateInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateInstance(UpdateInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateInstance', $request, $callOptions)->wait(); - } - - /** - * Upgrades Redis instance to the newer Redis version specified in the - * request. - * - * The async variant is {@see self::upgradeInstanceAsync()} . - * - * @param UpgradeInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function upgradeInstance(UpgradeInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpgradeInstance', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Redis/src/V1/Client/CloudRedisClient.php b/Redis/src/V1/Client/CloudRedisClient.php index 8dbd718b93b1..3d35c9c198e0 100644 --- a/Redis/src/V1/Client/CloudRedisClient.php +++ b/Redis/src/V1/Client/CloudRedisClient.php @@ -24,17 +24,635 @@ namespace Google\Cloud\Redis\V1\Client; -use Google\Cloud\Redis\V1\Client\BaseClient\CloudRedisBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\Redis\V1\CreateInstanceRequest; +use Google\Cloud\Redis\V1\DeleteInstanceRequest; +use Google\Cloud\Redis\V1\ExportInstanceRequest; +use Google\Cloud\Redis\V1\FailoverInstanceRequest; +use Google\Cloud\Redis\V1\GetInstanceAuthStringRequest; +use Google\Cloud\Redis\V1\GetInstanceRequest; +use Google\Cloud\Redis\V1\ImportInstanceRequest; +use Google\Cloud\Redis\V1\Instance; +use Google\Cloud\Redis\V1\InstanceAuthString; +use Google\Cloud\Redis\V1\ListInstancesRequest; +use Google\Cloud\Redis\V1\RescheduleMaintenanceRequest; +use Google\Cloud\Redis\V1\UpdateInstanceRequest; +use Google\Cloud\Redis\V1\UpgradeInstanceRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Configures and manages Cloud Memorystore for Redis instances * - * This class is currently experimental and may be subject to changes. + * Google Cloud Memorystore for Redis v1 + * + * The `redis.googleapis.com` service implements the Google Cloud Memorystore + * for Redis API and defines the following resource model for managing Redis + * instances: + * * The service works with a collection of cloud projects, named: `/projects/*` + * * Each project has a collection of available locations, named: `/locations/*` + * * Each location has a collection of Redis instances, named: `/instances/*` + * * As such, Redis instances are resources of the form: + * `/projects/{project_id}/locations/{location_id}/instances/{instance_id}` + * + * Note that location_id must be referring to a GCP `region`; for example: + * * `projects/redpepper-1290/locations/us-central1/instances/my-redis` + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Redis\V1\CloudRedisClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createInstanceAsync(CreateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteInstanceAsync(DeleteInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface exportInstanceAsync(ExportInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface failoverInstanceAsync(FailoverInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInstanceAsync(GetInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInstanceAuthStringAsync(GetInstanceAuthStringRequest $request, array $optionalArgs = []) + * @method PromiseInterface importInstanceAsync(ImportInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInstancesAsync(ListInstancesRequest $request, array $optionalArgs = []) + * @method PromiseInterface rescheduleMaintenanceAsync(RescheduleMaintenanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateInstanceAsync(UpdateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface upgradeInstanceAsync(UpgradeInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class CloudRedisClient extends CloudRedisBaseClient +final class CloudRedisClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CloudRedisBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.redis.v1.CloudRedis'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'redis.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/cloud_redis_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/cloud_redis_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/cloud_redis_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/cloud_redis_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a instance + * resource. + * + * @param string $project + * @param string $location + * @param string $instance + * + * @return string The formatted instance resource. + */ + public static function instanceName(string $project, string $location, string $instance): string + { + return self::getPathTemplate('instance')->render([ + 'project' => $project, + 'location' => $location, + 'instance' => $instance, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - instance: projects/{project}/locations/{location}/instances/{instance} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'redis.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a Redis instance based on the specified tier and memory size. + * + * By default, the instance is accessible from the project's + * [default network](https://cloud.google.com/vpc/docs/vpc). + * + * The creation is executed asynchronously and callers may check the returned + * operation to track its progress. Once the operation is completed the Redis + * instance will be fully functional. Completed longrunning.Operation will + * contain the new instance object in the response field. + * + * The returned operation is automatically deleted after a few hours, so there + * is no need to call DeleteOperation. + * + * The async variant is {@see CloudRedisClient::createInstanceAsync()} . + * + * @param CreateInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createInstance(CreateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateInstance', $request, $callOptions)->wait(); + } + + /** + * Deletes a specific Redis instance. Instance stops serving and data is + * deleted. + * + * The async variant is {@see CloudRedisClient::deleteInstanceAsync()} . + * + * @param DeleteInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); + } + + /** + * Export Redis instance data into a Redis RDB format file in Cloud Storage. + * + * Redis will continue serving during this operation. + * + * The returned operation is automatically deleted after a few hours, so + * there is no need to call DeleteOperation. + * + * The async variant is {@see CloudRedisClient::exportInstanceAsync()} . + * + * @param ExportInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function exportInstance(ExportInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ExportInstance', $request, $callOptions)->wait(); + } + + /** + * Initiates a failover of the primary node to current replica node for a + * specific STANDARD tier Cloud Memorystore for Redis instance. + * + * The async variant is {@see CloudRedisClient::failoverInstanceAsync()} . + * + * @param FailoverInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function failoverInstance(FailoverInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('FailoverInstance', $request, $callOptions)->wait(); + } + + /** + * Gets the details of a specific Redis instance. + * + * The async variant is {@see CloudRedisClient::getInstanceAsync()} . + * + * @param GetInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Instance + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance + { + return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); + } + + /** + * Gets the AUTH string for a Redis instance. If AUTH is not enabled for the + * instance the response will be empty. This information is not included in + * the details returned to GetInstance. + * + * The async variant is {@see CloudRedisClient::getInstanceAuthStringAsync()} . + * + * @param GetInstanceAuthStringRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InstanceAuthString + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInstanceAuthString(GetInstanceAuthStringRequest $request, array $callOptions = []): InstanceAuthString + { + return $this->startApiCall('GetInstanceAuthString', $request, $callOptions)->wait(); + } + + /** + * Import a Redis RDB snapshot file from Cloud Storage into a Redis instance. + * + * Redis may stop serving during this operation. Instance state will be + * IMPORTING for entire operation. When complete, the instance will contain + * only data from the imported file. + * + * The returned operation is automatically deleted after a few hours, so + * there is no need to call DeleteOperation. + * + * The async variant is {@see CloudRedisClient::importInstanceAsync()} . + * + * @param ImportInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importInstance(ImportInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportInstance', $request, $callOptions)->wait(); + } + + /** + * Lists all Redis instances owned by a project in either the specified + * location (region) or all locations. + * + * The location should have the following format: + * + * * `projects/{project_id}/locations/{location_id}` + * + * If `location_id` is specified as `-` (wildcard), then all regions + * available to the project are queried, and the results are aggregated. + * + * The async variant is {@see CloudRedisClient::listInstancesAsync()} . + * + * @param ListInstancesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInstances(ListInstancesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInstances', $request, $callOptions); + } + + /** + * Reschedule maintenance for a given instance in a given project and + * location. + * + * The async variant is {@see CloudRedisClient::rescheduleMaintenanceAsync()} . + * + * @param RescheduleMaintenanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function rescheduleMaintenance(RescheduleMaintenanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RescheduleMaintenance', $request, $callOptions)->wait(); + } + + /** + * Updates the metadata and configuration of a specific Redis instance. + * + * Completed longrunning.Operation will contain the new instance object + * in the response field. The returned operation is automatically deleted + * after a few hours, so there is no need to call DeleteOperation. + * + * The async variant is {@see CloudRedisClient::updateInstanceAsync()} . + * + * @param UpdateInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateInstance(UpdateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateInstance', $request, $callOptions)->wait(); + } + + /** + * Upgrades Redis instance to the newer Redis version specified in the + * request. + * + * The async variant is {@see CloudRedisClient::upgradeInstanceAsync()} . + * + * @param UpgradeInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function upgradeInstance(UpgradeInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpgradeInstance', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see CloudRedisClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see CloudRedisClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/ResourceManager/composer.json b/ResourceManager/composer.json index be47aeec18f7..6836144de6fc 100644 --- a/ResourceManager/composer.json +++ b/ResourceManager/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/ResourceManager/src/V3/Client/BaseClient/FoldersBaseClient.php b/ResourceManager/src/V3/Client/BaseClient/FoldersBaseClient.php deleted file mode 100644 index 7428f439c400..000000000000 --- a/ResourceManager/src/V3/Client/BaseClient/FoldersBaseClient.php +++ /dev/null @@ -1,661 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/folders_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/folders_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/folders_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/folders_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a folder - * resource. - * - * @param string $folder - * - * @return string The formatted folder resource. - */ - public static function folderName(string $folder): string - { - return self::getPathTemplate('folder')->render([ - 'folder' => $folder, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - folder: folders/{folder} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudresourcemanager.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a folder in the resource hierarchy. - * Returns an `Operation` which can be used to track the progress of the - * folder creation workflow. - * Upon success, the `Operation.response` field will be populated with the - * created Folder. - * - * In order to succeed, the addition of this new folder must not violate - * the folder naming, height, or fanout constraints. - * - * + The folder's `display_name` must be distinct from all other folders that - * share its parent. - * + The addition of the folder must not cause the active folder hierarchy - * to exceed a height of 10. Note, the full active + deleted folder hierarchy - * is allowed to reach a height of 20; this provides additional headroom when - * moving folders that contain deleted folders. - * + The addition of the folder must not cause the total number of folders - * under its parent to exceed 300. - * - * If the operation fails due to a folder constraint violation, some errors - * may be returned by the `CreateFolder` request, with status code - * `FAILED_PRECONDITION` and an error description. Other folder constraint - * violations will be communicated in the `Operation`, with the specific - * `PreconditionFailure` returned in the details list in the `Operation.error` - * field. - * - * The caller must have `resourcemanager.folders.create` permission on the - * identified parent. - * - * The async variant is {@see self::createFolderAsync()} . - * - * @example samples/V3/FoldersClient/create_folder.php - * - * @param CreateFolderRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createFolder(CreateFolderRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateFolder', $request, $callOptions)->wait(); - } - - /** - * Requests deletion of a folder. The folder is moved into the - * [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] - * state immediately, and is deleted approximately 30 days later. This method - * may only be called on an empty folder, where a folder is empty if it - * doesn't contain any folders or projects in the - * [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. If - * called on a folder in - * [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] - * state the operation will result in a no-op success. - * The caller must have `resourcemanager.folders.delete` permission on the - * identified folder. - * - * The async variant is {@see self::deleteFolderAsync()} . - * - * @example samples/V3/FoldersClient/delete_folder.php - * - * @param DeleteFolderRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteFolder(DeleteFolderRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteFolder', $request, $callOptions)->wait(); - } - - /** - * Retrieves a folder identified by the supplied resource name. - * Valid folder resource names have the format `folders/{folder_id}` - * (for example, `folders/1234`). - * The caller must have `resourcemanager.folders.get` permission on the - * identified folder. - * - * The async variant is {@see self::getFolderAsync()} . - * - * @example samples/V3/FoldersClient/get_folder.php - * - * @param GetFolderRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Folder - * - * @throws ApiException Thrown if the API call fails. - */ - public function getFolder(GetFolderRequest $request, array $callOptions = []): Folder - { - return $this->startApiCall('GetFolder', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a folder. The returned policy may be - * empty if no such policy or resource exists. The `resource` field should - * be the folder's resource name, for example: "folders/1234". - * The caller must have `resourcemanager.folders.getIamPolicy` permission - * on the identified folder. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V3/FoldersClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Lists the folders that are direct descendants of supplied parent resource. - * `list()` provides a strongly consistent view of the folders underneath - * the specified parent resource. - * `list()` returns folders sorted based upon the (ascending) lexical ordering - * of their display_name. - * The caller must have `resourcemanager.folders.list` permission on the - * identified parent. - * - * The async variant is {@see self::listFoldersAsync()} . - * - * @example samples/V3/FoldersClient/list_folders.php - * - * @param ListFoldersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listFolders(ListFoldersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListFolders', $request, $callOptions); - } - - /** - * Moves a folder under a new resource parent. - * Returns an `Operation` which can be used to track the progress of the - * folder move workflow. - * Upon success, the `Operation.response` field will be populated with the - * moved folder. - * Upon failure, a `FolderOperationError` categorizing the failure cause will - * be returned - if the failure occurs synchronously then the - * `FolderOperationError` will be returned in the `Status.details` field. - * If it occurs asynchronously, then the FolderOperation will be returned - * in the `Operation.error` field. - * In addition, the `Operation.metadata` field will be populated with a - * `FolderOperation` message as an aid to stateless clients. - * Folder moves will be rejected if they violate either the naming, height, - * or fanout constraints described in the - * [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] - * documentation. The caller must have `resourcemanager.folders.move` - * permission on the folder's current and proposed new parent. - * - * The async variant is {@see self::moveFolderAsync()} . - * - * @example samples/V3/FoldersClient/move_folder.php - * - * @param MoveFolderRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function moveFolder(MoveFolderRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('MoveFolder', $request, $callOptions)->wait(); - } - - /** - * Search for folders that match specific filter criteria. - * `search()` provides an eventually consistent view of the folders a user has - * access to which meet the specified filter criteria. - * - * This will only return folders on which the caller has the - * permission `resourcemanager.folders.get`. - * - * The async variant is {@see self::searchFoldersAsync()} . - * - * @example samples/V3/FoldersClient/search_folders.php - * - * @param SearchFoldersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchFolders(SearchFoldersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchFolders', $request, $callOptions); - } - - /** - * Sets the access control policy on a folder, replacing any existing policy. - * The `resource` field should be the folder's resource name, for example: - * "folders/1234". - * The caller must have `resourcemanager.folders.setIamPolicy` permission - * on the identified folder. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V3/FoldersClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified folder. - * The `resource` field should be the folder's resource name, - * for example: "folders/1234". - * - * There are no permissions required for making this API call. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V3/FoldersClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Cancels the deletion request for a folder. This method may be called on a - * folder in any state. If the folder is in the - * [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state the - * result will be a no-op success. In order to succeed, the folder's parent - * must be in the - * [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. In - * addition, reintroducing the folder into the tree must not violate folder - * naming, height, and fanout constraints described in the - * [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] - * documentation. The caller must have `resourcemanager.folders.undelete` - * permission on the identified folder. - * - * The async variant is {@see self::undeleteFolderAsync()} . - * - * @example samples/V3/FoldersClient/undelete_folder.php - * - * @param UndeleteFolderRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function undeleteFolder(UndeleteFolderRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UndeleteFolder', $request, $callOptions)->wait(); - } - - /** - * Updates a folder, changing its `display_name`. - * Changes to the folder `display_name` will be rejected if they violate - * either the `display_name` formatting rules or the naming constraints - * described in the - * [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] - * documentation. - * - * The folder's `display_name` must start and end with a letter or digit, - * may contain letters, digits, spaces, hyphens and underscores and can be - * between 3 and 30 characters. This is captured by the regular expression: - * `[\p{L}\p{N}][\p{L}\p{N}_- ]{1,28}[\p{L}\p{N}]`. - * The caller must have `resourcemanager.folders.update` permission on the - * identified folder. - * - * If the update fails due to the unique name constraint then a - * `PreconditionFailure` explaining this violation will be returned - * in the Status.details field. - * - * The async variant is {@see self::updateFolderAsync()} . - * - * @example samples/V3/FoldersClient/update_folder.php - * - * @param UpdateFolderRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateFolder(UpdateFolderRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateFolder', $request, $callOptions)->wait(); - } -} diff --git a/ResourceManager/src/V3/Client/BaseClient/OrganizationsBaseClient.php b/ResourceManager/src/V3/Client/BaseClient/OrganizationsBaseClient.php deleted file mode 100644 index 7594c6d76273..000000000000 --- a/ResourceManager/src/V3/Client/BaseClient/OrganizationsBaseClient.php +++ /dev/null @@ -1,372 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/organizations_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/organizations_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/organizations_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/organizations_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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(string $organization): string - { - return self::getPathTemplate('organization')->render([ - 'organization' => $organization, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - organization: organizations/{organization} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudresourcemanager.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Gets the access control policy for an organization resource. The policy may - * be empty if no such policy or resource exists. The `resource` field should - * be the organization's resource name, for example: "organizations/123". - * - * Authorization requires the IAM permission - * `resourcemanager.organizations.getIamPolicy` on the specified organization. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V3/OrganizationsClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Fetches an organization resource identified by the specified resource name. - * - * The async variant is {@see self::getOrganizationAsync()} . - * - * @example samples/V3/OrganizationsClient/get_organization.php - * - * @param GetOrganizationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Organization - * - * @throws ApiException Thrown if the API call fails. - */ - public function getOrganization(GetOrganizationRequest $request, array $callOptions = []): Organization - { - return $this->startApiCall('GetOrganization', $request, $callOptions)->wait(); - } - - /** - * Searches organization resources that are visible to the user and satisfy - * the specified filter. This method returns organizations in an unspecified - * order. New organizations do not necessarily appear at the end of the - * results, and may take a small amount of time to appear. - * - * Search will only return organizations on which the user has the permission - * `resourcemanager.organizations.get` - * - * The async variant is {@see self::searchOrganizationsAsync()} . - * - * @example samples/V3/OrganizationsClient/search_organizations.php - * - * @param SearchOrganizationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchOrganizations(SearchOrganizationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchOrganizations', $request, $callOptions); - } - - /** - * Sets the access control policy on an organization resource. Replaces any - * existing policy. The `resource` field should be the organization's resource - * name, for example: "organizations/123". - * - * Authorization requires the IAM permission - * `resourcemanager.organizations.setIamPolicy` on the specified organization. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V3/OrganizationsClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns the permissions that a caller has on the specified organization. - * The `resource` field should be the organization's resource name, - * for example: "organizations/123". - * - * There are no permissions required for making this API call. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V3/OrganizationsClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/ResourceManager/src/V3/Client/BaseClient/ProjectsBaseClient.php b/ResourceManager/src/V3/Client/BaseClient/ProjectsBaseClient.php deleted file mode 100644 index f2eb7d10f712..000000000000 --- a/ResourceManager/src/V3/Client/BaseClient/ProjectsBaseClient.php +++ /dev/null @@ -1,679 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/projects_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/projects_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/projects_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/projects_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->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. - */ - public static function parseName(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudresourcemanager.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Request that a new project be created. The result is an `Operation` which - * can be used to track the creation process. This process usually takes a few - * seconds, but can sometimes take much longer. The tracking `Operation` is - * automatically deleted after a few hours, so there is no need to call - * `DeleteOperation`. - * - * The async variant is {@see self::createProjectAsync()} . - * - * @example samples/V3/ProjectsClient/create_project.php - * - * @param CreateProjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createProject(CreateProjectRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateProject', $request, $callOptions)->wait(); - } - - /** - * Marks the project identified by the specified - * `name` (for example, `projects/415104041262`) for deletion. - * - * This method will only affect the project if it has a lifecycle state of - * [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE]. - * - * This method changes the Project's lifecycle state from - * [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE] - * to - * [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Project.State.DELETE_REQUESTED]. - * The deletion starts at an unspecified time, - * at which point the Project is no longer accessible. - * - * Until the deletion completes, you can check the lifecycle state - * checked by retrieving the project with [GetProject] - * [google.cloud.resourcemanager.v3.Projects.GetProject], - * and the project remains visible to [ListProjects] - * [google.cloud.resourcemanager.v3.Projects.ListProjects]. - * However, you cannot update the project. - * - * After the deletion completes, the project is not retrievable by - * the [GetProject] - * [google.cloud.resourcemanager.v3.Projects.GetProject], - * [ListProjects] - * [google.cloud.resourcemanager.v3.Projects.ListProjects], and - * [SearchProjects][google.cloud.resourcemanager.v3.Projects.SearchProjects] - * methods. - * - * This method behaves idempotently, such that deleting a `DELETE_REQUESTED` - * project will not cause an error, but also won't do anything. - * - * The caller must have `resourcemanager.projects.delete` permissions for this - * project. - * - * The async variant is {@see self::deleteProjectAsync()} . - * - * @example samples/V3/ProjectsClient/delete_project.php - * - * @param DeleteProjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteProject(DeleteProjectRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteProject', $request, $callOptions)->wait(); - } - - /** - * Returns the IAM access control policy for the specified project, in the - * format `projects/{ProjectIdOrNumber}` e.g. projects/123. - * Permission is denied if the policy or the resource do not exist. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V3/ProjectsClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Retrieves the project identified by the specified `name` (for example, - * `projects/415104041262`). - * - * The caller must have `resourcemanager.projects.get` permission - * for this project. - * - * The async variant is {@see self::getProjectAsync()} . - * - * @example samples/V3/ProjectsClient/get_project.php - * - * @param GetProjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Project - * - * @throws ApiException Thrown if the API call fails. - */ - public function getProject(GetProjectRequest $request, array $callOptions = []): Project - { - return $this->startApiCall('GetProject', $request, $callOptions)->wait(); - } - - /** - * Lists projects that are direct children of the specified folder or - * organization resource. `list()` provides a strongly consistent view of the - * projects underneath the specified parent resource. `list()` returns - * projects sorted based upon the (ascending) lexical ordering of their - * `display_name`. The caller must have `resourcemanager.projects.list` - * permission on the identified parent. - * - * The async variant is {@see self::listProjectsAsync()} . - * - * @example samples/V3/ProjectsClient/list_projects.php - * - * @param ListProjectsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listProjects(ListProjectsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListProjects', $request, $callOptions); - } - - /** - * Move a project to another place in your resource hierarchy, under a new - * resource parent. - * - * Returns an operation which can be used to track the process of the project - * move workflow. - * Upon success, the `Operation.response` field will be populated with the - * moved project. - * - * The caller must have `resourcemanager.projects.move` permission on the - * project, on the project's current and proposed new parent. - * - * If project has no current parent, or it currently does not have an - * associated organization resource, you will also need the - * `resourcemanager.projects.setIamPolicy` permission in the project. - * - * - * - * The async variant is {@see self::moveProjectAsync()} . - * - * @example samples/V3/ProjectsClient/move_project.php - * - * @param MoveProjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function moveProject(MoveProjectRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('MoveProject', $request, $callOptions)->wait(); - } - - /** - * Search for projects that the caller has both `resourcemanager.projects.get` - * permission on, and also satisfy the specified query. - * - * This method returns projects in an unspecified order. - * - * This method is eventually consistent with project mutations; this means - * that a newly created project may not appear in the results or recent - * updates to an existing project may not be reflected in the results. To - * retrieve the latest state of a project, use the - * [GetProject][google.cloud.resourcemanager.v3.Projects.GetProject] method. - * - * The async variant is {@see self::searchProjectsAsync()} . - * - * @example samples/V3/ProjectsClient/search_projects.php - * - * @param SearchProjectsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchProjects(SearchProjectsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchProjects', $request, $callOptions); - } - - /** - * Sets the IAM access control policy for the specified project, in the - * format `projects/{ProjectIdOrNumber}` e.g. projects/123. - * - * CAUTION: This method will replace the existing policy, and cannot be used - * to append additional IAM settings. - * - * Note: Removing service accounts from policies or changing their roles can - * render services completely inoperable. It is important to understand how - * the service account is being used before removing or updating its roles. - * - * The following constraints apply when using `setIamPolicy()`: - * - * + Project does not support `allUsers` and `allAuthenticatedUsers` as - * `members` in a `Binding` of a `Policy`. - * - * + The owner role can be granted to a `user`, `serviceAccount`, or a group - * that is part of an organization. For example, - * group@myownpersonaldomain.com could be added as an owner to a project in - * the myownpersonaldomain.com organization, but not the examplepetstore.com - * organization. - * - * + Service accounts can be made owners of a project directly - * without any restrictions. However, to be added as an owner, a user must be - * invited using the Cloud Platform console and must accept the invitation. - * - * + A user cannot be granted the owner role using `setIamPolicy()`. The user - * must be granted the owner role using the Cloud Platform Console and must - * explicitly accept the invitation. - * - * + Invitations to grant the owner role cannot be sent using - * `setIamPolicy()`; - * they must be sent only using the Cloud Platform Console. - * - * + If the project is not part of an organization, there must be at least - * one owner who has accepted the Terms of Service (ToS) agreement in the - * policy. Calling `setIamPolicy()` to remove the last ToS-accepted owner - * from the policy will fail. This restriction also applies to legacy - * projects that no longer have owners who have accepted the ToS. Edits to - * IAM policies will be rejected until the lack of a ToS-accepting owner is - * rectified. If the project is part of an organization, you can remove all - * owners, potentially making the organization inaccessible. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V3/ProjectsClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified project, in the - * format `projects/{ProjectIdOrNumber}` e.g. projects/123.. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V3/ProjectsClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Restores the project identified by the specified - * `name` (for example, `projects/415104041262`). - * You can only use this method for a project that has a lifecycle state of - * [DELETE_REQUESTED] - * [Projects.State.DELETE_REQUESTED]. - * After deletion starts, the project cannot be restored. - * - * The caller must have `resourcemanager.projects.undelete` permission for - * this project. - * - * The async variant is {@see self::undeleteProjectAsync()} . - * - * @example samples/V3/ProjectsClient/undelete_project.php - * - * @param UndeleteProjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function undeleteProject(UndeleteProjectRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UndeleteProject', $request, $callOptions)->wait(); - } - - /** - * Updates the `display_name` and labels of the project identified by the - * specified `name` (for example, `projects/415104041262`). Deleting all - * labels requires an update mask for labels field. - * - * The caller must have `resourcemanager.projects.update` permission for this - * project. - * - * The async variant is {@see self::updateProjectAsync()} . - * - * @example samples/V3/ProjectsClient/update_project.php - * - * @param UpdateProjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateProject(UpdateProjectRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateProject', $request, $callOptions)->wait(); - } -} diff --git a/ResourceManager/src/V3/Client/BaseClient/TagBindingsBaseClient.php b/ResourceManager/src/V3/Client/BaseClient/TagBindingsBaseClient.php deleted file mode 100644 index 21e8ac4f825e..000000000000 --- a/ResourceManager/src/V3/Client/BaseClient/TagBindingsBaseClient.php +++ /dev/null @@ -1,363 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/tag_bindings_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/tag_bindings_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/tag_bindings_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/tag_bindings_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a tag_binding - * resource. - * - * @param string $tagBinding - * - * @return string The formatted tag_binding resource. - */ - public static function tagBindingName(string $tagBinding): string - { - return self::getPathTemplate('tagBinding')->render([ - 'tag_binding' => $tagBinding, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - tagBinding: tagBindings/{tag_binding} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudresourcemanager.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a TagBinding between a TagValue and a Google Cloud resource. - * - * The async variant is {@see self::createTagBindingAsync()} . - * - * @example samples/V3/TagBindingsClient/create_tag_binding.php - * - * @param CreateTagBindingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTagBinding(CreateTagBindingRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateTagBinding', $request, $callOptions)->wait(); - } - - /** - * Deletes a TagBinding. - * - * The async variant is {@see self::deleteTagBindingAsync()} . - * - * @example samples/V3/TagBindingsClient/delete_tag_binding.php - * - * @param DeleteTagBindingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTagBinding(DeleteTagBindingRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteTagBinding', $request, $callOptions)->wait(); - } - - /** - * Return a list of effective tags for the given Google Cloud resource, as - * specified in `parent`. - * - * The async variant is {@see self::listEffectiveTagsAsync()} . - * - * @example samples/V3/TagBindingsClient/list_effective_tags.php - * - * @param ListEffectiveTagsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listEffectiveTags(ListEffectiveTagsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListEffectiveTags', $request, $callOptions); - } - - /** - * Lists the TagBindings for the given Google Cloud resource, as specified - * with `parent`. - * - * NOTE: The `parent` field is expected to be a full resource name: - * https://cloud.google.com/apis/design/resource_names#full_resource_name - * - * The async variant is {@see self::listTagBindingsAsync()} . - * - * @example samples/V3/TagBindingsClient/list_tag_bindings.php - * - * @param ListTagBindingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTagBindings(ListTagBindingsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTagBindings', $request, $callOptions); - } -} diff --git a/ResourceManager/src/V3/Client/BaseClient/TagHoldsBaseClient.php b/ResourceManager/src/V3/Client/BaseClient/TagHoldsBaseClient.php deleted file mode 100644 index df571c324498..000000000000 --- a/ResourceManager/src/V3/Client/BaseClient/TagHoldsBaseClient.php +++ /dev/null @@ -1,351 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/tag_holds_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/tag_holds_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/tag_holds_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/tag_holds_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a tag_hold - * resource. - * - * @param string $tagValue - * @param string $tagHold - * - * @return string The formatted tag_hold resource. - */ - public static function tagHoldName(string $tagValue, string $tagHold): string - { - return self::getPathTemplate('tagHold')->render([ - 'tag_value' => $tagValue, - 'tag_hold' => $tagHold, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a tag_value - * resource. - * - * @param string $tagValue - * - * @return string The formatted tag_value resource. - */ - public static function tagValueName(string $tagValue): string - { - return self::getPathTemplate('tagValue')->render([ - 'tag_value' => $tagValue, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - tagHold: tagValues/{tag_value}/tagHolds/{tag_hold} - * - tagValue: tagValues/{tag_value} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudresourcemanager.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a TagHold. Returns ALREADY_EXISTS if a TagHold with the same - * resource and origin exists under the same TagValue. - * - * The async variant is {@see self::createTagHoldAsync()} . - * - * @example samples/V3/TagHoldsClient/create_tag_hold.php - * - * @param CreateTagHoldRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTagHold(CreateTagHoldRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateTagHold', $request, $callOptions)->wait(); - } - - /** - * Deletes a TagHold. - * - * The async variant is {@see self::deleteTagHoldAsync()} . - * - * @example samples/V3/TagHoldsClient/delete_tag_hold.php - * - * @param DeleteTagHoldRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTagHold(DeleteTagHoldRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteTagHold', $request, $callOptions)->wait(); - } - - /** - * Lists TagHolds under a TagValue. - * - * The async variant is {@see self::listTagHoldsAsync()} . - * - * @example samples/V3/TagHoldsClient/list_tag_holds.php - * - * @param ListTagHoldsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTagHolds(ListTagHoldsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTagHolds', $request, $callOptions); - } -} diff --git a/ResourceManager/src/V3/Client/BaseClient/TagKeysBaseClient.php b/ResourceManager/src/V3/Client/BaseClient/TagKeysBaseClient.php deleted file mode 100644 index d626811d55a2..000000000000 --- a/ResourceManager/src/V3/Client/BaseClient/TagKeysBaseClient.php +++ /dev/null @@ -1,518 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/tag_keys_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/tag_keys_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/tag_keys_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/tag_keys_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a tag_key - * resource. - * - * @param string $tagKey - * - * @return string The formatted tag_key resource. - */ - public static function tagKeyName(string $tagKey): string - { - return self::getPathTemplate('tagKey')->render([ - 'tag_key' => $tagKey, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - tagKey: tagKeys/{tag_key} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudresourcemanager.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new TagKey. If another request with the same parameters is - * sent while the original request is in process, the second request - * will receive an error. A maximum of 1000 TagKeys can exist under a parent - * at any given time. - * - * The async variant is {@see self::createTagKeyAsync()} . - * - * @example samples/V3/TagKeysClient/create_tag_key.php - * - * @param CreateTagKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTagKey(CreateTagKeyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateTagKey', $request, $callOptions)->wait(); - } - - /** - * Deletes a TagKey. The TagKey cannot be deleted if it has any child - * TagValues. - * - * The async variant is {@see self::deleteTagKeyAsync()} . - * - * @example samples/V3/TagKeysClient/delete_tag_key.php - * - * @param DeleteTagKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTagKey(DeleteTagKeyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteTagKey', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a TagKey. The returned policy may be - * empty if no such policy or resource exists. The `resource` field should - * be the TagKey's resource name. For example, "tagKeys/1234". - * The caller must have - * `cloudresourcemanager.googleapis.com/tagKeys.getIamPolicy` permission on - * the specified TagKey. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V3/TagKeysClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Retrieves a TagKey by its namespaced name. - * This method will return `PERMISSION_DENIED` if the key does not exist - * or the user does not have permission to view it. - * - * The async variant is {@see self::getNamespacedTagKeyAsync()} . - * - * @example samples/V3/TagKeysClient/get_namespaced_tag_key.php - * - * @param GetNamespacedTagKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TagKey - * - * @throws ApiException Thrown if the API call fails. - */ - public function getNamespacedTagKey(GetNamespacedTagKeyRequest $request, array $callOptions = []): TagKey - { - return $this->startApiCall('GetNamespacedTagKey', $request, $callOptions)->wait(); - } - - /** - * Retrieves a TagKey. This method will return `PERMISSION_DENIED` if the - * key does not exist or the user does not have permission to view it. - * - * The async variant is {@see self::getTagKeyAsync()} . - * - * @example samples/V3/TagKeysClient/get_tag_key.php - * - * @param GetTagKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TagKey - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTagKey(GetTagKeyRequest $request, array $callOptions = []): TagKey - { - return $this->startApiCall('GetTagKey', $request, $callOptions)->wait(); - } - - /** - * Lists all TagKeys for a parent resource. - * - * The async variant is {@see self::listTagKeysAsync()} . - * - * @example samples/V3/TagKeysClient/list_tag_keys.php - * - * @param ListTagKeysRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTagKeys(ListTagKeysRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTagKeys', $request, $callOptions); - } - - /** - * Sets the access control policy on a TagKey, replacing any existing - * policy. The `resource` field should be the TagKey's resource name. - * For example, "tagKeys/1234". - * The caller must have `resourcemanager.tagKeys.setIamPolicy` permission - * on the identified tagValue. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V3/TagKeysClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified TagKey. - * The `resource` field should be the TagKey's resource name. - * For example, "tagKeys/1234". - * - * There are no permissions required for making this API call. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V3/TagKeysClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Updates the attributes of the TagKey resource. - * - * The async variant is {@see self::updateTagKeyAsync()} . - * - * @example samples/V3/TagKeysClient/update_tag_key.php - * - * @param UpdateTagKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateTagKey(UpdateTagKeyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateTagKey', $request, $callOptions)->wait(); - } -} diff --git a/ResourceManager/src/V3/Client/BaseClient/TagValuesBaseClient.php b/ResourceManager/src/V3/Client/BaseClient/TagValuesBaseClient.php deleted file mode 100644 index c6f3939e2248..000000000000 --- a/ResourceManager/src/V3/Client/BaseClient/TagValuesBaseClient.php +++ /dev/null @@ -1,518 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/tag_values_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/tag_values_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/tag_values_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/tag_values_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a tag_value - * resource. - * - * @param string $tagValue - * - * @return string The formatted tag_value resource. - */ - public static function tagValueName(string $tagValue): string - { - return self::getPathTemplate('tagValue')->render([ - 'tag_value' => $tagValue, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - tagValue: tagValues/{tag_value} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudresourcemanager.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a TagValue as a child of the specified TagKey. If a another - * request with the same parameters is sent while the original request is in - * process the second request will receive an error. A maximum of 1000 - * TagValues can exist under a TagKey at any given time. - * - * The async variant is {@see self::createTagValueAsync()} . - * - * @example samples/V3/TagValuesClient/create_tag_value.php - * - * @param CreateTagValueRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTagValue(CreateTagValueRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateTagValue', $request, $callOptions)->wait(); - } - - /** - * Deletes a TagValue. The TagValue cannot have any bindings when it is - * deleted. - * - * The async variant is {@see self::deleteTagValueAsync()} . - * - * @example samples/V3/TagValuesClient/delete_tag_value.php - * - * @param DeleteTagValueRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTagValue(DeleteTagValueRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteTagValue', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a TagValue. The returned policy may be - * empty if no such policy or resource exists. The `resource` field should - * be the TagValue's resource name. For example: `tagValues/1234`. - * The caller must have the - * `cloudresourcemanager.googleapis.com/tagValues.getIamPolicy` permission on - * the identified TagValue to get the access control policy. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V3/TagValuesClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Retrieves a TagValue by its namespaced name. - * This method will return `PERMISSION_DENIED` if the value does not exist - * or the user does not have permission to view it. - * - * The async variant is {@see self::getNamespacedTagValueAsync()} . - * - * @example samples/V3/TagValuesClient/get_namespaced_tag_value.php - * - * @param GetNamespacedTagValueRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TagValue - * - * @throws ApiException Thrown if the API call fails. - */ - public function getNamespacedTagValue(GetNamespacedTagValueRequest $request, array $callOptions = []): TagValue - { - return $this->startApiCall('GetNamespacedTagValue', $request, $callOptions)->wait(); - } - - /** - * Retrieves a TagValue. This method will return `PERMISSION_DENIED` if the - * value does not exist or the user does not have permission to view it. - * - * The async variant is {@see self::getTagValueAsync()} . - * - * @example samples/V3/TagValuesClient/get_tag_value.php - * - * @param GetTagValueRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TagValue - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTagValue(GetTagValueRequest $request, array $callOptions = []): TagValue - { - return $this->startApiCall('GetTagValue', $request, $callOptions)->wait(); - } - - /** - * Lists all TagValues for a specific TagKey. - * - * The async variant is {@see self::listTagValuesAsync()} . - * - * @example samples/V3/TagValuesClient/list_tag_values.php - * - * @param ListTagValuesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTagValues(ListTagValuesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTagValues', $request, $callOptions); - } - - /** - * Sets the access control policy on a TagValue, replacing any existing - * policy. The `resource` field should be the TagValue's resource name. - * For example: `tagValues/1234`. - * The caller must have `resourcemanager.tagValues.setIamPolicy` permission - * on the identified tagValue. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V3/TagValuesClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified TagValue. - * The `resource` field should be the TagValue's resource name. For example: - * `tagValues/1234`. - * - * There are no permissions required for making this API call. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V3/TagValuesClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Updates the attributes of the TagValue resource. - * - * The async variant is {@see self::updateTagValueAsync()} . - * - * @example samples/V3/TagValuesClient/update_tag_value.php - * - * @param UpdateTagValueRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateTagValue(UpdateTagValueRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateTagValue', $request, $callOptions)->wait(); - } -} diff --git a/ResourceManager/src/V3/Client/FoldersClient.php b/ResourceManager/src/V3/Client/FoldersClient.php index 344306bac158..4ebcb704ee4e 100644 --- a/ResourceManager/src/V3/Client/FoldersClient.php +++ b/ResourceManager/src/V3/Client/FoldersClient.php @@ -24,17 +24,636 @@ namespace Google\Cloud\ResourceManager\V3\Client; -use Google\Cloud\ResourceManager\V3\Client\BaseClient\FoldersBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\ResourceManager\V3\CreateFolderRequest; +use Google\Cloud\ResourceManager\V3\DeleteFolderRequest; +use Google\Cloud\ResourceManager\V3\Folder; +use Google\Cloud\ResourceManager\V3\GetFolderRequest; +use Google\Cloud\ResourceManager\V3\ListFoldersRequest; +use Google\Cloud\ResourceManager\V3\MoveFolderRequest; +use Google\Cloud\ResourceManager\V3\SearchFoldersRequest; +use Google\Cloud\ResourceManager\V3\UndeleteFolderRequest; +use Google\Cloud\ResourceManager\V3\UpdateFolderRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Manages Cloud Platform folder resources. + * Folders can be used to organize the resources under an + * organization and to control the policies applied to groups of resources. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ResourceManager\V3\FoldersClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createFolderAsync(CreateFolderRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteFolderAsync(DeleteFolderRequest $request, array $optionalArgs = []) + * @method PromiseInterface getFolderAsync(GetFolderRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listFoldersAsync(ListFoldersRequest $request, array $optionalArgs = []) + * @method PromiseInterface moveFolderAsync(MoveFolderRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchFoldersAsync(SearchFoldersRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface undeleteFolderAsync(UndeleteFolderRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateFolderAsync(UpdateFolderRequest $request, array $optionalArgs = []) */ -final class FoldersClient extends FoldersBaseClient +final class FoldersClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see FoldersBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.resourcemanager.v3.Folders'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudresourcemanager.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/folders_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/folders_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/folders_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/folders_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a folder + * resource. + * + * @param string $folder + * + * @return string The formatted folder resource. + */ + public static function folderName(string $folder): string + { + return self::getPathTemplate('folder')->render([ + 'folder' => $folder, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - folder: folders/{folder} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudresourcemanager.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a folder in the resource hierarchy. + * Returns an `Operation` which can be used to track the progress of the + * folder creation workflow. + * Upon success, the `Operation.response` field will be populated with the + * created Folder. + * + * In order to succeed, the addition of this new folder must not violate + * the folder naming, height, or fanout constraints. + * + * + The folder's `display_name` must be distinct from all other folders that + * share its parent. + * + The addition of the folder must not cause the active folder hierarchy + * to exceed a height of 10. Note, the full active + deleted folder hierarchy + * is allowed to reach a height of 20; this provides additional headroom when + * moving folders that contain deleted folders. + * + The addition of the folder must not cause the total number of folders + * under its parent to exceed 300. + * + * If the operation fails due to a folder constraint violation, some errors + * may be returned by the `CreateFolder` request, with status code + * `FAILED_PRECONDITION` and an error description. Other folder constraint + * violations will be communicated in the `Operation`, with the specific + * `PreconditionFailure` returned in the details list in the `Operation.error` + * field. + * + * The caller must have `resourcemanager.folders.create` permission on the + * identified parent. + * + * The async variant is {@see FoldersClient::createFolderAsync()} . + * + * @example samples/V3/FoldersClient/create_folder.php + * + * @param CreateFolderRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createFolder(CreateFolderRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateFolder', $request, $callOptions)->wait(); + } + + /** + * Requests deletion of a folder. The folder is moved into the + * [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] + * state immediately, and is deleted approximately 30 days later. This method + * may only be called on an empty folder, where a folder is empty if it + * doesn't contain any folders or projects in the + * [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. If + * called on a folder in + * [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] + * state the operation will result in a no-op success. + * The caller must have `resourcemanager.folders.delete` permission on the + * identified folder. + * + * The async variant is {@see FoldersClient::deleteFolderAsync()} . + * + * @example samples/V3/FoldersClient/delete_folder.php + * + * @param DeleteFolderRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteFolder(DeleteFolderRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteFolder', $request, $callOptions)->wait(); + } + + /** + * Retrieves a folder identified by the supplied resource name. + * Valid folder resource names have the format `folders/{folder_id}` + * (for example, `folders/1234`). + * The caller must have `resourcemanager.folders.get` permission on the + * identified folder. + * + * The async variant is {@see FoldersClient::getFolderAsync()} . + * + * @example samples/V3/FoldersClient/get_folder.php + * + * @param GetFolderRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Folder + * + * @throws ApiException Thrown if the API call fails. + */ + public function getFolder(GetFolderRequest $request, array $callOptions = []): Folder + { + return $this->startApiCall('GetFolder', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a folder. The returned policy may be + * empty if no such policy or resource exists. The `resource` field should + * be the folder's resource name, for example: "folders/1234". + * The caller must have `resourcemanager.folders.getIamPolicy` permission + * on the identified folder. + * + * The async variant is {@see FoldersClient::getIamPolicyAsync()} . + * + * @example samples/V3/FoldersClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Lists the folders that are direct descendants of supplied parent resource. + * `list()` provides a strongly consistent view of the folders underneath + * the specified parent resource. + * `list()` returns folders sorted based upon the (ascending) lexical ordering + * of their display_name. + * The caller must have `resourcemanager.folders.list` permission on the + * identified parent. + * + * The async variant is {@see FoldersClient::listFoldersAsync()} . + * + * @example samples/V3/FoldersClient/list_folders.php + * + * @param ListFoldersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listFolders(ListFoldersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListFolders', $request, $callOptions); + } + + /** + * Moves a folder under a new resource parent. + * Returns an `Operation` which can be used to track the progress of the + * folder move workflow. + * Upon success, the `Operation.response` field will be populated with the + * moved folder. + * Upon failure, a `FolderOperationError` categorizing the failure cause will + * be returned - if the failure occurs synchronously then the + * `FolderOperationError` will be returned in the `Status.details` field. + * If it occurs asynchronously, then the FolderOperation will be returned + * in the `Operation.error` field. + * In addition, the `Operation.metadata` field will be populated with a + * `FolderOperation` message as an aid to stateless clients. + * Folder moves will be rejected if they violate either the naming, height, + * or fanout constraints described in the + * [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] + * documentation. The caller must have `resourcemanager.folders.move` + * permission on the folder's current and proposed new parent. + * + * The async variant is {@see FoldersClient::moveFolderAsync()} . + * + * @example samples/V3/FoldersClient/move_folder.php + * + * @param MoveFolderRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function moveFolder(MoveFolderRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('MoveFolder', $request, $callOptions)->wait(); + } + + /** + * Search for folders that match specific filter criteria. + * `search()` provides an eventually consistent view of the folders a user has + * access to which meet the specified filter criteria. + * + * This will only return folders on which the caller has the + * permission `resourcemanager.folders.get`. + * + * The async variant is {@see FoldersClient::searchFoldersAsync()} . + * + * @example samples/V3/FoldersClient/search_folders.php + * + * @param SearchFoldersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchFolders(SearchFoldersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchFolders', $request, $callOptions); + } + + /** + * Sets the access control policy on a folder, replacing any existing policy. + * The `resource` field should be the folder's resource name, for example: + * "folders/1234". + * The caller must have `resourcemanager.folders.setIamPolicy` permission + * on the identified folder. + * + * The async variant is {@see FoldersClient::setIamPolicyAsync()} . + * + * @example samples/V3/FoldersClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified folder. + * The `resource` field should be the folder's resource name, + * for example: "folders/1234". + * + * There are no permissions required for making this API call. + * + * The async variant is {@see FoldersClient::testIamPermissionsAsync()} . + * + * @example samples/V3/FoldersClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Cancels the deletion request for a folder. This method may be called on a + * folder in any state. If the folder is in the + * [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state the + * result will be a no-op success. In order to succeed, the folder's parent + * must be in the + * [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. In + * addition, reintroducing the folder into the tree must not violate folder + * naming, height, and fanout constraints described in the + * [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] + * documentation. The caller must have `resourcemanager.folders.undelete` + * permission on the identified folder. + * + * The async variant is {@see FoldersClient::undeleteFolderAsync()} . + * + * @example samples/V3/FoldersClient/undelete_folder.php + * + * @param UndeleteFolderRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function undeleteFolder(UndeleteFolderRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UndeleteFolder', $request, $callOptions)->wait(); + } + + /** + * Updates a folder, changing its `display_name`. + * Changes to the folder `display_name` will be rejected if they violate + * either the `display_name` formatting rules or the naming constraints + * described in the + * [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] + * documentation. + * + * The folder's `display_name` must start and end with a letter or digit, + * may contain letters, digits, spaces, hyphens and underscores and can be + * between 3 and 30 characters. This is captured by the regular expression: + * `[\p{L}\p{N}][\p{L}\p{N}_- ]{1,28}[\p{L}\p{N}]`. + * The caller must have `resourcemanager.folders.update` permission on the + * identified folder. + * + * If the update fails due to the unique name constraint then a + * `PreconditionFailure` explaining this violation will be returned + * in the Status.details field. + * + * The async variant is {@see FoldersClient::updateFolderAsync()} . + * + * @example samples/V3/FoldersClient/update_folder.php + * + * @param UpdateFolderRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateFolder(UpdateFolderRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateFolder', $request, $callOptions)->wait(); + } } diff --git a/ResourceManager/src/V3/Client/OrganizationsClient.php b/ResourceManager/src/V3/Client/OrganizationsClient.php index 53fadf1ecc15..9832dee74c99 100644 --- a/ResourceManager/src/V3/Client/OrganizationsClient.php +++ b/ResourceManager/src/V3/Client/OrganizationsClient.php @@ -24,17 +24,347 @@ namespace Google\Cloud\ResourceManager\V3\Client; -use Google\Cloud\ResourceManager\V3\Client\BaseClient\OrganizationsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\ResourceManager\V3\GetOrganizationRequest; +use Google\Cloud\ResourceManager\V3\Organization; +use Google\Cloud\ResourceManager\V3\SearchOrganizationsRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Allows users to manage their organization resources. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ResourceManager\V3\OrganizationsClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getOrganizationAsync(GetOrganizationRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchOrganizationsAsync(SearchOrganizationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class OrganizationsClient extends OrganizationsBaseClient +final class OrganizationsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see OrganizationsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.resourcemanager.v3.Organizations'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudresourcemanager.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/organizations_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/organizations_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/organizations_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/organizations_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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(string $organization): string + { + return self::getPathTemplate('organization')->render([ + 'organization' => $organization, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - organization: organizations/{organization} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudresourcemanager.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Gets the access control policy for an organization resource. The policy may + * be empty if no such policy or resource exists. The `resource` field should + * be the organization's resource name, for example: "organizations/123". + * + * Authorization requires the IAM permission + * `resourcemanager.organizations.getIamPolicy` on the specified organization. + * + * The async variant is {@see OrganizationsClient::getIamPolicyAsync()} . + * + * @example samples/V3/OrganizationsClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Fetches an organization resource identified by the specified resource name. + * + * The async variant is {@see OrganizationsClient::getOrganizationAsync()} . + * + * @example samples/V3/OrganizationsClient/get_organization.php + * + * @param GetOrganizationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Organization + * + * @throws ApiException Thrown if the API call fails. + */ + public function getOrganization(GetOrganizationRequest $request, array $callOptions = []): Organization + { + return $this->startApiCall('GetOrganization', $request, $callOptions)->wait(); + } + + /** + * Searches organization resources that are visible to the user and satisfy + * the specified filter. This method returns organizations in an unspecified + * order. New organizations do not necessarily appear at the end of the + * results, and may take a small amount of time to appear. + * + * Search will only return organizations on which the user has the permission + * `resourcemanager.organizations.get` + * + * The async variant is {@see OrganizationsClient::searchOrganizationsAsync()} . + * + * @example samples/V3/OrganizationsClient/search_organizations.php + * + * @param SearchOrganizationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchOrganizations(SearchOrganizationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchOrganizations', $request, $callOptions); + } + + /** + * Sets the access control policy on an organization resource. Replaces any + * existing policy. The `resource` field should be the organization's resource + * name, for example: "organizations/123". + * + * Authorization requires the IAM permission + * `resourcemanager.organizations.setIamPolicy` on the specified organization. + * + * The async variant is {@see OrganizationsClient::setIamPolicyAsync()} . + * + * @example samples/V3/OrganizationsClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns the permissions that a caller has on the specified organization. + * The `resource` field should be the organization's resource name, + * for example: "organizations/123". + * + * There are no permissions required for making this API call. + * + * The async variant is {@see OrganizationsClient::testIamPermissionsAsync()} . + * + * @example samples/V3/OrganizationsClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/ResourceManager/src/V3/Client/ProjectsClient.php b/ResourceManager/src/V3/Client/ProjectsClient.php index f6b0b8c344c3..a65b4aacfe75 100644 --- a/ResourceManager/src/V3/Client/ProjectsClient.php +++ b/ResourceManager/src/V3/Client/ProjectsClient.php @@ -24,17 +24,654 @@ namespace Google\Cloud\ResourceManager\V3\Client; -use Google\Cloud\ResourceManager\V3\Client\BaseClient\ProjectsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\ResourceManager\V3\CreateProjectRequest; +use Google\Cloud\ResourceManager\V3\DeleteProjectRequest; +use Google\Cloud\ResourceManager\V3\GetProjectRequest; +use Google\Cloud\ResourceManager\V3\ListProjectsRequest; +use Google\Cloud\ResourceManager\V3\MoveProjectRequest; +use Google\Cloud\ResourceManager\V3\Project; +use Google\Cloud\ResourceManager\V3\SearchProjectsRequest; +use Google\Cloud\ResourceManager\V3\UndeleteProjectRequest; +use Google\Cloud\ResourceManager\V3\UpdateProjectRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Manages Google Cloud Projects. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ResourceManager\V3\ProjectsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createProjectAsync(CreateProjectRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteProjectAsync(DeleteProjectRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getProjectAsync(GetProjectRequest $request, array $optionalArgs = []) + * @method PromiseInterface listProjectsAsync(ListProjectsRequest $request, array $optionalArgs = []) + * @method PromiseInterface moveProjectAsync(MoveProjectRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchProjectsAsync(SearchProjectsRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface undeleteProjectAsync(UndeleteProjectRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateProjectAsync(UpdateProjectRequest $request, array $optionalArgs = []) */ -final class ProjectsClient extends ProjectsBaseClient +final class ProjectsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ProjectsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.resourcemanager.v3.Projects'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudresourcemanager.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/projects_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/projects_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/projects_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/projects_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->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. + */ + public static function parseName(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudresourcemanager.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Request that a new project be created. The result is an `Operation` which + * can be used to track the creation process. This process usually takes a few + * seconds, but can sometimes take much longer. The tracking `Operation` is + * automatically deleted after a few hours, so there is no need to call + * `DeleteOperation`. + * + * The async variant is {@see ProjectsClient::createProjectAsync()} . + * + * @example samples/V3/ProjectsClient/create_project.php + * + * @param CreateProjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createProject(CreateProjectRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateProject', $request, $callOptions)->wait(); + } + + /** + * Marks the project identified by the specified + * `name` (for example, `projects/415104041262`) for deletion. + * + * This method will only affect the project if it has a lifecycle state of + * [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE]. + * + * This method changes the Project's lifecycle state from + * [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE] + * to + * [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Project.State.DELETE_REQUESTED]. + * The deletion starts at an unspecified time, + * at which point the Project is no longer accessible. + * + * Until the deletion completes, you can check the lifecycle state + * checked by retrieving the project with [GetProject] + * [google.cloud.resourcemanager.v3.Projects.GetProject], + * and the project remains visible to [ListProjects] + * [google.cloud.resourcemanager.v3.Projects.ListProjects]. + * However, you cannot update the project. + * + * After the deletion completes, the project is not retrievable by + * the [GetProject] + * [google.cloud.resourcemanager.v3.Projects.GetProject], + * [ListProjects] + * [google.cloud.resourcemanager.v3.Projects.ListProjects], and + * [SearchProjects][google.cloud.resourcemanager.v3.Projects.SearchProjects] + * methods. + * + * This method behaves idempotently, such that deleting a `DELETE_REQUESTED` + * project will not cause an error, but also won't do anything. + * + * The caller must have `resourcemanager.projects.delete` permissions for this + * project. + * + * The async variant is {@see ProjectsClient::deleteProjectAsync()} . + * + * @example samples/V3/ProjectsClient/delete_project.php + * + * @param DeleteProjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteProject(DeleteProjectRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteProject', $request, $callOptions)->wait(); + } + + /** + * Returns the IAM access control policy for the specified project, in the + * format `projects/{ProjectIdOrNumber}` e.g. projects/123. + * Permission is denied if the policy or the resource do not exist. + * + * The async variant is {@see ProjectsClient::getIamPolicyAsync()} . + * + * @example samples/V3/ProjectsClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Retrieves the project identified by the specified `name` (for example, + * `projects/415104041262`). + * + * The caller must have `resourcemanager.projects.get` permission + * for this project. + * + * The async variant is {@see ProjectsClient::getProjectAsync()} . + * + * @example samples/V3/ProjectsClient/get_project.php + * + * @param GetProjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Project + * + * @throws ApiException Thrown if the API call fails. + */ + public function getProject(GetProjectRequest $request, array $callOptions = []): Project + { + return $this->startApiCall('GetProject', $request, $callOptions)->wait(); + } + + /** + * Lists projects that are direct children of the specified folder or + * organization resource. `list()` provides a strongly consistent view of the + * projects underneath the specified parent resource. `list()` returns + * projects sorted based upon the (ascending) lexical ordering of their + * `display_name`. The caller must have `resourcemanager.projects.list` + * permission on the identified parent. + * + * The async variant is {@see ProjectsClient::listProjectsAsync()} . + * + * @example samples/V3/ProjectsClient/list_projects.php + * + * @param ListProjectsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listProjects(ListProjectsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListProjects', $request, $callOptions); + } + + /** + * Move a project to another place in your resource hierarchy, under a new + * resource parent. + * + * Returns an operation which can be used to track the process of the project + * move workflow. + * Upon success, the `Operation.response` field will be populated with the + * moved project. + * + * The caller must have `resourcemanager.projects.move` permission on the + * project, on the project's current and proposed new parent. + * + * If project has no current parent, or it currently does not have an + * associated organization resource, you will also need the + * `resourcemanager.projects.setIamPolicy` permission in the project. + * + * + * + * The async variant is {@see ProjectsClient::moveProjectAsync()} . + * + * @example samples/V3/ProjectsClient/move_project.php + * + * @param MoveProjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function moveProject(MoveProjectRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('MoveProject', $request, $callOptions)->wait(); + } + + /** + * Search for projects that the caller has both `resourcemanager.projects.get` + * permission on, and also satisfy the specified query. + * + * This method returns projects in an unspecified order. + * + * This method is eventually consistent with project mutations; this means + * that a newly created project may not appear in the results or recent + * updates to an existing project may not be reflected in the results. To + * retrieve the latest state of a project, use the + * [GetProject][google.cloud.resourcemanager.v3.Projects.GetProject] method. + * + * The async variant is {@see ProjectsClient::searchProjectsAsync()} . + * + * @example samples/V3/ProjectsClient/search_projects.php + * + * @param SearchProjectsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchProjects(SearchProjectsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchProjects', $request, $callOptions); + } + + /** + * Sets the IAM access control policy for the specified project, in the + * format `projects/{ProjectIdOrNumber}` e.g. projects/123. + * + * CAUTION: This method will replace the existing policy, and cannot be used + * to append additional IAM settings. + * + * Note: Removing service accounts from policies or changing their roles can + * render services completely inoperable. It is important to understand how + * the service account is being used before removing or updating its roles. + * + * The following constraints apply when using `setIamPolicy()`: + * + * + Project does not support `allUsers` and `allAuthenticatedUsers` as + * `members` in a `Binding` of a `Policy`. + * + * + The owner role can be granted to a `user`, `serviceAccount`, or a group + * that is part of an organization. For example, + * group@myownpersonaldomain.com could be added as an owner to a project in + * the myownpersonaldomain.com organization, but not the examplepetstore.com + * organization. + * + * + Service accounts can be made owners of a project directly + * without any restrictions. However, to be added as an owner, a user must be + * invited using the Cloud Platform console and must accept the invitation. + * + * + A user cannot be granted the owner role using `setIamPolicy()`. The user + * must be granted the owner role using the Cloud Platform Console and must + * explicitly accept the invitation. + * + * + Invitations to grant the owner role cannot be sent using + * `setIamPolicy()`; + * they must be sent only using the Cloud Platform Console. + * + * + If the project is not part of an organization, there must be at least + * one owner who has accepted the Terms of Service (ToS) agreement in the + * policy. Calling `setIamPolicy()` to remove the last ToS-accepted owner + * from the policy will fail. This restriction also applies to legacy + * projects that no longer have owners who have accepted the ToS. Edits to + * IAM policies will be rejected until the lack of a ToS-accepting owner is + * rectified. If the project is part of an organization, you can remove all + * owners, potentially making the organization inaccessible. + * + * The async variant is {@see ProjectsClient::setIamPolicyAsync()} . + * + * @example samples/V3/ProjectsClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified project, in the + * format `projects/{ProjectIdOrNumber}` e.g. projects/123.. + * + * The async variant is {@see ProjectsClient::testIamPermissionsAsync()} . + * + * @example samples/V3/ProjectsClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Restores the project identified by the specified + * `name` (for example, `projects/415104041262`). + * You can only use this method for a project that has a lifecycle state of + * [DELETE_REQUESTED] + * [Projects.State.DELETE_REQUESTED]. + * After deletion starts, the project cannot be restored. + * + * The caller must have `resourcemanager.projects.undelete` permission for + * this project. + * + * The async variant is {@see ProjectsClient::undeleteProjectAsync()} . + * + * @example samples/V3/ProjectsClient/undelete_project.php + * + * @param UndeleteProjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function undeleteProject(UndeleteProjectRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UndeleteProject', $request, $callOptions)->wait(); + } + + /** + * Updates the `display_name` and labels of the project identified by the + * specified `name` (for example, `projects/415104041262`). Deleting all + * labels requires an update mask for labels field. + * + * The caller must have `resourcemanager.projects.update` permission for this + * project. + * + * The async variant is {@see ProjectsClient::updateProjectAsync()} . + * + * @example samples/V3/ProjectsClient/update_project.php + * + * @param UpdateProjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateProject(UpdateProjectRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateProject', $request, $callOptions)->wait(); + } } diff --git a/ResourceManager/src/V3/Client/TagBindingsClient.php b/ResourceManager/src/V3/Client/TagBindingsClient.php index 074fa75d3e4f..d6c50806c007 100644 --- a/ResourceManager/src/V3/Client/TagBindingsClient.php +++ b/ResourceManager/src/V3/Client/TagBindingsClient.php @@ -24,17 +24,338 @@ namespace Google\Cloud\ResourceManager\V3\Client; -use Google\Cloud\ResourceManager\V3\Client\BaseClient\TagBindingsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\ResourceManager\V3\CreateTagBindingRequest; +use Google\Cloud\ResourceManager\V3\DeleteTagBindingRequest; +use Google\Cloud\ResourceManager\V3\ListEffectiveTagsRequest; +use Google\Cloud\ResourceManager\V3\ListTagBindingsRequest; +use Google\Cloud\ResourceManager\V3\TagBinding; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Allow users to create and manage TagBindings between TagValues and + * different Google Cloud resources throughout the GCP resource hierarchy. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ResourceManager\V3\TagBindingsClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createTagBindingAsync(CreateTagBindingRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTagBindingAsync(DeleteTagBindingRequest $request, array $optionalArgs = []) + * @method PromiseInterface listEffectiveTagsAsync(ListEffectiveTagsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTagBindingsAsync(ListTagBindingsRequest $request, array $optionalArgs = []) */ -final class TagBindingsClient extends TagBindingsBaseClient +final class TagBindingsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TagBindingsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.resourcemanager.v3.TagBindings'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudresourcemanager.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/tag_bindings_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/tag_bindings_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/tag_bindings_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/tag_bindings_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a tag_binding + * resource. + * + * @param string $tagBinding + * + * @return string The formatted tag_binding resource. + */ + public static function tagBindingName(string $tagBinding): string + { + return self::getPathTemplate('tagBinding')->render([ + 'tag_binding' => $tagBinding, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - tagBinding: tagBindings/{tag_binding} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudresourcemanager.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a TagBinding between a TagValue and a Google Cloud resource. + * + * The async variant is {@see TagBindingsClient::createTagBindingAsync()} . + * + * @example samples/V3/TagBindingsClient/create_tag_binding.php + * + * @param CreateTagBindingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTagBinding(CreateTagBindingRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateTagBinding', $request, $callOptions)->wait(); + } + + /** + * Deletes a TagBinding. + * + * The async variant is {@see TagBindingsClient::deleteTagBindingAsync()} . + * + * @example samples/V3/TagBindingsClient/delete_tag_binding.php + * + * @param DeleteTagBindingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTagBinding(DeleteTagBindingRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteTagBinding', $request, $callOptions)->wait(); + } + + /** + * Return a list of effective tags for the given Google Cloud resource, as + * specified in `parent`. + * + * The async variant is {@see TagBindingsClient::listEffectiveTagsAsync()} . + * + * @example samples/V3/TagBindingsClient/list_effective_tags.php + * + * @param ListEffectiveTagsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listEffectiveTags(ListEffectiveTagsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEffectiveTags', $request, $callOptions); + } + + /** + * Lists the TagBindings for the given Google Cloud resource, as specified + * with `parent`. + * + * NOTE: The `parent` field is expected to be a full resource name: + * https://cloud.google.com/apis/design/resource_names#full_resource_name + * + * The async variant is {@see TagBindingsClient::listTagBindingsAsync()} . + * + * @example samples/V3/TagBindingsClient/list_tag_bindings.php + * + * @param ListTagBindingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTagBindings(ListTagBindingsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTagBindings', $request, $callOptions); + } } diff --git a/ResourceManager/src/V3/Client/TagHoldsClient.php b/ResourceManager/src/V3/Client/TagHoldsClient.php index cf73ed3db75a..9641624c80c3 100644 --- a/ResourceManager/src/V3/Client/TagHoldsClient.php +++ b/ResourceManager/src/V3/Client/TagHoldsClient.php @@ -24,17 +24,326 @@ namespace Google\Cloud\ResourceManager\V3\Client; -use Google\Cloud\ResourceManager\V3\Client\BaseClient\TagHoldsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\ResourceManager\V3\CreateTagHoldRequest; +use Google\Cloud\ResourceManager\V3\DeleteTagHoldRequest; +use Google\Cloud\ResourceManager\V3\ListTagHoldsRequest; +use Google\Cloud\ResourceManager\V3\TagHold; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Allow users to create and manage TagHolds for TagValues. TagHolds represent + * the use of a Tag Value that is not captured by TagBindings but + * should still block TagValue deletion (such as a reference in a policy + * condition). This service provides isolated failure domains by cloud location + * so that TagHolds can be managed in the same location as their usage. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ResourceManager\V3\TagHoldsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createTagHoldAsync(CreateTagHoldRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTagHoldAsync(DeleteTagHoldRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTagHoldsAsync(ListTagHoldsRequest $request, array $optionalArgs = []) */ -final class TagHoldsClient extends TagHoldsBaseClient +final class TagHoldsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TagHoldsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.resourcemanager.v3.TagHolds'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudresourcemanager.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/tag_holds_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/tag_holds_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/tag_holds_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/tag_holds_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a tag_hold + * resource. + * + * @param string $tagValue + * @param string $tagHold + * + * @return string The formatted tag_hold resource. + */ + public static function tagHoldName(string $tagValue, string $tagHold): string + { + return self::getPathTemplate('tagHold')->render([ + 'tag_value' => $tagValue, + 'tag_hold' => $tagHold, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a tag_value + * resource. + * + * @param string $tagValue + * + * @return string The formatted tag_value resource. + */ + public static function tagValueName(string $tagValue): string + { + return self::getPathTemplate('tagValue')->render([ + 'tag_value' => $tagValue, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - tagHold: tagValues/{tag_value}/tagHolds/{tag_hold} + * - tagValue: tagValues/{tag_value} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudresourcemanager.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a TagHold. Returns ALREADY_EXISTS if a TagHold with the same + * resource and origin exists under the same TagValue. + * + * The async variant is {@see TagHoldsClient::createTagHoldAsync()} . + * + * @example samples/V3/TagHoldsClient/create_tag_hold.php + * + * @param CreateTagHoldRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTagHold(CreateTagHoldRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateTagHold', $request, $callOptions)->wait(); + } + + /** + * Deletes a TagHold. + * + * The async variant is {@see TagHoldsClient::deleteTagHoldAsync()} . + * + * @example samples/V3/TagHoldsClient/delete_tag_hold.php + * + * @param DeleteTagHoldRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTagHold(DeleteTagHoldRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteTagHold', $request, $callOptions)->wait(); + } + + /** + * Lists TagHolds under a TagValue. + * + * The async variant is {@see TagHoldsClient::listTagHoldsAsync()} . + * + * @example samples/V3/TagHoldsClient/list_tag_holds.php + * + * @param ListTagHoldsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTagHolds(ListTagHoldsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTagHolds', $request, $callOptions); + } } diff --git a/ResourceManager/src/V3/Client/TagKeysClient.php b/ResourceManager/src/V3/Client/TagKeysClient.php index d2ad731f0d5a..0b4c1817813f 100644 --- a/ResourceManager/src/V3/Client/TagKeysClient.php +++ b/ResourceManager/src/V3/Client/TagKeysClient.php @@ -24,17 +24,493 @@ namespace Google\Cloud\ResourceManager\V3\Client; -use Google\Cloud\ResourceManager\V3\Client\BaseClient\TagKeysBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\ResourceManager\V3\CreateTagKeyRequest; +use Google\Cloud\ResourceManager\V3\DeleteTagKeyRequest; +use Google\Cloud\ResourceManager\V3\GetNamespacedTagKeyRequest; +use Google\Cloud\ResourceManager\V3\GetTagKeyRequest; +use Google\Cloud\ResourceManager\V3\ListTagKeysRequest; +use Google\Cloud\ResourceManager\V3\TagKey; +use Google\Cloud\ResourceManager\V3\UpdateTagKeyRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Allow users to create and manage tag keys. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ResourceManager\V3\TagKeysClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createTagKeyAsync(CreateTagKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTagKeyAsync(DeleteTagKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getNamespacedTagKeyAsync(GetNamespacedTagKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTagKeyAsync(GetTagKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTagKeysAsync(ListTagKeysRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateTagKeyAsync(UpdateTagKeyRequest $request, array $optionalArgs = []) */ -final class TagKeysClient extends TagKeysBaseClient +final class TagKeysClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TagKeysBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.resourcemanager.v3.TagKeys'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudresourcemanager.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/tag_keys_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/tag_keys_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/tag_keys_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/tag_keys_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a tag_key + * resource. + * + * @param string $tagKey + * + * @return string The formatted tag_key resource. + */ + public static function tagKeyName(string $tagKey): string + { + return self::getPathTemplate('tagKey')->render([ + 'tag_key' => $tagKey, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - tagKey: tagKeys/{tag_key} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudresourcemanager.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new TagKey. If another request with the same parameters is + * sent while the original request is in process, the second request + * will receive an error. A maximum of 1000 TagKeys can exist under a parent + * at any given time. + * + * The async variant is {@see TagKeysClient::createTagKeyAsync()} . + * + * @example samples/V3/TagKeysClient/create_tag_key.php + * + * @param CreateTagKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTagKey(CreateTagKeyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateTagKey', $request, $callOptions)->wait(); + } + + /** + * Deletes a TagKey. The TagKey cannot be deleted if it has any child + * TagValues. + * + * The async variant is {@see TagKeysClient::deleteTagKeyAsync()} . + * + * @example samples/V3/TagKeysClient/delete_tag_key.php + * + * @param DeleteTagKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTagKey(DeleteTagKeyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteTagKey', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a TagKey. The returned policy may be + * empty if no such policy or resource exists. The `resource` field should + * be the TagKey's resource name. For example, "tagKeys/1234". + * The caller must have + * `cloudresourcemanager.googleapis.com/tagKeys.getIamPolicy` permission on + * the specified TagKey. + * + * The async variant is {@see TagKeysClient::getIamPolicyAsync()} . + * + * @example samples/V3/TagKeysClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Retrieves a TagKey by its namespaced name. + * This method will return `PERMISSION_DENIED` if the key does not exist + * or the user does not have permission to view it. + * + * The async variant is {@see TagKeysClient::getNamespacedTagKeyAsync()} . + * + * @example samples/V3/TagKeysClient/get_namespaced_tag_key.php + * + * @param GetNamespacedTagKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TagKey + * + * @throws ApiException Thrown if the API call fails. + */ + public function getNamespacedTagKey(GetNamespacedTagKeyRequest $request, array $callOptions = []): TagKey + { + return $this->startApiCall('GetNamespacedTagKey', $request, $callOptions)->wait(); + } + + /** + * Retrieves a TagKey. This method will return `PERMISSION_DENIED` if the + * key does not exist or the user does not have permission to view it. + * + * The async variant is {@see TagKeysClient::getTagKeyAsync()} . + * + * @example samples/V3/TagKeysClient/get_tag_key.php + * + * @param GetTagKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TagKey + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTagKey(GetTagKeyRequest $request, array $callOptions = []): TagKey + { + return $this->startApiCall('GetTagKey', $request, $callOptions)->wait(); + } + + /** + * Lists all TagKeys for a parent resource. + * + * The async variant is {@see TagKeysClient::listTagKeysAsync()} . + * + * @example samples/V3/TagKeysClient/list_tag_keys.php + * + * @param ListTagKeysRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTagKeys(ListTagKeysRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTagKeys', $request, $callOptions); + } + + /** + * Sets the access control policy on a TagKey, replacing any existing + * policy. The `resource` field should be the TagKey's resource name. + * For example, "tagKeys/1234". + * The caller must have `resourcemanager.tagKeys.setIamPolicy` permission + * on the identified tagValue. + * + * The async variant is {@see TagKeysClient::setIamPolicyAsync()} . + * + * @example samples/V3/TagKeysClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified TagKey. + * The `resource` field should be the TagKey's resource name. + * For example, "tagKeys/1234". + * + * There are no permissions required for making this API call. + * + * The async variant is {@see TagKeysClient::testIamPermissionsAsync()} . + * + * @example samples/V3/TagKeysClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates the attributes of the TagKey resource. + * + * The async variant is {@see TagKeysClient::updateTagKeyAsync()} . + * + * @example samples/V3/TagKeysClient/update_tag_key.php + * + * @param UpdateTagKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTagKey(UpdateTagKeyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateTagKey', $request, $callOptions)->wait(); + } } diff --git a/ResourceManager/src/V3/Client/TagValuesClient.php b/ResourceManager/src/V3/Client/TagValuesClient.php index 4222011a27c3..76361c76d857 100644 --- a/ResourceManager/src/V3/Client/TagValuesClient.php +++ b/ResourceManager/src/V3/Client/TagValuesClient.php @@ -24,17 +24,493 @@ namespace Google\Cloud\ResourceManager\V3\Client; -use Google\Cloud\ResourceManager\V3\Client\BaseClient\TagValuesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\ResourceManager\V3\CreateTagValueRequest; +use Google\Cloud\ResourceManager\V3\DeleteTagValueRequest; +use Google\Cloud\ResourceManager\V3\GetNamespacedTagValueRequest; +use Google\Cloud\ResourceManager\V3\GetTagValueRequest; +use Google\Cloud\ResourceManager\V3\ListTagValuesRequest; +use Google\Cloud\ResourceManager\V3\TagValue; +use Google\Cloud\ResourceManager\V3\UpdateTagValueRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Allow users to create and manage tag values. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ResourceManager\V3\TagValuesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createTagValueAsync(CreateTagValueRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTagValueAsync(DeleteTagValueRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getNamespacedTagValueAsync(GetNamespacedTagValueRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTagValueAsync(GetTagValueRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTagValuesAsync(ListTagValuesRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateTagValueAsync(UpdateTagValueRequest $request, array $optionalArgs = []) */ -final class TagValuesClient extends TagValuesBaseClient +final class TagValuesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TagValuesBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.resourcemanager.v3.TagValues'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudresourcemanager.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/tag_values_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/tag_values_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/tag_values_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/tag_values_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a tag_value + * resource. + * + * @param string $tagValue + * + * @return string The formatted tag_value resource. + */ + public static function tagValueName(string $tagValue): string + { + return self::getPathTemplate('tagValue')->render([ + 'tag_value' => $tagValue, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - tagValue: tagValues/{tag_value} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudresourcemanager.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a TagValue as a child of the specified TagKey. If a another + * request with the same parameters is sent while the original request is in + * process the second request will receive an error. A maximum of 1000 + * TagValues can exist under a TagKey at any given time. + * + * The async variant is {@see TagValuesClient::createTagValueAsync()} . + * + * @example samples/V3/TagValuesClient/create_tag_value.php + * + * @param CreateTagValueRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTagValue(CreateTagValueRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateTagValue', $request, $callOptions)->wait(); + } + + /** + * Deletes a TagValue. The TagValue cannot have any bindings when it is + * deleted. + * + * The async variant is {@see TagValuesClient::deleteTagValueAsync()} . + * + * @example samples/V3/TagValuesClient/delete_tag_value.php + * + * @param DeleteTagValueRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTagValue(DeleteTagValueRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteTagValue', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a TagValue. The returned policy may be + * empty if no such policy or resource exists. The `resource` field should + * be the TagValue's resource name. For example: `tagValues/1234`. + * The caller must have the + * `cloudresourcemanager.googleapis.com/tagValues.getIamPolicy` permission on + * the identified TagValue to get the access control policy. + * + * The async variant is {@see TagValuesClient::getIamPolicyAsync()} . + * + * @example samples/V3/TagValuesClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Retrieves a TagValue by its namespaced name. + * This method will return `PERMISSION_DENIED` if the value does not exist + * or the user does not have permission to view it. + * + * The async variant is {@see TagValuesClient::getNamespacedTagValueAsync()} . + * + * @example samples/V3/TagValuesClient/get_namespaced_tag_value.php + * + * @param GetNamespacedTagValueRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TagValue + * + * @throws ApiException Thrown if the API call fails. + */ + public function getNamespacedTagValue(GetNamespacedTagValueRequest $request, array $callOptions = []): TagValue + { + return $this->startApiCall('GetNamespacedTagValue', $request, $callOptions)->wait(); + } + + /** + * Retrieves a TagValue. This method will return `PERMISSION_DENIED` if the + * value does not exist or the user does not have permission to view it. + * + * The async variant is {@see TagValuesClient::getTagValueAsync()} . + * + * @example samples/V3/TagValuesClient/get_tag_value.php + * + * @param GetTagValueRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TagValue + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTagValue(GetTagValueRequest $request, array $callOptions = []): TagValue + { + return $this->startApiCall('GetTagValue', $request, $callOptions)->wait(); + } + + /** + * Lists all TagValues for a specific TagKey. + * + * The async variant is {@see TagValuesClient::listTagValuesAsync()} . + * + * @example samples/V3/TagValuesClient/list_tag_values.php + * + * @param ListTagValuesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTagValues(ListTagValuesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTagValues', $request, $callOptions); + } + + /** + * Sets the access control policy on a TagValue, replacing any existing + * policy. The `resource` field should be the TagValue's resource name. + * For example: `tagValues/1234`. + * The caller must have `resourcemanager.tagValues.setIamPolicy` permission + * on the identified tagValue. + * + * The async variant is {@see TagValuesClient::setIamPolicyAsync()} . + * + * @example samples/V3/TagValuesClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified TagValue. + * The `resource` field should be the TagValue's resource name. For example: + * `tagValues/1234`. + * + * There are no permissions required for making this API call. + * + * The async variant is {@see TagValuesClient::testIamPermissionsAsync()} . + * + * @example samples/V3/TagValuesClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates the attributes of the TagValue resource. + * + * The async variant is {@see TagValuesClient::updateTagValueAsync()} . + * + * @example samples/V3/TagValuesClient/update_tag_value.php + * + * @param UpdateTagValueRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTagValue(UpdateTagValueRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateTagValue', $request, $callOptions)->wait(); + } } diff --git a/ResourceSettings/composer.json b/ResourceSettings/composer.json index bd861bf7a8d8..ff3d4fa32c12 100644 --- a/ResourceSettings/composer.json +++ b/ResourceSettings/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/ResourceSettings/src/V1/Client/BaseClient/ResourceSettingsServiceBaseClient.php b/ResourceSettings/src/V1/Client/BaseClient/ResourceSettingsServiceBaseClient.php deleted file mode 100644 index 0fa3ee492fbb..000000000000 --- a/ResourceSettings/src/V1/Client/BaseClient/ResourceSettingsServiceBaseClient.php +++ /dev/null @@ -1,372 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/resource_settings_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/resource_settings_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/resource_settings_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/resource_settings_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_setting_name resource. - * - * @param string $folder - * @param string $settingName - * - * @return string The formatted folder_setting_name resource. - */ - public static function folderSettingNameName(string $folder, string $settingName): string - { - return self::getPathTemplate('folderSettingName')->render([ - 'folder' => $folder, - 'setting_name' => $settingName, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_setting_name resource. - * - * @param string $organization - * @param string $settingName - * - * @return string The formatted organization_setting_name resource. - */ - public static function organizationSettingNameName(string $organization, string $settingName): string - { - return self::getPathTemplate('organizationSettingName')->render([ - 'organization' => $organization, - 'setting_name' => $settingName, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_number_setting_name resource. - * - * @param string $projectNumber - * @param string $settingName - * - * @return string The formatted project_number_setting_name resource. - */ - public static function projectNumberSettingNameName(string $projectNumber, string $settingName): string - { - return self::getPathTemplate('projectNumberSettingName')->render([ - 'project_number' => $projectNumber, - 'setting_name' => $settingName, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a setting - * resource. - * - * @param string $projectNumber - * @param string $settingName - * - * @return string The formatted setting resource. - */ - public static function settingName(string $projectNumber, string $settingName): string - { - return self::getPathTemplate('setting')->render([ - 'project_number' => $projectNumber, - 'setting_name' => $settingName, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - folderSettingName: folders/{folder}/settings/{setting_name} - * - organizationSettingName: organizations/{organization}/settings/{setting_name} - * - projectNumberSettingName: projects/{project_number}/settings/{setting_name} - * - setting: projects/{project_number}/settings/{setting_name} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'resourcesettings.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Gets a setting. - * - * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the - * setting does not exist. - * - * The async variant is {@see self::getSettingAsync()} . - * - * @param GetSettingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Setting - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSetting(GetSettingRequest $request, array $callOptions = []): Setting - { - return $this->startApiCall('GetSetting', $request, $callOptions)->wait(); - } - - /** - * Lists all the settings that are available on the Cloud resource `parent`. - * - * The async variant is {@see self::listSettingsAsync()} . - * - * @param ListSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSettings(ListSettingsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSettings', $request, $callOptions); - } - - /** - * Updates a setting. - * - * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the - * setting does not exist. - * Returns a `google.rpc.Status` with `google.rpc.Code.FAILED_PRECONDITION` if - * the setting is flagged as read only. - * Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag - * supplied in the request does not match the persisted etag of the setting - * value. - * - * On success, the response will contain only `name`, `local_value` and - * `etag`. The `metadata` and `effective_value` cannot be updated through - * this API. - * - * Note: the supplied setting will perform a full overwrite of the - * `local_value` field. - * - * The async variant is {@see self::updateSettingAsync()} . - * - * @param UpdateSettingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Setting - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSetting(UpdateSettingRequest $request, array $callOptions = []): Setting - { - return $this->startApiCall('UpdateSetting', $request, $callOptions)->wait(); - } -} diff --git a/ResourceSettings/src/V1/Client/ResourceSettingsServiceClient.php b/ResourceSettings/src/V1/Client/ResourceSettingsServiceClient.php index 156dd7379e10..f3b2c5859185 100644 --- a/ResourceSettings/src/V1/Client/ResourceSettingsServiceClient.php +++ b/ResourceSettings/src/V1/Client/ResourceSettingsServiceClient.php @@ -24,17 +24,348 @@ namespace Google\Cloud\ResourceSettings\V1\Client; -use Google\Cloud\ResourceSettings\V1\Client\BaseClient\ResourceSettingsServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\ResourceSettings\V1\GetSettingRequest; +use Google\Cloud\ResourceSettings\V1\ListSettingsRequest; +use Google\Cloud\ResourceSettings\V1\Setting; +use Google\Cloud\ResourceSettings\V1\UpdateSettingRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: An interface to interact with resource settings and setting values throughout + * the resource hierarchy. * - * This class is currently experimental and may be subject to changes. + * Services may surface a number of settings for users to control how their + * resources behave. Values of settings applied on a given Cloud resource are + * evaluated hierarchically and inherited by all descendants of that resource. + * + * For all requests, returns a `google.rpc.Status` with + * `google.rpc.Code.PERMISSION_DENIED` if the IAM check fails or the `parent` + * resource is not in a Cloud Organization. + * For all requests, returns a `google.rpc.Status` with + * `google.rpc.Code.INVALID_ARGUMENT` if the request is malformed. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ResourceSettings\V1\ResourceSettingsServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface getSettingAsync(GetSettingRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSettingsAsync(ListSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSettingAsync(UpdateSettingRequest $request, array $optionalArgs = []) */ -final class ResourceSettingsServiceClient extends ResourceSettingsServiceBaseClient +final class ResourceSettingsServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ResourceSettingsServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.resourcesettings.v1.ResourceSettingsService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'resourcesettings.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/resource_settings_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/resource_settings_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/resource_settings_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/resource_settings_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_setting_name resource. + * + * @param string $folder + * @param string $settingName + * + * @return string The formatted folder_setting_name resource. + */ + public static function folderSettingNameName(string $folder, string $settingName): string + { + return self::getPathTemplate('folderSettingName')->render([ + 'folder' => $folder, + 'setting_name' => $settingName, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_setting_name resource. + * + * @param string $organization + * @param string $settingName + * + * @return string The formatted organization_setting_name resource. + */ + public static function organizationSettingNameName(string $organization, string $settingName): string + { + return self::getPathTemplate('organizationSettingName')->render([ + 'organization' => $organization, + 'setting_name' => $settingName, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_number_setting_name resource. + * + * @param string $projectNumber + * @param string $settingName + * + * @return string The formatted project_number_setting_name resource. + */ + public static function projectNumberSettingNameName(string $projectNumber, string $settingName): string + { + return self::getPathTemplate('projectNumberSettingName')->render([ + 'project_number' => $projectNumber, + 'setting_name' => $settingName, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a setting + * resource. + * + * @param string $projectNumber + * @param string $settingName + * + * @return string The formatted setting resource. + */ + public static function settingName(string $projectNumber, string $settingName): string + { + return self::getPathTemplate('setting')->render([ + 'project_number' => $projectNumber, + 'setting_name' => $settingName, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - folderSettingName: folders/{folder}/settings/{setting_name} + * - organizationSettingName: organizations/{organization}/settings/{setting_name} + * - projectNumberSettingName: projects/{project_number}/settings/{setting_name} + * - setting: projects/{project_number}/settings/{setting_name} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'resourcesettings.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Gets a setting. + * + * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the + * setting does not exist. + * + * The async variant is {@see ResourceSettingsServiceClient::getSettingAsync()} . + * + * @param GetSettingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Setting + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSetting(GetSettingRequest $request, array $callOptions = []): Setting + { + return $this->startApiCall('GetSetting', $request, $callOptions)->wait(); + } + + /** + * Lists all the settings that are available on the Cloud resource `parent`. + * + * The async variant is {@see ResourceSettingsServiceClient::listSettingsAsync()} . + * + * @param ListSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSettings(ListSettingsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSettings', $request, $callOptions); + } + + /** + * Updates a setting. + * + * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the + * setting does not exist. + * Returns a `google.rpc.Status` with `google.rpc.Code.FAILED_PRECONDITION` if + * the setting is flagged as read only. + * Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag + * supplied in the request does not match the persisted etag of the setting + * value. + * + * On success, the response will contain only `name`, `local_value` and + * `etag`. The `metadata` and `effective_value` cannot be updated through + * this API. + * + * Note: the supplied setting will perform a full overwrite of the + * `local_value` field. + * + * The async variant is {@see ResourceSettingsServiceClient::updateSettingAsync()} + * . + * + * @param UpdateSettingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Setting + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSetting(UpdateSettingRequest $request, array $callOptions = []): Setting + { + return $this->startApiCall('UpdateSetting', $request, $callOptions)->wait(); + } } diff --git a/Retail/composer.json b/Retail/composer.json index 5b533c25db35..a109bee971a1 100644 --- a/Retail/composer.json +++ b/Retail/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Retail/src/V2/Client/BaseClient/CatalogServiceBaseClient.php b/Retail/src/V2/Client/BaseClient/CatalogServiceBaseClient.php deleted file mode 100644 index a309dbca5bd5..000000000000 --- a/Retail/src/V2/Client/BaseClient/CatalogServiceBaseClient.php +++ /dev/null @@ -1,638 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/catalog_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/catalog_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/catalog_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/catalog_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * attributes_config resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * - * @return string The formatted attributes_config resource. - */ - public static function attributesConfigName(string $project, string $location, string $catalog): string - { - return self::getPathTemplate('attributesConfig')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a branch - * resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * @param string $branch - * - * @return string The formatted branch resource. - */ - public static function branchName(string $project, string $location, string $catalog, string $branch): string - { - return self::getPathTemplate('branch')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - 'branch' => $branch, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a catalog - * resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * - * @return string The formatted catalog resource. - */ - public static function catalogName(string $project, string $location, string $catalog): string - { - return self::getPathTemplate('catalog')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * completion_config resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * - * @return string The formatted completion_config resource. - */ - public static function completionConfigName(string $project, string $location, string $catalog): string - { - return self::getPathTemplate('completionConfig')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - attributesConfig: projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig - * - branch: projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch} - * - catalog: projects/{project}/locations/{location}/catalogs/{catalog} - * - completionConfig: projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'retail.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Adds the specified - * [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to the - * [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. - * - * If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to add - * already exists, an ALREADY_EXISTS error is returned. - * - * The async variant is {@see self::addCatalogAttributeAsync()} . - * - * @param AddCatalogAttributeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AttributesConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function addCatalogAttribute(AddCatalogAttributeRequest $request, array $callOptions = []): AttributesConfig - { - return $this->startApiCall('AddCatalogAttribute', $request, $callOptions)->wait(); - } - - /** - * Gets an [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. - * - * The async variant is {@see self::getAttributesConfigAsync()} . - * - * @param GetAttributesConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AttributesConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAttributesConfig(GetAttributesConfigRequest $request, array $callOptions = []): AttributesConfig - { - return $this->startApiCall('GetAttributesConfig', $request, $callOptions)->wait(); - } - - /** - * Gets a [CompletionConfig][google.cloud.retail.v2.CompletionConfig]. - * - * The async variant is {@see self::getCompletionConfigAsync()} . - * - * @param GetCompletionConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CompletionConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCompletionConfig(GetCompletionConfigRequest $request, array $callOptions = []): CompletionConfig - { - return $this->startApiCall('GetCompletionConfig', $request, $callOptions)->wait(); - } - - /** - * Get which branch is currently default branch set by - * [CatalogService.SetDefaultBranch][google.cloud.retail.v2.CatalogService.SetDefaultBranch] - * method under a specified parent catalog. - * - * The async variant is {@see self::getDefaultBranchAsync()} . - * - * @param GetDefaultBranchRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GetDefaultBranchResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDefaultBranch(GetDefaultBranchRequest $request, array $callOptions = []): GetDefaultBranchResponse - { - return $this->startApiCall('GetDefaultBranch', $request, $callOptions)->wait(); - } - - /** - * Lists all the [Catalog][google.cloud.retail.v2.Catalog]s associated with - * the project. - * - * The async variant is {@see self::listCatalogsAsync()} . - * - * @param ListCatalogsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCatalogs(ListCatalogsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCatalogs', $request, $callOptions); - } - - /** - * Removes the specified - * [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] from the - * [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. - * - * If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to - * remove does not exist, a NOT_FOUND error is returned. - * - * The async variant is {@see self::removeCatalogAttributeAsync()} . - * - * @param RemoveCatalogAttributeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AttributesConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function removeCatalogAttribute(RemoveCatalogAttributeRequest $request, array $callOptions = []): AttributesConfig - { - return $this->startApiCall('RemoveCatalogAttribute', $request, $callOptions)->wait(); - } - - /** - * Replaces the specified - * [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] in the - * [AttributesConfig][google.cloud.retail.v2.AttributesConfig] by updating the - * catalog attribute with the same - * [CatalogAttribute.key][google.cloud.retail.v2.CatalogAttribute.key]. - * - * If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to - * replace does not exist, a NOT_FOUND error is returned. - * - * The async variant is {@see self::replaceCatalogAttributeAsync()} . - * - * @param ReplaceCatalogAttributeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AttributesConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function replaceCatalogAttribute(ReplaceCatalogAttributeRequest $request, array $callOptions = []): AttributesConfig - { - return $this->startApiCall('ReplaceCatalogAttribute', $request, $callOptions)->wait(); - } - - /** - * Set a specified branch id as default branch. API methods such as - * [SearchService.Search][google.cloud.retail.v2.SearchService.Search], - * [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct], - * [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] - * will treat requests using "default_branch" to the actual branch id set as - * default. - * - * For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as - * default, setting - * [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to - * `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent - * to setting - * [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to - * `projects/*/locations/*/catalogs/*/branches/1`. - * - * Using multiple branches can be useful when developers would like - * to have a staging branch to test and verify for future usage. When it - * becomes ready, developers switch on the staging branch using this API while - * keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` - * as [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to - * route the traffic to this staging branch. - * - * CAUTION: If you have live predict/search traffic, switching the default - * branch could potentially cause outages if the ID space of the new branch is - * very different from the old one. - * - * More specifically: - * - * * PredictionService will only return product IDs from branch {newBranch}. - * * SearchService will only return product IDs from branch {newBranch} - * (if branch is not explicitly set). - * * UserEventService will only join events with products from branch - * {newBranch}. - * - * The async variant is {@see self::setDefaultBranchAsync()} . - * - * @param SetDefaultBranchRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function setDefaultBranch(SetDefaultBranchRequest $request, array $callOptions = []): void - { - $this->startApiCall('SetDefaultBranch', $request, $callOptions)->wait(); - } - - /** - * Updates the [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. - * - * The catalog attributes in the request will be updated in the catalog, or - * inserted if they do not exist. Existing catalog attributes not included in - * the request will remain unchanged. Attributes that are assigned to - * products, but do not exist at the catalog level, are always included in the - * response. The product attribute is assigned default values for missing - * catalog attribute fields, e.g., searchable and dynamic facetable options. - * - * The async variant is {@see self::updateAttributesConfigAsync()} . - * - * @param UpdateAttributesConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AttributesConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAttributesConfig(UpdateAttributesConfigRequest $request, array $callOptions = []): AttributesConfig - { - return $this->startApiCall('UpdateAttributesConfig', $request, $callOptions)->wait(); - } - - /** - * Updates the [Catalog][google.cloud.retail.v2.Catalog]s. - * - * The async variant is {@see self::updateCatalogAsync()} . - * - * @param UpdateCatalogRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Catalog - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCatalog(UpdateCatalogRequest $request, array $callOptions = []): Catalog - { - return $this->startApiCall('UpdateCatalog', $request, $callOptions)->wait(); - } - - /** - * Updates the [CompletionConfig][google.cloud.retail.v2.CompletionConfig]s. - * - * The async variant is {@see self::updateCompletionConfigAsync()} . - * - * @param UpdateCompletionConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CompletionConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCompletionConfig(UpdateCompletionConfigRequest $request, array $callOptions = []): CompletionConfig - { - return $this->startApiCall('UpdateCompletionConfig', $request, $callOptions)->wait(); - } -} diff --git a/Retail/src/V2/Client/BaseClient/CompletionServiceBaseClient.php b/Retail/src/V2/Client/BaseClient/CompletionServiceBaseClient.php deleted file mode 100644 index 232c857e1e64..000000000000 --- a/Retail/src/V2/Client/BaseClient/CompletionServiceBaseClient.php +++ /dev/null @@ -1,312 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/completion_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/completion_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/completion_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/completion_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a catalog - * resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * - * @return string The formatted catalog resource. - */ - public static function catalogName(string $project, string $location, string $catalog): string - { - return self::getPathTemplate('catalog')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - catalog: projects/{project}/locations/{location}/catalogs/{catalog} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'retail.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Completes the specified prefix with keyword suggestions. - * - * This feature is only available for users who have Retail Search enabled. - * Enable Retail Search on Cloud Console before using this feature. - * - * The async variant is {@see self::completeQueryAsync()} . - * - * @param CompleteQueryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CompleteQueryResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function completeQuery(CompleteQueryRequest $request, array $callOptions = []): CompleteQueryResponse - { - return $this->startApiCall('CompleteQuery', $request, $callOptions)->wait(); - } - - /** - * Bulk import of processed completion dataset. - * - * Request processing is asynchronous. Partial updating is not supported. - * - * The operation is successfully finished only after the imported suggestions - * are indexed successfully and ready for serving. The process takes hours. - * - * This feature is only available for users who have Retail Search enabled. - * Enable Retail Search on Cloud Console before using this feature. - * - * The async variant is {@see self::importCompletionDataAsync()} . - * - * @param ImportCompletionDataRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function importCompletionData(ImportCompletionDataRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ImportCompletionData', $request, $callOptions)->wait(); - } -} diff --git a/Retail/src/V2/Client/BaseClient/ControlServiceBaseClient.php b/Retail/src/V2/Client/BaseClient/ControlServiceBaseClient.php deleted file mode 100644 index f994f25dfdaf..000000000000 --- a/Retail/src/V2/Client/BaseClient/ControlServiceBaseClient.php +++ /dev/null @@ -1,374 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/control_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/control_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/control_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/control_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a catalog - * resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * - * @return string The formatted catalog resource. - */ - public static function catalogName(string $project, string $location, string $catalog): string - { - return self::getPathTemplate('catalog')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a control - * resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * @param string $control - * - * @return string The formatted control resource. - */ - public static function controlName(string $project, string $location, string $catalog, string $control): string - { - return self::getPathTemplate('control')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - 'control' => $control, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - catalog: projects/{project}/locations/{location}/catalogs/{catalog} - * - control: projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'retail.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a Control. - * - * If the [Control][google.cloud.retail.v2.Control] to create already exists, - * an ALREADY_EXISTS error is returned. - * - * The async variant is {@see self::createControlAsync()} . - * - * @param CreateControlRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Control - * - * @throws ApiException Thrown if the API call fails. - */ - public function createControl(CreateControlRequest $request, array $callOptions = []): Control - { - return $this->startApiCall('CreateControl', $request, $callOptions)->wait(); - } - - /** - * Deletes a Control. - * - * If the [Control][google.cloud.retail.v2.Control] to delete does not exist, - * a NOT_FOUND error is returned. - * - * The async variant is {@see self::deleteControlAsync()} . - * - * @param DeleteControlRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteControl(DeleteControlRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteControl', $request, $callOptions)->wait(); - } - - /** - * Gets a Control. - * - * The async variant is {@see self::getControlAsync()} . - * - * @param GetControlRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Control - * - * @throws ApiException Thrown if the API call fails. - */ - public function getControl(GetControlRequest $request, array $callOptions = []): Control - { - return $this->startApiCall('GetControl', $request, $callOptions)->wait(); - } - - /** - * Lists all Controls by their parent - * [Catalog][google.cloud.retail.v2.Catalog]. - * - * The async variant is {@see self::listControlsAsync()} . - * - * @param ListControlsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listControls(ListControlsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListControls', $request, $callOptions); - } - - /** - * Updates a Control. - * - * [Control][google.cloud.retail.v2.Control] cannot be set to a different - * oneof field, if so an INVALID_ARGUMENT is returned. If the - * [Control][google.cloud.retail.v2.Control] to update does not exist, a - * NOT_FOUND error is returned. - * - * The async variant is {@see self::updateControlAsync()} . - * - * @param UpdateControlRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Control - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateControl(UpdateControlRequest $request, array $callOptions = []): Control - { - return $this->startApiCall('UpdateControl', $request, $callOptions)->wait(); - } -} diff --git a/Retail/src/V2/Client/BaseClient/ModelServiceBaseClient.php b/Retail/src/V2/Client/BaseClient/ModelServiceBaseClient.php deleted file mode 100644 index 4512709c0be6..000000000000 --- a/Retail/src/V2/Client/BaseClient/ModelServiceBaseClient.php +++ /dev/null @@ -1,489 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/model_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/model_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/model_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/model_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a catalog - * resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * - * @return string The formatted catalog resource. - */ - public static function catalogName(string $project, string $location, string $catalog): string - { - return self::getPathTemplate('catalog')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a model - * resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * @param string $model - * - * @return string The formatted model resource. - */ - public static function modelName(string $project, string $location, string $catalog, string $model): string - { - return self::getPathTemplate('model')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - 'model' => $model, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - catalog: projects/{project}/locations/{location}/catalogs/{catalog} - * - model: projects/{project}/locations/{location}/catalogs/{catalog}/models/{model} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'retail.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new model. - * - * The async variant is {@see self::createModelAsync()} . - * - * @param CreateModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createModel(CreateModelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateModel', $request, $callOptions)->wait(); - } - - /** - * Deletes an existing model. - * - * The async variant is {@see self::deleteModelAsync()} . - * - * @param DeleteModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteModel(DeleteModelRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteModel', $request, $callOptions)->wait(); - } - - /** - * Gets a model. - * - * The async variant is {@see self::getModelAsync()} . - * - * @param GetModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Model - * - * @throws ApiException Thrown if the API call fails. - */ - public function getModel(GetModelRequest $request, array $callOptions = []): Model - { - return $this->startApiCall('GetModel', $request, $callOptions)->wait(); - } - - /** - * Lists all the models linked to this event store. - * - * The async variant is {@see self::listModelsAsync()} . - * - * @param ListModelsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listModels(ListModelsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListModels', $request, $callOptions); - } - - /** - * Pauses the training of an existing model. - * - * The async variant is {@see self::pauseModelAsync()} . - * - * @param PauseModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Model - * - * @throws ApiException Thrown if the API call fails. - */ - public function pauseModel(PauseModelRequest $request, array $callOptions = []): Model - { - return $this->startApiCall('PauseModel', $request, $callOptions)->wait(); - } - - /** - * Resumes the training of an existing model. - * - * The async variant is {@see self::resumeModelAsync()} . - * - * @param ResumeModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Model - * - * @throws ApiException Thrown if the API call fails. - */ - public function resumeModel(ResumeModelRequest $request, array $callOptions = []): Model - { - return $this->startApiCall('ResumeModel', $request, $callOptions)->wait(); - } - - /** - * Tunes an existing model. - * - * The async variant is {@see self::tuneModelAsync()} . - * - * @param TuneModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function tuneModel(TuneModelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('TuneModel', $request, $callOptions)->wait(); - } - - /** - * Update of model metadata. Only fields that - * currently can be updated are: `filtering_option` and - * `periodic_tuning_state`. - * If other values are provided, this API method ignores them. - * - * The async variant is {@see self::updateModelAsync()} . - * - * @param UpdateModelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Model - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateModel(UpdateModelRequest $request, array $callOptions = []): Model - { - return $this->startApiCall('UpdateModel', $request, $callOptions)->wait(); - } -} diff --git a/Retail/src/V2/Client/BaseClient/PredictionServiceBaseClient.php b/Retail/src/V2/Client/BaseClient/PredictionServiceBaseClient.php deleted file mode 100644 index 0e99707f7765..000000000000 --- a/Retail/src/V2/Client/BaseClient/PredictionServiceBaseClient.php +++ /dev/null @@ -1,241 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/prediction_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/prediction_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/prediction_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/prediction_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a product - * resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * @param string $branch - * @param string $product - * - * @return string The formatted product resource. - */ - public static function productName(string $project, string $location, string $catalog, string $branch, string $product): string - { - return self::getPathTemplate('product')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - 'branch' => $branch, - 'product' => $product, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - product: projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'retail.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Makes a recommendation prediction. - * - * The async variant is {@see self::predictAsync()} . - * - * @param PredictRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PredictResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function predict(PredictRequest $request, array $callOptions = []): PredictResponse - { - return $this->startApiCall('Predict', $request, $callOptions)->wait(); - } -} diff --git a/Retail/src/V2/Client/BaseClient/ProductServiceBaseClient.php b/Retail/src/V2/Client/BaseClient/ProductServiceBaseClient.php deleted file mode 100644 index 7ce552620396..000000000000 --- a/Retail/src/V2/Client/BaseClient/ProductServiceBaseClient.php +++ /dev/null @@ -1,720 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/product_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/product_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/product_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/product_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a branch - * resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * @param string $branch - * - * @return string The formatted branch resource. - */ - public static function branchName(string $project, string $location, string $catalog, string $branch): string - { - return self::getPathTemplate('branch')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - 'branch' => $branch, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a product - * resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * @param string $branch - * @param string $product - * - * @return string The formatted product resource. - */ - public static function productName(string $project, string $location, string $catalog, string $branch, string $product): string - { - return self::getPathTemplate('product')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - 'branch' => $branch, - 'product' => $product, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - branch: projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch} - * - product: projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'retail.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * It is recommended to use the - * [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] - * method instead of - * [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces]. - * [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] - * achieves the same results but provides more fine-grained control over - * ingesting local inventory data. - * - * Incrementally adds place IDs to - * [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. - * - * This process is asynchronous and does not require the - * [Product][google.cloud.retail.v2.Product] to exist before updating - * fulfillment information. If the request is valid, the update will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, the added place IDs are not immediately manifested in the - * [Product][google.cloud.retail.v2.Product] queried by - * [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] - * or - * [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - * - * The returned [Operation][google.longrunning.Operation]s will be obsolete - * after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * [Operation][google.longrunning.Operation]s associated with the stale - * updates will not be marked as [done][google.longrunning.Operation.done] - * until being obsolete. - * - * The async variant is {@see self::addFulfillmentPlacesAsync()} . - * - * @param AddFulfillmentPlacesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addFulfillmentPlaces(AddFulfillmentPlacesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AddFulfillmentPlaces', $request, $callOptions)->wait(); - } - - /** - * Updates local inventory information for a - * [Product][google.cloud.retail.v2.Product] at a list of places, while - * respecting the last update timestamps of each inventory field. - * - * This process is asynchronous and does not require the - * [Product][google.cloud.retail.v2.Product] to exist before updating - * inventory information. If the request is valid, the update will be enqueued - * and processed downstream. As a consequence, when a response is returned, - * updates are not immediately manifested in the - * [Product][google.cloud.retail.v2.Product] queried by - * [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] - * or - * [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - * - * Local inventory information can only be modified using this method. - * [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] - * and - * [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] - * has no effect on local inventories. - * - * The returned [Operation][google.longrunning.Operation]s will be obsolete - * after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * [Operation][google.longrunning.Operation]s associated with the stale - * updates will not be marked as [done][google.longrunning.Operation.done] - * until being obsolete. - * - * The async variant is {@see self::addLocalInventoriesAsync()} . - * - * @param AddLocalInventoriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addLocalInventories(AddLocalInventoriesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AddLocalInventories', $request, $callOptions)->wait(); - } - - /** - * Creates a [Product][google.cloud.retail.v2.Product]. - * - * The async variant is {@see self::createProductAsync()} . - * - * @param CreateProductRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Product - * - * @throws ApiException Thrown if the API call fails. - */ - public function createProduct(CreateProductRequest $request, array $callOptions = []): Product - { - return $this->startApiCall('CreateProduct', $request, $callOptions)->wait(); - } - - /** - * Deletes a [Product][google.cloud.retail.v2.Product]. - * - * The async variant is {@see self::deleteProductAsync()} . - * - * @param DeleteProductRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteProduct(DeleteProductRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteProduct', $request, $callOptions)->wait(); - } - - /** - * Gets a [Product][google.cloud.retail.v2.Product]. - * - * The async variant is {@see self::getProductAsync()} . - * - * @param GetProductRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Product - * - * @throws ApiException Thrown if the API call fails. - */ - public function getProduct(GetProductRequest $request, array $callOptions = []): Product - { - return $this->startApiCall('GetProduct', $request, $callOptions)->wait(); - } - - /** - * Bulk import of multiple [Product][google.cloud.retail.v2.Product]s. - * - * Request processing may be synchronous. - * Non-existing items are created. - * - * Note that it is possible for a subset of the - * [Product][google.cloud.retail.v2.Product]s to be successfully updated. - * - * The async variant is {@see self::importProductsAsync()} . - * - * @param ImportProductsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function importProducts(ImportProductsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ImportProducts', $request, $callOptions)->wait(); - } - - /** - * Gets a list of [Product][google.cloud.retail.v2.Product]s. - * - * The async variant is {@see self::listProductsAsync()} . - * - * @param ListProductsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listProducts(ListProductsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListProducts', $request, $callOptions); - } - - /** - * It is recommended to use the - * [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] - * method instead of - * [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. - * [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] - * achieves the same results but provides more fine-grained control over - * ingesting local inventory data. - * - * Incrementally removes place IDs from a - * [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. - * - * This process is asynchronous and does not require the - * [Product][google.cloud.retail.v2.Product] to exist before updating - * fulfillment information. If the request is valid, the update will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, the removed place IDs are not immediately manifested in the - * [Product][google.cloud.retail.v2.Product] queried by - * [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] - * or - * [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - * - * The returned [Operation][google.longrunning.Operation]s will be obsolete - * after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * [Operation][google.longrunning.Operation]s associated with the stale - * updates will not be marked as [done][google.longrunning.Operation.done] - * until being obsolete. - * - * The async variant is {@see self::removeFulfillmentPlacesAsync()} . - * - * @param RemoveFulfillmentPlacesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function removeFulfillmentPlaces(RemoveFulfillmentPlacesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RemoveFulfillmentPlaces', $request, $callOptions)->wait(); - } - - /** - * Remove local inventory information for a - * [Product][google.cloud.retail.v2.Product] at a list of places at a removal - * timestamp. - * - * This process is asynchronous. If the request is valid, the removal will be - * enqueued and processed downstream. As a consequence, when a response is - * returned, removals are not immediately manifested in the - * [Product][google.cloud.retail.v2.Product] queried by - * [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] - * or - * [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - * - * Local inventory information can only be removed using this method. - * [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] - * and - * [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] - * has no effect on local inventories. - * - * The returned [Operation][google.longrunning.Operation]s will be obsolete - * after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * [Operation][google.longrunning.Operation]s associated with the stale - * updates will not be marked as [done][google.longrunning.Operation.done] - * until being obsolete. - * - * The async variant is {@see self::removeLocalInventoriesAsync()} . - * - * @param RemoveLocalInventoriesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function removeLocalInventories(RemoveLocalInventoriesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RemoveLocalInventories', $request, $callOptions)->wait(); - } - - /** - * Updates inventory information for a - * [Product][google.cloud.retail.v2.Product] while respecting the last update - * timestamps of each inventory field. - * - * This process is asynchronous and does not require the - * [Product][google.cloud.retail.v2.Product] to exist before updating - * fulfillment information. If the request is valid, the update is enqueued - * and processed downstream. As a consequence, when a response is returned, - * updates are not immediately manifested in the - * [Product][google.cloud.retail.v2.Product] queried by - * [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] - * or - * [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - * - * When inventory is updated with - * [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] - * and - * [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct], - * the specified inventory field value(s) overwrite any existing value(s) - * while ignoring the last update time for this field. Furthermore, the last - * update times for the specified inventory fields are overwritten by the - * times of the - * [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] - * or - * [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] - * request. - * - * If no inventory fields are set in - * [CreateProductRequest.product][google.cloud.retail.v2.CreateProductRequest.product], - * then any pre-existing inventory information for this product is used. - * - * If no inventory fields are set in - * [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask], - * then any existing inventory information is preserved. - * - * Pre-existing inventory information can only be updated with - * [ProductService.SetInventory][google.cloud.retail.v2.ProductService.SetInventory], - * [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces], - * and - * [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. - * - * The returned [Operation][google.longrunning.Operation]s is obsolete after - * one day, and the [GetOperation][google.longrunning.Operations.GetOperation] - * API returns `NOT_FOUND` afterwards. - * - * If conflicting updates are issued, the - * [Operation][google.longrunning.Operation]s associated with the stale - * updates are not marked as [done][google.longrunning.Operation.done] until - * they are obsolete. - * - * The async variant is {@see self::setInventoryAsync()} . - * - * @param SetInventoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function setInventory(SetInventoryRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SetInventory', $request, $callOptions)->wait(); - } - - /** - * Updates a [Product][google.cloud.retail.v2.Product]. - * - * The async variant is {@see self::updateProductAsync()} . - * - * @param UpdateProductRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Product - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateProduct(UpdateProductRequest $request, array $callOptions = []): Product - { - return $this->startApiCall('UpdateProduct', $request, $callOptions)->wait(); - } -} diff --git a/Retail/src/V2/Client/BaseClient/SearchServiceBaseClient.php b/Retail/src/V2/Client/BaseClient/SearchServiceBaseClient.php deleted file mode 100644 index 82ed4ea87ba0..000000000000 --- a/Retail/src/V2/Client/BaseClient/SearchServiceBaseClient.php +++ /dev/null @@ -1,245 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/search_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/search_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/search_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/search_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a branch - * resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * @param string $branch - * - * @return string The formatted branch resource. - */ - public static function branchName(string $project, string $location, string $catalog, string $branch): string - { - return self::getPathTemplate('branch')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - 'branch' => $branch, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - branch: projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'retail.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Performs a search. - * - * This feature is only available for users who have Retail Search enabled. - * Enable Retail Search on Cloud Console before using this feature. - * - * The async variant is {@see self::searchAsync()} . - * - * @param SearchRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function search(SearchRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('Search', $request, $callOptions); - } -} diff --git a/Retail/src/V2/Client/BaseClient/ServingConfigServiceBaseClient.php b/Retail/src/V2/Client/BaseClient/ServingConfigServiceBaseClient.php deleted file mode 100644 index 6bacbb2c7ef9..000000000000 --- a/Retail/src/V2/Client/BaseClient/ServingConfigServiceBaseClient.php +++ /dev/null @@ -1,432 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/serving_config_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/serving_config_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/serving_config_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/serving_config_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a catalog - * resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * - * @return string The formatted catalog resource. - */ - public static function catalogName(string $project, string $location, string $catalog): string - { - return self::getPathTemplate('catalog')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * serving_config resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * @param string $servingConfig - * - * @return string The formatted serving_config resource. - */ - public static function servingConfigName(string $project, string $location, string $catalog, string $servingConfig): string - { - return self::getPathTemplate('servingConfig')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - 'serving_config' => $servingConfig, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - catalog: projects/{project}/locations/{location}/catalogs/{catalog} - * - servingConfig: projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'retail.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Enables a Control on the specified ServingConfig. - * The control is added in the last position of the list of controls - * it belongs to (e.g. if it's a facet spec control it will be applied - * in the last position of servingConfig.facetSpecIds) - * Returns a ALREADY_EXISTS error if the control has already been applied. - * Returns a FAILED_PRECONDITION error if the addition could exceed maximum - * number of control allowed for that type of control. - * - * The async variant is {@see self::addControlAsync()} . - * - * @param AddControlRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ServingConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function addControl(AddControlRequest $request, array $callOptions = []): ServingConfig - { - return $this->startApiCall('AddControl', $request, $callOptions)->wait(); - } - - /** - * Creates a ServingConfig. - * - * A maximum of 100 [ServingConfig][google.cloud.retail.v2.ServingConfig]s are - * allowed in a [Catalog][google.cloud.retail.v2.Catalog], otherwise a - * FAILED_PRECONDITION error is returned. - * - * The async variant is {@see self::createServingConfigAsync()} . - * - * @param CreateServingConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ServingConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function createServingConfig(CreateServingConfigRequest $request, array $callOptions = []): ServingConfig - { - return $this->startApiCall('CreateServingConfig', $request, $callOptions)->wait(); - } - - /** - * Deletes a ServingConfig. - * - * Returns a NotFound error if the ServingConfig does not exist. - * - * The async variant is {@see self::deleteServingConfigAsync()} . - * - * @param DeleteServingConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteServingConfig(DeleteServingConfigRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteServingConfig', $request, $callOptions)->wait(); - } - - /** - * Gets a ServingConfig. - * - * Returns a NotFound error if the ServingConfig does not exist. - * - * The async variant is {@see self::getServingConfigAsync()} . - * - * @param GetServingConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ServingConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getServingConfig(GetServingConfigRequest $request, array $callOptions = []): ServingConfig - { - return $this->startApiCall('GetServingConfig', $request, $callOptions)->wait(); - } - - /** - * Lists all ServingConfigs linked to this catalog. - * - * The async variant is {@see self::listServingConfigsAsync()} . - * - * @param ListServingConfigsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listServingConfigs(ListServingConfigsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListServingConfigs', $request, $callOptions); - } - - /** - * Disables a Control on the specified ServingConfig. - * The control is removed from the ServingConfig. - * Returns a NOT_FOUND error if the Control is not enabled for the - * ServingConfig. - * - * The async variant is {@see self::removeControlAsync()} . - * - * @param RemoveControlRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ServingConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function removeControl(RemoveControlRequest $request, array $callOptions = []): ServingConfig - { - return $this->startApiCall('RemoveControl', $request, $callOptions)->wait(); - } - - /** - * Updates a ServingConfig. - * - * The async variant is {@see self::updateServingConfigAsync()} . - * - * @param UpdateServingConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ServingConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateServingConfig(UpdateServingConfigRequest $request, array $callOptions = []): ServingConfig - { - return $this->startApiCall('UpdateServingConfig', $request, $callOptions)->wait(); - } -} diff --git a/Retail/src/V2/Client/BaseClient/UserEventServiceBaseClient.php b/Retail/src/V2/Client/BaseClient/UserEventServiceBaseClient.php deleted file mode 100644 index 63a1ab1ef5c5..000000000000 --- a/Retail/src/V2/Client/BaseClient/UserEventServiceBaseClient.php +++ /dev/null @@ -1,422 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/user_event_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/user_event_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/user_event_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/user_event_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a catalog - * resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * - * @return string The formatted catalog resource. - */ - public static function catalogName(string $project, string $location, string $catalog): string - { - return self::getPathTemplate('catalog')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a product - * resource. - * - * @param string $project - * @param string $location - * @param string $catalog - * @param string $branch - * @param string $product - * - * @return string The formatted product resource. - */ - public static function productName(string $project, string $location, string $catalog, string $branch, string $product): string - { - return self::getPathTemplate('product')->render([ - 'project' => $project, - 'location' => $location, - 'catalog' => $catalog, - 'branch' => $branch, - 'product' => $product, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - catalog: projects/{project}/locations/{location}/catalogs/{catalog} - * - product: projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'retail.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Writes a single user event from the browser. This uses a GET request to - * due to browser restriction of POST-ing to a 3rd party domain. - * - * This method is used only by the Retail API JavaScript pixel and Google Tag - * Manager. Users should not call this method directly. - * - * The async variant is {@see self::collectUserEventAsync()} . - * - * @param CollectUserEventRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 HttpBody - * - * @throws ApiException Thrown if the API call fails. - */ - public function collectUserEvent(CollectUserEventRequest $request, array $callOptions = []): HttpBody - { - return $this->startApiCall('CollectUserEvent', $request, $callOptions)->wait(); - } - - /** - * Bulk import of User events. Request processing might be - * synchronous. Events that already exist are skipped. - * Use this method for backfilling historical user events. - * - * `Operation.response` is of type `ImportResponse`. Note that it is - * possible for a subset of the items to be successfully inserted. - * `Operation.metadata` is of type `ImportMetadata`. - * - * The async variant is {@see self::importUserEventsAsync()} . - * - * @param ImportUserEventsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function importUserEvents(ImportUserEventsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ImportUserEvents', $request, $callOptions)->wait(); - } - - /** - * Deletes permanently all user events specified by the filter provided. - * Depending on the number of events specified by the filter, this operation - * could take hours or days to complete. To test a filter, use the list - * command first. - * - * The async variant is {@see self::purgeUserEventsAsync()} . - * - * @param PurgeUserEventsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function purgeUserEvents(PurgeUserEventsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('PurgeUserEvents', $request, $callOptions)->wait(); - } - - /** - * Starts a user-event rejoin operation with latest product catalog. Events - * are not annotated with detailed product information for products that are - * missing from the catalog when the user event is ingested. These - * events are stored as unjoined events with limited usage on training and - * serving. You can use this method to start a join operation on specified - * events with the latest version of product catalog. You can also use this - * method to correct events joined with the wrong product catalog. A rejoin - * operation can take hours or days to complete. - * - * The async variant is {@see self::rejoinUserEventsAsync()} . - * - * @param RejoinUserEventsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function rejoinUserEvents(RejoinUserEventsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RejoinUserEvents', $request, $callOptions)->wait(); - } - - /** - * Writes a single user event. - * - * The async variant is {@see self::writeUserEventAsync()} . - * - * @param WriteUserEventRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 UserEvent - * - * @throws ApiException Thrown if the API call fails. - */ - public function writeUserEvent(WriteUserEventRequest $request, array $callOptions = []): UserEvent - { - return $this->startApiCall('WriteUserEvent', $request, $callOptions)->wait(); - } -} diff --git a/Retail/src/V2/Client/CatalogServiceClient.php b/Retail/src/V2/Client/CatalogServiceClient.php index def8c4b1a11c..a63ce42f565f 100644 --- a/Retail/src/V2/Client/CatalogServiceClient.php +++ b/Retail/src/V2/Client/CatalogServiceClient.php @@ -24,17 +24,617 @@ namespace Google\Cloud\Retail\V2\Client; -use Google\Cloud\Retail\V2\Client\BaseClient\CatalogServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Retail\V2\AddCatalogAttributeRequest; +use Google\Cloud\Retail\V2\AttributesConfig; +use Google\Cloud\Retail\V2\Catalog; +use Google\Cloud\Retail\V2\CompletionConfig; +use Google\Cloud\Retail\V2\GetAttributesConfigRequest; +use Google\Cloud\Retail\V2\GetCompletionConfigRequest; +use Google\Cloud\Retail\V2\GetDefaultBranchRequest; +use Google\Cloud\Retail\V2\GetDefaultBranchResponse; +use Google\Cloud\Retail\V2\ListCatalogsRequest; +use Google\Cloud\Retail\V2\RemoveCatalogAttributeRequest; +use Google\Cloud\Retail\V2\ReplaceCatalogAttributeRequest; +use Google\Cloud\Retail\V2\SetDefaultBranchRequest; +use Google\Cloud\Retail\V2\UpdateAttributesConfigRequest; +use Google\Cloud\Retail\V2\UpdateCatalogRequest; +use Google\Cloud\Retail\V2\UpdateCompletionConfigRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for managing catalog configuration. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Retail\V2\CatalogServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface addCatalogAttributeAsync(AddCatalogAttributeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAttributesConfigAsync(GetAttributesConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCompletionConfigAsync(GetCompletionConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDefaultBranchAsync(GetDefaultBranchRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCatalogsAsync(ListCatalogsRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeCatalogAttributeAsync(RemoveCatalogAttributeRequest $request, array $optionalArgs = []) + * @method PromiseInterface replaceCatalogAttributeAsync(ReplaceCatalogAttributeRequest $request, array $optionalArgs = []) + * @method PromiseInterface setDefaultBranchAsync(SetDefaultBranchRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAttributesConfigAsync(UpdateAttributesConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCatalogAsync(UpdateCatalogRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCompletionConfigAsync(UpdateCompletionConfigRequest $request, array $optionalArgs = []) */ -final class CatalogServiceClient extends CatalogServiceBaseClient +final class CatalogServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CatalogServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.retail.v2.CatalogService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'retail.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/catalog_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/catalog_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/catalog_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/catalog_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * attributes_config resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * + * @return string The formatted attributes_config resource. + */ + public static function attributesConfigName(string $project, string $location, string $catalog): string + { + return self::getPathTemplate('attributesConfig')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a branch + * resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * @param string $branch + * + * @return string The formatted branch resource. + */ + public static function branchName(string $project, string $location, string $catalog, string $branch): string + { + return self::getPathTemplate('branch')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + 'branch' => $branch, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a catalog + * resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * + * @return string The formatted catalog resource. + */ + public static function catalogName(string $project, string $location, string $catalog): string + { + return self::getPathTemplate('catalog')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * completion_config resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * + * @return string The formatted completion_config resource. + */ + public static function completionConfigName(string $project, string $location, string $catalog): string + { + return self::getPathTemplate('completionConfig')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - attributesConfig: projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig + * - branch: projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch} + * - catalog: projects/{project}/locations/{location}/catalogs/{catalog} + * - completionConfig: projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'retail.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Adds the specified + * [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to the + * [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. + * + * If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to add + * already exists, an ALREADY_EXISTS error is returned. + * + * The async variant is {@see CatalogServiceClient::addCatalogAttributeAsync()} . + * + * @param AddCatalogAttributeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AttributesConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function addCatalogAttribute(AddCatalogAttributeRequest $request, array $callOptions = []): AttributesConfig + { + return $this->startApiCall('AddCatalogAttribute', $request, $callOptions)->wait(); + } + + /** + * Gets an [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. + * + * The async variant is {@see CatalogServiceClient::getAttributesConfigAsync()} . + * + * @param GetAttributesConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AttributesConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAttributesConfig(GetAttributesConfigRequest $request, array $callOptions = []): AttributesConfig + { + return $this->startApiCall('GetAttributesConfig', $request, $callOptions)->wait(); + } + + /** + * Gets a [CompletionConfig][google.cloud.retail.v2.CompletionConfig]. + * + * The async variant is {@see CatalogServiceClient::getCompletionConfigAsync()} . + * + * @param GetCompletionConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CompletionConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCompletionConfig(GetCompletionConfigRequest $request, array $callOptions = []): CompletionConfig + { + return $this->startApiCall('GetCompletionConfig', $request, $callOptions)->wait(); + } + + /** + * Get which branch is currently default branch set by + * [CatalogService.SetDefaultBranch][google.cloud.retail.v2.CatalogService.SetDefaultBranch] + * method under a specified parent catalog. + * + * The async variant is {@see CatalogServiceClient::getDefaultBranchAsync()} . + * + * @param GetDefaultBranchRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GetDefaultBranchResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDefaultBranch(GetDefaultBranchRequest $request, array $callOptions = []): GetDefaultBranchResponse + { + return $this->startApiCall('GetDefaultBranch', $request, $callOptions)->wait(); + } + + /** + * Lists all the [Catalog][google.cloud.retail.v2.Catalog]s associated with + * the project. + * + * The async variant is {@see CatalogServiceClient::listCatalogsAsync()} . + * + * @param ListCatalogsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCatalogs(ListCatalogsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCatalogs', $request, $callOptions); + } + + /** + * Removes the specified + * [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] from the + * [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. + * + * If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to + * remove does not exist, a NOT_FOUND error is returned. + * + * The async variant is {@see CatalogServiceClient::removeCatalogAttributeAsync()} + * . + * + * @param RemoveCatalogAttributeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AttributesConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeCatalogAttribute(RemoveCatalogAttributeRequest $request, array $callOptions = []): AttributesConfig + { + return $this->startApiCall('RemoveCatalogAttribute', $request, $callOptions)->wait(); + } + + /** + * Replaces the specified + * [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] in the + * [AttributesConfig][google.cloud.retail.v2.AttributesConfig] by updating the + * catalog attribute with the same + * [CatalogAttribute.key][google.cloud.retail.v2.CatalogAttribute.key]. + * + * If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to + * replace does not exist, a NOT_FOUND error is returned. + * + * The async variant is {@see CatalogServiceClient::replaceCatalogAttributeAsync()} + * . + * + * @param ReplaceCatalogAttributeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AttributesConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function replaceCatalogAttribute(ReplaceCatalogAttributeRequest $request, array $callOptions = []): AttributesConfig + { + return $this->startApiCall('ReplaceCatalogAttribute', $request, $callOptions)->wait(); + } + + /** + * Set a specified branch id as default branch. API methods such as + * [SearchService.Search][google.cloud.retail.v2.SearchService.Search], + * [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct], + * [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] + * will treat requests using "default_branch" to the actual branch id set as + * default. + * + * For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as + * default, setting + * [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to + * `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent + * to setting + * [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to + * `projects/*/locations/*/catalogs/*/branches/1`. + * + * Using multiple branches can be useful when developers would like + * to have a staging branch to test and verify for future usage. When it + * becomes ready, developers switch on the staging branch using this API while + * keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` + * as [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to + * route the traffic to this staging branch. + * + * CAUTION: If you have live predict/search traffic, switching the default + * branch could potentially cause outages if the ID space of the new branch is + * very different from the old one. + * + * More specifically: + * + * * PredictionService will only return product IDs from branch {newBranch}. + * * SearchService will only return product IDs from branch {newBranch} + * (if branch is not explicitly set). + * * UserEventService will only join events with products from branch + * {newBranch}. + * + * The async variant is {@see CatalogServiceClient::setDefaultBranchAsync()} . + * + * @param SetDefaultBranchRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function setDefaultBranch(SetDefaultBranchRequest $request, array $callOptions = []): void + { + $this->startApiCall('SetDefaultBranch', $request, $callOptions)->wait(); + } + + /** + * Updates the [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. + * + * The catalog attributes in the request will be updated in the catalog, or + * inserted if they do not exist. Existing catalog attributes not included in + * the request will remain unchanged. Attributes that are assigned to + * products, but do not exist at the catalog level, are always included in the + * response. The product attribute is assigned default values for missing + * catalog attribute fields, e.g., searchable and dynamic facetable options. + * + * The async variant is {@see CatalogServiceClient::updateAttributesConfigAsync()} + * . + * + * @param UpdateAttributesConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AttributesConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAttributesConfig(UpdateAttributesConfigRequest $request, array $callOptions = []): AttributesConfig + { + return $this->startApiCall('UpdateAttributesConfig', $request, $callOptions)->wait(); + } + + /** + * Updates the [Catalog][google.cloud.retail.v2.Catalog]s. + * + * The async variant is {@see CatalogServiceClient::updateCatalogAsync()} . + * + * @param UpdateCatalogRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Catalog + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCatalog(UpdateCatalogRequest $request, array $callOptions = []): Catalog + { + return $this->startApiCall('UpdateCatalog', $request, $callOptions)->wait(); + } + + /** + * Updates the [CompletionConfig][google.cloud.retail.v2.CompletionConfig]s. + * + * The async variant is {@see CatalogServiceClient::updateCompletionConfigAsync()} + * . + * + * @param UpdateCompletionConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CompletionConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCompletionConfig(UpdateCompletionConfigRequest $request, array $callOptions = []): CompletionConfig + { + return $this->startApiCall('UpdateCompletionConfig', $request, $callOptions)->wait(); + } } diff --git a/Retail/src/V2/Client/CompletionServiceClient.php b/Retail/src/V2/Client/CompletionServiceClient.php index 02ae83134548..64dce9f49158 100644 --- a/Retail/src/V2/Client/CompletionServiceClient.php +++ b/Retail/src/V2/Client/CompletionServiceClient.php @@ -24,17 +24,288 @@ namespace Google\Cloud\Retail\V2\Client; -use Google\Cloud\Retail\V2\Client\BaseClient\CompletionServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Retail\V2\CompleteQueryRequest; +use Google\Cloud\Retail\V2\CompleteQueryResponse; +use Google\Cloud\Retail\V2\ImportCompletionDataRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Autocomplete service for retail. * - * This class is currently experimental and may be subject to changes. + * This feature is only available for users who have Retail Search enabled. + * Enable Retail Search on Cloud Console before using this feature. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Retail\V2\CompletionServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface completeQueryAsync(CompleteQueryRequest $request, array $optionalArgs = []) + * @method PromiseInterface importCompletionDataAsync(ImportCompletionDataRequest $request, array $optionalArgs = []) */ -final class CompletionServiceClient extends CompletionServiceBaseClient +final class CompletionServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CompletionServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.retail.v2.CompletionService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'retail.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/completion_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/completion_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/completion_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/completion_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a catalog + * resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * + * @return string The formatted catalog resource. + */ + public static function catalogName(string $project, string $location, string $catalog): string + { + return self::getPathTemplate('catalog')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - catalog: projects/{project}/locations/{location}/catalogs/{catalog} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'retail.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Completes the specified prefix with keyword suggestions. + * + * This feature is only available for users who have Retail Search enabled. + * Enable Retail Search on Cloud Console before using this feature. + * + * The async variant is {@see CompletionServiceClient::completeQueryAsync()} . + * + * @param CompleteQueryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CompleteQueryResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function completeQuery(CompleteQueryRequest $request, array $callOptions = []): CompleteQueryResponse + { + return $this->startApiCall('CompleteQuery', $request, $callOptions)->wait(); + } + + /** + * Bulk import of processed completion dataset. + * + * Request processing is asynchronous. Partial updating is not supported. + * + * The operation is successfully finished only after the imported suggestions + * are indexed successfully and ready for serving. The process takes hours. + * + * This feature is only available for users who have Retail Search enabled. + * Enable Retail Search on Cloud Console before using this feature. + * + * The async variant is {@see CompletionServiceClient::importCompletionDataAsync()} + * . + * + * @param ImportCompletionDataRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importCompletionData(ImportCompletionDataRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportCompletionData', $request, $callOptions)->wait(); + } } diff --git a/Retail/src/V2/Client/ControlServiceClient.php b/Retail/src/V2/Client/ControlServiceClient.php index fbb19c6567df..465ffa79bc04 100644 --- a/Retail/src/V2/Client/ControlServiceClient.php +++ b/Retail/src/V2/Client/ControlServiceClient.php @@ -24,17 +24,349 @@ namespace Google\Cloud\Retail\V2\Client; -use Google\Cloud\Retail\V2\Client\BaseClient\ControlServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Retail\V2\Control; +use Google\Cloud\Retail\V2\CreateControlRequest; +use Google\Cloud\Retail\V2\DeleteControlRequest; +use Google\Cloud\Retail\V2\GetControlRequest; +use Google\Cloud\Retail\V2\ListControlsRequest; +use Google\Cloud\Retail\V2\UpdateControlRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for modifying Control. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Retail\V2\ControlServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createControlAsync(CreateControlRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteControlAsync(DeleteControlRequest $request, array $optionalArgs = []) + * @method PromiseInterface getControlAsync(GetControlRequest $request, array $optionalArgs = []) + * @method PromiseInterface listControlsAsync(ListControlsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateControlAsync(UpdateControlRequest $request, array $optionalArgs = []) */ -final class ControlServiceClient extends ControlServiceBaseClient +final class ControlServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ControlServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.retail.v2.ControlService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'retail.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/control_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/control_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/control_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/control_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a catalog + * resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * + * @return string The formatted catalog resource. + */ + public static function catalogName(string $project, string $location, string $catalog): string + { + return self::getPathTemplate('catalog')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a control + * resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * @param string $control + * + * @return string The formatted control resource. + */ + public static function controlName(string $project, string $location, string $catalog, string $control): string + { + return self::getPathTemplate('control')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + 'control' => $control, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - catalog: projects/{project}/locations/{location}/catalogs/{catalog} + * - control: projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'retail.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a Control. + * + * If the [Control][google.cloud.retail.v2.Control] to create already exists, + * an ALREADY_EXISTS error is returned. + * + * The async variant is {@see ControlServiceClient::createControlAsync()} . + * + * @param CreateControlRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Control + * + * @throws ApiException Thrown if the API call fails. + */ + public function createControl(CreateControlRequest $request, array $callOptions = []): Control + { + return $this->startApiCall('CreateControl', $request, $callOptions)->wait(); + } + + /** + * Deletes a Control. + * + * If the [Control][google.cloud.retail.v2.Control] to delete does not exist, + * a NOT_FOUND error is returned. + * + * The async variant is {@see ControlServiceClient::deleteControlAsync()} . + * + * @param DeleteControlRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteControl(DeleteControlRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteControl', $request, $callOptions)->wait(); + } + + /** + * Gets a Control. + * + * The async variant is {@see ControlServiceClient::getControlAsync()} . + * + * @param GetControlRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Control + * + * @throws ApiException Thrown if the API call fails. + */ + public function getControl(GetControlRequest $request, array $callOptions = []): Control + { + return $this->startApiCall('GetControl', $request, $callOptions)->wait(); + } + + /** + * Lists all Controls by their parent + * [Catalog][google.cloud.retail.v2.Catalog]. + * + * The async variant is {@see ControlServiceClient::listControlsAsync()} . + * + * @param ListControlsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listControls(ListControlsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListControls', $request, $callOptions); + } + + /** + * Updates a Control. + * + * [Control][google.cloud.retail.v2.Control] cannot be set to a different + * oneof field, if so an INVALID_ARGUMENT is returned. If the + * [Control][google.cloud.retail.v2.Control] to update does not exist, a + * NOT_FOUND error is returned. + * + * The async variant is {@see ControlServiceClient::updateControlAsync()} . + * + * @param UpdateControlRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Control + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateControl(UpdateControlRequest $request, array $callOptions = []): Control + { + return $this->startApiCall('UpdateControl', $request, $callOptions)->wait(); + } } diff --git a/Retail/src/V2/Client/ModelServiceClient.php b/Retail/src/V2/Client/ModelServiceClient.php index 1eae8a630da5..35a06e247c1c 100644 --- a/Retail/src/V2/Client/ModelServiceClient.php +++ b/Retail/src/V2/Client/ModelServiceClient.php @@ -24,17 +24,464 @@ namespace Google\Cloud\Retail\V2\Client; -use Google\Cloud\Retail\V2\Client\BaseClient\ModelServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Retail\V2\CreateModelRequest; +use Google\Cloud\Retail\V2\DeleteModelRequest; +use Google\Cloud\Retail\V2\GetModelRequest; +use Google\Cloud\Retail\V2\ListModelsRequest; +use Google\Cloud\Retail\V2\Model; +use Google\Cloud\Retail\V2\PauseModelRequest; +use Google\Cloud\Retail\V2\ResumeModelRequest; +use Google\Cloud\Retail\V2\TuneModelRequest; +use Google\Cloud\Retail\V2\UpdateModelRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for performing CRUD operations on models. + * Recommendation models contain all the metadata necessary to generate a set of + * models for the `Predict()` API. A model is queried + * indirectly via a ServingConfig, which associates a model with a + * given Placement (e.g. Frequently Bought Together on Home Page). * - * This class is currently experimental and may be subject to changes. + * This service allows you to do the following: + * + * * Initiate training of a model. + * * Pause training of an existing model. + * * List all the available models along with their metadata. + * * Control their tuning schedule. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Retail\V2\ModelServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createModelAsync(CreateModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteModelAsync(DeleteModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface getModelAsync(GetModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface listModelsAsync(ListModelsRequest $request, array $optionalArgs = []) + * @method PromiseInterface pauseModelAsync(PauseModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface resumeModelAsync(ResumeModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface tuneModelAsync(TuneModelRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateModelAsync(UpdateModelRequest $request, array $optionalArgs = []) */ -final class ModelServiceClient extends ModelServiceBaseClient +final class ModelServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ModelServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.retail.v2.ModelService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'retail.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/model_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/model_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/model_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/model_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a catalog + * resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * + * @return string The formatted catalog resource. + */ + public static function catalogName(string $project, string $location, string $catalog): string + { + return self::getPathTemplate('catalog')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a model + * resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * @param string $model + * + * @return string The formatted model resource. + */ + public static function modelName(string $project, string $location, string $catalog, string $model): string + { + return self::getPathTemplate('model')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + 'model' => $model, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - catalog: projects/{project}/locations/{location}/catalogs/{catalog} + * - model: projects/{project}/locations/{location}/catalogs/{catalog}/models/{model} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'retail.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new model. + * + * The async variant is {@see ModelServiceClient::createModelAsync()} . + * + * @param CreateModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createModel(CreateModelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateModel', $request, $callOptions)->wait(); + } + + /** + * Deletes an existing model. + * + * The async variant is {@see ModelServiceClient::deleteModelAsync()} . + * + * @param DeleteModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteModel(DeleteModelRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteModel', $request, $callOptions)->wait(); + } + + /** + * Gets a model. + * + * The async variant is {@see ModelServiceClient::getModelAsync()} . + * + * @param GetModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Model + * + * @throws ApiException Thrown if the API call fails. + */ + public function getModel(GetModelRequest $request, array $callOptions = []): Model + { + return $this->startApiCall('GetModel', $request, $callOptions)->wait(); + } + + /** + * Lists all the models linked to this event store. + * + * The async variant is {@see ModelServiceClient::listModelsAsync()} . + * + * @param ListModelsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listModels(ListModelsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListModels', $request, $callOptions); + } + + /** + * Pauses the training of an existing model. + * + * The async variant is {@see ModelServiceClient::pauseModelAsync()} . + * + * @param PauseModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Model + * + * @throws ApiException Thrown if the API call fails. + */ + public function pauseModel(PauseModelRequest $request, array $callOptions = []): Model + { + return $this->startApiCall('PauseModel', $request, $callOptions)->wait(); + } + + /** + * Resumes the training of an existing model. + * + * The async variant is {@see ModelServiceClient::resumeModelAsync()} . + * + * @param ResumeModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Model + * + * @throws ApiException Thrown if the API call fails. + */ + public function resumeModel(ResumeModelRequest $request, array $callOptions = []): Model + { + return $this->startApiCall('ResumeModel', $request, $callOptions)->wait(); + } + + /** + * Tunes an existing model. + * + * The async variant is {@see ModelServiceClient::tuneModelAsync()} . + * + * @param TuneModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function tuneModel(TuneModelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('TuneModel', $request, $callOptions)->wait(); + } + + /** + * Update of model metadata. Only fields that + * currently can be updated are: `filtering_option` and + * `periodic_tuning_state`. + * If other values are provided, this API method ignores them. + * + * The async variant is {@see ModelServiceClient::updateModelAsync()} . + * + * @param UpdateModelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Model + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateModel(UpdateModelRequest $request, array $callOptions = []): Model + { + return $this->startApiCall('UpdateModel', $request, $callOptions)->wait(); + } } diff --git a/Retail/src/V2/Client/PredictionServiceClient.php b/Retail/src/V2/Client/PredictionServiceClient.php index b00bdb2feef5..3c086832336c 100644 --- a/Retail/src/V2/Client/PredictionServiceClient.php +++ b/Retail/src/V2/Client/PredictionServiceClient.php @@ -24,17 +24,216 @@ namespace Google\Cloud\Retail\V2\Client; -use Google\Cloud\Retail\V2\Client\BaseClient\PredictionServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Retail\V2\PredictRequest; +use Google\Cloud\Retail\V2\PredictResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for making recommendation prediction. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Retail\V2\PredictionServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface predictAsync(PredictRequest $request, array $optionalArgs = []) */ -final class PredictionServiceClient extends PredictionServiceBaseClient +final class PredictionServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see PredictionServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.retail.v2.PredictionService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'retail.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/prediction_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/prediction_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/prediction_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/prediction_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a product + * resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * @param string $branch + * @param string $product + * + * @return string The formatted product resource. + */ + public static function productName(string $project, string $location, string $catalog, string $branch, string $product): string + { + return self::getPathTemplate('product')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + 'branch' => $branch, + 'product' => $product, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - product: projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'retail.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Makes a recommendation prediction. + * + * The async variant is {@see PredictionServiceClient::predictAsync()} . + * + * @param PredictRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PredictResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function predict(PredictRequest $request, array $callOptions = []): PredictResponse + { + return $this->startApiCall('Predict', $request, $callOptions)->wait(); + } } diff --git a/Retail/src/V2/Client/ProductServiceClient.php b/Retail/src/V2/Client/ProductServiceClient.php index fe5b19f71093..b24a8db7d0a9 100644 --- a/Retail/src/V2/Client/ProductServiceClient.php +++ b/Retail/src/V2/Client/ProductServiceClient.php @@ -24,17 +24,697 @@ namespace Google\Cloud\Retail\V2\Client; -use Google\Cloud\Retail\V2\Client\BaseClient\ProductServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Retail\V2\AddFulfillmentPlacesRequest; +use Google\Cloud\Retail\V2\AddLocalInventoriesRequest; +use Google\Cloud\Retail\V2\CreateProductRequest; +use Google\Cloud\Retail\V2\DeleteProductRequest; +use Google\Cloud\Retail\V2\GetProductRequest; +use Google\Cloud\Retail\V2\ImportProductsRequest; +use Google\Cloud\Retail\V2\ListProductsRequest; +use Google\Cloud\Retail\V2\Product; +use Google\Cloud\Retail\V2\RemoveFulfillmentPlacesRequest; +use Google\Cloud\Retail\V2\RemoveLocalInventoriesRequest; +use Google\Cloud\Retail\V2\SetInventoryRequest; +use Google\Cloud\Retail\V2\UpdateProductRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for ingesting [Product][google.cloud.retail.v2.Product] information + * of the customer's website. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Retail\V2\ProductServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface addFulfillmentPlacesAsync(AddFulfillmentPlacesRequest $request, array $optionalArgs = []) + * @method PromiseInterface addLocalInventoriesAsync(AddLocalInventoriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface createProductAsync(CreateProductRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteProductAsync(DeleteProductRequest $request, array $optionalArgs = []) + * @method PromiseInterface getProductAsync(GetProductRequest $request, array $optionalArgs = []) + * @method PromiseInterface importProductsAsync(ImportProductsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listProductsAsync(ListProductsRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeFulfillmentPlacesAsync(RemoveFulfillmentPlacesRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeLocalInventoriesAsync(RemoveLocalInventoriesRequest $request, array $optionalArgs = []) + * @method PromiseInterface setInventoryAsync(SetInventoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateProductAsync(UpdateProductRequest $request, array $optionalArgs = []) */ -final class ProductServiceClient extends ProductServiceBaseClient +final class ProductServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ProductServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.retail.v2.ProductService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'retail.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/product_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/product_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/product_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/product_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a branch + * resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * @param string $branch + * + * @return string The formatted branch resource. + */ + public static function branchName(string $project, string $location, string $catalog, string $branch): string + { + return self::getPathTemplate('branch')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + 'branch' => $branch, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a product + * resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * @param string $branch + * @param string $product + * + * @return string The formatted product resource. + */ + public static function productName(string $project, string $location, string $catalog, string $branch, string $product): string + { + return self::getPathTemplate('product')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + 'branch' => $branch, + 'product' => $product, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - branch: projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch} + * - product: projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'retail.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * It is recommended to use the + * [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] + * method instead of + * [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces]. + * [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] + * achieves the same results but provides more fine-grained control over + * ingesting local inventory data. + * + * Incrementally adds place IDs to + * [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. + * + * This process is asynchronous and does not require the + * [Product][google.cloud.retail.v2.Product] to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, the added place IDs are not immediately manifested in the + * [Product][google.cloud.retail.v2.Product] queried by + * [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] + * or + * [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + * + * The returned [Operation][google.longrunning.Operation]s will be obsolete + * after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * [Operation][google.longrunning.Operation]s associated with the stale + * updates will not be marked as [done][google.longrunning.Operation.done] + * until being obsolete. + * + * The async variant is {@see ProductServiceClient::addFulfillmentPlacesAsync()} . + * + * @param AddFulfillmentPlacesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addFulfillmentPlaces(AddFulfillmentPlacesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddFulfillmentPlaces', $request, $callOptions)->wait(); + } + + /** + * Updates local inventory information for a + * [Product][google.cloud.retail.v2.Product] at a list of places, while + * respecting the last update timestamps of each inventory field. + * + * This process is asynchronous and does not require the + * [Product][google.cloud.retail.v2.Product] to exist before updating + * inventory information. If the request is valid, the update will be enqueued + * and processed downstream. As a consequence, when a response is returned, + * updates are not immediately manifested in the + * [Product][google.cloud.retail.v2.Product] queried by + * [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] + * or + * [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + * + * Local inventory information can only be modified using this method. + * [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] + * and + * [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] + * has no effect on local inventories. + * + * The returned [Operation][google.longrunning.Operation]s will be obsolete + * after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * [Operation][google.longrunning.Operation]s associated with the stale + * updates will not be marked as [done][google.longrunning.Operation.done] + * until being obsolete. + * + * The async variant is {@see ProductServiceClient::addLocalInventoriesAsync()} . + * + * @param AddLocalInventoriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addLocalInventories(AddLocalInventoriesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddLocalInventories', $request, $callOptions)->wait(); + } + + /** + * Creates a [Product][google.cloud.retail.v2.Product]. + * + * The async variant is {@see ProductServiceClient::createProductAsync()} . + * + * @param CreateProductRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Product + * + * @throws ApiException Thrown if the API call fails. + */ + public function createProduct(CreateProductRequest $request, array $callOptions = []): Product + { + return $this->startApiCall('CreateProduct', $request, $callOptions)->wait(); + } + + /** + * Deletes a [Product][google.cloud.retail.v2.Product]. + * + * The async variant is {@see ProductServiceClient::deleteProductAsync()} . + * + * @param DeleteProductRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteProduct(DeleteProductRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteProduct', $request, $callOptions)->wait(); + } + + /** + * Gets a [Product][google.cloud.retail.v2.Product]. + * + * The async variant is {@see ProductServiceClient::getProductAsync()} . + * + * @param GetProductRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Product + * + * @throws ApiException Thrown if the API call fails. + */ + public function getProduct(GetProductRequest $request, array $callOptions = []): Product + { + return $this->startApiCall('GetProduct', $request, $callOptions)->wait(); + } + + /** + * Bulk import of multiple [Product][google.cloud.retail.v2.Product]s. + * + * Request processing may be synchronous. + * Non-existing items are created. + * + * Note that it is possible for a subset of the + * [Product][google.cloud.retail.v2.Product]s to be successfully updated. + * + * The async variant is {@see ProductServiceClient::importProductsAsync()} . + * + * @param ImportProductsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importProducts(ImportProductsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportProducts', $request, $callOptions)->wait(); + } + + /** + * Gets a list of [Product][google.cloud.retail.v2.Product]s. + * + * The async variant is {@see ProductServiceClient::listProductsAsync()} . + * + * @param ListProductsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listProducts(ListProductsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListProducts', $request, $callOptions); + } + + /** + * It is recommended to use the + * [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] + * method instead of + * [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. + * [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] + * achieves the same results but provides more fine-grained control over + * ingesting local inventory data. + * + * Incrementally removes place IDs from a + * [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. + * + * This process is asynchronous and does not require the + * [Product][google.cloud.retail.v2.Product] to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, the removed place IDs are not immediately manifested in the + * [Product][google.cloud.retail.v2.Product] queried by + * [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] + * or + * [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + * + * The returned [Operation][google.longrunning.Operation]s will be obsolete + * after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * [Operation][google.longrunning.Operation]s associated with the stale + * updates will not be marked as [done][google.longrunning.Operation.done] + * until being obsolete. + * + * The async variant is {@see ProductServiceClient::removeFulfillmentPlacesAsync()} + * . + * + * @param RemoveFulfillmentPlacesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeFulfillmentPlaces(RemoveFulfillmentPlacesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RemoveFulfillmentPlaces', $request, $callOptions)->wait(); + } + + /** + * Remove local inventory information for a + * [Product][google.cloud.retail.v2.Product] at a list of places at a removal + * timestamp. + * + * This process is asynchronous. If the request is valid, the removal will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, removals are not immediately manifested in the + * [Product][google.cloud.retail.v2.Product] queried by + * [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] + * or + * [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + * + * Local inventory information can only be removed using this method. + * [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] + * and + * [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] + * has no effect on local inventories. + * + * The returned [Operation][google.longrunning.Operation]s will be obsolete + * after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * [Operation][google.longrunning.Operation]s associated with the stale + * updates will not be marked as [done][google.longrunning.Operation.done] + * until being obsolete. + * + * The async variant is {@see ProductServiceClient::removeLocalInventoriesAsync()} + * . + * + * @param RemoveLocalInventoriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeLocalInventories(RemoveLocalInventoriesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RemoveLocalInventories', $request, $callOptions)->wait(); + } + + /** + * Updates inventory information for a + * [Product][google.cloud.retail.v2.Product] while respecting the last update + * timestamps of each inventory field. + * + * This process is asynchronous and does not require the + * [Product][google.cloud.retail.v2.Product] to exist before updating + * fulfillment information. If the request is valid, the update is enqueued + * and processed downstream. As a consequence, when a response is returned, + * updates are not immediately manifested in the + * [Product][google.cloud.retail.v2.Product] queried by + * [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] + * or + * [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + * + * When inventory is updated with + * [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] + * and + * [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct], + * the specified inventory field value(s) overwrite any existing value(s) + * while ignoring the last update time for this field. Furthermore, the last + * update times for the specified inventory fields are overwritten by the + * times of the + * [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] + * or + * [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] + * request. + * + * If no inventory fields are set in + * [CreateProductRequest.product][google.cloud.retail.v2.CreateProductRequest.product], + * then any pre-existing inventory information for this product is used. + * + * If no inventory fields are set in + * [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask], + * then any existing inventory information is preserved. + * + * Pre-existing inventory information can only be updated with + * [ProductService.SetInventory][google.cloud.retail.v2.ProductService.SetInventory], + * [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces], + * and + * [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. + * + * The returned [Operation][google.longrunning.Operation]s is obsolete after + * one day, and the [GetOperation][google.longrunning.Operations.GetOperation] + * API returns `NOT_FOUND` afterwards. + * + * If conflicting updates are issued, the + * [Operation][google.longrunning.Operation]s associated with the stale + * updates are not marked as [done][google.longrunning.Operation.done] until + * they are obsolete. + * + * The async variant is {@see ProductServiceClient::setInventoryAsync()} . + * + * @param SetInventoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function setInventory(SetInventoryRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SetInventory', $request, $callOptions)->wait(); + } + + /** + * Updates a [Product][google.cloud.retail.v2.Product]. + * + * The async variant is {@see ProductServiceClient::updateProductAsync()} . + * + * @param UpdateProductRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Product + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateProduct(UpdateProductRequest $request, array $callOptions = []): Product + { + return $this->startApiCall('UpdateProduct', $request, $callOptions)->wait(); + } } diff --git a/Retail/src/V2/Client/SearchServiceClient.php b/Retail/src/V2/Client/SearchServiceClient.php index 586f65a2c015..7db334b4e8dc 100644 --- a/Retail/src/V2/Client/SearchServiceClient.php +++ b/Retail/src/V2/Client/SearchServiceClient.php @@ -24,17 +24,220 @@ namespace Google\Cloud\Retail\V2\Client; -use Google\Cloud\Retail\V2\Client\BaseClient\SearchServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Retail\V2\SearchRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for search. * - * This class is currently experimental and may be subject to changes. + * This feature is only available for users who have Retail Search enabled. + * Enable Retail Search on Cloud Console before using this feature. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Retail\V2\SearchServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface searchAsync(SearchRequest $request, array $optionalArgs = []) */ -final class SearchServiceClient extends SearchServiceBaseClient +final class SearchServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SearchServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.retail.v2.SearchService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'retail.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/search_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/search_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/search_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/search_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a branch + * resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * @param string $branch + * + * @return string The formatted branch resource. + */ + public static function branchName(string $project, string $location, string $catalog, string $branch): string + { + return self::getPathTemplate('branch')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + 'branch' => $branch, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - branch: projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'retail.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Performs a search. + * + * This feature is only available for users who have Retail Search enabled. + * Enable Retail Search on Cloud Console before using this feature. + * + * The async variant is {@see SearchServiceClient::searchAsync()} . + * + * @param SearchRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function search(SearchRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('Search', $request, $callOptions); + } } diff --git a/Retail/src/V2/Client/ServingConfigServiceClient.php b/Retail/src/V2/Client/ServingConfigServiceClient.php index 321a5bad1f4f..fdb9d3159dc9 100644 --- a/Retail/src/V2/Client/ServingConfigServiceClient.php +++ b/Retail/src/V2/Client/ServingConfigServiceClient.php @@ -24,17 +24,412 @@ namespace Google\Cloud\Retail\V2\Client; -use Google\Cloud\Retail\V2\Client\BaseClient\ServingConfigServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Retail\V2\AddControlRequest; +use Google\Cloud\Retail\V2\CreateServingConfigRequest; +use Google\Cloud\Retail\V2\DeleteServingConfigRequest; +use Google\Cloud\Retail\V2\GetServingConfigRequest; +use Google\Cloud\Retail\V2\ListServingConfigsRequest; +use Google\Cloud\Retail\V2\RemoveControlRequest; +use Google\Cloud\Retail\V2\ServingConfig; +use Google\Cloud\Retail\V2\UpdateServingConfigRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for modifying ServingConfig. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Retail\V2\ServingConfigServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface addControlAsync(AddControlRequest $request, array $optionalArgs = []) + * @method PromiseInterface createServingConfigAsync(CreateServingConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteServingConfigAsync(DeleteServingConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getServingConfigAsync(GetServingConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface listServingConfigsAsync(ListServingConfigsRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeControlAsync(RemoveControlRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateServingConfigAsync(UpdateServingConfigRequest $request, array $optionalArgs = []) */ -final class ServingConfigServiceClient extends ServingConfigServiceBaseClient +final class ServingConfigServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ServingConfigServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.retail.v2.ServingConfigService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'retail.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/serving_config_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/serving_config_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/serving_config_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/serving_config_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a catalog + * resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * + * @return string The formatted catalog resource. + */ + public static function catalogName(string $project, string $location, string $catalog): string + { + return self::getPathTemplate('catalog')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * serving_config resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * @param string $servingConfig + * + * @return string The formatted serving_config resource. + */ + public static function servingConfigName(string $project, string $location, string $catalog, string $servingConfig): string + { + return self::getPathTemplate('servingConfig')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + 'serving_config' => $servingConfig, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - catalog: projects/{project}/locations/{location}/catalogs/{catalog} + * - servingConfig: projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'retail.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Enables a Control on the specified ServingConfig. + * The control is added in the last position of the list of controls + * it belongs to (e.g. if it's a facet spec control it will be applied + * in the last position of servingConfig.facetSpecIds) + * Returns a ALREADY_EXISTS error if the control has already been applied. + * Returns a FAILED_PRECONDITION error if the addition could exceed maximum + * number of control allowed for that type of control. + * + * The async variant is {@see ServingConfigServiceClient::addControlAsync()} . + * + * @param AddControlRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ServingConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function addControl(AddControlRequest $request, array $callOptions = []): ServingConfig + { + return $this->startApiCall('AddControl', $request, $callOptions)->wait(); + } + + /** + * Creates a ServingConfig. + * + * A maximum of 100 [ServingConfig][google.cloud.retail.v2.ServingConfig]s are + * allowed in a [Catalog][google.cloud.retail.v2.Catalog], otherwise a + * FAILED_PRECONDITION error is returned. + * + * The async variant is + * {@see ServingConfigServiceClient::createServingConfigAsync()} . + * + * @param CreateServingConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ServingConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function createServingConfig(CreateServingConfigRequest $request, array $callOptions = []): ServingConfig + { + return $this->startApiCall('CreateServingConfig', $request, $callOptions)->wait(); + } + + /** + * Deletes a ServingConfig. + * + * Returns a NotFound error if the ServingConfig does not exist. + * + * The async variant is + * {@see ServingConfigServiceClient::deleteServingConfigAsync()} . + * + * @param DeleteServingConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteServingConfig(DeleteServingConfigRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteServingConfig', $request, $callOptions)->wait(); + } + + /** + * Gets a ServingConfig. + * + * Returns a NotFound error if the ServingConfig does not exist. + * + * The async variant is {@see ServingConfigServiceClient::getServingConfigAsync()} + * . + * + * @param GetServingConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ServingConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getServingConfig(GetServingConfigRequest $request, array $callOptions = []): ServingConfig + { + return $this->startApiCall('GetServingConfig', $request, $callOptions)->wait(); + } + + /** + * Lists all ServingConfigs linked to this catalog. + * + * The async variant is + * {@see ServingConfigServiceClient::listServingConfigsAsync()} . + * + * @param ListServingConfigsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listServingConfigs(ListServingConfigsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListServingConfigs', $request, $callOptions); + } + + /** + * Disables a Control on the specified ServingConfig. + * The control is removed from the ServingConfig. + * Returns a NOT_FOUND error if the Control is not enabled for the + * ServingConfig. + * + * The async variant is {@see ServingConfigServiceClient::removeControlAsync()} . + * + * @param RemoveControlRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ServingConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeControl(RemoveControlRequest $request, array $callOptions = []): ServingConfig + { + return $this->startApiCall('RemoveControl', $request, $callOptions)->wait(); + } + + /** + * Updates a ServingConfig. + * + * The async variant is + * {@see ServingConfigServiceClient::updateServingConfigAsync()} . + * + * @param UpdateServingConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ServingConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateServingConfig(UpdateServingConfigRequest $request, array $callOptions = []): ServingConfig + { + return $this->startApiCall('UpdateServingConfig', $request, $callOptions)->wait(); + } } diff --git a/Retail/src/V2/Client/UserEventServiceClient.php b/Retail/src/V2/Client/UserEventServiceClient.php index ee5f742f403f..c36185dfd084 100644 --- a/Retail/src/V2/Client/UserEventServiceClient.php +++ b/Retail/src/V2/Client/UserEventServiceClient.php @@ -24,17 +24,397 @@ namespace Google\Cloud\Retail\V2\Client; -use Google\Cloud\Retail\V2\Client\BaseClient\UserEventServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Api\HttpBody; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Retail\V2\CollectUserEventRequest; +use Google\Cloud\Retail\V2\ImportMetadata; +use Google\Cloud\Retail\V2\ImportUserEventsRequest; +use Google\Cloud\Retail\V2\PurgeUserEventsRequest; +use Google\Cloud\Retail\V2\RejoinUserEventsRequest; +use Google\Cloud\Retail\V2\UserEvent; +use Google\Cloud\Retail\V2\WriteUserEventRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for ingesting end user actions on the customer website. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Retail\V2\UserEventServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface collectUserEventAsync(CollectUserEventRequest $request, array $optionalArgs = []) + * @method PromiseInterface importUserEventsAsync(ImportUserEventsRequest $request, array $optionalArgs = []) + * @method PromiseInterface purgeUserEventsAsync(PurgeUserEventsRequest $request, array $optionalArgs = []) + * @method PromiseInterface rejoinUserEventsAsync(RejoinUserEventsRequest $request, array $optionalArgs = []) + * @method PromiseInterface writeUserEventAsync(WriteUserEventRequest $request, array $optionalArgs = []) */ -final class UserEventServiceClient extends UserEventServiceBaseClient +final class UserEventServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see UserEventServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.retail.v2.UserEventService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'retail.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/user_event_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/user_event_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/user_event_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/user_event_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a catalog + * resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * + * @return string The formatted catalog resource. + */ + public static function catalogName(string $project, string $location, string $catalog): string + { + return self::getPathTemplate('catalog')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a product + * resource. + * + * @param string $project + * @param string $location + * @param string $catalog + * @param string $branch + * @param string $product + * + * @return string The formatted product resource. + */ + public static function productName(string $project, string $location, string $catalog, string $branch, string $product): string + { + return self::getPathTemplate('product')->render([ + 'project' => $project, + 'location' => $location, + 'catalog' => $catalog, + 'branch' => $branch, + 'product' => $product, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - catalog: projects/{project}/locations/{location}/catalogs/{catalog} + * - product: projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'retail.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Writes a single user event from the browser. This uses a GET request to + * due to browser restriction of POST-ing to a 3rd party domain. + * + * This method is used only by the Retail API JavaScript pixel and Google Tag + * Manager. Users should not call this method directly. + * + * The async variant is {@see UserEventServiceClient::collectUserEventAsync()} . + * + * @param CollectUserEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 HttpBody + * + * @throws ApiException Thrown if the API call fails. + */ + public function collectUserEvent(CollectUserEventRequest $request, array $callOptions = []): HttpBody + { + return $this->startApiCall('CollectUserEvent', $request, $callOptions)->wait(); + } + + /** + * Bulk import of User events. Request processing might be + * synchronous. Events that already exist are skipped. + * Use this method for backfilling historical user events. + * + * `Operation.response` is of type `ImportResponse`. Note that it is + * possible for a subset of the items to be successfully inserted. + * `Operation.metadata` is of type `ImportMetadata`. + * + * The async variant is {@see UserEventServiceClient::importUserEventsAsync()} . + * + * @param ImportUserEventsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importUserEvents(ImportUserEventsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportUserEvents', $request, $callOptions)->wait(); + } + + /** + * Deletes permanently all user events specified by the filter provided. + * Depending on the number of events specified by the filter, this operation + * could take hours or days to complete. To test a filter, use the list + * command first. + * + * The async variant is {@see UserEventServiceClient::purgeUserEventsAsync()} . + * + * @param PurgeUserEventsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function purgeUserEvents(PurgeUserEventsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('PurgeUserEvents', $request, $callOptions)->wait(); + } + + /** + * Starts a user-event rejoin operation with latest product catalog. Events + * are not annotated with detailed product information for products that are + * missing from the catalog when the user event is ingested. These + * events are stored as unjoined events with limited usage on training and + * serving. You can use this method to start a join operation on specified + * events with the latest version of product catalog. You can also use this + * method to correct events joined with the wrong product catalog. A rejoin + * operation can take hours or days to complete. + * + * The async variant is {@see UserEventServiceClient::rejoinUserEventsAsync()} . + * + * @param RejoinUserEventsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function rejoinUserEvents(RejoinUserEventsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RejoinUserEvents', $request, $callOptions)->wait(); + } + + /** + * Writes a single user event. + * + * The async variant is {@see UserEventServiceClient::writeUserEventAsync()} . + * + * @param WriteUserEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 UserEvent + * + * @throws ApiException Thrown if the API call fails. + */ + public function writeUserEvent(WriteUserEventRequest $request, array $callOptions = []): UserEvent + { + return $this->startApiCall('WriteUserEvent', $request, $callOptions)->wait(); + } } diff --git a/Run/composer.json b/Run/composer.json index ae0e688fa6e8..70fbae334be9 100644 --- a/Run/composer.json +++ b/Run/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Run/src/V2/Client/BaseClient/ExecutionsBaseClient.php b/Run/src/V2/Client/BaseClient/ExecutionsBaseClient.php deleted file mode 100644 index 6efa9f930102..000000000000 --- a/Run/src/V2/Client/BaseClient/ExecutionsBaseClient.php +++ /dev/null @@ -1,381 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/executions_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/executions_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/executions_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/executions_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a execution - * resource. - * - * @param string $project - * @param string $location - * @param string $job - * @param string $execution - * - * @return string The formatted execution resource. - */ - public static function executionName(string $project, string $location, string $job, string $execution): string - { - return self::getPathTemplate('execution')->render([ - 'project' => $project, - 'location' => $location, - 'job' => $job, - 'execution' => $execution, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a job - * resource. - * - * @param string $project - * @param string $location - * @param string $job - * - * @return string The formatted job resource. - */ - public static function jobName(string $project, string $location, string $job): string - { - return self::getPathTemplate('job')->render([ - 'project' => $project, - 'location' => $location, - 'job' => $job, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - execution: projects/{project}/locations/{location}/jobs/{job}/executions/{execution} - * - job: projects/{project}/locations/{location}/jobs/{job} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'run.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Cancels an Execution. - * - * The async variant is {@see self::cancelExecutionAsync()} . - * - * @example samples/V2/ExecutionsClient/cancel_execution.php - * - * @param CancelExecutionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function cancelExecution(CancelExecutionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CancelExecution', $request, $callOptions)->wait(); - } - - /** - * Deletes an Execution. - * - * The async variant is {@see self::deleteExecutionAsync()} . - * - * @example samples/V2/ExecutionsClient/delete_execution.php - * - * @param DeleteExecutionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteExecution(DeleteExecutionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteExecution', $request, $callOptions)->wait(); - } - - /** - * Gets information about an Execution. - * - * The async variant is {@see self::getExecutionAsync()} . - * - * @example samples/V2/ExecutionsClient/get_execution.php - * - * @param GetExecutionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Execution - * - * @throws ApiException Thrown if the API call fails. - */ - public function getExecution(GetExecutionRequest $request, array $callOptions = []): Execution - { - return $this->startApiCall('GetExecution', $request, $callOptions)->wait(); - } - - /** - * Lists Executions from a Job. - * - * The async variant is {@see self::listExecutionsAsync()} . - * - * @example samples/V2/ExecutionsClient/list_executions.php - * - * @param ListExecutionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listExecutions(ListExecutionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListExecutions', $request, $callOptions); - } -} diff --git a/Run/src/V2/Client/BaseClient/JobsBaseClient.php b/Run/src/V2/Client/BaseClient/JobsBaseClient.php deleted file mode 100644 index be771ce6beaa..000000000000 --- a/Run/src/V2/Client/BaseClient/JobsBaseClient.php +++ /dev/null @@ -1,626 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/jobs_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/jobs_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/jobs_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/jobs_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a connector - * resource. - * - * @param string $project - * @param string $location - * @param string $connector - * - * @return string The formatted connector resource. - */ - public static function connectorName(string $project, string $location, string $connector): string - { - return self::getPathTemplate('connector')->render([ - 'project' => $project, - 'location' => $location, - 'connector' => $connector, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a crypto_key - * resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * @param string $cryptoKey - * - * @return string The formatted crypto_key resource. - */ - public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string - { - return self::getPathTemplate('cryptoKey')->render([ - 'project' => $project, - 'location' => $location, - 'key_ring' => $keyRing, - 'crypto_key' => $cryptoKey, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a execution - * resource. - * - * @param string $project - * @param string $location - * @param string $job - * @param string $execution - * - * @return string The formatted execution resource. - */ - public static function executionName(string $project, string $location, string $job, string $execution): string - { - return self::getPathTemplate('execution')->render([ - 'project' => $project, - 'location' => $location, - 'job' => $job, - 'execution' => $execution, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a job - * resource. - * - * @param string $project - * @param string $location - * @param string $job - * - * @return string The formatted job resource. - */ - public static function jobName(string $project, string $location, string $job): string - { - return self::getPathTemplate('job')->render([ - 'project' => $project, - 'location' => $location, - 'job' => $job, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a secret - * resource. - * - * @param string $project - * @param string $secret - * - * @return string The formatted secret resource. - */ - public static function secretName(string $project, string $secret): string - { - return self::getPathTemplate('secret')->render([ - 'project' => $project, - 'secret' => $secret, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * secret_version resource. - * - * @param string $project - * @param string $secret - * @param string $version - * - * @return string The formatted secret_version resource. - */ - public static function secretVersionName(string $project, string $secret, string $version): string - { - return self::getPathTemplate('secretVersion')->render([ - 'project' => $project, - 'secret' => $secret, - 'version' => $version, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - connector: projects/{project}/locations/{location}/connectors/{connector} - * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} - * - execution: projects/{project}/locations/{location}/jobs/{job}/executions/{execution} - * - job: projects/{project}/locations/{location}/jobs/{job} - * - location: projects/{project}/locations/{location} - * - secret: projects/{project}/secrets/{secret} - * - secretVersion: projects/{project}/secrets/{secret}/versions/{version} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'run.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a Job. - * - * The async variant is {@see self::createJobAsync()} . - * - * @example samples/V2/JobsClient/create_job.php - * - * @param CreateJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createJob(CreateJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateJob', $request, $callOptions)->wait(); - } - - /** - * Deletes a Job. - * - * The async variant is {@see self::deleteJobAsync()} . - * - * @example samples/V2/JobsClient/delete_job.php - * - * @param DeleteJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteJob(DeleteJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteJob', $request, $callOptions)->wait(); - } - - /** - * Gets the IAM Access Control policy currently in effect for the given Job. - * This result does not include any inherited policies. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V2/JobsClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets information about a Job. - * - * The async variant is {@see self::getJobAsync()} . - * - * @example samples/V2/JobsClient/get_job.php - * - * @param GetJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - */ - public function getJob(GetJobRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('GetJob', $request, $callOptions)->wait(); - } - - /** - * Lists Jobs. - * - * The async variant is {@see self::listJobsAsync()} . - * - * @example samples/V2/JobsClient/list_jobs.php - * - * @param ListJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listJobs(ListJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListJobs', $request, $callOptions); - } - - /** - * Triggers creation of a new Execution of this Job. - * - * The async variant is {@see self::runJobAsync()} . - * - * @example samples/V2/JobsClient/run_job.php - * - * @param RunJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function runJob(RunJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RunJob', $request, $callOptions)->wait(); - } - - /** - * Sets the IAM Access control policy for the specified Job. Overwrites - * any existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V2/JobsClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified Project. - * - * There are no permissions required for making this API call. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V2/JobsClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Updates a Job. - * - * The async variant is {@see self::updateJobAsync()} . - * - * @example samples/V2/JobsClient/update_job.php - * - * @param UpdateJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateJob(UpdateJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateJob', $request, $callOptions)->wait(); - } -} diff --git a/Run/src/V2/Client/BaseClient/RevisionsBaseClient.php b/Run/src/V2/Client/BaseClient/RevisionsBaseClient.php deleted file mode 100644 index bb32980c23a0..000000000000 --- a/Run/src/V2/Client/BaseClient/RevisionsBaseClient.php +++ /dev/null @@ -1,353 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/revisions_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/revisions_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/revisions_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/revisions_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a revision - * resource. - * - * @param string $project - * @param string $location - * @param string $service - * @param string $revision - * - * @return string The formatted revision resource. - */ - public static function revisionName(string $project, string $location, string $service, string $revision): string - { - return self::getPathTemplate('revision')->render([ - 'project' => $project, - 'location' => $location, - 'service' => $service, - 'revision' => $revision, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a service - * resource. - * - * @param string $project - * @param string $location - * @param string $service - * - * @return string The formatted service resource. - */ - public static function serviceName(string $project, string $location, string $service): string - { - return self::getPathTemplate('service')->render([ - 'project' => $project, - 'location' => $location, - 'service' => $service, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - revision: projects/{project}/locations/{location}/services/{service}/revisions/{revision} - * - service: projects/{project}/locations/{location}/services/{service} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'run.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes a Revision. - * - * The async variant is {@see self::deleteRevisionAsync()} . - * - * @example samples/V2/RevisionsClient/delete_revision.php - * - * @param DeleteRevisionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteRevision(DeleteRevisionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteRevision', $request, $callOptions)->wait(); - } - - /** - * Gets information about a Revision. - * - * The async variant is {@see self::getRevisionAsync()} . - * - * @example samples/V2/RevisionsClient/get_revision.php - * - * @param GetRevisionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Revision - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRevision(GetRevisionRequest $request, array $callOptions = []): Revision - { - return $this->startApiCall('GetRevision', $request, $callOptions)->wait(); - } - - /** - * Lists Revisions from a given Service, or from a given location. - * - * The async variant is {@see self::listRevisionsAsync()} . - * - * @example samples/V2/RevisionsClient/list_revisions.php - * - * @param ListRevisionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listRevisions(ListRevisionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListRevisions', $request, $callOptions); - } -} diff --git a/Run/src/V2/Client/BaseClient/ServicesBaseClient.php b/Run/src/V2/Client/BaseClient/ServicesBaseClient.php deleted file mode 100644 index 820eeb75feca..000000000000 --- a/Run/src/V2/Client/BaseClient/ServicesBaseClient.php +++ /dev/null @@ -1,599 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/services_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/services_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/services_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/services_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a connector - * resource. - * - * @param string $project - * @param string $location - * @param string $connector - * - * @return string The formatted connector resource. - */ - public static function connectorName(string $project, string $location, string $connector): string - { - return self::getPathTemplate('connector')->render([ - 'project' => $project, - 'location' => $location, - 'connector' => $connector, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a crypto_key - * resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * @param string $cryptoKey - * - * @return string The formatted crypto_key resource. - */ - public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string - { - return self::getPathTemplate('cryptoKey')->render([ - 'project' => $project, - 'location' => $location, - 'key_ring' => $keyRing, - 'crypto_key' => $cryptoKey, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a revision - * resource. - * - * @param string $project - * @param string $location - * @param string $service - * @param string $revision - * - * @return string The formatted revision resource. - */ - public static function revisionName(string $project, string $location, string $service, string $revision): string - { - return self::getPathTemplate('revision')->render([ - 'project' => $project, - 'location' => $location, - 'service' => $service, - 'revision' => $revision, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a secret - * resource. - * - * @param string $project - * @param string $secret - * - * @return string The formatted secret resource. - */ - public static function secretName(string $project, string $secret): string - { - return self::getPathTemplate('secret')->render([ - 'project' => $project, - 'secret' => $secret, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * secret_version resource. - * - * @param string $project - * @param string $secret - * @param string $version - * - * @return string The formatted secret_version resource. - */ - public static function secretVersionName(string $project, string $secret, string $version): string - { - return self::getPathTemplate('secretVersion')->render([ - 'project' => $project, - 'secret' => $secret, - 'version' => $version, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a service - * resource. - * - * @param string $project - * @param string $location - * @param string $service - * - * @return string The formatted service resource. - */ - public static function serviceName(string $project, string $location, string $service): string - { - return self::getPathTemplate('service')->render([ - 'project' => $project, - 'location' => $location, - 'service' => $service, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - connector: projects/{project}/locations/{location}/connectors/{connector} - * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} - * - location: projects/{project}/locations/{location} - * - revision: projects/{project}/locations/{location}/services/{service}/revisions/{revision} - * - secret: projects/{project}/secrets/{secret} - * - secretVersion: projects/{project}/secrets/{secret}/versions/{version} - * - service: projects/{project}/locations/{location}/services/{service} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'run.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new Service in a given project and location. - * - * The async variant is {@see self::createServiceAsync()} . - * - * @example samples/V2/ServicesClient/create_service.php - * - * @param CreateServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createService(CreateServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateService', $request, $callOptions)->wait(); - } - - /** - * Deletes a Service. - * This will cause the Service to stop serving traffic and will delete all - * revisions. - * - * The async variant is {@see self::deleteServiceAsync()} . - * - * @example samples/V2/ServicesClient/delete_service.php - * - * @param DeleteServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteService(DeleteServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteService', $request, $callOptions)->wait(); - } - - /** - * Gets the IAM Access Control policy currently in effect for the given - * Cloud Run Service. This result does not include any inherited policies. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V2/ServicesClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets information about a Service. - * - * The async variant is {@see self::getServiceAsync()} . - * - * @example samples/V2/ServicesClient/get_service.php - * - * @param GetServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Service - * - * @throws ApiException Thrown if the API call fails. - */ - public function getService(GetServiceRequest $request, array $callOptions = []): Service - { - return $this->startApiCall('GetService', $request, $callOptions)->wait(); - } - - /** - * Lists Services. - * - * The async variant is {@see self::listServicesAsync()} . - * - * @example samples/V2/ServicesClient/list_services.php - * - * @param ListServicesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listServices(ListServicesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListServices', $request, $callOptions); - } - - /** - * Sets the IAM Access control policy for the specified Service. Overwrites - * any existing policy. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V2/ServicesClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified Project. - * - * There are no permissions required for making this API call. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V2/ServicesClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Updates a Service. - * - * The async variant is {@see self::updateServiceAsync()} . - * - * @example samples/V2/ServicesClient/update_service.php - * - * @param UpdateServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateService(UpdateServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateService', $request, $callOptions)->wait(); - } -} diff --git a/Run/src/V2/Client/BaseClient/TasksBaseClient.php b/Run/src/V2/Client/BaseClient/TasksBaseClient.php deleted file mode 100644 index a0f990886598..000000000000 --- a/Run/src/V2/Client/BaseClient/TasksBaseClient.php +++ /dev/null @@ -1,294 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/tasks_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/tasks_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/tasks_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/tasks_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a execution - * resource. - * - * @param string $project - * @param string $location - * @param string $job - * @param string $execution - * - * @return string The formatted execution resource. - */ - public static function executionName(string $project, string $location, string $job, string $execution): string - { - return self::getPathTemplate('execution')->render([ - 'project' => $project, - 'location' => $location, - 'job' => $job, - 'execution' => $execution, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a task - * resource. - * - * @param string $project - * @param string $location - * @param string $job - * @param string $execution - * @param string $task - * - * @return string The formatted task resource. - */ - public static function taskName(string $project, string $location, string $job, string $execution, string $task): string - { - return self::getPathTemplate('task')->render([ - 'project' => $project, - 'location' => $location, - 'job' => $job, - 'execution' => $execution, - 'task' => $task, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - execution: projects/{project}/locations/{location}/jobs/{job}/executions/{execution} - * - task: projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'run.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Gets information about a Task. - * - * The async variant is {@see self::getTaskAsync()} . - * - * @example samples/V2/TasksClient/get_task.php - * - * @param GetTaskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Task - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTask(GetTaskRequest $request, array $callOptions = []): Task - { - return $this->startApiCall('GetTask', $request, $callOptions)->wait(); - } - - /** - * Lists Tasks from an Execution of a Job. - * - * The async variant is {@see self::listTasksAsync()} . - * - * @example samples/V2/TasksClient/list_tasks.php - * - * @param ListTasksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTasks(ListTasksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTasks', $request, $callOptions); - } -} diff --git a/Run/src/V2/Client/ExecutionsClient.php b/Run/src/V2/Client/ExecutionsClient.php index 7c1c810a6e4b..be24319a72fc 100644 --- a/Run/src/V2/Client/ExecutionsClient.php +++ b/Run/src/V2/Client/ExecutionsClient.php @@ -24,17 +24,356 @@ namespace Google\Cloud\Run\V2\Client; -use Google\Cloud\Run\V2\Client\BaseClient\ExecutionsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Run\V2\CancelExecutionRequest; +use Google\Cloud\Run\V2\DeleteExecutionRequest; +use Google\Cloud\Run\V2\Execution; +use Google\Cloud\Run\V2\GetExecutionRequest; +use Google\Cloud\Run\V2\ListExecutionsRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Cloud Run Execution Control Plane API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Run\V2\ExecutionsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface cancelExecutionAsync(CancelExecutionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteExecutionAsync(DeleteExecutionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getExecutionAsync(GetExecutionRequest $request, array $optionalArgs = []) + * @method PromiseInterface listExecutionsAsync(ListExecutionsRequest $request, array $optionalArgs = []) */ -final class ExecutionsClient extends ExecutionsBaseClient +final class ExecutionsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ExecutionsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.run.v2.Executions'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'run.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/executions_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/executions_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/executions_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/executions_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a execution + * resource. + * + * @param string $project + * @param string $location + * @param string $job + * @param string $execution + * + * @return string The formatted execution resource. + */ + public static function executionName(string $project, string $location, string $job, string $execution): string + { + return self::getPathTemplate('execution')->render([ + 'project' => $project, + 'location' => $location, + 'job' => $job, + 'execution' => $execution, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a job + * resource. + * + * @param string $project + * @param string $location + * @param string $job + * + * @return string The formatted job resource. + */ + public static function jobName(string $project, string $location, string $job): string + { + return self::getPathTemplate('job')->render([ + 'project' => $project, + 'location' => $location, + 'job' => $job, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - execution: projects/{project}/locations/{location}/jobs/{job}/executions/{execution} + * - job: projects/{project}/locations/{location}/jobs/{job} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'run.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Cancels an Execution. + * + * The async variant is {@see ExecutionsClient::cancelExecutionAsync()} . + * + * @example samples/V2/ExecutionsClient/cancel_execution.php + * + * @param CancelExecutionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function cancelExecution(CancelExecutionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CancelExecution', $request, $callOptions)->wait(); + } + + /** + * Deletes an Execution. + * + * The async variant is {@see ExecutionsClient::deleteExecutionAsync()} . + * + * @example samples/V2/ExecutionsClient/delete_execution.php + * + * @param DeleteExecutionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteExecution(DeleteExecutionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteExecution', $request, $callOptions)->wait(); + } + + /** + * Gets information about an Execution. + * + * The async variant is {@see ExecutionsClient::getExecutionAsync()} . + * + * @example samples/V2/ExecutionsClient/get_execution.php + * + * @param GetExecutionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Execution + * + * @throws ApiException Thrown if the API call fails. + */ + public function getExecution(GetExecutionRequest $request, array $callOptions = []): Execution + { + return $this->startApiCall('GetExecution', $request, $callOptions)->wait(); + } + + /** + * Lists Executions from a Job. + * + * The async variant is {@see ExecutionsClient::listExecutionsAsync()} . + * + * @example samples/V2/ExecutionsClient/list_executions.php + * + * @param ListExecutionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listExecutions(ListExecutionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListExecutions', $request, $callOptions); + } } diff --git a/Run/src/V2/Client/JobsClient.php b/Run/src/V2/Client/JobsClient.php index 27c06f610402..493e7c68b787 100644 --- a/Run/src/V2/Client/JobsClient.php +++ b/Run/src/V2/Client/JobsClient.php @@ -24,17 +24,601 @@ namespace Google\Cloud\Run\V2\Client; -use Google\Cloud\Run\V2\Client\BaseClient\JobsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Run\V2\CreateJobRequest; +use Google\Cloud\Run\V2\DeleteJobRequest; +use Google\Cloud\Run\V2\Execution; +use Google\Cloud\Run\V2\GetJobRequest; +use Google\Cloud\Run\V2\Job; +use Google\Cloud\Run\V2\ListJobsRequest; +use Google\Cloud\Run\V2\RunJobRequest; +use Google\Cloud\Run\V2\UpdateJobRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Cloud Run Job Control Plane API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Run\V2\JobsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createJobAsync(CreateJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteJobAsync(DeleteJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getJobAsync(GetJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface listJobsAsync(ListJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface runJobAsync(RunJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateJobAsync(UpdateJobRequest $request, array $optionalArgs = []) */ -final class JobsClient extends JobsBaseClient +final class JobsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see JobsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.run.v2.Jobs'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'run.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/jobs_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/jobs_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/jobs_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/jobs_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a connector + * resource. + * + * @param string $project + * @param string $location + * @param string $connector + * + * @return string The formatted connector resource. + */ + public static function connectorName(string $project, string $location, string $connector): string + { + return self::getPathTemplate('connector')->render([ + 'project' => $project, + 'location' => $location, + 'connector' => $connector, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a crypto_key + * resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * + * @return string The formatted crypto_key resource. + */ + public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string + { + return self::getPathTemplate('cryptoKey')->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'crypto_key' => $cryptoKey, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a execution + * resource. + * + * @param string $project + * @param string $location + * @param string $job + * @param string $execution + * + * @return string The formatted execution resource. + */ + public static function executionName(string $project, string $location, string $job, string $execution): string + { + return self::getPathTemplate('execution')->render([ + 'project' => $project, + 'location' => $location, + 'job' => $job, + 'execution' => $execution, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a job + * resource. + * + * @param string $project + * @param string $location + * @param string $job + * + * @return string The formatted job resource. + */ + public static function jobName(string $project, string $location, string $job): string + { + return self::getPathTemplate('job')->render([ + 'project' => $project, + 'location' => $location, + 'job' => $job, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a secret + * resource. + * + * @param string $project + * @param string $secret + * + * @return string The formatted secret resource. + */ + public static function secretName(string $project, string $secret): string + { + return self::getPathTemplate('secret')->render([ + 'project' => $project, + 'secret' => $secret, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * secret_version resource. + * + * @param string $project + * @param string $secret + * @param string $version + * + * @return string The formatted secret_version resource. + */ + public static function secretVersionName(string $project, string $secret, string $version): string + { + return self::getPathTemplate('secretVersion')->render([ + 'project' => $project, + 'secret' => $secret, + 'version' => $version, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - connector: projects/{project}/locations/{location}/connectors/{connector} + * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} + * - execution: projects/{project}/locations/{location}/jobs/{job}/executions/{execution} + * - job: projects/{project}/locations/{location}/jobs/{job} + * - location: projects/{project}/locations/{location} + * - secret: projects/{project}/secrets/{secret} + * - secretVersion: projects/{project}/secrets/{secret}/versions/{version} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'run.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a Job. + * + * The async variant is {@see JobsClient::createJobAsync()} . + * + * @example samples/V2/JobsClient/create_job.php + * + * @param CreateJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createJob(CreateJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateJob', $request, $callOptions)->wait(); + } + + /** + * Deletes a Job. + * + * The async variant is {@see JobsClient::deleteJobAsync()} . + * + * @example samples/V2/JobsClient/delete_job.php + * + * @param DeleteJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteJob(DeleteJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteJob', $request, $callOptions)->wait(); + } + + /** + * Gets the IAM Access Control policy currently in effect for the given Job. + * This result does not include any inherited policies. + * + * The async variant is {@see JobsClient::getIamPolicyAsync()} . + * + * @example samples/V2/JobsClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets information about a Job. + * + * The async variant is {@see JobsClient::getJobAsync()} . + * + * @example samples/V2/JobsClient/get_job.php + * + * @param GetJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + */ + public function getJob(GetJobRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('GetJob', $request, $callOptions)->wait(); + } + + /** + * Lists Jobs. + * + * The async variant is {@see JobsClient::listJobsAsync()} . + * + * @example samples/V2/JobsClient/list_jobs.php + * + * @param ListJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listJobs(ListJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListJobs', $request, $callOptions); + } + + /** + * Triggers creation of a new Execution of this Job. + * + * The async variant is {@see JobsClient::runJobAsync()} . + * + * @example samples/V2/JobsClient/run_job.php + * + * @param RunJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function runJob(RunJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RunJob', $request, $callOptions)->wait(); + } + + /** + * Sets the IAM Access control policy for the specified Job. Overwrites + * any existing policy. + * + * The async variant is {@see JobsClient::setIamPolicyAsync()} . + * + * @example samples/V2/JobsClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified Project. + * + * There are no permissions required for making this API call. + * + * The async variant is {@see JobsClient::testIamPermissionsAsync()} . + * + * @example samples/V2/JobsClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates a Job. + * + * The async variant is {@see JobsClient::updateJobAsync()} . + * + * @example samples/V2/JobsClient/update_job.php + * + * @param UpdateJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateJob(UpdateJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateJob', $request, $callOptions)->wait(); + } } diff --git a/Run/src/V2/Client/RevisionsClient.php b/Run/src/V2/Client/RevisionsClient.php index f681ad39eb3c..4c1f46af004b 100644 --- a/Run/src/V2/Client/RevisionsClient.php +++ b/Run/src/V2/Client/RevisionsClient.php @@ -24,17 +24,328 @@ namespace Google\Cloud\Run\V2\Client; -use Google\Cloud\Run\V2\Client\BaseClient\RevisionsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Run\V2\DeleteRevisionRequest; +use Google\Cloud\Run\V2\GetRevisionRequest; +use Google\Cloud\Run\V2\ListRevisionsRequest; +use Google\Cloud\Run\V2\Revision; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Cloud Run Revision Control Plane API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Run\V2\RevisionsClient} for the stable implementation * * @experimental + * + * @method PromiseInterface deleteRevisionAsync(DeleteRevisionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRevisionAsync(GetRevisionRequest $request, array $optionalArgs = []) + * @method PromiseInterface listRevisionsAsync(ListRevisionsRequest $request, array $optionalArgs = []) */ -final class RevisionsClient extends RevisionsBaseClient +final class RevisionsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RevisionsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.run.v2.Revisions'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'run.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/revisions_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/revisions_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/revisions_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/revisions_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a revision + * resource. + * + * @param string $project + * @param string $location + * @param string $service + * @param string $revision + * + * @return string The formatted revision resource. + */ + public static function revisionName(string $project, string $location, string $service, string $revision): string + { + return self::getPathTemplate('revision')->render([ + 'project' => $project, + 'location' => $location, + 'service' => $service, + 'revision' => $revision, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a service + * resource. + * + * @param string $project + * @param string $location + * @param string $service + * + * @return string The formatted service resource. + */ + public static function serviceName(string $project, string $location, string $service): string + { + return self::getPathTemplate('service')->render([ + 'project' => $project, + 'location' => $location, + 'service' => $service, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - revision: projects/{project}/locations/{location}/services/{service}/revisions/{revision} + * - service: projects/{project}/locations/{location}/services/{service} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'run.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes a Revision. + * + * The async variant is {@see RevisionsClient::deleteRevisionAsync()} . + * + * @example samples/V2/RevisionsClient/delete_revision.php + * + * @param DeleteRevisionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteRevision(DeleteRevisionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteRevision', $request, $callOptions)->wait(); + } + + /** + * Gets information about a Revision. + * + * The async variant is {@see RevisionsClient::getRevisionAsync()} . + * + * @example samples/V2/RevisionsClient/get_revision.php + * + * @param GetRevisionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Revision + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRevision(GetRevisionRequest $request, array $callOptions = []): Revision + { + return $this->startApiCall('GetRevision', $request, $callOptions)->wait(); + } + + /** + * Lists Revisions from a given Service, or from a given location. + * + * The async variant is {@see RevisionsClient::listRevisionsAsync()} . + * + * @example samples/V2/RevisionsClient/list_revisions.php + * + * @param ListRevisionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listRevisions(ListRevisionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListRevisions', $request, $callOptions); + } } diff --git a/Run/src/V2/Client/ServicesClient.php b/Run/src/V2/Client/ServicesClient.php index e8dbfe2368d1..e5f42726bced 100644 --- a/Run/src/V2/Client/ServicesClient.php +++ b/Run/src/V2/Client/ServicesClient.php @@ -24,17 +24,574 @@ namespace Google\Cloud\Run\V2\Client; -use Google\Cloud\Run\V2\Client\BaseClient\ServicesBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Run\V2\CreateServiceRequest; +use Google\Cloud\Run\V2\DeleteServiceRequest; +use Google\Cloud\Run\V2\GetServiceRequest; +use Google\Cloud\Run\V2\ListServicesRequest; +use Google\Cloud\Run\V2\Service; +use Google\Cloud\Run\V2\UpdateServiceRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Cloud Run Service Control Plane API * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Run\V2\ServicesClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createServiceAsync(CreateServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteServiceAsync(DeleteServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getServiceAsync(GetServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface listServicesAsync(ListServicesRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateServiceAsync(UpdateServiceRequest $request, array $optionalArgs = []) */ -final class ServicesClient extends ServicesBaseClient +final class ServicesClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ServicesBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.run.v2.Services'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'run.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/services_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/services_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/services_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/services_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a connector + * resource. + * + * @param string $project + * @param string $location + * @param string $connector + * + * @return string The formatted connector resource. + */ + public static function connectorName(string $project, string $location, string $connector): string + { + return self::getPathTemplate('connector')->render([ + 'project' => $project, + 'location' => $location, + 'connector' => $connector, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a crypto_key + * resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * + * @return string The formatted crypto_key resource. + */ + public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string + { + return self::getPathTemplate('cryptoKey')->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'crypto_key' => $cryptoKey, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a revision + * resource. + * + * @param string $project + * @param string $location + * @param string $service + * @param string $revision + * + * @return string The formatted revision resource. + */ + public static function revisionName(string $project, string $location, string $service, string $revision): string + { + return self::getPathTemplate('revision')->render([ + 'project' => $project, + 'location' => $location, + 'service' => $service, + 'revision' => $revision, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a secret + * resource. + * + * @param string $project + * @param string $secret + * + * @return string The formatted secret resource. + */ + public static function secretName(string $project, string $secret): string + { + return self::getPathTemplate('secret')->render([ + 'project' => $project, + 'secret' => $secret, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * secret_version resource. + * + * @param string $project + * @param string $secret + * @param string $version + * + * @return string The formatted secret_version resource. + */ + public static function secretVersionName(string $project, string $secret, string $version): string + { + return self::getPathTemplate('secretVersion')->render([ + 'project' => $project, + 'secret' => $secret, + 'version' => $version, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a service + * resource. + * + * @param string $project + * @param string $location + * @param string $service + * + * @return string The formatted service resource. + */ + public static function serviceName(string $project, string $location, string $service): string + { + return self::getPathTemplate('service')->render([ + 'project' => $project, + 'location' => $location, + 'service' => $service, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - connector: projects/{project}/locations/{location}/connectors/{connector} + * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} + * - location: projects/{project}/locations/{location} + * - revision: projects/{project}/locations/{location}/services/{service}/revisions/{revision} + * - secret: projects/{project}/secrets/{secret} + * - secretVersion: projects/{project}/secrets/{secret}/versions/{version} + * - service: projects/{project}/locations/{location}/services/{service} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'run.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new Service in a given project and location. + * + * The async variant is {@see ServicesClient::createServiceAsync()} . + * + * @example samples/V2/ServicesClient/create_service.php + * + * @param CreateServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createService(CreateServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateService', $request, $callOptions)->wait(); + } + + /** + * Deletes a Service. + * This will cause the Service to stop serving traffic and will delete all + * revisions. + * + * The async variant is {@see ServicesClient::deleteServiceAsync()} . + * + * @example samples/V2/ServicesClient/delete_service.php + * + * @param DeleteServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteService(DeleteServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteService', $request, $callOptions)->wait(); + } + + /** + * Gets the IAM Access Control policy currently in effect for the given + * Cloud Run Service. This result does not include any inherited policies. + * + * The async variant is {@see ServicesClient::getIamPolicyAsync()} . + * + * @example samples/V2/ServicesClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets information about a Service. + * + * The async variant is {@see ServicesClient::getServiceAsync()} . + * + * @example samples/V2/ServicesClient/get_service.php + * + * @param GetServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Service + * + * @throws ApiException Thrown if the API call fails. + */ + public function getService(GetServiceRequest $request, array $callOptions = []): Service + { + return $this->startApiCall('GetService', $request, $callOptions)->wait(); + } + + /** + * Lists Services. + * + * The async variant is {@see ServicesClient::listServicesAsync()} . + * + * @example samples/V2/ServicesClient/list_services.php + * + * @param ListServicesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listServices(ListServicesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListServices', $request, $callOptions); + } + + /** + * Sets the IAM Access control policy for the specified Service. Overwrites + * any existing policy. + * + * The async variant is {@see ServicesClient::setIamPolicyAsync()} . + * + * @example samples/V2/ServicesClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified Project. + * + * There are no permissions required for making this API call. + * + * The async variant is {@see ServicesClient::testIamPermissionsAsync()} . + * + * @example samples/V2/ServicesClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates a Service. + * + * The async variant is {@see ServicesClient::updateServiceAsync()} . + * + * @example samples/V2/ServicesClient/update_service.php + * + * @param UpdateServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateService(UpdateServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateService', $request, $callOptions)->wait(); + } } diff --git a/Run/src/V2/Client/TasksClient.php b/Run/src/V2/Client/TasksClient.php index 97e135185a5f..7991cc62efa7 100644 --- a/Run/src/V2/Client/TasksClient.php +++ b/Run/src/V2/Client/TasksClient.php @@ -24,17 +24,269 @@ namespace Google\Cloud\Run\V2\Client; -use Google\Cloud\Run\V2\Client\BaseClient\TasksBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Run\V2\GetTaskRequest; +use Google\Cloud\Run\V2\ListTasksRequest; +use Google\Cloud\Run\V2\Task; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Cloud Run Task Control Plane API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Run\V2\TasksClient} for the stable implementation * * @experimental + * + * @method PromiseInterface getTaskAsync(GetTaskRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTasksAsync(ListTasksRequest $request, array $optionalArgs = []) */ -final class TasksClient extends TasksBaseClient +final class TasksClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TasksBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.run.v2.Tasks'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'run.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/tasks_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/tasks_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/tasks_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/tasks_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a execution + * resource. + * + * @param string $project + * @param string $location + * @param string $job + * @param string $execution + * + * @return string The formatted execution resource. + */ + public static function executionName(string $project, string $location, string $job, string $execution): string + { + return self::getPathTemplate('execution')->render([ + 'project' => $project, + 'location' => $location, + 'job' => $job, + 'execution' => $execution, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a task + * resource. + * + * @param string $project + * @param string $location + * @param string $job + * @param string $execution + * @param string $task + * + * @return string The formatted task resource. + */ + public static function taskName(string $project, string $location, string $job, string $execution, string $task): string + { + return self::getPathTemplate('task')->render([ + 'project' => $project, + 'location' => $location, + 'job' => $job, + 'execution' => $execution, + 'task' => $task, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - execution: projects/{project}/locations/{location}/jobs/{job}/executions/{execution} + * - task: projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'run.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Gets information about a Task. + * + * The async variant is {@see TasksClient::getTaskAsync()} . + * + * @example samples/V2/TasksClient/get_task.php + * + * @param GetTaskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Task + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTask(GetTaskRequest $request, array $callOptions = []): Task + { + return $this->startApiCall('GetTask', $request, $callOptions)->wait(); + } + + /** + * Lists Tasks from an Execution of a Job. + * + * The async variant is {@see TasksClient::listTasksAsync()} . + * + * @example samples/V2/TasksClient/list_tasks.php + * + * @param ListTasksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTasks(ListTasksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTasks', $request, $callOptions); + } } diff --git a/Scheduler/composer.json b/Scheduler/composer.json index c62cff97c3b9..9340a47c563d 100644 --- a/Scheduler/composer.json +++ b/Scheduler/composer.json @@ -24,11 +24,11 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", - "google/cloud-core": "^1.39" + "google/cloud-core": "^1.52.7" }, "suggest": { "ext-grpc": "Enables use of gRPC, a universal high-performance RPC framework created by Google.", diff --git a/Scheduler/src/V1/Client/BaseClient/CloudSchedulerBaseClient.php b/Scheduler/src/V1/Client/BaseClient/CloudSchedulerBaseClient.php deleted file mode 100644 index b3091c0143d7..000000000000 --- a/Scheduler/src/V1/Client/BaseClient/CloudSchedulerBaseClient.php +++ /dev/null @@ -1,537 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/cloud_scheduler_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/cloud_scheduler_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/cloud_scheduler_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/cloud_scheduler_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a job - * resource. - * - * @param string $project - * @param string $location - * @param string $job - * - * @return string The formatted job resource. - */ - public static function jobName(string $project, string $location, string $job): string - { - return self::getPathTemplate('job')->render([ - 'project' => $project, - 'location' => $location, - 'job' => $job, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a topic - * resource. - * - * @param string $project - * @param string $topic - * - * @return string The formatted topic resource. - */ - public static function topicName(string $project, string $topic): string - { - return self::getPathTemplate('topic')->render([ - 'project' => $project, - 'topic' => $topic, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - job: projects/{project}/locations/{location}/jobs/{job} - * - location: projects/{project}/locations/{location} - * - topic: projects/{project}/topics/{topic} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudscheduler.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a job. - * - * The async variant is {@see self::createJobAsync()} . - * - * @param CreateJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - */ - public function createJob(CreateJobRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('CreateJob', $request, $callOptions)->wait(); - } - - /** - * Deletes a job. - * - * The async variant is {@see self::deleteJobAsync()} . - * - * @param DeleteJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteJob(DeleteJobRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteJob', $request, $callOptions)->wait(); - } - - /** - * Gets a job. - * - * The async variant is {@see self::getJobAsync()} . - * - * @param GetJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - */ - public function getJob(GetJobRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('GetJob', $request, $callOptions)->wait(); - } - - /** - * Lists jobs. - * - * The async variant is {@see self::listJobsAsync()} . - * - * @param ListJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listJobs(ListJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListJobs', $request, $callOptions); - } - - /** - * Pauses a job. - * - * If a job is paused then the system will stop executing the job - * until it is re-enabled via - * [ResumeJob][google.cloud.scheduler.v1.CloudScheduler.ResumeJob]. The state - * of the job is stored in [state][google.cloud.scheduler.v1.Job.state]; if - * paused it will be set to - * [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. A job must - * be in [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED] to - * be paused. - * - * The async variant is {@see self::pauseJobAsync()} . - * - * @param PauseJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - */ - public function pauseJob(PauseJobRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('PauseJob', $request, $callOptions)->wait(); - } - - /** - * Resume a job. - * - * This method reenables a job after it has been - * [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. The state - * of a job is stored in [Job.state][google.cloud.scheduler.v1.Job.state]; - * after calling this method it will be set to - * [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED]. A job - * must be in [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED] - * to be resumed. - * - * The async variant is {@see self::resumeJobAsync()} . - * - * @param ResumeJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - */ - public function resumeJob(ResumeJobRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('ResumeJob', $request, $callOptions)->wait(); - } - - /** - * Forces a job to run now. - * - * When this method is called, Cloud Scheduler will dispatch the job, even - * if the job is already running. - * - * The async variant is {@see self::runJobAsync()} . - * - * @param RunJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - */ - public function runJob(RunJobRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('RunJob', $request, $callOptions)->wait(); - } - - /** - * Updates a job. - * - * If successful, the updated [Job][google.cloud.scheduler.v1.Job] is - * returned. If the job does not exist, `NOT_FOUND` is returned. - * - * If UpdateJob does not successfully return, it is possible for the - * job to be in an - * [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1.Job.State.UPDATE_FAILED] - * state. A job in this state may not be executed. If this happens, retry the - * UpdateJob request until a successful response is received. - * - * The async variant is {@see self::updateJobAsync()} . - * - * @param UpdateJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateJob(UpdateJobRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('UpdateJob', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Scheduler/src/V1/Client/CloudSchedulerClient.php b/Scheduler/src/V1/Client/CloudSchedulerClient.php index d0bb8c7b67c3..d2cbb7fb5eb2 100644 --- a/Scheduler/src/V1/Client/CloudSchedulerClient.php +++ b/Scheduler/src/V1/Client/CloudSchedulerClient.php @@ -24,17 +24,512 @@ namespace Google\Cloud\Scheduler\V1\Client; -use Google\Cloud\Scheduler\V1\Client\BaseClient\CloudSchedulerBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\Scheduler\V1\CreateJobRequest; +use Google\Cloud\Scheduler\V1\DeleteJobRequest; +use Google\Cloud\Scheduler\V1\GetJobRequest; +use Google\Cloud\Scheduler\V1\Job; +use Google\Cloud\Scheduler\V1\ListJobsRequest; +use Google\Cloud\Scheduler\V1\PauseJobRequest; +use Google\Cloud\Scheduler\V1\ResumeJobRequest; +use Google\Cloud\Scheduler\V1\RunJobRequest; +use Google\Cloud\Scheduler\V1\UpdateJobRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: The Cloud Scheduler API allows external entities to reliably + * schedule asynchronous jobs. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Scheduler\V1\CloudSchedulerClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createJobAsync(CreateJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteJobAsync(DeleteJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getJobAsync(GetJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface listJobsAsync(ListJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface pauseJobAsync(PauseJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface resumeJobAsync(ResumeJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface runJobAsync(RunJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateJobAsync(UpdateJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class CloudSchedulerClient extends CloudSchedulerBaseClient +final class CloudSchedulerClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CloudSchedulerBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.scheduler.v1.CloudScheduler'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudscheduler.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/cloud_scheduler_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/cloud_scheduler_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/cloud_scheduler_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/cloud_scheduler_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a job + * resource. + * + * @param string $project + * @param string $location + * @param string $job + * + * @return string The formatted job resource. + */ + public static function jobName(string $project, string $location, string $job): string + { + return self::getPathTemplate('job')->render([ + 'project' => $project, + 'location' => $location, + 'job' => $job, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a topic + * resource. + * + * @param string $project + * @param string $topic + * + * @return string The formatted topic resource. + */ + public static function topicName(string $project, string $topic): string + { + return self::getPathTemplate('topic')->render([ + 'project' => $project, + 'topic' => $topic, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - job: projects/{project}/locations/{location}/jobs/{job} + * - location: projects/{project}/locations/{location} + * - topic: projects/{project}/topics/{topic} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudscheduler.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a job. + * + * The async variant is {@see CloudSchedulerClient::createJobAsync()} . + * + * @param CreateJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + */ + public function createJob(CreateJobRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('CreateJob', $request, $callOptions)->wait(); + } + + /** + * Deletes a job. + * + * The async variant is {@see CloudSchedulerClient::deleteJobAsync()} . + * + * @param DeleteJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteJob(DeleteJobRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteJob', $request, $callOptions)->wait(); + } + + /** + * Gets a job. + * + * The async variant is {@see CloudSchedulerClient::getJobAsync()} . + * + * @param GetJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + */ + public function getJob(GetJobRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('GetJob', $request, $callOptions)->wait(); + } + + /** + * Lists jobs. + * + * The async variant is {@see CloudSchedulerClient::listJobsAsync()} . + * + * @param ListJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listJobs(ListJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListJobs', $request, $callOptions); + } + + /** + * Pauses a job. + * + * If a job is paused then the system will stop executing the job + * until it is re-enabled via + * [ResumeJob][google.cloud.scheduler.v1.CloudScheduler.ResumeJob]. The state + * of the job is stored in [state][google.cloud.scheduler.v1.Job.state]; if + * paused it will be set to + * [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. A job must + * be in [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED] to + * be paused. + * + * The async variant is {@see CloudSchedulerClient::pauseJobAsync()} . + * + * @param PauseJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + */ + public function pauseJob(PauseJobRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('PauseJob', $request, $callOptions)->wait(); + } + + /** + * Resume a job. + * + * This method reenables a job after it has been + * [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED]. The state + * of a job is stored in [Job.state][google.cloud.scheduler.v1.Job.state]; + * after calling this method it will be set to + * [Job.State.ENABLED][google.cloud.scheduler.v1.Job.State.ENABLED]. A job + * must be in [Job.State.PAUSED][google.cloud.scheduler.v1.Job.State.PAUSED] + * to be resumed. + * + * The async variant is {@see CloudSchedulerClient::resumeJobAsync()} . + * + * @param ResumeJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + */ + public function resumeJob(ResumeJobRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('ResumeJob', $request, $callOptions)->wait(); + } + + /** + * Forces a job to run now. + * + * When this method is called, Cloud Scheduler will dispatch the job, even + * if the job is already running. + * + * The async variant is {@see CloudSchedulerClient::runJobAsync()} . + * + * @param RunJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + */ + public function runJob(RunJobRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('RunJob', $request, $callOptions)->wait(); + } + + /** + * Updates a job. + * + * If successful, the updated [Job][google.cloud.scheduler.v1.Job] is + * returned. If the job does not exist, `NOT_FOUND` is returned. + * + * If UpdateJob does not successfully return, it is possible for the + * job to be in an + * [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1.Job.State.UPDATE_FAILED] + * state. A job in this state may not be executed. If this happens, retry the + * UpdateJob request until a successful response is received. + * + * The async variant is {@see CloudSchedulerClient::updateJobAsync()} . + * + * @param UpdateJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateJob(UpdateJobRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('UpdateJob', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see CloudSchedulerClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see CloudSchedulerClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/SecretManager/composer.json b/SecretManager/composer.json index 95af1170bab3..9f86ad01b67a 100644 --- a/SecretManager/composer.json +++ b/SecretManager/composer.json @@ -25,7 +25,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/SecretManager/src/V1/Client/BaseClient/SecretManagerServiceBaseClient.php b/SecretManager/src/V1/Client/BaseClient/SecretManagerServiceBaseClient.php deleted file mode 100644 index e6e3648f4c93..000000000000 --- a/SecretManager/src/V1/Client/BaseClient/SecretManagerServiceBaseClient.php +++ /dev/null @@ -1,692 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/secret_manager_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/secret_manager_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/secret_manager_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/secret_manager_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a secret - * resource. - * - * @param string $project - * @param string $secret - * - * @return string The formatted secret resource. - */ - public static function secretName(string $project, string $secret): string - { - return self::getPathTemplate('secret')->render([ - 'project' => $project, - 'secret' => $secret, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * secret_version resource. - * - * @param string $project - * @param string $secret - * @param string $secretVersion - * - * @return string The formatted secret_version resource. - */ - public static function secretVersionName(string $project, string $secret, string $secretVersion): string - { - return self::getPathTemplate('secretVersion')->render([ - 'project' => $project, - 'secret' => $secret, - 'secret_version' => $secretVersion, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a topic - * resource. - * - * @param string $project - * @param string $topic - * - * @return string The formatted topic resource. - */ - public static function topicName(string $project, string $topic): string - { - return self::getPathTemplate('topic')->render([ - 'project' => $project, - 'topic' => $topic, - ]); - } - - /** - * 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} - * - secret: projects/{project}/secrets/{secret} - * - secretVersion: projects/{project}/secrets/{secret}/versions/{secret_version} - * - topic: projects/{project}/topics/{topic} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'secretmanager.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Accesses a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. This call returns the secret data. - * - * `projects/*/secrets/*/versions/latest` is an alias to the most recently - * created [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. - * - * The async variant is {@see self::accessSecretVersionAsync()} . - * - * @param AccessSecretVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AccessSecretVersionResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function accessSecretVersion(AccessSecretVersionRequest $request, array $callOptions = []): AccessSecretVersionResponse - { - return $this->startApiCall('AccessSecretVersion', $request, $callOptions)->wait(); - } - - /** - * Creates a new [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] containing secret data and attaches - * it to an existing [Secret][google.cloud.secretmanager.v1.Secret]. - * - * The async variant is {@see self::addSecretVersionAsync()} . - * - * @param AddSecretVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SecretVersion - * - * @throws ApiException Thrown if the API call fails. - */ - public function addSecretVersion(AddSecretVersionRequest $request, array $callOptions = []): SecretVersion - { - return $this->startApiCall('AddSecretVersion', $request, $callOptions)->wait(); - } - - /** - * Creates a new [Secret][google.cloud.secretmanager.v1.Secret] containing no [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. - * - * The async variant is {@see self::createSecretAsync()} . - * - * @param CreateSecretRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Secret - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSecret(CreateSecretRequest $request, array $callOptions = []): Secret - { - return $this->startApiCall('CreateSecret', $request, $callOptions)->wait(); - } - - /** - * Deletes a [Secret][google.cloud.secretmanager.v1.Secret]. - * - * The async variant is {@see self::deleteSecretAsync()} . - * - * @param DeleteSecretRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSecret(DeleteSecretRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteSecret', $request, $callOptions)->wait(); - } - - /** - * Destroys a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. - * - * Sets the [state][google.cloud.secretmanager.v1.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] to - * [DESTROYED][google.cloud.secretmanager.v1.SecretVersion.State.DESTROYED] and irrevocably destroys the - * secret data. - * - * The async variant is {@see self::destroySecretVersionAsync()} . - * - * @param DestroySecretVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SecretVersion - * - * @throws ApiException Thrown if the API call fails. - */ - public function destroySecretVersion(DestroySecretVersionRequest $request, array $callOptions = []): SecretVersion - { - return $this->startApiCall('DestroySecretVersion', $request, $callOptions)->wait(); - } - - /** - * Disables a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. - * - * Sets the [state][google.cloud.secretmanager.v1.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] to - * [DISABLED][google.cloud.secretmanager.v1.SecretVersion.State.DISABLED]. - * - * The async variant is {@see self::disableSecretVersionAsync()} . - * - * @param DisableSecretVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SecretVersion - * - * @throws ApiException Thrown if the API call fails. - */ - public function disableSecretVersion(DisableSecretVersionRequest $request, array $callOptions = []): SecretVersion - { - return $this->startApiCall('DisableSecretVersion', $request, $callOptions)->wait(); - } - - /** - * Enables a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. - * - * Sets the [state][google.cloud.secretmanager.v1.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] to - * [ENABLED][google.cloud.secretmanager.v1.SecretVersion.State.ENABLED]. - * - * The async variant is {@see self::enableSecretVersionAsync()} . - * - * @param EnableSecretVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SecretVersion - * - * @throws ApiException Thrown if the API call fails. - */ - public function enableSecretVersion(EnableSecretVersionRequest $request, array $callOptions = []): SecretVersion - { - return $this->startApiCall('EnableSecretVersion', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a secret. - * Returns empty policy if the secret exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets metadata for a given [Secret][google.cloud.secretmanager.v1.Secret]. - * - * The async variant is {@see self::getSecretAsync()} . - * - * @param GetSecretRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Secret - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSecret(GetSecretRequest $request, array $callOptions = []): Secret - { - return $this->startApiCall('GetSecret', $request, $callOptions)->wait(); - } - - /** - * Gets metadata for a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. - * - * `projects/*/secrets/*/versions/latest` is an alias to the most recently - * created [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. - * - * The async variant is {@see self::getSecretVersionAsync()} . - * - * @param GetSecretVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SecretVersion - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSecretVersion(GetSecretVersionRequest $request, array $callOptions = []): SecretVersion - { - return $this->startApiCall('GetSecretVersion', $request, $callOptions)->wait(); - } - - /** - * Lists [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. This call does not return secret - * data. - * - * The async variant is {@see self::listSecretVersionsAsync()} . - * - * @param ListSecretVersionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSecretVersions(ListSecretVersionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSecretVersions', $request, $callOptions); - } - - /** - * Lists [Secrets][google.cloud.secretmanager.v1.Secret]. - * - * The async variant is {@see self::listSecretsAsync()} . - * - * @param ListSecretsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSecrets(ListSecretsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSecrets', $request, $callOptions); - } - - /** - * Sets the access control policy on the specified secret. Replaces any - * existing policy. - * - * Permissions on [SecretVersions][google.cloud.secretmanager.v1.SecretVersion] are enforced according - * to the policy set on the associated [Secret][google.cloud.secretmanager.v1.Secret]. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has for the specified secret. - * If the secret does not exist, this call returns an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building permission-aware - * UIs and command-line tools, not for authorization checking. This operation - * may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Updates metadata of an existing [Secret][google.cloud.secretmanager.v1.Secret]. - * - * The async variant is {@see self::updateSecretAsync()} . - * - * @param UpdateSecretRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Secret - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSecret(UpdateSecretRequest $request, array $callOptions = []): Secret - { - return $this->startApiCall('UpdateSecret', $request, $callOptions)->wait(); - } -} diff --git a/SecretManager/src/V1/Client/SecretManagerServiceClient.php b/SecretManager/src/V1/Client/SecretManagerServiceClient.php index bed17fa71429..a392a412591c 100644 --- a/SecretManager/src/V1/Client/SecretManagerServiceClient.php +++ b/SecretManager/src/V1/Client/SecretManagerServiceClient.php @@ -24,17 +24,675 @@ namespace Google\Cloud\SecretManager\V1\Client; -use Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\SecretManager\V1\AccessSecretVersionRequest; +use Google\Cloud\SecretManager\V1\AccessSecretVersionResponse; +use Google\Cloud\SecretManager\V1\AddSecretVersionRequest; +use Google\Cloud\SecretManager\V1\CreateSecretRequest; +use Google\Cloud\SecretManager\V1\DeleteSecretRequest; +use Google\Cloud\SecretManager\V1\DestroySecretVersionRequest; +use Google\Cloud\SecretManager\V1\DisableSecretVersionRequest; +use Google\Cloud\SecretManager\V1\EnableSecretVersionRequest; +use Google\Cloud\SecretManager\V1\GetSecretRequest; +use Google\Cloud\SecretManager\V1\GetSecretVersionRequest; +use Google\Cloud\SecretManager\V1\ListSecretVersionsRequest; +use Google\Cloud\SecretManager\V1\ListSecretsRequest; +use Google\Cloud\SecretManager\V1\Secret; +use Google\Cloud\SecretManager\V1\SecretVersion; +use Google\Cloud\SecretManager\V1\UpdateSecretRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Secret Manager Service * - * This class is currently experimental and may be subject to changes. + * Manages secrets and operations using those secrets. Implements a REST + * model with the following objects: + * + * * [Secret][google.cloud.secretmanager.v1.Secret] + * * [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\SecretManager\V1\SecretManagerServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface accessSecretVersionAsync(AccessSecretVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface addSecretVersionAsync(AddSecretVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSecretAsync(CreateSecretRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSecretAsync(DeleteSecretRequest $request, array $optionalArgs = []) + * @method PromiseInterface destroySecretVersionAsync(DestroySecretVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface disableSecretVersionAsync(DisableSecretVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface enableSecretVersionAsync(EnableSecretVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSecretAsync(GetSecretRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSecretVersionAsync(GetSecretVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSecretVersionsAsync(ListSecretVersionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSecretsAsync(ListSecretsRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSecretAsync(UpdateSecretRequest $request, array $optionalArgs = []) */ -final class SecretManagerServiceClient extends SecretManagerServiceBaseClient +final class SecretManagerServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SecretManagerServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.secretmanager.v1.SecretManagerService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'secretmanager.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/secret_manager_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/secret_manager_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/secret_manager_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/secret_manager_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a secret + * resource. + * + * @param string $project + * @param string $secret + * + * @return string The formatted secret resource. + */ + public static function secretName(string $project, string $secret): string + { + return self::getPathTemplate('secret')->render([ + 'project' => $project, + 'secret' => $secret, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * secret_version resource. + * + * @param string $project + * @param string $secret + * @param string $secretVersion + * + * @return string The formatted secret_version resource. + */ + public static function secretVersionName(string $project, string $secret, string $secretVersion): string + { + return self::getPathTemplate('secretVersion')->render([ + 'project' => $project, + 'secret' => $secret, + 'secret_version' => $secretVersion, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a topic + * resource. + * + * @param string $project + * @param string $topic + * + * @return string The formatted topic resource. + */ + public static function topicName(string $project, string $topic): string + { + return self::getPathTemplate('topic')->render([ + 'project' => $project, + 'topic' => $topic, + ]); + } + + /** + * 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} + * - secret: projects/{project}/secrets/{secret} + * - secretVersion: projects/{project}/secrets/{secret}/versions/{secret_version} + * - topic: projects/{project}/topics/{topic} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'secretmanager.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Accesses a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. This call returns the secret data. + * + * `projects/*/secrets/*/versions/latest` is an alias to the most recently + * created [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. + * + * The async variant is + * {@see SecretManagerServiceClient::accessSecretVersionAsync()} . + * + * @param AccessSecretVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AccessSecretVersionResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function accessSecretVersion(AccessSecretVersionRequest $request, array $callOptions = []): AccessSecretVersionResponse + { + return $this->startApiCall('AccessSecretVersion', $request, $callOptions)->wait(); + } + + /** + * Creates a new [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] containing secret data and attaches + * it to an existing [Secret][google.cloud.secretmanager.v1.Secret]. + * + * The async variant is {@see SecretManagerServiceClient::addSecretVersionAsync()} + * . + * + * @param AddSecretVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SecretVersion + * + * @throws ApiException Thrown if the API call fails. + */ + public function addSecretVersion(AddSecretVersionRequest $request, array $callOptions = []): SecretVersion + { + return $this->startApiCall('AddSecretVersion', $request, $callOptions)->wait(); + } + + /** + * Creates a new [Secret][google.cloud.secretmanager.v1.Secret] containing no [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. + * + * The async variant is {@see SecretManagerServiceClient::createSecretAsync()} . + * + * @param CreateSecretRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Secret + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSecret(CreateSecretRequest $request, array $callOptions = []): Secret + { + return $this->startApiCall('CreateSecret', $request, $callOptions)->wait(); + } + + /** + * Deletes a [Secret][google.cloud.secretmanager.v1.Secret]. + * + * The async variant is {@see SecretManagerServiceClient::deleteSecretAsync()} . + * + * @param DeleteSecretRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSecret(DeleteSecretRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteSecret', $request, $callOptions)->wait(); + } + + /** + * Destroys a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. + * + * Sets the [state][google.cloud.secretmanager.v1.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] to + * [DESTROYED][google.cloud.secretmanager.v1.SecretVersion.State.DESTROYED] and irrevocably destroys the + * secret data. + * + * The async variant is + * {@see SecretManagerServiceClient::destroySecretVersionAsync()} . + * + * @param DestroySecretVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SecretVersion + * + * @throws ApiException Thrown if the API call fails. + */ + public function destroySecretVersion(DestroySecretVersionRequest $request, array $callOptions = []): SecretVersion + { + return $this->startApiCall('DestroySecretVersion', $request, $callOptions)->wait(); + } + + /** + * Disables a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. + * + * Sets the [state][google.cloud.secretmanager.v1.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] to + * [DISABLED][google.cloud.secretmanager.v1.SecretVersion.State.DISABLED]. + * + * The async variant is + * {@see SecretManagerServiceClient::disableSecretVersionAsync()} . + * + * @param DisableSecretVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SecretVersion + * + * @throws ApiException Thrown if the API call fails. + */ + public function disableSecretVersion(DisableSecretVersionRequest $request, array $callOptions = []): SecretVersion + { + return $this->startApiCall('DisableSecretVersion', $request, $callOptions)->wait(); + } + + /** + * Enables a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. + * + * Sets the [state][google.cloud.secretmanager.v1.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] to + * [ENABLED][google.cloud.secretmanager.v1.SecretVersion.State.ENABLED]. + * + * The async variant is + * {@see SecretManagerServiceClient::enableSecretVersionAsync()} . + * + * @param EnableSecretVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SecretVersion + * + * @throws ApiException Thrown if the API call fails. + */ + public function enableSecretVersion(EnableSecretVersionRequest $request, array $callOptions = []): SecretVersion + { + return $this->startApiCall('EnableSecretVersion', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a secret. + * Returns empty policy if the secret exists and does not have a policy set. + * + * The async variant is {@see SecretManagerServiceClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets metadata for a given [Secret][google.cloud.secretmanager.v1.Secret]. + * + * The async variant is {@see SecretManagerServiceClient::getSecretAsync()} . + * + * @param GetSecretRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Secret + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSecret(GetSecretRequest $request, array $callOptions = []): Secret + { + return $this->startApiCall('GetSecret', $request, $callOptions)->wait(); + } + + /** + * Gets metadata for a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. + * + * `projects/*/secrets/*/versions/latest` is an alias to the most recently + * created [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. + * + * The async variant is {@see SecretManagerServiceClient::getSecretVersionAsync()} + * . + * + * @param GetSecretVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SecretVersion + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSecretVersion(GetSecretVersionRequest $request, array $callOptions = []): SecretVersion + { + return $this->startApiCall('GetSecretVersion', $request, $callOptions)->wait(); + } + + /** + * Lists [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. This call does not return secret + * data. + * + * The async variant is + * {@see SecretManagerServiceClient::listSecretVersionsAsync()} . + * + * @param ListSecretVersionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSecretVersions(ListSecretVersionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSecretVersions', $request, $callOptions); + } + + /** + * Lists [Secrets][google.cloud.secretmanager.v1.Secret]. + * + * The async variant is {@see SecretManagerServiceClient::listSecretsAsync()} . + * + * @param ListSecretsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSecrets(ListSecretsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSecrets', $request, $callOptions); + } + + /** + * Sets the access control policy on the specified secret. Replaces any + * existing policy. + * + * Permissions on [SecretVersions][google.cloud.secretmanager.v1.SecretVersion] are enforced according + * to the policy set on the associated [Secret][google.cloud.secretmanager.v1.Secret]. + * + * The async variant is {@see SecretManagerServiceClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has for the specified secret. + * If the secret does not exist, this call returns an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building permission-aware + * UIs and command-line tools, not for authorization checking. This operation + * may "fail open" without warning. + * + * The async variant is + * {@see SecretManagerServiceClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates metadata of an existing [Secret][google.cloud.secretmanager.v1.Secret]. + * + * The async variant is {@see SecretManagerServiceClient::updateSecretAsync()} . + * + * @param UpdateSecretRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Secret + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSecret(UpdateSecretRequest $request, array $callOptions = []): Secret + { + return $this->startApiCall('UpdateSecret', $request, $callOptions)->wait(); + } } diff --git a/SecurityCenter/composer.json b/SecurityCenter/composer.json index 983847c562f3..660b9c16563e 100644 --- a/SecurityCenter/composer.json +++ b/SecurityCenter/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/SecurityCenter/src/V1/Client/BaseClient/SecurityCenterBaseClient.php b/SecurityCenter/src/V1/Client/BaseClient/SecurityCenterBaseClient.php deleted file mode 100644 index f16a23ba3629..000000000000 --- a/SecurityCenter/src/V1/Client/BaseClient/SecurityCenterBaseClient.php +++ /dev/null @@ -1,2418 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/security_center_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/security_center_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/security_center_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/security_center_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * big_query_export resource. - * - * @param string $organization - * @param string $export - * - * @return string The formatted big_query_export resource. - */ - public static function bigQueryExportName(string $organization, string $export): string - { - return self::getPathTemplate('bigQueryExport')->render([ - 'organization' => $organization, - 'export' => $export, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a dlp_job - * resource. - * - * @param string $project - * @param string $dlpJob - * - * @return string The formatted dlp_job resource. - */ - public static function dlpJobName(string $project, string $dlpJob): string - { - return self::getPathTemplate('dlpJob')->render([ - 'project' => $project, - 'dlp_job' => $dlpJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * effective_security_health_analytics_custom_module resource. - * - * @param string $organization - * @param string $effectiveCustomModule - * - * @return string The formatted effective_security_health_analytics_custom_module resource. - */ - public static function effectiveSecurityHealthAnalyticsCustomModuleName(string $organization, string $effectiveCustomModule): string - { - return self::getPathTemplate('effectiveSecurityHealthAnalyticsCustomModule')->render([ - 'organization' => $organization, - 'effective_custom_module' => $effectiveCustomModule, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * external_system resource. - * - * @param string $organization - * @param string $source - * @param string $finding - * @param string $externalsystem - * - * @return string The formatted external_system resource. - */ - public static function externalSystemName(string $organization, string $source, string $finding, string $externalsystem): string - { - return self::getPathTemplate('externalSystem')->render([ - 'organization' => $organization, - 'source' => $source, - 'finding' => $finding, - 'externalsystem' => $externalsystem, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a finding - * resource. - * - * @param string $organization - * @param string $source - * @param string $finding - * - * @return string The formatted finding resource. - */ - public static function findingName(string $organization, string $source, string $finding): string - { - return self::getPathTemplate('finding')->render([ - 'organization' => $organization, - 'source' => $source, - 'finding' => $finding, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a folder - * resource. - * - * @param string $folder - * - * @return string The formatted folder resource. - */ - public static function folderName(string $folder): string - { - return self::getPathTemplate('folder')->render([ - 'folder' => $folder, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_asset_securityMarks resource. - * - * @param string $folder - * @param string $asset - * - * @return string The formatted folder_asset_securityMarks resource. - */ - public static function folderAssetSecurityMarksName(string $folder, string $asset): string - { - return self::getPathTemplate('folderAssetSecurityMarks')->render([ - 'folder' => $folder, - 'asset' => $asset, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_custom_module resource. - * - * @param string $folder - * @param string $customModule - * - * @return string The formatted folder_custom_module resource. - */ - public static function folderCustomModuleName(string $folder, string $customModule): string - { - return self::getPathTemplate('folderCustomModule')->render([ - 'folder' => $folder, - 'custom_module' => $customModule, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_effective_custom_module resource. - * - * @param string $folder - * @param string $effectiveCustomModule - * - * @return string The formatted folder_effective_custom_module resource. - */ - public static function folderEffectiveCustomModuleName(string $folder, string $effectiveCustomModule): string - { - return self::getPathTemplate('folderEffectiveCustomModule')->render([ - 'folder' => $folder, - 'effective_custom_module' => $effectiveCustomModule, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_export resource. - * - * @param string $folder - * @param string $export - * - * @return string The formatted folder_export resource. - */ - public static function folderExportName(string $folder, string $export): string - { - return self::getPathTemplate('folderExport')->render([ - 'folder' => $folder, - 'export' => $export, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_mute_config resource. - * - * @param string $folder - * @param string $muteConfig - * - * @return string The formatted folder_mute_config resource. - */ - public static function folderMuteConfigName(string $folder, string $muteConfig): string - { - return self::getPathTemplate('folderMuteConfig')->render([ - 'folder' => $folder, - 'mute_config' => $muteConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_notification_config resource. - * - * @param string $folder - * @param string $notificationConfig - * - * @return string The formatted folder_notification_config resource. - */ - public static function folderNotificationConfigName(string $folder, string $notificationConfig): string - { - return self::getPathTemplate('folderNotificationConfig')->render([ - 'folder' => $folder, - 'notification_config' => $notificationConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_securityHealthAnalyticsSettings resource. - * - * @param string $folder - * - * @return string The formatted folder_securityHealthAnalyticsSettings resource. - */ - public static function folderSecurityHealthAnalyticsSettingsName(string $folder): string - { - return self::getPathTemplate('folderSecurityHealthAnalyticsSettings')->render([ - 'folder' => $folder, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_source resource. - * - * @param string $folder - * @param string $source - * - * @return string The formatted folder_source resource. - */ - public static function folderSourceName(string $folder, string $source): string - { - return self::getPathTemplate('folderSource')->render([ - 'folder' => $folder, - 'source' => $source, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_source_finding resource. - * - * @param string $folder - * @param string $source - * @param string $finding - * - * @return string The formatted folder_source_finding resource. - */ - public static function folderSourceFindingName(string $folder, string $source, string $finding): string - { - return self::getPathTemplate('folderSourceFinding')->render([ - 'folder' => $folder, - 'source' => $source, - 'finding' => $finding, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_source_finding_externalsystem resource. - * - * @param string $folder - * @param string $source - * @param string $finding - * @param string $externalsystem - * - * @return string The formatted folder_source_finding_externalsystem resource. - */ - public static function folderSourceFindingExternalsystemName(string $folder, string $source, string $finding, string $externalsystem): string - { - return self::getPathTemplate('folderSourceFindingExternalsystem')->render([ - 'folder' => $folder, - 'source' => $source, - 'finding' => $finding, - 'externalsystem' => $externalsystem, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * folder_source_finding_securityMarks resource. - * - * @param string $folder - * @param string $source - * @param string $finding - * - * @return string The formatted folder_source_finding_securityMarks resource. - */ - public static function folderSourceFindingSecurityMarksName(string $folder, string $source, string $finding): string - { - return self::getPathTemplate('folderSourceFindingSecurityMarks')->render([ - 'folder' => $folder, - 'source' => $source, - 'finding' => $finding, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a mute_config - * resource. - * - * @param string $organization - * @param string $muteConfig - * - * @return string The formatted mute_config resource. - */ - public static function muteConfigName(string $organization, string $muteConfig): string - { - return self::getPathTemplate('muteConfig')->render([ - 'organization' => $organization, - 'mute_config' => $muteConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * notification_config resource. - * - * @param string $organization - * @param string $notificationConfig - * - * @return string The formatted notification_config resource. - */ - public static function notificationConfigName(string $organization, string $notificationConfig): string - { - return self::getPathTemplate('notificationConfig')->render([ - 'organization' => $organization, - 'notification_config' => $notificationConfig, - ]); - } - - /** - * 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(string $organization): string - { - return self::getPathTemplate('organization')->render([ - 'organization' => $organization, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_asset_securityMarks resource. - * - * @param string $organization - * @param string $asset - * - * @return string The formatted organization_asset_securityMarks resource. - */ - public static function organizationAssetSecurityMarksName(string $organization, string $asset): string - { - return self::getPathTemplate('organizationAssetSecurityMarks')->render([ - 'organization' => $organization, - 'asset' => $asset, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_custom_module resource. - * - * @param string $organization - * @param string $customModule - * - * @return string The formatted organization_custom_module resource. - */ - public static function organizationCustomModuleName(string $organization, string $customModule): string - { - return self::getPathTemplate('organizationCustomModule')->render([ - 'organization' => $organization, - 'custom_module' => $customModule, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_effective_custom_module resource. - * - * @param string $organization - * @param string $effectiveCustomModule - * - * @return string The formatted organization_effective_custom_module resource. - */ - public static function organizationEffectiveCustomModuleName(string $organization, string $effectiveCustomModule): string - { - return self::getPathTemplate('organizationEffectiveCustomModule')->render([ - 'organization' => $organization, - 'effective_custom_module' => $effectiveCustomModule, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_export resource. - * - * @param string $organization - * @param string $export - * - * @return string The formatted organization_export resource. - */ - public static function organizationExportName(string $organization, string $export): string - { - return self::getPathTemplate('organizationExport')->render([ - 'organization' => $organization, - 'export' => $export, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_mute_config resource. - * - * @param string $organization - * @param string $muteConfig - * - * @return string The formatted organization_mute_config resource. - */ - public static function organizationMuteConfigName(string $organization, string $muteConfig): string - { - return self::getPathTemplate('organizationMuteConfig')->render([ - 'organization' => $organization, - 'mute_config' => $muteConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_notification_config resource. - * - * @param string $organization - * @param string $notificationConfig - * - * @return string The formatted organization_notification_config resource. - */ - public static function organizationNotificationConfigName(string $organization, string $notificationConfig): string - { - return self::getPathTemplate('organizationNotificationConfig')->render([ - 'organization' => $organization, - 'notification_config' => $notificationConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_securityHealthAnalyticsSettings resource. - * - * @param string $organization - * - * @return string The formatted organization_securityHealthAnalyticsSettings resource. - */ - public static function organizationSecurityHealthAnalyticsSettingsName(string $organization): string - { - return self::getPathTemplate('organizationSecurityHealthAnalyticsSettings')->render([ - 'organization' => $organization, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_settings resource. - * - * @param string $organization - * - * @return string The formatted organization_settings resource. - */ - public static function organizationSettingsName(string $organization): string - { - return self::getPathTemplate('organizationSettings')->render([ - 'organization' => $organization, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_source resource. - * - * @param string $organization - * @param string $source - * - * @return string The formatted organization_source resource. - */ - public static function organizationSourceName(string $organization, string $source): string - { - return self::getPathTemplate('organizationSource')->render([ - 'organization' => $organization, - 'source' => $source, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_source_finding resource. - * - * @param string $organization - * @param string $source - * @param string $finding - * - * @return string The formatted organization_source_finding resource. - */ - public static function organizationSourceFindingName(string $organization, string $source, string $finding): string - { - return self::getPathTemplate('organizationSourceFinding')->render([ - 'organization' => $organization, - 'source' => $source, - 'finding' => $finding, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_source_finding_externalsystem resource. - * - * @param string $organization - * @param string $source - * @param string $finding - * @param string $externalsystem - * - * @return string The formatted organization_source_finding_externalsystem resource. - */ - public static function organizationSourceFindingExternalsystemName(string $organization, string $source, string $finding, string $externalsystem): string - { - return self::getPathTemplate('organizationSourceFindingExternalsystem')->render([ - 'organization' => $organization, - 'source' => $source, - 'finding' => $finding, - 'externalsystem' => $externalsystem, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_source_finding_securityMarks resource. - * - * @param string $organization - * @param string $source - * @param string $finding - * - * @return string The formatted organization_source_finding_securityMarks resource. - */ - public static function organizationSourceFindingSecurityMarksName(string $organization, string $source, string $finding): string - { - return self::getPathTemplate('organizationSourceFindingSecurityMarks')->render([ - 'organization' => $organization, - 'source' => $source, - 'finding' => $finding, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_asset_securityMarks resource. - * - * @param string $project - * @param string $asset - * - * @return string The formatted project_asset_securityMarks resource. - */ - public static function projectAssetSecurityMarksName(string $project, string $asset): string - { - return self::getPathTemplate('projectAssetSecurityMarks')->render([ - 'project' => $project, - 'asset' => $asset, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_custom_module resource. - * - * @param string $project - * @param string $customModule - * - * @return string The formatted project_custom_module resource. - */ - public static function projectCustomModuleName(string $project, string $customModule): string - { - return self::getPathTemplate('projectCustomModule')->render([ - 'project' => $project, - 'custom_module' => $customModule, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_dlp_job resource. - * - * @param string $project - * @param string $dlpJob - * - * @return string The formatted project_dlp_job resource. - */ - public static function projectDlpJobName(string $project, string $dlpJob): string - { - return self::getPathTemplate('projectDlpJob')->render([ - 'project' => $project, - 'dlp_job' => $dlpJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_effective_custom_module resource. - * - * @param string $project - * @param string $effectiveCustomModule - * - * @return string The formatted project_effective_custom_module resource. - */ - public static function projectEffectiveCustomModuleName(string $project, string $effectiveCustomModule): string - { - return self::getPathTemplate('projectEffectiveCustomModule')->render([ - 'project' => $project, - 'effective_custom_module' => $effectiveCustomModule, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_export resource. - * - * @param string $project - * @param string $export - * - * @return string The formatted project_export resource. - */ - public static function projectExportName(string $project, string $export): string - { - return self::getPathTemplate('projectExport')->render([ - 'project' => $project, - 'export' => $export, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_dlp_job resource. - * - * @param string $project - * @param string $location - * @param string $dlpJob - * - * @return string The formatted project_location_dlp_job resource. - */ - public static function projectLocationDlpJobName(string $project, string $location, string $dlpJob): string - { - return self::getPathTemplate('projectLocationDlpJob')->render([ - 'project' => $project, - 'location' => $location, - 'dlp_job' => $dlpJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_location_table_profile resource. - * - * @param string $project - * @param string $location - * @param string $tableProfile - * - * @return string The formatted project_location_table_profile resource. - */ - public static function projectLocationTableProfileName(string $project, string $location, string $tableProfile): string - { - return self::getPathTemplate('projectLocationTableProfile')->render([ - 'project' => $project, - 'location' => $location, - 'table_profile' => $tableProfile, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_mute_config resource. - * - * @param string $project - * @param string $muteConfig - * - * @return string The formatted project_mute_config resource. - */ - public static function projectMuteConfigName(string $project, string $muteConfig): string - { - return self::getPathTemplate('projectMuteConfig')->render([ - 'project' => $project, - 'mute_config' => $muteConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_notification_config resource. - * - * @param string $project - * @param string $notificationConfig - * - * @return string The formatted project_notification_config resource. - */ - public static function projectNotificationConfigName(string $project, string $notificationConfig): string - { - return self::getPathTemplate('projectNotificationConfig')->render([ - 'project' => $project, - 'notification_config' => $notificationConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_securityHealthAnalyticsSettings resource. - * - * @param string $project - * - * @return string The formatted project_securityHealthAnalyticsSettings resource. - */ - public static function projectSecurityHealthAnalyticsSettingsName(string $project): string - { - return self::getPathTemplate('projectSecurityHealthAnalyticsSettings')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_source resource. - * - * @param string $project - * @param string $source - * - * @return string The formatted project_source resource. - */ - public static function projectSourceName(string $project, string $source): string - { - return self::getPathTemplate('projectSource')->render([ - 'project' => $project, - 'source' => $source, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_source_finding resource. - * - * @param string $project - * @param string $source - * @param string $finding - * - * @return string The formatted project_source_finding resource. - */ - public static function projectSourceFindingName(string $project, string $source, string $finding): string - { - return self::getPathTemplate('projectSourceFinding')->render([ - 'project' => $project, - 'source' => $source, - 'finding' => $finding, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_source_finding_externalsystem resource. - * - * @param string $project - * @param string $source - * @param string $finding - * @param string $externalsystem - * - * @return string The formatted project_source_finding_externalsystem resource. - */ - public static function projectSourceFindingExternalsystemName(string $project, string $source, string $finding, string $externalsystem): string - { - return self::getPathTemplate('projectSourceFindingExternalsystem')->render([ - 'project' => $project, - 'source' => $source, - 'finding' => $finding, - 'externalsystem' => $externalsystem, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_source_finding_securityMarks resource. - * - * @param string $project - * @param string $source - * @param string $finding - * - * @return string The formatted project_source_finding_securityMarks resource. - */ - public static function projectSourceFindingSecurityMarksName(string $project, string $source, string $finding): string - { - return self::getPathTemplate('projectSourceFindingSecurityMarks')->render([ - 'project' => $project, - 'source' => $source, - 'finding' => $finding, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_table_profile resource. - * - * @param string $project - * @param string $tableProfile - * - * @return string The formatted project_table_profile resource. - */ - public static function projectTableProfileName(string $project, string $tableProfile): string - { - return self::getPathTemplate('projectTableProfile')->render([ - 'project' => $project, - 'table_profile' => $tableProfile, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * security_health_analytics_custom_module resource. - * - * @param string $organization - * @param string $customModule - * - * @return string The formatted security_health_analytics_custom_module resource. - */ - public static function securityHealthAnalyticsCustomModuleName(string $organization, string $customModule): string - { - return self::getPathTemplate('securityHealthAnalyticsCustomModule')->render([ - 'organization' => $organization, - 'custom_module' => $customModule, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * security_health_analytics_settings resource. - * - * @param string $organization - * - * @return string The formatted security_health_analytics_settings resource. - */ - public static function securityHealthAnalyticsSettingsName(string $organization): string - { - return self::getPathTemplate('securityHealthAnalyticsSettings')->render([ - 'organization' => $organization, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * security_marks resource. - * - * @param string $organization - * @param string $asset - * - * @return string The formatted security_marks resource. - */ - public static function securityMarksName(string $organization, string $asset): string - { - return self::getPathTemplate('securityMarks')->render([ - 'organization' => $organization, - 'asset' => $asset, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a source - * resource. - * - * @param string $organization - * @param string $source - * - * @return string The formatted source resource. - */ - public static function sourceName(string $organization, string $source): string - { - return self::getPathTemplate('source')->render([ - 'organization' => $organization, - 'source' => $source, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * table_data_profile resource. - * - * @param string $project - * @param string $tableProfile - * - * @return string The formatted table_data_profile resource. - */ - public static function tableDataProfileName(string $project, string $tableProfile): string - { - return self::getPathTemplate('tableDataProfile')->render([ - 'project' => $project, - 'table_profile' => $tableProfile, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a topic - * resource. - * - * @param string $project - * @param string $topic - * - * @return string The formatted topic resource. - */ - public static function topicName(string $project, string $topic): string - { - return self::getPathTemplate('topic')->render([ - 'project' => $project, - 'topic' => $topic, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - bigQueryExport: organizations/{organization}/bigQueryExports/{export} - * - dlpJob: projects/{project}/dlpJobs/{dlp_job} - * - effectiveSecurityHealthAnalyticsCustomModule: organizations/{organization}/securityHealthAnalyticsSettings/effectiveCustomModules/{effective_custom_module} - * - externalSystem: organizations/{organization}/sources/{source}/findings/{finding}/externalSystems/{externalsystem} - * - finding: organizations/{organization}/sources/{source}/findings/{finding} - * - folder: folders/{folder} - * - folderAssetSecurityMarks: folders/{folder}/assets/{asset}/securityMarks - * - folderCustomModule: folders/{folder}/securityHealthAnalyticsSettings/customModules/{custom_module} - * - folderEffectiveCustomModule: folders/{folder}/securityHealthAnalyticsSettings/effectiveCustomModules/{effective_custom_module} - * - folderExport: folders/{folder}/bigQueryExports/{export} - * - folderMuteConfig: folders/{folder}/muteConfigs/{mute_config} - * - folderNotificationConfig: folders/{folder}/notificationConfigs/{notification_config} - * - folderSecurityHealthAnalyticsSettings: folders/{folder}/securityHealthAnalyticsSettings - * - folderSource: folders/{folder}/sources/{source} - * - folderSourceFinding: folders/{folder}/sources/{source}/findings/{finding} - * - folderSourceFindingExternalsystem: folders/{folder}/sources/{source}/findings/{finding}/externalSystems/{externalsystem} - * - folderSourceFindingSecurityMarks: folders/{folder}/sources/{source}/findings/{finding}/securityMarks - * - muteConfig: organizations/{organization}/muteConfigs/{mute_config} - * - notificationConfig: organizations/{organization}/notificationConfigs/{notification_config} - * - organization: organizations/{organization} - * - organizationAssetSecurityMarks: organizations/{organization}/assets/{asset}/securityMarks - * - organizationCustomModule: organizations/{organization}/securityHealthAnalyticsSettings/customModules/{custom_module} - * - organizationEffectiveCustomModule: organizations/{organization}/securityHealthAnalyticsSettings/effectiveCustomModules/{effective_custom_module} - * - organizationExport: organizations/{organization}/bigQueryExports/{export} - * - organizationMuteConfig: organizations/{organization}/muteConfigs/{mute_config} - * - organizationNotificationConfig: organizations/{organization}/notificationConfigs/{notification_config} - * - organizationSecurityHealthAnalyticsSettings: organizations/{organization}/securityHealthAnalyticsSettings - * - organizationSettings: organizations/{organization}/organizationSettings - * - organizationSource: organizations/{organization}/sources/{source} - * - organizationSourceFinding: organizations/{organization}/sources/{source}/findings/{finding} - * - organizationSourceFindingExternalsystem: organizations/{organization}/sources/{source}/findings/{finding}/externalSystems/{externalsystem} - * - organizationSourceFindingSecurityMarks: organizations/{organization}/sources/{source}/findings/{finding}/securityMarks - * - project: projects/{project} - * - projectAssetSecurityMarks: projects/{project}/assets/{asset}/securityMarks - * - projectCustomModule: projects/{project}/securityHealthAnalyticsSettings/customModules/{custom_module} - * - projectDlpJob: projects/{project}/dlpJobs/{dlp_job} - * - projectEffectiveCustomModule: projects/{project}/securityHealthAnalyticsSettings/effectiveCustomModules/{effective_custom_module} - * - projectExport: projects/{project}/bigQueryExports/{export} - * - projectLocationDlpJob: projects/{project}/locations/{location}/dlpJobs/{dlp_job} - * - projectLocationTableProfile: projects/{project}/locations/{location}/tableProfiles/{table_profile} - * - projectMuteConfig: projects/{project}/muteConfigs/{mute_config} - * - projectNotificationConfig: projects/{project}/notificationConfigs/{notification_config} - * - projectSecurityHealthAnalyticsSettings: projects/{project}/securityHealthAnalyticsSettings - * - projectSource: projects/{project}/sources/{source} - * - projectSourceFinding: projects/{project}/sources/{source}/findings/{finding} - * - projectSourceFindingExternalsystem: projects/{project}/sources/{source}/findings/{finding}/externalSystems/{externalsystem} - * - projectSourceFindingSecurityMarks: projects/{project}/sources/{source}/findings/{finding}/securityMarks - * - projectTableProfile: projects/{project}/tableProfiles/{table_profile} - * - securityHealthAnalyticsCustomModule: organizations/{organization}/securityHealthAnalyticsSettings/customModules/{custom_module} - * - securityHealthAnalyticsSettings: organizations/{organization}/securityHealthAnalyticsSettings - * - securityMarks: organizations/{organization}/assets/{asset}/securityMarks - * - source: organizations/{organization}/sources/{source} - * - tableDataProfile: projects/{project}/tableProfiles/{table_profile} - * - topic: projects/{project}/topics/{topic} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'securitycenter.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Kicks off an LRO to bulk mute findings for a parent based on a filter. The - * parent can be either an organization, folder or project. The findings - * matched by the filter will be muted after the LRO is done. - * - * The async variant is {@see self::bulkMuteFindingsAsync()} . - * - * @param BulkMuteFindingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function bulkMuteFindings(BulkMuteFindingsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BulkMuteFindings', $request, $callOptions)->wait(); - } - - /** - * Creates a BigQuery export. - * - * The async variant is {@see self::createBigQueryExportAsync()} . - * - * @param CreateBigQueryExportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BigQueryExport - * - * @throws ApiException Thrown if the API call fails. - */ - public function createBigQueryExport(CreateBigQueryExportRequest $request, array $callOptions = []): BigQueryExport - { - return $this->startApiCall('CreateBigQueryExport', $request, $callOptions)->wait(); - } - - /** - * Creates a finding. The corresponding source must exist for finding creation - * to succeed. - * - * The async variant is {@see self::createFindingAsync()} . - * - * @param CreateFindingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Finding - * - * @throws ApiException Thrown if the API call fails. - */ - public function createFinding(CreateFindingRequest $request, array $callOptions = []): Finding - { - return $this->startApiCall('CreateFinding', $request, $callOptions)->wait(); - } - - /** - * Creates a mute config. - * - * The async variant is {@see self::createMuteConfigAsync()} . - * - * @param CreateMuteConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MuteConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function createMuteConfig(CreateMuteConfigRequest $request, array $callOptions = []): MuteConfig - { - return $this->startApiCall('CreateMuteConfig', $request, $callOptions)->wait(); - } - - /** - * Creates a notification config. - * - * The async variant is {@see self::createNotificationConfigAsync()} . - * - * @param CreateNotificationConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NotificationConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function createNotificationConfig(CreateNotificationConfigRequest $request, array $callOptions = []): NotificationConfig - { - return $this->startApiCall('CreateNotificationConfig', $request, $callOptions)->wait(); - } - - /** - * Creates a resident SecurityHealthAnalyticsCustomModule at the scope of the - * given CRM parent, and also creates inherited - * SecurityHealthAnalyticsCustomModules for all CRM descendants of the given - * parent. These modules are enabled by default. - * - * The async variant is - * {@see self::createSecurityHealthAnalyticsCustomModuleAsync()} . - * - * @param CreateSecurityHealthAnalyticsCustomModuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SecurityHealthAnalyticsCustomModule - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSecurityHealthAnalyticsCustomModule(CreateSecurityHealthAnalyticsCustomModuleRequest $request, array $callOptions = []): SecurityHealthAnalyticsCustomModule - { - return $this->startApiCall('CreateSecurityHealthAnalyticsCustomModule', $request, $callOptions)->wait(); - } - - /** - * Creates a source. - * - * The async variant is {@see self::createSourceAsync()} . - * - * @param CreateSourceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Source - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSource(CreateSourceRequest $request, array $callOptions = []): Source - { - return $this->startApiCall('CreateSource', $request, $callOptions)->wait(); - } - - /** - * Deletes an existing BigQuery export. - * - * The async variant is {@see self::deleteBigQueryExportAsync()} . - * - * @param DeleteBigQueryExportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteBigQueryExport(DeleteBigQueryExportRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteBigQueryExport', $request, $callOptions)->wait(); - } - - /** - * Deletes an existing mute config. - * - * The async variant is {@see self::deleteMuteConfigAsync()} . - * - * @param DeleteMuteConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteMuteConfig(DeleteMuteConfigRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteMuteConfig', $request, $callOptions)->wait(); - } - - /** - * Deletes a notification config. - * - * The async variant is {@see self::deleteNotificationConfigAsync()} . - * - * @param DeleteNotificationConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteNotificationConfig(DeleteNotificationConfigRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteNotificationConfig', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified SecurityHealthAnalyticsCustomModule and all of its - * descendants in the CRM hierarchy. This method is only supported for - * resident custom modules. - * - * The async variant is - * {@see self::deleteSecurityHealthAnalyticsCustomModuleAsync()} . - * - * @param DeleteSecurityHealthAnalyticsCustomModuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSecurityHealthAnalyticsCustomModule(DeleteSecurityHealthAnalyticsCustomModuleRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteSecurityHealthAnalyticsCustomModule', $request, $callOptions)->wait(); - } - - /** - * Gets a BigQuery export. - * - * The async variant is {@see self::getBigQueryExportAsync()} . - * - * @param GetBigQueryExportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BigQueryExport - * - * @throws ApiException Thrown if the API call fails. - */ - public function getBigQueryExport(GetBigQueryExportRequest $request, array $callOptions = []): BigQueryExport - { - return $this->startApiCall('GetBigQueryExport', $request, $callOptions)->wait(); - } - - /** - * Retrieves an EffectiveSecurityHealthAnalyticsCustomModule. - * - * The async variant is - * {@see self::getEffectiveSecurityHealthAnalyticsCustomModuleAsync()} . - * - * @param GetEffectiveSecurityHealthAnalyticsCustomModuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 EffectiveSecurityHealthAnalyticsCustomModule - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEffectiveSecurityHealthAnalyticsCustomModule(GetEffectiveSecurityHealthAnalyticsCustomModuleRequest $request, array $callOptions = []): EffectiveSecurityHealthAnalyticsCustomModule - { - return $this->startApiCall('GetEffectiveSecurityHealthAnalyticsCustomModule', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy on the specified Source. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets a mute config. - * - * The async variant is {@see self::getMuteConfigAsync()} . - * - * @param GetMuteConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MuteConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getMuteConfig(GetMuteConfigRequest $request, array $callOptions = []): MuteConfig - { - return $this->startApiCall('GetMuteConfig', $request, $callOptions)->wait(); - } - - /** - * Gets a notification config. - * - * The async variant is {@see self::getNotificationConfigAsync()} . - * - * @param GetNotificationConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NotificationConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getNotificationConfig(GetNotificationConfigRequest $request, array $callOptions = []): NotificationConfig - { - return $this->startApiCall('GetNotificationConfig', $request, $callOptions)->wait(); - } - - /** - * Gets the settings for an organization. - * - * The async variant is {@see self::getOrganizationSettingsAsync()} . - * - * @param GetOrganizationSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OrganizationSettings - * - * @throws ApiException Thrown if the API call fails. - */ - public function getOrganizationSettings(GetOrganizationSettingsRequest $request, array $callOptions = []): OrganizationSettings - { - return $this->startApiCall('GetOrganizationSettings', $request, $callOptions)->wait(); - } - - /** - * Retrieves a SecurityHealthAnalyticsCustomModule. - * - * The async variant is {@see self::getSecurityHealthAnalyticsCustomModuleAsync()} - * . - * - * @param GetSecurityHealthAnalyticsCustomModuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SecurityHealthAnalyticsCustomModule - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSecurityHealthAnalyticsCustomModule(GetSecurityHealthAnalyticsCustomModuleRequest $request, array $callOptions = []): SecurityHealthAnalyticsCustomModule - { - return $this->startApiCall('GetSecurityHealthAnalyticsCustomModule', $request, $callOptions)->wait(); - } - - /** - * Gets a source. - * - * The async variant is {@see self::getSourceAsync()} . - * - * @param GetSourceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Source - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSource(GetSourceRequest $request, array $callOptions = []): Source - { - return $this->startApiCall('GetSource', $request, $callOptions)->wait(); - } - - /** - * Filters an organization's assets and groups them by their specified - * properties. - * - * The async variant is {@see self::groupAssetsAsync()} . - * - * @param GroupAssetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @deprecated This method will be removed in the next major version update. - */ - public function groupAssets(GroupAssetsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('GroupAssets', $request, $callOptions); - } - - /** - * Filters an organization or source's findings and groups them by their - * specified properties. - * - * To group across all sources provide a `-` as the source id. - * Example: /v1/organizations/{organization_id}/sources/-/findings, - * /v1/folders/{folder_id}/sources/-/findings, - * /v1/projects/{project_id}/sources/-/findings - * - * The async variant is {@see self::groupFindingsAsync()} . - * - * @param GroupFindingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function groupFindings(GroupFindingsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('GroupFindings', $request, $callOptions); - } - - /** - * Lists an organization's assets. - * - * The async variant is {@see self::listAssetsAsync()} . - * - * @param ListAssetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @deprecated This method will be removed in the next major version update. - */ - public function listAssets(ListAssetsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAssets', $request, $callOptions); - } - - /** - * Lists BigQuery exports. Note that when requesting BigQuery exports at a - * given level all exports under that level are also returned e.g. if - * requesting BigQuery exports under a folder, then all BigQuery exports - * immediately under the folder plus the ones created under the projects - * within the folder are returned. - * - * The async variant is {@see self::listBigQueryExportsAsync()} . - * - * @param ListBigQueryExportsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listBigQueryExports(ListBigQueryExportsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListBigQueryExports', $request, $callOptions); - } - - /** - * Returns a list of all resident SecurityHealthAnalyticsCustomModules under - * the given CRM parent and all of the parent’s CRM descendants. - * - * The async variant is - * {@see self::listDescendantSecurityHealthAnalyticsCustomModulesAsync()} . - * - * @param ListDescendantSecurityHealthAnalyticsCustomModulesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDescendantSecurityHealthAnalyticsCustomModules(ListDescendantSecurityHealthAnalyticsCustomModulesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDescendantSecurityHealthAnalyticsCustomModules', $request, $callOptions); - } - - /** - * Returns a list of all EffectiveSecurityHealthAnalyticsCustomModules for the - * given parent. This includes resident modules defined at the scope of the - * parent, and inherited modules, inherited from CRM ancestors. - * - * The async variant is - * {@see self::listEffectiveSecurityHealthAnalyticsCustomModulesAsync()} . - * - * @param ListEffectiveSecurityHealthAnalyticsCustomModulesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listEffectiveSecurityHealthAnalyticsCustomModules(ListEffectiveSecurityHealthAnalyticsCustomModulesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListEffectiveSecurityHealthAnalyticsCustomModules', $request, $callOptions); - } - - /** - * Lists an organization or source's findings. - * - * To list across all sources provide a `-` as the source id. - * Example: /v1/organizations/{organization_id}/sources/-/findings - * - * The async variant is {@see self::listFindingsAsync()} . - * - * @param ListFindingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listFindings(ListFindingsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListFindings', $request, $callOptions); - } - - /** - * Lists mute configs. - * - * The async variant is {@see self::listMuteConfigsAsync()} . - * - * @param ListMuteConfigsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listMuteConfigs(ListMuteConfigsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListMuteConfigs', $request, $callOptions); - } - - /** - * Lists notification configs. - * - * The async variant is {@see self::listNotificationConfigsAsync()} . - * - * @param ListNotificationConfigsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listNotificationConfigs(ListNotificationConfigsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListNotificationConfigs', $request, $callOptions); - } - - /** - * Returns a list of all SecurityHealthAnalyticsCustomModules for the given - * parent. This includes resident modules defined at the scope of the parent, - * and inherited modules, inherited from CRM ancestors. - * - * The async variant is - * {@see self::listSecurityHealthAnalyticsCustomModulesAsync()} . - * - * @param ListSecurityHealthAnalyticsCustomModulesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSecurityHealthAnalyticsCustomModules(ListSecurityHealthAnalyticsCustomModulesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSecurityHealthAnalyticsCustomModules', $request, $callOptions); - } - - /** - * Lists all sources belonging to an organization. - * - * The async variant is {@see self::listSourcesAsync()} . - * - * @param ListSourcesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSources(ListSourcesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSources', $request, $callOptions); - } - - /** - * Runs asset discovery. The discovery is tracked with a long-running - * operation. - * - * This API can only be called with limited frequency for an organization. If - * it is called too frequently the caller will receive a TOO_MANY_REQUESTS - * error. - * - * The async variant is {@see self::runAssetDiscoveryAsync()} . - * - * @param RunAssetDiscoveryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @deprecated This method will be removed in the next major version update. - */ - public function runAssetDiscovery(RunAssetDiscoveryRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RunAssetDiscovery', $request, $callOptions)->wait(); - } - - /** - * Updates the state of a finding. - * - * The async variant is {@see self::setFindingStateAsync()} . - * - * @param SetFindingStateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Finding - * - * @throws ApiException Thrown if the API call fails. - */ - public function setFindingState(SetFindingStateRequest $request, array $callOptions = []): Finding - { - return $this->startApiCall('SetFindingState', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified Source. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Updates the mute state of a finding. - * - * The async variant is {@see self::setMuteAsync()} . - * - * @param SetMuteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Finding - * - * @throws ApiException Thrown if the API call fails. - */ - public function setMute(SetMuteRequest $request, array $callOptions = []): Finding - { - return $this->startApiCall('SetMute', $request, $callOptions)->wait(); - } - - /** - * Returns the permissions that a caller has on the specified source. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Updates a BigQuery export. - * - * The async variant is {@see self::updateBigQueryExportAsync()} . - * - * @param UpdateBigQueryExportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BigQueryExport - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateBigQueryExport(UpdateBigQueryExportRequest $request, array $callOptions = []): BigQueryExport - { - return $this->startApiCall('UpdateBigQueryExport', $request, $callOptions)->wait(); - } - - /** - * Updates external system. This is for a given finding. - * - * The async variant is {@see self::updateExternalSystemAsync()} . - * - * @param UpdateExternalSystemRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ExternalSystem - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateExternalSystem(UpdateExternalSystemRequest $request, array $callOptions = []): ExternalSystem - { - return $this->startApiCall('UpdateExternalSystem', $request, $callOptions)->wait(); - } - - /** - * Creates or updates a finding. The corresponding source must exist for a - * finding creation to succeed. - * - * The async variant is {@see self::updateFindingAsync()} . - * - * @param UpdateFindingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Finding - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateFinding(UpdateFindingRequest $request, array $callOptions = []): Finding - { - return $this->startApiCall('UpdateFinding', $request, $callOptions)->wait(); - } - - /** - * Updates a mute config. - * - * The async variant is {@see self::updateMuteConfigAsync()} . - * - * @param UpdateMuteConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MuteConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateMuteConfig(UpdateMuteConfigRequest $request, array $callOptions = []): MuteConfig - { - return $this->startApiCall('UpdateMuteConfig', $request, $callOptions)->wait(); - } - - /** - * - * Updates a notification config. The following update - * fields are allowed: description, pubsub_topic, streaming_config.filter - * - * The async variant is {@see self::updateNotificationConfigAsync()} . - * - * @param UpdateNotificationConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NotificationConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateNotificationConfig(UpdateNotificationConfigRequest $request, array $callOptions = []): NotificationConfig - { - return $this->startApiCall('UpdateNotificationConfig', $request, $callOptions)->wait(); - } - - /** - * Updates an organization's settings. - * - * The async variant is {@see self::updateOrganizationSettingsAsync()} . - * - * @param UpdateOrganizationSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OrganizationSettings - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateOrganizationSettings(UpdateOrganizationSettingsRequest $request, array $callOptions = []): OrganizationSettings - { - return $this->startApiCall('UpdateOrganizationSettings', $request, $callOptions)->wait(); - } - - /** - * Updates the SecurityHealthAnalyticsCustomModule under the given name based - * on the given update mask. Updating the enablement state is supported on - * both resident and inherited modules (though resident modules cannot have an - * enablement state of "inherited"). Updating the display name and custom - * config of a module is supported on resident modules only. - * - * The async variant is - * {@see self::updateSecurityHealthAnalyticsCustomModuleAsync()} . - * - * @param UpdateSecurityHealthAnalyticsCustomModuleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SecurityHealthAnalyticsCustomModule - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSecurityHealthAnalyticsCustomModule(UpdateSecurityHealthAnalyticsCustomModuleRequest $request, array $callOptions = []): SecurityHealthAnalyticsCustomModule - { - return $this->startApiCall('UpdateSecurityHealthAnalyticsCustomModule', $request, $callOptions)->wait(); - } - - /** - * Updates security marks. - * - * The async variant is {@see self::updateSecurityMarksAsync()} . - * - * @param UpdateSecurityMarksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SecurityMarks - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSecurityMarks(UpdateSecurityMarksRequest $request, array $callOptions = []): SecurityMarks - { - return $this->startApiCall('UpdateSecurityMarks', $request, $callOptions)->wait(); - } - - /** - * Updates a source. - * - * The async variant is {@see self::updateSourceAsync()} . - * - * @param UpdateSourceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Source - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSource(UpdateSourceRequest $request, array $callOptions = []): Source - { - return $this->startApiCall('UpdateSource', $request, $callOptions)->wait(); - } -} diff --git a/SecurityCenter/src/V1/Client/SecurityCenterClient.php b/SecurityCenter/src/V1/Client/SecurityCenterClient.php index 001f4955539f..959bb1088d10 100644 --- a/SecurityCenter/src/V1/Client/SecurityCenterClient.php +++ b/SecurityCenter/src/V1/Client/SecurityCenterClient.php @@ -24,17 +24,2402 @@ namespace Google\Cloud\SecurityCenter\V1\Client; -use Google\Cloud\SecurityCenter\V1\Client\BaseClient\SecurityCenterBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\SecurityCenter\V1\BigQueryExport; +use Google\Cloud\SecurityCenter\V1\BulkMuteFindingsRequest; +use Google\Cloud\SecurityCenter\V1\CreateBigQueryExportRequest; +use Google\Cloud\SecurityCenter\V1\CreateFindingRequest; +use Google\Cloud\SecurityCenter\V1\CreateMuteConfigRequest; +use Google\Cloud\SecurityCenter\V1\CreateNotificationConfigRequest; +use Google\Cloud\SecurityCenter\V1\CreateSecurityHealthAnalyticsCustomModuleRequest; +use Google\Cloud\SecurityCenter\V1\CreateSourceRequest; +use Google\Cloud\SecurityCenter\V1\DeleteBigQueryExportRequest; +use Google\Cloud\SecurityCenter\V1\DeleteMuteConfigRequest; +use Google\Cloud\SecurityCenter\V1\DeleteNotificationConfigRequest; +use Google\Cloud\SecurityCenter\V1\DeleteSecurityHealthAnalyticsCustomModuleRequest; +use Google\Cloud\SecurityCenter\V1\EffectiveSecurityHealthAnalyticsCustomModule; +use Google\Cloud\SecurityCenter\V1\ExternalSystem; +use Google\Cloud\SecurityCenter\V1\Finding; +use Google\Cloud\SecurityCenter\V1\GetBigQueryExportRequest; +use Google\Cloud\SecurityCenter\V1\GetEffectiveSecurityHealthAnalyticsCustomModuleRequest; +use Google\Cloud\SecurityCenter\V1\GetMuteConfigRequest; +use Google\Cloud\SecurityCenter\V1\GetNotificationConfigRequest; +use Google\Cloud\SecurityCenter\V1\GetOrganizationSettingsRequest; +use Google\Cloud\SecurityCenter\V1\GetSecurityHealthAnalyticsCustomModuleRequest; +use Google\Cloud\SecurityCenter\V1\GetSourceRequest; +use Google\Cloud\SecurityCenter\V1\GroupAssetsRequest; +use Google\Cloud\SecurityCenter\V1\GroupFindingsRequest; +use Google\Cloud\SecurityCenter\V1\ListAssetsRequest; +use Google\Cloud\SecurityCenter\V1\ListBigQueryExportsRequest; +use Google\Cloud\SecurityCenter\V1\ListDescendantSecurityHealthAnalyticsCustomModulesRequest; +use Google\Cloud\SecurityCenter\V1\ListEffectiveSecurityHealthAnalyticsCustomModulesRequest; +use Google\Cloud\SecurityCenter\V1\ListFindingsRequest; +use Google\Cloud\SecurityCenter\V1\ListMuteConfigsRequest; +use Google\Cloud\SecurityCenter\V1\ListNotificationConfigsRequest; +use Google\Cloud\SecurityCenter\V1\ListSecurityHealthAnalyticsCustomModulesRequest; +use Google\Cloud\SecurityCenter\V1\ListSourcesRequest; +use Google\Cloud\SecurityCenter\V1\MuteConfig; +use Google\Cloud\SecurityCenter\V1\NotificationConfig; +use Google\Cloud\SecurityCenter\V1\OrganizationSettings; +use Google\Cloud\SecurityCenter\V1\RunAssetDiscoveryRequest; +use Google\Cloud\SecurityCenter\V1\SecurityHealthAnalyticsCustomModule; +use Google\Cloud\SecurityCenter\V1\SecurityMarks; +use Google\Cloud\SecurityCenter\V1\SetFindingStateRequest; +use Google\Cloud\SecurityCenter\V1\SetMuteRequest; +use Google\Cloud\SecurityCenter\V1\Source; +use Google\Cloud\SecurityCenter\V1\UpdateBigQueryExportRequest; +use Google\Cloud\SecurityCenter\V1\UpdateExternalSystemRequest; +use Google\Cloud\SecurityCenter\V1\UpdateFindingRequest; +use Google\Cloud\SecurityCenter\V1\UpdateMuteConfigRequest; +use Google\Cloud\SecurityCenter\V1\UpdateNotificationConfigRequest; +use Google\Cloud\SecurityCenter\V1\UpdateOrganizationSettingsRequest; +use Google\Cloud\SecurityCenter\V1\UpdateSecurityHealthAnalyticsCustomModuleRequest; +use Google\Cloud\SecurityCenter\V1\UpdateSecurityMarksRequest; +use Google\Cloud\SecurityCenter\V1\UpdateSourceRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: V1 APIs for Security Center service. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\SecurityCenter\V1\SecurityCenterClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface bulkMuteFindingsAsync(BulkMuteFindingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface createBigQueryExportAsync(CreateBigQueryExportRequest $request, array $optionalArgs = []) + * @method PromiseInterface createFindingAsync(CreateFindingRequest $request, array $optionalArgs = []) + * @method PromiseInterface createMuteConfigAsync(CreateMuteConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface createNotificationConfigAsync(CreateNotificationConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSecurityHealthAnalyticsCustomModuleAsync(CreateSecurityHealthAnalyticsCustomModuleRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSourceAsync(CreateSourceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteBigQueryExportAsync(DeleteBigQueryExportRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteMuteConfigAsync(DeleteMuteConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteNotificationConfigAsync(DeleteNotificationConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSecurityHealthAnalyticsCustomModuleAsync(DeleteSecurityHealthAnalyticsCustomModuleRequest $request, array $optionalArgs = []) + * @method PromiseInterface getBigQueryExportAsync(GetBigQueryExportRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEffectiveSecurityHealthAnalyticsCustomModuleAsync(GetEffectiveSecurityHealthAnalyticsCustomModuleRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getMuteConfigAsync(GetMuteConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getNotificationConfigAsync(GetNotificationConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getOrganizationSettingsAsync(GetOrganizationSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSecurityHealthAnalyticsCustomModuleAsync(GetSecurityHealthAnalyticsCustomModuleRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSourceAsync(GetSourceRequest $request, array $optionalArgs = []) + * @method PromiseInterface groupAssetsAsync(GroupAssetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface groupFindingsAsync(GroupFindingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAssetsAsync(ListAssetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listBigQueryExportsAsync(ListBigQueryExportsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDescendantSecurityHealthAnalyticsCustomModulesAsync(ListDescendantSecurityHealthAnalyticsCustomModulesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listEffectiveSecurityHealthAnalyticsCustomModulesAsync(ListEffectiveSecurityHealthAnalyticsCustomModulesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listFindingsAsync(ListFindingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listMuteConfigsAsync(ListMuteConfigsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listNotificationConfigsAsync(ListNotificationConfigsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSecurityHealthAnalyticsCustomModulesAsync(ListSecurityHealthAnalyticsCustomModulesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSourcesAsync(ListSourcesRequest $request, array $optionalArgs = []) + * @method PromiseInterface runAssetDiscoveryAsync(RunAssetDiscoveryRequest $request, array $optionalArgs = []) + * @method PromiseInterface setFindingStateAsync(SetFindingStateRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setMuteAsync(SetMuteRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateBigQueryExportAsync(UpdateBigQueryExportRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateExternalSystemAsync(UpdateExternalSystemRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateFindingAsync(UpdateFindingRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateMuteConfigAsync(UpdateMuteConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateNotificationConfigAsync(UpdateNotificationConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateOrganizationSettingsAsync(UpdateOrganizationSettingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSecurityHealthAnalyticsCustomModuleAsync(UpdateSecurityHealthAnalyticsCustomModuleRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSecurityMarksAsync(UpdateSecurityMarksRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSourceAsync(UpdateSourceRequest $request, array $optionalArgs = []) */ -final class SecurityCenterClient extends SecurityCenterBaseClient +final class SecurityCenterClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SecurityCenterBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.securitycenter.v1.SecurityCenter'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'securitycenter.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/security_center_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/security_center_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/security_center_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/security_center_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * big_query_export resource. + * + * @param string $organization + * @param string $export + * + * @return string The formatted big_query_export resource. + */ + public static function bigQueryExportName(string $organization, string $export): string + { + return self::getPathTemplate('bigQueryExport')->render([ + 'organization' => $organization, + 'export' => $export, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a dlp_job + * resource. + * + * @param string $project + * @param string $dlpJob + * + * @return string The formatted dlp_job resource. + */ + public static function dlpJobName(string $project, string $dlpJob): string + { + return self::getPathTemplate('dlpJob')->render([ + 'project' => $project, + 'dlp_job' => $dlpJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * effective_security_health_analytics_custom_module resource. + * + * @param string $organization + * @param string $effectiveCustomModule + * + * @return string The formatted effective_security_health_analytics_custom_module resource. + */ + public static function effectiveSecurityHealthAnalyticsCustomModuleName(string $organization, string $effectiveCustomModule): string + { + return self::getPathTemplate('effectiveSecurityHealthAnalyticsCustomModule')->render([ + 'organization' => $organization, + 'effective_custom_module' => $effectiveCustomModule, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * external_system resource. + * + * @param string $organization + * @param string $source + * @param string $finding + * @param string $externalsystem + * + * @return string The formatted external_system resource. + */ + public static function externalSystemName(string $organization, string $source, string $finding, string $externalsystem): string + { + return self::getPathTemplate('externalSystem')->render([ + 'organization' => $organization, + 'source' => $source, + 'finding' => $finding, + 'externalsystem' => $externalsystem, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a finding + * resource. + * + * @param string $organization + * @param string $source + * @param string $finding + * + * @return string The formatted finding resource. + */ + public static function findingName(string $organization, string $source, string $finding): string + { + return self::getPathTemplate('finding')->render([ + 'organization' => $organization, + 'source' => $source, + 'finding' => $finding, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a folder + * resource. + * + * @param string $folder + * + * @return string The formatted folder resource. + */ + public static function folderName(string $folder): string + { + return self::getPathTemplate('folder')->render([ + 'folder' => $folder, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_asset_securityMarks resource. + * + * @param string $folder + * @param string $asset + * + * @return string The formatted folder_asset_securityMarks resource. + */ + public static function folderAssetSecurityMarksName(string $folder, string $asset): string + { + return self::getPathTemplate('folderAssetSecurityMarks')->render([ + 'folder' => $folder, + 'asset' => $asset, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_custom_module resource. + * + * @param string $folder + * @param string $customModule + * + * @return string The formatted folder_custom_module resource. + */ + public static function folderCustomModuleName(string $folder, string $customModule): string + { + return self::getPathTemplate('folderCustomModule')->render([ + 'folder' => $folder, + 'custom_module' => $customModule, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_effective_custom_module resource. + * + * @param string $folder + * @param string $effectiveCustomModule + * + * @return string The formatted folder_effective_custom_module resource. + */ + public static function folderEffectiveCustomModuleName(string $folder, string $effectiveCustomModule): string + { + return self::getPathTemplate('folderEffectiveCustomModule')->render([ + 'folder' => $folder, + 'effective_custom_module' => $effectiveCustomModule, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_export resource. + * + * @param string $folder + * @param string $export + * + * @return string The formatted folder_export resource. + */ + public static function folderExportName(string $folder, string $export): string + { + return self::getPathTemplate('folderExport')->render([ + 'folder' => $folder, + 'export' => $export, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_mute_config resource. + * + * @param string $folder + * @param string $muteConfig + * + * @return string The formatted folder_mute_config resource. + */ + public static function folderMuteConfigName(string $folder, string $muteConfig): string + { + return self::getPathTemplate('folderMuteConfig')->render([ + 'folder' => $folder, + 'mute_config' => $muteConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_notification_config resource. + * + * @param string $folder + * @param string $notificationConfig + * + * @return string The formatted folder_notification_config resource. + */ + public static function folderNotificationConfigName(string $folder, string $notificationConfig): string + { + return self::getPathTemplate('folderNotificationConfig')->render([ + 'folder' => $folder, + 'notification_config' => $notificationConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_securityHealthAnalyticsSettings resource. + * + * @param string $folder + * + * @return string The formatted folder_securityHealthAnalyticsSettings resource. + */ + public static function folderSecurityHealthAnalyticsSettingsName(string $folder): string + { + return self::getPathTemplate('folderSecurityHealthAnalyticsSettings')->render([ + 'folder' => $folder, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_source resource. + * + * @param string $folder + * @param string $source + * + * @return string The formatted folder_source resource. + */ + public static function folderSourceName(string $folder, string $source): string + { + return self::getPathTemplate('folderSource')->render([ + 'folder' => $folder, + 'source' => $source, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_source_finding resource. + * + * @param string $folder + * @param string $source + * @param string $finding + * + * @return string The formatted folder_source_finding resource. + */ + public static function folderSourceFindingName(string $folder, string $source, string $finding): string + { + return self::getPathTemplate('folderSourceFinding')->render([ + 'folder' => $folder, + 'source' => $source, + 'finding' => $finding, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_source_finding_externalsystem resource. + * + * @param string $folder + * @param string $source + * @param string $finding + * @param string $externalsystem + * + * @return string The formatted folder_source_finding_externalsystem resource. + */ + public static function folderSourceFindingExternalsystemName(string $folder, string $source, string $finding, string $externalsystem): string + { + return self::getPathTemplate('folderSourceFindingExternalsystem')->render([ + 'folder' => $folder, + 'source' => $source, + 'finding' => $finding, + 'externalsystem' => $externalsystem, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * folder_source_finding_securityMarks resource. + * + * @param string $folder + * @param string $source + * @param string $finding + * + * @return string The formatted folder_source_finding_securityMarks resource. + */ + public static function folderSourceFindingSecurityMarksName(string $folder, string $source, string $finding): string + { + return self::getPathTemplate('folderSourceFindingSecurityMarks')->render([ + 'folder' => $folder, + 'source' => $source, + 'finding' => $finding, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a mute_config + * resource. + * + * @param string $organization + * @param string $muteConfig + * + * @return string The formatted mute_config resource. + */ + public static function muteConfigName(string $organization, string $muteConfig): string + { + return self::getPathTemplate('muteConfig')->render([ + 'organization' => $organization, + 'mute_config' => $muteConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * notification_config resource. + * + * @param string $organization + * @param string $notificationConfig + * + * @return string The formatted notification_config resource. + */ + public static function notificationConfigName(string $organization, string $notificationConfig): string + { + return self::getPathTemplate('notificationConfig')->render([ + 'organization' => $organization, + 'notification_config' => $notificationConfig, + ]); + } + + /** + * 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(string $organization): string + { + return self::getPathTemplate('organization')->render([ + 'organization' => $organization, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_asset_securityMarks resource. + * + * @param string $organization + * @param string $asset + * + * @return string The formatted organization_asset_securityMarks resource. + */ + public static function organizationAssetSecurityMarksName(string $organization, string $asset): string + { + return self::getPathTemplate('organizationAssetSecurityMarks')->render([ + 'organization' => $organization, + 'asset' => $asset, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_custom_module resource. + * + * @param string $organization + * @param string $customModule + * + * @return string The formatted organization_custom_module resource. + */ + public static function organizationCustomModuleName(string $organization, string $customModule): string + { + return self::getPathTemplate('organizationCustomModule')->render([ + 'organization' => $organization, + 'custom_module' => $customModule, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_effective_custom_module resource. + * + * @param string $organization + * @param string $effectiveCustomModule + * + * @return string The formatted organization_effective_custom_module resource. + */ + public static function organizationEffectiveCustomModuleName(string $organization, string $effectiveCustomModule): string + { + return self::getPathTemplate('organizationEffectiveCustomModule')->render([ + 'organization' => $organization, + 'effective_custom_module' => $effectiveCustomModule, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_export resource. + * + * @param string $organization + * @param string $export + * + * @return string The formatted organization_export resource. + */ + public static function organizationExportName(string $organization, string $export): string + { + return self::getPathTemplate('organizationExport')->render([ + 'organization' => $organization, + 'export' => $export, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_mute_config resource. + * + * @param string $organization + * @param string $muteConfig + * + * @return string The formatted organization_mute_config resource. + */ + public static function organizationMuteConfigName(string $organization, string $muteConfig): string + { + return self::getPathTemplate('organizationMuteConfig')->render([ + 'organization' => $organization, + 'mute_config' => $muteConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_notification_config resource. + * + * @param string $organization + * @param string $notificationConfig + * + * @return string The formatted organization_notification_config resource. + */ + public static function organizationNotificationConfigName(string $organization, string $notificationConfig): string + { + return self::getPathTemplate('organizationNotificationConfig')->render([ + 'organization' => $organization, + 'notification_config' => $notificationConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_securityHealthAnalyticsSettings resource. + * + * @param string $organization + * + * @return string The formatted organization_securityHealthAnalyticsSettings resource. + */ + public static function organizationSecurityHealthAnalyticsSettingsName(string $organization): string + { + return self::getPathTemplate('organizationSecurityHealthAnalyticsSettings')->render([ + 'organization' => $organization, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_settings resource. + * + * @param string $organization + * + * @return string The formatted organization_settings resource. + */ + public static function organizationSettingsName(string $organization): string + { + return self::getPathTemplate('organizationSettings')->render([ + 'organization' => $organization, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_source resource. + * + * @param string $organization + * @param string $source + * + * @return string The formatted organization_source resource. + */ + public static function organizationSourceName(string $organization, string $source): string + { + return self::getPathTemplate('organizationSource')->render([ + 'organization' => $organization, + 'source' => $source, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_source_finding resource. + * + * @param string $organization + * @param string $source + * @param string $finding + * + * @return string The formatted organization_source_finding resource. + */ + public static function organizationSourceFindingName(string $organization, string $source, string $finding): string + { + return self::getPathTemplate('organizationSourceFinding')->render([ + 'organization' => $organization, + 'source' => $source, + 'finding' => $finding, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_source_finding_externalsystem resource. + * + * @param string $organization + * @param string $source + * @param string $finding + * @param string $externalsystem + * + * @return string The formatted organization_source_finding_externalsystem resource. + */ + public static function organizationSourceFindingExternalsystemName(string $organization, string $source, string $finding, string $externalsystem): string + { + return self::getPathTemplate('organizationSourceFindingExternalsystem')->render([ + 'organization' => $organization, + 'source' => $source, + 'finding' => $finding, + 'externalsystem' => $externalsystem, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_source_finding_securityMarks resource. + * + * @param string $organization + * @param string $source + * @param string $finding + * + * @return string The formatted organization_source_finding_securityMarks resource. + */ + public static function organizationSourceFindingSecurityMarksName(string $organization, string $source, string $finding): string + { + return self::getPathTemplate('organizationSourceFindingSecurityMarks')->render([ + 'organization' => $organization, + 'source' => $source, + 'finding' => $finding, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_asset_securityMarks resource. + * + * @param string $project + * @param string $asset + * + * @return string The formatted project_asset_securityMarks resource. + */ + public static function projectAssetSecurityMarksName(string $project, string $asset): string + { + return self::getPathTemplate('projectAssetSecurityMarks')->render([ + 'project' => $project, + 'asset' => $asset, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_custom_module resource. + * + * @param string $project + * @param string $customModule + * + * @return string The formatted project_custom_module resource. + */ + public static function projectCustomModuleName(string $project, string $customModule): string + { + return self::getPathTemplate('projectCustomModule')->render([ + 'project' => $project, + 'custom_module' => $customModule, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_dlp_job resource. + * + * @param string $project + * @param string $dlpJob + * + * @return string The formatted project_dlp_job resource. + */ + public static function projectDlpJobName(string $project, string $dlpJob): string + { + return self::getPathTemplate('projectDlpJob')->render([ + 'project' => $project, + 'dlp_job' => $dlpJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_effective_custom_module resource. + * + * @param string $project + * @param string $effectiveCustomModule + * + * @return string The formatted project_effective_custom_module resource. + */ + public static function projectEffectiveCustomModuleName(string $project, string $effectiveCustomModule): string + { + return self::getPathTemplate('projectEffectiveCustomModule')->render([ + 'project' => $project, + 'effective_custom_module' => $effectiveCustomModule, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_export resource. + * + * @param string $project + * @param string $export + * + * @return string The formatted project_export resource. + */ + public static function projectExportName(string $project, string $export): string + { + return self::getPathTemplate('projectExport')->render([ + 'project' => $project, + 'export' => $export, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_dlp_job resource. + * + * @param string $project + * @param string $location + * @param string $dlpJob + * + * @return string The formatted project_location_dlp_job resource. + */ + public static function projectLocationDlpJobName(string $project, string $location, string $dlpJob): string + { + return self::getPathTemplate('projectLocationDlpJob')->render([ + 'project' => $project, + 'location' => $location, + 'dlp_job' => $dlpJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_location_table_profile resource. + * + * @param string $project + * @param string $location + * @param string $tableProfile + * + * @return string The formatted project_location_table_profile resource. + */ + public static function projectLocationTableProfileName(string $project, string $location, string $tableProfile): string + { + return self::getPathTemplate('projectLocationTableProfile')->render([ + 'project' => $project, + 'location' => $location, + 'table_profile' => $tableProfile, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_mute_config resource. + * + * @param string $project + * @param string $muteConfig + * + * @return string The formatted project_mute_config resource. + */ + public static function projectMuteConfigName(string $project, string $muteConfig): string + { + return self::getPathTemplate('projectMuteConfig')->render([ + 'project' => $project, + 'mute_config' => $muteConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_notification_config resource. + * + * @param string $project + * @param string $notificationConfig + * + * @return string The formatted project_notification_config resource. + */ + public static function projectNotificationConfigName(string $project, string $notificationConfig): string + { + return self::getPathTemplate('projectNotificationConfig')->render([ + 'project' => $project, + 'notification_config' => $notificationConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_securityHealthAnalyticsSettings resource. + * + * @param string $project + * + * @return string The formatted project_securityHealthAnalyticsSettings resource. + */ + public static function projectSecurityHealthAnalyticsSettingsName(string $project): string + { + return self::getPathTemplate('projectSecurityHealthAnalyticsSettings')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_source resource. + * + * @param string $project + * @param string $source + * + * @return string The formatted project_source resource. + */ + public static function projectSourceName(string $project, string $source): string + { + return self::getPathTemplate('projectSource')->render([ + 'project' => $project, + 'source' => $source, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_source_finding resource. + * + * @param string $project + * @param string $source + * @param string $finding + * + * @return string The formatted project_source_finding resource. + */ + public static function projectSourceFindingName(string $project, string $source, string $finding): string + { + return self::getPathTemplate('projectSourceFinding')->render([ + 'project' => $project, + 'source' => $source, + 'finding' => $finding, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_source_finding_externalsystem resource. + * + * @param string $project + * @param string $source + * @param string $finding + * @param string $externalsystem + * + * @return string The formatted project_source_finding_externalsystem resource. + */ + public static function projectSourceFindingExternalsystemName(string $project, string $source, string $finding, string $externalsystem): string + { + return self::getPathTemplate('projectSourceFindingExternalsystem')->render([ + 'project' => $project, + 'source' => $source, + 'finding' => $finding, + 'externalsystem' => $externalsystem, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_source_finding_securityMarks resource. + * + * @param string $project + * @param string $source + * @param string $finding + * + * @return string The formatted project_source_finding_securityMarks resource. + */ + public static function projectSourceFindingSecurityMarksName(string $project, string $source, string $finding): string + { + return self::getPathTemplate('projectSourceFindingSecurityMarks')->render([ + 'project' => $project, + 'source' => $source, + 'finding' => $finding, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_table_profile resource. + * + * @param string $project + * @param string $tableProfile + * + * @return string The formatted project_table_profile resource. + */ + public static function projectTableProfileName(string $project, string $tableProfile): string + { + return self::getPathTemplate('projectTableProfile')->render([ + 'project' => $project, + 'table_profile' => $tableProfile, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * security_health_analytics_custom_module resource. + * + * @param string $organization + * @param string $customModule + * + * @return string The formatted security_health_analytics_custom_module resource. + */ + public static function securityHealthAnalyticsCustomModuleName(string $organization, string $customModule): string + { + return self::getPathTemplate('securityHealthAnalyticsCustomModule')->render([ + 'organization' => $organization, + 'custom_module' => $customModule, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * security_health_analytics_settings resource. + * + * @param string $organization + * + * @return string The formatted security_health_analytics_settings resource. + */ + public static function securityHealthAnalyticsSettingsName(string $organization): string + { + return self::getPathTemplate('securityHealthAnalyticsSettings')->render([ + 'organization' => $organization, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * security_marks resource. + * + * @param string $organization + * @param string $asset + * + * @return string The formatted security_marks resource. + */ + public static function securityMarksName(string $organization, string $asset): string + { + return self::getPathTemplate('securityMarks')->render([ + 'organization' => $organization, + 'asset' => $asset, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a source + * resource. + * + * @param string $organization + * @param string $source + * + * @return string The formatted source resource. + */ + public static function sourceName(string $organization, string $source): string + { + return self::getPathTemplate('source')->render([ + 'organization' => $organization, + 'source' => $source, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * table_data_profile resource. + * + * @param string $project + * @param string $tableProfile + * + * @return string The formatted table_data_profile resource. + */ + public static function tableDataProfileName(string $project, string $tableProfile): string + { + return self::getPathTemplate('tableDataProfile')->render([ + 'project' => $project, + 'table_profile' => $tableProfile, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a topic + * resource. + * + * @param string $project + * @param string $topic + * + * @return string The formatted topic resource. + */ + public static function topicName(string $project, string $topic): string + { + return self::getPathTemplate('topic')->render([ + 'project' => $project, + 'topic' => $topic, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - bigQueryExport: organizations/{organization}/bigQueryExports/{export} + * - dlpJob: projects/{project}/dlpJobs/{dlp_job} + * - effectiveSecurityHealthAnalyticsCustomModule: organizations/{organization}/securityHealthAnalyticsSettings/effectiveCustomModules/{effective_custom_module} + * - externalSystem: organizations/{organization}/sources/{source}/findings/{finding}/externalSystems/{externalsystem} + * - finding: organizations/{organization}/sources/{source}/findings/{finding} + * - folder: folders/{folder} + * - folderAssetSecurityMarks: folders/{folder}/assets/{asset}/securityMarks + * - folderCustomModule: folders/{folder}/securityHealthAnalyticsSettings/customModules/{custom_module} + * - folderEffectiveCustomModule: folders/{folder}/securityHealthAnalyticsSettings/effectiveCustomModules/{effective_custom_module} + * - folderExport: folders/{folder}/bigQueryExports/{export} + * - folderMuteConfig: folders/{folder}/muteConfigs/{mute_config} + * - folderNotificationConfig: folders/{folder}/notificationConfigs/{notification_config} + * - folderSecurityHealthAnalyticsSettings: folders/{folder}/securityHealthAnalyticsSettings + * - folderSource: folders/{folder}/sources/{source} + * - folderSourceFinding: folders/{folder}/sources/{source}/findings/{finding} + * - folderSourceFindingExternalsystem: folders/{folder}/sources/{source}/findings/{finding}/externalSystems/{externalsystem} + * - folderSourceFindingSecurityMarks: folders/{folder}/sources/{source}/findings/{finding}/securityMarks + * - muteConfig: organizations/{organization}/muteConfigs/{mute_config} + * - notificationConfig: organizations/{organization}/notificationConfigs/{notification_config} + * - organization: organizations/{organization} + * - organizationAssetSecurityMarks: organizations/{organization}/assets/{asset}/securityMarks + * - organizationCustomModule: organizations/{organization}/securityHealthAnalyticsSettings/customModules/{custom_module} + * - organizationEffectiveCustomModule: organizations/{organization}/securityHealthAnalyticsSettings/effectiveCustomModules/{effective_custom_module} + * - organizationExport: organizations/{organization}/bigQueryExports/{export} + * - organizationMuteConfig: organizations/{organization}/muteConfigs/{mute_config} + * - organizationNotificationConfig: organizations/{organization}/notificationConfigs/{notification_config} + * - organizationSecurityHealthAnalyticsSettings: organizations/{organization}/securityHealthAnalyticsSettings + * - organizationSettings: organizations/{organization}/organizationSettings + * - organizationSource: organizations/{organization}/sources/{source} + * - organizationSourceFinding: organizations/{organization}/sources/{source}/findings/{finding} + * - organizationSourceFindingExternalsystem: organizations/{organization}/sources/{source}/findings/{finding}/externalSystems/{externalsystem} + * - organizationSourceFindingSecurityMarks: organizations/{organization}/sources/{source}/findings/{finding}/securityMarks + * - project: projects/{project} + * - projectAssetSecurityMarks: projects/{project}/assets/{asset}/securityMarks + * - projectCustomModule: projects/{project}/securityHealthAnalyticsSettings/customModules/{custom_module} + * - projectDlpJob: projects/{project}/dlpJobs/{dlp_job} + * - projectEffectiveCustomModule: projects/{project}/securityHealthAnalyticsSettings/effectiveCustomModules/{effective_custom_module} + * - projectExport: projects/{project}/bigQueryExports/{export} + * - projectLocationDlpJob: projects/{project}/locations/{location}/dlpJobs/{dlp_job} + * - projectLocationTableProfile: projects/{project}/locations/{location}/tableProfiles/{table_profile} + * - projectMuteConfig: projects/{project}/muteConfigs/{mute_config} + * - projectNotificationConfig: projects/{project}/notificationConfigs/{notification_config} + * - projectSecurityHealthAnalyticsSettings: projects/{project}/securityHealthAnalyticsSettings + * - projectSource: projects/{project}/sources/{source} + * - projectSourceFinding: projects/{project}/sources/{source}/findings/{finding} + * - projectSourceFindingExternalsystem: projects/{project}/sources/{source}/findings/{finding}/externalSystems/{externalsystem} + * - projectSourceFindingSecurityMarks: projects/{project}/sources/{source}/findings/{finding}/securityMarks + * - projectTableProfile: projects/{project}/tableProfiles/{table_profile} + * - securityHealthAnalyticsCustomModule: organizations/{organization}/securityHealthAnalyticsSettings/customModules/{custom_module} + * - securityHealthAnalyticsSettings: organizations/{organization}/securityHealthAnalyticsSettings + * - securityMarks: organizations/{organization}/assets/{asset}/securityMarks + * - source: organizations/{organization}/sources/{source} + * - tableDataProfile: projects/{project}/tableProfiles/{table_profile} + * - topic: projects/{project}/topics/{topic} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'securitycenter.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Kicks off an LRO to bulk mute findings for a parent based on a filter. The + * parent can be either an organization, folder or project. The findings + * matched by the filter will be muted after the LRO is done. + * + * The async variant is {@see SecurityCenterClient::bulkMuteFindingsAsync()} . + * + * @param BulkMuteFindingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function bulkMuteFindings(BulkMuteFindingsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BulkMuteFindings', $request, $callOptions)->wait(); + } + + /** + * Creates a BigQuery export. + * + * The async variant is {@see SecurityCenterClient::createBigQueryExportAsync()} . + * + * @param CreateBigQueryExportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BigQueryExport + * + * @throws ApiException Thrown if the API call fails. + */ + public function createBigQueryExport(CreateBigQueryExportRequest $request, array $callOptions = []): BigQueryExport + { + return $this->startApiCall('CreateBigQueryExport', $request, $callOptions)->wait(); + } + + /** + * Creates a finding. The corresponding source must exist for finding creation + * to succeed. + * + * The async variant is {@see SecurityCenterClient::createFindingAsync()} . + * + * @param CreateFindingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Finding + * + * @throws ApiException Thrown if the API call fails. + */ + public function createFinding(CreateFindingRequest $request, array $callOptions = []): Finding + { + return $this->startApiCall('CreateFinding', $request, $callOptions)->wait(); + } + + /** + * Creates a mute config. + * + * The async variant is {@see SecurityCenterClient::createMuteConfigAsync()} . + * + * @param CreateMuteConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MuteConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function createMuteConfig(CreateMuteConfigRequest $request, array $callOptions = []): MuteConfig + { + return $this->startApiCall('CreateMuteConfig', $request, $callOptions)->wait(); + } + + /** + * Creates a notification config. + * + * The async variant is + * {@see SecurityCenterClient::createNotificationConfigAsync()} . + * + * @param CreateNotificationConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NotificationConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function createNotificationConfig(CreateNotificationConfigRequest $request, array $callOptions = []): NotificationConfig + { + return $this->startApiCall('CreateNotificationConfig', $request, $callOptions)->wait(); + } + + /** + * Creates a resident SecurityHealthAnalyticsCustomModule at the scope of the + * given CRM parent, and also creates inherited + * SecurityHealthAnalyticsCustomModules for all CRM descendants of the given + * parent. These modules are enabled by default. + * + * The async variant is + * {@see SecurityCenterClient::createSecurityHealthAnalyticsCustomModuleAsync()} . + * + * @param CreateSecurityHealthAnalyticsCustomModuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SecurityHealthAnalyticsCustomModule + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSecurityHealthAnalyticsCustomModule(CreateSecurityHealthAnalyticsCustomModuleRequest $request, array $callOptions = []): SecurityHealthAnalyticsCustomModule + { + return $this->startApiCall('CreateSecurityHealthAnalyticsCustomModule', $request, $callOptions)->wait(); + } + + /** + * Creates a source. + * + * The async variant is {@see SecurityCenterClient::createSourceAsync()} . + * + * @param CreateSourceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Source + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSource(CreateSourceRequest $request, array $callOptions = []): Source + { + return $this->startApiCall('CreateSource', $request, $callOptions)->wait(); + } + + /** + * Deletes an existing BigQuery export. + * + * The async variant is {@see SecurityCenterClient::deleteBigQueryExportAsync()} . + * + * @param DeleteBigQueryExportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteBigQueryExport(DeleteBigQueryExportRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteBigQueryExport', $request, $callOptions)->wait(); + } + + /** + * Deletes an existing mute config. + * + * The async variant is {@see SecurityCenterClient::deleteMuteConfigAsync()} . + * + * @param DeleteMuteConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteMuteConfig(DeleteMuteConfigRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteMuteConfig', $request, $callOptions)->wait(); + } + + /** + * Deletes a notification config. + * + * The async variant is + * {@see SecurityCenterClient::deleteNotificationConfigAsync()} . + * + * @param DeleteNotificationConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteNotificationConfig(DeleteNotificationConfigRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteNotificationConfig', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified SecurityHealthAnalyticsCustomModule and all of its + * descendants in the CRM hierarchy. This method is only supported for + * resident custom modules. + * + * The async variant is + * {@see SecurityCenterClient::deleteSecurityHealthAnalyticsCustomModuleAsync()} . + * + * @param DeleteSecurityHealthAnalyticsCustomModuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSecurityHealthAnalyticsCustomModule(DeleteSecurityHealthAnalyticsCustomModuleRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteSecurityHealthAnalyticsCustomModule', $request, $callOptions)->wait(); + } + + /** + * Gets a BigQuery export. + * + * The async variant is {@see SecurityCenterClient::getBigQueryExportAsync()} . + * + * @param GetBigQueryExportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BigQueryExport + * + * @throws ApiException Thrown if the API call fails. + */ + public function getBigQueryExport(GetBigQueryExportRequest $request, array $callOptions = []): BigQueryExport + { + return $this->startApiCall('GetBigQueryExport', $request, $callOptions)->wait(); + } + + /** + * Retrieves an EffectiveSecurityHealthAnalyticsCustomModule. + * + * The async variant is + * {@see SecurityCenterClient::getEffectiveSecurityHealthAnalyticsCustomModuleAsync()} + * . + * + * @param GetEffectiveSecurityHealthAnalyticsCustomModuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 EffectiveSecurityHealthAnalyticsCustomModule + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEffectiveSecurityHealthAnalyticsCustomModule(GetEffectiveSecurityHealthAnalyticsCustomModuleRequest $request, array $callOptions = []): EffectiveSecurityHealthAnalyticsCustomModule + { + return $this->startApiCall('GetEffectiveSecurityHealthAnalyticsCustomModule', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy on the specified Source. + * + * The async variant is {@see SecurityCenterClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets a mute config. + * + * The async variant is {@see SecurityCenterClient::getMuteConfigAsync()} . + * + * @param GetMuteConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MuteConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getMuteConfig(GetMuteConfigRequest $request, array $callOptions = []): MuteConfig + { + return $this->startApiCall('GetMuteConfig', $request, $callOptions)->wait(); + } + + /** + * Gets a notification config. + * + * The async variant is {@see SecurityCenterClient::getNotificationConfigAsync()} . + * + * @param GetNotificationConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NotificationConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getNotificationConfig(GetNotificationConfigRequest $request, array $callOptions = []): NotificationConfig + { + return $this->startApiCall('GetNotificationConfig', $request, $callOptions)->wait(); + } + + /** + * Gets the settings for an organization. + * + * The async variant is {@see SecurityCenterClient::getOrganizationSettingsAsync()} + * . + * + * @param GetOrganizationSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OrganizationSettings + * + * @throws ApiException Thrown if the API call fails. + */ + public function getOrganizationSettings(GetOrganizationSettingsRequest $request, array $callOptions = []): OrganizationSettings + { + return $this->startApiCall('GetOrganizationSettings', $request, $callOptions)->wait(); + } + + /** + * Retrieves a SecurityHealthAnalyticsCustomModule. + * + * The async variant is + * {@see SecurityCenterClient::getSecurityHealthAnalyticsCustomModuleAsync()} . + * + * @param GetSecurityHealthAnalyticsCustomModuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SecurityHealthAnalyticsCustomModule + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSecurityHealthAnalyticsCustomModule(GetSecurityHealthAnalyticsCustomModuleRequest $request, array $callOptions = []): SecurityHealthAnalyticsCustomModule + { + return $this->startApiCall('GetSecurityHealthAnalyticsCustomModule', $request, $callOptions)->wait(); + } + + /** + * Gets a source. + * + * The async variant is {@see SecurityCenterClient::getSourceAsync()} . + * + * @param GetSourceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Source + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSource(GetSourceRequest $request, array $callOptions = []): Source + { + return $this->startApiCall('GetSource', $request, $callOptions)->wait(); + } + + /** + * Filters an organization's assets and groups them by their specified + * properties. + * + * The async variant is {@see SecurityCenterClient::groupAssetsAsync()} . + * + * @param GroupAssetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @deprecated This method will be removed in the next major version update. + */ + public function groupAssets(GroupAssetsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('GroupAssets', $request, $callOptions); + } + + /** + * Filters an organization or source's findings and groups them by their + * specified properties. + * + * To group across all sources provide a `-` as the source id. + * Example: /v1/organizations/{organization_id}/sources/-/findings, + * /v1/folders/{folder_id}/sources/-/findings, + * /v1/projects/{project_id}/sources/-/findings + * + * The async variant is {@see SecurityCenterClient::groupFindingsAsync()} . + * + * @param GroupFindingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function groupFindings(GroupFindingsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('GroupFindings', $request, $callOptions); + } + + /** + * Lists an organization's assets. + * + * The async variant is {@see SecurityCenterClient::listAssetsAsync()} . + * + * @param ListAssetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @deprecated This method will be removed in the next major version update. + */ + public function listAssets(ListAssetsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAssets', $request, $callOptions); + } + + /** + * Lists BigQuery exports. Note that when requesting BigQuery exports at a + * given level all exports under that level are also returned e.g. if + * requesting BigQuery exports under a folder, then all BigQuery exports + * immediately under the folder plus the ones created under the projects + * within the folder are returned. + * + * The async variant is {@see SecurityCenterClient::listBigQueryExportsAsync()} . + * + * @param ListBigQueryExportsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listBigQueryExports(ListBigQueryExportsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListBigQueryExports', $request, $callOptions); + } + + /** + * Returns a list of all resident SecurityHealthAnalyticsCustomModules under + * the given CRM parent and all of the parent’s CRM descendants. + * + * The async variant is + * {@see SecurityCenterClient::listDescendantSecurityHealthAnalyticsCustomModulesAsync()} + * . + * + * @param ListDescendantSecurityHealthAnalyticsCustomModulesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDescendantSecurityHealthAnalyticsCustomModules(ListDescendantSecurityHealthAnalyticsCustomModulesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDescendantSecurityHealthAnalyticsCustomModules', $request, $callOptions); + } + + /** + * Returns a list of all EffectiveSecurityHealthAnalyticsCustomModules for the + * given parent. This includes resident modules defined at the scope of the + * parent, and inherited modules, inherited from CRM ancestors. + * + * The async variant is + * {@see SecurityCenterClient::listEffectiveSecurityHealthAnalyticsCustomModulesAsync()} + * . + * + * @param ListEffectiveSecurityHealthAnalyticsCustomModulesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listEffectiveSecurityHealthAnalyticsCustomModules(ListEffectiveSecurityHealthAnalyticsCustomModulesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEffectiveSecurityHealthAnalyticsCustomModules', $request, $callOptions); + } + + /** + * Lists an organization or source's findings. + * + * To list across all sources provide a `-` as the source id. + * Example: /v1/organizations/{organization_id}/sources/-/findings + * + * The async variant is {@see SecurityCenterClient::listFindingsAsync()} . + * + * @param ListFindingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listFindings(ListFindingsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListFindings', $request, $callOptions); + } + + /** + * Lists mute configs. + * + * The async variant is {@see SecurityCenterClient::listMuteConfigsAsync()} . + * + * @param ListMuteConfigsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listMuteConfigs(ListMuteConfigsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListMuteConfigs', $request, $callOptions); + } + + /** + * Lists notification configs. + * + * The async variant is {@see SecurityCenterClient::listNotificationConfigsAsync()} + * . + * + * @param ListNotificationConfigsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listNotificationConfigs(ListNotificationConfigsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListNotificationConfigs', $request, $callOptions); + } + + /** + * Returns a list of all SecurityHealthAnalyticsCustomModules for the given + * parent. This includes resident modules defined at the scope of the parent, + * and inherited modules, inherited from CRM ancestors. + * + * The async variant is + * {@see SecurityCenterClient::listSecurityHealthAnalyticsCustomModulesAsync()} . + * + * @param ListSecurityHealthAnalyticsCustomModulesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSecurityHealthAnalyticsCustomModules(ListSecurityHealthAnalyticsCustomModulesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSecurityHealthAnalyticsCustomModules', $request, $callOptions); + } + + /** + * Lists all sources belonging to an organization. + * + * The async variant is {@see SecurityCenterClient::listSourcesAsync()} . + * + * @param ListSourcesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSources(ListSourcesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSources', $request, $callOptions); + } + + /** + * Runs asset discovery. The discovery is tracked with a long-running + * operation. + * + * This API can only be called with limited frequency for an organization. If + * it is called too frequently the caller will receive a TOO_MANY_REQUESTS + * error. + * + * The async variant is {@see SecurityCenterClient::runAssetDiscoveryAsync()} . + * + * @param RunAssetDiscoveryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @deprecated This method will be removed in the next major version update. + */ + public function runAssetDiscovery(RunAssetDiscoveryRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RunAssetDiscovery', $request, $callOptions)->wait(); + } + + /** + * Updates the state of a finding. + * + * The async variant is {@see SecurityCenterClient::setFindingStateAsync()} . + * + * @param SetFindingStateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Finding + * + * @throws ApiException Thrown if the API call fails. + */ + public function setFindingState(SetFindingStateRequest $request, array $callOptions = []): Finding + { + return $this->startApiCall('SetFindingState', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified Source. + * + * The async variant is {@see SecurityCenterClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Updates the mute state of a finding. + * + * The async variant is {@see SecurityCenterClient::setMuteAsync()} . + * + * @param SetMuteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Finding + * + * @throws ApiException Thrown if the API call fails. + */ + public function setMute(SetMuteRequest $request, array $callOptions = []): Finding + { + return $this->startApiCall('SetMute', $request, $callOptions)->wait(); + } + + /** + * Returns the permissions that a caller has on the specified source. + * + * The async variant is {@see SecurityCenterClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates a BigQuery export. + * + * The async variant is {@see SecurityCenterClient::updateBigQueryExportAsync()} . + * + * @param UpdateBigQueryExportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BigQueryExport + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateBigQueryExport(UpdateBigQueryExportRequest $request, array $callOptions = []): BigQueryExport + { + return $this->startApiCall('UpdateBigQueryExport', $request, $callOptions)->wait(); + } + + /** + * Updates external system. This is for a given finding. + * + * The async variant is {@see SecurityCenterClient::updateExternalSystemAsync()} . + * + * @param UpdateExternalSystemRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ExternalSystem + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateExternalSystem(UpdateExternalSystemRequest $request, array $callOptions = []): ExternalSystem + { + return $this->startApiCall('UpdateExternalSystem', $request, $callOptions)->wait(); + } + + /** + * Creates or updates a finding. The corresponding source must exist for a + * finding creation to succeed. + * + * The async variant is {@see SecurityCenterClient::updateFindingAsync()} . + * + * @param UpdateFindingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Finding + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateFinding(UpdateFindingRequest $request, array $callOptions = []): Finding + { + return $this->startApiCall('UpdateFinding', $request, $callOptions)->wait(); + } + + /** + * Updates a mute config. + * + * The async variant is {@see SecurityCenterClient::updateMuteConfigAsync()} . + * + * @param UpdateMuteConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MuteConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateMuteConfig(UpdateMuteConfigRequest $request, array $callOptions = []): MuteConfig + { + return $this->startApiCall('UpdateMuteConfig', $request, $callOptions)->wait(); + } + + /** + * + * Updates a notification config. The following update + * fields are allowed: description, pubsub_topic, streaming_config.filter + * + * The async variant is + * {@see SecurityCenterClient::updateNotificationConfigAsync()} . + * + * @param UpdateNotificationConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NotificationConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateNotificationConfig(UpdateNotificationConfigRequest $request, array $callOptions = []): NotificationConfig + { + return $this->startApiCall('UpdateNotificationConfig', $request, $callOptions)->wait(); + } + + /** + * Updates an organization's settings. + * + * The async variant is + * {@see SecurityCenterClient::updateOrganizationSettingsAsync()} . + * + * @param UpdateOrganizationSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OrganizationSettings + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateOrganizationSettings(UpdateOrganizationSettingsRequest $request, array $callOptions = []): OrganizationSettings + { + return $this->startApiCall('UpdateOrganizationSettings', $request, $callOptions)->wait(); + } + + /** + * Updates the SecurityHealthAnalyticsCustomModule under the given name based + * on the given update mask. Updating the enablement state is supported on + * both resident and inherited modules (though resident modules cannot have an + * enablement state of "inherited"). Updating the display name and custom + * config of a module is supported on resident modules only. + * + * The async variant is + * {@see SecurityCenterClient::updateSecurityHealthAnalyticsCustomModuleAsync()} . + * + * @param UpdateSecurityHealthAnalyticsCustomModuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SecurityHealthAnalyticsCustomModule + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSecurityHealthAnalyticsCustomModule(UpdateSecurityHealthAnalyticsCustomModuleRequest $request, array $callOptions = []): SecurityHealthAnalyticsCustomModule + { + return $this->startApiCall('UpdateSecurityHealthAnalyticsCustomModule', $request, $callOptions)->wait(); + } + + /** + * Updates security marks. + * + * The async variant is {@see SecurityCenterClient::updateSecurityMarksAsync()} . + * + * @param UpdateSecurityMarksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SecurityMarks + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSecurityMarks(UpdateSecurityMarksRequest $request, array $callOptions = []): SecurityMarks + { + return $this->startApiCall('UpdateSecurityMarks', $request, $callOptions)->wait(); + } + + /** + * Updates a source. + * + * The async variant is {@see SecurityCenterClient::updateSourceAsync()} . + * + * @param UpdateSourceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Source + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSource(UpdateSourceRequest $request, array $callOptions = []): Source + { + return $this->startApiCall('UpdateSource', $request, $callOptions)->wait(); + } } diff --git a/SecurityPrivateCa/composer.json b/SecurityPrivateCa/composer.json index 3b7002d73428..02ff47e04fa3 100644 --- a/SecurityPrivateCa/composer.json +++ b/SecurityPrivateCa/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.5.0" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/SecurityPrivateCa/src/V1/Client/BaseClient/CertificateAuthorityServiceBaseClient.php b/SecurityPrivateCa/src/V1/Client/BaseClient/CertificateAuthorityServiceBaseClient.php deleted file mode 100644 index b435ec04bbf3..000000000000 --- a/SecurityPrivateCa/src/V1/Client/BaseClient/CertificateAuthorityServiceBaseClient.php +++ /dev/null @@ -1,1306 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/certificate_authority_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/certificate_authority_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/certificate_authority_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/certificate_authority_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a ca_pool - * resource. - * - * @param string $project - * @param string $location - * @param string $caPool - * - * @return string The formatted ca_pool resource. - */ - public static function caPoolName(string $project, string $location, string $caPool): string - { - return self::getPathTemplate('caPool')->render([ - 'project' => $project, - 'location' => $location, - 'ca_pool' => $caPool, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a certificate - * resource. - * - * @param string $project - * @param string $location - * @param string $caPool - * @param string $certificate - * - * @return string The formatted certificate resource. - */ - public static function certificateName(string $project, string $location, string $caPool, string $certificate): string - { - return self::getPathTemplate('certificate')->render([ - 'project' => $project, - 'location' => $location, - 'ca_pool' => $caPool, - 'certificate' => $certificate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * certificate_authority resource. - * - * @param string $project - * @param string $location - * @param string $caPool - * @param string $certificateAuthority - * - * @return string The formatted certificate_authority resource. - */ - public static function certificateAuthorityName(string $project, string $location, string $caPool, string $certificateAuthority): string - { - return self::getPathTemplate('certificateAuthority')->render([ - 'project' => $project, - 'location' => $location, - 'ca_pool' => $caPool, - 'certificate_authority' => $certificateAuthority, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * certificate_revocation_list resource. - * - * @param string $project - * @param string $location - * @param string $caPool - * @param string $certificateAuthority - * @param string $certificateRevocationList - * - * @return string The formatted certificate_revocation_list resource. - */ - public static function certificateRevocationListName(string $project, string $location, string $caPool, string $certificateAuthority, string $certificateRevocationList): string - { - return self::getPathTemplate('certificateRevocationList')->render([ - 'project' => $project, - 'location' => $location, - 'ca_pool' => $caPool, - 'certificate_authority' => $certificateAuthority, - 'certificate_revocation_list' => $certificateRevocationList, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * certificate_template resource. - * - * @param string $project - * @param string $location - * @param string $certificateTemplate - * - * @return string The formatted certificate_template resource. - */ - public static function certificateTemplateName(string $project, string $location, string $certificateTemplate): string - { - return self::getPathTemplate('certificateTemplate')->render([ - 'project' => $project, - 'location' => $location, - 'certificate_template' => $certificateTemplate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - caPool: projects/{project}/locations/{location}/caPools/{ca_pool} - * - certificate: projects/{project}/locations/{location}/caPools/{ca_pool}/certificates/{certificate} - * - certificateAuthority: projects/{project}/locations/{location}/caPools/{ca_pool}/certificateAuthorities/{certificate_authority} - * - certificateRevocationList: projects/{project}/locations/{location}/caPools/{ca_pool}/certificateAuthorities/{certificate_authority}/certificateRevocationLists/{certificate_revocation_list} - * - certificateTemplate: projects/{project}/locations/{location}/certificateTemplates/{certificate_template} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'privateca.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Activate a - * [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - * that is in state - * [AWAITING_USER_ACTIVATION][google.cloud.security.privateca.v1.CertificateAuthority.State.AWAITING_USER_ACTIVATION] - * and is of type - * [SUBORDINATE][google.cloud.security.privateca.v1.CertificateAuthority.Type.SUBORDINATE]. - * After the parent Certificate Authority signs a certificate signing request - * from - * [FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCertificateAuthorityCsr], - * this method can complete the activation process. - * - * The async variant is {@see self::activateCertificateAuthorityAsync()} . - * - * @param ActivateCertificateAuthorityRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function activateCertificateAuthority(ActivateCertificateAuthorityRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ActivateCertificateAuthority', $request, $callOptions)->wait(); - } - - /** - * Create a [CaPool][google.cloud.security.privateca.v1.CaPool]. - * - * The async variant is {@see self::createCaPoolAsync()} . - * - * @param CreateCaPoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCaPool(CreateCaPoolRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateCaPool', $request, $callOptions)->wait(); - } - - /** - * Create a new [Certificate][google.cloud.security.privateca.v1.Certificate] - * in a given Project, Location from a particular - * [CaPool][google.cloud.security.privateca.v1.CaPool]. - * - * The async variant is {@see self::createCertificateAsync()} . - * - * @param CreateCertificateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Certificate - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCertificate(CreateCertificateRequest $request, array $callOptions = []): Certificate - { - return $this->startApiCall('CreateCertificate', $request, $callOptions)->wait(); - } - - /** - * Create a new - * [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - * in a given Project and Location. - * - * The async variant is {@see self::createCertificateAuthorityAsync()} . - * - * @param CreateCertificateAuthorityRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCertificateAuthority(CreateCertificateAuthorityRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateCertificateAuthority', $request, $callOptions)->wait(); - } - - /** - * Create a new - * [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] - * in a given Project and Location. - * - * The async variant is {@see self::createCertificateTemplateAsync()} . - * - * @param CreateCertificateTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCertificateTemplate(CreateCertificateTemplateRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateCertificateTemplate', $request, $callOptions)->wait(); - } - - /** - * Delete a [CaPool][google.cloud.security.privateca.v1.CaPool]. - * - * The async variant is {@see self::deleteCaPoolAsync()} . - * - * @param DeleteCaPoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteCaPool(DeleteCaPoolRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteCaPool', $request, $callOptions)->wait(); - } - - /** - * Delete a - * [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - * - * The async variant is {@see self::deleteCertificateAuthorityAsync()} . - * - * @param DeleteCertificateAuthorityRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteCertificateAuthority(DeleteCertificateAuthorityRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteCertificateAuthority', $request, $callOptions)->wait(); - } - - /** - * DeleteCertificateTemplate deletes a - * [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. - * - * The async variant is {@see self::deleteCertificateTemplateAsync()} . - * - * @param DeleteCertificateTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteCertificateTemplate(DeleteCertificateTemplateRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteCertificateTemplate', $request, $callOptions)->wait(); - } - - /** - * Disable a - * [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - * - * The async variant is {@see self::disableCertificateAuthorityAsync()} . - * - * @param DisableCertificateAuthorityRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function disableCertificateAuthority(DisableCertificateAuthorityRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DisableCertificateAuthority', $request, $callOptions)->wait(); - } - - /** - * Enable a - * [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - * - * The async variant is {@see self::enableCertificateAuthorityAsync()} . - * - * @param EnableCertificateAuthorityRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function enableCertificateAuthority(EnableCertificateAuthorityRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('EnableCertificateAuthority', $request, $callOptions)->wait(); - } - - /** - * FetchCaCerts returns the current trust anchor for the - * [CaPool][google.cloud.security.privateca.v1.CaPool]. This will include CA - * certificate chains for all ACTIVE - * [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - * resources in the [CaPool][google.cloud.security.privateca.v1.CaPool]. - * - * The async variant is {@see self::fetchCaCertsAsync()} . - * - * @param FetchCaCertsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FetchCaCertsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function fetchCaCerts(FetchCaCertsRequest $request, array $callOptions = []): FetchCaCertsResponse - { - return $this->startApiCall('FetchCaCerts', $request, $callOptions)->wait(); - } - - /** - * Fetch a certificate signing request (CSR) from a - * [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - * that is in state - * [AWAITING_USER_ACTIVATION][google.cloud.security.privateca.v1.CertificateAuthority.State.AWAITING_USER_ACTIVATION] - * and is of type - * [SUBORDINATE][google.cloud.security.privateca.v1.CertificateAuthority.Type.SUBORDINATE]. - * The CSR must then be signed by the desired parent Certificate Authority, - * which could be another - * [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - * resource, or could be an on-prem certificate authority. See also - * [ActivateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.ActivateCertificateAuthority]. - * - * The async variant is {@see self::fetchCertificateAuthorityCsrAsync()} . - * - * @param FetchCertificateAuthorityCsrRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FetchCertificateAuthorityCsrResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function fetchCertificateAuthorityCsr(FetchCertificateAuthorityCsrRequest $request, array $callOptions = []): FetchCertificateAuthorityCsrResponse - { - return $this->startApiCall('FetchCertificateAuthorityCsr', $request, $callOptions)->wait(); - } - - /** - * Returns a [CaPool][google.cloud.security.privateca.v1.CaPool]. - * - * The async variant is {@see self::getCaPoolAsync()} . - * - * @param GetCaPoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CaPool - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCaPool(GetCaPoolRequest $request, array $callOptions = []): CaPool - { - return $this->startApiCall('GetCaPool', $request, $callOptions)->wait(); - } - - /** - * Returns a [Certificate][google.cloud.security.privateca.v1.Certificate]. - * - * The async variant is {@see self::getCertificateAsync()} . - * - * @param GetCertificateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Certificate - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCertificate(GetCertificateRequest $request, array $callOptions = []): Certificate - { - return $this->startApiCall('GetCertificate', $request, $callOptions)->wait(); - } - - /** - * Returns a - * [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - * - * The async variant is {@see self::getCertificateAuthorityAsync()} . - * - * @param GetCertificateAuthorityRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CertificateAuthority - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCertificateAuthority(GetCertificateAuthorityRequest $request, array $callOptions = []): CertificateAuthority - { - return $this->startApiCall('GetCertificateAuthority', $request, $callOptions)->wait(); - } - - /** - * Returns a - * [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. - * - * The async variant is {@see self::getCertificateRevocationListAsync()} . - * - * @param GetCertificateRevocationListRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CertificateRevocationList - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCertificateRevocationList(GetCertificateRevocationListRequest $request, array $callOptions = []): CertificateRevocationList - { - return $this->startApiCall('GetCertificateRevocationList', $request, $callOptions)->wait(); - } - - /** - * Returns a - * [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. - * - * The async variant is {@see self::getCertificateTemplateAsync()} . - * - * @param GetCertificateTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CertificateTemplate - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCertificateTemplate(GetCertificateTemplateRequest $request, array $callOptions = []): CertificateTemplate - { - return $this->startApiCall('GetCertificateTemplate', $request, $callOptions)->wait(); - } - - /** - * Lists [CaPools][google.cloud.security.privateca.v1.CaPool]. - * - * The async variant is {@see self::listCaPoolsAsync()} . - * - * @param ListCaPoolsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCaPools(ListCaPoolsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCaPools', $request, $callOptions); - } - - /** - * Lists - * [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority]. - * - * The async variant is {@see self::listCertificateAuthoritiesAsync()} . - * - * @param ListCertificateAuthoritiesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCertificateAuthorities(ListCertificateAuthoritiesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCertificateAuthorities', $request, $callOptions); - } - - /** - * Lists - * [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList]. - * - * The async variant is {@see self::listCertificateRevocationListsAsync()} . - * - * @param ListCertificateRevocationListsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCertificateRevocationLists(ListCertificateRevocationListsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCertificateRevocationLists', $request, $callOptions); - } - - /** - * Lists - * [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate]. - * - * The async variant is {@see self::listCertificateTemplatesAsync()} . - * - * @param ListCertificateTemplatesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCertificateTemplates(ListCertificateTemplatesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCertificateTemplates', $request, $callOptions); - } - - /** - * Lists [Certificates][google.cloud.security.privateca.v1.Certificate]. - * - * The async variant is {@see self::listCertificatesAsync()} . - * - * @param ListCertificatesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCertificates(ListCertificatesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCertificates', $request, $callOptions); - } - - /** - * Revoke a [Certificate][google.cloud.security.privateca.v1.Certificate]. - * - * The async variant is {@see self::revokeCertificateAsync()} . - * - * @param RevokeCertificateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Certificate - * - * @throws ApiException Thrown if the API call fails. - */ - public function revokeCertificate(RevokeCertificateRequest $request, array $callOptions = []): Certificate - { - return $this->startApiCall('RevokeCertificate', $request, $callOptions)->wait(); - } - - /** - * Undelete a - * [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] - * that has been deleted. - * - * The async variant is {@see self::undeleteCertificateAuthorityAsync()} . - * - * @param UndeleteCertificateAuthorityRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function undeleteCertificateAuthority(UndeleteCertificateAuthorityRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UndeleteCertificateAuthority', $request, $callOptions)->wait(); - } - - /** - * Update a [CaPool][google.cloud.security.privateca.v1.CaPool]. - * - * The async variant is {@see self::updateCaPoolAsync()} . - * - * @param UpdateCaPoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCaPool(UpdateCaPoolRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateCaPool', $request, $callOptions)->wait(); - } - - /** - * Update a [Certificate][google.cloud.security.privateca.v1.Certificate]. - * Currently, the only field you can update is the - * [labels][google.cloud.security.privateca.v1.Certificate.labels] field. - * - * The async variant is {@see self::updateCertificateAsync()} . - * - * @param UpdateCertificateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Certificate - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCertificate(UpdateCertificateRequest $request, array $callOptions = []): Certificate - { - return $this->startApiCall('UpdateCertificate', $request, $callOptions)->wait(); - } - - /** - * Update a - * [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. - * - * The async variant is {@see self::updateCertificateAuthorityAsync()} . - * - * @param UpdateCertificateAuthorityRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCertificateAuthority(UpdateCertificateAuthorityRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateCertificateAuthority', $request, $callOptions)->wait(); - } - - /** - * Update a - * [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. - * - * The async variant is {@see self::updateCertificateRevocationListAsync()} . - * - * @param UpdateCertificateRevocationListRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCertificateRevocationList(UpdateCertificateRevocationListRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateCertificateRevocationList', $request, $callOptions)->wait(); - } - - /** - * Update a - * [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. - * - * The async variant is {@see self::updateCertificateTemplateAsync()} . - * - * @param UpdateCertificateTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCertificateTemplate(UpdateCertificateTemplateRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateCertificateTemplate', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/SecurityPrivateCa/src/V1/Client/CertificateAuthorityServiceClient.php b/SecurityPrivateCa/src/V1/Client/CertificateAuthorityServiceClient.php index 60cf03e8fd63..a424493b7b52 100644 --- a/SecurityPrivateCa/src/V1/Client/CertificateAuthorityServiceClient.php +++ b/SecurityPrivateCa/src/V1/Client/CertificateAuthorityServiceClient.php @@ -24,17 +24,1317 @@ namespace Google\Cloud\Security\PrivateCA\V1\Client; -use Google\Cloud\Security\PrivateCA\V1\Client\BaseClient\CertificateAuthorityServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\Security\PrivateCA\V1\ActivateCertificateAuthorityRequest; +use Google\Cloud\Security\PrivateCA\V1\CaPool; +use Google\Cloud\Security\PrivateCA\V1\Certificate; +use Google\Cloud\Security\PrivateCA\V1\CertificateAuthority; +use Google\Cloud\Security\PrivateCA\V1\CertificateRevocationList; +use Google\Cloud\Security\PrivateCA\V1\CertificateTemplate; +use Google\Cloud\Security\PrivateCA\V1\CreateCaPoolRequest; +use Google\Cloud\Security\PrivateCA\V1\CreateCertificateAuthorityRequest; +use Google\Cloud\Security\PrivateCA\V1\CreateCertificateRequest; +use Google\Cloud\Security\PrivateCA\V1\CreateCertificateTemplateRequest; +use Google\Cloud\Security\PrivateCA\V1\DeleteCaPoolRequest; +use Google\Cloud\Security\PrivateCA\V1\DeleteCertificateAuthorityRequest; +use Google\Cloud\Security\PrivateCA\V1\DeleteCertificateTemplateRequest; +use Google\Cloud\Security\PrivateCA\V1\DisableCertificateAuthorityRequest; +use Google\Cloud\Security\PrivateCA\V1\EnableCertificateAuthorityRequest; +use Google\Cloud\Security\PrivateCA\V1\FetchCaCertsRequest; +use Google\Cloud\Security\PrivateCA\V1\FetchCaCertsResponse; +use Google\Cloud\Security\PrivateCA\V1\FetchCertificateAuthorityCsrRequest; +use Google\Cloud\Security\PrivateCA\V1\FetchCertificateAuthorityCsrResponse; +use Google\Cloud\Security\PrivateCA\V1\GetCaPoolRequest; +use Google\Cloud\Security\PrivateCA\V1\GetCertificateAuthorityRequest; +use Google\Cloud\Security\PrivateCA\V1\GetCertificateRequest; +use Google\Cloud\Security\PrivateCA\V1\GetCertificateRevocationListRequest; +use Google\Cloud\Security\PrivateCA\V1\GetCertificateTemplateRequest; +use Google\Cloud\Security\PrivateCA\V1\ListCaPoolsRequest; +use Google\Cloud\Security\PrivateCA\V1\ListCertificateAuthoritiesRequest; +use Google\Cloud\Security\PrivateCA\V1\ListCertificateRevocationListsRequest; +use Google\Cloud\Security\PrivateCA\V1\ListCertificateTemplatesRequest; +use Google\Cloud\Security\PrivateCA\V1\ListCertificatesRequest; +use Google\Cloud\Security\PrivateCA\V1\RevokeCertificateRequest; +use Google\Cloud\Security\PrivateCA\V1\UndeleteCertificateAuthorityRequest; +use Google\Cloud\Security\PrivateCA\V1\UpdateCaPoolRequest; +use Google\Cloud\Security\PrivateCA\V1\UpdateCertificateAuthorityRequest; +use Google\Cloud\Security\PrivateCA\V1\UpdateCertificateRequest; +use Google\Cloud\Security\PrivateCA\V1\UpdateCertificateRevocationListRequest; +use Google\Cloud\Security\PrivateCA\V1\UpdateCertificateTemplateRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: [Certificate Authority + * Service][google.cloud.security.privateca.v1.CertificateAuthorityService] + * manages private certificate authorities and issued certificates. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Security\PrivateCA\V1\CertificateAuthorityServiceClient} for the + * stable implementation * * @experimental + * + * @method PromiseInterface activateCertificateAuthorityAsync(ActivateCertificateAuthorityRequest $request, array $optionalArgs = []) + * @method PromiseInterface createCaPoolAsync(CreateCaPoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface createCertificateAsync(CreateCertificateRequest $request, array $optionalArgs = []) + * @method PromiseInterface createCertificateAuthorityAsync(CreateCertificateAuthorityRequest $request, array $optionalArgs = []) + * @method PromiseInterface createCertificateTemplateAsync(CreateCertificateTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteCaPoolAsync(DeleteCaPoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteCertificateAuthorityAsync(DeleteCertificateAuthorityRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteCertificateTemplateAsync(DeleteCertificateTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface disableCertificateAuthorityAsync(DisableCertificateAuthorityRequest $request, array $optionalArgs = []) + * @method PromiseInterface enableCertificateAuthorityAsync(EnableCertificateAuthorityRequest $request, array $optionalArgs = []) + * @method PromiseInterface fetchCaCertsAsync(FetchCaCertsRequest $request, array $optionalArgs = []) + * @method PromiseInterface fetchCertificateAuthorityCsrAsync(FetchCertificateAuthorityCsrRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCaPoolAsync(GetCaPoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCertificateAsync(GetCertificateRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCertificateAuthorityAsync(GetCertificateAuthorityRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCertificateRevocationListAsync(GetCertificateRevocationListRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCertificateTemplateAsync(GetCertificateTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCaPoolsAsync(ListCaPoolsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCertificateAuthoritiesAsync(ListCertificateAuthoritiesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCertificateRevocationListsAsync(ListCertificateRevocationListsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCertificateTemplatesAsync(ListCertificateTemplatesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCertificatesAsync(ListCertificatesRequest $request, array $optionalArgs = []) + * @method PromiseInterface revokeCertificateAsync(RevokeCertificateRequest $request, array $optionalArgs = []) + * @method PromiseInterface undeleteCertificateAuthorityAsync(UndeleteCertificateAuthorityRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCaPoolAsync(UpdateCaPoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCertificateAsync(UpdateCertificateRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCertificateAuthorityAsync(UpdateCertificateAuthorityRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCertificateRevocationListAsync(UpdateCertificateRevocationListRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCertificateTemplateAsync(UpdateCertificateTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class CertificateAuthorityServiceClient extends CertificateAuthorityServiceBaseClient +final class CertificateAuthorityServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CertificateAuthorityServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.security.privateca.v1.CertificateAuthorityService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'privateca.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/certificate_authority_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/certificate_authority_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/certificate_authority_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/certificate_authority_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a ca_pool + * resource. + * + * @param string $project + * @param string $location + * @param string $caPool + * + * @return string The formatted ca_pool resource. + */ + public static function caPoolName(string $project, string $location, string $caPool): string + { + return self::getPathTemplate('caPool')->render([ + 'project' => $project, + 'location' => $location, + 'ca_pool' => $caPool, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a certificate + * resource. + * + * @param string $project + * @param string $location + * @param string $caPool + * @param string $certificate + * + * @return string The formatted certificate resource. + */ + public static function certificateName(string $project, string $location, string $caPool, string $certificate): string + { + return self::getPathTemplate('certificate')->render([ + 'project' => $project, + 'location' => $location, + 'ca_pool' => $caPool, + 'certificate' => $certificate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * certificate_authority resource. + * + * @param string $project + * @param string $location + * @param string $caPool + * @param string $certificateAuthority + * + * @return string The formatted certificate_authority resource. + */ + public static function certificateAuthorityName(string $project, string $location, string $caPool, string $certificateAuthority): string + { + return self::getPathTemplate('certificateAuthority')->render([ + 'project' => $project, + 'location' => $location, + 'ca_pool' => $caPool, + 'certificate_authority' => $certificateAuthority, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * certificate_revocation_list resource. + * + * @param string $project + * @param string $location + * @param string $caPool + * @param string $certificateAuthority + * @param string $certificateRevocationList + * + * @return string The formatted certificate_revocation_list resource. + */ + public static function certificateRevocationListName(string $project, string $location, string $caPool, string $certificateAuthority, string $certificateRevocationList): string + { + return self::getPathTemplate('certificateRevocationList')->render([ + 'project' => $project, + 'location' => $location, + 'ca_pool' => $caPool, + 'certificate_authority' => $certificateAuthority, + 'certificate_revocation_list' => $certificateRevocationList, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * certificate_template resource. + * + * @param string $project + * @param string $location + * @param string $certificateTemplate + * + * @return string The formatted certificate_template resource. + */ + public static function certificateTemplateName(string $project, string $location, string $certificateTemplate): string + { + return self::getPathTemplate('certificateTemplate')->render([ + 'project' => $project, + 'location' => $location, + 'certificate_template' => $certificateTemplate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - caPool: projects/{project}/locations/{location}/caPools/{ca_pool} + * - certificate: projects/{project}/locations/{location}/caPools/{ca_pool}/certificates/{certificate} + * - certificateAuthority: projects/{project}/locations/{location}/caPools/{ca_pool}/certificateAuthorities/{certificate_authority} + * - certificateRevocationList: projects/{project}/locations/{location}/caPools/{ca_pool}/certificateAuthorities/{certificate_authority}/certificateRevocationLists/{certificate_revocation_list} + * - certificateTemplate: projects/{project}/locations/{location}/certificateTemplates/{certificate_template} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'privateca.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Activate a + * [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + * that is in state + * [AWAITING_USER_ACTIVATION][google.cloud.security.privateca.v1.CertificateAuthority.State.AWAITING_USER_ACTIVATION] + * and is of type + * [SUBORDINATE][google.cloud.security.privateca.v1.CertificateAuthority.Type.SUBORDINATE]. + * After the parent Certificate Authority signs a certificate signing request + * from + * [FetchCertificateAuthorityCsr][google.cloud.security.privateca.v1.CertificateAuthorityService.FetchCertificateAuthorityCsr], + * this method can complete the activation process. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::activateCertificateAuthorityAsync()} . + * + * @param ActivateCertificateAuthorityRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function activateCertificateAuthority(ActivateCertificateAuthorityRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ActivateCertificateAuthority', $request, $callOptions)->wait(); + } + + /** + * Create a [CaPool][google.cloud.security.privateca.v1.CaPool]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::createCaPoolAsync()} . + * + * @param CreateCaPoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCaPool(CreateCaPoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateCaPool', $request, $callOptions)->wait(); + } + + /** + * Create a new [Certificate][google.cloud.security.privateca.v1.Certificate] + * in a given Project, Location from a particular + * [CaPool][google.cloud.security.privateca.v1.CaPool]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::createCertificateAsync()} . + * + * @param CreateCertificateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Certificate + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCertificate(CreateCertificateRequest $request, array $callOptions = []): Certificate + { + return $this->startApiCall('CreateCertificate', $request, $callOptions)->wait(); + } + + /** + * Create a new + * [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + * in a given Project and Location. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::createCertificateAuthorityAsync()} . + * + * @param CreateCertificateAuthorityRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCertificateAuthority(CreateCertificateAuthorityRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateCertificateAuthority', $request, $callOptions)->wait(); + } + + /** + * Create a new + * [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate] + * in a given Project and Location. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::createCertificateTemplateAsync()} . + * + * @param CreateCertificateTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCertificateTemplate(CreateCertificateTemplateRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateCertificateTemplate', $request, $callOptions)->wait(); + } + + /** + * Delete a [CaPool][google.cloud.security.privateca.v1.CaPool]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::deleteCaPoolAsync()} . + * + * @param DeleteCaPoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteCaPool(DeleteCaPoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteCaPool', $request, $callOptions)->wait(); + } + + /** + * Delete a + * [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::deleteCertificateAuthorityAsync()} . + * + * @param DeleteCertificateAuthorityRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteCertificateAuthority(DeleteCertificateAuthorityRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteCertificateAuthority', $request, $callOptions)->wait(); + } + + /** + * DeleteCertificateTemplate deletes a + * [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::deleteCertificateTemplateAsync()} . + * + * @param DeleteCertificateTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteCertificateTemplate(DeleteCertificateTemplateRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteCertificateTemplate', $request, $callOptions)->wait(); + } + + /** + * Disable a + * [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::disableCertificateAuthorityAsync()} . + * + * @param DisableCertificateAuthorityRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function disableCertificateAuthority(DisableCertificateAuthorityRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DisableCertificateAuthority', $request, $callOptions)->wait(); + } + + /** + * Enable a + * [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::enableCertificateAuthorityAsync()} . + * + * @param EnableCertificateAuthorityRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function enableCertificateAuthority(EnableCertificateAuthorityRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('EnableCertificateAuthority', $request, $callOptions)->wait(); + } + + /** + * FetchCaCerts returns the current trust anchor for the + * [CaPool][google.cloud.security.privateca.v1.CaPool]. This will include CA + * certificate chains for all ACTIVE + * [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + * resources in the [CaPool][google.cloud.security.privateca.v1.CaPool]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::fetchCaCertsAsync()} . + * + * @param FetchCaCertsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FetchCaCertsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function fetchCaCerts(FetchCaCertsRequest $request, array $callOptions = []): FetchCaCertsResponse + { + return $this->startApiCall('FetchCaCerts', $request, $callOptions)->wait(); + } + + /** + * Fetch a certificate signing request (CSR) from a + * [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + * that is in state + * [AWAITING_USER_ACTIVATION][google.cloud.security.privateca.v1.CertificateAuthority.State.AWAITING_USER_ACTIVATION] + * and is of type + * [SUBORDINATE][google.cloud.security.privateca.v1.CertificateAuthority.Type.SUBORDINATE]. + * The CSR must then be signed by the desired parent Certificate Authority, + * which could be another + * [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + * resource, or could be an on-prem certificate authority. See also + * [ActivateCertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthorityService.ActivateCertificateAuthority]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::fetchCertificateAuthorityCsrAsync()} . + * + * @param FetchCertificateAuthorityCsrRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FetchCertificateAuthorityCsrResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function fetchCertificateAuthorityCsr(FetchCertificateAuthorityCsrRequest $request, array $callOptions = []): FetchCertificateAuthorityCsrResponse + { + return $this->startApiCall('FetchCertificateAuthorityCsr', $request, $callOptions)->wait(); + } + + /** + * Returns a [CaPool][google.cloud.security.privateca.v1.CaPool]. + * + * The async variant is {@see CertificateAuthorityServiceClient::getCaPoolAsync()} + * . + * + * @param GetCaPoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CaPool + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCaPool(GetCaPoolRequest $request, array $callOptions = []): CaPool + { + return $this->startApiCall('GetCaPool', $request, $callOptions)->wait(); + } + + /** + * Returns a [Certificate][google.cloud.security.privateca.v1.Certificate]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::getCertificateAsync()} . + * + * @param GetCertificateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Certificate + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCertificate(GetCertificateRequest $request, array $callOptions = []): Certificate + { + return $this->startApiCall('GetCertificate', $request, $callOptions)->wait(); + } + + /** + * Returns a + * [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::getCertificateAuthorityAsync()} . + * + * @param GetCertificateAuthorityRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CertificateAuthority + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCertificateAuthority(GetCertificateAuthorityRequest $request, array $callOptions = []): CertificateAuthority + { + return $this->startApiCall('GetCertificateAuthority', $request, $callOptions)->wait(); + } + + /** + * Returns a + * [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::getCertificateRevocationListAsync()} . + * + * @param GetCertificateRevocationListRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CertificateRevocationList + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCertificateRevocationList(GetCertificateRevocationListRequest $request, array $callOptions = []): CertificateRevocationList + { + return $this->startApiCall('GetCertificateRevocationList', $request, $callOptions)->wait(); + } + + /** + * Returns a + * [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::getCertificateTemplateAsync()} . + * + * @param GetCertificateTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CertificateTemplate + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCertificateTemplate(GetCertificateTemplateRequest $request, array $callOptions = []): CertificateTemplate + { + return $this->startApiCall('GetCertificateTemplate', $request, $callOptions)->wait(); + } + + /** + * Lists [CaPools][google.cloud.security.privateca.v1.CaPool]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::listCaPoolsAsync()} . + * + * @param ListCaPoolsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCaPools(ListCaPoolsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCaPools', $request, $callOptions); + } + + /** + * Lists + * [CertificateAuthorities][google.cloud.security.privateca.v1.CertificateAuthority]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::listCertificateAuthoritiesAsync()} . + * + * @param ListCertificateAuthoritiesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCertificateAuthorities(ListCertificateAuthoritiesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCertificateAuthorities', $request, $callOptions); + } + + /** + * Lists + * [CertificateRevocationLists][google.cloud.security.privateca.v1.CertificateRevocationList]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::listCertificateRevocationListsAsync()} + * . + * + * @param ListCertificateRevocationListsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCertificateRevocationLists(ListCertificateRevocationListsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCertificateRevocationLists', $request, $callOptions); + } + + /** + * Lists + * [CertificateTemplates][google.cloud.security.privateca.v1.CertificateTemplate]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::listCertificateTemplatesAsync()} . + * + * @param ListCertificateTemplatesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCertificateTemplates(ListCertificateTemplatesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCertificateTemplates', $request, $callOptions); + } + + /** + * Lists [Certificates][google.cloud.security.privateca.v1.Certificate]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::listCertificatesAsync()} . + * + * @param ListCertificatesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCertificates(ListCertificatesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCertificates', $request, $callOptions); + } + + /** + * Revoke a [Certificate][google.cloud.security.privateca.v1.Certificate]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::revokeCertificateAsync()} . + * + * @param RevokeCertificateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Certificate + * + * @throws ApiException Thrown if the API call fails. + */ + public function revokeCertificate(RevokeCertificateRequest $request, array $callOptions = []): Certificate + { + return $this->startApiCall('RevokeCertificate', $request, $callOptions)->wait(); + } + + /** + * Undelete a + * [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority] + * that has been deleted. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::undeleteCertificateAuthorityAsync()} . + * + * @param UndeleteCertificateAuthorityRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function undeleteCertificateAuthority(UndeleteCertificateAuthorityRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UndeleteCertificateAuthority', $request, $callOptions)->wait(); + } + + /** + * Update a [CaPool][google.cloud.security.privateca.v1.CaPool]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::updateCaPoolAsync()} . + * + * @param UpdateCaPoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCaPool(UpdateCaPoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateCaPool', $request, $callOptions)->wait(); + } + + /** + * Update a [Certificate][google.cloud.security.privateca.v1.Certificate]. + * Currently, the only field you can update is the + * [labels][google.cloud.security.privateca.v1.Certificate.labels] field. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::updateCertificateAsync()} . + * + * @param UpdateCertificateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Certificate + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCertificate(UpdateCertificateRequest $request, array $callOptions = []): Certificate + { + return $this->startApiCall('UpdateCertificate', $request, $callOptions)->wait(); + } + + /** + * Update a + * [CertificateAuthority][google.cloud.security.privateca.v1.CertificateAuthority]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::updateCertificateAuthorityAsync()} . + * + * @param UpdateCertificateAuthorityRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCertificateAuthority(UpdateCertificateAuthorityRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateCertificateAuthority', $request, $callOptions)->wait(); + } + + /** + * Update a + * [CertificateRevocationList][google.cloud.security.privateca.v1.CertificateRevocationList]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::updateCertificateRevocationListAsync()} + * . + * + * @param UpdateCertificateRevocationListRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCertificateRevocationList(UpdateCertificateRevocationListRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateCertificateRevocationList', $request, $callOptions)->wait(); + } + + /** + * Update a + * [CertificateTemplate][google.cloud.security.privateca.v1.CertificateTemplate]. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::updateCertificateTemplateAsync()} . + * + * @param UpdateCertificateTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCertificateTemplate(UpdateCertificateTemplateRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateCertificateTemplate', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is + * {@see CertificateAuthorityServiceClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/SecurityPublicCA/composer.json b/SecurityPublicCA/composer.json index 7a30270b43bc..8f9b0996d57f 100644 --- a/SecurityPublicCA/composer.json +++ b/SecurityPublicCA/composer.json @@ -19,7 +19,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/SecurityPublicCA/src/V1beta1/Client/BaseClient/PublicCertificateAuthorityServiceBaseClient.php b/SecurityPublicCA/src/V1beta1/Client/BaseClient/PublicCertificateAuthorityServiceBaseClient.php deleted file mode 100644 index 32457985d7d1..000000000000 --- a/SecurityPublicCA/src/V1beta1/Client/BaseClient/PublicCertificateAuthorityServiceBaseClient.php +++ /dev/null @@ -1,270 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/public_certificate_authority_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/public_certificate_authority_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/public_certificate_authority_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/public_certificate_authority_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * external_account_key resource. - * - * @param string $project - * @param string $location - * @param string $externalAccountKey - * - * @return string The formatted external_account_key resource. - * - * @experimental - */ - public static function externalAccountKeyName(string $project, string $location, string $externalAccountKey): string - { - return self::getPathTemplate('externalAccountKey')->render([ - 'project' => $project, - 'location' => $location, - 'external_account_key' => $externalAccountKey, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - * - * @experimental - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - externalAccountKey: projects/{project}/locations/{location}/externalAccountKeys/{external_account_key} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'publicca.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); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new [ExternalAccountKey][google.cloud.security.publicca.v1beta1.ExternalAccountKey] bound to the project. - * - * The async variant is {@see self::createExternalAccountKeyAsync()} . - * - * @example samples/V1beta1/PublicCertificateAuthorityServiceClient/create_external_account_key.php - * - * @param CreateExternalAccountKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ExternalAccountKey - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function createExternalAccountKey(CreateExternalAccountKeyRequest $request, array $callOptions = []): ExternalAccountKey - { - return $this->startApiCall('CreateExternalAccountKey', $request, $callOptions)->wait(); - } -} diff --git a/SecurityPublicCA/src/V1beta1/Client/PublicCertificateAuthorityServiceClient.php b/SecurityPublicCA/src/V1beta1/Client/PublicCertificateAuthorityServiceClient.php index c9195cf2b2e1..de41ff4d0265 100644 --- a/SecurityPublicCA/src/V1beta1/Client/PublicCertificateAuthorityServiceClient.php +++ b/SecurityPublicCA/src/V1beta1/Client/PublicCertificateAuthorityServiceClient.php @@ -26,17 +26,245 @@ namespace Google\Cloud\Security\PublicCA\V1beta1\Client; -use Google\Cloud\Security\PublicCA\V1beta1\Client\BaseClient\PublicCertificateAuthorityServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Security\PublicCA\V1beta1\CreateExternalAccountKeyRequest; +use Google\Cloud\Security\PublicCA\V1beta1\ExternalAccountKey; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Manages the resources required for ACME [external account + * binding](https://tools.ietf.org/html/rfc8555#section-7.3.4) for + * the public certificate authority service. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createExternalAccountKeyAsync(CreateExternalAccountKeyRequest $request, array $optionalArgs = []) */ -final class PublicCertificateAuthorityServiceClient extends PublicCertificateAuthorityServiceBaseClient +final class PublicCertificateAuthorityServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see PublicCertificateAuthorityServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.security.publicca.v1beta1.PublicCertificateAuthorityService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'publicca.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/public_certificate_authority_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/public_certificate_authority_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/public_certificate_authority_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/public_certificate_authority_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * external_account_key resource. + * + * @param string $project + * @param string $location + * @param string $externalAccountKey + * + * @return string The formatted external_account_key resource. + * + * @experimental + */ + public static function externalAccountKeyName(string $project, string $location, string $externalAccountKey): string + { + return self::getPathTemplate('externalAccountKey')->render([ + 'project' => $project, + 'location' => $location, + 'external_account_key' => $externalAccountKey, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + * + * @experimental + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - externalAccountKey: projects/{project}/locations/{location}/externalAccountKeys/{external_account_key} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'publicca.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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new [ExternalAccountKey][google.cloud.security.publicca.v1beta1.ExternalAccountKey] bound to the project. + * + * The async variant is + * {@see PublicCertificateAuthorityServiceClient::createExternalAccountKeyAsync()} + * . + * + * @example samples/V1beta1/PublicCertificateAuthorityServiceClient/create_external_account_key.php + * + * @param CreateExternalAccountKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ExternalAccountKey + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function createExternalAccountKey(CreateExternalAccountKeyRequest $request, array $callOptions = []): ExternalAccountKey + { + return $this->startApiCall('CreateExternalAccountKey', $request, $callOptions)->wait(); + } } diff --git a/ServiceControl/composer.json b/ServiceControl/composer.json index e4a1eaaa410f..71549df73433 100644 --- a/ServiceControl/composer.json +++ b/ServiceControl/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.20.0" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/ServiceControl/src/V1/Client/BaseClient/QuotaControllerBaseClient.php b/ServiceControl/src/V1/Client/BaseClient/QuotaControllerBaseClient.php deleted file mode 100644 index 37d6c36d6fdd..000000000000 --- a/ServiceControl/src/V1/Client/BaseClient/QuotaControllerBaseClient.php +++ /dev/null @@ -1,202 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/quota_controller_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/quota_controller_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/quota_controller_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/quota_controller_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'servicecontrol.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Attempts to allocate quota for the specified consumer. It should be called - * before the operation is executed. - * - * This method requires the `servicemanagement.services.quota` - * permission on the specified service. For more information, see - * [Cloud IAM](https://cloud.google.com/iam). - * - * **NOTE:** The client **must** fail-open on server errors `INTERNAL`, - * `UNKNOWN`, `DEADLINE_EXCEEDED`, and `UNAVAILABLE`. To ensure system - * reliability, the server may inject these errors to prohibit any hard - * dependency on the quota functionality. - * - * The async variant is {@see self::allocateQuotaAsync()} . - * - * @param AllocateQuotaRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AllocateQuotaResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function allocateQuota(AllocateQuotaRequest $request, array $callOptions = []): AllocateQuotaResponse - { - return $this->startApiCall('AllocateQuota', $request, $callOptions)->wait(); - } -} diff --git a/ServiceControl/src/V1/Client/BaseClient/ServiceControllerBaseClient.php b/ServiceControl/src/V1/Client/BaseClient/ServiceControllerBaseClient.php deleted file mode 100644 index 4d6431d23f85..000000000000 --- a/ServiceControl/src/V1/Client/BaseClient/ServiceControllerBaseClient.php +++ /dev/null @@ -1,250 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/service_controller_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/service_controller_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/service_controller_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/service_controller_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'servicecontrol.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Checks whether an operation on a service should be allowed to proceed - * based on the configuration of the service and related policies. It must be - * called before the operation is executed. - * - * If feasible, the client should cache the check results and reuse them for - * 60 seconds. In case of any server errors, the client should rely on the - * cached results for much longer time to avoid outage. - * WARNING: There is general 60s delay for the configuration and policy - * propagation, therefore callers MUST NOT depend on the `Check` method having - * the latest policy information. - * - * NOTE: the [CheckRequest][google.api.servicecontrol.v1.CheckRequest] has - * the size limit (wire-format byte size) of 1MB. - * - * This method requires the `servicemanagement.services.check` permission - * on the specified service. For more information, see - * [Cloud IAM](https://cloud.google.com/iam). - * - * The async variant is {@see self::checkAsync()} . - * - * @param CheckRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CheckResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function check(CheckRequest $request, array $callOptions = []): CheckResponse - { - return $this->startApiCall('Check', $request, $callOptions)->wait(); - } - - /** - * Reports operation results to Google Service Control, such as logs and - * metrics. It should be called after an operation is completed. - * - * If feasible, the client should aggregate reporting data for up to 5 - * seconds to reduce API traffic. Limiting aggregation to 5 seconds is to - * reduce data loss during client crashes. Clients should carefully choose - * the aggregation time window to avoid data loss risk more than 0.01% - * for business and compliance reasons. - * - * NOTE: the [ReportRequest][google.api.servicecontrol.v1.ReportRequest] has - * the size limit (wire-format byte size) of 1MB. - * - * This method requires the `servicemanagement.services.report` permission - * on the specified service. For more information, see - * [Google Cloud IAM](https://cloud.google.com/iam). - * - * The async variant is {@see self::reportAsync()} . - * - * @param ReportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ReportResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function report(ReportRequest $request, array $callOptions = []): ReportResponse - { - return $this->startApiCall('Report', $request, $callOptions)->wait(); - } -} diff --git a/ServiceControl/src/V1/Client/QuotaControllerClient.php b/ServiceControl/src/V1/Client/QuotaControllerClient.php index 8402a915f60d..af2e5bd5e55d 100644 --- a/ServiceControl/src/V1/Client/QuotaControllerClient.php +++ b/ServiceControl/src/V1/Client/QuotaControllerClient.php @@ -24,17 +24,177 @@ namespace Google\Cloud\ServiceControl\V1\Client; -use Google\Cloud\ServiceControl\V1\Client\BaseClient\QuotaControllerBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\ServiceControl\V1\AllocateQuotaRequest; +use Google\Cloud\ServiceControl\V1\AllocateQuotaResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: [Google Quota Control API](https://cloud.google.com/service-control/overview) * - * This class is currently experimental and may be subject to changes. + * Allows clients to allocate and release quota against a [managed + * service](https://cloud.google.com/service-management/reference/rpc/google.api/servicemanagement.v1#google.api.servicemanagement.v1.ManagedService). + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ServiceControl\V1\QuotaControllerClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface allocateQuotaAsync(AllocateQuotaRequest $request, array $optionalArgs = []) */ -final class QuotaControllerClient extends QuotaControllerBaseClient +final class QuotaControllerClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see QuotaControllerBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.api.servicecontrol.v1.QuotaController'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'servicecontrol.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/servicecontrol', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/quota_controller_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/quota_controller_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/quota_controller_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/quota_controller_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'servicecontrol.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Attempts to allocate quota for the specified consumer. It should be called + * before the operation is executed. + * + * This method requires the `servicemanagement.services.quota` + * permission on the specified service. For more information, see + * [Cloud IAM](https://cloud.google.com/iam). + * + * **NOTE:** The client **must** fail-open on server errors `INTERNAL`, + * `UNKNOWN`, `DEADLINE_EXCEEDED`, and `UNAVAILABLE`. To ensure system + * reliability, the server may inject these errors to prohibit any hard + * dependency on the quota functionality. + * + * The async variant is {@see QuotaControllerClient::allocateQuotaAsync()} . + * + * @param AllocateQuotaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AllocateQuotaResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function allocateQuota(AllocateQuotaRequest $request, array $callOptions = []): AllocateQuotaResponse + { + return $this->startApiCall('AllocateQuota', $request, $callOptions)->wait(); + } } diff --git a/ServiceControl/src/V1/Client/ServiceControllerClient.php b/ServiceControl/src/V1/Client/ServiceControllerClient.php index aa258e44d860..80c09d76059a 100644 --- a/ServiceControl/src/V1/Client/ServiceControllerClient.php +++ b/ServiceControl/src/V1/Client/ServiceControllerClient.php @@ -24,17 +24,225 @@ namespace Google\Cloud\ServiceControl\V1\Client; -use Google\Cloud\ServiceControl\V1\Client\BaseClient\ServiceControllerBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\ServiceControl\V1\CheckRequest; +use Google\Cloud\ServiceControl\V1\CheckResponse; +use Google\Cloud\ServiceControl\V1\Operation; +use Google\Cloud\ServiceControl\V1\ReportRequest; +use Google\Cloud\ServiceControl\V1\ReportResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: [Google Service Control API](https://cloud.google.com/service-control/overview) * - * This class is currently experimental and may be subject to changes. + * Lets clients check and report operations against a [managed + * service](https://cloud.google.com/service-management/reference/rpc/google.api/servicemanagement.v1#google.api.servicemanagement.v1.ManagedService). + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ServiceControl\V1\ServiceControllerClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface checkAsync(CheckRequest $request, array $optionalArgs = []) + * @method PromiseInterface reportAsync(ReportRequest $request, array $optionalArgs = []) */ -final class ServiceControllerClient extends ServiceControllerBaseClient +final class ServiceControllerClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ServiceControllerBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.api.servicecontrol.v1.ServiceController'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'servicecontrol.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/servicecontrol', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/service_controller_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/service_controller_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/service_controller_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/service_controller_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'servicecontrol.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Checks whether an operation on a service should be allowed to proceed + * based on the configuration of the service and related policies. It must be + * called before the operation is executed. + * + * If feasible, the client should cache the check results and reuse them for + * 60 seconds. In case of any server errors, the client should rely on the + * cached results for much longer time to avoid outage. + * WARNING: There is general 60s delay for the configuration and policy + * propagation, therefore callers MUST NOT depend on the `Check` method having + * the latest policy information. + * + * NOTE: the [CheckRequest][google.api.servicecontrol.v1.CheckRequest] has + * the size limit (wire-format byte size) of 1MB. + * + * This method requires the `servicemanagement.services.check` permission + * on the specified service. For more information, see + * [Cloud IAM](https://cloud.google.com/iam). + * + * The async variant is {@see ServiceControllerClient::checkAsync()} . + * + * @param CheckRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CheckResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function check(CheckRequest $request, array $callOptions = []): CheckResponse + { + return $this->startApiCall('Check', $request, $callOptions)->wait(); + } + + /** + * Reports operation results to Google Service Control, such as logs and + * metrics. It should be called after an operation is completed. + * + * If feasible, the client should aggregate reporting data for up to 5 + * seconds to reduce API traffic. Limiting aggregation to 5 seconds is to + * reduce data loss during client crashes. Clients should carefully choose + * the aggregation time window to avoid data loss risk more than 0.01% + * for business and compliance reasons. + * + * NOTE: the [ReportRequest][google.api.servicecontrol.v1.ReportRequest] has + * the size limit (wire-format byte size) of 1MB. + * + * This method requires the `servicemanagement.services.report` permission + * on the specified service. For more information, see + * [Google Cloud IAM](https://cloud.google.com/iam). + * + * The async variant is {@see ServiceControllerClient::reportAsync()} . + * + * @param ReportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ReportResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function report(ReportRequest $request, array $callOptions = []): ReportResponse + { + return $this->startApiCall('Report', $request, $callOptions)->wait(); + } } diff --git a/ServiceDirectory/composer.json b/ServiceDirectory/composer.json index fde32fdaa82b..47d869a39356 100644 --- a/ServiceDirectory/composer.json +++ b/ServiceDirectory/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/ServiceDirectory/src/V1/Client/BaseClient/RegistrationServiceBaseClient.php b/ServiceDirectory/src/V1/Client/BaseClient/RegistrationServiceBaseClient.php deleted file mode 100644 index a5a368dd7bc6..000000000000 --- a/ServiceDirectory/src/V1/Client/BaseClient/RegistrationServiceBaseClient.php +++ /dev/null @@ -1,830 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/registration_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/registration_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/registration_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/registration_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a endpoint - * resource. - * - * @param string $project - * @param string $location - * @param string $namespace - * @param string $service - * @param string $endpoint - * - * @return string The formatted endpoint resource. - */ - public static function endpointName(string $project, string $location, string $namespace, string $service, string $endpoint): string - { - return self::getPathTemplate('endpoint')->render([ - 'project' => $project, - 'location' => $location, - 'namespace' => $namespace, - 'service' => $service, - 'endpoint' => $endpoint, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a namespace - * resource. - * - * @param string $project - * @param string $location - * @param string $namespace - * - * @return string The formatted namespace resource. - */ - public static function namespaceName(string $project, string $location, string $namespace): string - { - return self::getPathTemplate('namespace')->render([ - 'project' => $project, - 'location' => $location, - 'namespace' => $namespace, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a network - * resource. - * - * @param string $project - * @param string $network - * - * @return string The formatted network resource. - */ - public static function networkName(string $project, string $network): string - { - return self::getPathTemplate('network')->render([ - 'project' => $project, - 'network' => $network, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a service - * resource. - * - * @param string $project - * @param string $location - * @param string $namespace - * @param string $service - * - * @return string The formatted service resource. - */ - public static function serviceName(string $project, string $location, string $namespace, string $service): string - { - return self::getPathTemplate('service')->render([ - 'project' => $project, - 'location' => $location, - 'namespace' => $namespace, - 'service' => $service, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - endpoint: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}/endpoints/{endpoint} - * - location: projects/{project}/locations/{location} - * - namespace: projects/{project}/locations/{location}/namespaces/{namespace} - * - network: projects/{project}/locations/global/networks/{network} - * - service: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'servicedirectory.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates an endpoint, and returns the new endpoint. - * - * The async variant is {@see self::createEndpointAsync()} . - * - * @param CreateEndpointRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Endpoint - * - * @throws ApiException Thrown if the API call fails. - */ - public function createEndpoint(CreateEndpointRequest $request, array $callOptions = []): Endpoint - { - return $this->startApiCall('CreateEndpoint', $request, $callOptions)->wait(); - } - - /** - * Creates a namespace, and returns the new namespace. - * - * The async variant is {@see self::createNamespaceAsync()} . - * - * @param CreateNamespaceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PBNamespace - * - * @throws ApiException Thrown if the API call fails. - */ - public function createNamespace(CreateNamespaceRequest $request, array $callOptions = []): PBNamespace - { - return $this->startApiCall('CreateNamespace', $request, $callOptions)->wait(); - } - - /** - * Creates a service, and returns the new service. - * - * The async variant is {@see self::createServiceAsync()} . - * - * @param CreateServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Service - * - * @throws ApiException Thrown if the API call fails. - */ - public function createService(CreateServiceRequest $request, array $callOptions = []): Service - { - return $this->startApiCall('CreateService', $request, $callOptions)->wait(); - } - - /** - * Deletes an endpoint. - * - * The async variant is {@see self::deleteEndpointAsync()} . - * - * @param DeleteEndpointRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteEndpoint(DeleteEndpointRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteEndpoint', $request, $callOptions)->wait(); - } - - /** - * Deletes a namespace. This also deletes all services and endpoints in - * the namespace. - * - * The async variant is {@see self::deleteNamespaceAsync()} . - * - * @param DeleteNamespaceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteNamespace(DeleteNamespaceRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteNamespace', $request, $callOptions)->wait(); - } - - /** - * Deletes a service. This also deletes all endpoints associated with - * the service. - * - * The async variant is {@see self::deleteServiceAsync()} . - * - * @param DeleteServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteService(DeleteServiceRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteService', $request, $callOptions)->wait(); - } - - /** - * Gets an endpoint. - * - * The async variant is {@see self::getEndpointAsync()} . - * - * @param GetEndpointRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Endpoint - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEndpoint(GetEndpointRequest $request, array $callOptions = []): Endpoint - { - return $this->startApiCall('GetEndpoint', $request, $callOptions)->wait(); - } - - /** - * Gets the IAM Policy for a resource (namespace or service only). - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets a namespace. - * - * The async variant is {@see self::getNamespaceAsync()} . - * - * @param GetNamespaceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PBNamespace - * - * @throws ApiException Thrown if the API call fails. - */ - public function getNamespace(GetNamespaceRequest $request, array $callOptions = []): PBNamespace - { - return $this->startApiCall('GetNamespace', $request, $callOptions)->wait(); - } - - /** - * Gets a service. - * - * The async variant is {@see self::getServiceAsync()} . - * - * @param GetServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Service - * - * @throws ApiException Thrown if the API call fails. - */ - public function getService(GetServiceRequest $request, array $callOptions = []): Service - { - return $this->startApiCall('GetService', $request, $callOptions)->wait(); - } - - /** - * Lists all endpoints. - * - * The async variant is {@see self::listEndpointsAsync()} . - * - * @param ListEndpointsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listEndpoints(ListEndpointsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListEndpoints', $request, $callOptions); - } - - /** - * Lists all namespaces. - * - * The async variant is {@see self::listNamespacesAsync()} . - * - * @param ListNamespacesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listNamespaces(ListNamespacesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListNamespaces', $request, $callOptions); - } - - /** - * Lists all services belonging to a namespace. - * - * The async variant is {@see self::listServicesAsync()} . - * - * @param ListServicesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listServices(ListServicesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListServices', $request, $callOptions); - } - - /** - * Sets the IAM Policy for a resource (namespace or service only). - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Tests IAM permissions for a resource (namespace or service only). - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Updates an endpoint. - * - * The async variant is {@see self::updateEndpointAsync()} . - * - * @param UpdateEndpointRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Endpoint - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateEndpoint(UpdateEndpointRequest $request, array $callOptions = []): Endpoint - { - return $this->startApiCall('UpdateEndpoint', $request, $callOptions)->wait(); - } - - /** - * Updates a namespace. - * - * The async variant is {@see self::updateNamespaceAsync()} . - * - * @param UpdateNamespaceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PBNamespace - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateNamespace(UpdateNamespaceRequest $request, array $callOptions = []): PBNamespace - { - return $this->startApiCall('UpdateNamespace', $request, $callOptions)->wait(); - } - - /** - * Updates a service. - * - * The async variant is {@see self::updateServiceAsync()} . - * - * @param UpdateServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Service - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateService(UpdateServiceRequest $request, array $callOptions = []): Service - { - return $this->startApiCall('UpdateService', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/ServiceDirectory/src/V1/Client/LookupServiceClient.php b/ServiceDirectory/src/V1/Client/LookupServiceClient.php index 0b4dca5b04b5..5a6c7b55664d 100644 --- a/ServiceDirectory/src/V1/Client/LookupServiceClient.php +++ b/ServiceDirectory/src/V1/Client/LookupServiceClient.php @@ -24,17 +24,271 @@ namespace Google\Cloud\ServiceDirectory\V1\Client; -use Google\Cloud\ServiceDirectory\V1\Client\BaseClient\LookupServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\ServiceDirectory\V1\ResolveServiceRequest; +use Google\Cloud\ServiceDirectory\V1\ResolveServiceResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service Directory API for looking up service data at runtime. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ServiceDirectory\V1\LookupServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface resolveServiceAsync(ResolveServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class LookupServiceClient extends LookupServiceBaseClient +final class LookupServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see LookupServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.servicedirectory.v1.LookupService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'servicedirectory.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/lookup_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/lookup_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/lookup_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/lookup_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a service + * resource. + * + * @param string $project + * @param string $location + * @param string $namespace + * @param string $service + * + * @return string The formatted service resource. + */ + public static function serviceName(string $project, string $location, string $namespace, string $service): string + { + return self::getPathTemplate('service')->render([ + 'project' => $project, + 'location' => $location, + 'namespace' => $namespace, + 'service' => $service, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - service: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'servicedirectory.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Returns a [service][google.cloud.servicedirectory.v1.Service] and its + * associated endpoints. + * Resolving a service is not considered an active developer method. + * + * The async variant is {@see LookupServiceClient::resolveServiceAsync()} . + * + * @param ResolveServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ResolveServiceResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function resolveService(ResolveServiceRequest $request, array $callOptions = []): ResolveServiceResponse + { + return $this->startApiCall('ResolveService', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see LookupServiceClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see LookupServiceClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/ServiceDirectory/src/V1/Client/RegistrationServiceClient.php b/ServiceDirectory/src/V1/Client/RegistrationServiceClient.php index 7d83c47c66eb..77345f77f788 100644 --- a/ServiceDirectory/src/V1/Client/RegistrationServiceClient.php +++ b/ServiceDirectory/src/V1/Client/RegistrationServiceClient.php @@ -24,17 +24,806 @@ namespace Google\Cloud\ServiceDirectory\V1\Client; -use Google\Cloud\ServiceDirectory\V1\Client\BaseClient\RegistrationServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\ServiceDirectory\V1\CreateEndpointRequest; +use Google\Cloud\ServiceDirectory\V1\CreateNamespaceRequest; +use Google\Cloud\ServiceDirectory\V1\CreateServiceRequest; +use Google\Cloud\ServiceDirectory\V1\DeleteEndpointRequest; +use Google\Cloud\ServiceDirectory\V1\DeleteNamespaceRequest; +use Google\Cloud\ServiceDirectory\V1\DeleteServiceRequest; +use Google\Cloud\ServiceDirectory\V1\Endpoint; +use Google\Cloud\ServiceDirectory\V1\GetEndpointRequest; +use Google\Cloud\ServiceDirectory\V1\GetNamespaceRequest; +use Google\Cloud\ServiceDirectory\V1\GetServiceRequest; +use Google\Cloud\ServiceDirectory\V1\ListEndpointsRequest; +use Google\Cloud\ServiceDirectory\V1\ListNamespacesRequest; +use Google\Cloud\ServiceDirectory\V1\ListServicesRequest; +use Google\Cloud\ServiceDirectory\V1\PBNamespace; +use Google\Cloud\ServiceDirectory\V1\Service; +use Google\Cloud\ServiceDirectory\V1\UpdateEndpointRequest; +use Google\Cloud\ServiceDirectory\V1\UpdateNamespaceRequest; +use Google\Cloud\ServiceDirectory\V1\UpdateServiceRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service Directory API for registering services. It defines the following + * resource model: * - * This class is currently experimental and may be subject to changes. + * - The API has a collection of + * [Namespace][google.cloud.servicedirectory.v1.Namespace] + * resources, named `projects/*/locations/*/namespaces/*`. + * + * - Each Namespace has a collection of + * [Service][google.cloud.servicedirectory.v1.Service] resources, named + * `projects/*/locations/*/namespaces/*/services/*`. + * + * - Each Service has a collection of + * [Endpoint][google.cloud.servicedirectory.v1.Endpoint] + * resources, named + * `projects/*/locations/*/namespaces/*/services/*/endpoints/*`. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ServiceDirectory\V1\RegistrationServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createEndpointAsync(CreateEndpointRequest $request, array $optionalArgs = []) + * @method PromiseInterface createNamespaceAsync(CreateNamespaceRequest $request, array $optionalArgs = []) + * @method PromiseInterface createServiceAsync(CreateServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteEndpointAsync(DeleteEndpointRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteNamespaceAsync(DeleteNamespaceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteServiceAsync(DeleteServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEndpointAsync(GetEndpointRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getNamespaceAsync(GetNamespaceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getServiceAsync(GetServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface listEndpointsAsync(ListEndpointsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listNamespacesAsync(ListNamespacesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listServicesAsync(ListServicesRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateEndpointAsync(UpdateEndpointRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateNamespaceAsync(UpdateNamespaceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateServiceAsync(UpdateServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class RegistrationServiceClient extends RegistrationServiceBaseClient +final class RegistrationServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see RegistrationServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.servicedirectory.v1.RegistrationService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'servicedirectory.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/registration_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/registration_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/registration_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/registration_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a endpoint + * resource. + * + * @param string $project + * @param string $location + * @param string $namespace + * @param string $service + * @param string $endpoint + * + * @return string The formatted endpoint resource. + */ + public static function endpointName(string $project, string $location, string $namespace, string $service, string $endpoint): string + { + return self::getPathTemplate('endpoint')->render([ + 'project' => $project, + 'location' => $location, + 'namespace' => $namespace, + 'service' => $service, + 'endpoint' => $endpoint, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a namespace + * resource. + * + * @param string $project + * @param string $location + * @param string $namespace + * + * @return string The formatted namespace resource. + */ + public static function namespaceName(string $project, string $location, string $namespace): string + { + return self::getPathTemplate('namespace')->render([ + 'project' => $project, + 'location' => $location, + 'namespace' => $namespace, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a network + * resource. + * + * @param string $project + * @param string $network + * + * @return string The formatted network resource. + */ + public static function networkName(string $project, string $network): string + { + return self::getPathTemplate('network')->render([ + 'project' => $project, + 'network' => $network, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a service + * resource. + * + * @param string $project + * @param string $location + * @param string $namespace + * @param string $service + * + * @return string The formatted service resource. + */ + public static function serviceName(string $project, string $location, string $namespace, string $service): string + { + return self::getPathTemplate('service')->render([ + 'project' => $project, + 'location' => $location, + 'namespace' => $namespace, + 'service' => $service, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - endpoint: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}/endpoints/{endpoint} + * - location: projects/{project}/locations/{location} + * - namespace: projects/{project}/locations/{location}/namespaces/{namespace} + * - network: projects/{project}/locations/global/networks/{network} + * - service: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'servicedirectory.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates an endpoint, and returns the new endpoint. + * + * The async variant is {@see RegistrationServiceClient::createEndpointAsync()} . + * + * @param CreateEndpointRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Endpoint + * + * @throws ApiException Thrown if the API call fails. + */ + public function createEndpoint(CreateEndpointRequest $request, array $callOptions = []): Endpoint + { + return $this->startApiCall('CreateEndpoint', $request, $callOptions)->wait(); + } + + /** + * Creates a namespace, and returns the new namespace. + * + * The async variant is {@see RegistrationServiceClient::createNamespaceAsync()} . + * + * @param CreateNamespaceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PBNamespace + * + * @throws ApiException Thrown if the API call fails. + */ + public function createNamespace(CreateNamespaceRequest $request, array $callOptions = []): PBNamespace + { + return $this->startApiCall('CreateNamespace', $request, $callOptions)->wait(); + } + + /** + * Creates a service, and returns the new service. + * + * The async variant is {@see RegistrationServiceClient::createServiceAsync()} . + * + * @param CreateServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Service + * + * @throws ApiException Thrown if the API call fails. + */ + public function createService(CreateServiceRequest $request, array $callOptions = []): Service + { + return $this->startApiCall('CreateService', $request, $callOptions)->wait(); + } + + /** + * Deletes an endpoint. + * + * The async variant is {@see RegistrationServiceClient::deleteEndpointAsync()} . + * + * @param DeleteEndpointRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteEndpoint(DeleteEndpointRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteEndpoint', $request, $callOptions)->wait(); + } + + /** + * Deletes a namespace. This also deletes all services and endpoints in + * the namespace. + * + * The async variant is {@see RegistrationServiceClient::deleteNamespaceAsync()} . + * + * @param DeleteNamespaceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteNamespace(DeleteNamespaceRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteNamespace', $request, $callOptions)->wait(); + } + + /** + * Deletes a service. This also deletes all endpoints associated with + * the service. + * + * The async variant is {@see RegistrationServiceClient::deleteServiceAsync()} . + * + * @param DeleteServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteService(DeleteServiceRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteService', $request, $callOptions)->wait(); + } + + /** + * Gets an endpoint. + * + * The async variant is {@see RegistrationServiceClient::getEndpointAsync()} . + * + * @param GetEndpointRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Endpoint + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEndpoint(GetEndpointRequest $request, array $callOptions = []): Endpoint + { + return $this->startApiCall('GetEndpoint', $request, $callOptions)->wait(); + } + + /** + * Gets the IAM Policy for a resource (namespace or service only). + * + * The async variant is {@see RegistrationServiceClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets a namespace. + * + * The async variant is {@see RegistrationServiceClient::getNamespaceAsync()} . + * + * @param GetNamespaceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PBNamespace + * + * @throws ApiException Thrown if the API call fails. + */ + public function getNamespace(GetNamespaceRequest $request, array $callOptions = []): PBNamespace + { + return $this->startApiCall('GetNamespace', $request, $callOptions)->wait(); + } + + /** + * Gets a service. + * + * The async variant is {@see RegistrationServiceClient::getServiceAsync()} . + * + * @param GetServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Service + * + * @throws ApiException Thrown if the API call fails. + */ + public function getService(GetServiceRequest $request, array $callOptions = []): Service + { + return $this->startApiCall('GetService', $request, $callOptions)->wait(); + } + + /** + * Lists all endpoints. + * + * The async variant is {@see RegistrationServiceClient::listEndpointsAsync()} . + * + * @param ListEndpointsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listEndpoints(ListEndpointsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEndpoints', $request, $callOptions); + } + + /** + * Lists all namespaces. + * + * The async variant is {@see RegistrationServiceClient::listNamespacesAsync()} . + * + * @param ListNamespacesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listNamespaces(ListNamespacesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListNamespaces', $request, $callOptions); + } + + /** + * Lists all services belonging to a namespace. + * + * The async variant is {@see RegistrationServiceClient::listServicesAsync()} . + * + * @param ListServicesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listServices(ListServicesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListServices', $request, $callOptions); + } + + /** + * Sets the IAM Policy for a resource (namespace or service only). + * + * The async variant is {@see RegistrationServiceClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Tests IAM permissions for a resource (namespace or service only). + * + * The async variant is {@see RegistrationServiceClient::testIamPermissionsAsync()} + * . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates an endpoint. + * + * The async variant is {@see RegistrationServiceClient::updateEndpointAsync()} . + * + * @param UpdateEndpointRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Endpoint + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateEndpoint(UpdateEndpointRequest $request, array $callOptions = []): Endpoint + { + return $this->startApiCall('UpdateEndpoint', $request, $callOptions)->wait(); + } + + /** + * Updates a namespace. + * + * The async variant is {@see RegistrationServiceClient::updateNamespaceAsync()} . + * + * @param UpdateNamespaceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PBNamespace + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateNamespace(UpdateNamespaceRequest $request, array $callOptions = []): PBNamespace + { + return $this->startApiCall('UpdateNamespace', $request, $callOptions)->wait(); + } + + /** + * Updates a service. + * + * The async variant is {@see RegistrationServiceClient::updateServiceAsync()} . + * + * @param UpdateServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Service + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateService(UpdateServiceRequest $request, array $callOptions = []): Service + { + return $this->startApiCall('UpdateService', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see RegistrationServiceClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see RegistrationServiceClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/ServiceManagement/composer.json b/ServiceManagement/composer.json index 34a2eed18311..b135d1664d3b 100644 --- a/ServiceManagement/composer.json +++ b/ServiceManagement/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.20" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/ServiceManagement/src/V1/Client/BaseClient/ServiceManagerBaseClient.php b/ServiceManagement/src/V1/Client/BaseClient/ServiceManagerBaseClient.php deleted file mode 100644 index 6738daca6e48..000000000000 --- a/ServiceManagement/src/V1/Client/BaseClient/ServiceManagerBaseClient.php +++ /dev/null @@ -1,709 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/service_manager_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/service_manager_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/service_manager_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/service_manager_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'servicemanagement.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new managed service. - * - * A managed service is immutable, and is subject to mandatory 30-day - * data retention. You cannot move a service or recreate it within 30 days - * after deletion. - * - * One producer project can own no more than 500 services. For security and - * reliability purposes, a production service should be hosted in a - * dedicated producer project. - * - * Operation - * - * The async variant is {@see self::createServiceAsync()} . - * - * @param CreateServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createService(CreateServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateService', $request, $callOptions)->wait(); - } - - /** - * Creates a new service configuration (version) for a managed service. - * This method only stores the service configuration. To roll out the service - * configuration to backend systems please call - * [CreateServiceRollout][google.api.servicemanagement.v1.ServiceManager.CreateServiceRollout]. - * - * Only the 100 most recent service configurations and ones referenced by - * existing rollouts are kept for each service. The rest will be deleted - * eventually. - * - * The async variant is {@see self::createServiceConfigAsync()} . - * - * @param CreateServiceConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Service - * - * @throws ApiException Thrown if the API call fails. - */ - public function createServiceConfig(CreateServiceConfigRequest $request, array $callOptions = []): Service - { - return $this->startApiCall('CreateServiceConfig', $request, $callOptions)->wait(); - } - - /** - * Creates a new service configuration rollout. Based on rollout, the - * Google Service Management will roll out the service configurations to - * different backend services. For example, the logging configuration will be - * pushed to Google Cloud Logging. - * - * Please note that any previous pending and running Rollouts and associated - * Operations will be automatically cancelled so that the latest Rollout will - * not be blocked by previous Rollouts. - * - * Only the 100 most recent (in any state) and the last 10 successful (if not - * already part of the set of 100 most recent) rollouts are kept for each - * service. The rest will be deleted eventually. - * - * Operation - * - * The async variant is {@see self::createServiceRolloutAsync()} . - * - * @param CreateServiceRolloutRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createServiceRollout(CreateServiceRolloutRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateServiceRollout', $request, $callOptions)->wait(); - } - - /** - * Deletes a managed service. This method will change the service to the - * `Soft-Delete` state for 30 days. Within this period, service producers may - * call - * [UndeleteService][google.api.servicemanagement.v1.ServiceManager.UndeleteService] - * to restore the service. After 30 days, the service will be permanently - * deleted. - * - * Operation - * - * The async variant is {@see self::deleteServiceAsync()} . - * - * @param DeleteServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteService(DeleteServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteService', $request, $callOptions)->wait(); - } - - /** - * Generates and returns a report (errors, warnings and changes from - * existing configurations) associated with - * GenerateConfigReportRequest.new_value - * - * If GenerateConfigReportRequest.old_value is specified, - * GenerateConfigReportRequest will contain a single ChangeReport based on the - * comparison between GenerateConfigReportRequest.new_value and - * GenerateConfigReportRequest.old_value. - * If GenerateConfigReportRequest.old_value is not specified, this method - * will compare GenerateConfigReportRequest.new_value with the last pushed - * service configuration. - * - * The async variant is {@see self::generateConfigReportAsync()} . - * - * @param GenerateConfigReportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GenerateConfigReportResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function generateConfigReport(GenerateConfigReportRequest $request, array $callOptions = []): GenerateConfigReportResponse - { - return $this->startApiCall('GenerateConfigReport', $request, $callOptions)->wait(); - } - - /** - * Gets a managed service. Authentication is required unless the service is - * public. - * - * The async variant is {@see self::getServiceAsync()} . - * - * @param GetServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ManagedService - * - * @throws ApiException Thrown if the API call fails. - */ - public function getService(GetServiceRequest $request, array $callOptions = []): ManagedService - { - return $this->startApiCall('GetService', $request, $callOptions)->wait(); - } - - /** - * Gets a service configuration (version) for a managed service. - * - * The async variant is {@see self::getServiceConfigAsync()} . - * - * @param GetServiceConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Service - * - * @throws ApiException Thrown if the API call fails. - */ - public function getServiceConfig(GetServiceConfigRequest $request, array $callOptions = []): Service - { - return $this->startApiCall('GetServiceConfig', $request, $callOptions)->wait(); - } - - /** - * Gets a service configuration - * [rollout][google.api.servicemanagement.v1.Rollout]. - * - * The async variant is {@see self::getServiceRolloutAsync()} . - * - * @param GetServiceRolloutRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Rollout - * - * @throws ApiException Thrown if the API call fails. - */ - public function getServiceRollout(GetServiceRolloutRequest $request, array $callOptions = []): Rollout - { - return $this->startApiCall('GetServiceRollout', $request, $callOptions)->wait(); - } - - /** - * Lists the history of the service configuration for a managed service, - * from the newest to the oldest. - * - * The async variant is {@see self::listServiceConfigsAsync()} . - * - * @param ListServiceConfigsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listServiceConfigs(ListServiceConfigsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListServiceConfigs', $request, $callOptions); - } - - /** - * Lists the history of the service configuration rollouts for a managed - * service, from the newest to the oldest. - * - * The async variant is {@see self::listServiceRolloutsAsync()} . - * - * @param ListServiceRolloutsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listServiceRollouts(ListServiceRolloutsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListServiceRollouts', $request, $callOptions); - } - - /** - * Lists managed services. - * - * Returns all public services. For authenticated users, also returns all - * services the calling user has "servicemanagement.services.get" permission - * for. - * - * The async variant is {@see self::listServicesAsync()} . - * - * @param ListServicesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listServices(ListServicesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListServices', $request, $callOptions); - } - - /** - * Creates a new service configuration (version) for a managed service based - * on - * user-supplied configuration source files (for example: OpenAPI - * Specification). This method stores the source configurations as well as the - * generated service configuration. To rollout the service configuration to - * other services, - * please call - * [CreateServiceRollout][google.api.servicemanagement.v1.ServiceManager.CreateServiceRollout]. - * - * Only the 100 most recent configuration sources and ones referenced by - * existing service configurtions are kept for each service. The rest will be - * deleted eventually. - * - * Operation - * - * The async variant is {@see self::submitConfigSourceAsync()} . - * - * @param SubmitConfigSourceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function submitConfigSource(SubmitConfigSourceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SubmitConfigSource', $request, $callOptions)->wait(); - } - - /** - * Revives a previously deleted managed service. The method restores the - * service using the configuration at the time the service was deleted. - * The target service must exist and must have been deleted within the - * last 30 days. - * - * Operation - * - * The async variant is {@see self::undeleteServiceAsync()} . - * - * @param UndeleteServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function undeleteService(UndeleteServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UndeleteService', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/ServiceManagement/src/V1/Client/ServiceManagerClient.php b/ServiceManagement/src/V1/Client/ServiceManagerClient.php index 9bca3d3e358b..169a774ddd0b 100644 --- a/ServiceManagement/src/V1/Client/ServiceManagerClient.php +++ b/ServiceManagement/src/V1/Client/ServiceManagerClient.php @@ -24,17 +24,684 @@ namespace Google\Cloud\ServiceManagement\V1\Client; -use Google\Cloud\ServiceManagement\V1\Client\BaseClient\ServiceManagerBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Api\Service; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\ServiceManagement\V1\CreateServiceConfigRequest; +use Google\Cloud\ServiceManagement\V1\CreateServiceRequest; +use Google\Cloud\ServiceManagement\V1\CreateServiceRolloutRequest; +use Google\Cloud\ServiceManagement\V1\DeleteServiceRequest; +use Google\Cloud\ServiceManagement\V1\GenerateConfigReportRequest; +use Google\Cloud\ServiceManagement\V1\GenerateConfigReportResponse; +use Google\Cloud\ServiceManagement\V1\GetServiceConfigRequest; +use Google\Cloud\ServiceManagement\V1\GetServiceRequest; +use Google\Cloud\ServiceManagement\V1\GetServiceRolloutRequest; +use Google\Cloud\ServiceManagement\V1\ListServiceConfigsRequest; +use Google\Cloud\ServiceManagement\V1\ListServiceRolloutsRequest; +use Google\Cloud\ServiceManagement\V1\ListServicesRequest; +use Google\Cloud\ServiceManagement\V1\ManagedService; +use Google\Cloud\ServiceManagement\V1\Rollout; +use Google\Cloud\ServiceManagement\V1\SubmitConfigSourceRequest; +use Google\Cloud\ServiceManagement\V1\SubmitConfigSourceResponse; +use Google\Cloud\ServiceManagement\V1\UndeleteServiceRequest; +use Google\Cloud\ServiceManagement\V1\UndeleteServiceResponse; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: [Google Service Management + * API](https://cloud.google.com/service-infrastructure/docs/overview) * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ServiceManagement\V1\ServiceManagerClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createServiceAsync(CreateServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface createServiceConfigAsync(CreateServiceConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface createServiceRolloutAsync(CreateServiceRolloutRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteServiceAsync(DeleteServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface generateConfigReportAsync(GenerateConfigReportRequest $request, array $optionalArgs = []) + * @method PromiseInterface getServiceAsync(GetServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getServiceConfigAsync(GetServiceConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getServiceRolloutAsync(GetServiceRolloutRequest $request, array $optionalArgs = []) + * @method PromiseInterface listServiceConfigsAsync(ListServiceConfigsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listServiceRolloutsAsync(ListServiceRolloutsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listServicesAsync(ListServicesRequest $request, array $optionalArgs = []) + * @method PromiseInterface submitConfigSourceAsync(SubmitConfigSourceRequest $request, array $optionalArgs = []) + * @method PromiseInterface undeleteServiceAsync(UndeleteServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class ServiceManagerClient extends ServiceManagerBaseClient +final class ServiceManagerClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ServiceManagerBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.api.servicemanagement.v1.ServiceManager'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'servicemanagement.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + 'https://www.googleapis.com/auth/service.management', + 'https://www.googleapis.com/auth/service.management.readonly', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/service_manager_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/service_manager_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/service_manager_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/service_manager_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'servicemanagement.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new managed service. + * + * A managed service is immutable, and is subject to mandatory 30-day + * data retention. You cannot move a service or recreate it within 30 days + * after deletion. + * + * One producer project can own no more than 500 services. For security and + * reliability purposes, a production service should be hosted in a + * dedicated producer project. + * + * Operation + * + * The async variant is {@see ServiceManagerClient::createServiceAsync()} . + * + * @param CreateServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createService(CreateServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateService', $request, $callOptions)->wait(); + } + + /** + * Creates a new service configuration (version) for a managed service. + * This method only stores the service configuration. To roll out the service + * configuration to backend systems please call + * [CreateServiceRollout][google.api.servicemanagement.v1.ServiceManager.CreateServiceRollout]. + * + * Only the 100 most recent service configurations and ones referenced by + * existing rollouts are kept for each service. The rest will be deleted + * eventually. + * + * The async variant is {@see ServiceManagerClient::createServiceConfigAsync()} . + * + * @param CreateServiceConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Service + * + * @throws ApiException Thrown if the API call fails. + */ + public function createServiceConfig(CreateServiceConfigRequest $request, array $callOptions = []): Service + { + return $this->startApiCall('CreateServiceConfig', $request, $callOptions)->wait(); + } + + /** + * Creates a new service configuration rollout. Based on rollout, the + * Google Service Management will roll out the service configurations to + * different backend services. For example, the logging configuration will be + * pushed to Google Cloud Logging. + * + * Please note that any previous pending and running Rollouts and associated + * Operations will be automatically cancelled so that the latest Rollout will + * not be blocked by previous Rollouts. + * + * Only the 100 most recent (in any state) and the last 10 successful (if not + * already part of the set of 100 most recent) rollouts are kept for each + * service. The rest will be deleted eventually. + * + * Operation + * + * The async variant is {@see ServiceManagerClient::createServiceRolloutAsync()} . + * + * @param CreateServiceRolloutRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createServiceRollout(CreateServiceRolloutRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateServiceRollout', $request, $callOptions)->wait(); + } + + /** + * Deletes a managed service. This method will change the service to the + * `Soft-Delete` state for 30 days. Within this period, service producers may + * call + * [UndeleteService][google.api.servicemanagement.v1.ServiceManager.UndeleteService] + * to restore the service. After 30 days, the service will be permanently + * deleted. + * + * Operation + * + * The async variant is {@see ServiceManagerClient::deleteServiceAsync()} . + * + * @param DeleteServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteService(DeleteServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteService', $request, $callOptions)->wait(); + } + + /** + * Generates and returns a report (errors, warnings and changes from + * existing configurations) associated with + * GenerateConfigReportRequest.new_value + * + * If GenerateConfigReportRequest.old_value is specified, + * GenerateConfigReportRequest will contain a single ChangeReport based on the + * comparison between GenerateConfigReportRequest.new_value and + * GenerateConfigReportRequest.old_value. + * If GenerateConfigReportRequest.old_value is not specified, this method + * will compare GenerateConfigReportRequest.new_value with the last pushed + * service configuration. + * + * The async variant is {@see ServiceManagerClient::generateConfigReportAsync()} . + * + * @param GenerateConfigReportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GenerateConfigReportResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function generateConfigReport(GenerateConfigReportRequest $request, array $callOptions = []): GenerateConfigReportResponse + { + return $this->startApiCall('GenerateConfigReport', $request, $callOptions)->wait(); + } + + /** + * Gets a managed service. Authentication is required unless the service is + * public. + * + * The async variant is {@see ServiceManagerClient::getServiceAsync()} . + * + * @param GetServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ManagedService + * + * @throws ApiException Thrown if the API call fails. + */ + public function getService(GetServiceRequest $request, array $callOptions = []): ManagedService + { + return $this->startApiCall('GetService', $request, $callOptions)->wait(); + } + + /** + * Gets a service configuration (version) for a managed service. + * + * The async variant is {@see ServiceManagerClient::getServiceConfigAsync()} . + * + * @param GetServiceConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Service + * + * @throws ApiException Thrown if the API call fails. + */ + public function getServiceConfig(GetServiceConfigRequest $request, array $callOptions = []): Service + { + return $this->startApiCall('GetServiceConfig', $request, $callOptions)->wait(); + } + + /** + * Gets a service configuration + * [rollout][google.api.servicemanagement.v1.Rollout]. + * + * The async variant is {@see ServiceManagerClient::getServiceRolloutAsync()} . + * + * @param GetServiceRolloutRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Rollout + * + * @throws ApiException Thrown if the API call fails. + */ + public function getServiceRollout(GetServiceRolloutRequest $request, array $callOptions = []): Rollout + { + return $this->startApiCall('GetServiceRollout', $request, $callOptions)->wait(); + } + + /** + * Lists the history of the service configuration for a managed service, + * from the newest to the oldest. + * + * The async variant is {@see ServiceManagerClient::listServiceConfigsAsync()} . + * + * @param ListServiceConfigsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listServiceConfigs(ListServiceConfigsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListServiceConfigs', $request, $callOptions); + } + + /** + * Lists the history of the service configuration rollouts for a managed + * service, from the newest to the oldest. + * + * The async variant is {@see ServiceManagerClient::listServiceRolloutsAsync()} . + * + * @param ListServiceRolloutsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listServiceRollouts(ListServiceRolloutsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListServiceRollouts', $request, $callOptions); + } + + /** + * Lists managed services. + * + * Returns all public services. For authenticated users, also returns all + * services the calling user has "servicemanagement.services.get" permission + * for. + * + * The async variant is {@see ServiceManagerClient::listServicesAsync()} . + * + * @param ListServicesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listServices(ListServicesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListServices', $request, $callOptions); + } + + /** + * Creates a new service configuration (version) for a managed service based + * on + * user-supplied configuration source files (for example: OpenAPI + * Specification). This method stores the source configurations as well as the + * generated service configuration. To rollout the service configuration to + * other services, + * please call + * [CreateServiceRollout][google.api.servicemanagement.v1.ServiceManager.CreateServiceRollout]. + * + * Only the 100 most recent configuration sources and ones referenced by + * existing service configurtions are kept for each service. The rest will be + * deleted eventually. + * + * Operation + * + * The async variant is {@see ServiceManagerClient::submitConfigSourceAsync()} . + * + * @param SubmitConfigSourceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function submitConfigSource(SubmitConfigSourceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SubmitConfigSource', $request, $callOptions)->wait(); + } + + /** + * Revives a previously deleted managed service. The method restores the + * service using the configuration at the time the service was deleted. + * The target service must exist and must have been deleted within the + * last 30 days. + * + * Operation + * + * The async variant is {@see ServiceManagerClient::undeleteServiceAsync()} . + * + * @param UndeleteServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function undeleteService(UndeleteServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UndeleteService', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see ServiceManagerClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see ServiceManagerClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see ServiceManagerClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/ServiceUsage/composer.json b/ServiceUsage/composer.json index 2d1cde54fbf8..a01e362c4e79 100644 --- a/ServiceUsage/composer.json +++ b/ServiceUsage/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/ServiceUsage/src/V1/Client/BaseClient/ServiceUsageBaseClient.php b/ServiceUsage/src/V1/Client/BaseClient/ServiceUsageBaseClient.php deleted file mode 100644 index c9659eda5c75..000000000000 --- a/ServiceUsage/src/V1/Client/BaseClient/ServiceUsageBaseClient.php +++ /dev/null @@ -1,381 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/service_usage_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/service_usage_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/service_usage_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/service_usage_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'serviceusage.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Enable multiple services on a project. The operation is atomic: if enabling - * any service fails, then the entire batch fails, and no state changes occur. - * To enable a single service, use the `EnableService` method instead. - * - * The async variant is {@see self::batchEnableServicesAsync()} . - * - * @param BatchEnableServicesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchEnableServices(BatchEnableServicesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BatchEnableServices', $request, $callOptions)->wait(); - } - - /** - * Returns the service configurations and enabled states for a given list of - * services. - * - * The async variant is {@see self::batchGetServicesAsync()} . - * - * @param BatchGetServicesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BatchGetServicesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchGetServices(BatchGetServicesRequest $request, array $callOptions = []): BatchGetServicesResponse - { - return $this->startApiCall('BatchGetServices', $request, $callOptions)->wait(); - } - - /** - * Disable a service so that it can no longer be used with a project. - * This prevents unintended usage that may cause unexpected billing - * charges or security leaks. - * - * It is not valid to call the disable method on a service that is not - * currently enabled. Callers will receive a `FAILED_PRECONDITION` status if - * the target service is not currently enabled. - * - * The async variant is {@see self::disableServiceAsync()} . - * - * @param DisableServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function disableService(DisableServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DisableService', $request, $callOptions)->wait(); - } - - /** - * Enable a service so that it can be used with a project. - * - * The async variant is {@see self::enableServiceAsync()} . - * - * @param EnableServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function enableService(EnableServiceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('EnableService', $request, $callOptions)->wait(); - } - - /** - * Returns the service configuration and enabled state for a given service. - * - * The async variant is {@see self::getServiceAsync()} . - * - * @param GetServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Service - * - * @throws ApiException Thrown if the API call fails. - */ - public function getService(GetServiceRequest $request, array $callOptions = []): Service - { - return $this->startApiCall('GetService', $request, $callOptions)->wait(); - } - - /** - * List all services available to the specified project, and the current - * state of those services with respect to the project. The list includes - * all public services, all services for which the calling user has the - * `servicemanagement.services.bind` permission, and all services that have - * already been enabled on the project. The list can be filtered to - * only include services in a specific state, for example to only include - * services enabled on the project. - * - * WARNING: If you need to query enabled services frequently or across - * an organization, you should use - * [Cloud Asset Inventory - * API](https://cloud.google.com/asset-inventory/docs/apis), which provides - * higher throughput and richer filtering capability. - * - * The async variant is {@see self::listServicesAsync()} . - * - * @param ListServicesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listServices(ListServicesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListServices', $request, $callOptions); - } -} diff --git a/ServiceUsage/src/V1/Client/ServiceUsageClient.php b/ServiceUsage/src/V1/Client/ServiceUsageClient.php index 9f578f36abe5..f266d6e08f34 100644 --- a/ServiceUsage/src/V1/Client/ServiceUsageClient.php +++ b/ServiceUsage/src/V1/Client/ServiceUsageClient.php @@ -24,17 +24,356 @@ namespace Google\Cloud\ServiceUsage\V1\Client; -use Google\Cloud\ServiceUsage\V1\Client\BaseClient\ServiceUsageBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\ServiceUsage\V1\BatchEnableServicesRequest; +use Google\Cloud\ServiceUsage\V1\BatchGetServicesRequest; +use Google\Cloud\ServiceUsage\V1\BatchGetServicesResponse; +use Google\Cloud\ServiceUsage\V1\DisableServiceRequest; +use Google\Cloud\ServiceUsage\V1\EnableServiceRequest; +use Google\Cloud\ServiceUsage\V1\GetServiceRequest; +use Google\Cloud\ServiceUsage\V1\ListServicesRequest; +use Google\Cloud\ServiceUsage\V1\Service; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Enables services that service consumers want to use on Google Cloud Platform, + * lists the available or enabled services, or disables services that service + * consumers no longer use. * - * This class is currently experimental and may be subject to changes. + * See [Service Usage API](https://cloud.google.com/service-usage/docs/overview) + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\ServiceUsage\V1\ServiceUsageClient} for the stable implementation * * @experimental + * + * @method PromiseInterface batchEnableServicesAsync(BatchEnableServicesRequest $request, array $optionalArgs = []) + * @method PromiseInterface batchGetServicesAsync(BatchGetServicesRequest $request, array $optionalArgs = []) + * @method PromiseInterface disableServiceAsync(DisableServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface enableServiceAsync(EnableServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getServiceAsync(GetServiceRequest $request, array $optionalArgs = []) + * @method PromiseInterface listServicesAsync(ListServicesRequest $request, array $optionalArgs = []) */ -final class ServiceUsageClient extends ServiceUsageBaseClient +final class ServiceUsageClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ServiceUsageBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.api.serviceusage.v1.ServiceUsage'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'serviceusage.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + 'https://www.googleapis.com/auth/service.management', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/service_usage_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/service_usage_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/service_usage_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/service_usage_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'serviceusage.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Enable multiple services on a project. The operation is atomic: if enabling + * any service fails, then the entire batch fails, and no state changes occur. + * To enable a single service, use the `EnableService` method instead. + * + * The async variant is {@see ServiceUsageClient::batchEnableServicesAsync()} . + * + * @param BatchEnableServicesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchEnableServices(BatchEnableServicesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchEnableServices', $request, $callOptions)->wait(); + } + + /** + * Returns the service configurations and enabled states for a given list of + * services. + * + * The async variant is {@see ServiceUsageClient::batchGetServicesAsync()} . + * + * @param BatchGetServicesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BatchGetServicesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchGetServices(BatchGetServicesRequest $request, array $callOptions = []): BatchGetServicesResponse + { + return $this->startApiCall('BatchGetServices', $request, $callOptions)->wait(); + } + + /** + * Disable a service so that it can no longer be used with a project. + * This prevents unintended usage that may cause unexpected billing + * charges or security leaks. + * + * It is not valid to call the disable method on a service that is not + * currently enabled. Callers will receive a `FAILED_PRECONDITION` status if + * the target service is not currently enabled. + * + * The async variant is {@see ServiceUsageClient::disableServiceAsync()} . + * + * @param DisableServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function disableService(DisableServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DisableService', $request, $callOptions)->wait(); + } + + /** + * Enable a service so that it can be used with a project. + * + * The async variant is {@see ServiceUsageClient::enableServiceAsync()} . + * + * @param EnableServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function enableService(EnableServiceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('EnableService', $request, $callOptions)->wait(); + } + + /** + * Returns the service configuration and enabled state for a given service. + * + * The async variant is {@see ServiceUsageClient::getServiceAsync()} . + * + * @param GetServiceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Service + * + * @throws ApiException Thrown if the API call fails. + */ + public function getService(GetServiceRequest $request, array $callOptions = []): Service + { + return $this->startApiCall('GetService', $request, $callOptions)->wait(); + } + + /** + * List all services available to the specified project, and the current + * state of those services with respect to the project. The list includes + * all public services, all services for which the calling user has the + * `servicemanagement.services.bind` permission, and all services that have + * already been enabled on the project. The list can be filtered to + * only include services in a specific state, for example to only include + * services enabled on the project. + * + * WARNING: If you need to query enabled services frequently or across + * an organization, you should use + * [Cloud Asset Inventory + * API](https://cloud.google.com/asset-inventory/docs/apis), which provides + * higher throughput and richer filtering capability. + * + * The async variant is {@see ServiceUsageClient::listServicesAsync()} . + * + * @param ListServicesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listServices(ListServicesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListServices', $request, $callOptions); + } } diff --git a/Shell/composer.json b/Shell/composer.json index 5621b384a2e8..70d675eb3a53 100644 --- a/Shell/composer.json +++ b/Shell/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Shell/src/V1/Client/BaseClient/CloudShellServiceBaseClient.php b/Shell/src/V1/Client/BaseClient/CloudShellServiceBaseClient.php deleted file mode 100644 index bceadb9fa2e4..000000000000 --- a/Shell/src/V1/Client/BaseClient/CloudShellServiceBaseClient.php +++ /dev/null @@ -1,395 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/cloud_shell_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/cloud_shell_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/cloud_shell_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/cloud_shell_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a environment - * resource. - * - * @param string $user - * @param string $environment - * - * @return string The formatted environment resource. - */ - public static function environmentName(string $user, string $environment): string - { - return self::getPathTemplate('environment')->render([ - 'user' => $user, - 'environment' => $environment, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - environment: users/{user}/environments/{environment} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudshell.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Adds a public SSH key to an environment, allowing clients with the - * corresponding private key to connect to that environment via SSH. If a key - * with the same content already exists, this will error with ALREADY_EXISTS. - * - * The async variant is {@see self::addPublicKeyAsync()} . - * - * @param AddPublicKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addPublicKey(AddPublicKeyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AddPublicKey', $request, $callOptions)->wait(); - } - - /** - * Sends OAuth credentials to a running environment on behalf of a user. When - * this completes, the environment will be authorized to run various Google - * Cloud command line tools without requiring the user to manually - * authenticate. - * - * The async variant is {@see self::authorizeEnvironmentAsync()} . - * - * @param AuthorizeEnvironmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function authorizeEnvironment(AuthorizeEnvironmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AuthorizeEnvironment', $request, $callOptions)->wait(); - } - - /** - * Gets an environment. Returns NOT_FOUND if the environment does not exist. - * - * The async variant is {@see self::getEnvironmentAsync()} . - * - * @param GetEnvironmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Environment - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEnvironment(GetEnvironmentRequest $request, array $callOptions = []): Environment - { - return $this->startApiCall('GetEnvironment', $request, $callOptions)->wait(); - } - - /** - * Removes a public SSH key from an environment. Clients will no longer be - * able to connect to the environment using the corresponding private key. - * If a key with the same content is not present, this will error with - * NOT_FOUND. - * - * The async variant is {@see self::removePublicKeyAsync()} . - * - * @param RemovePublicKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function removePublicKey(RemovePublicKeyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RemovePublicKey', $request, $callOptions)->wait(); - } - - /** - * Starts an existing environment, allowing clients to connect to it. The - * returned operation will contain an instance of StartEnvironmentMetadata in - * its metadata field. Users can wait for the environment to start by polling - * this operation via GetOperation. Once the environment has finished starting - * and is ready to accept connections, the operation will contain a - * StartEnvironmentResponse in its response field. - * - * The async variant is {@see self::startEnvironmentAsync()} . - * - * @param StartEnvironmentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function startEnvironment(StartEnvironmentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StartEnvironment', $request, $callOptions)->wait(); - } -} diff --git a/Shell/src/V1/Client/CloudShellServiceClient.php b/Shell/src/V1/Client/CloudShellServiceClient.php index 342e40656668..14639c2aace9 100644 --- a/Shell/src/V1/Client/CloudShellServiceClient.php +++ b/Shell/src/V1/Client/CloudShellServiceClient.php @@ -24,17 +24,371 @@ namespace Google\Cloud\Shell\V1\Client; -use Google\Cloud\Shell\V1\Client\BaseClient\CloudShellServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Shell\V1\AddPublicKeyRequest; +use Google\Cloud\Shell\V1\AuthorizeEnvironmentRequest; +use Google\Cloud\Shell\V1\Environment; +use Google\Cloud\Shell\V1\GetEnvironmentRequest; +use Google\Cloud\Shell\V1\RemovePublicKeyRequest; +use Google\Cloud\Shell\V1\StartEnvironmentMetadata; +use Google\Cloud\Shell\V1\StartEnvironmentRequest; +use Google\Cloud\Shell\V1\StartEnvironmentResponse; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: API for interacting with Google Cloud Shell. Each user of Cloud Shell has at + * least one environment, which has the ID "default". Environment consists of a + * Docker image defining what is installed on the environment and a home + * directory containing the user's data that will remain across sessions. + * Clients use this API to start and fetch information about their environment, + * which can then be used to connect to that environment via a separate SSH + * client. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Shell\V1\CloudShellServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface addPublicKeyAsync(AddPublicKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface authorizeEnvironmentAsync(AuthorizeEnvironmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEnvironmentAsync(GetEnvironmentRequest $request, array $optionalArgs = []) + * @method PromiseInterface removePublicKeyAsync(RemovePublicKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface startEnvironmentAsync(StartEnvironmentRequest $request, array $optionalArgs = []) */ -final class CloudShellServiceClient extends CloudShellServiceBaseClient +final class CloudShellServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CloudShellServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.shell.v1.CloudShellService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudshell.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/cloud_shell_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/cloud_shell_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/cloud_shell_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/cloud_shell_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a environment + * resource. + * + * @param string $user + * @param string $environment + * + * @return string The formatted environment resource. + */ + public static function environmentName(string $user, string $environment): string + { + return self::getPathTemplate('environment')->render([ + 'user' => $user, + 'environment' => $environment, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - environment: users/{user}/environments/{environment} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudshell.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Adds a public SSH key to an environment, allowing clients with the + * corresponding private key to connect to that environment via SSH. If a key + * with the same content already exists, this will error with ALREADY_EXISTS. + * + * The async variant is {@see CloudShellServiceClient::addPublicKeyAsync()} . + * + * @param AddPublicKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addPublicKey(AddPublicKeyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddPublicKey', $request, $callOptions)->wait(); + } + + /** + * Sends OAuth credentials to a running environment on behalf of a user. When + * this completes, the environment will be authorized to run various Google + * Cloud command line tools without requiring the user to manually + * authenticate. + * + * The async variant is {@see CloudShellServiceClient::authorizeEnvironmentAsync()} + * . + * + * @param AuthorizeEnvironmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function authorizeEnvironment(AuthorizeEnvironmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AuthorizeEnvironment', $request, $callOptions)->wait(); + } + + /** + * Gets an environment. Returns NOT_FOUND if the environment does not exist. + * + * The async variant is {@see CloudShellServiceClient::getEnvironmentAsync()} . + * + * @param GetEnvironmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Environment + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEnvironment(GetEnvironmentRequest $request, array $callOptions = []): Environment + { + return $this->startApiCall('GetEnvironment', $request, $callOptions)->wait(); + } + + /** + * Removes a public SSH key from an environment. Clients will no longer be + * able to connect to the environment using the corresponding private key. + * If a key with the same content is not present, this will error with + * NOT_FOUND. + * + * The async variant is {@see CloudShellServiceClient::removePublicKeyAsync()} . + * + * @param RemovePublicKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function removePublicKey(RemovePublicKeyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RemovePublicKey', $request, $callOptions)->wait(); + } + + /** + * Starts an existing environment, allowing clients to connect to it. The + * returned operation will contain an instance of StartEnvironmentMetadata in + * its metadata field. Users can wait for the environment to start by polling + * this operation via GetOperation. Once the environment has finished starting + * and is ready to accept connections, the operation will contain a + * StartEnvironmentResponse in its response field. + * + * The async variant is {@see CloudShellServiceClient::startEnvironmentAsync()} . + * + * @param StartEnvironmentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function startEnvironment(StartEnvironmentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StartEnvironment', $request, $callOptions)->wait(); + } } diff --git a/ShoppingCommonProtos/metadata/Type/Types.php b/ShoppingCommonProtos/metadata/Type/Types.php index 649b6af7c078..8cab8d410542 100644 Binary files a/ShoppingCommonProtos/metadata/Type/Types.php and b/ShoppingCommonProtos/metadata/Type/Types.php differ diff --git a/ShoppingCommonProtos/src/Type/Channel.php b/ShoppingCommonProtos/src/Type/Channel.php new file mode 100644 index 000000000000..3ea930ad45ec --- /dev/null +++ b/ShoppingCommonProtos/src/Type/Channel.php @@ -0,0 +1,34 @@ +google.shopping.type.Channel + */ +class Channel extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Shopping\Type\Types::initOnce(); + parent::__construct($data); + } + +} + diff --git a/ShoppingCommonProtos/src/Type/Channel/ChannelEnum.php b/ShoppingCommonProtos/src/Type/Channel/ChannelEnum.php new file mode 100644 index 000000000000..c3581dc450ac --- /dev/null +++ b/ShoppingCommonProtos/src/Type/Channel/ChannelEnum.php @@ -0,0 +1,64 @@ +google.shopping.type.Channel.ChannelEnum + */ +class ChannelEnum +{ + /** + * Not specified. + * + * Generated from protobuf enum CHANNEL_ENUM_UNSPECIFIED = 0; + */ + const CHANNEL_ENUM_UNSPECIFIED = 0; + /** + * Online product. + * + * Generated from protobuf enum ONLINE = 1; + */ + const ONLINE = 1; + /** + * Local product. + * + * Generated from protobuf enum LOCAL = 2; + */ + const LOCAL = 2; + + private static $valueToName = [ + self::CHANNEL_ENUM_UNSPECIFIED => 'CHANNEL_ENUM_UNSPECIFIED', + self::ONLINE => 'ONLINE', + self::LOCAL => 'LOCAL', + ]; + + 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(ChannelEnum::class, \Google\Shopping\Type\Channel_ChannelEnum::class); + diff --git a/ShoppingCommonProtos/src/Type/Destination.php b/ShoppingCommonProtos/src/Type/Destination.php index 3f500ac3b453..c939a8e57c8b 100644 --- a/ShoppingCommonProtos/src/Type/Destination.php +++ b/ShoppingCommonProtos/src/Type/Destination.php @@ -4,74 +4,32 @@ namespace Google\Shopping\Type; -use UnexpectedValueException; +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\GPBUtil; /** * Destinations available for a product. * Destinations are used in Merchant Center to allow you to control where the * products from your data feed should be displayed. * - * Protobuf type google.shopping.type.Destination + * Generated from protobuf message google.shopping.type.Destination */ -class Destination +class Destination extends \Google\Protobuf\Internal\Message { + /** - * Not specified. - * - * Generated from protobuf enum DESTINATION_UNSPECIFIED = 0; - */ - const DESTINATION_UNSPECIFIED = 0; - /** - * Shopping ads. - * - * Generated from protobuf enum SHOPPING_ADS = 1; - */ - const SHOPPING_ADS = 1; - /** - * Local inventory ads. - * - * Generated from protobuf enum LOCAL_INVENTORY_ADS = 2; - */ - const LOCAL_INVENTORY_ADS = 2; - /** - * Free listings. + * Constructor. * - * Generated from protobuf enum FREE_LISTINGS = 3; - */ - const FREE_LISTINGS = 3; - /** - * Free local product listings. + * @param array $data { + * Optional. Data for populating the Message object. * - * Generated from protobuf enum FREE_LOCAL_LISTINGS = 4; + * } */ - const FREE_LOCAL_LISTINGS = 4; - - private static $valueToName = [ - self::DESTINATION_UNSPECIFIED => 'DESTINATION_UNSPECIFIED', - self::SHOPPING_ADS => 'SHOPPING_ADS', - self::LOCAL_INVENTORY_ADS => 'LOCAL_INVENTORY_ADS', - self::FREE_LISTINGS => 'FREE_LISTINGS', - self::FREE_LOCAL_LISTINGS => 'FREE_LOCAL_LISTINGS', - ]; - - 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 function __construct($data = NULL) { + \GPBMetadata\Google\Shopping\Type\Types::initOnce(); + parent::__construct($data); } - - 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/ShoppingCommonProtos/src/Type/Destination/DestinationEnum.php b/ShoppingCommonProtos/src/Type/Destination/DestinationEnum.php new file mode 100644 index 000000000000..1e9663bdd652 --- /dev/null +++ b/ShoppingCommonProtos/src/Type/Destination/DestinationEnum.php @@ -0,0 +1,94 @@ +google.shopping.type.Destination.DestinationEnum + */ +class DestinationEnum +{ + /** + * Not specified. + * + * Generated from protobuf enum DESTINATION_ENUM_UNSPECIFIED = 0; + */ + const DESTINATION_ENUM_UNSPECIFIED = 0; + /** + * [Shopping ads](https://support.google.com/google-ads/answer/2454022). + * + * Generated from protobuf enum SHOPPING_ADS = 1; + */ + const SHOPPING_ADS = 1; + /** + * [Display ads](https://support.google.com/merchants/answer/6069387). + * + * Generated from protobuf enum DISPLAY_ADS = 2; + */ + const DISPLAY_ADS = 2; + /** + * [Local inventory + * ads](https://support.google.com/merchants/answer/3057972). + * + * Generated from protobuf enum LOCAL_INVENTORY_ADS = 3; + */ + const LOCAL_INVENTORY_ADS = 3; + /** + * [Free listings](https://support.google.com/merchants/answer/9199328). + * + * Generated from protobuf enum FREE_LISTINGS = 4; + */ + const FREE_LISTINGS = 4; + /** + * [Free local product + * listings](https://support.google.com/merchants/answer/9825611). + * + * Generated from protobuf enum FREE_LOCAL_LISTINGS = 5; + */ + const FREE_LOCAL_LISTINGS = 5; + /** + * [YouTube Shopping](https://support.google.com/merchants/answer/12362804). + * + * Generated from protobuf enum YOUTUBE_SHOPPING = 6; + */ + const YOUTUBE_SHOPPING = 6; + + private static $valueToName = [ + self::DESTINATION_ENUM_UNSPECIFIED => 'DESTINATION_ENUM_UNSPECIFIED', + self::SHOPPING_ADS => 'SHOPPING_ADS', + self::DISPLAY_ADS => 'DISPLAY_ADS', + self::LOCAL_INVENTORY_ADS => 'LOCAL_INVENTORY_ADS', + self::FREE_LISTINGS => 'FREE_LISTINGS', + self::FREE_LOCAL_LISTINGS => 'FREE_LOCAL_LISTINGS', + self::YOUTUBE_SHOPPING => 'YOUTUBE_SHOPPING', + ]; + + 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(DestinationEnum::class, \Google\Shopping\Type\Destination_DestinationEnum::class); + diff --git a/ShoppingCommonProtos/src/Type/Price.php b/ShoppingCommonProtos/src/Type/Price.php index 769212ad4d89..d54d15dc6e6a 100644 --- a/ShoppingCommonProtos/src/Type/Price.php +++ b/ShoppingCommonProtos/src/Type/Price.php @@ -19,6 +19,8 @@ class Price extends \Google\Protobuf\Internal\Message * The price represented as a number in micros (1 million micros is an * equivalent to one's currency standard unit, for example, 1 USD = 1000000 * micros). + * This field can also be set as infinity by setting to -1. + * This field only support -1 and positive value. * * Generated from protobuf field optional int64 amount_micros = 1; */ @@ -41,6 +43,8 @@ class Price extends \Google\Protobuf\Internal\Message * The price represented as a number in micros (1 million micros is an * equivalent to one's currency standard unit, for example, 1 USD = 1000000 * micros). + * This field can also be set as infinity by setting to -1. + * This field only support -1 and positive value. * @type string $currency_code * The currency of the price using three-letter acronyms according to [ISO * 4217](http://en.wikipedia.org/wiki/ISO_4217). @@ -55,6 +59,8 @@ public function __construct($data = NULL) { * The price represented as a number in micros (1 million micros is an * equivalent to one's currency standard unit, for example, 1 USD = 1000000 * micros). + * This field can also be set as infinity by setting to -1. + * This field only support -1 and positive value. * * Generated from protobuf field optional int64 amount_micros = 1; * @return int|string @@ -78,6 +84,8 @@ public function clearAmountMicros() * The price represented as a number in micros (1 million micros is an * equivalent to one's currency standard unit, for example, 1 USD = 1000000 * micros). + * This field can also be set as infinity by setting to -1. + * This field only support -1 and positive value. * * Generated from protobuf field optional int64 amount_micros = 1; * @param int|string $var diff --git a/ShoppingCommonProtos/src/Type/ReportingContext.php b/ShoppingCommonProtos/src/Type/ReportingContext.php new file mode 100644 index 000000000000..05559f26d264 --- /dev/null +++ b/ShoppingCommonProtos/src/Type/ReportingContext.php @@ -0,0 +1,38 @@ +google.shopping.type.ReportingContext + */ +class ReportingContext extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Shopping\Type\Types::initOnce(); + parent::__construct($data); + } + +} + diff --git a/ShoppingCommonProtos/src/Type/ReportingContext/ReportingContextEnum.php b/ShoppingCommonProtos/src/Type/ReportingContext/ReportingContextEnum.php new file mode 100644 index 000000000000..98b0fae8b7ee --- /dev/null +++ b/ShoppingCommonProtos/src/Type/ReportingContext/ReportingContextEnum.php @@ -0,0 +1,141 @@ +google.shopping.type.ReportingContext.ReportingContextEnum + */ +class ReportingContextEnum +{ + /** + * Not specified. + * + * Generated from protobuf enum REPORTING_CONTEXT_ENUM_UNSPECIFIED = 0; + */ + const REPORTING_CONTEXT_ENUM_UNSPECIFIED = 0; + /** + * [Shopping ads](https://support.google.com/merchants/answer/6149970). + * + * Generated from protobuf enum SHOPPING_ADS = 1; + */ + const SHOPPING_ADS = 1; + /** + * [Discovery and Demand Gen + * ads](https://support.google.com/merchants/answer/13389785). + * + * Generated from protobuf enum DISCOVERY_ADS = 2; + */ + const DISCOVERY_ADS = 2; + /** + * [Video ads](https://support.google.com/google-ads/answer/6340491). + * + * Generated from protobuf enum VIDEO_ADS = 3; + */ + const VIDEO_ADS = 3; + /** + * [Display ads](https://support.google.com/merchants/answer/6069387). + * + * Generated from protobuf enum DISPLAY_ADS = 4; + */ + const DISPLAY_ADS = 4; + /** + * [Local inventory + * ads](https://support.google.com/merchants/answer/3271956). + * + * Generated from protobuf enum LOCAL_INVENTORY_ADS = 5; + */ + const LOCAL_INVENTORY_ADS = 5; + /** + * [Vehicle inventory + * ads](https://support.google.com/merchants/answer/11544533). + * + * Generated from protobuf enum VEHICLE_INVENTORY_ADS = 6; + */ + const VEHICLE_INVENTORY_ADS = 6; + /** + * [Free product + * listings](https://support.google.com/merchants/answer/9199328). + * + * Generated from protobuf enum FREE_LISTINGS = 7; + */ + const FREE_LISTINGS = 7; + /** + * [Free local product + * listings](https://support.google.com/merchants/answer/9825611). + * + * Generated from protobuf enum FREE_LOCAL_LISTINGS = 8; + */ + const FREE_LOCAL_LISTINGS = 8; + /** + * [Free local vehicle + * listings](https://support.google.com/merchants/answer/11544533). + * + * Generated from protobuf enum FREE_LOCAL_VEHICLE_LISTINGS = 9; + */ + const FREE_LOCAL_VEHICLE_LISTINGS = 9; + /** + * [YouTube + * Shopping](https://support.google.com/merchants/answer/13478370). + * + * Generated from protobuf enum YOUTUBE_SHOPPING = 10; + */ + const YOUTUBE_SHOPPING = 10; + /** + * [Cloud retail](https://cloud.google.com/solutions/retail). + * + * Generated from protobuf enum CLOUD_RETAIL = 11; + */ + const CLOUD_RETAIL = 11; + /** + * [Local cloud retail](https://cloud.google.com/solutions/retail). + * + * Generated from protobuf enum LOCAL_CLOUD_RETAIL = 12; + */ + const LOCAL_CLOUD_RETAIL = 12; + + private static $valueToName = [ + self::REPORTING_CONTEXT_ENUM_UNSPECIFIED => 'REPORTING_CONTEXT_ENUM_UNSPECIFIED', + self::SHOPPING_ADS => 'SHOPPING_ADS', + self::DISCOVERY_ADS => 'DISCOVERY_ADS', + self::VIDEO_ADS => 'VIDEO_ADS', + self::DISPLAY_ADS => 'DISPLAY_ADS', + self::LOCAL_INVENTORY_ADS => 'LOCAL_INVENTORY_ADS', + self::VEHICLE_INVENTORY_ADS => 'VEHICLE_INVENTORY_ADS', + self::FREE_LISTINGS => 'FREE_LISTINGS', + self::FREE_LOCAL_LISTINGS => 'FREE_LOCAL_LISTINGS', + self::FREE_LOCAL_VEHICLE_LISTINGS => 'FREE_LOCAL_VEHICLE_LISTINGS', + self::YOUTUBE_SHOPPING => 'YOUTUBE_SHOPPING', + self::CLOUD_RETAIL => 'CLOUD_RETAIL', + self::LOCAL_CLOUD_RETAIL => 'LOCAL_CLOUD_RETAIL', + ]; + + 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(ReportingContextEnum::class, \Google\Shopping\Type\ReportingContext_ReportingContextEnum::class); + diff --git a/ShoppingMerchantInventories/composer.json b/ShoppingMerchantInventories/composer.json index 51e8295885d0..2ec03a204435 100644 --- a/ShoppingMerchantInventories/composer.json +++ b/ShoppingMerchantInventories/composer.json @@ -18,7 +18,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.23.0", + "google/gax": "^1.24.0", "google/shopping-common-protos": "^0.1.0" }, "require-dev": { diff --git a/ShoppingMerchantInventories/metadata/V1Beta/Localinventory.php b/ShoppingMerchantInventories/metadata/V1Beta/Localinventory.php index 1797f78bc94e..cc078ac9ead9 100644 Binary files a/ShoppingMerchantInventories/metadata/V1Beta/Localinventory.php and b/ShoppingMerchantInventories/metadata/V1Beta/Localinventory.php differ diff --git a/ShoppingMerchantInventories/metadata/V1Beta/Regionalinventory.php b/ShoppingMerchantInventories/metadata/V1Beta/Regionalinventory.php index e34664111101..7c043be7140f 100644 Binary files a/ShoppingMerchantInventories/metadata/V1Beta/Regionalinventory.php and b/ShoppingMerchantInventories/metadata/V1Beta/Regionalinventory.php differ diff --git a/ShoppingMerchantInventories/samples/V1beta/LocalInventoryServiceClient/delete_local_inventory.php b/ShoppingMerchantInventories/samples/V1beta/LocalInventoryServiceClient/delete_local_inventory.php index 4759807320ac..2d1bfac0a3e7 100644 --- a/ShoppingMerchantInventories/samples/V1beta/LocalInventoryServiceClient/delete_local_inventory.php +++ b/ShoppingMerchantInventories/samples/V1beta/LocalInventoryServiceClient/delete_local_inventory.php @@ -24,7 +24,8 @@ // [START merchantapi_v1beta_generated_LocalInventoryService_DeleteLocalInventory_sync] use Google\ApiCore\ApiException; -use Google\Shopping\Merchant\Inventories\V1beta\LocalInventoryServiceClient; +use Google\Shopping\Merchant\Inventories\V1beta\Client\LocalInventoryServiceClient; +use Google\Shopping\Merchant\Inventories\V1beta\DeleteLocalInventoryRequest; /** * Deletes the specified `LocalInventory` from the given product in your @@ -43,9 +44,13 @@ function delete_local_inventory_sample(string $formattedName): void // Create a client. $localInventoryServiceClient = new LocalInventoryServiceClient(); + // Prepare the request message. + $request = (new DeleteLocalInventoryRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { - $localInventoryServiceClient->deleteLocalInventory($formattedName); + $localInventoryServiceClient->deleteLocalInventory($request); printf('Call completed successfully.' . PHP_EOL); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/ShoppingMerchantInventories/samples/V1beta/LocalInventoryServiceClient/insert_local_inventory.php b/ShoppingMerchantInventories/samples/V1beta/LocalInventoryServiceClient/insert_local_inventory.php index 818578a44763..bac18eb69cf0 100644 --- a/ShoppingMerchantInventories/samples/V1beta/LocalInventoryServiceClient/insert_local_inventory.php +++ b/ShoppingMerchantInventories/samples/V1beta/LocalInventoryServiceClient/insert_local_inventory.php @@ -24,8 +24,9 @@ // [START merchantapi_v1beta_generated_LocalInventoryService_InsertLocalInventory_sync] use Google\ApiCore\ApiException; +use Google\Shopping\Merchant\Inventories\V1beta\Client\LocalInventoryServiceClient; +use Google\Shopping\Merchant\Inventories\V1beta\InsertLocalInventoryRequest; use Google\Shopping\Merchant\Inventories\V1beta\LocalInventory; -use Google\Shopping\Merchant\Inventories\V1beta\LocalInventoryServiceClient; /** * Inserts a `LocalInventory` resource to a product in your merchant @@ -50,14 +51,17 @@ function insert_local_inventory_sample(string $parent, string $localInventorySto // Create a client. $localInventoryServiceClient = new LocalInventoryServiceClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $localInventory = (new LocalInventory()) ->setStoreCode($localInventoryStoreCode); + $request = (new InsertLocalInventoryRequest()) + ->setParent($parent) + ->setLocalInventory($localInventory); // Call the API and handle any network failures. try { /** @var LocalInventory $response */ - $response = $localInventoryServiceClient->insertLocalInventory($parent, $localInventory); + $response = $localInventoryServiceClient->insertLocalInventory($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/ShoppingMerchantInventories/samples/V1beta/LocalInventoryServiceClient/list_local_inventories.php b/ShoppingMerchantInventories/samples/V1beta/LocalInventoryServiceClient/list_local_inventories.php index 8f60b3c07e59..7590e4babdb7 100644 --- a/ShoppingMerchantInventories/samples/V1beta/LocalInventoryServiceClient/list_local_inventories.php +++ b/ShoppingMerchantInventories/samples/V1beta/LocalInventoryServiceClient/list_local_inventories.php @@ -25,8 +25,9 @@ // [START merchantapi_v1beta_generated_LocalInventoryService_ListLocalInventories_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; +use Google\Shopping\Merchant\Inventories\V1beta\Client\LocalInventoryServiceClient; +use Google\Shopping\Merchant\Inventories\V1beta\ListLocalInventoriesRequest; use Google\Shopping\Merchant\Inventories\V1beta\LocalInventory; -use Google\Shopping\Merchant\Inventories\V1beta\LocalInventoryServiceClient; /** * Lists the `LocalInventory` resources for the given product in your merchant @@ -45,10 +46,14 @@ function list_local_inventories_sample(string $parent): void // Create a client. $localInventoryServiceClient = new LocalInventoryServiceClient(); + // Prepare the request message. + $request = (new ListLocalInventoriesRequest()) + ->setParent($parent); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $localInventoryServiceClient->listLocalInventories($parent); + $response = $localInventoryServiceClient->listLocalInventories($request); /** @var LocalInventory $element */ foreach ($response as $element) { diff --git a/ShoppingMerchantInventories/samples/V1beta/RegionalInventoryServiceClient/delete_regional_inventory.php b/ShoppingMerchantInventories/samples/V1beta/RegionalInventoryServiceClient/delete_regional_inventory.php index 806a09fdabcf..d674124b98b8 100644 --- a/ShoppingMerchantInventories/samples/V1beta/RegionalInventoryServiceClient/delete_regional_inventory.php +++ b/ShoppingMerchantInventories/samples/V1beta/RegionalInventoryServiceClient/delete_regional_inventory.php @@ -24,7 +24,8 @@ // [START merchantapi_v1beta_generated_RegionalInventoryService_DeleteRegionalInventory_sync] use Google\ApiCore\ApiException; -use Google\Shopping\Merchant\Inventories\V1beta\RegionalInventoryServiceClient; +use Google\Shopping\Merchant\Inventories\V1beta\Client\RegionalInventoryServiceClient; +use Google\Shopping\Merchant\Inventories\V1beta\DeleteRegionalInventoryRequest; /** * Deletes the specified `RegionalInventory` resource from the given product @@ -43,9 +44,13 @@ function delete_regional_inventory_sample(string $formattedName): void // Create a client. $regionalInventoryServiceClient = new RegionalInventoryServiceClient(); + // Prepare the request message. + $request = (new DeleteRegionalInventoryRequest()) + ->setName($formattedName); + // Call the API and handle any network failures. try { - $regionalInventoryServiceClient->deleteRegionalInventory($formattedName); + $regionalInventoryServiceClient->deleteRegionalInventory($request); printf('Call completed successfully.' . PHP_EOL); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/ShoppingMerchantInventories/samples/V1beta/RegionalInventoryServiceClient/insert_regional_inventory.php b/ShoppingMerchantInventories/samples/V1beta/RegionalInventoryServiceClient/insert_regional_inventory.php index d1805b8294a9..8744ef2144d1 100644 --- a/ShoppingMerchantInventories/samples/V1beta/RegionalInventoryServiceClient/insert_regional_inventory.php +++ b/ShoppingMerchantInventories/samples/V1beta/RegionalInventoryServiceClient/insert_regional_inventory.php @@ -24,8 +24,9 @@ // [START merchantapi_v1beta_generated_RegionalInventoryService_InsertRegionalInventory_sync] use Google\ApiCore\ApiException; +use Google\Shopping\Merchant\Inventories\V1beta\Client\RegionalInventoryServiceClient; +use Google\Shopping\Merchant\Inventories\V1beta\InsertRegionalInventoryRequest; use Google\Shopping\Merchant\Inventories\V1beta\RegionalInventory; -use Google\Shopping\Merchant\Inventories\V1beta\RegionalInventoryServiceClient; /** * Inserts a `RegionalInventory` to a given product in your @@ -50,14 +51,17 @@ function insert_regional_inventory_sample(string $parent, string $regionalInvent // Create a client. $regionalInventoryServiceClient = new RegionalInventoryServiceClient(); - // Prepare any non-scalar elements to be passed along with the request. + // Prepare the request message. $regionalInventory = (new RegionalInventory()) ->setRegion($regionalInventoryRegion); + $request = (new InsertRegionalInventoryRequest()) + ->setParent($parent) + ->setRegionalInventory($regionalInventory); // Call the API and handle any network failures. try { /** @var RegionalInventory $response */ - $response = $regionalInventoryServiceClient->insertRegionalInventory($parent, $regionalInventory); + $response = $regionalInventoryServiceClient->insertRegionalInventory($request); printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); } catch (ApiException $ex) { printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); diff --git a/ShoppingMerchantInventories/samples/V1beta/RegionalInventoryServiceClient/list_regional_inventories.php b/ShoppingMerchantInventories/samples/V1beta/RegionalInventoryServiceClient/list_regional_inventories.php index 3675bc15c661..e4b74f5634d2 100644 --- a/ShoppingMerchantInventories/samples/V1beta/RegionalInventoryServiceClient/list_regional_inventories.php +++ b/ShoppingMerchantInventories/samples/V1beta/RegionalInventoryServiceClient/list_regional_inventories.php @@ -25,8 +25,9 @@ // [START merchantapi_v1beta_generated_RegionalInventoryService_ListRegionalInventories_sync] use Google\ApiCore\ApiException; use Google\ApiCore\PagedListResponse; +use Google\Shopping\Merchant\Inventories\V1beta\Client\RegionalInventoryServiceClient; +use Google\Shopping\Merchant\Inventories\V1beta\ListRegionalInventoriesRequest; use Google\Shopping\Merchant\Inventories\V1beta\RegionalInventory; -use Google\Shopping\Merchant\Inventories\V1beta\RegionalInventoryServiceClient; /** * Lists the `RegionalInventory` resources for the given product in your @@ -44,10 +45,14 @@ function list_regional_inventories_sample(string $parent): void // Create a client. $regionalInventoryServiceClient = new RegionalInventoryServiceClient(); + // Prepare the request message. + $request = (new ListRegionalInventoriesRequest()) + ->setParent($parent); + // Call the API and handle any network failures. try { /** @var PagedListResponse $response */ - $response = $regionalInventoryServiceClient->listRegionalInventories($parent); + $response = $regionalInventoryServiceClient->listRegionalInventories($request); /** @var RegionalInventory $element */ foreach ($response as $element) { diff --git a/ErrorReporting/src/V1beta1/Client/BaseClient/ErrorStatsServiceBaseClient.php b/ShoppingMerchantInventories/src/V1beta/Client/LocalInventoryServiceClient.php similarity index 64% rename from ErrorReporting/src/V1beta1/Client/BaseClient/ErrorStatsServiceBaseClient.php rename to ShoppingMerchantInventories/src/V1beta/Client/LocalInventoryServiceClient.php index 211fa4aa776f..bc9a1859f490 100644 --- a/ErrorReporting/src/V1beta1/Client/BaseClient/ErrorStatsServiceBaseClient.php +++ b/ShoppingMerchantInventories/src/V1beta/Client/LocalInventoryServiceClient.php @@ -18,13 +18,13 @@ /* * GENERATED CODE WARNING * Generated by gapic-generator-php from the file - * https://github.com/googleapis/googleapis/blob/master/google/devtools/clouderrorreporting/v1beta1/error_stats_service.proto + * https://github.com/googleapis/googleapis/blob/master/google/shopping/merchant/inventories/v1beta/localinventory.proto * Updates to the above are reflected here through a refresh process. * * @experimental */ -namespace Google\Cloud\ErrorReporting\V1beta1\Client\BaseClient; +namespace Google\Shopping\Merchant\Inventories\V1beta\Client; use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; @@ -35,15 +35,14 @@ use Google\ApiCore\Transport\TransportInterface; use Google\ApiCore\ValidationException; use Google\Auth\FetchAuthTokenInterface; -use Google\Cloud\ErrorReporting\V1beta1\DeleteEventsRequest; -use Google\Cloud\ErrorReporting\V1beta1\DeleteEventsResponse; -use Google\Cloud\ErrorReporting\V1beta1\ListEventsRequest; -use Google\Cloud\ErrorReporting\V1beta1\ListGroupStatsRequest; +use Google\Shopping\Merchant\Inventories\V1beta\DeleteLocalInventoryRequest; +use Google\Shopping\Merchant\Inventories\V1beta\InsertLocalInventoryRequest; +use Google\Shopping\Merchant\Inventories\V1beta\ListLocalInventoriesRequest; +use Google\Shopping\Merchant\Inventories\V1beta\LocalInventory; use GuzzleHttp\Promise\PromiseInterface; /** - * Service Description: An API for retrieving and managing error statistics as well as data for - * individual events. + * Service Description: Service to manage local inventory for products * * This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. @@ -57,22 +56,20 @@ * * @experimental * - * @internal - * - * @method PromiseInterface deleteEventsAsync(DeleteEventsRequest $request, array $optionalArgs = []) - * @method PromiseInterface listEventsAsync(ListEventsRequest $request, array $optionalArgs = []) - * @method PromiseInterface listGroupStatsAsync(ListGroupStatsRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteLocalInventoryAsync(DeleteLocalInventoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertLocalInventoryAsync(InsertLocalInventoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocalInventoriesAsync(ListLocalInventoriesRequest $request, array $optionalArgs = []) */ -abstract class ErrorStatsServiceBaseClient +final class LocalInventoryServiceClient { use GapicClientTrait; use ResourceHelperTrait; /** The name of the service. */ - private const SERVICE_NAME = 'google.devtools.clouderrorreporting.v1beta1.ErrorStatsService'; + private const SERVICE_NAME = 'google.shopping.merchant.inventories.v1beta.LocalInventoryService'; /** The default address of the service. */ - private const SERVICE_ADDRESS = 'clouderrorreporting.googleapis.com'; + private const SERVICE_ADDRESS = 'merchantapi.googleapis.com'; /** The default port of the service. */ private const DEFAULT_SERVICE_PORT = 443; @@ -82,7 +79,7 @@ abstract class ErrorStatsServiceBaseClient /** The default scopes required by the service. */ public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/content', ]; private static function getClientDefaults() @@ -90,34 +87,38 @@ 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', + 'clientConfig' => __DIR__ . '/../resources/local_inventory_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/local_inventory_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/local_inventory_service_grpc_config.json', 'credentialsConfig' => [ 'defaultScopes' => self::$serviceScopes, ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/error_stats_service_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/local_inventory_service_rest_client_config.php', ], ], ]; } /** - * Formats a string containing the fully-qualified path to represent a project - * resource. + * Formats a string containing the fully-qualified path to represent a + * local_inventory resource. * - * @param string $project + * @param string $account + * @param string $product + * @param string $storeCode * - * @return string The formatted project resource. + * @return string The formatted local_inventory resource. * * @experimental */ - public static function projectName(string $project): string + public static function localInventoryName(string $account, string $product, string $storeCode): string { - return self::getPathTemplate('project')->render([ - 'project' => $project, + return self::getPathTemplate('localInventory')->render([ + 'account' => $account, + 'product' => $product, + 'store_code' => $storeCode, ]); } @@ -125,7 +126,7 @@ public static function projectName(string $project): string * 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} + * - localInventory: accounts/{account}/products/{product}/localInventories/{store_code} * * 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 @@ -155,7 +156,7 @@ public static function parseName(string $formattedName, string $template = null) * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted - * as ":". Default 'clouderrorreporting.googleapis.com:443'. + * as ":". Default 'merchantapi.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 @@ -221,14 +222,19 @@ public function __call($method, $args) } /** - * Deletes all error events of a given project. + * Deletes the specified `LocalInventory` from the given product in your + * merchant account. It might take a up to an hour for the + * `LocalInventory` to be deleted from the specific product. + * Once you have received a successful delete response, wait for that + * period before attempting a delete again. * - * The async variant is {@see self::deleteEventsAsync()} . + * The async variant is + * {@see LocalInventoryServiceClient::deleteLocalInventoryAsync()} . * - * @example samples/V1beta1/ErrorStatsServiceClient/delete_events.php + * @example samples/V1beta/LocalInventoryServiceClient/delete_local_inventory.php * - * @param DeleteEventsRequest $request A request to house fields associated with the call. - * @param array $callOptions { + * @param DeleteLocalInventoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { * Optional. * * @type RetrySettings|array $retrySettings @@ -237,26 +243,33 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return DeleteEventsResponse - * * @throws ApiException Thrown if the API call fails. * * @experimental */ - public function deleteEvents(DeleteEventsRequest $request, array $callOptions = []): DeleteEventsResponse + public function deleteLocalInventory(DeleteLocalInventoryRequest $request, array $callOptions = []): void { - return $this->startApiCall('DeleteEvents', $request, $callOptions)->wait(); + $this->startApiCall('DeleteLocalInventory', $request, $callOptions)->wait(); } /** - * Lists the specified events. + * Inserts a `LocalInventory` resource to a product in your merchant + * account. + * + * Replaces the full `LocalInventory` resource if an entry with the same + * [`storeCode`][google.shopping.merchant.inventories.v1beta.LocalInventory.store_code] + * already exists for the product. * - * The async variant is {@see self::listEventsAsync()} . + * It might take up to 30 minutes for the new or updated `LocalInventory` + * resource to appear in products. * - * @example samples/V1beta1/ErrorStatsServiceClient/list_events.php + * The async variant is + * {@see LocalInventoryServiceClient::insertLocalInventoryAsync()} . * - * @param ListEventsRequest $request A request to house fields associated with the call. - * @param array $callOptions { + * @example samples/V1beta/LocalInventoryServiceClient/insert_local_inventory.php + * + * @param InsertLocalInventoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { * Optional. * * @type RetrySettings|array $retrySettings @@ -265,26 +278,32 @@ public function deleteEvents(DeleteEventsRequest $request, array $callOptions = * {@see RetrySettings} for example usage. * } * - * @return PagedListResponse + * @return LocalInventory * * @throws ApiException Thrown if the API call fails. * * @experimental */ - public function listEvents(ListEventsRequest $request, array $callOptions = []): PagedListResponse + public function insertLocalInventory(InsertLocalInventoryRequest $request, array $callOptions = []): LocalInventory { - return $this->startApiCall('ListEvents', $request, $callOptions); + return $this->startApiCall('InsertLocalInventory', $request, $callOptions)->wait(); } /** - * Lists the specified groups. + * Lists the `LocalInventory` resources for the given product in your merchant + * account. The response might contain fewer items than specified by + * `pageSize`. If `pageToken` was returned in previous request, it can be used + * to obtain additional results. + * + * `LocalInventory` resources are listed per product for a given account. * - * The async variant is {@see self::listGroupStatsAsync()} . + * The async variant is + * {@see LocalInventoryServiceClient::listLocalInventoriesAsync()} . * - * @example samples/V1beta1/ErrorStatsServiceClient/list_group_stats.php + * @example samples/V1beta/LocalInventoryServiceClient/list_local_inventories.php * - * @param ListGroupStatsRequest $request A request to house fields associated with the call. - * @param array $callOptions { + * @param ListLocalInventoriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { * Optional. * * @type RetrySettings|array $retrySettings @@ -299,8 +318,8 @@ public function listEvents(ListEventsRequest $request, array $callOptions = []): * * @experimental */ - public function listGroupStats(ListGroupStatsRequest $request, array $callOptions = []): PagedListResponse + public function listLocalInventories(ListLocalInventoriesRequest $request, array $callOptions = []): PagedListResponse { - return $this->startApiCall('ListGroupStats', $request, $callOptions); + return $this->startApiCall('ListLocalInventories', $request, $callOptions); } } diff --git a/ServiceDirectory/src/V1/Client/BaseClient/LookupServiceBaseClient.php b/ShoppingMerchantInventories/src/V1beta/Client/RegionalInventoryServiceClient.php similarity index 61% rename from ServiceDirectory/src/V1/Client/BaseClient/LookupServiceBaseClient.php rename to ShoppingMerchantInventories/src/V1beta/Client/RegionalInventoryServiceClient.php index 12b15170c47b..15466de1ecd7 100644 --- a/ServiceDirectory/src/V1/Client/BaseClient/LookupServiceBaseClient.php +++ b/ShoppingMerchantInventories/src/V1beta/Client/RegionalInventoryServiceClient.php @@ -18,11 +18,13 @@ /* * GENERATED CODE WARNING * Generated by gapic-generator-php from the file - * https://github.com/googleapis/googleapis/blob/master/google/cloud/servicedirectory/v1/lookup_service.proto + * https://github.com/googleapis/googleapis/blob/master/google/shopping/merchant/inventories/v1beta/regionalinventory.proto * Updates to the above are reflected here through a refresh process. + * + * @experimental */ -namespace Google\Cloud\ServiceDirectory\V1\Client\BaseClient; +namespace Google\Shopping\Merchant\Inventories\V1beta\Client; use Google\ApiCore\ApiException; use Google\ApiCore\CredentialsWrapper; @@ -33,15 +35,15 @@ use Google\ApiCore\Transport\TransportInterface; use Google\ApiCore\ValidationException; use Google\Auth\FetchAuthTokenInterface; -use Google\Cloud\Location\GetLocationRequest; -use Google\Cloud\Location\ListLocationsRequest; -use Google\Cloud\Location\Location; -use Google\Cloud\ServiceDirectory\V1\ResolveServiceRequest; -use Google\Cloud\ServiceDirectory\V1\ResolveServiceResponse; +use Google\Shopping\Merchant\Inventories\V1beta\DeleteRegionalInventoryRequest; +use Google\Shopping\Merchant\Inventories\V1beta\InsertRegionalInventoryRequest; +use Google\Shopping\Merchant\Inventories\V1beta\ListRegionalInventoriesRequest; +use Google\Shopping\Merchant\Inventories\V1beta\RegionalInventory; use GuzzleHttp\Promise\PromiseInterface; /** - * Service Description: Service Directory API for looking up service data at runtime. + * Service Description: Service to manage regional inventory for products. There is also separate + * `regions` resource and API to manage regions definitions. * * This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. @@ -51,28 +53,24 @@ * name, and additionally a parseName method to extract the individual identifiers * contained within formatted names that are returned by the API. * - * This class is currently experimental and may be subject to changes. See {@see - * \Google\Cloud\ServiceDirectory\V1\LookupServiceClient} for the stable - * implementation + * This class is currently experimental and may be subject to changes. * * @experimental * - * @internal - * - * @method PromiseInterface resolveServiceAsync(ResolveServiceRequest $request, array $optionalArgs = []) - * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) - * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteRegionalInventoryAsync(DeleteRegionalInventoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertRegionalInventoryAsync(InsertRegionalInventoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface listRegionalInventoriesAsync(ListRegionalInventoriesRequest $request, array $optionalArgs = []) */ -abstract class LookupServiceBaseClient +final class RegionalInventoryServiceClient { use GapicClientTrait; use ResourceHelperTrait; /** The name of the service. */ - private const SERVICE_NAME = 'google.cloud.servicedirectory.v1.LookupService'; + private const SERVICE_NAME = 'google.shopping.merchant.inventories.v1beta.RegionalInventoryService'; /** The default address of the service. */ - private const SERVICE_ADDRESS = 'servicedirectory.googleapis.com'; + private const SERVICE_ADDRESS = 'merchantapi.googleapis.com'; /** The default port of the service. */ private const DEFAULT_SERVICE_PORT = 443; @@ -82,7 +80,7 @@ abstract class LookupServiceBaseClient /** The default scopes required by the service. */ public static $serviceScopes = [ - 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/content', ]; private static function getClientDefaults() @@ -90,38 +88,38 @@ private static function getClientDefaults() return [ 'serviceName' => self::SERVICE_NAME, 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/lookup_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/lookup_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/lookup_service_grpc_config.json', + 'clientConfig' => __DIR__ . '/../resources/regional_inventory_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/regional_inventory_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/regional_inventory_service_grpc_config.json', 'credentialsConfig' => [ 'defaultScopes' => self::$serviceScopes, ], 'transportConfig' => [ 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/lookup_service_rest_client_config.php', + 'restClientConfigPath' => __DIR__ . '/../resources/regional_inventory_service_rest_client_config.php', ], ], ]; } /** - * Formats a string containing the fully-qualified path to represent a service - * resource. + * Formats a string containing the fully-qualified path to represent a + * regional_inventory resource. + * + * @param string $account + * @param string $product + * @param string $region * - * @param string $project - * @param string $location - * @param string $namespace - * @param string $service + * @return string The formatted regional_inventory resource. * - * @return string The formatted service resource. + * @experimental */ - public static function serviceName(string $project, string $location, string $namespace, string $service): string + public static function regionalInventoryName(string $account, string $product, string $region): string { - return self::getPathTemplate('service')->render([ - 'project' => $project, - 'location' => $location, - 'namespace' => $namespace, - 'service' => $service, + return self::getPathTemplate('regionalInventory')->render([ + 'account' => $account, + 'product' => $product, + 'region' => $region, ]); } @@ -129,7 +127,7 @@ public static function serviceName(string $project, string $location, string $na * Parses a formatted name string and returns an associative array of the components in the name. * The following name formats are supported: * Template: Pattern - * - service: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service} + * - regionalInventory: accounts/{account}/products/{product}/regionalInventories/{region} * * 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 @@ -143,6 +141,8 @@ public static function serviceName(string $project, string $location, string $na * @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(string $formattedName, string $template = null): array { @@ -157,7 +157,7 @@ public static function parseName(string $formattedName, string $template = null) * * @type string $apiEndpoint * The address of the API remote host. May optionally include the port, formatted - * as ":". Default 'servicedirectory.googleapis.com:443'. + * as ":". Default 'merchantapi.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 @@ -202,6 +202,8 @@ public static function parseName(string $formattedName, string $template = null) * } * * @throws ValidationException + * + * @experimental */ public function __construct(array $options = []) { @@ -221,14 +223,19 @@ public function __call($method, $args) } /** - * Returns a [service][google.cloud.servicedirectory.v1.Service] and its - * associated endpoints. - * Resolving a service is not considered an active developer method. + * Deletes the specified `RegionalInventory` resource from the given product + * in your merchant account. It might take up to an hour for the + * `RegionalInventory` to be deleted from the specific product. + * Once you have received a successful delete response, wait for that + * period before attempting a delete again. * - * The async variant is {@see self::resolveServiceAsync()} . + * The async variant is + * {@see RegionalInventoryServiceClient::deleteRegionalInventoryAsync()} . * - * @param ResolveServiceRequest $request A request to house fields associated with the call. - * @param array $callOptions { + * @example samples/V1beta/RegionalInventoryServiceClient/delete_regional_inventory.php + * + * @param DeleteRegionalInventoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { * Optional. * * @type RetrySettings|array $retrySettings @@ -237,22 +244,33 @@ public function __call($method, $args) * {@see RetrySettings} for example usage. * } * - * @return ResolveServiceResponse - * * @throws ApiException Thrown if the API call fails. + * + * @experimental */ - public function resolveService(ResolveServiceRequest $request, array $callOptions = []): ResolveServiceResponse + public function deleteRegionalInventory(DeleteRegionalInventoryRequest $request, array $callOptions = []): void { - return $this->startApiCall('ResolveService', $request, $callOptions)->wait(); + $this->startApiCall('DeleteRegionalInventory', $request, $callOptions)->wait(); } /** - * Gets information about a location. + * Inserts a `RegionalInventory` to a given product in your + * merchant account. + * + * Replaces the full `RegionalInventory` resource if an entry with the same + * [`region`][google.shopping.merchant.inventories.v1beta.RegionalInventory.region] + * already exists for the product. + * + * It might take up to 30 minutes for the new or updated `RegionalInventory` + * resource to appear in products. + * + * The async variant is + * {@see RegionalInventoryServiceClient::insertRegionalInventoryAsync()} . * - * The async variant is {@see self::getLocationAsync()} . + * @example samples/V1beta/RegionalInventoryServiceClient/insert_regional_inventory.php * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { + * @param InsertRegionalInventoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { * Optional. * * @type RetrySettings|array $retrySettings @@ -261,22 +279,32 @@ public function resolveService(ResolveServiceRequest $request, array $callOption * {@see RetrySettings} for example usage. * } * - * @return Location + * @return RegionalInventory * * @throws ApiException Thrown if the API call fails. + * + * @experimental */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + public function insertRegionalInventory(InsertRegionalInventoryRequest $request, array $callOptions = []): RegionalInventory { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + return $this->startApiCall('InsertRegionalInventory', $request, $callOptions)->wait(); } /** - * Lists information about the supported locations for this service. + * Lists the `RegionalInventory` resources for the given product in your + * merchant account. The response might contain fewer items than specified by + * `pageSize`. If `pageToken` was returned in previous request, it can be + * used to obtain additional results. + * + * `RegionalInventory` resources are listed per product for a given account. * - * The async variant is {@see self::listLocationsAsync()} . + * The async variant is + * {@see RegionalInventoryServiceClient::listRegionalInventoriesAsync()} . * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { + * @example samples/V1beta/RegionalInventoryServiceClient/list_regional_inventories.php + * + * @param ListRegionalInventoriesRequest $request A request to house fields associated with the call. + * @param array $callOptions { * Optional. * * @type RetrySettings|array $retrySettings @@ -288,9 +316,11 @@ public function getLocation(GetLocationRequest $request, array $callOptions = [] * @return PagedListResponse * * @throws ApiException Thrown if the API call fails. + * + * @experimental */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + public function listRegionalInventories(ListRegionalInventoriesRequest $request, array $callOptions = []): PagedListResponse { - return $this->startApiCall('ListLocations', $request, $callOptions); + return $this->startApiCall('ListRegionalInventories', $request, $callOptions); } } diff --git a/ShoppingMerchantInventories/src/V1beta/DeleteLocalInventoryRequest.php b/ShoppingMerchantInventories/src/V1beta/DeleteLocalInventoryRequest.php index e30648291083..0ed2f7026f70 100644 --- a/ShoppingMerchantInventories/src/V1beta/DeleteLocalInventoryRequest.php +++ b/ShoppingMerchantInventories/src/V1beta/DeleteLocalInventoryRequest.php @@ -24,6 +24,22 @@ class DeleteLocalInventoryRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; + /** + * @param string $name Required. The name of the local inventory for the given product to delete. + * Format: + * `accounts/{account}/products/{product}/localInventories/{store_code}` + * Please see {@see LocalInventoryServiceClient::localInventoryName()} for help formatting this field. + * + * @return \Google\Shopping\Merchant\Inventories\V1beta\DeleteLocalInventoryRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/ShoppingMerchantInventories/src/V1beta/DeleteRegionalInventoryRequest.php b/ShoppingMerchantInventories/src/V1beta/DeleteRegionalInventoryRequest.php index 417cfe317990..ce9aa3a4789b 100644 --- a/ShoppingMerchantInventories/src/V1beta/DeleteRegionalInventoryRequest.php +++ b/ShoppingMerchantInventories/src/V1beta/DeleteRegionalInventoryRequest.php @@ -24,6 +24,22 @@ class DeleteRegionalInventoryRequest extends \Google\Protobuf\Internal\Message */ protected $name = ''; + /** + * @param string $name Required. The name of the `RegionalInventory` resource to delete. + * Format: + * `accounts/{account}/products/{product}/regionalInventories/{region}` + * Please see {@see RegionalInventoryServiceClient::regionalInventoryName()} for help formatting this field. + * + * @return \Google\Shopping\Merchant\Inventories\V1beta\DeleteRegionalInventoryRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + /** * Constructor. * diff --git a/ShoppingMerchantInventories/src/V1beta/ListLocalInventoriesRequest.php b/ShoppingMerchantInventories/src/V1beta/ListLocalInventoriesRequest.php index b31225d276d9..e786e9639015 100644 --- a/ShoppingMerchantInventories/src/V1beta/ListLocalInventoriesRequest.php +++ b/ShoppingMerchantInventories/src/V1beta/ListLocalInventoriesRequest.php @@ -45,6 +45,21 @@ class ListLocalInventoriesRequest extends \Google\Protobuf\Internal\Message */ protected $page_token = ''; + /** + * @param string $parent Required. The `name` of the parent product to list local inventories for. + * Format: + * `accounts/{account}/products/{product}` + * + * @return \Google\Shopping\Merchant\Inventories\V1beta\ListLocalInventoriesRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + /** * Constructor. * diff --git a/ShoppingMerchantInventories/src/V1beta/ListRegionalInventoriesRequest.php b/ShoppingMerchantInventories/src/V1beta/ListRegionalInventoriesRequest.php index 353b56761e31..aaa8fc4a1ebb 100644 --- a/ShoppingMerchantInventories/src/V1beta/ListRegionalInventoriesRequest.php +++ b/ShoppingMerchantInventories/src/V1beta/ListRegionalInventoriesRequest.php @@ -44,6 +44,20 @@ class ListRegionalInventoriesRequest extends \Google\Protobuf\Internal\Message */ protected $page_token = ''; + /** + * @param string $parent Required. The `name` of the parent product to list `RegionalInventory` + * resources for. Format: `accounts/{account}/products/{product}` + * + * @return \Google\Shopping\Merchant\Inventories\V1beta\ListRegionalInventoriesRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + /** * Constructor. * diff --git a/ShoppingMerchantInventories/src/V1beta/resources/local_inventory_service_descriptor_config.php b/ShoppingMerchantInventories/src/V1beta/resources/local_inventory_service_descriptor_config.php index ee26132c8631..5e3094b48415 100644 --- a/ShoppingMerchantInventories/src/V1beta/resources/local_inventory_service_descriptor_config.php +++ b/ShoppingMerchantInventories/src/V1beta/resources/local_inventory_service_descriptor_config.php @@ -3,6 +3,30 @@ return [ 'interfaces' => [ 'google.shopping.merchant.inventories.v1beta.LocalInventoryService' => [ + 'DeleteLocalInventory' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'InsertLocalInventory' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Shopping\Merchant\Inventories\V1beta\LocalInventory', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], 'ListLocalInventories' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', @@ -12,6 +36,19 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getLocalInventories', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Shopping\Merchant\Inventories\V1beta\ListLocalInventoriesResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'templateMap' => [ + 'localInventory' => 'accounts/{account}/products/{product}/localInventories/{store_code}', ], ], ], diff --git a/ShoppingMerchantInventories/src/V1beta/resources/regional_inventory_service_descriptor_config.php b/ShoppingMerchantInventories/src/V1beta/resources/regional_inventory_service_descriptor_config.php index 032df6b4bbf2..14a000b5300b 100644 --- a/ShoppingMerchantInventories/src/V1beta/resources/regional_inventory_service_descriptor_config.php +++ b/ShoppingMerchantInventories/src/V1beta/resources/regional_inventory_service_descriptor_config.php @@ -3,6 +3,30 @@ return [ 'interfaces' => [ 'google.shopping.merchant.inventories.v1beta.RegionalInventoryService' => [ + 'DeleteRegionalInventory' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Protobuf\GPBEmpty', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], + 'InsertRegionalInventory' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Shopping\Merchant\Inventories\V1beta\RegionalInventory', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], 'ListRegionalInventories' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', @@ -12,6 +36,19 @@ 'responsePageTokenGetMethod' => 'getNextPageToken', 'resourcesGetMethod' => 'getRegionalInventories', ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Shopping\Merchant\Inventories\V1beta\ListRegionalInventoriesResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'templateMap' => [ + 'regionalInventory' => 'accounts/{account}/products/{product}/regionalInventories/{region}', ], ], ], diff --git a/ShoppingMerchantInventories/tests/Unit/V1beta/Client/LocalInventoryServiceClientTest.php b/ShoppingMerchantInventories/tests/Unit/V1beta/Client/LocalInventoryServiceClientTest.php new file mode 100644 index 000000000000..506dde4096c3 --- /dev/null +++ b/ShoppingMerchantInventories/tests/Unit/V1beta/Client/LocalInventoryServiceClientTest.php @@ -0,0 +1,313 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return LocalInventoryServiceClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new LocalInventoryServiceClient($options); + } + + /** @test */ + public function deleteLocalInventoryTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->localInventoryName('[ACCOUNT]', '[PRODUCT]', '[STORE_CODE]'); + $request = (new DeleteLocalInventoryRequest()) + ->setName($formattedName); + $gapicClient->deleteLocalInventory($request); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.shopping.merchant.inventories.v1beta.LocalInventoryService/DeleteLocalInventory', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteLocalInventoryExceptionTest() + { + $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 + $formattedName = $gapicClient->localInventoryName('[ACCOUNT]', '[PRODUCT]', '[STORE_CODE]'); + $request = (new DeleteLocalInventoryRequest()) + ->setName($formattedName); + try { + $gapicClient->deleteLocalInventory($request); + // 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 insertLocalInventoryTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $account = 1177318867; + $storeCode = 'storeCode921424523'; + $availability = 'availability1997542747'; + $quantity = 1285004149; + $pickupMethod = 'pickupMethod-950845436'; + $pickupSla = 'pickupSla-964667163'; + $instoreProductLocation = 'instoreProductLocation-243942392'; + $expectedResponse = new LocalInventory(); + $expectedResponse->setName($name); + $expectedResponse->setAccount($account); + $expectedResponse->setStoreCode($storeCode); + $expectedResponse->setAvailability($availability); + $expectedResponse->setQuantity($quantity); + $expectedResponse->setPickupMethod($pickupMethod); + $expectedResponse->setPickupSla($pickupSla); + $expectedResponse->setInstoreProductLocation($instoreProductLocation); + $transport->addResponse($expectedResponse); + // Mock request + $parent = 'parent-995424086'; + $localInventory = new LocalInventory(); + $localInventoryStoreCode = 'localInventoryStoreCode1126909757'; + $localInventory->setStoreCode($localInventoryStoreCode); + $request = (new InsertLocalInventoryRequest()) + ->setParent($parent) + ->setLocalInventory($localInventory); + $response = $gapicClient->insertLocalInventory($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.shopping.merchant.inventories.v1beta.LocalInventoryService/InsertLocalInventory', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($parent, $actualValue); + $actualValue = $actualRequestObject->getLocalInventory(); + $this->assertProtobufEquals($localInventory, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function insertLocalInventoryExceptionTest() + { + $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 + $parent = 'parent-995424086'; + $localInventory = new LocalInventory(); + $localInventoryStoreCode = 'localInventoryStoreCode1126909757'; + $localInventory->setStoreCode($localInventoryStoreCode); + $request = (new InsertLocalInventoryRequest()) + ->setParent($parent) + ->setLocalInventory($localInventory); + try { + $gapicClient->insertLocalInventory($request); + // 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 listLocalInventoriesTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $localInventoriesElement = new LocalInventory(); + $localInventories = [ + $localInventoriesElement, + ]; + $expectedResponse = new ListLocalInventoriesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setLocalInventories($localInventories); + $transport->addResponse($expectedResponse); + // Mock request + $parent = 'parent-995424086'; + $request = (new ListLocalInventoriesRequest()) + ->setParent($parent); + $response = $gapicClient->listLocalInventories($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getLocalInventories()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.shopping.merchant.inventories.v1beta.LocalInventoryService/ListLocalInventories', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($parent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listLocalInventoriesExceptionTest() + { + $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 + $parent = 'parent-995424086'; + $request = (new ListLocalInventoriesRequest()) + ->setParent($parent); + try { + $gapicClient->listLocalInventories($request); + // 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 deleteLocalInventoryAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->localInventoryName('[ACCOUNT]', '[PRODUCT]', '[STORE_CODE]'); + $request = (new DeleteLocalInventoryRequest()) + ->setName($formattedName); + $gapicClient->deleteLocalInventoryAsync($request)->wait(); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.shopping.merchant.inventories.v1beta.LocalInventoryService/DeleteLocalInventory', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } +} diff --git a/ShoppingMerchantInventories/tests/Unit/V1beta/Client/RegionalInventoryServiceClientTest.php b/ShoppingMerchantInventories/tests/Unit/V1beta/Client/RegionalInventoryServiceClientTest.php new file mode 100644 index 000000000000..28b2c73a171c --- /dev/null +++ b/ShoppingMerchantInventories/tests/Unit/V1beta/Client/RegionalInventoryServiceClientTest.php @@ -0,0 +1,305 @@ +getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return RegionalInventoryServiceClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new RegionalInventoryServiceClient($options); + } + + /** @test */ + public function deleteRegionalInventoryTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->regionalInventoryName('[ACCOUNT]', '[PRODUCT]', '[REGION]'); + $request = (new DeleteRegionalInventoryRequest()) + ->setName($formattedName); + $gapicClient->deleteRegionalInventory($request); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.shopping.merchant.inventories.v1beta.RegionalInventoryService/DeleteRegionalInventory', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function deleteRegionalInventoryExceptionTest() + { + $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 + $formattedName = $gapicClient->regionalInventoryName('[ACCOUNT]', '[PRODUCT]', '[REGION]'); + $request = (new DeleteRegionalInventoryRequest()) + ->setName($formattedName); + try { + $gapicClient->deleteRegionalInventory($request); + // 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 insertRegionalInventoryTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name = 'name3373707'; + $account = 1177318867; + $region = 'region-934795532'; + $availability = 'availability1997542747'; + $expectedResponse = new RegionalInventory(); + $expectedResponse->setName($name); + $expectedResponse->setAccount($account); + $expectedResponse->setRegion($region); + $expectedResponse->setAvailability($availability); + $transport->addResponse($expectedResponse); + // Mock request + $parent = 'parent-995424086'; + $regionalInventory = new RegionalInventory(); + $regionalInventoryRegion = 'regionalInventoryRegion-40810671'; + $regionalInventory->setRegion($regionalInventoryRegion); + $request = (new InsertRegionalInventoryRequest()) + ->setParent($parent) + ->setRegionalInventory($regionalInventory); + $response = $gapicClient->insertRegionalInventory($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.shopping.merchant.inventories.v1beta.RegionalInventoryService/InsertRegionalInventory', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($parent, $actualValue); + $actualValue = $actualRequestObject->getRegionalInventory(); + $this->assertProtobufEquals($regionalInventory, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function insertRegionalInventoryExceptionTest() + { + $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 + $parent = 'parent-995424086'; + $regionalInventory = new RegionalInventory(); + $regionalInventoryRegion = 'regionalInventoryRegion-40810671'; + $regionalInventory->setRegion($regionalInventoryRegion); + $request = (new InsertRegionalInventoryRequest()) + ->setParent($parent) + ->setRegionalInventory($regionalInventory); + try { + $gapicClient->insertRegionalInventory($request); + // 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 listRegionalInventoriesTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $regionalInventoriesElement = new RegionalInventory(); + $regionalInventories = [ + $regionalInventoriesElement, + ]; + $expectedResponse = new ListRegionalInventoriesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setRegionalInventories($regionalInventories); + $transport->addResponse($expectedResponse); + // Mock request + $parent = 'parent-995424086'; + $request = (new ListRegionalInventoriesRequest()) + ->setParent($parent); + $response = $gapicClient->listRegionalInventories($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getRegionalInventories()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.shopping.merchant.inventories.v1beta.RegionalInventoryService/ListRegionalInventories', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($parent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listRegionalInventoriesExceptionTest() + { + $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 + $parent = 'parent-995424086'; + $request = (new ListRegionalInventoriesRequest()) + ->setParent($parent); + try { + $gapicClient->listRegionalInventories($request); + // 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 deleteRegionalInventoryAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new GPBEmpty(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->regionalInventoryName('[ACCOUNT]', '[PRODUCT]', '[REGION]'); + $request = (new DeleteRegionalInventoryRequest()) + ->setName($formattedName); + $gapicClient->deleteRegionalInventoryAsync($request)->wait(); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.shopping.merchant.inventories.v1beta.RegionalInventoryService/DeleteRegionalInventory', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } +} diff --git a/ShoppingMerchantReports/composer.json b/ShoppingMerchantReports/composer.json index 24d34cf8ff14..7ac3a4174d40 100644 --- a/ShoppingMerchantReports/composer.json +++ b/ShoppingMerchantReports/composer.json @@ -18,7 +18,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.23.0", + "google/gax": "^1.24.0", "google/shopping-common-protos": "^0.1.0" }, "require-dev": { diff --git a/ShoppingMerchantReports/metadata/V1Beta/Reports.php b/ShoppingMerchantReports/metadata/V1Beta/Reports.php index ab522445d763..47f7f5e1da06 100644 Binary files a/ShoppingMerchantReports/metadata/V1Beta/Reports.php and b/ShoppingMerchantReports/metadata/V1Beta/Reports.php differ diff --git a/ShoppingMerchantReports/src/V1beta/BestSellersBrandView.php b/ShoppingMerchantReports/src/V1beta/BestSellersBrandView.php index 535718df134e..b8be331a2fee 100644 --- a/ShoppingMerchantReports/src/V1beta/BestSellersBrandView.php +++ b/ShoppingMerchantReports/src/V1beta/BestSellersBrandView.php @@ -36,7 +36,7 @@ class BestSellersBrandView extends \Google\Protobuf\Internal\Message * Required in the `SELECT` clause. Condition on `report_granularity` is * required in the `WHERE` clause. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.ReportGranularity report_granularity = 2; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.ReportGranularity.ReportGranularityEnum report_granularity = 2; */ protected $report_granularity = null; /** @@ -88,20 +88,20 @@ class BestSellersBrandView extends \Google\Protobuf\Internal\Message * Estimated demand in relation to the brand with the highest popularity rank * in the same category and country. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand relative_demand = 9; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand.RelativeDemandEnum relative_demand = 9; */ protected $relative_demand = null; /** * Estimated demand in relation to the brand with the highest popularity rank * in the same category and country in the previous week or month. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand previous_relative_demand = 10; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand.RelativeDemandEnum previous_relative_demand = 10; */ protected $previous_relative_demand = null; /** * Change in the estimated demand. Whether it rose, sank or remained flat. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemandChangeType relative_demand_change = 11; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemandChangeType.RelativeDemandChangeTypeEnum relative_demand_change = 11; */ protected $relative_demand_change = null; @@ -211,7 +211,7 @@ public function setReportDate($var) * Required in the `SELECT` clause. Condition on `report_granularity` is * required in the `WHERE` clause. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.ReportGranularity report_granularity = 2; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.ReportGranularity.ReportGranularityEnum report_granularity = 2; * @return int */ public function getReportGranularity() @@ -235,13 +235,13 @@ public function clearReportGranularity() * Required in the `SELECT` clause. Condition on `report_granularity` is * required in the `WHERE` clause. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.ReportGranularity report_granularity = 2; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.ReportGranularity.ReportGranularityEnum report_granularity = 2; * @param int $var * @return $this */ public function setReportGranularity($var) { - GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\ReportGranularity::class); + GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\ReportGranularity\ReportGranularityEnum::class); $this->report_granularity = $var; return $this; @@ -485,7 +485,7 @@ public function setPreviousRank($var) * Estimated demand in relation to the brand with the highest popularity rank * in the same category and country. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand relative_demand = 9; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand.RelativeDemandEnum relative_demand = 9; * @return int */ public function getRelativeDemand() @@ -507,13 +507,13 @@ public function clearRelativeDemand() * Estimated demand in relation to the brand with the highest popularity rank * in the same category and country. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand relative_demand = 9; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand.RelativeDemandEnum relative_demand = 9; * @param int $var * @return $this */ public function setRelativeDemand($var) { - GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\RelativeDemand::class); + GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\RelativeDemand\RelativeDemandEnum::class); $this->relative_demand = $var; return $this; @@ -523,7 +523,7 @@ public function setRelativeDemand($var) * Estimated demand in relation to the brand with the highest popularity rank * in the same category and country in the previous week or month. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand previous_relative_demand = 10; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand.RelativeDemandEnum previous_relative_demand = 10; * @return int */ public function getPreviousRelativeDemand() @@ -545,13 +545,13 @@ public function clearPreviousRelativeDemand() * Estimated demand in relation to the brand with the highest popularity rank * in the same category and country in the previous week or month. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand previous_relative_demand = 10; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand.RelativeDemandEnum previous_relative_demand = 10; * @param int $var * @return $this */ public function setPreviousRelativeDemand($var) { - GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\RelativeDemand::class); + GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\RelativeDemand\RelativeDemandEnum::class); $this->previous_relative_demand = $var; return $this; @@ -560,7 +560,7 @@ public function setPreviousRelativeDemand($var) /** * Change in the estimated demand. Whether it rose, sank or remained flat. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemandChangeType relative_demand_change = 11; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemandChangeType.RelativeDemandChangeTypeEnum relative_demand_change = 11; * @return int */ public function getRelativeDemandChange() @@ -581,13 +581,13 @@ public function clearRelativeDemandChange() /** * Change in the estimated demand. Whether it rose, sank or remained flat. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemandChangeType relative_demand_change = 11; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemandChangeType.RelativeDemandChangeTypeEnum relative_demand_change = 11; * @param int $var * @return $this */ public function setRelativeDemandChange($var) { - GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\RelativeDemandChangeType::class); + GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\RelativeDemandChangeType\RelativeDemandChangeTypeEnum::class); $this->relative_demand_change = $var; return $this; diff --git a/ShoppingMerchantReports/src/V1beta/BestSellersProductClusterView.php b/ShoppingMerchantReports/src/V1beta/BestSellersProductClusterView.php index 02eeeab99a5d..90686b52b107 100644 --- a/ShoppingMerchantReports/src/V1beta/BestSellersProductClusterView.php +++ b/ShoppingMerchantReports/src/V1beta/BestSellersProductClusterView.php @@ -38,7 +38,7 @@ class BestSellersProductClusterView extends \Google\Protobuf\Internal\Message * Required in the `SELECT` clause. Condition on `report_granularity` is * required in the `WHERE` clause. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.ReportGranularity report_granularity = 2; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.ReportGranularity.ReportGranularityEnum report_granularity = 2; */ protected $report_granularity = null; /** @@ -161,7 +161,7 @@ class BestSellersProductClusterView extends \Google\Protobuf\Internal\Message * Estimated demand in relation to the product cluster with the highest * popularity rank in the same category and country. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand relative_demand = 18; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand.RelativeDemandEnum relative_demand = 18; */ protected $relative_demand = null; /** @@ -169,13 +169,13 @@ class BestSellersProductClusterView extends \Google\Protobuf\Internal\Message * popularity rank in the same category and country in the previous week or * month. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand previous_relative_demand = 19; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand.RelativeDemandEnum previous_relative_demand = 19; */ protected $previous_relative_demand = null; /** * Change in the estimated demand. Whether it rose, sank or remained flat. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemandChangeType relative_demand_change = 20; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemandChangeType.RelativeDemandChangeTypeEnum relative_demand_change = 20; */ protected $relative_demand_change = null; @@ -321,7 +321,7 @@ public function setReportDate($var) * Required in the `SELECT` clause. Condition on `report_granularity` is * required in the `WHERE` clause. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.ReportGranularity report_granularity = 2; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.ReportGranularity.ReportGranularityEnum report_granularity = 2; * @return int */ public function getReportGranularity() @@ -345,13 +345,13 @@ public function clearReportGranularity() * Required in the `SELECT` clause. Condition on `report_granularity` is * required in the `WHERE` clause. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.ReportGranularity report_granularity = 2; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.ReportGranularity.ReportGranularityEnum report_granularity = 2; * @param int $var * @return $this */ public function setReportGranularity($var) { - GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\ReportGranularity::class); + GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\ReportGranularity\ReportGranularityEnum::class); $this->report_granularity = $var; return $this; @@ -943,7 +943,7 @@ public function setPreviousRank($var) * Estimated demand in relation to the product cluster with the highest * popularity rank in the same category and country. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand relative_demand = 18; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand.RelativeDemandEnum relative_demand = 18; * @return int */ public function getRelativeDemand() @@ -965,13 +965,13 @@ public function clearRelativeDemand() * Estimated demand in relation to the product cluster with the highest * popularity rank in the same category and country. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand relative_demand = 18; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand.RelativeDemandEnum relative_demand = 18; * @param int $var * @return $this */ public function setRelativeDemand($var) { - GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\RelativeDemand::class); + GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\RelativeDemand\RelativeDemandEnum::class); $this->relative_demand = $var; return $this; @@ -982,7 +982,7 @@ public function setRelativeDemand($var) * popularity rank in the same category and country in the previous week or * month. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand previous_relative_demand = 19; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand.RelativeDemandEnum previous_relative_demand = 19; * @return int */ public function getPreviousRelativeDemand() @@ -1005,13 +1005,13 @@ public function clearPreviousRelativeDemand() * popularity rank in the same category and country in the previous week or * month. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand previous_relative_demand = 19; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemand.RelativeDemandEnum previous_relative_demand = 19; * @param int $var * @return $this */ public function setPreviousRelativeDemand($var) { - GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\RelativeDemand::class); + GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\RelativeDemand\RelativeDemandEnum::class); $this->previous_relative_demand = $var; return $this; @@ -1020,7 +1020,7 @@ public function setPreviousRelativeDemand($var) /** * Change in the estimated demand. Whether it rose, sank or remained flat. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemandChangeType relative_demand_change = 20; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemandChangeType.RelativeDemandChangeTypeEnum relative_demand_change = 20; * @return int */ public function getRelativeDemandChange() @@ -1041,13 +1041,13 @@ public function clearRelativeDemandChange() /** * Change in the estimated demand. Whether it rose, sank or remained flat. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemandChangeType relative_demand_change = 20; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.RelativeDemandChangeType.RelativeDemandChangeTypeEnum relative_demand_change = 20; * @param int $var * @return $this */ public function setRelativeDemandChange($var) { - GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\RelativeDemandChangeType::class); + GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\RelativeDemandChangeType\RelativeDemandChangeTypeEnum::class); $this->relative_demand_change = $var; return $this; diff --git a/ShoppingMerchantReports/src/V1beta/Client/BaseClient/ReportServiceBaseClient.php b/ShoppingMerchantReports/src/V1beta/Client/BaseClient/ReportServiceBaseClient.php deleted file mode 100644 index 2e3483d5a77a..000000000000 --- a/ShoppingMerchantReports/src/V1beta/Client/BaseClient/ReportServiceBaseClient.php +++ /dev/null @@ -1,207 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => - self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => - __DIR__ . '/../../resources/report_service_client_config.json', - 'descriptorsConfigPath' => - __DIR__ . - '/../../resources/report_service_descriptor_config.php', - 'gcpApiConfigPath' => - __DIR__ . '/../../resources/report_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => - __DIR__ . - '/../../resources/report_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'merchantapi.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); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error( - 'Call to undefined method ' . __CLASS__ . "::$method()", - E_USER_ERROR - ); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieves a report defined by a search query. The response might contain - * fewer rows than specified by `page_size`. Rely on `next_page_token` to - * determine if there are more rows to be requested. - * - * The async variant is {@see self::searchAsync()} . - * - * @example samples/V1beta/ReportServiceClient/search.php - * - * @param SearchRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - * - * @experimental - */ - public function search( - SearchRequest $request, - array $callOptions = [] - ): PagedListResponse { - return $this->startApiCall('Search', $request, $callOptions); - } -} diff --git a/ShoppingMerchantReports/src/V1beta/Client/ReportServiceClient.php b/ShoppingMerchantReports/src/V1beta/Client/ReportServiceClient.php index 27abdb7fe927..3118554b47fc 100644 --- a/ShoppingMerchantReports/src/V1beta/Client/ReportServiceClient.php +++ b/ShoppingMerchantReports/src/V1beta/Client/ReportServiceClient.php @@ -26,17 +26,170 @@ namespace Google\Shopping\Merchant\Reports\V1beta\Client; -use Google\Shopping\Merchant\Reports\V1beta\Client\BaseClient\ReportServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Shopping\Merchant\Reports\V1beta\SearchRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for retrieving reports and insights about your products, their + * performance, and their competitive environment on Google. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface searchAsync(SearchRequest $request, array $optionalArgs = []) */ -final class ReportServiceClient extends ReportServiceBaseClient +final class ReportServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ReportServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.shopping.merchant.reports.v1beta.ReportService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'merchantapi.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/content', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/report_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/report_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/report_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/report_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'merchantapi.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); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieves a report defined by a search query. The response might contain + * fewer rows than specified by `page_size`. Rely on `next_page_token` to + * determine if there are more rows to be requested. + * + * The async variant is {@see ReportServiceClient::searchAsync()} . + * + * @example samples/V1beta/ReportServiceClient/search.php + * + * @param SearchRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + * + * @experimental + */ + public function search(SearchRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('Search', $request, $callOptions); + } } diff --git a/ShoppingMerchantReports/src/V1beta/CompetitiveVisibilityBenchmarkView.php b/ShoppingMerchantReports/src/V1beta/CompetitiveVisibilityBenchmarkView.php index b8564d037caa..e5e9773a20e6 100644 --- a/ShoppingMerchantReports/src/V1beta/CompetitiveVisibilityBenchmarkView.php +++ b/ShoppingMerchantReports/src/V1beta/CompetitiveVisibilityBenchmarkView.php @@ -50,7 +50,7 @@ class CompetitiveVisibilityBenchmarkView extends \Google\Protobuf\Internal\Messa * Traffic source of impressions. * Required in the `SELECT` clause. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.TrafficSource traffic_source = 4; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.TrafficSource.TrafficSourceEnum traffic_source = 4; */ protected $traffic_source = null; /** @@ -242,7 +242,7 @@ public function setReportCategoryId($var) * Traffic source of impressions. * Required in the `SELECT` clause. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.TrafficSource traffic_source = 4; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.TrafficSource.TrafficSourceEnum traffic_source = 4; * @return int */ public function getTrafficSource() @@ -264,13 +264,13 @@ public function clearTrafficSource() * Traffic source of impressions. * Required in the `SELECT` clause. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.TrafficSource traffic_source = 4; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.TrafficSource.TrafficSourceEnum traffic_source = 4; * @param int $var * @return $this */ public function setTrafficSource($var) { - GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\TrafficSource::class); + GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\TrafficSource\TrafficSourceEnum::class); $this->traffic_source = $var; return $this; diff --git a/ShoppingMerchantReports/src/V1beta/CompetitiveVisibilityCompetitorView.php b/ShoppingMerchantReports/src/V1beta/CompetitiveVisibilityCompetitorView.php index eff50e4a3192..1f172eceefe2 100644 --- a/ShoppingMerchantReports/src/V1beta/CompetitiveVisibilityCompetitorView.php +++ b/ShoppingMerchantReports/src/V1beta/CompetitiveVisibilityCompetitorView.php @@ -64,7 +64,7 @@ class CompetitiveVisibilityCompetitorView extends \Google\Protobuf\Internal\Mess * Traffic source of impressions. * Required in the `SELECT` clause. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.TrafficSource traffic_source = 6; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.TrafficSource.TrafficSourceEnum traffic_source = 6; */ protected $traffic_source = null; /** @@ -390,7 +390,7 @@ public function setReportCategoryId($var) * Traffic source of impressions. * Required in the `SELECT` clause. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.TrafficSource traffic_source = 6; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.TrafficSource.TrafficSourceEnum traffic_source = 6; * @return int */ public function getTrafficSource() @@ -412,13 +412,13 @@ public function clearTrafficSource() * Traffic source of impressions. * Required in the `SELECT` clause. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.TrafficSource traffic_source = 6; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.TrafficSource.TrafficSourceEnum traffic_source = 6; * @param int $var * @return $this */ public function setTrafficSource($var) { - GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\TrafficSource::class); + GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\TrafficSource\TrafficSourceEnum::class); $this->traffic_source = $var; return $this; diff --git a/ShoppingMerchantReports/src/V1beta/CompetitiveVisibilityTopMerchantView.php b/ShoppingMerchantReports/src/V1beta/CompetitiveVisibilityTopMerchantView.php index db3d5ecdbaa6..255112193e37 100644 --- a/ShoppingMerchantReports/src/V1beta/CompetitiveVisibilityTopMerchantView.php +++ b/ShoppingMerchantReports/src/V1beta/CompetitiveVisibilityTopMerchantView.php @@ -66,7 +66,7 @@ class CompetitiveVisibilityTopMerchantView extends \Google\Protobuf\Internal\Mes * Traffic source of impressions. * Required in the `SELECT` clause. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.TrafficSource traffic_source = 6; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.TrafficSource.TrafficSourceEnum traffic_source = 6; */ protected $traffic_source = null; /** @@ -375,7 +375,7 @@ public function setReportCategoryId($var) * Traffic source of impressions. * Required in the `SELECT` clause. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.TrafficSource traffic_source = 6; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.TrafficSource.TrafficSourceEnum traffic_source = 6; * @return int */ public function getTrafficSource() @@ -397,13 +397,13 @@ public function clearTrafficSource() * Traffic source of impressions. * Required in the `SELECT` clause. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.TrafficSource traffic_source = 6; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.TrafficSource.TrafficSourceEnum traffic_source = 6; * @param int $var * @return $this */ public function setTrafficSource($var) { - GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\TrafficSource::class); + GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\TrafficSource\TrafficSourceEnum::class); $this->traffic_source = $var; return $this; diff --git a/ShoppingMerchantReports/src/V1beta/MarketingMethod.php b/ShoppingMerchantReports/src/V1beta/MarketingMethod.php new file mode 100644 index 000000000000..77c1a3decec6 --- /dev/null +++ b/ShoppingMerchantReports/src/V1beta/MarketingMethod.php @@ -0,0 +1,34 @@ +google.shopping.merchant.reports.v1beta.MarketingMethod + */ +class MarketingMethod extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Shopping\Merchant\Reports\V1Beta\Reports::initOnce(); + parent::__construct($data); + } + +} + diff --git a/ShoppingMerchantReports/src/V1beta/MarketingMethod/MarketingMethodEnum.php b/ShoppingMerchantReports/src/V1beta/MarketingMethod/MarketingMethodEnum.php new file mode 100644 index 000000000000..1e4f9249c1fa --- /dev/null +++ b/ShoppingMerchantReports/src/V1beta/MarketingMethod/MarketingMethodEnum.php @@ -0,0 +1,62 @@ +google.shopping.merchant.reports.v1beta.MarketingMethod.MarketingMethodEnum + */ +class MarketingMethodEnum +{ + /** + * Not specified. + * + * Generated from protobuf enum MARKETING_METHOD_ENUM_UNSPECIFIED = 0; + */ + const MARKETING_METHOD_ENUM_UNSPECIFIED = 0; + /** + * Organic marketing. + * + * Generated from protobuf enum ORGANIC = 1; + */ + const ORGANIC = 1; + /** + * Ads-based marketing. + * + * Generated from protobuf enum ADS = 2; + */ + const ADS = 2; + + private static $valueToName = [ + self::MARKETING_METHOD_ENUM_UNSPECIFIED => 'MARKETING_METHOD_ENUM_UNSPECIFIED', + self::ORGANIC => 'ORGANIC', + self::ADS => 'ADS', + ]; + + 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/ShoppingMerchantReports/src/V1beta/PriceCompetitivenessProductView.php b/ShoppingMerchantReports/src/V1beta/PriceCompetitivenessProductView.php index d6e5f606565b..d8e3837e2053 100644 --- a/ShoppingMerchantReports/src/V1beta/PriceCompetitivenessProductView.php +++ b/ShoppingMerchantReports/src/V1beta/PriceCompetitivenessProductView.php @@ -27,8 +27,9 @@ class PriceCompetitivenessProductView extends \Google\Protobuf\Internal\Message */ protected $report_country_code = null; /** - * REST ID of the product, in the form of languageCode~feedLabel~offerId. Can - * be used to join data with the `product_view` table. + * REST ID of the product, in the form of + * `channel~languageCode~feedLabel~offerId`. Can be used to join data with the + * `product_view` table. * Required in the `SELECT` clause. * * Generated from protobuf field optional string id = 2; @@ -146,8 +147,9 @@ class PriceCompetitivenessProductView extends \Google\Protobuf\Internal\Message * Country of the price benchmark. Represented in the ISO 3166 format. * Required in the `SELECT` clause. * @type string $id - * REST ID of the product, in the form of languageCode~feedLabel~offerId. Can - * be used to join data with the `product_view` table. + * REST ID of the product, in the form of + * `channel~languageCode~feedLabel~offerId`. Can be used to join data with the + * `product_view` table. * Required in the `SELECT` clause. * @type string $offer_id * Merchant-provided id of the product. @@ -236,8 +238,9 @@ public function setReportCountryCode($var) } /** - * REST ID of the product, in the form of languageCode~feedLabel~offerId. Can - * be used to join data with the `product_view` table. + * REST ID of the product, in the form of + * `channel~languageCode~feedLabel~offerId`. Can be used to join data with the + * `product_view` table. * Required in the `SELECT` clause. * * Generated from protobuf field optional string id = 2; @@ -259,8 +262,9 @@ public function clearId() } /** - * REST ID of the product, in the form of languageCode~feedLabel~offerId. Can - * be used to join data with the `product_view` table. + * REST ID of the product, in the form of + * `channel~languageCode~feedLabel~offerId`. Can be used to join data with the + * `product_view` table. * Required in the `SELECT` clause. * * Generated from protobuf field optional string id = 2; diff --git a/ShoppingMerchantReports/src/V1beta/PriceInsightsProductView.php b/ShoppingMerchantReports/src/V1beta/PriceInsightsProductView.php index c6a9e8e18a9a..b53355a0c2aa 100644 --- a/ShoppingMerchantReports/src/V1beta/PriceInsightsProductView.php +++ b/ShoppingMerchantReports/src/V1beta/PriceInsightsProductView.php @@ -20,8 +20,9 @@ class PriceInsightsProductView extends \Google\Protobuf\Internal\Message { /** - * REST ID of the product, in the form of languageCode~feedLabel~offerId. Can - * be used to join data with the `product_view` table. + * REST ID of the product, in the form of + * `channel~languageCode~feedLabel~offerId`. Can be used to join data with the + * `product_view` table. * Required in the `SELECT` clause. * * Generated from protobuf field optional string id = 1; @@ -151,21 +152,6 @@ class PriceInsightsProductView extends \Google\Protobuf\Internal\Message * Generated from protobuf field optional double predicted_conversions_change_fraction = 19; */ protected $predicted_conversions_change_fraction = null; - /** - * Predicted change in gross profit as a fraction after introducing the - * suggested price compared to current active price. For example, 0.05 is a 5% - * predicted increase in gross profit. - * - * Generated from protobuf field optional double predicted_gross_profit_change_fraction = 20; - */ - protected $predicted_gross_profit_change_fraction = null; - /** - * Predicted change in gross profit after introducing the suggested price - * for a month compared to current active price. - * - * Generated from protobuf field .google.shopping.type.Price predicted_monthly_gross_profit_change = 21; - */ - protected $predicted_monthly_gross_profit_change = null; /** * Constructor. @@ -174,8 +160,9 @@ class PriceInsightsProductView extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $id - * REST ID of the product, in the form of languageCode~feedLabel~offerId. Can - * be used to join data with the `product_view` table. + * REST ID of the product, in the form of + * `channel~languageCode~feedLabel~offerId`. Can be used to join data with the + * `product_view` table. * Required in the `SELECT` clause. * @type string $offer_id * Merchant-provided id of the product. @@ -229,13 +216,6 @@ class PriceInsightsProductView extends \Google\Protobuf\Internal\Message * Predicted change in conversions as a fraction after introducing the * suggested price compared to current active price. For example, 0.05 is a 5% * predicted increase in conversions). - * @type float $predicted_gross_profit_change_fraction - * Predicted change in gross profit as a fraction after introducing the - * suggested price compared to current active price. For example, 0.05 is a 5% - * predicted increase in gross profit. - * @type \Google\Shopping\Type\Price $predicted_monthly_gross_profit_change - * Predicted change in gross profit after introducing the suggested price - * for a month compared to current active price. * } */ public function __construct($data = NULL) { @@ -244,8 +224,9 @@ public function __construct($data = NULL) { } /** - * REST ID of the product, in the form of languageCode~feedLabel~offerId. Can - * be used to join data with the `product_view` table. + * REST ID of the product, in the form of + * `channel~languageCode~feedLabel~offerId`. Can be used to join data with the + * `product_view` table. * Required in the `SELECT` clause. * * Generated from protobuf field optional string id = 1; @@ -267,8 +248,9 @@ public function clearId() } /** - * REST ID of the product, in the form of languageCode~feedLabel~offerId. Can - * be used to join data with the `product_view` table. + * REST ID of the product, in the form of + * `channel~languageCode~feedLabel~offerId`. Can be used to join data with the + * `product_view` table. * Required in the `SELECT` clause. * * Generated from protobuf field optional string id = 1; @@ -963,83 +945,5 @@ public function setPredictedConversionsChangeFraction($var) return $this; } - /** - * Predicted change in gross profit as a fraction after introducing the - * suggested price compared to current active price. For example, 0.05 is a 5% - * predicted increase in gross profit. - * - * Generated from protobuf field optional double predicted_gross_profit_change_fraction = 20; - * @return float - */ - public function getPredictedGrossProfitChangeFraction() - { - return isset($this->predicted_gross_profit_change_fraction) ? $this->predicted_gross_profit_change_fraction : 0.0; - } - - public function hasPredictedGrossProfitChangeFraction() - { - return isset($this->predicted_gross_profit_change_fraction); - } - - public function clearPredictedGrossProfitChangeFraction() - { - unset($this->predicted_gross_profit_change_fraction); - } - - /** - * Predicted change in gross profit as a fraction after introducing the - * suggested price compared to current active price. For example, 0.05 is a 5% - * predicted increase in gross profit. - * - * Generated from protobuf field optional double predicted_gross_profit_change_fraction = 20; - * @param float $var - * @return $this - */ - public function setPredictedGrossProfitChangeFraction($var) - { - GPBUtil::checkDouble($var); - $this->predicted_gross_profit_change_fraction = $var; - - return $this; - } - - /** - * Predicted change in gross profit after introducing the suggested price - * for a month compared to current active price. - * - * Generated from protobuf field .google.shopping.type.Price predicted_monthly_gross_profit_change = 21; - * @return \Google\Shopping\Type\Price|null - */ - public function getPredictedMonthlyGrossProfitChange() - { - return $this->predicted_monthly_gross_profit_change; - } - - public function hasPredictedMonthlyGrossProfitChange() - { - return isset($this->predicted_monthly_gross_profit_change); - } - - public function clearPredictedMonthlyGrossProfitChange() - { - unset($this->predicted_monthly_gross_profit_change); - } - - /** - * Predicted change in gross profit after introducing the suggested price - * for a month compared to current active price. - * - * Generated from protobuf field .google.shopping.type.Price predicted_monthly_gross_profit_change = 21; - * @param \Google\Shopping\Type\Price $var - * @return $this - */ - public function setPredictedMonthlyGrossProfitChange($var) - { - GPBUtil::checkMessage($var, \Google\Shopping\Type\Price::class); - $this->predicted_monthly_gross_profit_change = $var; - - return $this; - } - } diff --git a/ShoppingMerchantReports/src/V1beta/ProductPerformanceView.php b/ShoppingMerchantReports/src/V1beta/ProductPerformanceView.php index cb50577359b0..b2c483064d49 100644 --- a/ShoppingMerchantReports/src/V1beta/ProductPerformanceView.php +++ b/ShoppingMerchantReports/src/V1beta/ProductPerformanceView.php @@ -24,13 +24,11 @@ class ProductPerformanceView extends \Google\Protobuf\Internal\Message { /** - * Destination of the product to which metrics apply. Segment. - * Product performance data is not available for the LOCAL_INVENTORY_ADS - * destination. + * Marketing method to which metrics apply. Segment. * - * Generated from protobuf field optional .google.shopping.type.Destination destination = 1; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.MarketingMethod.MarketingMethodEnum marketing_method = 1; */ - protected $destination = null; + protected $marketing_method = null; /** * Date in the merchant timezone to which metrics apply. Segment. * Condition on `date` is required in the `WHERE` clause. @@ -260,10 +258,8 @@ class ProductPerformanceView extends \Google\Protobuf\Internal\Message * @param array $data { * Optional. Data for populating the Message object. * - * @type int $destination - * Destination of the product to which metrics apply. Segment. - * Product performance data is not available for the LOCAL_INVENTORY_ADS - * destination. + * @type int $marketing_method + * Marketing method to which metrics apply. Segment. * @type \Google\Type\Date $date * Date in the merchant timezone to which metrics apply. Segment. * Condition on `date` is required in the `WHERE` clause. @@ -374,41 +370,37 @@ public function __construct($data = NULL) { } /** - * Destination of the product to which metrics apply. Segment. - * Product performance data is not available for the LOCAL_INVENTORY_ADS - * destination. + * Marketing method to which metrics apply. Segment. * - * Generated from protobuf field optional .google.shopping.type.Destination destination = 1; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.MarketingMethod.MarketingMethodEnum marketing_method = 1; * @return int */ - public function getDestination() + public function getMarketingMethod() { - return isset($this->destination) ? $this->destination : 0; + return isset($this->marketing_method) ? $this->marketing_method : 0; } - public function hasDestination() + public function hasMarketingMethod() { - return isset($this->destination); + return isset($this->marketing_method); } - public function clearDestination() + public function clearMarketingMethod() { - unset($this->destination); + unset($this->marketing_method); } /** - * Destination of the product to which metrics apply. Segment. - * Product performance data is not available for the LOCAL_INVENTORY_ADS - * destination. + * Marketing method to which metrics apply. Segment. * - * Generated from protobuf field optional .google.shopping.type.Destination destination = 1; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.MarketingMethod.MarketingMethodEnum marketing_method = 1; * @param int $var * @return $this */ - public function setDestination($var) + public function setMarketingMethod($var) { - GPBUtil::checkEnum($var, \Google\Shopping\Type\Destination::class); - $this->destination = $var; + GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\MarketingMethod\MarketingMethodEnum::class); + $this->marketing_method = $var; return $this; } diff --git a/ShoppingMerchantReports/src/V1beta/ProductView.php b/ShoppingMerchantReports/src/V1beta/ProductView.php index af576d376f5b..8ad4d783310d 100644 --- a/ShoppingMerchantReports/src/V1beta/ProductView.php +++ b/ShoppingMerchantReports/src/V1beta/ProductView.php @@ -24,14 +24,20 @@ class ProductView extends \Google\Protobuf\Internal\Message { /** - * REST ID of the product, in the form of languageCode~feedLabel~offerId. - * Merchant API methods that operate on products take this as their `name` - * parameter. + * REST ID of the product, in the form of + * `channel~languageCode~feedLabel~offerId`. Merchant API methods that operate + * on products take this as their `name` parameter. * Required in the `SELECT` clause. * * Generated from protobuf field optional string id = 1; */ protected $id = null; + /** + * Channel of the product. Can be `ONLINE` or `LOCAL`. + * + * Generated from protobuf field optional .google.shopping.type.Channel.ChannelEnum channel = 28; + */ + protected $channel = null; /** * Language code of the product in BCP 47 format. * @@ -193,11 +199,11 @@ class ProductView extends \Google\Protobuf\Internal\Message */ protected $expiration_date = null; /** - * Aggregated destination status. + * Aggregated status. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.ProductView.AggregatedDestinationStatus aggregated_destination_status = 26; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.ProductView.AggregatedReportingContextStatus aggregated_reporting_context_status = 26; */ - protected $aggregated_destination_status = null; + protected $aggregated_reporting_context_status = null; /** * List of item issues for the product. * **This field cannot be used for sorting the results.** @@ -216,10 +222,12 @@ class ProductView extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $id - * REST ID of the product, in the form of languageCode~feedLabel~offerId. - * Merchant API methods that operate on products take this as their `name` - * parameter. + * REST ID of the product, in the form of + * `channel~languageCode~feedLabel~offerId`. Merchant API methods that operate + * on products take this as their `name` parameter. * Required in the `SELECT` clause. + * @type int $channel + * Channel of the product. Can be `ONLINE` or `LOCAL`. * @type string $language_code * Language code of the product in BCP 47 format. * @type string $feed_label @@ -284,8 +292,8 @@ class ProductView extends \Google\Protobuf\Internal\Message * The time the merchant created the product in timestamp seconds. * @type \Google\Type\Date $expiration_date * Expiration date for the product, specified on insertion. - * @type int $aggregated_destination_status - * Aggregated destination status. + * @type int $aggregated_reporting_context_status + * Aggregated status. * @type array<\Google\Shopping\Merchant\Reports\V1beta\ProductView\ItemIssue>|\Google\Protobuf\Internal\RepeatedField $item_issues * List of item issues for the product. * **This field cannot be used for sorting the results.** @@ -300,9 +308,9 @@ public function __construct($data = NULL) { } /** - * REST ID of the product, in the form of languageCode~feedLabel~offerId. - * Merchant API methods that operate on products take this as their `name` - * parameter. + * REST ID of the product, in the form of + * `channel~languageCode~feedLabel~offerId`. Merchant API methods that operate + * on products take this as their `name` parameter. * Required in the `SELECT` clause. * * Generated from protobuf field optional string id = 1; @@ -324,9 +332,9 @@ public function clearId() } /** - * REST ID of the product, in the form of languageCode~feedLabel~offerId. - * Merchant API methods that operate on products take this as their `name` - * parameter. + * REST ID of the product, in the form of + * `channel~languageCode~feedLabel~offerId`. Merchant API methods that operate + * on products take this as their `name` parameter. * Required in the `SELECT` clause. * * Generated from protobuf field optional string id = 1; @@ -341,6 +349,42 @@ public function setId($var) return $this; } + /** + * Channel of the product. Can be `ONLINE` or `LOCAL`. + * + * Generated from protobuf field optional .google.shopping.type.Channel.ChannelEnum channel = 28; + * @return int + */ + public function getChannel() + { + return isset($this->channel) ? $this->channel : 0; + } + + public function hasChannel() + { + return isset($this->channel); + } + + public function clearChannel() + { + unset($this->channel); + } + + /** + * Channel of the product. Can be `ONLINE` or `LOCAL`. + * + * Generated from protobuf field optional .google.shopping.type.Channel.ChannelEnum channel = 28; + * @param int $var + * @return $this + */ + public function setChannel($var) + { + GPBUtil::checkEnum($var, \Google\Shopping\Type\Channel\ChannelEnum::class); + $this->channel = $var; + + return $this; + } + /** * Language code of the product in BCP 47 format. * @@ -1228,37 +1272,37 @@ public function setExpirationDate($var) } /** - * Aggregated destination status. + * Aggregated status. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.ProductView.AggregatedDestinationStatus aggregated_destination_status = 26; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.ProductView.AggregatedReportingContextStatus aggregated_reporting_context_status = 26; * @return int */ - public function getAggregatedDestinationStatus() + public function getAggregatedReportingContextStatus() { - return isset($this->aggregated_destination_status) ? $this->aggregated_destination_status : 0; + return isset($this->aggregated_reporting_context_status) ? $this->aggregated_reporting_context_status : 0; } - public function hasAggregatedDestinationStatus() + public function hasAggregatedReportingContextStatus() { - return isset($this->aggregated_destination_status); + return isset($this->aggregated_reporting_context_status); } - public function clearAggregatedDestinationStatus() + public function clearAggregatedReportingContextStatus() { - unset($this->aggregated_destination_status); + unset($this->aggregated_reporting_context_status); } /** - * Aggregated destination status. + * Aggregated status. * - * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.ProductView.AggregatedDestinationStatus aggregated_destination_status = 26; + * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.ProductView.AggregatedReportingContextStatus aggregated_reporting_context_status = 26; * @param int $var * @return $this */ - public function setAggregatedDestinationStatus($var) + public function setAggregatedReportingContextStatus($var) { - GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\ProductView\AggregatedDestinationStatus::class); - $this->aggregated_destination_status = $var; + GPBUtil::checkEnum($var, \Google\Shopping\Merchant\Reports\V1beta\ProductView\AggregatedReportingContextStatus::class); + $this->aggregated_reporting_context_status = $var; return $this; } diff --git a/ShoppingMerchantReports/src/V1beta/ProductView/AggregatedReportingContextStatus.php b/ShoppingMerchantReports/src/V1beta/ProductView/AggregatedReportingContextStatus.php new file mode 100644 index 000000000000..9e6a103dccbc --- /dev/null +++ b/ShoppingMerchantReports/src/V1beta/ProductView/AggregatedReportingContextStatus.php @@ -0,0 +1,84 @@ +google.shopping.merchant.reports.v1beta.ProductView.AggregatedReportingContextStatus + */ +class AggregatedReportingContextStatus +{ + /** + * Not specified. + * + * Generated from protobuf enum AGGREGATED_REPORTING_CONTEXT_STATUS_UNSPECIFIED = 0; + */ + const AGGREGATED_REPORTING_CONTEXT_STATUS_UNSPECIFIED = 0; + /** + * Product is not eligible or is disapproved for all reporting contexts. + * + * Generated from protobuf enum NOT_ELIGIBLE_OR_DISAPPROVED = 1; + */ + const NOT_ELIGIBLE_OR_DISAPPROVED = 1; + /** + * Product's status is pending in all reporting contexts. + * + * Generated from protobuf enum PENDING = 2; + */ + const PENDING = 2; + /** + * Product is eligible for some (but not all) reporting contexts. + * + * Generated from protobuf enum ELIGIBLE_LIMITED = 3; + */ + const ELIGIBLE_LIMITED = 3; + /** + * Product is eligible for all reporting contexts. + * + * Generated from protobuf enum ELIGIBLE = 4; + */ + const ELIGIBLE = 4; + + private static $valueToName = [ + self::AGGREGATED_REPORTING_CONTEXT_STATUS_UNSPECIFIED => 'AGGREGATED_REPORTING_CONTEXT_STATUS_UNSPECIFIED', + self::NOT_ELIGIBLE_OR_DISAPPROVED => 'NOT_ELIGIBLE_OR_DISAPPROVED', + self::PENDING => 'PENDING', + self::ELIGIBLE_LIMITED => 'ELIGIBLE_LIMITED', + self::ELIGIBLE => 'ELIGIBLE', + ]; + + 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/ShoppingMerchantReports/src/V1beta/ProductView/ItemIssue/ItemIssueSeverity.php b/ShoppingMerchantReports/src/V1beta/ProductView/ItemIssue/ItemIssueSeverity.php index 2f60a75c11f8..1fc2cab67dba 100644 --- a/ShoppingMerchantReports/src/V1beta/ProductView/ItemIssue/ItemIssueSeverity.php +++ b/ShoppingMerchantReports/src/V1beta/ProductView/ItemIssue/ItemIssueSeverity.php @@ -16,13 +16,13 @@ class ItemIssueSeverity extends \Google\Protobuf\Internal\Message { /** - * Issue severity per destination. + * Issue severity per reporting context. * - * Generated from protobuf field repeated .google.shopping.merchant.reports.v1beta.ProductView.ItemIssue.ItemIssueSeverity.IssueSeverityPerDestination severity_per_destination = 1; + * Generated from protobuf field repeated .google.shopping.merchant.reports.v1beta.ProductView.ItemIssue.ItemIssueSeverity.IssueSeverityPerReportingContext severity_per_reporting_context = 1; */ - private $severity_per_destination; + private $severity_per_reporting_context; /** - * Aggregated severity of the issue for all destinations it affects. + * Aggregated severity of the issue for all reporting contexts it affects. * **This field can be used for filtering the results.** * * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.ProductView.ItemIssue.ItemIssueSeverity.AggregatedIssueSeverity aggregated_severity = 2; @@ -35,10 +35,10 @@ class ItemIssueSeverity extends \Google\Protobuf\Internal\Message * @param array $data { * Optional. Data for populating the Message object. * - * @type array<\Google\Shopping\Merchant\Reports\V1beta\ProductView\ItemIssue\ItemIssueSeverity\IssueSeverityPerDestination>|\Google\Protobuf\Internal\RepeatedField $severity_per_destination - * Issue severity per destination. + * @type array<\Google\Shopping\Merchant\Reports\V1beta\ProductView\ItemIssue\ItemIssueSeverity\IssueSeverityPerReportingContext>|\Google\Protobuf\Internal\RepeatedField $severity_per_reporting_context + * Issue severity per reporting context. * @type int $aggregated_severity - * Aggregated severity of the issue for all destinations it affects. + * Aggregated severity of the issue for all reporting contexts it affects. * **This field can be used for filtering the results.** * } */ @@ -48,33 +48,33 @@ public function __construct($data = NULL) { } /** - * Issue severity per destination. + * Issue severity per reporting context. * - * Generated from protobuf field repeated .google.shopping.merchant.reports.v1beta.ProductView.ItemIssue.ItemIssueSeverity.IssueSeverityPerDestination severity_per_destination = 1; + * Generated from protobuf field repeated .google.shopping.merchant.reports.v1beta.ProductView.ItemIssue.ItemIssueSeverity.IssueSeverityPerReportingContext severity_per_reporting_context = 1; * @return \Google\Protobuf\Internal\RepeatedField */ - public function getSeverityPerDestination() + public function getSeverityPerReportingContext() { - return $this->severity_per_destination; + return $this->severity_per_reporting_context; } /** - * Issue severity per destination. + * Issue severity per reporting context. * - * Generated from protobuf field repeated .google.shopping.merchant.reports.v1beta.ProductView.ItemIssue.ItemIssueSeverity.IssueSeverityPerDestination severity_per_destination = 1; - * @param array<\Google\Shopping\Merchant\Reports\V1beta\ProductView\ItemIssue\ItemIssueSeverity\IssueSeverityPerDestination>|\Google\Protobuf\Internal\RepeatedField $var + * Generated from protobuf field repeated .google.shopping.merchant.reports.v1beta.ProductView.ItemIssue.ItemIssueSeverity.IssueSeverityPerReportingContext severity_per_reporting_context = 1; + * @param array<\Google\Shopping\Merchant\Reports\V1beta\ProductView\ItemIssue\ItemIssueSeverity\IssueSeverityPerReportingContext>|\Google\Protobuf\Internal\RepeatedField $var * @return $this */ - public function setSeverityPerDestination($var) + public function setSeverityPerReportingContext($var) { - $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Shopping\Merchant\Reports\V1beta\ProductView\ItemIssue\ItemIssueSeverity\IssueSeverityPerDestination::class); - $this->severity_per_destination = $arr; + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Shopping\Merchant\Reports\V1beta\ProductView\ItemIssue\ItemIssueSeverity\IssueSeverityPerReportingContext::class); + $this->severity_per_reporting_context = $arr; return $this; } /** - * Aggregated severity of the issue for all destinations it affects. + * Aggregated severity of the issue for all reporting contexts it affects. * **This field can be used for filtering the results.** * * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.ProductView.ItemIssue.ItemIssueSeverity.AggregatedIssueSeverity aggregated_severity = 2; @@ -96,7 +96,7 @@ public function clearAggregatedSeverity() } /** - * Aggregated severity of the issue for all destinations it affects. + * Aggregated severity of the issue for all reporting contexts it affects. * **This field can be used for filtering the results.** * * Generated from protobuf field optional .google.shopping.merchant.reports.v1beta.ProductView.ItemIssue.ItemIssueSeverity.AggregatedIssueSeverity aggregated_severity = 2; diff --git a/ShoppingMerchantReports/src/V1beta/ProductView/ItemIssue/ItemIssueSeverity/AggregatedIssueSeverity.php b/ShoppingMerchantReports/src/V1beta/ProductView/ItemIssue/ItemIssueSeverity/AggregatedIssueSeverity.php index 076e9f69f2b2..5851f23e4d12 100644 --- a/ShoppingMerchantReports/src/V1beta/ProductView/ItemIssue/ItemIssueSeverity/AggregatedIssueSeverity.php +++ b/ShoppingMerchantReports/src/V1beta/ProductView/ItemIssue/ItemIssueSeverity/AggregatedIssueSeverity.php @@ -7,7 +7,7 @@ use UnexpectedValueException; /** - * Issue severity aggregated for all destinations. + * Issue severity aggregated for all reporting contexts. * * Protobuf type google.shopping.merchant.reports.v1beta.ProductView.ItemIssue.ItemIssueSeverity.AggregatedIssueSeverity */ @@ -20,13 +20,13 @@ class AggregatedIssueSeverity */ const AGGREGATED_ISSUE_SEVERITY_UNSPECIFIED = 0; /** - * Issue disapproves the product in at least one destination. + * Issue disapproves the product in at least one reporting context. * * Generated from protobuf enum DISAPPROVED = 1; */ const DISAPPROVED = 1; /** - * Issue demotes the product in all destinations it affects. + * Issue demotes the product in all reporting contexts it affects. * * Generated from protobuf enum DEMOTED = 2; */ diff --git a/ShoppingMerchantReports/src/V1beta/ProductView/ItemIssue/ItemIssueSeverity/IssueSeverityPerDestination.php b/ShoppingMerchantReports/src/V1beta/ProductView/ItemIssue/ItemIssueSeverity/IssueSeverityPerDestination.php index e8fab7c56aa4..9074216acd3d 100644 --- a/ShoppingMerchantReports/src/V1beta/ProductView/ItemIssue/ItemIssueSeverity/IssueSeverityPerDestination.php +++ b/ShoppingMerchantReports/src/V1beta/ProductView/ItemIssue/ItemIssueSeverity/IssueSeverityPerDestination.php @@ -42,7 +42,7 @@ class IssueSeverityPerDestination extends \Google\Protobuf\Internal\Message * @param array $data { * Optional. Data for populating the Message object. * - * @type int $destination + * @type \Google\Shopping\Type\Destination $destination * Destination the issue applies to. * @type array|\Google\Protobuf\Internal\RepeatedField $disapproved_countries * List of disapproved countries in the destination, represented in ISO @@ -61,11 +61,11 @@ public function __construct($data = NULL) { * Destination the issue applies to. * * Generated from protobuf field optional .google.shopping.type.Destination destination = 1; - * @return int + * @return \Google\Shopping\Type\Destination|null */ public function getDestination() { - return isset($this->destination) ? $this->destination : 0; + return $this->destination; } public function hasDestination() @@ -82,12 +82,12 @@ public function clearDestination() * Destination the issue applies to. * * Generated from protobuf field optional .google.shopping.type.Destination destination = 1; - * @param int $var + * @param \Google\Shopping\Type\Destination $var * @return $this */ public function setDestination($var) { - GPBUtil::checkEnum($var, \Google\Shopping\Type\Destination::class); + GPBUtil::checkMessage($var, \Google\Shopping\Type\Destination::class); $this->destination = $var; return $this; diff --git a/ShoppingMerchantReports/src/V1beta/ProductView/ItemIssue/ItemIssueSeverity/IssueSeverityPerReportingContext.php b/ShoppingMerchantReports/src/V1beta/ProductView/ItemIssue/ItemIssueSeverity/IssueSeverityPerReportingContext.php new file mode 100644 index 000000000000..e448be224818 --- /dev/null +++ b/ShoppingMerchantReports/src/V1beta/ProductView/ItemIssue/ItemIssueSeverity/IssueSeverityPerReportingContext.php @@ -0,0 +1,154 @@ +google.shopping.merchant.reports.v1beta.ProductView.ItemIssue.ItemIssueSeverity.IssueSeverityPerReportingContext + */ +class IssueSeverityPerReportingContext extends \Google\Protobuf\Internal\Message +{ + /** + * Reporting context the issue applies to. + * + * Generated from protobuf field optional .google.shopping.type.ReportingContext.ReportingContextEnum reporting_context = 1; + */ + protected $reporting_context = null; + /** + * List of disapproved countries in the reporting context, represented + * in ISO 3166 format. + * + * Generated from protobuf field repeated string disapproved_countries = 2; + */ + private $disapproved_countries; + /** + * List of demoted countries in the reporting context, represented in + * ISO 3166 format. + * + * Generated from protobuf field repeated string demoted_countries = 3; + */ + private $demoted_countries; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $reporting_context + * Reporting context the issue applies to. + * @type array|\Google\Protobuf\Internal\RepeatedField $disapproved_countries + * List of disapproved countries in the reporting context, represented + * in ISO 3166 format. + * @type array|\Google\Protobuf\Internal\RepeatedField $demoted_countries + * List of demoted countries in the reporting context, represented in + * ISO 3166 format. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Shopping\Merchant\Reports\V1Beta\Reports::initOnce(); + parent::__construct($data); + } + + /** + * Reporting context the issue applies to. + * + * Generated from protobuf field optional .google.shopping.type.ReportingContext.ReportingContextEnum reporting_context = 1; + * @return int + */ + public function getReportingContext() + { + return isset($this->reporting_context) ? $this->reporting_context : 0; + } + + public function hasReportingContext() + { + return isset($this->reporting_context); + } + + public function clearReportingContext() + { + unset($this->reporting_context); + } + + /** + * Reporting context the issue applies to. + * + * Generated from protobuf field optional .google.shopping.type.ReportingContext.ReportingContextEnum reporting_context = 1; + * @param int $var + * @return $this + */ + public function setReportingContext($var) + { + GPBUtil::checkEnum($var, \Google\Shopping\Type\ReportingContext\ReportingContextEnum::class); + $this->reporting_context = $var; + + return $this; + } + + /** + * List of disapproved countries in the reporting context, represented + * in ISO 3166 format. + * + * Generated from protobuf field repeated string disapproved_countries = 2; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getDisapprovedCountries() + { + return $this->disapproved_countries; + } + + /** + * List of disapproved countries in the reporting context, represented + * in ISO 3166 format. + * + * Generated from protobuf field repeated string disapproved_countries = 2; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setDisapprovedCountries($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->disapproved_countries = $arr; + + return $this; + } + + /** + * List of demoted countries in the reporting context, represented in + * ISO 3166 format. + * + * Generated from protobuf field repeated string demoted_countries = 3; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getDemotedCountries() + { + return $this->demoted_countries; + } + + /** + * List of demoted countries in the reporting context, represented in + * ISO 3166 format. + * + * Generated from protobuf field repeated string demoted_countries = 3; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setDemotedCountries($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->demoted_countries = $arr; + + return $this; + } + +} + + diff --git a/ShoppingMerchantReports/src/V1beta/RelativeDemand.php b/ShoppingMerchantReports/src/V1beta/RelativeDemand.php index 0a52588ebf6f..846182504c11 100644 --- a/ShoppingMerchantReports/src/V1beta/RelativeDemand.php +++ b/ShoppingMerchantReports/src/V1beta/RelativeDemand.php @@ -4,84 +4,30 @@ namespace Google\Shopping\Merchant\Reports\V1beta; -use UnexpectedValueException; +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\GPBUtil; /** * Relative demand of a product cluster or brand in the Best sellers report. * - * Protobuf type google.shopping.merchant.reports.v1beta.RelativeDemand + * Generated from protobuf message google.shopping.merchant.reports.v1beta.RelativeDemand */ -class RelativeDemand +class RelativeDemand extends \Google\Protobuf\Internal\Message { + /** - * Not specified. - * - * Generated from protobuf enum RELATIVE_DEMAND_UNSPECIFIED = 0; - */ - const RELATIVE_DEMAND_UNSPECIFIED = 0; - /** - * Demand is 0-5% of the demand of the highest ranked product cluster or - * brand. - * - * Generated from protobuf enum VERY_LOW = 10; - */ - const VERY_LOW = 10; - /** - * Demand is 6-10% of the demand of the highest ranked product cluster or - * brand. - * - * Generated from protobuf enum LOW = 20; - */ - const LOW = 20; - /** - * Demand is 11-20% of the demand of the highest ranked product cluster or - * brand. - * - * Generated from protobuf enum MEDIUM = 30; - */ - const MEDIUM = 30; - /** - * Demand is 21-50% of the demand of the highest ranked product cluster or - * brand. + * Constructor. * - * Generated from protobuf enum HIGH = 40; - */ - const HIGH = 40; - /** - * Demand is 51-100% of the demand of the highest ranked product cluster or - * brand. + * @param array $data { + * Optional. Data for populating the Message object. * - * Generated from protobuf enum VERY_HIGH = 50; + * } */ - const VERY_HIGH = 50; - - private static $valueToName = [ - self::RELATIVE_DEMAND_UNSPECIFIED => 'RELATIVE_DEMAND_UNSPECIFIED', - self::VERY_LOW => 'VERY_LOW', - self::LOW => 'LOW', - self::MEDIUM => 'MEDIUM', - self::HIGH => 'HIGH', - self::VERY_HIGH => 'VERY_HIGH', - ]; - - 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 function __construct($data = NULL) { + \GPBMetadata\Google\Shopping\Merchant\Reports\V1Beta\Reports::initOnce(); + parent::__construct($data); } - - 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/ShoppingMerchantReports/src/V1beta/RelativeDemand/RelativeDemandEnum.php b/ShoppingMerchantReports/src/V1beta/RelativeDemand/RelativeDemandEnum.php new file mode 100644 index 000000000000..30e2a17875a9 --- /dev/null +++ b/ShoppingMerchantReports/src/V1beta/RelativeDemand/RelativeDemandEnum.php @@ -0,0 +1,88 @@ +google.shopping.merchant.reports.v1beta.RelativeDemand.RelativeDemandEnum + */ +class RelativeDemandEnum +{ + /** + * Not specified. + * + * Generated from protobuf enum RELATIVE_DEMAND_ENUM_UNSPECIFIED = 0; + */ + const RELATIVE_DEMAND_ENUM_UNSPECIFIED = 0; + /** + * Demand is 0-5% of the demand of the highest ranked product cluster or + * brand. + * + * Generated from protobuf enum VERY_LOW = 10; + */ + const VERY_LOW = 10; + /** + * Demand is 6-10% of the demand of the highest ranked product cluster or + * brand. + * + * Generated from protobuf enum LOW = 20; + */ + const LOW = 20; + /** + * Demand is 11-20% of the demand of the highest ranked product cluster or + * brand. + * + * Generated from protobuf enum MEDIUM = 30; + */ + const MEDIUM = 30; + /** + * Demand is 21-50% of the demand of the highest ranked product cluster or + * brand. + * + * Generated from protobuf enum HIGH = 40; + */ + const HIGH = 40; + /** + * Demand is 51-100% of the demand of the highest ranked product cluster or + * brand. + * + * Generated from protobuf enum VERY_HIGH = 50; + */ + const VERY_HIGH = 50; + + private static $valueToName = [ + self::RELATIVE_DEMAND_ENUM_UNSPECIFIED => 'RELATIVE_DEMAND_ENUM_UNSPECIFIED', + self::VERY_LOW => 'VERY_LOW', + self::LOW => 'LOW', + self::MEDIUM => 'MEDIUM', + self::HIGH => 'HIGH', + self::VERY_HIGH => 'VERY_HIGH', + ]; + + 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/ShoppingMerchantReports/src/V1beta/RelativeDemandChangeType.php b/ShoppingMerchantReports/src/V1beta/RelativeDemandChangeType.php index a70d45075158..8ed8c4d35b29 100644 --- a/ShoppingMerchantReports/src/V1beta/RelativeDemandChangeType.php +++ b/ShoppingMerchantReports/src/V1beta/RelativeDemandChangeType.php @@ -4,66 +4,31 @@ namespace Google\Shopping\Merchant\Reports\V1beta; -use UnexpectedValueException; +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\GPBUtil; /** * Relative demand of a product cluster or brand in the Best sellers report * compared to the previous time period. * - * Protobuf type google.shopping.merchant.reports.v1beta.RelativeDemandChangeType + * Generated from protobuf message google.shopping.merchant.reports.v1beta.RelativeDemandChangeType */ -class RelativeDemandChangeType +class RelativeDemandChangeType extends \Google\Protobuf\Internal\Message { + /** - * Not specified. + * Constructor. * - * Generated from protobuf enum RELATIVE_DEMAND_CHANGE_TYPE_UNSPECIFIED = 0; - */ - const RELATIVE_DEMAND_CHANGE_TYPE_UNSPECIFIED = 0; - /** - * Relative demand is lower than the previous time period. + * @param array $data { + * Optional. Data for populating the Message object. * - * Generated from protobuf enum SINKER = 1; + * } */ - const SINKER = 1; - /** - * Relative demand is equal to the previous time period. - * - * Generated from protobuf enum FLAT = 2; - */ - const FLAT = 2; - /** - * Relative demand is higher than the previous time period. - * - * Generated from protobuf enum RISER = 3; - */ - const RISER = 3; - - private static $valueToName = [ - self::RELATIVE_DEMAND_CHANGE_TYPE_UNSPECIFIED => 'RELATIVE_DEMAND_CHANGE_TYPE_UNSPECIFIED', - self::SINKER => 'SINKER', - self::FLAT => 'FLAT', - self::RISER => 'RISER', - ]; - - 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 function __construct($data = NULL) { + \GPBMetadata\Google\Shopping\Merchant\Reports\V1Beta\Reports::initOnce(); + parent::__construct($data); } - - 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/ShoppingMerchantReports/src/V1beta/RelativeDemandChangeType/RelativeDemandChangeTypeEnum.php b/ShoppingMerchantReports/src/V1beta/RelativeDemandChangeType/RelativeDemandChangeTypeEnum.php new file mode 100644 index 000000000000..96a6b5539d41 --- /dev/null +++ b/ShoppingMerchantReports/src/V1beta/RelativeDemandChangeType/RelativeDemandChangeTypeEnum.php @@ -0,0 +1,69 @@ +google.shopping.merchant.reports.v1beta.RelativeDemandChangeType.RelativeDemandChangeTypeEnum + */ +class RelativeDemandChangeTypeEnum +{ + /** + * Not specified. + * + * Generated from protobuf enum RELATIVE_DEMAND_CHANGE_TYPE_ENUM_UNSPECIFIED = 0; + */ + const RELATIVE_DEMAND_CHANGE_TYPE_ENUM_UNSPECIFIED = 0; + /** + * Relative demand is lower than the previous time period. + * + * Generated from protobuf enum SINKER = 1; + */ + const SINKER = 1; + /** + * Relative demand is equal to the previous time period. + * + * Generated from protobuf enum FLAT = 2; + */ + const FLAT = 2; + /** + * Relative demand is higher than the previous time period. + * + * Generated from protobuf enum RISER = 3; + */ + const RISER = 3; + + private static $valueToName = [ + self::RELATIVE_DEMAND_CHANGE_TYPE_ENUM_UNSPECIFIED => 'RELATIVE_DEMAND_CHANGE_TYPE_ENUM_UNSPECIFIED', + self::SINKER => 'SINKER', + self::FLAT => 'FLAT', + self::RISER => 'RISER', + ]; + + 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/ShoppingMerchantReports/src/V1beta/ReportGranularity.php b/ShoppingMerchantReports/src/V1beta/ReportGranularity.php index aa5490f1dfe1..8915a8440ea4 100644 --- a/ShoppingMerchantReports/src/V1beta/ReportGranularity.php +++ b/ShoppingMerchantReports/src/V1beta/ReportGranularity.php @@ -4,59 +4,31 @@ namespace Google\Shopping\Merchant\Reports\V1beta; -use UnexpectedValueException; +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\GPBUtil; /** * Granularity of the Best sellers report. Best sellers reports are computed * over a week and a month timeframe. * - * Protobuf type google.shopping.merchant.reports.v1beta.ReportGranularity + * Generated from protobuf message google.shopping.merchant.reports.v1beta.ReportGranularity */ -class ReportGranularity +class ReportGranularity extends \Google\Protobuf\Internal\Message { + /** - * Not specified. - * - * Generated from protobuf enum REPORT_GRANULARITY_UNSPECIFIED = 0; - */ - const REPORT_GRANULARITY_UNSPECIFIED = 0; - /** - * Report is computed over a week timeframe. + * Constructor. * - * Generated from protobuf enum WEEKLY = 1; - */ - const WEEKLY = 1; - /** - * Report is computed over a month timeframe. + * @param array $data { + * Optional. Data for populating the Message object. * - * Generated from protobuf enum MONTHLY = 2; + * } */ - const MONTHLY = 2; - - private static $valueToName = [ - self::REPORT_GRANULARITY_UNSPECIFIED => 'REPORT_GRANULARITY_UNSPECIFIED', - self::WEEKLY => 'WEEKLY', - self::MONTHLY => 'MONTHLY', - ]; - - 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 function __construct($data = NULL) { + \GPBMetadata\Google\Shopping\Merchant\Reports\V1Beta\Reports::initOnce(); + parent::__construct($data); } - - 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/ShoppingMerchantReports/src/V1beta/ReportGranularity/ReportGranularityEnum.php b/ShoppingMerchantReports/src/V1beta/ReportGranularity/ReportGranularityEnum.php new file mode 100644 index 000000000000..580dd844aa9f --- /dev/null +++ b/ShoppingMerchantReports/src/V1beta/ReportGranularity/ReportGranularityEnum.php @@ -0,0 +1,62 @@ +google.shopping.merchant.reports.v1beta.ReportGranularity.ReportGranularityEnum + */ +class ReportGranularityEnum +{ + /** + * Not specified. + * + * Generated from protobuf enum REPORT_GRANULARITY_ENUM_UNSPECIFIED = 0; + */ + const REPORT_GRANULARITY_ENUM_UNSPECIFIED = 0; + /** + * Report is computed over a week timeframe. + * + * Generated from protobuf enum WEEKLY = 1; + */ + const WEEKLY = 1; + /** + * Report is computed over a month timeframe. + * + * Generated from protobuf enum MONTHLY = 2; + */ + const MONTHLY = 2; + + private static $valueToName = [ + self::REPORT_GRANULARITY_ENUM_UNSPECIFIED => 'REPORT_GRANULARITY_ENUM_UNSPECIFIED', + self::WEEKLY => 'WEEKLY', + self::MONTHLY => 'MONTHLY', + ]; + + 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/ShoppingMerchantReports/src/V1beta/SearchRequest.php b/ShoppingMerchantReports/src/V1beta/SearchRequest.php index 8b5a4777bd2d..ee82051d5ced 100644 --- a/ShoppingMerchantReports/src/V1beta/SearchRequest.php +++ b/ShoppingMerchantReports/src/V1beta/SearchRequest.php @@ -32,18 +32,19 @@ class SearchRequest extends \Google\Protobuf\Internal\Message */ protected $query = ''; /** - * Number of `ReportRows` to retrieve in a single page. Defaults to the - * maximum of 1000. Values above 1000 are coerced to 1000. + * Optional. Number of `ReportRows` to retrieve in a single page. Defaults to + * the maximum of 1000. Values above 1000 are coerced to 1000. * - * Generated from protobuf field int32 page_size = 3; + * Generated from protobuf field int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; */ protected $page_size = 0; /** - * Token of the page to retrieve. If not specified, the first page of results - * is returned. In order to request the next page of results, the value - * obtained from `next_page_token` in the previous response should be used. + * Optional. Token of the page to retrieve. If not specified, the first page + * of results is returned. In order to request the next page of results, the + * value obtained from `next_page_token` in the previous response should be + * used. * - * Generated from protobuf field string page_token = 4; + * Generated from protobuf field string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; */ protected $page_token = ''; @@ -76,12 +77,13 @@ public static function build(string $parent): self * guide. For the full list of available tables and fields, see the Available * fields. * @type int $page_size - * Number of `ReportRows` to retrieve in a single page. Defaults to the - * maximum of 1000. Values above 1000 are coerced to 1000. + * Optional. Number of `ReportRows` to retrieve in a single page. Defaults to + * the maximum of 1000. Values above 1000 are coerced to 1000. * @type string $page_token - * Token of the page to retrieve. If not specified, the first page of results - * is returned. In order to request the next page of results, the value - * obtained from `next_page_token` in the previous response should be used. + * Optional. Token of the page to retrieve. If not specified, the first page + * of results is returned. In order to request the next page of results, the + * value obtained from `next_page_token` in the previous response should be + * used. * } */ public function __construct($data = NULL) { @@ -150,10 +152,10 @@ public function setQuery($var) } /** - * Number of `ReportRows` to retrieve in a single page. Defaults to the - * maximum of 1000. Values above 1000 are coerced to 1000. + * Optional. Number of `ReportRows` to retrieve in a single page. Defaults to + * the maximum of 1000. Values above 1000 are coerced to 1000. * - * 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() @@ -162,10 +164,10 @@ public function getPageSize() } /** - * Number of `ReportRows` to retrieve in a single page. Defaults to the - * maximum of 1000. Values above 1000 are coerced to 1000. + * Optional. Number of `ReportRows` to retrieve in a single page. Defaults to + * the maximum of 1000. Values above 1000 are coerced to 1000. * - * 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 */ @@ -178,11 +180,12 @@ public function setPageSize($var) } /** - * Token of the page to retrieve. If not specified, the first page of results - * is returned. In order to request the next page of results, the value - * obtained from `next_page_token` in the previous response should be used. + * Optional. Token of the page to retrieve. If not specified, the first page + * of results is returned. In order to request the next page of results, the + * value obtained from `next_page_token` in the previous response should be + * used. * - * Generated from protobuf field string page_token = 4; + * Generated from protobuf field string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; * @return string */ public function getPageToken() @@ -191,11 +194,12 @@ public function getPageToken() } /** - * Token of the page to retrieve. If not specified, the first page of results - * is returned. In order to request the next page of results, the value - * obtained from `next_page_token` in the previous response should be used. + * Optional. Token of the page to retrieve. If not specified, the first page + * of results is returned. In order to request the next page of results, the + * value obtained from `next_page_token` in the previous response should be + * used. * - * Generated from protobuf field string page_token = 4; + * Generated from protobuf field string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; * @param string $var * @return $this */ diff --git a/ShoppingMerchantReports/src/V1beta/TrafficSource.php b/ShoppingMerchantReports/src/V1beta/TrafficSource.php index a99429f6e1ec..9efff184ff28 100644 --- a/ShoppingMerchantReports/src/V1beta/TrafficSource.php +++ b/ShoppingMerchantReports/src/V1beta/TrafficSource.php @@ -4,65 +4,30 @@ namespace Google\Shopping\Merchant\Reports\V1beta; -use UnexpectedValueException; +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\GPBUtil; /** * Traffic source of impressions in the Competitive visibility report. * - * Protobuf type google.shopping.merchant.reports.v1beta.TrafficSource + * Generated from protobuf message google.shopping.merchant.reports.v1beta.TrafficSource */ -class TrafficSource +class TrafficSource extends \Google\Protobuf\Internal\Message { + /** - * Not specified. + * Constructor. * - * Generated from protobuf enum TRAFFIC_SOURCE_UNSPECIFIED = 0; - */ - const TRAFFIC_SOURCE_UNSPECIFIED = 0; - /** - * Organic traffic. + * @param array $data { + * Optional. Data for populating the Message object. * - * Generated from protobuf enum ORGANIC = 1; + * } */ - const ORGANIC = 1; - /** - * Traffic from ads. - * - * Generated from protobuf enum ADS = 2; - */ - const ADS = 2; - /** - * Organic and ads traffic. - * - * Generated from protobuf enum ALL = 3; - */ - const ALL = 3; - - private static $valueToName = [ - self::TRAFFIC_SOURCE_UNSPECIFIED => 'TRAFFIC_SOURCE_UNSPECIFIED', - self::ORGANIC => 'ORGANIC', - self::ADS => 'ADS', - self::ALL => 'ALL', - ]; - - 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 function __construct($data = NULL) { + \GPBMetadata\Google\Shopping\Merchant\Reports\V1Beta\Reports::initOnce(); + parent::__construct($data); } - - 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/ShoppingMerchantReports/src/V1beta/TrafficSource/TrafficSourceEnum.php b/ShoppingMerchantReports/src/V1beta/TrafficSource/TrafficSourceEnum.php new file mode 100644 index 000000000000..7b3beb302ba3 --- /dev/null +++ b/ShoppingMerchantReports/src/V1beta/TrafficSource/TrafficSourceEnum.php @@ -0,0 +1,69 @@ +google.shopping.merchant.reports.v1beta.TrafficSource.TrafficSourceEnum + */ +class TrafficSourceEnum +{ + /** + * Not specified. + * + * Generated from protobuf enum TRAFFIC_SOURCE_ENUM_UNSPECIFIED = 0; + */ + const TRAFFIC_SOURCE_ENUM_UNSPECIFIED = 0; + /** + * Organic traffic. + * + * Generated from protobuf enum ORGANIC = 1; + */ + const ORGANIC = 1; + /** + * Traffic from ads. + * + * Generated from protobuf enum ADS = 2; + */ + const ADS = 2; + /** + * Organic and ads traffic. + * + * Generated from protobuf enum ALL = 3; + */ + const ALL = 3; + + private static $valueToName = [ + self::TRAFFIC_SOURCE_ENUM_UNSPECIFIED => 'TRAFFIC_SOURCE_ENUM_UNSPECIFIED', + self::ORGANIC => 'ORGANIC', + self::ADS => 'ADS', + self::ALL => 'ALL', + ]; + + 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/Spanner/composer.json b/Spanner/composer.json index 3998b0be6a1e..6ec6ebb1a696 100644 --- a/Spanner/composer.json +++ b/Spanner/composer.json @@ -6,8 +6,8 @@ "require": { "php": ">=7.4", "ext-grpc": "*", - "google/cloud-core": "^1.49", - "google/gax": "^1.19.1" + "google/cloud-core": "^1.52.7", + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", diff --git a/Spanner/metadata/Admin/Instance/V1/SpannerInstanceAdmin.php b/Spanner/metadata/Admin/Instance/V1/SpannerInstanceAdmin.php index f8aacfe1cce2..c5db135d02cd 100644 Binary files a/Spanner/metadata/Admin/Instance/V1/SpannerInstanceAdmin.php and b/Spanner/metadata/Admin/Instance/V1/SpannerInstanceAdmin.php differ diff --git a/Spanner/src/Admin/Database/V1/Client/BaseClient/DatabaseAdminBaseClient.php b/Spanner/src/Admin/Database/V1/Client/BaseClient/DatabaseAdminBaseClient.php deleted file mode 100644 index 0216640710c7..000000000000 --- a/Spanner/src/Admin/Database/V1/Client/BaseClient/DatabaseAdminBaseClient.php +++ /dev/null @@ -1,997 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/database_admin_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/database_admin_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/database_admin_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/database_admin_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a backup - * resource. - * - * @param string $project - * @param string $instance - * @param string $backup - * - * @return string The formatted backup resource. - */ - public static function backupName(string $project, string $instance, string $backup): string - { - return self::getPathTemplate('backup')->render([ - 'project' => $project, - 'instance' => $instance, - 'backup' => $backup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a crypto_key - * resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * @param string $cryptoKey - * - * @return string The formatted crypto_key resource. - */ - public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string - { - return self::getPathTemplate('cryptoKey')->render([ - 'project' => $project, - 'location' => $location, - 'key_ring' => $keyRing, - 'crypto_key' => $cryptoKey, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * crypto_key_version resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * @param string $cryptoKey - * @param string $cryptoKeyVersion - * - * @return string The formatted crypto_key_version resource. - */ - public static function cryptoKeyVersionName(string $project, string $location, string $keyRing, string $cryptoKey, string $cryptoKeyVersion): string - { - return self::getPathTemplate('cryptoKeyVersion')->render([ - 'project' => $project, - 'location' => $location, - 'key_ring' => $keyRing, - 'crypto_key' => $cryptoKey, - 'crypto_key_version' => $cryptoKeyVersion, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a database - * resource. - * - * @param string $project - * @param string $instance - * @param string $database - * - * @return string The formatted database resource. - */ - public static function databaseName(string $project, string $instance, string $database): string - { - return self::getPathTemplate('database')->render([ - 'project' => $project, - 'instance' => $instance, - 'database' => $database, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a instance - * resource. - * - * @param string $project - * @param string $instance - * - * @return string The formatted instance resource. - */ - public static function instanceName(string $project, string $instance): string - { - return self::getPathTemplate('instance')->render([ - 'project' => $project, - 'instance' => $instance, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - backup: projects/{project}/instances/{instance}/backups/{backup} - * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} - * - cryptoKeyVersion: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version} - * - database: projects/{project}/instances/{instance}/databases/{database} - * - instance: projects/{project}/instances/{instance} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'spanner.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Starts copying a Cloud Spanner Backup. - * The returned backup [long-running operation][google.longrunning.Operation] - * will have a name of the format - * `projects//instances//backups//operations/` - * and can be used to track copying of the backup. The operation is associated - * with the destination backup. - * The [metadata][google.longrunning.Operation.metadata] field type is - * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. - * The [response][google.longrunning.Operation.response] field type is - * [Backup][google.spanner.admin.database.v1.Backup], if successful. Cancelling the returned operation will stop the - * copying and delete the backup. - * Concurrent CopyBackup requests can run on the same source backup. - * - * The async variant is {@see self::copyBackupAsync()} . - * - * @param CopyBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function copyBackup(CopyBackupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CopyBackup', $request, $callOptions)->wait(); - } - - /** - * Starts creating a new Cloud Spanner Backup. - * The returned backup [long-running operation][google.longrunning.Operation] - * will have a name of the format - * `projects//instances//backups//operations/` - * and can be used to track creation of the backup. The - * [metadata][google.longrunning.Operation.metadata] field type is - * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. The - * [response][google.longrunning.Operation.response] field type is - * [Backup][google.spanner.admin.database.v1.Backup], if successful. Cancelling the returned operation will stop the - * creation and delete the backup. - * There can be only one pending backup creation per database. Backup creation - * of different databases can run concurrently. - * - * The async variant is {@see self::createBackupAsync()} . - * - * @param CreateBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createBackup(CreateBackupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateBackup', $request, $callOptions)->wait(); - } - - /** - * Creates a new Cloud Spanner database and starts to prepare it for serving. - * The returned [long-running operation][google.longrunning.Operation] will - * have a name of the format `/operations/` and - * can be used to track preparation of the database. The - * [metadata][google.longrunning.Operation.metadata] field type is - * [CreateDatabaseMetadata][google.spanner.admin.database.v1.CreateDatabaseMetadata]. The - * [response][google.longrunning.Operation.response] field type is - * [Database][google.spanner.admin.database.v1.Database], if successful. - * - * The async variant is {@see self::createDatabaseAsync()} . - * - * @param CreateDatabaseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDatabase(CreateDatabaseRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateDatabase', $request, $callOptions)->wait(); - } - - /** - * Deletes a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. - * - * The async variant is {@see self::deleteBackupAsync()} . - * - * @param DeleteBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteBackup(DeleteBackupRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteBackup', $request, $callOptions)->wait(); - } - - /** - * Drops (aka deletes) a Cloud Spanner database. - * Completed backups for the database will be retained according to their - * `expire_time`. - * Note: Cloud Spanner might continue to accept requests for a few seconds - * after the database has been deleted. - * - * The async variant is {@see self::dropDatabaseAsync()} . - * - * @param DropDatabaseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function dropDatabase(DropDatabaseRequest $request, array $callOptions = []): void - { - $this->startApiCall('DropDatabase', $request, $callOptions)->wait(); - } - - /** - * Gets metadata on a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. - * - * The async variant is {@see self::getBackupAsync()} . - * - * @param GetBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Backup - * - * @throws ApiException Thrown if the API call fails. - */ - public function getBackup(GetBackupRequest $request, array $callOptions = []): Backup - { - return $this->startApiCall('GetBackup', $request, $callOptions)->wait(); - } - - /** - * Gets the state of a Cloud Spanner database. - * - * The async variant is {@see self::getDatabaseAsync()} . - * - * @param GetDatabaseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Database - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDatabase(GetDatabaseRequest $request, array $callOptions = []): Database - { - return $this->startApiCall('GetDatabase', $request, $callOptions)->wait(); - } - - /** - * Returns the schema of a Cloud Spanner database as a list of formatted - * DDL statements. This method does not show pending schema updates, those may - * be queried using the [Operations][google.longrunning.Operations] API. - * - * The async variant is {@see self::getDatabaseDdlAsync()} . - * - * @param GetDatabaseDdlRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GetDatabaseDdlResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDatabaseDdl(GetDatabaseDdlRequest $request, array $callOptions = []): GetDatabaseDdlResponse - { - return $this->startApiCall('GetDatabaseDdl', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a database or backup resource. - * Returns an empty policy if a database or backup exists but does not have a - * policy set. - * - * Authorization requires `spanner.databases.getIamPolicy` permission on - * [resource][google.iam.v1.GetIamPolicyRequest.resource]. - * For backups, authorization requires `spanner.backups.getIamPolicy` - * permission on [resource][google.iam.v1.GetIamPolicyRequest.resource]. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Lists the backup [long-running operations][google.longrunning.Operation] in - * the given instance. A backup operation has a name of the form - * `projects//instances//backups//operations/`. - * The long-running operation - * [metadata][google.longrunning.Operation.metadata] field type - * `metadata.type_url` describes the type of the metadata. Operations returned - * include those that have completed/failed/canceled within the last 7 days, - * and pending operations. Operations returned are ordered by - * `operation.metadata.value.progress.start_time` in descending order starting - * from the most recently started operation. - * - * The async variant is {@see self::listBackupOperationsAsync()} . - * - * @param ListBackupOperationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listBackupOperations(ListBackupOperationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListBackupOperations', $request, $callOptions); - } - - /** - * Lists completed and pending backups. - * Backups returned are ordered by `create_time` in descending order, - * starting from the most recent `create_time`. - * - * The async variant is {@see self::listBackupsAsync()} . - * - * @param ListBackupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listBackups(ListBackupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListBackups', $request, $callOptions); - } - - /** - * Lists database [longrunning-operations][google.longrunning.Operation]. - * A database operation has a name of the form - * `projects//instances//databases//operations/`. - * The long-running operation - * [metadata][google.longrunning.Operation.metadata] field type - * `metadata.type_url` describes the type of the metadata. Operations returned - * include those that have completed/failed/canceled within the last 7 days, - * and pending operations. - * - * The async variant is {@see self::listDatabaseOperationsAsync()} . - * - * @param ListDatabaseOperationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDatabaseOperations(ListDatabaseOperationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDatabaseOperations', $request, $callOptions); - } - - /** - * Lists Cloud Spanner database roles. - * - * The async variant is {@see self::listDatabaseRolesAsync()} . - * - * @param ListDatabaseRolesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDatabaseRoles(ListDatabaseRolesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDatabaseRoles', $request, $callOptions); - } - - /** - * Lists Cloud Spanner databases. - * - * The async variant is {@see self::listDatabasesAsync()} . - * - * @param ListDatabasesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDatabases(ListDatabasesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDatabases', $request, $callOptions); - } - - /** - * Create a new database by restoring from a completed backup. The new - * database must be in the same project and in an instance with the same - * instance configuration as the instance containing - * the backup. The returned database [long-running - * operation][google.longrunning.Operation] has a name of the format - * `projects//instances//databases//operations/`, - * and can be used to track the progress of the operation, and to cancel it. - * The [metadata][google.longrunning.Operation.metadata] field type is - * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. - * The [response][google.longrunning.Operation.response] type - * is [Database][google.spanner.admin.database.v1.Database], if - * successful. Cancelling the returned operation will stop the restore and - * delete the database. - * There can be only one database being restored into an instance at a time. - * Once the restore operation completes, a new restore operation can be - * initiated, without waiting for the optimize operation associated with the - * first restore to complete. - * - * The async variant is {@see self::restoreDatabaseAsync()} . - * - * @param RestoreDatabaseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function restoreDatabase(RestoreDatabaseRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RestoreDatabase', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on a database or backup resource. - * Replaces any existing policy. - * - * Authorization requires `spanner.databases.setIamPolicy` - * permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. - * For backups, authorization requires `spanner.backups.setIamPolicy` - * permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that the caller has on the specified database or backup - * resource. - * - * Attempting this RPC on a non-existent Cloud Spanner database will - * result in a NOT_FOUND error if the user has - * `spanner.databases.list` permission on the containing Cloud - * Spanner instance. Otherwise returns an empty set of permissions. - * Calling this method on a backup that does not exist will - * result in a NOT_FOUND error if the user has - * `spanner.backups.list` permission on the containing instance. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Updates a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. - * - * The async variant is {@see self::updateBackupAsync()} . - * - * @param UpdateBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Backup - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateBackup(UpdateBackupRequest $request, array $callOptions = []): Backup - { - return $this->startApiCall('UpdateBackup', $request, $callOptions)->wait(); - } - - /** - * Updates a Cloud Spanner database. The returned - * [long-running operation][google.longrunning.Operation] can be used to track - * the progress of updating the database. If the named database does not - * exist, returns `NOT_FOUND`. - * - * While the operation is pending: - * - * * The database's - * [reconciling][google.spanner.admin.database.v1.Database.reconciling] - * field is set to true. - * * Cancelling the operation is best-effort. If the cancellation succeeds, - * the operation metadata's - * [cancel_time][google.spanner.admin.database.v1.UpdateDatabaseMetadata.cancel_time] - * is set, the updates are reverted, and the operation terminates with a - * `CANCELLED` status. - * * New UpdateDatabase requests will return a `FAILED_PRECONDITION` error - * until the pending operation is done (returns successfully or with - * error). - * * Reading the database via the API continues to give the pre-request - * values. - * - * Upon completion of the returned operation: - * - * * The new values are in effect and readable via the API. - * * The database's - * [reconciling][google.spanner.admin.database.v1.Database.reconciling] - * field becomes false. - * - * The returned [long-running operation][google.longrunning.Operation] will - * have a name of the format - * `projects//instances//databases//operations/` - * and can be used to track the database modification. The - * [metadata][google.longrunning.Operation.metadata] field type is - * [UpdateDatabaseMetadata][google.spanner.admin.database.v1.UpdateDatabaseMetadata]. - * The [response][google.longrunning.Operation.response] field type is - * [Database][google.spanner.admin.database.v1.Database], if successful. - * - * The async variant is {@see self::updateDatabaseAsync()} . - * - * @param UpdateDatabaseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDatabase(UpdateDatabaseRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateDatabase', $request, $callOptions)->wait(); - } - - /** - * Updates the schema of a Cloud Spanner database by - * creating/altering/dropping tables, columns, indexes, etc. The returned - * [long-running operation][google.longrunning.Operation] will have a name of - * the format `/operations/` and can be used to - * track execution of the schema change(s). The - * [metadata][google.longrunning.Operation.metadata] field type is - * [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. The operation has no response. - * - * The async variant is {@see self::updateDatabaseDdlAsync()} . - * - * @param UpdateDatabaseDdlRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateDatabaseDdl(UpdateDatabaseDdlRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateDatabaseDdl', $request, $callOptions)->wait(); - } -} diff --git a/Spanner/src/Admin/Database/V1/Client/DatabaseAdminClient.php b/Spanner/src/Admin/Database/V1/Client/DatabaseAdminClient.php index 80d18058c8f1..0ecbe515f47c 100644 --- a/Spanner/src/Admin/Database/V1/Client/DatabaseAdminClient.php +++ b/Spanner/src/Admin/Database/V1/Client/DatabaseAdminClient.php @@ -24,17 +24,972 @@ namespace Google\Cloud\Spanner\Admin\Database\V1\Client; -use Google\Cloud\Spanner\Admin\Database\V1\Client\BaseClient\DatabaseAdminBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Spanner\Admin\Database\V1\Backup; +use Google\Cloud\Spanner\Admin\Database\V1\CopyBackupMetadata; +use Google\Cloud\Spanner\Admin\Database\V1\CopyBackupRequest; +use Google\Cloud\Spanner\Admin\Database\V1\CreateBackupMetadata; +use Google\Cloud\Spanner\Admin\Database\V1\CreateBackupRequest; +use Google\Cloud\Spanner\Admin\Database\V1\CreateDatabaseMetadata; +use Google\Cloud\Spanner\Admin\Database\V1\CreateDatabaseRequest; +use Google\Cloud\Spanner\Admin\Database\V1\Database; +use Google\Cloud\Spanner\Admin\Database\V1\DeleteBackupRequest; +use Google\Cloud\Spanner\Admin\Database\V1\DropDatabaseRequest; +use Google\Cloud\Spanner\Admin\Database\V1\GetBackupRequest; +use Google\Cloud\Spanner\Admin\Database\V1\GetDatabaseDdlRequest; +use Google\Cloud\Spanner\Admin\Database\V1\GetDatabaseDdlResponse; +use Google\Cloud\Spanner\Admin\Database\V1\GetDatabaseRequest; +use Google\Cloud\Spanner\Admin\Database\V1\ListBackupOperationsRequest; +use Google\Cloud\Spanner\Admin\Database\V1\ListBackupsRequest; +use Google\Cloud\Spanner\Admin\Database\V1\ListDatabaseOperationsRequest; +use Google\Cloud\Spanner\Admin\Database\V1\ListDatabaseRolesRequest; +use Google\Cloud\Spanner\Admin\Database\V1\ListDatabasesRequest; +use Google\Cloud\Spanner\Admin\Database\V1\RestoreDatabaseMetadata; +use Google\Cloud\Spanner\Admin\Database\V1\RestoreDatabaseRequest; +use Google\Cloud\Spanner\Admin\Database\V1\UpdateBackupRequest; +use Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseDdlMetadata; +use Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseDdlRequest; +use Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseMetadata; +use Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Cloud Spanner Database Admin API * - * This class is currently experimental and may be subject to changes. + * The Cloud Spanner Database Admin API can be used to: + * * create, drop, and list databases + * * update the schema of pre-existing databases + * * create, delete and list backups for a database + * * restore a database from an existing backup + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Spanner\Admin\Database\V1\DatabaseAdminClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface copyBackupAsync(CopyBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface createBackupAsync(CreateBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface createDatabaseAsync(CreateDatabaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteBackupAsync(DeleteBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface dropDatabaseAsync(DropDatabaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface getBackupAsync(GetBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDatabaseAsync(GetDatabaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDatabaseDdlAsync(GetDatabaseDdlRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listBackupOperationsAsync(ListBackupOperationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listBackupsAsync(ListBackupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDatabaseOperationsAsync(ListDatabaseOperationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDatabaseRolesAsync(ListDatabaseRolesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDatabasesAsync(ListDatabasesRequest $request, array $optionalArgs = []) + * @method PromiseInterface restoreDatabaseAsync(RestoreDatabaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateBackupAsync(UpdateBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDatabaseAsync(UpdateDatabaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateDatabaseDdlAsync(UpdateDatabaseDdlRequest $request, array $optionalArgs = []) */ -final class DatabaseAdminClient extends DatabaseAdminBaseClient +final class DatabaseAdminClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see DatabaseAdminBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.spanner.admin.database.v1.DatabaseAdmin'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'spanner.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/spanner.admin', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/database_admin_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/database_admin_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/database_admin_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/database_admin_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a backup + * resource. + * + * @param string $project + * @param string $instance + * @param string $backup + * + * @return string The formatted backup resource. + */ + public static function backupName(string $project, string $instance, string $backup): string + { + return self::getPathTemplate('backup')->render([ + 'project' => $project, + 'instance' => $instance, + 'backup' => $backup, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a crypto_key + * resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * + * @return string The formatted crypto_key resource. + */ + public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string + { + return self::getPathTemplate('cryptoKey')->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'crypto_key' => $cryptoKey, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * crypto_key_version resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * @param string $cryptoKeyVersion + * + * @return string The formatted crypto_key_version resource. + */ + public static function cryptoKeyVersionName(string $project, string $location, string $keyRing, string $cryptoKey, string $cryptoKeyVersion): string + { + return self::getPathTemplate('cryptoKeyVersion')->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'crypto_key' => $cryptoKey, + 'crypto_key_version' => $cryptoKeyVersion, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a database + * resource. + * + * @param string $project + * @param string $instance + * @param string $database + * + * @return string The formatted database resource. + */ + public static function databaseName(string $project, string $instance, string $database): string + { + return self::getPathTemplate('database')->render([ + 'project' => $project, + 'instance' => $instance, + 'database' => $database, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a instance + * resource. + * + * @param string $project + * @param string $instance + * + * @return string The formatted instance resource. + */ + public static function instanceName(string $project, string $instance): string + { + return self::getPathTemplate('instance')->render([ + 'project' => $project, + 'instance' => $instance, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - backup: projects/{project}/instances/{instance}/backups/{backup} + * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} + * - cryptoKeyVersion: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version} + * - database: projects/{project}/instances/{instance}/databases/{database} + * - instance: projects/{project}/instances/{instance} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'spanner.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Starts copying a Cloud Spanner Backup. + * The returned backup [long-running operation][google.longrunning.Operation] + * will have a name of the format + * `projects//instances//backups//operations/` + * and can be used to track copying of the backup. The operation is associated + * with the destination backup. + * The [metadata][google.longrunning.Operation.metadata] field type is + * [CopyBackupMetadata][google.spanner.admin.database.v1.CopyBackupMetadata]. + * The [response][google.longrunning.Operation.response] field type is + * [Backup][google.spanner.admin.database.v1.Backup], if successful. Cancelling the returned operation will stop the + * copying and delete the backup. + * Concurrent CopyBackup requests can run on the same source backup. + * + * The async variant is {@see DatabaseAdminClient::copyBackupAsync()} . + * + * @param CopyBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function copyBackup(CopyBackupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CopyBackup', $request, $callOptions)->wait(); + } + + /** + * Starts creating a new Cloud Spanner Backup. + * The returned backup [long-running operation][google.longrunning.Operation] + * will have a name of the format + * `projects//instances//backups//operations/` + * and can be used to track creation of the backup. The + * [metadata][google.longrunning.Operation.metadata] field type is + * [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. The + * [response][google.longrunning.Operation.response] field type is + * [Backup][google.spanner.admin.database.v1.Backup], if successful. Cancelling the returned operation will stop the + * creation and delete the backup. + * There can be only one pending backup creation per database. Backup creation + * of different databases can run concurrently. + * + * The async variant is {@see DatabaseAdminClient::createBackupAsync()} . + * + * @param CreateBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createBackup(CreateBackupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateBackup', $request, $callOptions)->wait(); + } + + /** + * Creates a new Cloud Spanner database and starts to prepare it for serving. + * The returned [long-running operation][google.longrunning.Operation] will + * have a name of the format `/operations/` and + * can be used to track preparation of the database. The + * [metadata][google.longrunning.Operation.metadata] field type is + * [CreateDatabaseMetadata][google.spanner.admin.database.v1.CreateDatabaseMetadata]. The + * [response][google.longrunning.Operation.response] field type is + * [Database][google.spanner.admin.database.v1.Database], if successful. + * + * The async variant is {@see DatabaseAdminClient::createDatabaseAsync()} . + * + * @param CreateDatabaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDatabase(CreateDatabaseRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateDatabase', $request, $callOptions)->wait(); + } + + /** + * Deletes a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. + * + * The async variant is {@see DatabaseAdminClient::deleteBackupAsync()} . + * + * @param DeleteBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteBackup(DeleteBackupRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteBackup', $request, $callOptions)->wait(); + } + + /** + * Drops (aka deletes) a Cloud Spanner database. + * Completed backups for the database will be retained according to their + * `expire_time`. + * Note: Cloud Spanner might continue to accept requests for a few seconds + * after the database has been deleted. + * + * The async variant is {@see DatabaseAdminClient::dropDatabaseAsync()} . + * + * @param DropDatabaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function dropDatabase(DropDatabaseRequest $request, array $callOptions = []): void + { + $this->startApiCall('DropDatabase', $request, $callOptions)->wait(); + } + + /** + * Gets metadata on a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. + * + * The async variant is {@see DatabaseAdminClient::getBackupAsync()} . + * + * @param GetBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Backup + * + * @throws ApiException Thrown if the API call fails. + */ + public function getBackup(GetBackupRequest $request, array $callOptions = []): Backup + { + return $this->startApiCall('GetBackup', $request, $callOptions)->wait(); + } + + /** + * Gets the state of a Cloud Spanner database. + * + * The async variant is {@see DatabaseAdminClient::getDatabaseAsync()} . + * + * @param GetDatabaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Database + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDatabase(GetDatabaseRequest $request, array $callOptions = []): Database + { + return $this->startApiCall('GetDatabase', $request, $callOptions)->wait(); + } + + /** + * Returns the schema of a Cloud Spanner database as a list of formatted + * DDL statements. This method does not show pending schema updates, those may + * be queried using the [Operations][google.longrunning.Operations] API. + * + * The async variant is {@see DatabaseAdminClient::getDatabaseDdlAsync()} . + * + * @param GetDatabaseDdlRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GetDatabaseDdlResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDatabaseDdl(GetDatabaseDdlRequest $request, array $callOptions = []): GetDatabaseDdlResponse + { + return $this->startApiCall('GetDatabaseDdl', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a database or backup resource. + * Returns an empty policy if a database or backup exists but does not have a + * policy set. + * + * Authorization requires `spanner.databases.getIamPolicy` permission on + * [resource][google.iam.v1.GetIamPolicyRequest.resource]. + * For backups, authorization requires `spanner.backups.getIamPolicy` + * permission on [resource][google.iam.v1.GetIamPolicyRequest.resource]. + * + * The async variant is {@see DatabaseAdminClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Lists the backup [long-running operations][google.longrunning.Operation] in + * the given instance. A backup operation has a name of the form + * `projects//instances//backups//operations/`. + * The long-running operation + * [metadata][google.longrunning.Operation.metadata] field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that have completed/failed/canceled within the last 7 days, + * and pending operations. Operations returned are ordered by + * `operation.metadata.value.progress.start_time` in descending order starting + * from the most recently started operation. + * + * The async variant is {@see DatabaseAdminClient::listBackupOperationsAsync()} . + * + * @param ListBackupOperationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listBackupOperations(ListBackupOperationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListBackupOperations', $request, $callOptions); + } + + /** + * Lists completed and pending backups. + * Backups returned are ordered by `create_time` in descending order, + * starting from the most recent `create_time`. + * + * The async variant is {@see DatabaseAdminClient::listBackupsAsync()} . + * + * @param ListBackupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listBackups(ListBackupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListBackups', $request, $callOptions); + } + + /** + * Lists database [longrunning-operations][google.longrunning.Operation]. + * A database operation has a name of the form + * `projects//instances//databases//operations/`. + * The long-running operation + * [metadata][google.longrunning.Operation.metadata] field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that have completed/failed/canceled within the last 7 days, + * and pending operations. + * + * The async variant is {@see DatabaseAdminClient::listDatabaseOperationsAsync()} . + * + * @param ListDatabaseOperationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDatabaseOperations(ListDatabaseOperationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDatabaseOperations', $request, $callOptions); + } + + /** + * Lists Cloud Spanner database roles. + * + * The async variant is {@see DatabaseAdminClient::listDatabaseRolesAsync()} . + * + * @param ListDatabaseRolesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDatabaseRoles(ListDatabaseRolesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDatabaseRoles', $request, $callOptions); + } + + /** + * Lists Cloud Spanner databases. + * + * The async variant is {@see DatabaseAdminClient::listDatabasesAsync()} . + * + * @param ListDatabasesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDatabases(ListDatabasesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDatabases', $request, $callOptions); + } + + /** + * Create a new database by restoring from a completed backup. The new + * database must be in the same project and in an instance with the same + * instance configuration as the instance containing + * the backup. The returned database [long-running + * operation][google.longrunning.Operation] has a name of the format + * `projects//instances//databases//operations/`, + * and can be used to track the progress of the operation, and to cancel it. + * The [metadata][google.longrunning.Operation.metadata] field type is + * [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata]. + * The [response][google.longrunning.Operation.response] type + * is [Database][google.spanner.admin.database.v1.Database], if + * successful. Cancelling the returned operation will stop the restore and + * delete the database. + * There can be only one database being restored into an instance at a time. + * Once the restore operation completes, a new restore operation can be + * initiated, without waiting for the optimize operation associated with the + * first restore to complete. + * + * The async variant is {@see DatabaseAdminClient::restoreDatabaseAsync()} . + * + * @param RestoreDatabaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function restoreDatabase(RestoreDatabaseRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RestoreDatabase', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on a database or backup resource. + * Replaces any existing policy. + * + * Authorization requires `spanner.databases.setIamPolicy` + * permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. + * For backups, authorization requires `spanner.backups.setIamPolicy` + * permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. + * + * The async variant is {@see DatabaseAdminClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that the caller has on the specified database or backup + * resource. + * + * Attempting this RPC on a non-existent Cloud Spanner database will + * result in a NOT_FOUND error if the user has + * `spanner.databases.list` permission on the containing Cloud + * Spanner instance. Otherwise returns an empty set of permissions. + * Calling this method on a backup that does not exist will + * result in a NOT_FOUND error if the user has + * `spanner.backups.list` permission on the containing instance. + * + * The async variant is {@see DatabaseAdminClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates a pending or completed [Backup][google.spanner.admin.database.v1.Backup]. + * + * The async variant is {@see DatabaseAdminClient::updateBackupAsync()} . + * + * @param UpdateBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Backup + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateBackup(UpdateBackupRequest $request, array $callOptions = []): Backup + { + return $this->startApiCall('UpdateBackup', $request, $callOptions)->wait(); + } + + /** + * Updates a Cloud Spanner database. The returned + * [long-running operation][google.longrunning.Operation] can be used to track + * the progress of updating the database. If the named database does not + * exist, returns `NOT_FOUND`. + * + * While the operation is pending: + * + * * The database's + * [reconciling][google.spanner.admin.database.v1.Database.reconciling] + * field is set to true. + * * Cancelling the operation is best-effort. If the cancellation succeeds, + * the operation metadata's + * [cancel_time][google.spanner.admin.database.v1.UpdateDatabaseMetadata.cancel_time] + * is set, the updates are reverted, and the operation terminates with a + * `CANCELLED` status. + * * New UpdateDatabase requests will return a `FAILED_PRECONDITION` error + * until the pending operation is done (returns successfully or with + * error). + * * Reading the database via the API continues to give the pre-request + * values. + * + * Upon completion of the returned operation: + * + * * The new values are in effect and readable via the API. + * * The database's + * [reconciling][google.spanner.admin.database.v1.Database.reconciling] + * field becomes false. + * + * The returned [long-running operation][google.longrunning.Operation] will + * have a name of the format + * `projects//instances//databases//operations/` + * and can be used to track the database modification. The + * [metadata][google.longrunning.Operation.metadata] field type is + * [UpdateDatabaseMetadata][google.spanner.admin.database.v1.UpdateDatabaseMetadata]. + * The [response][google.longrunning.Operation.response] field type is + * [Database][google.spanner.admin.database.v1.Database], if successful. + * + * The async variant is {@see DatabaseAdminClient::updateDatabaseAsync()} . + * + * @param UpdateDatabaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDatabase(UpdateDatabaseRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateDatabase', $request, $callOptions)->wait(); + } + + /** + * Updates the schema of a Cloud Spanner database by + * creating/altering/dropping tables, columns, indexes, etc. The returned + * [long-running operation][google.longrunning.Operation] will have a name of + * the format `/operations/` and can be used to + * track execution of the schema change(s). The + * [metadata][google.longrunning.Operation.metadata] field type is + * [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. The operation has no response. + * + * The async variant is {@see DatabaseAdminClient::updateDatabaseDdlAsync()} . + * + * @param UpdateDatabaseDdlRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateDatabaseDdl(UpdateDatabaseDdlRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateDatabaseDdl', $request, $callOptions)->wait(); + } } diff --git a/Spanner/src/Admin/Instance/V1/AutoscalingConfig.php b/Spanner/src/Admin/Instance/V1/AutoscalingConfig.php new file mode 100644 index 000000000000..fa11ad369651 --- /dev/null +++ b/Spanner/src/Admin/Instance/V1/AutoscalingConfig.php @@ -0,0 +1,121 @@ +google.spanner.admin.instance.v1.AutoscalingConfig + */ +class AutoscalingConfig extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Autoscaling limits for an instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig.AutoscalingLimits autoscaling_limits = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $autoscaling_limits = null; + /** + * Required. The autoscaling targets for an instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig.AutoscalingTargets autoscaling_targets = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $autoscaling_targets = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AutoscalingLimits $autoscaling_limits + * Required. Autoscaling limits for an instance. + * @type \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AutoscalingTargets $autoscaling_targets + * Required. The autoscaling targets for an instance. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. Autoscaling limits for an instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig.AutoscalingLimits autoscaling_limits = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AutoscalingLimits|null + */ + public function getAutoscalingLimits() + { + return $this->autoscaling_limits; + } + + public function hasAutoscalingLimits() + { + return isset($this->autoscaling_limits); + } + + public function clearAutoscalingLimits() + { + unset($this->autoscaling_limits); + } + + /** + * Required. Autoscaling limits for an instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig.AutoscalingLimits autoscaling_limits = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AutoscalingLimits $var + * @return $this + */ + public function setAutoscalingLimits($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AutoscalingLimits::class); + $this->autoscaling_limits = $var; + + return $this; + } + + /** + * Required. The autoscaling targets for an instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig.AutoscalingTargets autoscaling_targets = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AutoscalingTargets|null + */ + public function getAutoscalingTargets() + { + return $this->autoscaling_targets; + } + + public function hasAutoscalingTargets() + { + return isset($this->autoscaling_targets); + } + + public function clearAutoscalingTargets() + { + unset($this->autoscaling_targets); + } + + /** + * Required. The autoscaling targets for an instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig.AutoscalingTargets autoscaling_targets = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AutoscalingTargets $var + * @return $this + */ + public function setAutoscalingTargets($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig\AutoscalingTargets::class); + $this->autoscaling_targets = $var; + + return $this; + } + +} + diff --git a/Spanner/src/Admin/Instance/V1/AutoscalingConfig/AutoscalingLimits.php b/Spanner/src/Admin/Instance/V1/AutoscalingConfig/AutoscalingLimits.php new file mode 100644 index 000000000000..48ac73c059f5 --- /dev/null +++ b/Spanner/src/Admin/Instance/V1/AutoscalingConfig/AutoscalingLimits.php @@ -0,0 +1,205 @@ +google.spanner.admin.instance.v1.AutoscalingConfig.AutoscalingLimits + */ +class AutoscalingLimits extends \Google\Protobuf\Internal\Message +{ + protected $min_limit; + protected $max_limit; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $min_nodes + * Minimum number of nodes allocated to the instance. If set, this number + * should be greater than or equal to 1. + * @type int $min_processing_units + * Minimum number of processing units allocated to the instance. If set, + * this number should be multiples of 1000. + * @type int $max_nodes + * Maximum number of nodes allocated to the instance. If set, this number + * should be greater than or equal to min_nodes. + * @type int $max_processing_units + * Maximum number of processing units allocated to the instance. If set, + * this number should be multiples of 1000 and be greater than or equal to + * min_processing_units. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Minimum number of nodes allocated to the instance. If set, this number + * should be greater than or equal to 1. + * + * Generated from protobuf field int32 min_nodes = 1; + * @return int + */ + public function getMinNodes() + { + return $this->readOneof(1); + } + + public function hasMinNodes() + { + return $this->hasOneof(1); + } + + /** + * Minimum number of nodes allocated to the instance. If set, this number + * should be greater than or equal to 1. + * + * Generated from protobuf field int32 min_nodes = 1; + * @param int $var + * @return $this + */ + public function setMinNodes($var) + { + GPBUtil::checkInt32($var); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * Minimum number of processing units allocated to the instance. If set, + * this number should be multiples of 1000. + * + * Generated from protobuf field int32 min_processing_units = 2; + * @return int + */ + public function getMinProcessingUnits() + { + return $this->readOneof(2); + } + + public function hasMinProcessingUnits() + { + return $this->hasOneof(2); + } + + /** + * Minimum number of processing units allocated to the instance. If set, + * this number should be multiples of 1000. + * + * Generated from protobuf field int32 min_processing_units = 2; + * @param int $var + * @return $this + */ + public function setMinProcessingUnits($var) + { + GPBUtil::checkInt32($var); + $this->writeOneof(2, $var); + + return $this; + } + + /** + * Maximum number of nodes allocated to the instance. If set, this number + * should be greater than or equal to min_nodes. + * + * Generated from protobuf field int32 max_nodes = 3; + * @return int + */ + public function getMaxNodes() + { + return $this->readOneof(3); + } + + public function hasMaxNodes() + { + return $this->hasOneof(3); + } + + /** + * Maximum number of nodes allocated to the instance. If set, this number + * should be greater than or equal to min_nodes. + * + * Generated from protobuf field int32 max_nodes = 3; + * @param int $var + * @return $this + */ + public function setMaxNodes($var) + { + GPBUtil::checkInt32($var); + $this->writeOneof(3, $var); + + return $this; + } + + /** + * Maximum number of processing units allocated to the instance. If set, + * this number should be multiples of 1000 and be greater than or equal to + * min_processing_units. + * + * Generated from protobuf field int32 max_processing_units = 4; + * @return int + */ + public function getMaxProcessingUnits() + { + return $this->readOneof(4); + } + + public function hasMaxProcessingUnits() + { + return $this->hasOneof(4); + } + + /** + * Maximum number of processing units allocated to the instance. If set, + * this number should be multiples of 1000 and be greater than or equal to + * min_processing_units. + * + * Generated from protobuf field int32 max_processing_units = 4; + * @param int $var + * @return $this + */ + public function setMaxProcessingUnits($var) + { + GPBUtil::checkInt32($var); + $this->writeOneof(4, $var); + + return $this; + } + + /** + * @return string + */ + public function getMinLimit() + { + return $this->whichOneof("min_limit"); + } + + /** + * @return string + */ + public function getMaxLimit() + { + return $this->whichOneof("max_limit"); + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(AutoscalingLimits::class, \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig_AutoscalingLimits::class); + diff --git a/Spanner/src/Admin/Instance/V1/AutoscalingConfig/AutoscalingTargets.php b/Spanner/src/Admin/Instance/V1/AutoscalingConfig/AutoscalingTargets.php new file mode 100644 index 000000000000..45f359fee624 --- /dev/null +++ b/Spanner/src/Admin/Instance/V1/AutoscalingConfig/AutoscalingTargets.php @@ -0,0 +1,128 @@ +google.spanner.admin.instance.v1.AutoscalingConfig.AutoscalingTargets + */ +class AutoscalingTargets extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The target high priority cpu utilization percentage that the + * autoscaler should be trying to achieve for the instance. This number is + * on a scale from 0 (no utilization) to 100 (full utilization). The valid + * range is [10, 90] inclusive. + * + * Generated from protobuf field int32 high_priority_cpu_utilization_percent = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + private $high_priority_cpu_utilization_percent = 0; + /** + * Required. The target storage utilization percentage that the autoscaler + * should be trying to achieve for the instance. This number is on a scale + * from 0 (no utilization) to 100 (full utilization). The valid range is + * [10, 100] inclusive. + * + * Generated from protobuf field int32 storage_utilization_percent = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $storage_utilization_percent = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $high_priority_cpu_utilization_percent + * Required. The target high priority cpu utilization percentage that the + * autoscaler should be trying to achieve for the instance. This number is + * on a scale from 0 (no utilization) to 100 (full utilization). The valid + * range is [10, 90] inclusive. + * @type int $storage_utilization_percent + * Required. The target storage utilization percentage that the autoscaler + * should be trying to achieve for the instance. This number is on a scale + * from 0 (no utilization) to 100 (full utilization). The valid range is + * [10, 100] inclusive. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Spanner\Admin\Instance\V1\SpannerInstanceAdmin::initOnce(); + parent::__construct($data); + } + + /** + * Required. The target high priority cpu utilization percentage that the + * autoscaler should be trying to achieve for the instance. This number is + * on a scale from 0 (no utilization) to 100 (full utilization). The valid + * range is [10, 90] inclusive. + * + * Generated from protobuf field int32 high_priority_cpu_utilization_percent = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return int + */ + public function getHighPriorityCpuUtilizationPercent() + { + return $this->high_priority_cpu_utilization_percent; + } + + /** + * Required. The target high priority cpu utilization percentage that the + * autoscaler should be trying to achieve for the instance. This number is + * on a scale from 0 (no utilization) to 100 (full utilization). The valid + * range is [10, 90] inclusive. + * + * Generated from protobuf field int32 high_priority_cpu_utilization_percent = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param int $var + * @return $this + */ + public function setHighPriorityCpuUtilizationPercent($var) + { + GPBUtil::checkInt32($var); + $this->high_priority_cpu_utilization_percent = $var; + + return $this; + } + + /** + * Required. The target storage utilization percentage that the autoscaler + * should be trying to achieve for the instance. This number is on a scale + * from 0 (no utilization) to 100 (full utilization). The valid range is + * [10, 100] inclusive. + * + * Generated from protobuf field int32 storage_utilization_percent = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return int + */ + public function getStorageUtilizationPercent() + { + return $this->storage_utilization_percent; + } + + /** + * Required. The target storage utilization percentage that the autoscaler + * should be trying to achieve for the instance. This number is on a scale + * from 0 (no utilization) to 100 (full utilization). The valid range is + * [10, 100] inclusive. + * + * Generated from protobuf field int32 storage_utilization_percent = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param int $var + * @return $this + */ + public function setStorageUtilizationPercent($var) + { + GPBUtil::checkInt32($var); + $this->storage_utilization_percent = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(AutoscalingTargets::class, \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig_AutoscalingTargets::class); + diff --git a/Spanner/src/Admin/Instance/V1/Client/BaseClient/InstanceAdminBaseClient.php b/Spanner/src/Admin/Instance/V1/Client/BaseClient/InstanceAdminBaseClient.php deleted file mode 100644 index c686fed163c9..000000000000 --- a/Spanner/src/Admin/Instance/V1/Client/BaseClient/InstanceAdminBaseClient.php +++ /dev/null @@ -1,863 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/instance_admin_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/instance_admin_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/instance_admin_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/instance_admin_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a instance - * resource. - * - * @param string $project - * @param string $instance - * - * @return string The formatted instance resource. - */ - public static function instanceName(string $project, string $instance): string - { - return self::getPathTemplate('instance')->render([ - 'project' => $project, - 'instance' => $instance, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * instance_config resource. - * - * @param string $project - * @param string $instanceConfig - * - * @return string The formatted instance_config resource. - */ - public static function instanceConfigName(string $project, string $instanceConfig): string - { - return self::getPathTemplate('instanceConfig')->render([ - 'project' => $project, - 'instance_config' => $instanceConfig, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->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 - * - instance: projects/{project}/instances/{instance} - * - instanceConfig: projects/{project}/instanceConfigs/{instance_config} - * - 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. - */ - public static function parseName(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'spanner.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates an instance and begins preparing it to begin serving. The - * returned [long-running operation][google.longrunning.Operation] - * can be used to track the progress of preparing the new - * instance. The instance name is assigned by the caller. If the - * named instance already exists, `CreateInstance` returns - * `ALREADY_EXISTS`. - * - * Immediately upon completion of this request: - * - * * The instance is readable via the API, with all requested attributes - * but no allocated resources. Its state is `CREATING`. - * - * Until completion of the returned operation: - * - * * Cancelling the operation renders the instance immediately unreadable - * via the API. - * * The instance can be deleted. - * * All other attempts to modify the instance are rejected. - * - * Upon completion of the returned operation: - * - * * Billing for all successfully-allocated resources begins (some types - * may have lower than the requested levels). - * * Databases can be created in the instance. - * * The instance's allocated resource levels are readable via the API. - * * The instance's state becomes `READY`. - * - * The returned [long-running operation][google.longrunning.Operation] will - * have a name of the format `/operations/` and - * can be used to track creation of the instance. The - * [metadata][google.longrunning.Operation.metadata] field type is - * [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. - * The [response][google.longrunning.Operation.response] field type is - * [Instance][google.spanner.admin.instance.v1.Instance], if successful. - * - * The async variant is {@see self::createInstanceAsync()} . - * - * @param CreateInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createInstance(CreateInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateInstance', $request, $callOptions)->wait(); - } - - /** - * Creates an instance config and begins preparing it to be used. The - * returned [long-running operation][google.longrunning.Operation] - * can be used to track the progress of preparing the new - * instance config. The instance config name is assigned by the caller. If the - * named instance config already exists, `CreateInstanceConfig` returns - * `ALREADY_EXISTS`. - * - * Immediately after the request returns: - * - * * The instance config is readable via the API, with all requested - * attributes. The instance config's - * [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] - * field is set to true. Its state is `CREATING`. - * - * While the operation is pending: - * - * * Cancelling the operation renders the instance config immediately - * unreadable via the API. - * * Except for deleting the creating resource, all other attempts to modify - * the instance config are rejected. - * - * Upon completion of the returned operation: - * - * * Instances can be created using the instance configuration. - * * The instance config's - * [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] - * field becomes false. Its state becomes `READY`. - * - * The returned [long-running operation][google.longrunning.Operation] will - * have a name of the format - * `/operations/` and can be used to track - * creation of the instance config. The - * [metadata][google.longrunning.Operation.metadata] field type is - * [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata]. - * The [response][google.longrunning.Operation.response] field type is - * [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig], if - * successful. - * - * Authorization requires `spanner.instanceConfigs.create` permission on - * the resource - * [parent][google.spanner.admin.instance.v1.CreateInstanceConfigRequest.parent]. - * - * The async variant is {@see self::createInstanceConfigAsync()} . - * - * @param CreateInstanceConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createInstanceConfig(CreateInstanceConfigRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateInstanceConfig', $request, $callOptions)->wait(); - } - - /** - * Deletes an instance. - * - * Immediately upon completion of the request: - * - * * Billing ceases for all of the instance's reserved resources. - * - * Soon afterward: - * - * * The instance and *all of its databases* immediately and - * irrevocably disappear from the API. All data in the databases - * is permanently deleted. - * - * The async variant is {@see self::deleteInstanceAsync()} . - * - * @param DeleteInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); - } - - /** - * Deletes the instance config. Deletion is only allowed when no - * instances are using the configuration. If any instances are using - * the config, returns `FAILED_PRECONDITION`. - * - * Only user managed configurations can be deleted. - * - * Authorization requires `spanner.instanceConfigs.delete` permission on - * the resource [name][google.spanner.admin.instance.v1.InstanceConfig.name]. - * - * The async variant is {@see self::deleteInstanceConfigAsync()} . - * - * @param DeleteInstanceConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteInstanceConfig(DeleteInstanceConfigRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteInstanceConfig', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for an instance resource. Returns an empty - * policy if an instance exists but does not have a policy set. - * - * Authorization requires `spanner.instances.getIamPolicy` on - * [resource][google.iam.v1.GetIamPolicyRequest.resource]. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets information about a particular instance. - * - * The async variant is {@see self::getInstanceAsync()} . - * - * @param GetInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Instance - * - * @throws ApiException Thrown if the API call fails. - */ - public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance - { - return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); - } - - /** - * Gets information about a particular instance configuration. - * - * The async variant is {@see self::getInstanceConfigAsync()} . - * - * @param GetInstanceConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InstanceConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getInstanceConfig(GetInstanceConfigRequest $request, array $callOptions = []): InstanceConfig - { - return $this->startApiCall('GetInstanceConfig', $request, $callOptions)->wait(); - } - - /** - * Lists the user-managed instance config [long-running - * operations][google.longrunning.Operation] in the given project. An instance - * config operation has a name of the form - * `projects//instanceConfigs//operations/`. - * The long-running operation - * [metadata][google.longrunning.Operation.metadata] field type - * `metadata.type_url` describes the type of the metadata. Operations returned - * include those that have completed/failed/canceled within the last 7 days, - * and pending operations. Operations returned are ordered by - * `operation.metadata.value.start_time` in descending order starting - * from the most recently started operation. - * - * The async variant is {@see self::listInstanceConfigOperationsAsync()} . - * - * @param ListInstanceConfigOperationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listInstanceConfigOperations(ListInstanceConfigOperationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListInstanceConfigOperations', $request, $callOptions); - } - - /** - * Lists the supported instance configurations for a given project. - * - * The async variant is {@see self::listInstanceConfigsAsync()} . - * - * @param ListInstanceConfigsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listInstanceConfigs(ListInstanceConfigsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListInstanceConfigs', $request, $callOptions); - } - - /** - * Lists all instances in the given project. - * - * The async variant is {@see self::listInstancesAsync()} . - * - * @param ListInstancesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listInstances(ListInstancesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListInstances', $request, $callOptions); - } - - /** - * Sets the access control policy on an instance resource. Replaces any - * existing policy. - * - * Authorization requires `spanner.instances.setIamPolicy` on - * [resource][google.iam.v1.SetIamPolicyRequest.resource]. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that the caller has on the specified instance resource. - * - * Attempting this RPC on a non-existent Cloud Spanner instance resource will - * result in a NOT_FOUND error if the user has `spanner.instances.list` - * permission on the containing Google Cloud Project. Otherwise returns an - * empty set of permissions. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Updates an instance, and begins allocating or releasing resources - * as requested. The returned [long-running - * operation][google.longrunning.Operation] can be used to track the - * progress of updating the instance. If the named instance does not - * exist, returns `NOT_FOUND`. - * - * Immediately upon completion of this request: - * - * * For resource types for which a decrease in the instance's allocation - * has been requested, billing is based on the newly-requested level. - * - * Until completion of the returned operation: - * - * * Cancelling the operation sets its metadata's - * [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], - * and begins restoring resources to their pre-request values. The - * operation is guaranteed to succeed at undoing all resource changes, - * after which point it terminates with a `CANCELLED` status. - * * All other attempts to modify the instance are rejected. - * * Reading the instance via the API continues to give the pre-request - * resource levels. - * - * Upon completion of the returned operation: - * - * * Billing begins for all successfully-allocated resources (some types - * may have lower than the requested levels). - * * All newly-reserved resources are available for serving the instance's - * tables. - * * The instance's new resource levels are readable via the API. - * - * The returned [long-running operation][google.longrunning.Operation] will - * have a name of the format `/operations/` and - * can be used to track the instance modification. The - * [metadata][google.longrunning.Operation.metadata] field type is - * [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata]. - * The [response][google.longrunning.Operation.response] field type is - * [Instance][google.spanner.admin.instance.v1.Instance], if successful. - * - * Authorization requires `spanner.instances.update` permission on - * the resource [name][google.spanner.admin.instance.v1.Instance.name]. - * - * The async variant is {@see self::updateInstanceAsync()} . - * - * @param UpdateInstanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateInstance(UpdateInstanceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateInstance', $request, $callOptions)->wait(); - } - - /** - * Updates an instance config. The returned - * [long-running operation][google.longrunning.Operation] can be used to track - * the progress of updating the instance. If the named instance config does - * not exist, returns `NOT_FOUND`. - * - * Only user managed configurations can be updated. - * - * Immediately after the request returns: - * - * * The instance config's - * [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] - * field is set to true. - * - * While the operation is pending: - * - * * Cancelling the operation sets its metadata's - * [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata.cancel_time]. - * The operation is guaranteed to succeed at undoing all changes, after - * which point it terminates with a `CANCELLED` status. - * * All other attempts to modify the instance config are rejected. - * * Reading the instance config via the API continues to give the - * pre-request values. - * - * Upon completion of the returned operation: - * - * * Creating instances using the instance configuration uses the new - * values. - * * The instance config's new values are readable via the API. - * * The instance config's - * [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] - * field becomes false. - * - * The returned [long-running operation][google.longrunning.Operation] will - * have a name of the format - * `/operations/` and can be used to track - * the instance config modification. The - * [metadata][google.longrunning.Operation.metadata] field type is - * [UpdateInstanceConfigMetadata][google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata]. - * The [response][google.longrunning.Operation.response] field type is - * [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig], if - * successful. - * - * Authorization requires `spanner.instanceConfigs.update` permission on - * the resource [name][google.spanner.admin.instance.v1.InstanceConfig.name]. - * - * The async variant is {@see self::updateInstanceConfigAsync()} . - * - * @param UpdateInstanceConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateInstanceConfig(UpdateInstanceConfigRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateInstanceConfig', $request, $callOptions)->wait(); - } -} diff --git a/Spanner/src/Admin/Instance/V1/Client/InstanceAdminClient.php b/Spanner/src/Admin/Instance/V1/Client/InstanceAdminClient.php index 5d048e625ba3..f7db87ad1256 100644 --- a/Spanner/src/Admin/Instance/V1/Client/InstanceAdminClient.php +++ b/Spanner/src/Admin/Instance/V1/Client/InstanceAdminClient.php @@ -24,17 +24,839 @@ namespace Google\Cloud\Spanner\Admin\Instance\V1\Client; -use Google\Cloud\Spanner\Admin\Instance\V1\Client\BaseClient\InstanceAdminBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Spanner\Admin\Instance\V1\CreateInstanceConfigMetadata; +use Google\Cloud\Spanner\Admin\Instance\V1\CreateInstanceConfigRequest; +use Google\Cloud\Spanner\Admin\Instance\V1\CreateInstanceMetadata; +use Google\Cloud\Spanner\Admin\Instance\V1\CreateInstanceRequest; +use Google\Cloud\Spanner\Admin\Instance\V1\DeleteInstanceConfigRequest; +use Google\Cloud\Spanner\Admin\Instance\V1\DeleteInstanceRequest; +use Google\Cloud\Spanner\Admin\Instance\V1\GetInstanceConfigRequest; +use Google\Cloud\Spanner\Admin\Instance\V1\GetInstanceRequest; +use Google\Cloud\Spanner\Admin\Instance\V1\Instance; +use Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig; +use Google\Cloud\Spanner\Admin\Instance\V1\ListInstanceConfigOperationsRequest; +use Google\Cloud\Spanner\Admin\Instance\V1\ListInstanceConfigsRequest; +use Google\Cloud\Spanner\Admin\Instance\V1\ListInstancesRequest; +use Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstanceConfigMetadata; +use Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstanceConfigRequest; +use Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstanceMetadata; +use Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstanceRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Cloud Spanner Instance Admin API * - * This class is currently experimental and may be subject to changes. + * The Cloud Spanner Instance Admin API can be used to create, delete, + * modify and list instances. Instances are dedicated Cloud Spanner serving + * and storage resources to be used by Cloud Spanner databases. + * + * Each instance has a "configuration", which dictates where the + * serving resources for the Cloud Spanner instance are located (e.g., + * US-central, Europe). Configurations are created by Google based on + * resource availability. + * + * Cloud Spanner billing is based on the instances that exist and their + * sizes. After an instance exists, there are no additional + * per-database or per-operation charges for use of the instance + * (though there may be additional network bandwidth charges). + * Instances offer isolation: problems with databases in one instance + * will not affect other instances. However, within an instance + * databases can affect each other. For example, if one database in an + * instance receives a lot of requests and consumes most of the + * instance resources, fewer resources are available for other + * databases in that instance, and their performance may suffer. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Spanner\Admin\Instance\V1\InstanceAdminClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createInstanceAsync(CreateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface createInstanceConfigAsync(CreateInstanceConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteInstanceAsync(DeleteInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteInstanceConfigAsync(DeleteInstanceConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInstanceAsync(GetInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInstanceConfigAsync(GetInstanceConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInstanceConfigOperationsAsync(ListInstanceConfigOperationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInstanceConfigsAsync(ListInstanceConfigsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInstancesAsync(ListInstancesRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateInstanceAsync(UpdateInstanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateInstanceConfigAsync(UpdateInstanceConfigRequest $request, array $optionalArgs = []) */ -final class InstanceAdminClient extends InstanceAdminBaseClient +final class InstanceAdminClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see InstanceAdminBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.spanner.admin.instance.v1.InstanceAdmin'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'spanner.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/spanner.admin', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/instance_admin_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/instance_admin_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/instance_admin_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/instance_admin_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a instance + * resource. + * + * @param string $project + * @param string $instance + * + * @return string The formatted instance resource. + */ + public static function instanceName(string $project, string $instance): string + { + return self::getPathTemplate('instance')->render([ + 'project' => $project, + 'instance' => $instance, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * instance_config resource. + * + * @param string $project + * @param string $instanceConfig + * + * @return string The formatted instance_config resource. + */ + public static function instanceConfigName(string $project, string $instanceConfig): string + { + return self::getPathTemplate('instanceConfig')->render([ + 'project' => $project, + 'instance_config' => $instanceConfig, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->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 + * - instance: projects/{project}/instances/{instance} + * - instanceConfig: projects/{project}/instanceConfigs/{instance_config} + * - 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. + */ + public static function parseName(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'spanner.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates an instance and begins preparing it to begin serving. The + * returned [long-running operation][google.longrunning.Operation] + * can be used to track the progress of preparing the new + * instance. The instance name is assigned by the caller. If the + * named instance already exists, `CreateInstance` returns + * `ALREADY_EXISTS`. + * + * Immediately upon completion of this request: + * + * * The instance is readable via the API, with all requested attributes + * but no allocated resources. Its state is `CREATING`. + * + * Until completion of the returned operation: + * + * * Cancelling the operation renders the instance immediately unreadable + * via the API. + * * The instance can be deleted. + * * All other attempts to modify the instance are rejected. + * + * Upon completion of the returned operation: + * + * * Billing for all successfully-allocated resources begins (some types + * may have lower than the requested levels). + * * Databases can be created in the instance. + * * The instance's allocated resource levels are readable via the API. + * * The instance's state becomes `READY`. + * + * The returned [long-running operation][google.longrunning.Operation] will + * have a name of the format `/operations/` and + * can be used to track creation of the instance. The + * [metadata][google.longrunning.Operation.metadata] field type is + * [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. + * The [response][google.longrunning.Operation.response] field type is + * [Instance][google.spanner.admin.instance.v1.Instance], if successful. + * + * The async variant is {@see InstanceAdminClient::createInstanceAsync()} . + * + * @param CreateInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createInstance(CreateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateInstance', $request, $callOptions)->wait(); + } + + /** + * Creates an instance config and begins preparing it to be used. The + * returned [long-running operation][google.longrunning.Operation] + * can be used to track the progress of preparing the new + * instance config. The instance config name is assigned by the caller. If the + * named instance config already exists, `CreateInstanceConfig` returns + * `ALREADY_EXISTS`. + * + * Immediately after the request returns: + * + * * The instance config is readable via the API, with all requested + * attributes. The instance config's + * [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] + * field is set to true. Its state is `CREATING`. + * + * While the operation is pending: + * + * * Cancelling the operation renders the instance config immediately + * unreadable via the API. + * * Except for deleting the creating resource, all other attempts to modify + * the instance config are rejected. + * + * Upon completion of the returned operation: + * + * * Instances can be created using the instance configuration. + * * The instance config's + * [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] + * field becomes false. Its state becomes `READY`. + * + * The returned [long-running operation][google.longrunning.Operation] will + * have a name of the format + * `/operations/` and can be used to track + * creation of the instance config. The + * [metadata][google.longrunning.Operation.metadata] field type is + * [CreateInstanceConfigMetadata][google.spanner.admin.instance.v1.CreateInstanceConfigMetadata]. + * The [response][google.longrunning.Operation.response] field type is + * [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig], if + * successful. + * + * Authorization requires `spanner.instanceConfigs.create` permission on + * the resource + * [parent][google.spanner.admin.instance.v1.CreateInstanceConfigRequest.parent]. + * + * The async variant is {@see InstanceAdminClient::createInstanceConfigAsync()} . + * + * @param CreateInstanceConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createInstanceConfig(CreateInstanceConfigRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateInstanceConfig', $request, $callOptions)->wait(); + } + + /** + * Deletes an instance. + * + * Immediately upon completion of the request: + * + * * Billing ceases for all of the instance's reserved resources. + * + * Soon afterward: + * + * * The instance and *all of its databases* immediately and + * irrevocably disappear from the API. All data in the databases + * is permanently deleted. + * + * The async variant is {@see InstanceAdminClient::deleteInstanceAsync()} . + * + * @param DeleteInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteInstance(DeleteInstanceRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteInstance', $request, $callOptions)->wait(); + } + + /** + * Deletes the instance config. Deletion is only allowed when no + * instances are using the configuration. If any instances are using + * the config, returns `FAILED_PRECONDITION`. + * + * Only user managed configurations can be deleted. + * + * Authorization requires `spanner.instanceConfigs.delete` permission on + * the resource [name][google.spanner.admin.instance.v1.InstanceConfig.name]. + * + * The async variant is {@see InstanceAdminClient::deleteInstanceConfigAsync()} . + * + * @param DeleteInstanceConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteInstanceConfig(DeleteInstanceConfigRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteInstanceConfig', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for an instance resource. Returns an empty + * policy if an instance exists but does not have a policy set. + * + * Authorization requires `spanner.instances.getIamPolicy` on + * [resource][google.iam.v1.GetIamPolicyRequest.resource]. + * + * The async variant is {@see InstanceAdminClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets information about a particular instance. + * + * The async variant is {@see InstanceAdminClient::getInstanceAsync()} . + * + * @param GetInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Instance + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInstance(GetInstanceRequest $request, array $callOptions = []): Instance + { + return $this->startApiCall('GetInstance', $request, $callOptions)->wait(); + } + + /** + * Gets information about a particular instance configuration. + * + * The async variant is {@see InstanceAdminClient::getInstanceConfigAsync()} . + * + * @param GetInstanceConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InstanceConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInstanceConfig(GetInstanceConfigRequest $request, array $callOptions = []): InstanceConfig + { + return $this->startApiCall('GetInstanceConfig', $request, $callOptions)->wait(); + } + + /** + * Lists the user-managed instance config [long-running + * operations][google.longrunning.Operation] in the given project. An instance + * config operation has a name of the form + * `projects//instanceConfigs//operations/`. + * The long-running operation + * [metadata][google.longrunning.Operation.metadata] field type + * `metadata.type_url` describes the type of the metadata. Operations returned + * include those that have completed/failed/canceled within the last 7 days, + * and pending operations. Operations returned are ordered by + * `operation.metadata.value.start_time` in descending order starting + * from the most recently started operation. + * + * The async variant is + * {@see InstanceAdminClient::listInstanceConfigOperationsAsync()} . + * + * @param ListInstanceConfigOperationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInstanceConfigOperations(ListInstanceConfigOperationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInstanceConfigOperations', $request, $callOptions); + } + + /** + * Lists the supported instance configurations for a given project. + * + * The async variant is {@see InstanceAdminClient::listInstanceConfigsAsync()} . + * + * @param ListInstanceConfigsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInstanceConfigs(ListInstanceConfigsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInstanceConfigs', $request, $callOptions); + } + + /** + * Lists all instances in the given project. + * + * The async variant is {@see InstanceAdminClient::listInstancesAsync()} . + * + * @param ListInstancesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInstances(ListInstancesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInstances', $request, $callOptions); + } + + /** + * Sets the access control policy on an instance resource. Replaces any + * existing policy. + * + * Authorization requires `spanner.instances.setIamPolicy` on + * [resource][google.iam.v1.SetIamPolicyRequest.resource]. + * + * The async variant is {@see InstanceAdminClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that the caller has on the specified instance resource. + * + * Attempting this RPC on a non-existent Cloud Spanner instance resource will + * result in a NOT_FOUND error if the user has `spanner.instances.list` + * permission on the containing Google Cloud Project. Otherwise returns an + * empty set of permissions. + * + * The async variant is {@see InstanceAdminClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates an instance, and begins allocating or releasing resources + * as requested. The returned [long-running + * operation][google.longrunning.Operation] can be used to track the + * progress of updating the instance. If the named instance does not + * exist, returns `NOT_FOUND`. + * + * Immediately upon completion of this request: + * + * * For resource types for which a decrease in the instance's allocation + * has been requested, billing is based on the newly-requested level. + * + * Until completion of the returned operation: + * + * * Cancelling the operation sets its metadata's + * [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], + * and begins restoring resources to their pre-request values. The + * operation is guaranteed to succeed at undoing all resource changes, + * after which point it terminates with a `CANCELLED` status. + * * All other attempts to modify the instance are rejected. + * * Reading the instance via the API continues to give the pre-request + * resource levels. + * + * Upon completion of the returned operation: + * + * * Billing begins for all successfully-allocated resources (some types + * may have lower than the requested levels). + * * All newly-reserved resources are available for serving the instance's + * tables. + * * The instance's new resource levels are readable via the API. + * + * The returned [long-running operation][google.longrunning.Operation] will + * have a name of the format `/operations/` and + * can be used to track the instance modification. The + * [metadata][google.longrunning.Operation.metadata] field type is + * [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata]. + * The [response][google.longrunning.Operation.response] field type is + * [Instance][google.spanner.admin.instance.v1.Instance], if successful. + * + * Authorization requires `spanner.instances.update` permission on + * the resource [name][google.spanner.admin.instance.v1.Instance.name]. + * + * The async variant is {@see InstanceAdminClient::updateInstanceAsync()} . + * + * @param UpdateInstanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateInstance(UpdateInstanceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateInstance', $request, $callOptions)->wait(); + } + + /** + * Updates an instance config. The returned + * [long-running operation][google.longrunning.Operation] can be used to track + * the progress of updating the instance. If the named instance config does + * not exist, returns `NOT_FOUND`. + * + * Only user managed configurations can be updated. + * + * Immediately after the request returns: + * + * * The instance config's + * [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] + * field is set to true. + * + * While the operation is pending: + * + * * Cancelling the operation sets its metadata's + * [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata.cancel_time]. + * The operation is guaranteed to succeed at undoing all changes, after + * which point it terminates with a `CANCELLED` status. + * * All other attempts to modify the instance config are rejected. + * * Reading the instance config via the API continues to give the + * pre-request values. + * + * Upon completion of the returned operation: + * + * * Creating instances using the instance configuration uses the new + * values. + * * The instance config's new values are readable via the API. + * * The instance config's + * [reconciling][google.spanner.admin.instance.v1.InstanceConfig.reconciling] + * field becomes false. + * + * The returned [long-running operation][google.longrunning.Operation] will + * have a name of the format + * `/operations/` and can be used to track + * the instance config modification. The + * [metadata][google.longrunning.Operation.metadata] field type is + * [UpdateInstanceConfigMetadata][google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata]. + * The [response][google.longrunning.Operation.response] field type is + * [InstanceConfig][google.spanner.admin.instance.v1.InstanceConfig], if + * successful. + * + * Authorization requires `spanner.instanceConfigs.update` permission on + * the resource [name][google.spanner.admin.instance.v1.InstanceConfig.name]. + * + * The async variant is {@see InstanceAdminClient::updateInstanceConfigAsync()} . + * + * @param UpdateInstanceConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateInstanceConfig(UpdateInstanceConfigRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateInstanceConfig', $request, $callOptions)->wait(); + } } diff --git a/Spanner/src/Admin/Instance/V1/Instance.php b/Spanner/src/Admin/Instance/V1/Instance.php index 3fbd6e13687f..8e4c75155862 100644 --- a/Spanner/src/Admin/Instance/V1/Instance.php +++ b/Spanner/src/Admin/Instance/V1/Instance.php @@ -42,8 +42,10 @@ class Instance extends \Google\Protobuf\Internal\Message private $display_name = ''; /** * The number of nodes allocated to this instance. At most one of either - * node_count or processing_units should be present in the message. This - * may be zero in API responses for instances that are not yet in state + * node_count or processing_units should be present in the message. + * Users can set the node_count field to specify the target number of nodes + * allocated to the instance. + * This may be zero in API responses for instances that are not yet in state * `READY`. * See [the * documentation](https://cloud.google.com/spanner/docs/compute-capacity) @@ -54,8 +56,11 @@ class Instance extends \Google\Protobuf\Internal\Message private $node_count = 0; /** * The number of processing units allocated to this instance. At most one of - * processing_units or node_count should be present in the message. This may - * be zero in API responses for instances that are not yet in state `READY`. + * processing_units or node_count should be present in the message. + * Users can set the processing_units field to specify the target number of + * processing units allocated to the instance. + * This may be zero in API responses for instances that are not yet in state + * `READY`. * See [the * documentation](https://cloud.google.com/spanner/docs/compute-capacity) * for more information about nodes and processing units. @@ -63,6 +68,15 @@ class Instance extends \Google\Protobuf\Internal\Message * Generated from protobuf field int32 processing_units = 9; */ private $processing_units = 0; + /** + * Optional. The autoscaling configuration. Autoscaling is enabled if this + * field is set. When autoscaling is enabled, node_count and processing_units + * are treated as OUTPUT_ONLY fields and reflect the current compute capacity + * allocated to the instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig autoscaling_config = 17 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $autoscaling_config = null; /** * Output only. The current instance state. For * [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance], @@ -136,19 +150,29 @@ class Instance extends \Google\Protobuf\Internal\Message * Must be unique per project and between 4 and 30 characters in length. * @type int $node_count * The number of nodes allocated to this instance. At most one of either - * node_count or processing_units should be present in the message. This - * may be zero in API responses for instances that are not yet in state + * node_count or processing_units should be present in the message. + * Users can set the node_count field to specify the target number of nodes + * allocated to the instance. + * This may be zero in API responses for instances that are not yet in state * `READY`. * See [the * documentation](https://cloud.google.com/spanner/docs/compute-capacity) * for more information about nodes and processing units. * @type int $processing_units * The number of processing units allocated to this instance. At most one of - * processing_units or node_count should be present in the message. This may - * be zero in API responses for instances that are not yet in state `READY`. + * processing_units or node_count should be present in the message. + * Users can set the processing_units field to specify the target number of + * processing units allocated to the instance. + * This may be zero in API responses for instances that are not yet in state + * `READY`. * See [the * documentation](https://cloud.google.com/spanner/docs/compute-capacity) * for more information about nodes and processing units. + * @type \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig $autoscaling_config + * Optional. The autoscaling configuration. Autoscaling is enabled if this + * field is set. When autoscaling is enabled, node_count and processing_units + * are treated as OUTPUT_ONLY fields and reflect the current compute capacity + * allocated to the instance. * @type int $state * Output only. The current instance state. For * [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance], @@ -281,8 +305,10 @@ public function setDisplayName($var) /** * The number of nodes allocated to this instance. At most one of either - * node_count or processing_units should be present in the message. This - * may be zero in API responses for instances that are not yet in state + * node_count or processing_units should be present in the message. + * Users can set the node_count field to specify the target number of nodes + * allocated to the instance. + * This may be zero in API responses for instances that are not yet in state * `READY`. * See [the * documentation](https://cloud.google.com/spanner/docs/compute-capacity) @@ -298,8 +324,10 @@ public function getNodeCount() /** * The number of nodes allocated to this instance. At most one of either - * node_count or processing_units should be present in the message. This - * may be zero in API responses for instances that are not yet in state + * node_count or processing_units should be present in the message. + * Users can set the node_count field to specify the target number of nodes + * allocated to the instance. + * This may be zero in API responses for instances that are not yet in state * `READY`. * See [the * documentation](https://cloud.google.com/spanner/docs/compute-capacity) @@ -319,8 +347,11 @@ public function setNodeCount($var) /** * The number of processing units allocated to this instance. At most one of - * processing_units or node_count should be present in the message. This may - * be zero in API responses for instances that are not yet in state `READY`. + * processing_units or node_count should be present in the message. + * Users can set the processing_units field to specify the target number of + * processing units allocated to the instance. + * This may be zero in API responses for instances that are not yet in state + * `READY`. * See [the * documentation](https://cloud.google.com/spanner/docs/compute-capacity) * for more information about nodes and processing units. @@ -335,8 +366,11 @@ public function getProcessingUnits() /** * The number of processing units allocated to this instance. At most one of - * processing_units or node_count should be present in the message. This may - * be zero in API responses for instances that are not yet in state `READY`. + * processing_units or node_count should be present in the message. + * Users can set the processing_units field to specify the target number of + * processing units allocated to the instance. + * This may be zero in API responses for instances that are not yet in state + * `READY`. * See [the * documentation](https://cloud.google.com/spanner/docs/compute-capacity) * for more information about nodes and processing units. @@ -353,6 +387,48 @@ public function setProcessingUnits($var) return $this; } + /** + * Optional. The autoscaling configuration. Autoscaling is enabled if this + * field is set. When autoscaling is enabled, node_count and processing_units + * are treated as OUTPUT_ONLY fields and reflect the current compute capacity + * allocated to the instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig autoscaling_config = 17 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig|null + */ + public function getAutoscalingConfig() + { + return $this->autoscaling_config; + } + + public function hasAutoscalingConfig() + { + return isset($this->autoscaling_config); + } + + public function clearAutoscalingConfig() + { + unset($this->autoscaling_config); + } + + /** + * Optional. The autoscaling configuration. Autoscaling is enabled if this + * field is set. When autoscaling is enabled, node_count and processing_units + * are treated as OUTPUT_ONLY fields and reflect the current compute capacity + * allocated to the instance. + * + * Generated from protobuf field .google.spanner.admin.instance.v1.AutoscalingConfig autoscaling_config = 17 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig $var + * @return $this + */ + public function setAutoscalingConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Spanner\Admin\Instance\V1\AutoscalingConfig::class); + $this->autoscaling_config = $var; + + return $this; + } + /** * Output only. The current instance state. For * [CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance], diff --git a/Spanner/src/V1/Client/BaseClient/SpannerBaseClient.php b/Spanner/src/V1/Client/BaseClient/SpannerBaseClient.php deleted file mode 100644 index 870c80838e30..000000000000 --- a/Spanner/src/V1/Client/BaseClient/SpannerBaseClient.php +++ /dev/null @@ -1,766 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/spanner_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/spanner_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/spanner_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/spanner_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a database - * resource. - * - * @param string $project - * @param string $instance - * @param string $database - * - * @return string The formatted database resource. - */ - public static function databaseName(string $project, string $instance, string $database): string - { - return self::getPathTemplate('database')->render([ - 'project' => $project, - 'instance' => $instance, - 'database' => $database, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a session - * resource. - * - * @param string $project - * @param string $instance - * @param string $database - * @param string $session - * - * @return string The formatted session resource. - */ - public static function sessionName(string $project, string $instance, string $database, string $session): string - { - return self::getPathTemplate('session')->render([ - 'project' => $project, - 'instance' => $instance, - 'database' => $database, - 'session' => $session, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - database: projects/{project}/instances/{instance}/databases/{database} - * - session: projects/{project}/instances/{instance}/databases/{database}/sessions/{session} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'spanner.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates multiple new sessions. - * - * This API can be used to initialize a session cache on the clients. - * See https://goo.gl/TgSFN2 for best practices on session cache management. - * - * The async variant is {@see self::batchCreateSessionsAsync()} . - * - * @param BatchCreateSessionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BatchCreateSessionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchCreateSessions(BatchCreateSessionsRequest $request, array $callOptions = []): BatchCreateSessionsResponse - { - return $this->startApiCall('BatchCreateSessions', $request, $callOptions)->wait(); - } - - /** - * Batches the supplied mutation groups in a collection of efficient - * transactions. All mutations in a group are committed atomically. However, - * mutations across groups can be committed non-atomically in an unspecified - * order and thus, they must be independent of each other. Partial failure is - * possible, i.e., some groups may have been committed successfully, while - * some may have failed. The results of individual batches are streamed into - * the response as the batches are applied. - * - * BatchWrite requests are not replay protected, meaning that each mutation - * group may be applied more than once. Replays of non-idempotent mutations - * may have undesirable effects. For example, replays of an insert mutation - * may produce an already exists error or if you use generated or commit - * timestamp-based keys, it may result in additional rows being added to the - * mutation's table. We recommend structuring your mutation groups to be - * idempotent to avoid this issue. - * - * @param BatchWriteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return ServerStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchWrite(BatchWriteRequest $request, array $callOptions = []): ServerStream - { - return $this->startApiCall('BatchWrite', $request, $callOptions); - } - - /** - * Begins a new transaction. This step can often be skipped: - * [Read][google.spanner.v1.Spanner.Read], [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and - * [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a - * side-effect. - * - * The async variant is {@see self::beginTransactionAsync()} . - * - * @param BeginTransactionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Transaction - * - * @throws ApiException Thrown if the API call fails. - */ - public function beginTransaction(BeginTransactionRequest $request, array $callOptions = []): Transaction - { - return $this->startApiCall('BeginTransaction', $request, $callOptions)->wait(); - } - - /** - * Commits a transaction. The request includes the mutations to be - * applied to rows in the database. - * - * `Commit` might return an `ABORTED` error. This can occur at any time; - * commonly, the cause is conflicts with concurrent - * transactions. However, it can also happen for a variety of other - * reasons. If `Commit` returns `ABORTED`, the caller should re-attempt - * the transaction from the beginning, re-using the same session. - * - * On very rare occasions, `Commit` might return `UNKNOWN`. This can happen, - * for example, if the client job experiences a 1+ hour networking failure. - * At that point, Cloud Spanner has lost track of the transaction outcome and - * we recommend that you perform another read from the database to see the - * state of things as they are now. - * - * The async variant is {@see self::commitAsync()} . - * - * @param CommitRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CommitResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function commit(CommitRequest $request, array $callOptions = []): CommitResponse - { - return $this->startApiCall('Commit', $request, $callOptions)->wait(); - } - - /** - * Creates a new session. A session can be used to perform - * transactions that read and/or modify data in a Cloud Spanner database. - * Sessions are meant to be reused for many consecutive - * transactions. - * - * Sessions can only execute one transaction at a time. To execute - * multiple concurrent read-write/write-only transactions, create - * multiple sessions. Note that standalone reads and queries use a - * transaction internally, and count toward the one transaction - * limit. - * - * Active sessions use additional server resources, so it is a good idea to - * delete idle and unneeded sessions. - * Aside from explicit deletes, Cloud Spanner may delete sessions for which no - * operations are sent for more than an hour. If a session is deleted, - * requests to it return `NOT_FOUND`. - * - * Idle sessions can be kept alive by sending a trivial SQL query - * periodically, e.g., `"SELECT 1"`. - * - * The async variant is {@see self::createSessionAsync()} . - * - * @param CreateSessionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Session - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSession(CreateSessionRequest $request, array $callOptions = []): Session - { - return $this->startApiCall('CreateSession', $request, $callOptions)->wait(); - } - - /** - * Ends a session, releasing server resources associated with it. This will - * asynchronously trigger cancellation of any operations that are running with - * this session. - * - * The async variant is {@see self::deleteSessionAsync()} . - * - * @param DeleteSessionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSession(DeleteSessionRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteSession', $request, $callOptions)->wait(); - } - - /** - * Executes a batch of SQL DML statements. This method allows many statements - * to be run with lower latency than submitting them sequentially with - * [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql]. - * - * Statements are executed in sequential order. A request can succeed even if - * a statement fails. The [ExecuteBatchDmlResponse.status][google.spanner.v1.ExecuteBatchDmlResponse.status] field in the - * response provides information about the statement that failed. Clients must - * inspect this field to determine whether an error occurred. - * - * Execution stops after the first failed statement; the remaining statements - * are not executed. - * - * The async variant is {@see self::executeBatchDmlAsync()} . - * - * @param ExecuteBatchDmlRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ExecuteBatchDmlResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function executeBatchDml(ExecuteBatchDmlRequest $request, array $callOptions = []): ExecuteBatchDmlResponse - { - return $this->startApiCall('ExecuteBatchDml', $request, $callOptions)->wait(); - } - - /** - * Executes an SQL statement, returning all results in a single reply. This - * method cannot be used to return a result set larger than 10 MiB; - * if the query yields more data than that, the query fails with - * a `FAILED_PRECONDITION` error. - * - * Operations inside read-write transactions might return `ABORTED`. If - * this occurs, the application should restart the transaction from - * the beginning. See [Transaction][google.spanner.v1.Transaction] for more details. - * - * Larger result sets can be fetched in streaming fashion by calling - * [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] instead. - * - * The async variant is {@see self::executeSqlAsync()} . - * - * @param ExecuteSqlRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ResultSet - * - * @throws ApiException Thrown if the API call fails. - */ - public function executeSql(ExecuteSqlRequest $request, array $callOptions = []): ResultSet - { - return $this->startApiCall('ExecuteSql', $request, $callOptions)->wait(); - } - - /** - * Like [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], except returns the result - * set as a stream. Unlike [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], there - * is no limit on the size of the returned result set. However, no - * individual row in the result set can exceed 100 MiB, and no - * column value can exceed 10 MiB. - * - * @param ExecuteSqlRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return ServerStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function executeStreamingSql(ExecuteSqlRequest $request, array $callOptions = []): ServerStream - { - return $this->startApiCall('ExecuteStreamingSql', $request, $callOptions); - } - - /** - * Gets a session. Returns `NOT_FOUND` if the session does not exist. - * This is mainly useful for determining whether a session is still - * alive. - * - * The async variant is {@see self::getSessionAsync()} . - * - * @param GetSessionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Session - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSession(GetSessionRequest $request, array $callOptions = []): Session - { - return $this->startApiCall('GetSession', $request, $callOptions)->wait(); - } - - /** - * Lists all sessions in a given database. - * - * The async variant is {@see self::listSessionsAsync()} . - * - * @param ListSessionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSessions(ListSessionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSessions', $request, $callOptions); - } - - /** - * Creates a set of partition tokens that can be used to execute a query - * operation in parallel. Each of the returned partition tokens can be used - * by [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] to specify a subset - * of the query result to read. The same session and read-only transaction - * must be used by the PartitionQueryRequest used to create the - * partition tokens and the ExecuteSqlRequests that use the partition tokens. - * - * Partition tokens become invalid when the session used to create them - * is deleted, is idle for too long, begins a new transaction, or becomes too - * old. When any of these happen, it is not possible to resume the query, and - * the whole operation must be restarted from the beginning. - * - * The async variant is {@see self::partitionQueryAsync()} . - * - * @param PartitionQueryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PartitionResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function partitionQuery(PartitionQueryRequest $request, array $callOptions = []): PartitionResponse - { - return $this->startApiCall('PartitionQuery', $request, $callOptions)->wait(); - } - - /** - * Creates a set of partition tokens that can be used to execute a read - * operation in parallel. Each of the returned partition tokens can be used - * by [StreamingRead][google.spanner.v1.Spanner.StreamingRead] to specify a subset of the read - * result to read. The same session and read-only transaction must be used by - * the PartitionReadRequest used to create the partition tokens and the - * ReadRequests that use the partition tokens. There are no ordering - * guarantees on rows returned among the returned partition tokens, or even - * within each individual StreamingRead call issued with a partition_token. - * - * Partition tokens become invalid when the session used to create them - * is deleted, is idle for too long, begins a new transaction, or becomes too - * old. When any of these happen, it is not possible to resume the read, and - * the whole operation must be restarted from the beginning. - * - * The async variant is {@see self::partitionReadAsync()} . - * - * @param PartitionReadRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PartitionResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function partitionRead(PartitionReadRequest $request, array $callOptions = []): PartitionResponse - { - return $this->startApiCall('PartitionRead', $request, $callOptions)->wait(); - } - - /** - * Reads rows from the database using key lookups and scans, as a - * simple key/value style alternative to - * [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql]. This method cannot be used to - * return a result set larger than 10 MiB; if the read matches more - * data than that, the read fails with a `FAILED_PRECONDITION` - * error. - * - * Reads inside read-write transactions might return `ABORTED`. If - * this occurs, the application should restart the transaction from - * the beginning. See [Transaction][google.spanner.v1.Transaction] for more details. - * - * Larger result sets can be yielded in streaming fashion by calling - * [StreamingRead][google.spanner.v1.Spanner.StreamingRead] instead. - * - * The async variant is {@see self::readAsync()} . - * - * @param ReadRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ResultSet - * - * @throws ApiException Thrown if the API call fails. - */ - public function read(ReadRequest $request, array $callOptions = []): ResultSet - { - return $this->startApiCall('Read', $request, $callOptions)->wait(); - } - - /** - * Rolls back a transaction, releasing any locks it holds. It is a good - * idea to call this for any transaction that includes one or more - * [Read][google.spanner.v1.Spanner.Read] or [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] requests and - * ultimately decides not to commit. - * - * `Rollback` returns `OK` if it successfully aborts the transaction, the - * transaction was already aborted, or the transaction is not - * found. `Rollback` never returns `ABORTED`. - * - * The async variant is {@see self::rollbackAsync()} . - * - * @param RollbackRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function rollback(RollbackRequest $request, array $callOptions = []): void - { - $this->startApiCall('Rollback', $request, $callOptions)->wait(); - } - - /** - * Like [Read][google.spanner.v1.Spanner.Read], except returns the result set as a - * stream. Unlike [Read][google.spanner.v1.Spanner.Read], there is no limit on the - * size of the returned result set. However, no individual row in - * the result set can exceed 100 MiB, and no column value can exceed - * 10 MiB. - * - * @param ReadRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return ServerStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function streamingRead(ReadRequest $request, array $callOptions = []): ServerStream - { - return $this->startApiCall('StreamingRead', $request, $callOptions); - } -} diff --git a/Spanner/src/V1/Client/SpannerClient.php b/Spanner/src/V1/Client/SpannerClient.php index 166574f052d2..865a26dd4d33 100644 --- a/Spanner/src/V1/Client/SpannerClient.php +++ b/Spanner/src/V1/Client/SpannerClient.php @@ -24,17 +24,741 @@ namespace Google\Cloud\Spanner\V1\Client; -use Google\Cloud\Spanner\V1\Client\BaseClient\SpannerBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\ServerStream; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Spanner\V1\BatchCreateSessionsRequest; +use Google\Cloud\Spanner\V1\BatchCreateSessionsResponse; +use Google\Cloud\Spanner\V1\BatchWriteRequest; +use Google\Cloud\Spanner\V1\BeginTransactionRequest; +use Google\Cloud\Spanner\V1\CommitRequest; +use Google\Cloud\Spanner\V1\CommitResponse; +use Google\Cloud\Spanner\V1\CreateSessionRequest; +use Google\Cloud\Spanner\V1\DeleteSessionRequest; +use Google\Cloud\Spanner\V1\ExecuteBatchDmlRequest; +use Google\Cloud\Spanner\V1\ExecuteBatchDmlRequest\Statement; +use Google\Cloud\Spanner\V1\ExecuteBatchDmlResponse; +use Google\Cloud\Spanner\V1\ExecuteSqlRequest; +use Google\Cloud\Spanner\V1\GetSessionRequest; +use Google\Cloud\Spanner\V1\ListSessionsRequest; +use Google\Cloud\Spanner\V1\Mutation; +use Google\Cloud\Spanner\V1\PartitionQueryRequest; +use Google\Cloud\Spanner\V1\PartitionReadRequest; +use Google\Cloud\Spanner\V1\PartitionResponse; +use Google\Cloud\Spanner\V1\ReadRequest; +use Google\Cloud\Spanner\V1\ResultSet; +use Google\Cloud\Spanner\V1\RollbackRequest; +use Google\Cloud\Spanner\V1\Session; +use Google\Cloud\Spanner\V1\Transaction; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Cloud Spanner API * - * This class is currently experimental and may be subject to changes. + * The Cloud Spanner API can be used to manage sessions and execute + * transactions on data stored in Cloud Spanner databases. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Spanner\V1\SpannerClient} for the stable implementation * * @experimental + * + * @method PromiseInterface batchCreateSessionsAsync(BatchCreateSessionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface beginTransactionAsync(BeginTransactionRequest $request, array $optionalArgs = []) + * @method PromiseInterface commitAsync(CommitRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSessionAsync(CreateSessionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSessionAsync(DeleteSessionRequest $request, array $optionalArgs = []) + * @method PromiseInterface executeBatchDmlAsync(ExecuteBatchDmlRequest $request, array $optionalArgs = []) + * @method PromiseInterface executeSqlAsync(ExecuteSqlRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSessionAsync(GetSessionRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSessionsAsync(ListSessionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface partitionQueryAsync(PartitionQueryRequest $request, array $optionalArgs = []) + * @method PromiseInterface partitionReadAsync(PartitionReadRequest $request, array $optionalArgs = []) + * @method PromiseInterface readAsync(ReadRequest $request, array $optionalArgs = []) + * @method PromiseInterface rollbackAsync(RollbackRequest $request, array $optionalArgs = []) */ -final class SpannerClient extends SpannerBaseClient +final class SpannerClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SpannerBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.spanner.v1.Spanner'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'spanner.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/spanner.data', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/spanner_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/spanner_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/spanner_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/spanner_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a database + * resource. + * + * @param string $project + * @param string $instance + * @param string $database + * + * @return string The formatted database resource. + */ + public static function databaseName(string $project, string $instance, string $database): string + { + return self::getPathTemplate('database')->render([ + 'project' => $project, + 'instance' => $instance, + 'database' => $database, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a session + * resource. + * + * @param string $project + * @param string $instance + * @param string $database + * @param string $session + * + * @return string The formatted session resource. + */ + public static function sessionName(string $project, string $instance, string $database, string $session): string + { + return self::getPathTemplate('session')->render([ + 'project' => $project, + 'instance' => $instance, + 'database' => $database, + 'session' => $session, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - database: projects/{project}/instances/{instance}/databases/{database} + * - session: projects/{project}/instances/{instance}/databases/{database}/sessions/{session} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'spanner.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates multiple new sessions. + * + * This API can be used to initialize a session cache on the clients. + * See https://goo.gl/TgSFN2 for best practices on session cache management. + * + * The async variant is {@see SpannerClient::batchCreateSessionsAsync()} . + * + * @param BatchCreateSessionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BatchCreateSessionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchCreateSessions(BatchCreateSessionsRequest $request, array $callOptions = []): BatchCreateSessionsResponse + { + return $this->startApiCall('BatchCreateSessions', $request, $callOptions)->wait(); + } + + /** + * Batches the supplied mutation groups in a collection of efficient + * transactions. All mutations in a group are committed atomically. However, + * mutations across groups can be committed non-atomically in an unspecified + * order and thus, they must be independent of each other. Partial failure is + * possible, i.e., some groups may have been committed successfully, while + * some may have failed. The results of individual batches are streamed into + * the response as the batches are applied. + * + * BatchWrite requests are not replay protected, meaning that each mutation + * group may be applied more than once. Replays of non-idempotent mutations + * may have undesirable effects. For example, replays of an insert mutation + * may produce an already exists error or if you use generated or commit + * timestamp-based keys, it may result in additional rows being added to the + * mutation's table. We recommend structuring your mutation groups to be + * idempotent to avoid this issue. + * + * @param BatchWriteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return ServerStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchWrite(BatchWriteRequest $request, array $callOptions = []): ServerStream + { + return $this->startApiCall('BatchWrite', $request, $callOptions); + } + + /** + * Begins a new transaction. This step can often be skipped: + * [Read][google.spanner.v1.Spanner.Read], [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and + * [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a + * side-effect. + * + * The async variant is {@see SpannerClient::beginTransactionAsync()} . + * + * @param BeginTransactionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Transaction + * + * @throws ApiException Thrown if the API call fails. + */ + public function beginTransaction(BeginTransactionRequest $request, array $callOptions = []): Transaction + { + return $this->startApiCall('BeginTransaction', $request, $callOptions)->wait(); + } + + /** + * Commits a transaction. The request includes the mutations to be + * applied to rows in the database. + * + * `Commit` might return an `ABORTED` error. This can occur at any time; + * commonly, the cause is conflicts with concurrent + * transactions. However, it can also happen for a variety of other + * reasons. If `Commit` returns `ABORTED`, the caller should re-attempt + * the transaction from the beginning, re-using the same session. + * + * On very rare occasions, `Commit` might return `UNKNOWN`. This can happen, + * for example, if the client job experiences a 1+ hour networking failure. + * At that point, Cloud Spanner has lost track of the transaction outcome and + * we recommend that you perform another read from the database to see the + * state of things as they are now. + * + * The async variant is {@see SpannerClient::commitAsync()} . + * + * @param CommitRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CommitResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function commit(CommitRequest $request, array $callOptions = []): CommitResponse + { + return $this->startApiCall('Commit', $request, $callOptions)->wait(); + } + + /** + * Creates a new session. A session can be used to perform + * transactions that read and/or modify data in a Cloud Spanner database. + * Sessions are meant to be reused for many consecutive + * transactions. + * + * Sessions can only execute one transaction at a time. To execute + * multiple concurrent read-write/write-only transactions, create + * multiple sessions. Note that standalone reads and queries use a + * transaction internally, and count toward the one transaction + * limit. + * + * Active sessions use additional server resources, so it is a good idea to + * delete idle and unneeded sessions. + * Aside from explicit deletes, Cloud Spanner may delete sessions for which no + * operations are sent for more than an hour. If a session is deleted, + * requests to it return `NOT_FOUND`. + * + * Idle sessions can be kept alive by sending a trivial SQL query + * periodically, e.g., `"SELECT 1"`. + * + * The async variant is {@see SpannerClient::createSessionAsync()} . + * + * @param CreateSessionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Session + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSession(CreateSessionRequest $request, array $callOptions = []): Session + { + return $this->startApiCall('CreateSession', $request, $callOptions)->wait(); + } + + /** + * Ends a session, releasing server resources associated with it. This will + * asynchronously trigger cancellation of any operations that are running with + * this session. + * + * The async variant is {@see SpannerClient::deleteSessionAsync()} . + * + * @param DeleteSessionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSession(DeleteSessionRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteSession', $request, $callOptions)->wait(); + } + + /** + * Executes a batch of SQL DML statements. This method allows many statements + * to be run with lower latency than submitting them sequentially with + * [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql]. + * + * Statements are executed in sequential order. A request can succeed even if + * a statement fails. The [ExecuteBatchDmlResponse.status][google.spanner.v1.ExecuteBatchDmlResponse.status] field in the + * response provides information about the statement that failed. Clients must + * inspect this field to determine whether an error occurred. + * + * Execution stops after the first failed statement; the remaining statements + * are not executed. + * + * The async variant is {@see SpannerClient::executeBatchDmlAsync()} . + * + * @param ExecuteBatchDmlRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ExecuteBatchDmlResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function executeBatchDml(ExecuteBatchDmlRequest $request, array $callOptions = []): ExecuteBatchDmlResponse + { + return $this->startApiCall('ExecuteBatchDml', $request, $callOptions)->wait(); + } + + /** + * Executes an SQL statement, returning all results in a single reply. This + * method cannot be used to return a result set larger than 10 MiB; + * if the query yields more data than that, the query fails with + * a `FAILED_PRECONDITION` error. + * + * Operations inside read-write transactions might return `ABORTED`. If + * this occurs, the application should restart the transaction from + * the beginning. See [Transaction][google.spanner.v1.Transaction] for more details. + * + * Larger result sets can be fetched in streaming fashion by calling + * [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] instead. + * + * The async variant is {@see SpannerClient::executeSqlAsync()} . + * + * @param ExecuteSqlRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ResultSet + * + * @throws ApiException Thrown if the API call fails. + */ + public function executeSql(ExecuteSqlRequest $request, array $callOptions = []): ResultSet + { + return $this->startApiCall('ExecuteSql', $request, $callOptions)->wait(); + } + + /** + * Like [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], except returns the result + * set as a stream. Unlike [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], there + * is no limit on the size of the returned result set. However, no + * individual row in the result set can exceed 100 MiB, and no + * column value can exceed 10 MiB. + * + * @param ExecuteSqlRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return ServerStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function executeStreamingSql(ExecuteSqlRequest $request, array $callOptions = []): ServerStream + { + return $this->startApiCall('ExecuteStreamingSql', $request, $callOptions); + } + + /** + * Gets a session. Returns `NOT_FOUND` if the session does not exist. + * This is mainly useful for determining whether a session is still + * alive. + * + * The async variant is {@see SpannerClient::getSessionAsync()} . + * + * @param GetSessionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Session + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSession(GetSessionRequest $request, array $callOptions = []): Session + { + return $this->startApiCall('GetSession', $request, $callOptions)->wait(); + } + + /** + * Lists all sessions in a given database. + * + * The async variant is {@see SpannerClient::listSessionsAsync()} . + * + * @param ListSessionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSessions(ListSessionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSessions', $request, $callOptions); + } + + /** + * Creates a set of partition tokens that can be used to execute a query + * operation in parallel. Each of the returned partition tokens can be used + * by [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] to specify a subset + * of the query result to read. The same session and read-only transaction + * must be used by the PartitionQueryRequest used to create the + * partition tokens and the ExecuteSqlRequests that use the partition tokens. + * + * Partition tokens become invalid when the session used to create them + * is deleted, is idle for too long, begins a new transaction, or becomes too + * old. When any of these happen, it is not possible to resume the query, and + * the whole operation must be restarted from the beginning. + * + * The async variant is {@see SpannerClient::partitionQueryAsync()} . + * + * @param PartitionQueryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PartitionResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function partitionQuery(PartitionQueryRequest $request, array $callOptions = []): PartitionResponse + { + return $this->startApiCall('PartitionQuery', $request, $callOptions)->wait(); + } + + /** + * Creates a set of partition tokens that can be used to execute a read + * operation in parallel. Each of the returned partition tokens can be used + * by [StreamingRead][google.spanner.v1.Spanner.StreamingRead] to specify a subset of the read + * result to read. The same session and read-only transaction must be used by + * the PartitionReadRequest used to create the partition tokens and the + * ReadRequests that use the partition tokens. There are no ordering + * guarantees on rows returned among the returned partition tokens, or even + * within each individual StreamingRead call issued with a partition_token. + * + * Partition tokens become invalid when the session used to create them + * is deleted, is idle for too long, begins a new transaction, or becomes too + * old. When any of these happen, it is not possible to resume the read, and + * the whole operation must be restarted from the beginning. + * + * The async variant is {@see SpannerClient::partitionReadAsync()} . + * + * @param PartitionReadRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PartitionResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function partitionRead(PartitionReadRequest $request, array $callOptions = []): PartitionResponse + { + return $this->startApiCall('PartitionRead', $request, $callOptions)->wait(); + } + + /** + * Reads rows from the database using key lookups and scans, as a + * simple key/value style alternative to + * [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql]. This method cannot be used to + * return a result set larger than 10 MiB; if the read matches more + * data than that, the read fails with a `FAILED_PRECONDITION` + * error. + * + * Reads inside read-write transactions might return `ABORTED`. If + * this occurs, the application should restart the transaction from + * the beginning. See [Transaction][google.spanner.v1.Transaction] for more details. + * + * Larger result sets can be yielded in streaming fashion by calling + * [StreamingRead][google.spanner.v1.Spanner.StreamingRead] instead. + * + * The async variant is {@see SpannerClient::readAsync()} . + * + * @param ReadRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ResultSet + * + * @throws ApiException Thrown if the API call fails. + */ + public function read(ReadRequest $request, array $callOptions = []): ResultSet + { + return $this->startApiCall('Read', $request, $callOptions)->wait(); + } + + /** + * Rolls back a transaction, releasing any locks it holds. It is a good + * idea to call this for any transaction that includes one or more + * [Read][google.spanner.v1.Spanner.Read] or [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] requests and + * ultimately decides not to commit. + * + * `Rollback` returns `OK` if it successfully aborts the transaction, the + * transaction was already aborted, or the transaction is not + * found. `Rollback` never returns `ABORTED`. + * + * The async variant is {@see SpannerClient::rollbackAsync()} . + * + * @param RollbackRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function rollback(RollbackRequest $request, array $callOptions = []): void + { + $this->startApiCall('Rollback', $request, $callOptions)->wait(); + } + + /** + * Like [Read][google.spanner.v1.Spanner.Read], except returns the result set as a + * stream. Unlike [Read][google.spanner.v1.Spanner.Read], there is no limit on the + * size of the returned result set. However, no individual row in + * the result set can exceed 100 MiB, and no column value can exceed + * 10 MiB. + * + * @param ReadRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return ServerStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function streamingRead(ReadRequest $request, array $callOptions = []): ServerStream + { + return $this->startApiCall('StreamingRead', $request, $callOptions); + } } diff --git a/Speech/composer.json b/Speech/composer.json index a8ecb50fb10b..e3a56f32b3ea 100644 --- a/Speech/composer.json +++ b/Speech/composer.json @@ -5,8 +5,8 @@ "minimum-stability": "stable", "require": { "php": ">=7.4", - "google/cloud-core": "^1.39", - "google/gax": "^1.19.1" + "google/cloud-core": "^1.52.7", + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", diff --git a/Speech/src/V2/Client/BaseClient/SpeechBaseClient.php b/Speech/src/V2/Client/BaseClient/SpeechBaseClient.php deleted file mode 100644 index 73f572554b94..000000000000 --- a/Speech/src/V2/Client/BaseClient/SpeechBaseClient.php +++ /dev/null @@ -1,1027 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/speech_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/speech_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/speech_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/speech_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a config - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted config resource. - */ - public static function configName(string $project, string $location): string - { - return self::getPathTemplate('config')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a crypto_key - * resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * @param string $cryptoKey - * - * @return string The formatted crypto_key resource. - */ - public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string - { - return self::getPathTemplate('cryptoKey')->render([ - 'project' => $project, - 'location' => $location, - 'key_ring' => $keyRing, - 'crypto_key' => $cryptoKey, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * crypto_key_version resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * @param string $cryptoKey - * @param string $cryptoKeyVersion - * - * @return string The formatted crypto_key_version resource. - */ - public static function cryptoKeyVersionName(string $project, string $location, string $keyRing, string $cryptoKey, string $cryptoKeyVersion): string - { - return self::getPathTemplate('cryptoKeyVersion')->render([ - 'project' => $project, - 'location' => $location, - 'key_ring' => $keyRing, - 'crypto_key' => $cryptoKey, - 'crypto_key_version' => $cryptoKeyVersion, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a custom_class - * resource. - * - * @param string $project - * @param string $location - * @param string $customClass - * - * @return string The formatted custom_class resource. - */ - public static function customClassName(string $project, string $location, string $customClass): string - { - return self::getPathTemplate('customClass')->render([ - 'project' => $project, - 'location' => $location, - 'custom_class' => $customClass, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a phrase_set - * resource. - * - * @param string $project - * @param string $location - * @param string $phraseSet - * - * @return string The formatted phrase_set resource. - */ - public static function phraseSetName(string $project, string $location, string $phraseSet): string - { - return self::getPathTemplate('phraseSet')->render([ - 'project' => $project, - 'location' => $location, - 'phrase_set' => $phraseSet, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a recognizer - * resource. - * - * @param string $project - * @param string $location - * @param string $recognizer - * - * @return string The formatted recognizer resource. - */ - public static function recognizerName(string $project, string $location, string $recognizer): string - { - return self::getPathTemplate('recognizer')->render([ - 'project' => $project, - 'location' => $location, - 'recognizer' => $recognizer, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - config: projects/{project}/locations/{location}/config - * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} - * - cryptoKeyVersion: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version} - * - customClass: projects/{project}/locations/{location}/customClasses/{custom_class} - * - location: projects/{project}/locations/{location} - * - phraseSet: projects/{project}/locations/{location}/phraseSets/{phrase_set} - * - recognizer: projects/{project}/locations/{location}/recognizers/{recognizer} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'speech.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Performs batch asynchronous speech recognition: send a request with N - * audio files and receive a long running operation that can be polled to see - * when the transcriptions are finished. - * - * The async variant is {@see self::batchRecognizeAsync()} . - * - * @param BatchRecognizeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchRecognize(BatchRecognizeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BatchRecognize', $request, $callOptions)->wait(); - } - - /** - * Creates a [CustomClass][google.cloud.speech.v2.CustomClass]. - * - * The async variant is {@see self::createCustomClassAsync()} . - * - * @param CreateCustomClassRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCustomClass(CreateCustomClassRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateCustomClass', $request, $callOptions)->wait(); - } - - /** - * Creates a [PhraseSet][google.cloud.speech.v2.PhraseSet]. - * - * The async variant is {@see self::createPhraseSetAsync()} . - * - * @param CreatePhraseSetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createPhraseSet(CreatePhraseSetRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreatePhraseSet', $request, $callOptions)->wait(); - } - - /** - * Creates a [Recognizer][google.cloud.speech.v2.Recognizer]. - * - * The async variant is {@see self::createRecognizerAsync()} . - * - * @param CreateRecognizerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createRecognizer(CreateRecognizerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateRecognizer', $request, $callOptions)->wait(); - } - - /** - * Deletes the [CustomClass][google.cloud.speech.v2.CustomClass]. - * - * The async variant is {@see self::deleteCustomClassAsync()} . - * - * @param DeleteCustomClassRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteCustomClass(DeleteCustomClassRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteCustomClass', $request, $callOptions)->wait(); - } - - /** - * Deletes the [PhraseSet][google.cloud.speech.v2.PhraseSet]. - * - * The async variant is {@see self::deletePhraseSetAsync()} . - * - * @param DeletePhraseSetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deletePhraseSet(DeletePhraseSetRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeletePhraseSet', $request, $callOptions)->wait(); - } - - /** - * Deletes the [Recognizer][google.cloud.speech.v2.Recognizer]. - * - * The async variant is {@see self::deleteRecognizerAsync()} . - * - * @param DeleteRecognizerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteRecognizer(DeleteRecognizerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteRecognizer', $request, $callOptions)->wait(); - } - - /** - * Returns the requested [Config][google.cloud.speech.v2.Config]. - * - * The async variant is {@see self::getConfigAsync()} . - * - * @param GetConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Config - * - * @throws ApiException Thrown if the API call fails. - */ - public function getConfig(GetConfigRequest $request, array $callOptions = []): Config - { - return $this->startApiCall('GetConfig', $request, $callOptions)->wait(); - } - - /** - * Returns the requested - * [CustomClass][google.cloud.speech.v2.CustomClass]. - * - * The async variant is {@see self::getCustomClassAsync()} . - * - * @param GetCustomClassRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CustomClass - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCustomClass(GetCustomClassRequest $request, array $callOptions = []): CustomClass - { - return $this->startApiCall('GetCustomClass', $request, $callOptions)->wait(); - } - - /** - * Returns the requested - * [PhraseSet][google.cloud.speech.v2.PhraseSet]. - * - * The async variant is {@see self::getPhraseSetAsync()} . - * - * @param GetPhraseSetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PhraseSet - * - * @throws ApiException Thrown if the API call fails. - */ - public function getPhraseSet(GetPhraseSetRequest $request, array $callOptions = []): PhraseSet - { - return $this->startApiCall('GetPhraseSet', $request, $callOptions)->wait(); - } - - /** - * Returns the requested - * [Recognizer][google.cloud.speech.v2.Recognizer]. Fails with - * [NOT_FOUND][google.rpc.Code.NOT_FOUND] if the requested Recognizer doesn't - * exist. - * - * The async variant is {@see self::getRecognizerAsync()} . - * - * @param GetRecognizerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Recognizer - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRecognizer(GetRecognizerRequest $request, array $callOptions = []): Recognizer - { - return $this->startApiCall('GetRecognizer', $request, $callOptions)->wait(); - } - - /** - * Lists CustomClasses. - * - * The async variant is {@see self::listCustomClassesAsync()} . - * - * @param ListCustomClassesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCustomClasses(ListCustomClassesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCustomClasses', $request, $callOptions); - } - - /** - * Lists PhraseSets. - * - * The async variant is {@see self::listPhraseSetsAsync()} . - * - * @param ListPhraseSetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPhraseSets(ListPhraseSetsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPhraseSets', $request, $callOptions); - } - - /** - * Lists Recognizers. - * - * The async variant is {@see self::listRecognizersAsync()} . - * - * @param ListRecognizersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listRecognizers(ListRecognizersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListRecognizers', $request, $callOptions); - } - - /** - * Performs synchronous Speech recognition: receive results after all audio - * has been sent and processed. - * - * The async variant is {@see self::recognizeAsync()} . - * - * @param RecognizeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RecognizeResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function recognize(RecognizeRequest $request, array $callOptions = []): RecognizeResponse - { - return $this->startApiCall('Recognize', $request, $callOptions)->wait(); - } - - /** - * Performs bidirectional streaming speech recognition: receive results while - * sending audio. This method is only available via the gRPC API (not REST). - * - * @param array $callOptions { - * Optional. - * - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return BidiStream - * - * @throws ApiException Thrown if the API call fails. - */ - public function streamingRecognize(array $callOptions = []): BidiStream - { - return $this->startApiCall('StreamingRecognize', null, $callOptions); - } - - /** - * Undeletes the [CustomClass][google.cloud.speech.v2.CustomClass]. - * - * The async variant is {@see self::undeleteCustomClassAsync()} . - * - * @param UndeleteCustomClassRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function undeleteCustomClass(UndeleteCustomClassRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UndeleteCustomClass', $request, $callOptions)->wait(); - } - - /** - * Undeletes the [PhraseSet][google.cloud.speech.v2.PhraseSet]. - * - * The async variant is {@see self::undeletePhraseSetAsync()} . - * - * @param UndeletePhraseSetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function undeletePhraseSet(UndeletePhraseSetRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UndeletePhraseSet', $request, $callOptions)->wait(); - } - - /** - * Undeletes the [Recognizer][google.cloud.speech.v2.Recognizer]. - * - * The async variant is {@see self::undeleteRecognizerAsync()} . - * - * @param UndeleteRecognizerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function undeleteRecognizer(UndeleteRecognizerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UndeleteRecognizer', $request, $callOptions)->wait(); - } - - /** - * Updates the [Config][google.cloud.speech.v2.Config]. - * - * The async variant is {@see self::updateConfigAsync()} . - * - * @param UpdateConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Config - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateConfig(UpdateConfigRequest $request, array $callOptions = []): Config - { - return $this->startApiCall('UpdateConfig', $request, $callOptions)->wait(); - } - - /** - * Updates the [CustomClass][google.cloud.speech.v2.CustomClass]. - * - * The async variant is {@see self::updateCustomClassAsync()} . - * - * @param UpdateCustomClassRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCustomClass(UpdateCustomClassRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateCustomClass', $request, $callOptions)->wait(); - } - - /** - * Updates the [PhraseSet][google.cloud.speech.v2.PhraseSet]. - * - * The async variant is {@see self::updatePhraseSetAsync()} . - * - * @param UpdatePhraseSetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updatePhraseSet(UpdatePhraseSetRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdatePhraseSet', $request, $callOptions)->wait(); - } - - /** - * Updates the [Recognizer][google.cloud.speech.v2.Recognizer]. - * - * The async variant is {@see self::updateRecognizerAsync()} . - * - * @param UpdateRecognizerRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateRecognizer(UpdateRecognizerRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateRecognizer', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Speech/src/V2/Client/SpeechClient.php b/Speech/src/V2/Client/SpeechClient.php index e15cba85469f..fc54f454a4b2 100644 --- a/Speech/src/V2/Client/SpeechClient.php +++ b/Speech/src/V2/Client/SpeechClient.php @@ -24,17 +24,1002 @@ namespace Google\Cloud\Speech\V2\Client; -use Google\Cloud\Speech\V2\Client\BaseClient\SpeechBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\BidiStream; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\Speech\V2\BatchRecognizeRequest; +use Google\Cloud\Speech\V2\Config; +use Google\Cloud\Speech\V2\CreateCustomClassRequest; +use Google\Cloud\Speech\V2\CreatePhraseSetRequest; +use Google\Cloud\Speech\V2\CreateRecognizerRequest; +use Google\Cloud\Speech\V2\CustomClass; +use Google\Cloud\Speech\V2\DeleteCustomClassRequest; +use Google\Cloud\Speech\V2\DeletePhraseSetRequest; +use Google\Cloud\Speech\V2\DeleteRecognizerRequest; +use Google\Cloud\Speech\V2\GetConfigRequest; +use Google\Cloud\Speech\V2\GetCustomClassRequest; +use Google\Cloud\Speech\V2\GetPhraseSetRequest; +use Google\Cloud\Speech\V2\GetRecognizerRequest; +use Google\Cloud\Speech\V2\ListCustomClassesRequest; +use Google\Cloud\Speech\V2\ListPhraseSetsRequest; +use Google\Cloud\Speech\V2\ListRecognizersRequest; +use Google\Cloud\Speech\V2\PhraseSet; +use Google\Cloud\Speech\V2\RecognizeRequest; +use Google\Cloud\Speech\V2\RecognizeResponse; +use Google\Cloud\Speech\V2\Recognizer; +use Google\Cloud\Speech\V2\UndeleteCustomClassRequest; +use Google\Cloud\Speech\V2\UndeletePhraseSetRequest; +use Google\Cloud\Speech\V2\UndeleteRecognizerRequest; +use Google\Cloud\Speech\V2\UpdateConfigRequest; +use Google\Cloud\Speech\V2\UpdateCustomClassRequest; +use Google\Cloud\Speech\V2\UpdatePhraseSetRequest; +use Google\Cloud\Speech\V2\UpdateRecognizerRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Enables speech transcription and resource management. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Speech\V2\SpeechClient} for the stable implementation * * @experimental + * + * @method PromiseInterface batchRecognizeAsync(BatchRecognizeRequest $request, array $optionalArgs = []) + * @method PromiseInterface createCustomClassAsync(CreateCustomClassRequest $request, array $optionalArgs = []) + * @method PromiseInterface createPhraseSetAsync(CreatePhraseSetRequest $request, array $optionalArgs = []) + * @method PromiseInterface createRecognizerAsync(CreateRecognizerRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteCustomClassAsync(DeleteCustomClassRequest $request, array $optionalArgs = []) + * @method PromiseInterface deletePhraseSetAsync(DeletePhraseSetRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteRecognizerAsync(DeleteRecognizerRequest $request, array $optionalArgs = []) + * @method PromiseInterface getConfigAsync(GetConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCustomClassAsync(GetCustomClassRequest $request, array $optionalArgs = []) + * @method PromiseInterface getPhraseSetAsync(GetPhraseSetRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRecognizerAsync(GetRecognizerRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCustomClassesAsync(ListCustomClassesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPhraseSetsAsync(ListPhraseSetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listRecognizersAsync(ListRecognizersRequest $request, array $optionalArgs = []) + * @method PromiseInterface recognizeAsync(RecognizeRequest $request, array $optionalArgs = []) + * @method PromiseInterface undeleteCustomClassAsync(UndeleteCustomClassRequest $request, array $optionalArgs = []) + * @method PromiseInterface undeletePhraseSetAsync(UndeletePhraseSetRequest $request, array $optionalArgs = []) + * @method PromiseInterface undeleteRecognizerAsync(UndeleteRecognizerRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateConfigAsync(UpdateConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCustomClassAsync(UpdateCustomClassRequest $request, array $optionalArgs = []) + * @method PromiseInterface updatePhraseSetAsync(UpdatePhraseSetRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateRecognizerAsync(UpdateRecognizerRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class SpeechClient extends SpeechBaseClient +final class SpeechClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SpeechBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.speech.v2.Speech'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'speech.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/speech_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/speech_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/speech_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/speech_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a config + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted config resource. + */ + public static function configName(string $project, string $location): string + { + return self::getPathTemplate('config')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a crypto_key + * resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * + * @return string The formatted crypto_key resource. + */ + public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string + { + return self::getPathTemplate('cryptoKey')->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'crypto_key' => $cryptoKey, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * crypto_key_version resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * @param string $cryptoKeyVersion + * + * @return string The formatted crypto_key_version resource. + */ + public static function cryptoKeyVersionName(string $project, string $location, string $keyRing, string $cryptoKey, string $cryptoKeyVersion): string + { + return self::getPathTemplate('cryptoKeyVersion')->render([ + 'project' => $project, + 'location' => $location, + 'key_ring' => $keyRing, + 'crypto_key' => $cryptoKey, + 'crypto_key_version' => $cryptoKeyVersion, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a custom_class + * resource. + * + * @param string $project + * @param string $location + * @param string $customClass + * + * @return string The formatted custom_class resource. + */ + public static function customClassName(string $project, string $location, string $customClass): string + { + return self::getPathTemplate('customClass')->render([ + 'project' => $project, + 'location' => $location, + 'custom_class' => $customClass, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a phrase_set + * resource. + * + * @param string $project + * @param string $location + * @param string $phraseSet + * + * @return string The formatted phrase_set resource. + */ + public static function phraseSetName(string $project, string $location, string $phraseSet): string + { + return self::getPathTemplate('phraseSet')->render([ + 'project' => $project, + 'location' => $location, + 'phrase_set' => $phraseSet, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a recognizer + * resource. + * + * @param string $project + * @param string $location + * @param string $recognizer + * + * @return string The formatted recognizer resource. + */ + public static function recognizerName(string $project, string $location, string $recognizer): string + { + return self::getPathTemplate('recognizer')->render([ + 'project' => $project, + 'location' => $location, + 'recognizer' => $recognizer, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - config: projects/{project}/locations/{location}/config + * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} + * - cryptoKeyVersion: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version} + * - customClass: projects/{project}/locations/{location}/customClasses/{custom_class} + * - location: projects/{project}/locations/{location} + * - phraseSet: projects/{project}/locations/{location}/phraseSets/{phrase_set} + * - recognizer: projects/{project}/locations/{location}/recognizers/{recognizer} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'speech.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Performs batch asynchronous speech recognition: send a request with N + * audio files and receive a long running operation that can be polled to see + * when the transcriptions are finished. + * + * The async variant is {@see SpeechClient::batchRecognizeAsync()} . + * + * @param BatchRecognizeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchRecognize(BatchRecognizeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchRecognize', $request, $callOptions)->wait(); + } + + /** + * Creates a [CustomClass][google.cloud.speech.v2.CustomClass]. + * + * The async variant is {@see SpeechClient::createCustomClassAsync()} . + * + * @param CreateCustomClassRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCustomClass(CreateCustomClassRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateCustomClass', $request, $callOptions)->wait(); + } + + /** + * Creates a [PhraseSet][google.cloud.speech.v2.PhraseSet]. + * + * The async variant is {@see SpeechClient::createPhraseSetAsync()} . + * + * @param CreatePhraseSetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createPhraseSet(CreatePhraseSetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreatePhraseSet', $request, $callOptions)->wait(); + } + + /** + * Creates a [Recognizer][google.cloud.speech.v2.Recognizer]. + * + * The async variant is {@see SpeechClient::createRecognizerAsync()} . + * + * @param CreateRecognizerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createRecognizer(CreateRecognizerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateRecognizer', $request, $callOptions)->wait(); + } + + /** + * Deletes the [CustomClass][google.cloud.speech.v2.CustomClass]. + * + * The async variant is {@see SpeechClient::deleteCustomClassAsync()} . + * + * @param DeleteCustomClassRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteCustomClass(DeleteCustomClassRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteCustomClass', $request, $callOptions)->wait(); + } + + /** + * Deletes the [PhraseSet][google.cloud.speech.v2.PhraseSet]. + * + * The async variant is {@see SpeechClient::deletePhraseSetAsync()} . + * + * @param DeletePhraseSetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deletePhraseSet(DeletePhraseSetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeletePhraseSet', $request, $callOptions)->wait(); + } + + /** + * Deletes the [Recognizer][google.cloud.speech.v2.Recognizer]. + * + * The async variant is {@see SpeechClient::deleteRecognizerAsync()} . + * + * @param DeleteRecognizerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteRecognizer(DeleteRecognizerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteRecognizer', $request, $callOptions)->wait(); + } + + /** + * Returns the requested [Config][google.cloud.speech.v2.Config]. + * + * The async variant is {@see SpeechClient::getConfigAsync()} . + * + * @param GetConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Config + * + * @throws ApiException Thrown if the API call fails. + */ + public function getConfig(GetConfigRequest $request, array $callOptions = []): Config + { + return $this->startApiCall('GetConfig', $request, $callOptions)->wait(); + } + + /** + * Returns the requested + * [CustomClass][google.cloud.speech.v2.CustomClass]. + * + * The async variant is {@see SpeechClient::getCustomClassAsync()} . + * + * @param GetCustomClassRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CustomClass + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCustomClass(GetCustomClassRequest $request, array $callOptions = []): CustomClass + { + return $this->startApiCall('GetCustomClass', $request, $callOptions)->wait(); + } + + /** + * Returns the requested + * [PhraseSet][google.cloud.speech.v2.PhraseSet]. + * + * The async variant is {@see SpeechClient::getPhraseSetAsync()} . + * + * @param GetPhraseSetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PhraseSet + * + * @throws ApiException Thrown if the API call fails. + */ + public function getPhraseSet(GetPhraseSetRequest $request, array $callOptions = []): PhraseSet + { + return $this->startApiCall('GetPhraseSet', $request, $callOptions)->wait(); + } + + /** + * Returns the requested + * [Recognizer][google.cloud.speech.v2.Recognizer]. Fails with + * [NOT_FOUND][google.rpc.Code.NOT_FOUND] if the requested Recognizer doesn't + * exist. + * + * The async variant is {@see SpeechClient::getRecognizerAsync()} . + * + * @param GetRecognizerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Recognizer + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRecognizer(GetRecognizerRequest $request, array $callOptions = []): Recognizer + { + return $this->startApiCall('GetRecognizer', $request, $callOptions)->wait(); + } + + /** + * Lists CustomClasses. + * + * The async variant is {@see SpeechClient::listCustomClassesAsync()} . + * + * @param ListCustomClassesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCustomClasses(ListCustomClassesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCustomClasses', $request, $callOptions); + } + + /** + * Lists PhraseSets. + * + * The async variant is {@see SpeechClient::listPhraseSetsAsync()} . + * + * @param ListPhraseSetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPhraseSets(ListPhraseSetsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPhraseSets', $request, $callOptions); + } + + /** + * Lists Recognizers. + * + * The async variant is {@see SpeechClient::listRecognizersAsync()} . + * + * @param ListRecognizersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listRecognizers(ListRecognizersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListRecognizers', $request, $callOptions); + } + + /** + * Performs synchronous Speech recognition: receive results after all audio + * has been sent and processed. + * + * The async variant is {@see SpeechClient::recognizeAsync()} . + * + * @param RecognizeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RecognizeResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function recognize(RecognizeRequest $request, array $callOptions = []): RecognizeResponse + { + return $this->startApiCall('Recognize', $request, $callOptions)->wait(); + } + + /** + * Performs bidirectional streaming speech recognition: receive results while + * sending audio. This method is only available via the gRPC API (not REST). + * + * @param array $callOptions { + * Optional. + * + * @type int $timeoutMillis + * Timeout to use for this call. + * } + * + * @return BidiStream + * + * @throws ApiException Thrown if the API call fails. + */ + public function streamingRecognize(array $callOptions = []): BidiStream + { + return $this->startApiCall('StreamingRecognize', null, $callOptions); + } + + /** + * Undeletes the [CustomClass][google.cloud.speech.v2.CustomClass]. + * + * The async variant is {@see SpeechClient::undeleteCustomClassAsync()} . + * + * @param UndeleteCustomClassRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function undeleteCustomClass(UndeleteCustomClassRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UndeleteCustomClass', $request, $callOptions)->wait(); + } + + /** + * Undeletes the [PhraseSet][google.cloud.speech.v2.PhraseSet]. + * + * The async variant is {@see SpeechClient::undeletePhraseSetAsync()} . + * + * @param UndeletePhraseSetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function undeletePhraseSet(UndeletePhraseSetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UndeletePhraseSet', $request, $callOptions)->wait(); + } + + /** + * Undeletes the [Recognizer][google.cloud.speech.v2.Recognizer]. + * + * The async variant is {@see SpeechClient::undeleteRecognizerAsync()} . + * + * @param UndeleteRecognizerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function undeleteRecognizer(UndeleteRecognizerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UndeleteRecognizer', $request, $callOptions)->wait(); + } + + /** + * Updates the [Config][google.cloud.speech.v2.Config]. + * + * The async variant is {@see SpeechClient::updateConfigAsync()} . + * + * @param UpdateConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Config + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateConfig(UpdateConfigRequest $request, array $callOptions = []): Config + { + return $this->startApiCall('UpdateConfig', $request, $callOptions)->wait(); + } + + /** + * Updates the [CustomClass][google.cloud.speech.v2.CustomClass]. + * + * The async variant is {@see SpeechClient::updateCustomClassAsync()} . + * + * @param UpdateCustomClassRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCustomClass(UpdateCustomClassRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateCustomClass', $request, $callOptions)->wait(); + } + + /** + * Updates the [PhraseSet][google.cloud.speech.v2.PhraseSet]. + * + * The async variant is {@see SpeechClient::updatePhraseSetAsync()} . + * + * @param UpdatePhraseSetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updatePhraseSet(UpdatePhraseSetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdatePhraseSet', $request, $callOptions)->wait(); + } + + /** + * Updates the [Recognizer][google.cloud.speech.v2.Recognizer]. + * + * The async variant is {@see SpeechClient::updateRecognizerAsync()} . + * + * @param UpdateRecognizerRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateRecognizer(UpdateRecognizerRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateRecognizer', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see SpeechClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see SpeechClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/SqlAdmin/VERSION b/SqlAdmin/VERSION index 8f0916f768f0..a918a2aa18d5 100644 --- a/SqlAdmin/VERSION +++ b/SqlAdmin/VERSION @@ -1 +1 @@ -0.5.0 +0.6.0 diff --git a/SqlAdmin/composer.json b/SqlAdmin/composer.json index 88b1e6f49e0c..bac88d140869 100644 --- a/SqlAdmin/composer.json +++ b/SqlAdmin/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/SqlAdmin/metadata/V1/CloudSqlInstances.php b/SqlAdmin/metadata/V1/CloudSqlInstances.php index ae8c75e1c251..f2950fdd737f 100644 Binary files a/SqlAdmin/metadata/V1/CloudSqlInstances.php and b/SqlAdmin/metadata/V1/CloudSqlInstances.php differ diff --git a/SqlAdmin/metadata/V1Beta4/CloudSql.php b/SqlAdmin/metadata/V1Beta4/CloudSql.php index f2a8bcc4f505..1fdca7037343 100644 Binary files a/SqlAdmin/metadata/V1Beta4/CloudSql.php and b/SqlAdmin/metadata/V1Beta4/CloudSql.php differ diff --git a/SqlAdmin/metadata/V1Beta4/CloudSqlResources.php b/SqlAdmin/metadata/V1Beta4/CloudSqlResources.php index 90efd28be71c..459b34cb3d22 100644 Binary files a/SqlAdmin/metadata/V1Beta4/CloudSqlResources.php and b/SqlAdmin/metadata/V1Beta4/CloudSqlResources.php differ diff --git a/SqlAdmin/src/V1/Client/BaseClient/SqlAvailableDatabaseVersionsServiceBaseClient.php b/SqlAdmin/src/V1/Client/BaseClient/SqlAvailableDatabaseVersionsServiceBaseClient.php deleted file mode 100644 index 0ccede2df375..000000000000 --- a/SqlAdmin/src/V1/Client/BaseClient/SqlAvailableDatabaseVersionsServiceBaseClient.php +++ /dev/null @@ -1,143 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/sql_available_database_versions_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/sql_available_database_versions_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/sql_available_database_versions_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/sql_available_database_versions_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'sqladmin.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } -} diff --git a/SqlAdmin/src/V1/Client/BaseClient/SqlBackupRunsServiceBaseClient.php b/SqlAdmin/src/V1/Client/BaseClient/SqlBackupRunsServiceBaseClient.php deleted file mode 100644 index aec2bc862a8a..000000000000 --- a/SqlAdmin/src/V1/Client/BaseClient/SqlBackupRunsServiceBaseClient.php +++ /dev/null @@ -1,277 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/sql_backup_runs_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/sql_backup_runs_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/sql_backup_runs_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/sql_backup_runs_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'sqladmin.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the backup taken by a backup run. - * - * The async variant is {@see self::deleteAsync()} . - * - * @example samples/V1/SqlBackupRunsServiceClient/delete.php - * - * @param SqlBackupRunsDeleteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(SqlBackupRunsDeleteRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Retrieves a resource containing information about a backup run. - * - * The async variant is {@see self::getAsync()} . - * - * @example samples/V1/SqlBackupRunsServiceClient/get.php - * - * @param SqlBackupRunsGetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BackupRun - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(SqlBackupRunsGetRequest $request, array $callOptions = []): BackupRun - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a new backup run on demand. - * - * The async variant is {@see self::insertAsync()} . - * - * @example samples/V1/SqlBackupRunsServiceClient/insert.php - * - * @param SqlBackupRunsInsertRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(SqlBackupRunsInsertRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Lists all backup runs associated with the project or a given instance - * and configuration in the reverse chronological order of the backup - * initiation time. - * - * The async variant is {@see self::listAsync()} . - * - * @example samples/V1/SqlBackupRunsServiceClient/list.php - * - * @param SqlBackupRunsListRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BackupRunsListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(SqlBackupRunsListRequest $request, array $callOptions = []): BackupRunsListResponse - { - return $this->startApiCall('List', $request, $callOptions)->wait(); - } -} diff --git a/SqlAdmin/src/V1/Client/BaseClient/SqlConnectServiceBaseClient.php b/SqlAdmin/src/V1/Client/BaseClient/SqlConnectServiceBaseClient.php deleted file mode 100644 index 140492d898db..000000000000 --- a/SqlAdmin/src/V1/Client/BaseClient/SqlConnectServiceBaseClient.php +++ /dev/null @@ -1,221 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/sql_connect_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/sql_connect_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/sql_connect_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/sql_connect_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'sqladmin.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Generates a short-lived X509 certificate containing the provided public key - * and signed by a private key specific to the target instance. Users may use - * the certificate to authenticate as themselves when connecting to the - * database. - * - * The async variant is {@see self::generateEphemeralCertAsync()} . - * - * @example samples/V1/SqlConnectServiceClient/generate_ephemeral_cert.php - * - * @param GenerateEphemeralCertRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GenerateEphemeralCertResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function generateEphemeralCert(GenerateEphemeralCertRequest $request, array $callOptions = []): GenerateEphemeralCertResponse - { - return $this->startApiCall('GenerateEphemeralCert', $request, $callOptions)->wait(); - } - - /** - * Retrieves connect settings about a Cloud SQL instance. - * - * The async variant is {@see self::getConnectSettingsAsync()} . - * - * @example samples/V1/SqlConnectServiceClient/get_connect_settings.php - * - * @param GetConnectSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ConnectSettings - * - * @throws ApiException Thrown if the API call fails. - */ - public function getConnectSettings(GetConnectSettingsRequest $request, array $callOptions = []): ConnectSettings - { - return $this->startApiCall('GetConnectSettings', $request, $callOptions)->wait(); - } -} diff --git a/SqlAdmin/src/V1/Client/BaseClient/SqlDatabasesServiceBaseClient.php b/SqlAdmin/src/V1/Client/BaseClient/SqlDatabasesServiceBaseClient.php deleted file mode 100644 index 2dfa84056245..000000000000 --- a/SqlAdmin/src/V1/Client/BaseClient/SqlDatabasesServiceBaseClient.php +++ /dev/null @@ -1,336 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/sql_databases_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/sql_databases_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/sql_databases_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/sql_databases_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'sqladmin.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes a database from a Cloud SQL instance. - * - * The async variant is {@see self::deleteAsync()} . - * - * @example samples/V1/SqlDatabasesServiceClient/delete.php - * - * @param SqlDatabasesDeleteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(SqlDatabasesDeleteRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Retrieves a resource containing information about a database inside a Cloud - * SQL instance. - * - * The async variant is {@see self::getAsync()} . - * - * @example samples/V1/SqlDatabasesServiceClient/get.php - * - * @param SqlDatabasesGetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Database - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(SqlDatabasesGetRequest $request, array $callOptions = []): Database - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Inserts a resource containing information about a database inside a Cloud - * SQL instance. - * - * **Note:** You can't modify the default character set and collation. - * - * The async variant is {@see self::insertAsync()} . - * - * @example samples/V1/SqlDatabasesServiceClient/insert.php - * - * @param SqlDatabasesInsertRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(SqlDatabasesInsertRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Lists databases in the specified Cloud SQL instance. - * - * The async variant is {@see self::listAsync()} . - * - * @example samples/V1/SqlDatabasesServiceClient/list.php - * - * @param SqlDatabasesListRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DatabasesListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(SqlDatabasesListRequest $request, array $callOptions = []): DatabasesListResponse - { - return $this->startApiCall('List', $request, $callOptions)->wait(); - } - - /** - * Partially updates a resource containing information about a database inside - * a Cloud SQL instance. This method supports patch semantics. - * - * The async variant is {@see self::patchAsync()} . - * - * @example samples/V1/SqlDatabasesServiceClient/patch.php - * - * @param SqlDatabasesUpdateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(SqlDatabasesUpdateRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Updates a resource containing information about a database inside a Cloud - * SQL instance. - * - * The async variant is {@see self::updateAsync()} . - * - * @example samples/V1/SqlDatabasesServiceClient/update.php - * - * @param SqlDatabasesUpdateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function update(SqlDatabasesUpdateRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Update', $request, $callOptions)->wait(); - } -} diff --git a/SqlAdmin/src/V1/Client/BaseClient/SqlEventsServiceBaseClient.php b/SqlAdmin/src/V1/Client/BaseClient/SqlEventsServiceBaseClient.php deleted file mode 100644 index 62da511c129c..000000000000 --- a/SqlAdmin/src/V1/Client/BaseClient/SqlEventsServiceBaseClient.php +++ /dev/null @@ -1,143 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/sql_events_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/sql_events_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/sql_events_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/sql_events_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'sqladmin.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } -} diff --git a/SqlAdmin/src/V1/Client/BaseClient/SqlFlagsServiceBaseClient.php b/SqlAdmin/src/V1/Client/BaseClient/SqlFlagsServiceBaseClient.php deleted file mode 100644 index 1b81bad92f16..000000000000 --- a/SqlAdmin/src/V1/Client/BaseClient/SqlFlagsServiceBaseClient.php +++ /dev/null @@ -1,189 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/sql_flags_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/sql_flags_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/sql_flags_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/sql_flags_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'sqladmin.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Lists all available database flags for Cloud SQL instances. - * - * The async variant is {@see self::listAsync()} . - * - * @example samples/V1/SqlFlagsServiceClient/list.php - * - * @param SqlFlagsListRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FlagsListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(SqlFlagsListRequest $request, array $callOptions = []): FlagsListResponse - { - return $this->startApiCall('List', $request, $callOptions)->wait(); - } -} diff --git a/SqlAdmin/src/V1/Client/BaseClient/SqlIamPoliciesServiceBaseClient.php b/SqlAdmin/src/V1/Client/BaseClient/SqlIamPoliciesServiceBaseClient.php deleted file mode 100644 index cf4c1cfbf24a..000000000000 --- a/SqlAdmin/src/V1/Client/BaseClient/SqlIamPoliciesServiceBaseClient.php +++ /dev/null @@ -1,142 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/sql_iam_policies_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/sql_iam_policies_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/sql_iam_policies_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/sql_iam_policies_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'sqladmin.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } -} diff --git a/SqlAdmin/src/V1/Client/BaseClient/SqlInstanceNamesServiceBaseClient.php b/SqlAdmin/src/V1/Client/BaseClient/SqlInstanceNamesServiceBaseClient.php deleted file mode 100644 index 9687a02fcc95..000000000000 --- a/SqlAdmin/src/V1/Client/BaseClient/SqlInstanceNamesServiceBaseClient.php +++ /dev/null @@ -1,142 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/sql_instance_names_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/sql_instance_names_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/sql_instance_names_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/sql_instance_names_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'sqladmin.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } -} diff --git a/SqlAdmin/src/V1/Client/BaseClient/SqlInstancesServiceBaseClient.php b/SqlAdmin/src/V1/Client/BaseClient/SqlInstancesServiceBaseClient.php deleted file mode 100644 index 4b79df19cf88..000000000000 --- a/SqlAdmin/src/V1/Client/BaseClient/SqlInstancesServiceBaseClient.php +++ /dev/null @@ -1,1037 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/sql_instances_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/sql_instances_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/sql_instances_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/sql_instances_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'sqladmin.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Adds a new trusted Certificate Authority (CA) version for the specified - * instance. Required to prepare for a certificate rotation. If a CA version - * was previously added but never used in a certificate rotation, this - * operation replaces that version. There cannot be more than one CA version - * waiting to be rotated in. - * - * The async variant is {@see self::addServerCaAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/add_server_ca.php - * - * @param SqlInstancesAddServerCaRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function addServerCa(SqlInstancesAddServerCaRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('AddServerCa', $request, $callOptions)->wait(); - } - - /** - * Creates a Cloud SQL instance as a clone of the source instance. Using this - * operation might cause your instance to restart. - * - * The async variant is {@see self::cloneAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/clone.php - * - * @param SqlInstancesCloneRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function clone(SqlInstancesCloneRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Clone', $request, $callOptions)->wait(); - } - - /** - * Generates a short-lived X509 certificate containing the provided public key - * and signed by a private key specific to the target instance. Users may use - * the certificate to authenticate as themselves when connecting to the - * database. - * - * The async variant is {@see self::createEphemeralAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/create_ephemeral.php - * - * @param SqlInstancesCreateEphemeralCertRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SslCert - * - * @throws ApiException Thrown if the API call fails. - */ - public function createEphemeral(SqlInstancesCreateEphemeralCertRequest $request, array $callOptions = []): SslCert - { - return $this->startApiCall('CreateEphemeral', $request, $callOptions)->wait(); - } - - /** - * Deletes a Cloud SQL instance. - * - * The async variant is {@see self::deleteAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/delete.php - * - * @param SqlInstancesDeleteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(SqlInstancesDeleteRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Demotes the stand-alone instance to be a Cloud SQL read replica for an - * external database server. - * - * The async variant is {@see self::demoteMasterAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/demote_master.php - * - * @param SqlInstancesDemoteMasterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function demoteMaster(SqlInstancesDemoteMasterRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('DemoteMaster', $request, $callOptions)->wait(); - } - - /** - * Exports data from a Cloud SQL instance to a Cloud Storage bucket as a SQL - * dump or CSV file. - * - * The async variant is {@see self::exportAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/export.php - * - * @param SqlInstancesExportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function export(SqlInstancesExportRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Export', $request, $callOptions)->wait(); - } - - /** - * Initiates a manual failover of a high availability (HA) primary instance - * to a standby instance, which becomes the primary instance. Users are - * then rerouted to the new primary. For more information, see the - * [Overview of high - * availability](https://cloud.google.com/sql/docs/mysql/high-availability) - * page in the Cloud SQL documentation. - * If using Legacy HA (MySQL only), this causes the instance to failover to - * its failover replica instance. - * - * The async variant is {@see self::failoverAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/failover.php - * - * @param SqlInstancesFailoverRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function failover(SqlInstancesFailoverRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Failover', $request, $callOptions)->wait(); - } - - /** - * Retrieves a resource containing information about a Cloud SQL instance. - * - * The async variant is {@see self::getAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/get.php - * - * @param SqlInstancesGetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DatabaseInstance - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(SqlInstancesGetRequest $request, array $callOptions = []): DatabaseInstance - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Get Disk Shrink Config for a given instance. - * - * The async variant is {@see self::getDiskShrinkConfigAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/get_disk_shrink_config.php - * - * @param SqlInstancesGetDiskShrinkConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SqlInstancesGetDiskShrinkConfigResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDiskShrinkConfig(SqlInstancesGetDiskShrinkConfigRequest $request, array $callOptions = []): SqlInstancesGetDiskShrinkConfigResponse - { - return $this->startApiCall('GetDiskShrinkConfig', $request, $callOptions)->wait(); - } - - /** - * Get Latest Recovery Time for a given instance. - * - * The async variant is {@see self::getLatestRecoveryTimeAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/get_latest_recovery_time.php - * - * @param SqlInstancesGetLatestRecoveryTimeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SqlInstancesGetLatestRecoveryTimeResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLatestRecoveryTime(SqlInstancesGetLatestRecoveryTimeRequest $request, array $callOptions = []): SqlInstancesGetLatestRecoveryTimeResponse - { - return $this->startApiCall('GetLatestRecoveryTime', $request, $callOptions)->wait(); - } - - /** - * Imports data into a Cloud SQL instance from a SQL dump or CSV file in - * Cloud Storage. - * - * The async variant is {@see self::importAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/import.php - * - * @param SqlInstancesImportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function import(SqlInstancesImportRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Import', $request, $callOptions)->wait(); - } - - /** - * Creates a new Cloud SQL instance. - * - * The async variant is {@see self::insertAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/insert.php - * - * @param SqlInstancesInsertRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(SqlInstancesInsertRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Lists instances under a given project. - * - * The async variant is {@see self::listAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/list.php - * - * @param SqlInstancesListRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InstancesListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(SqlInstancesListRequest $request, array $callOptions = []): InstancesListResponse - { - return $this->startApiCall('List', $request, $callOptions)->wait(); - } - - /** - * Lists all of the trusted Certificate Authorities (CAs) for the specified - * instance. There can be up to three CAs listed: the CA that was used to sign - * the certificate that is currently in use, a CA that has been added but not - * yet used to sign a certificate, and a CA used to sign a certificate that - * has previously rotated out. - * - * The async variant is {@see self::listServerCasAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/list_server_cas.php - * - * @param SqlInstancesListServerCasRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 InstancesListServerCasResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listServerCas(SqlInstancesListServerCasRequest $request, array $callOptions = []): InstancesListServerCasResponse - { - return $this->startApiCall('ListServerCas', $request, $callOptions)->wait(); - } - - /** - * Partially updates settings of a Cloud SQL instance by merging the request - * with the current configuration. This method supports patch semantics. - * - * The async variant is {@see self::patchAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/patch.php - * - * @param SqlInstancesPatchRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function patch(SqlInstancesPatchRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Patch', $request, $callOptions)->wait(); - } - - /** - * Perform Disk Shrink on primary instance. - * - * The async variant is {@see self::performDiskShrinkAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/perform_disk_shrink.php - * - * @param SqlInstancesPerformDiskShrinkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function performDiskShrink(SqlInstancesPerformDiskShrinkRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('PerformDiskShrink', $request, $callOptions)->wait(); - } - - /** - * Promotes the read replica instance to be a stand-alone Cloud SQL instance. - * Using this operation might cause your instance to restart. - * - * The async variant is {@see self::promoteReplicaAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/promote_replica.php - * - * @param SqlInstancesPromoteReplicaRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function promoteReplica(SqlInstancesPromoteReplicaRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('PromoteReplica', $request, $callOptions)->wait(); - } - - /** - * Reencrypt CMEK instance with latest key version. - * - * The async variant is {@see self::reencryptAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/reencrypt.php - * - * @param SqlInstancesReencryptRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function reencrypt(SqlInstancesReencryptRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Reencrypt', $request, $callOptions)->wait(); - } - - /** - * Reschedules the maintenance on the given instance. - * - * The async variant is {@see self::rescheduleMaintenanceAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/reschedule_maintenance.php - * - * @param SqlInstancesRescheduleMaintenanceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function rescheduleMaintenance(SqlInstancesRescheduleMaintenanceRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('RescheduleMaintenance', $request, $callOptions)->wait(); - } - - /** - * Reset Replica Size to primary instance disk size. - * - * The async variant is {@see self::resetReplicaSizeAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/reset_replica_size.php - * - * @param SqlInstancesResetReplicaSizeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function resetReplicaSize(SqlInstancesResetReplicaSizeRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('ResetReplicaSize', $request, $callOptions)->wait(); - } - - /** - * Deletes all client certificates and generates a new server SSL certificate - * for the instance. - * - * The async variant is {@see self::resetSslConfigAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/reset_ssl_config.php - * - * @param SqlInstancesResetSslConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function resetSslConfig(SqlInstancesResetSslConfigRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('ResetSslConfig', $request, $callOptions)->wait(); - } - - /** - * Restarts a Cloud SQL instance. - * - * The async variant is {@see self::restartAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/restart.php - * - * @param SqlInstancesRestartRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function restart(SqlInstancesRestartRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Restart', $request, $callOptions)->wait(); - } - - /** - * Restores a backup of a Cloud SQL instance. Using this operation might cause - * your instance to restart. - * - * The async variant is {@see self::restoreBackupAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/restore_backup.php - * - * @param SqlInstancesRestoreBackupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function restoreBackup(SqlInstancesRestoreBackupRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('RestoreBackup', $request, $callOptions)->wait(); - } - - /** - * Rotates the server certificate to one signed by the Certificate Authority - * (CA) version previously added with the addServerCA method. - * - * The async variant is {@see self::rotateServerCaAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/rotate_server_ca.php - * - * @param SqlInstancesRotateServerCaRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function rotateServerCa(SqlInstancesRotateServerCaRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('RotateServerCa', $request, $callOptions)->wait(); - } - - /** - * Start External primary instance migration. - * - * The async variant is {@see self::startExternalSyncAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/start_external_sync.php - * - * @param SqlInstancesStartExternalSyncRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function startExternalSync(SqlInstancesStartExternalSyncRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('StartExternalSync', $request, $callOptions)->wait(); - } - - /** - * Starts the replication in the read replica instance. - * - * The async variant is {@see self::startReplicaAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/start_replica.php - * - * @param SqlInstancesStartReplicaRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function startReplica(SqlInstancesStartReplicaRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('StartReplica', $request, $callOptions)->wait(); - } - - /** - * Stops the replication in the read replica instance. - * - * The async variant is {@see self::stopReplicaAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/stop_replica.php - * - * @param SqlInstancesStopReplicaRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function stopReplica(SqlInstancesStopReplicaRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('StopReplica', $request, $callOptions)->wait(); - } - - /** - * Truncate MySQL general and slow query log tables - * MySQL only. - * - * The async variant is {@see self::truncateLogAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/truncate_log.php - * - * @param SqlInstancesTruncateLogRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function truncateLog(SqlInstancesTruncateLogRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('TruncateLog', $request, $callOptions)->wait(); - } - - /** - * Updates settings of a Cloud SQL instance. Using this operation might cause - * your instance to restart. - * - * The async variant is {@see self::updateAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/update.php - * - * @param SqlInstancesUpdateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function update(SqlInstancesUpdateRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Update', $request, $callOptions)->wait(); - } - - /** - * Verify External primary instance external sync settings. - * - * The async variant is {@see self::verifyExternalSyncSettingsAsync()} . - * - * @example samples/V1/SqlInstancesServiceClient/verify_external_sync_settings.php - * - * @param SqlInstancesVerifyExternalSyncSettingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SqlInstancesVerifyExternalSyncSettingsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function verifyExternalSyncSettings(SqlInstancesVerifyExternalSyncSettingsRequest $request, array $callOptions = []): SqlInstancesVerifyExternalSyncSettingsResponse - { - return $this->startApiCall('VerifyExternalSyncSettings', $request, $callOptions)->wait(); - } -} diff --git a/SqlAdmin/src/V1/Client/BaseClient/SqlOperationsServiceBaseClient.php b/SqlAdmin/src/V1/Client/BaseClient/SqlOperationsServiceBaseClient.php deleted file mode 100644 index cbe0dd44110e..000000000000 --- a/SqlAdmin/src/V1/Client/BaseClient/SqlOperationsServiceBaseClient.php +++ /dev/null @@ -1,245 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/sql_operations_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/sql_operations_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/sql_operations_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/sql_operations_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'sqladmin.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Cancels an instance operation that has been performed on an instance. - * - * The async variant is {@see self::cancelAsync()} . - * - * @example samples/V1/SqlOperationsServiceClient/cancel.php - * - * @param SqlOperationsCancelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function cancel(SqlOperationsCancelRequest $request, array $callOptions = []): void - { - $this->startApiCall('Cancel', $request, $callOptions)->wait(); - } - - /** - * Retrieves an instance operation that has been performed on an instance. - * - * The async variant is {@see self::getAsync()} . - * - * @example samples/V1/SqlOperationsServiceClient/get.php - * - * @param SqlOperationsGetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(SqlOperationsGetRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Lists all instance operations that have been performed on the given Cloud - * SQL instance in the reverse chronological order of the start time. - * - * The async variant is {@see self::listAsync()} . - * - * @example samples/V1/SqlOperationsServiceClient/list.php - * - * @param SqlOperationsListRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationsListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(SqlOperationsListRequest $request, array $callOptions = []): OperationsListResponse - { - return $this->startApiCall('List', $request, $callOptions)->wait(); - } -} diff --git a/SqlAdmin/src/V1/Client/BaseClient/SqlRegionsServiceBaseClient.php b/SqlAdmin/src/V1/Client/BaseClient/SqlRegionsServiceBaseClient.php deleted file mode 100644 index 11b5c1bfea2c..000000000000 --- a/SqlAdmin/src/V1/Client/BaseClient/SqlRegionsServiceBaseClient.php +++ /dev/null @@ -1,143 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/sql_regions_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/sql_regions_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/sql_regions_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/sql_regions_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'sqladmin.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } -} diff --git a/SqlAdmin/src/V1/Client/BaseClient/SqlSslCertsServiceBaseClient.php b/SqlAdmin/src/V1/Client/BaseClient/SqlSslCertsServiceBaseClient.php deleted file mode 100644 index a0bc2773fd73..000000000000 --- a/SqlAdmin/src/V1/Client/BaseClient/SqlSslCertsServiceBaseClient.php +++ /dev/null @@ -1,281 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/sql_ssl_certs_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/sql_ssl_certs_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/sql_ssl_certs_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/sql_ssl_certs_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'sqladmin.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes the SSL certificate. For First Generation instances, the - * certificate remains valid until the instance is restarted. - * - * The async variant is {@see self::deleteAsync()} . - * - * @example samples/V1/SqlSslCertsServiceClient/delete.php - * - * @param SqlSslCertsDeleteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(SqlSslCertsDeleteRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Retrieves a particular SSL certificate. Does not include the private key - * (required for usage). The private key must be saved from the response to - * initial creation. - * - * The async variant is {@see self::getAsync()} . - * - * @example samples/V1/SqlSslCertsServiceClient/get.php - * - * @param SqlSslCertsGetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SslCert - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(SqlSslCertsGetRequest $request, array $callOptions = []): SslCert - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates an SSL certificate and returns it along with the private key and - * server certificate authority. The new certificate will not be usable until - * the instance is restarted. - * - * The async variant is {@see self::insertAsync()} . - * - * @example samples/V1/SqlSslCertsServiceClient/insert.php - * - * @param SqlSslCertsInsertRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SslCertsInsertResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(SqlSslCertsInsertRequest $request, array $callOptions = []): SslCertsInsertResponse - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Lists all of the current SSL certificates for the instance. - * - * The async variant is {@see self::listAsync()} . - * - * @example samples/V1/SqlSslCertsServiceClient/list.php - * - * @param SqlSslCertsListRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SslCertsListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(SqlSslCertsListRequest $request, array $callOptions = []): SslCertsListResponse - { - return $this->startApiCall('List', $request, $callOptions)->wait(); - } -} diff --git a/SqlAdmin/src/V1/Client/BaseClient/SqlTiersServiceBaseClient.php b/SqlAdmin/src/V1/Client/BaseClient/SqlTiersServiceBaseClient.php deleted file mode 100644 index 3566221dbcf9..000000000000 --- a/SqlAdmin/src/V1/Client/BaseClient/SqlTiersServiceBaseClient.php +++ /dev/null @@ -1,191 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/sql_tiers_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/sql_tiers_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/sql_tiers_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/sql_tiers_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'sqladmin.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Lists all available machine types (tiers) for Cloud SQL, for example, - * `db-custom-1-3840`. For more information, see - * https://cloud.google.com/sql/pricing. - * - * The async variant is {@see self::listAsync()} . - * - * @example samples/V1/SqlTiersServiceClient/list.php - * - * @param SqlTiersListRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TiersListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(SqlTiersListRequest $request, array $callOptions = []): TiersListResponse - { - return $this->startApiCall('List', $request, $callOptions)->wait(); - } -} diff --git a/SqlAdmin/src/V1/Client/BaseClient/SqlUsersServiceBaseClient.php b/SqlAdmin/src/V1/Client/BaseClient/SqlUsersServiceBaseClient.php deleted file mode 100644 index f59e5fddb72e..000000000000 --- a/SqlAdmin/src/V1/Client/BaseClient/SqlUsersServiceBaseClient.php +++ /dev/null @@ -1,303 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/sql_users_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/sql_users_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/sql_users_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/sql_users_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'sqladmin.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Deletes a user from a Cloud SQL instance. - * - * The async variant is {@see self::deleteAsync()} . - * - * @example samples/V1/SqlUsersServiceClient/delete.php - * - * @param SqlUsersDeleteRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function delete(SqlUsersDeleteRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Delete', $request, $callOptions)->wait(); - } - - /** - * Retrieves a resource containing information about a user. - * - * The async variant is {@see self::getAsync()} . - * - * @example samples/V1/SqlUsersServiceClient/get.php - * - * @param SqlUsersGetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 User - * - * @throws ApiException Thrown if the API call fails. - */ - public function get(SqlUsersGetRequest $request, array $callOptions = []): User - { - return $this->startApiCall('Get', $request, $callOptions)->wait(); - } - - /** - * Creates a new user in a Cloud SQL instance. - * - * The async variant is {@see self::insertAsync()} . - * - * @example samples/V1/SqlUsersServiceClient/insert.php - * - * @param SqlUsersInsertRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function insert(SqlUsersInsertRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Insert', $request, $callOptions)->wait(); - } - - /** - * Lists users in the specified Cloud SQL instance. - * - * The async variant is {@see self::listAsync()} . - * - * @example samples/V1/SqlUsersServiceClient/list.php - * - * @param SqlUsersListRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 UsersListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function list(SqlUsersListRequest $request, array $callOptions = []): UsersListResponse - { - return $this->startApiCall('List', $request, $callOptions)->wait(); - } - - /** - * Updates an existing user in a Cloud SQL instance. - * - * The async variant is {@see self::updateAsync()} . - * - * @example samples/V1/SqlUsersServiceClient/update.php - * - * @param SqlUsersUpdateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Operation - * - * @throws ApiException Thrown if the API call fails. - */ - public function update(SqlUsersUpdateRequest $request, array $callOptions = []): Operation - { - return $this->startApiCall('Update', $request, $callOptions)->wait(); - } -} diff --git a/SqlAdmin/src/V1/Client/SqlAvailableDatabaseVersionsServiceClient.php b/SqlAdmin/src/V1/Client/SqlAvailableDatabaseVersionsServiceClient.php index a3a25d52542a..7fc043b32c97 100644 --- a/SqlAdmin/src/V1/Client/SqlAvailableDatabaseVersionsServiceClient.php +++ b/SqlAdmin/src/V1/Client/SqlAvailableDatabaseVersionsServiceClient.php @@ -24,17 +24,118 @@ namespace Google\Cloud\Sql\V1\Client; -use Google\Cloud\Sql\V1\Client\BaseClient\SqlAvailableDatabaseVersionsServiceBaseClient; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; /** - * {@inheritdoc} + * Service Description: Service that exposes Cloud SQL database versions information. This + * service is only used internally. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental */ -final class SqlAvailableDatabaseVersionsServiceClient extends SqlAvailableDatabaseVersionsServiceBaseClient +final class SqlAvailableDatabaseVersionsServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SqlAvailableDatabaseVersionsServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.sql.v1.SqlAvailableDatabaseVersionsService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'sqladmin.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = []; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/sql_available_database_versions_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/sql_available_database_versions_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/sql_available_database_versions_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/sql_available_database_versions_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'sqladmin.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } } diff --git a/SqlAdmin/src/V1/Client/SqlBackupRunsServiceClient.php b/SqlAdmin/src/V1/Client/SqlBackupRunsServiceClient.php index 50ca01cb916c..14b4489e7f6b 100644 --- a/SqlAdmin/src/V1/Client/SqlBackupRunsServiceClient.php +++ b/SqlAdmin/src/V1/Client/SqlBackupRunsServiceClient.php @@ -24,17 +24,252 @@ namespace Google\Cloud\Sql\V1\Client; -use Google\Cloud\Sql\V1\Client\BaseClient\SqlBackupRunsServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Sql\V1\BackupRun; +use Google\Cloud\Sql\V1\BackupRunsListResponse; +use Google\Cloud\Sql\V1\Operation; +use Google\Cloud\Sql\V1\SqlBackupRunsDeleteRequest; +use Google\Cloud\Sql\V1\SqlBackupRunsGetRequest; +use Google\Cloud\Sql\V1\SqlBackupRunsInsertRequest; +use Google\Cloud\Sql\V1\SqlBackupRunsListRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for managing database backups. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface deleteAsync(SqlBackupRunsDeleteRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(SqlBackupRunsGetRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(SqlBackupRunsInsertRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(SqlBackupRunsListRequest $request, array $optionalArgs = []) */ -final class SqlBackupRunsServiceClient extends SqlBackupRunsServiceBaseClient +final class SqlBackupRunsServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SqlBackupRunsServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.sql.v1.SqlBackupRunsService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'sqladmin.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/sqlservice.admin', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/sql_backup_runs_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/sql_backup_runs_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/sql_backup_runs_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/sql_backup_runs_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'sqladmin.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the backup taken by a backup run. + * + * The async variant is {@see SqlBackupRunsServiceClient::deleteAsync()} . + * + * @example samples/V1/SqlBackupRunsServiceClient/delete.php + * + * @param SqlBackupRunsDeleteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(SqlBackupRunsDeleteRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Retrieves a resource containing information about a backup run. + * + * The async variant is {@see SqlBackupRunsServiceClient::getAsync()} . + * + * @example samples/V1/SqlBackupRunsServiceClient/get.php + * + * @param SqlBackupRunsGetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BackupRun + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(SqlBackupRunsGetRequest $request, array $callOptions = []): BackupRun + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a new backup run on demand. + * + * The async variant is {@see SqlBackupRunsServiceClient::insertAsync()} . + * + * @example samples/V1/SqlBackupRunsServiceClient/insert.php + * + * @param SqlBackupRunsInsertRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(SqlBackupRunsInsertRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Lists all backup runs associated with the project or a given instance + * and configuration in the reverse chronological order of the backup + * initiation time. + * + * The async variant is {@see SqlBackupRunsServiceClient::listAsync()} . + * + * @example samples/V1/SqlBackupRunsServiceClient/list.php + * + * @param SqlBackupRunsListRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BackupRunsListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(SqlBackupRunsListRequest $request, array $callOptions = []): BackupRunsListResponse + { + return $this->startApiCall('List', $request, $callOptions)->wait(); + } } diff --git a/SqlAdmin/src/V1/Client/SqlConnectServiceClient.php b/SqlAdmin/src/V1/Client/SqlConnectServiceClient.php index b37dd8adfec4..b95d220391f0 100644 --- a/SqlAdmin/src/V1/Client/SqlConnectServiceClient.php +++ b/SqlAdmin/src/V1/Client/SqlConnectServiceClient.php @@ -24,17 +24,197 @@ namespace Google\Cloud\Sql\V1\Client; -use Google\Cloud\Sql\V1\Client\BaseClient\SqlConnectServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Sql\V1\ConnectSettings; +use Google\Cloud\Sql\V1\GenerateEphemeralCertRequest; +use Google\Cloud\Sql\V1\GenerateEphemeralCertResponse; +use Google\Cloud\Sql\V1\GetConnectSettingsRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Cloud SQL connect service. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface generateEphemeralCertAsync(GenerateEphemeralCertRequest $request, array $optionalArgs = []) + * @method PromiseInterface getConnectSettingsAsync(GetConnectSettingsRequest $request, array $optionalArgs = []) */ -final class SqlConnectServiceClient extends SqlConnectServiceBaseClient +final class SqlConnectServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SqlConnectServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.sql.v1.SqlConnectService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'sqladmin.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/sqlservice.admin', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/sql_connect_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/sql_connect_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/sql_connect_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/sql_connect_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'sqladmin.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Generates a short-lived X509 certificate containing the provided public key + * and signed by a private key specific to the target instance. Users may use + * the certificate to authenticate as themselves when connecting to the + * database. + * + * The async variant is + * {@see SqlConnectServiceClient::generateEphemeralCertAsync()} . + * + * @example samples/V1/SqlConnectServiceClient/generate_ephemeral_cert.php + * + * @param GenerateEphemeralCertRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GenerateEphemeralCertResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function generateEphemeralCert(GenerateEphemeralCertRequest $request, array $callOptions = []): GenerateEphemeralCertResponse + { + return $this->startApiCall('GenerateEphemeralCert', $request, $callOptions)->wait(); + } + + /** + * Retrieves connect settings about a Cloud SQL instance. + * + * The async variant is {@see SqlConnectServiceClient::getConnectSettingsAsync()} . + * + * @example samples/V1/SqlConnectServiceClient/get_connect_settings.php + * + * @param GetConnectSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ConnectSettings + * + * @throws ApiException Thrown if the API call fails. + */ + public function getConnectSettings(GetConnectSettingsRequest $request, array $callOptions = []): ConnectSettings + { + return $this->startApiCall('GetConnectSettings', $request, $callOptions)->wait(); + } } diff --git a/SqlAdmin/src/V1/Client/SqlDatabasesServiceClient.php b/SqlAdmin/src/V1/Client/SqlDatabasesServiceClient.php index 3d0524c9a66f..3c5a403ef3b1 100644 --- a/SqlAdmin/src/V1/Client/SqlDatabasesServiceClient.php +++ b/SqlAdmin/src/V1/Client/SqlDatabasesServiceClient.php @@ -24,17 +24,311 @@ namespace Google\Cloud\Sql\V1\Client; -use Google\Cloud\Sql\V1\Client\BaseClient\SqlDatabasesServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Sql\V1\Database; +use Google\Cloud\Sql\V1\DatabasesListResponse; +use Google\Cloud\Sql\V1\Operation; +use Google\Cloud\Sql\V1\SqlDatabasesDeleteRequest; +use Google\Cloud\Sql\V1\SqlDatabasesGetRequest; +use Google\Cloud\Sql\V1\SqlDatabasesInsertRequest; +use Google\Cloud\Sql\V1\SqlDatabasesListRequest; +use Google\Cloud\Sql\V1\SqlDatabasesUpdateRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service to manage databases. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface deleteAsync(SqlDatabasesDeleteRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(SqlDatabasesGetRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(SqlDatabasesInsertRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(SqlDatabasesListRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(SqlDatabasesUpdateRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAsync(SqlDatabasesUpdateRequest $request, array $optionalArgs = []) */ -final class SqlDatabasesServiceClient extends SqlDatabasesServiceBaseClient +final class SqlDatabasesServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SqlDatabasesServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.sql.v1.SqlDatabasesService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'sqladmin.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/sqlservice.admin', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/sql_databases_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/sql_databases_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/sql_databases_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/sql_databases_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'sqladmin.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes a database from a Cloud SQL instance. + * + * The async variant is {@see SqlDatabasesServiceClient::deleteAsync()} . + * + * @example samples/V1/SqlDatabasesServiceClient/delete.php + * + * @param SqlDatabasesDeleteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(SqlDatabasesDeleteRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Retrieves a resource containing information about a database inside a Cloud + * SQL instance. + * + * The async variant is {@see SqlDatabasesServiceClient::getAsync()} . + * + * @example samples/V1/SqlDatabasesServiceClient/get.php + * + * @param SqlDatabasesGetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Database + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(SqlDatabasesGetRequest $request, array $callOptions = []): Database + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Inserts a resource containing information about a database inside a Cloud + * SQL instance. + * + * **Note:** You can't modify the default character set and collation. + * + * The async variant is {@see SqlDatabasesServiceClient::insertAsync()} . + * + * @example samples/V1/SqlDatabasesServiceClient/insert.php + * + * @param SqlDatabasesInsertRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(SqlDatabasesInsertRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Lists databases in the specified Cloud SQL instance. + * + * The async variant is {@see SqlDatabasesServiceClient::listAsync()} . + * + * @example samples/V1/SqlDatabasesServiceClient/list.php + * + * @param SqlDatabasesListRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DatabasesListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(SqlDatabasesListRequest $request, array $callOptions = []): DatabasesListResponse + { + return $this->startApiCall('List', $request, $callOptions)->wait(); + } + + /** + * Partially updates a resource containing information about a database inside + * a Cloud SQL instance. This method supports patch semantics. + * + * The async variant is {@see SqlDatabasesServiceClient::patchAsync()} . + * + * @example samples/V1/SqlDatabasesServiceClient/patch.php + * + * @param SqlDatabasesUpdateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(SqlDatabasesUpdateRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Updates a resource containing information about a database inside a Cloud + * SQL instance. + * + * The async variant is {@see SqlDatabasesServiceClient::updateAsync()} . + * + * @example samples/V1/SqlDatabasesServiceClient/update.php + * + * @param SqlDatabasesUpdateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function update(SqlDatabasesUpdateRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Update', $request, $callOptions)->wait(); + } } diff --git a/SqlAdmin/src/V1/Client/SqlEventsServiceClient.php b/SqlAdmin/src/V1/Client/SqlEventsServiceClient.php index 7e4e39229e0d..954c963b3f79 100644 --- a/SqlAdmin/src/V1/Client/SqlEventsServiceClient.php +++ b/SqlAdmin/src/V1/Client/SqlEventsServiceClient.php @@ -24,17 +24,118 @@ namespace Google\Cloud\Sql\V1\Client; -use Google\Cloud\Sql\V1\Client\BaseClient\SqlEventsServiceBaseClient; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; /** - * {@inheritdoc} + * Service Description: Service that exposes Cloud SQL event information. This + * service is only used internally. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental */ -final class SqlEventsServiceClient extends SqlEventsServiceBaseClient +final class SqlEventsServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SqlEventsServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.sql.v1.SqlEventsService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'sqladmin.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = []; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/sql_events_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/sql_events_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/sql_events_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/sql_events_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'sqladmin.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } } diff --git a/SqlAdmin/src/V1/Client/SqlFlagsServiceClient.php b/SqlAdmin/src/V1/Client/SqlFlagsServiceClient.php index 8c03c4c461e4..e55050c3ef61 100644 --- a/SqlAdmin/src/V1/Client/SqlFlagsServiceClient.php +++ b/SqlAdmin/src/V1/Client/SqlFlagsServiceClient.php @@ -24,17 +24,164 @@ namespace Google\Cloud\Sql\V1\Client; -use Google\Cloud\Sql\V1\Client\BaseClient\SqlFlagsServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Sql\V1\FlagsListResponse; +use Google\Cloud\Sql\V1\SqlFlagsListRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service to manage database flags for Cloud SQL instances. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface listAsync(SqlFlagsListRequest $request, array $optionalArgs = []) */ -final class SqlFlagsServiceClient extends SqlFlagsServiceBaseClient +final class SqlFlagsServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SqlFlagsServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.sql.v1.SqlFlagsService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'sqladmin.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/sqlservice.admin', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/sql_flags_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/sql_flags_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/sql_flags_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/sql_flags_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'sqladmin.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Lists all available database flags for Cloud SQL instances. + * + * The async variant is {@see SqlFlagsServiceClient::listAsync()} . + * + * @example samples/V1/SqlFlagsServiceClient/list.php + * + * @param SqlFlagsListRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FlagsListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(SqlFlagsListRequest $request, array $callOptions = []): FlagsListResponse + { + return $this->startApiCall('List', $request, $callOptions)->wait(); + } } diff --git a/SqlAdmin/src/V1/Client/SqlIamPoliciesServiceClient.php b/SqlAdmin/src/V1/Client/SqlIamPoliciesServiceClient.php index 6020f00df84e..9d9a8cebe729 100644 --- a/SqlAdmin/src/V1/Client/SqlIamPoliciesServiceClient.php +++ b/SqlAdmin/src/V1/Client/SqlIamPoliciesServiceClient.php @@ -24,17 +24,117 @@ namespace Google\Cloud\Sql\V1\Client; -use Google\Cloud\Sql\V1\Client\BaseClient\SqlIamPoliciesServiceBaseClient; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; /** - * {@inheritdoc} + * Service Description: Service for providing IAM Meta APIs for Cloud SQL. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental */ -final class SqlIamPoliciesServiceClient extends SqlIamPoliciesServiceBaseClient +final class SqlIamPoliciesServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SqlIamPoliciesServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.sql.v1.SqlIamPoliciesService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'sqladmin.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = []; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/sql_iam_policies_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/sql_iam_policies_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/sql_iam_policies_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/sql_iam_policies_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'sqladmin.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } } diff --git a/SqlAdmin/src/V1/Client/SqlInstanceNamesServiceClient.php b/SqlAdmin/src/V1/Client/SqlInstanceNamesServiceClient.php index b35cd45b3563..e7cffbc5b1a0 100644 --- a/SqlAdmin/src/V1/Client/SqlInstanceNamesServiceClient.php +++ b/SqlAdmin/src/V1/Client/SqlInstanceNamesServiceClient.php @@ -24,17 +24,117 @@ namespace Google\Cloud\Sql\V1\Client; -use Google\Cloud\Sql\V1\Client\BaseClient\SqlInstanceNamesServiceBaseClient; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; /** - * {@inheritdoc} + * Service Description: Cloud SQL instance names service. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental */ -final class SqlInstanceNamesServiceClient extends SqlInstanceNamesServiceBaseClient +final class SqlInstanceNamesServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SqlInstanceNamesServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.sql.v1.SqlInstanceNamesService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'sqladmin.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = []; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/sql_instance_names_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/sql_instance_names_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/sql_instance_names_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/sql_instance_names_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'sqladmin.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } } diff --git a/SqlAdmin/src/V1/Client/SqlInstancesServiceClient.php b/SqlAdmin/src/V1/Client/SqlInstancesServiceClient.php index 5c9c477cc918..6884fec72edf 100644 --- a/SqlAdmin/src/V1/Client/SqlInstancesServiceClient.php +++ b/SqlAdmin/src/V1/Client/SqlInstancesServiceClient.php @@ -24,17 +24,1018 @@ namespace Google\Cloud\Sql\V1\Client; -use Google\Cloud\Sql\V1\Client\BaseClient\SqlInstancesServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Sql\V1\DatabaseInstance; +use Google\Cloud\Sql\V1\InstancesListResponse; +use Google\Cloud\Sql\V1\InstancesListServerCasResponse; +use Google\Cloud\Sql\V1\Operation; +use Google\Cloud\Sql\V1\SqlInstancesAddServerCaRequest; +use Google\Cloud\Sql\V1\SqlInstancesCloneRequest; +use Google\Cloud\Sql\V1\SqlInstancesCreateEphemeralCertRequest; +use Google\Cloud\Sql\V1\SqlInstancesDeleteRequest; +use Google\Cloud\Sql\V1\SqlInstancesDemoteMasterRequest; +use Google\Cloud\Sql\V1\SqlInstancesExportRequest; +use Google\Cloud\Sql\V1\SqlInstancesFailoverRequest; +use Google\Cloud\Sql\V1\SqlInstancesGetDiskShrinkConfigRequest; +use Google\Cloud\Sql\V1\SqlInstancesGetDiskShrinkConfigResponse; +use Google\Cloud\Sql\V1\SqlInstancesGetLatestRecoveryTimeRequest; +use Google\Cloud\Sql\V1\SqlInstancesGetLatestRecoveryTimeResponse; +use Google\Cloud\Sql\V1\SqlInstancesGetRequest; +use Google\Cloud\Sql\V1\SqlInstancesImportRequest; +use Google\Cloud\Sql\V1\SqlInstancesInsertRequest; +use Google\Cloud\Sql\V1\SqlInstancesListRequest; +use Google\Cloud\Sql\V1\SqlInstancesListServerCasRequest; +use Google\Cloud\Sql\V1\SqlInstancesPatchRequest; +use Google\Cloud\Sql\V1\SqlInstancesPerformDiskShrinkRequest; +use Google\Cloud\Sql\V1\SqlInstancesPromoteReplicaRequest; +use Google\Cloud\Sql\V1\SqlInstancesReencryptRequest; +use Google\Cloud\Sql\V1\SqlInstancesRescheduleMaintenanceRequest; +use Google\Cloud\Sql\V1\SqlInstancesResetReplicaSizeRequest; +use Google\Cloud\Sql\V1\SqlInstancesResetSslConfigRequest; +use Google\Cloud\Sql\V1\SqlInstancesRestartRequest; +use Google\Cloud\Sql\V1\SqlInstancesRestoreBackupRequest; +use Google\Cloud\Sql\V1\SqlInstancesRotateServerCaRequest; +use Google\Cloud\Sql\V1\SqlInstancesStartExternalSyncRequest; +use Google\Cloud\Sql\V1\SqlInstancesStartReplicaRequest; +use Google\Cloud\Sql\V1\SqlInstancesStopReplicaRequest; +use Google\Cloud\Sql\V1\SqlInstancesTruncateLogRequest; +use Google\Cloud\Sql\V1\SqlInstancesUpdateRequest; +use Google\Cloud\Sql\V1\SqlInstancesVerifyExternalSyncSettingsRequest; +use Google\Cloud\Sql\V1\SqlInstancesVerifyExternalSyncSettingsResponse; +use Google\Cloud\Sql\V1\SslCert; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service to manage Cloud SQL instances. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface addServerCaAsync(SqlInstancesAddServerCaRequest $request, array $optionalArgs = []) + * @method PromiseInterface cloneAsync(SqlInstancesCloneRequest $request, array $optionalArgs = []) + * @method PromiseInterface createEphemeralAsync(SqlInstancesCreateEphemeralCertRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAsync(SqlInstancesDeleteRequest $request, array $optionalArgs = []) + * @method PromiseInterface demoteMasterAsync(SqlInstancesDemoteMasterRequest $request, array $optionalArgs = []) + * @method PromiseInterface exportAsync(SqlInstancesExportRequest $request, array $optionalArgs = []) + * @method PromiseInterface failoverAsync(SqlInstancesFailoverRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(SqlInstancesGetRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDiskShrinkConfigAsync(SqlInstancesGetDiskShrinkConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLatestRecoveryTimeAsync(SqlInstancesGetLatestRecoveryTimeRequest $request, array $optionalArgs = []) + * @method PromiseInterface importAsync(SqlInstancesImportRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(SqlInstancesInsertRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(SqlInstancesListRequest $request, array $optionalArgs = []) + * @method PromiseInterface listServerCasAsync(SqlInstancesListServerCasRequest $request, array $optionalArgs = []) + * @method PromiseInterface patchAsync(SqlInstancesPatchRequest $request, array $optionalArgs = []) + * @method PromiseInterface performDiskShrinkAsync(SqlInstancesPerformDiskShrinkRequest $request, array $optionalArgs = []) + * @method PromiseInterface promoteReplicaAsync(SqlInstancesPromoteReplicaRequest $request, array $optionalArgs = []) + * @method PromiseInterface reencryptAsync(SqlInstancesReencryptRequest $request, array $optionalArgs = []) + * @method PromiseInterface rescheduleMaintenanceAsync(SqlInstancesRescheduleMaintenanceRequest $request, array $optionalArgs = []) + * @method PromiseInterface resetReplicaSizeAsync(SqlInstancesResetReplicaSizeRequest $request, array $optionalArgs = []) + * @method PromiseInterface resetSslConfigAsync(SqlInstancesResetSslConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface restartAsync(SqlInstancesRestartRequest $request, array $optionalArgs = []) + * @method PromiseInterface restoreBackupAsync(SqlInstancesRestoreBackupRequest $request, array $optionalArgs = []) + * @method PromiseInterface rotateServerCaAsync(SqlInstancesRotateServerCaRequest $request, array $optionalArgs = []) + * @method PromiseInterface startExternalSyncAsync(SqlInstancesStartExternalSyncRequest $request, array $optionalArgs = []) + * @method PromiseInterface startReplicaAsync(SqlInstancesStartReplicaRequest $request, array $optionalArgs = []) + * @method PromiseInterface stopReplicaAsync(SqlInstancesStopReplicaRequest $request, array $optionalArgs = []) + * @method PromiseInterface truncateLogAsync(SqlInstancesTruncateLogRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAsync(SqlInstancesUpdateRequest $request, array $optionalArgs = []) + * @method PromiseInterface verifyExternalSyncSettingsAsync(SqlInstancesVerifyExternalSyncSettingsRequest $request, array $optionalArgs = []) */ -final class SqlInstancesServiceClient extends SqlInstancesServiceBaseClient +final class SqlInstancesServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SqlInstancesServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.sql.v1.SqlInstancesService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'sqladmin.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/sqlservice.admin', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/sql_instances_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/sql_instances_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/sql_instances_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/sql_instances_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'sqladmin.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Adds a new trusted Certificate Authority (CA) version for the specified + * instance. Required to prepare for a certificate rotation. If a CA version + * was previously added but never used in a certificate rotation, this + * operation replaces that version. There cannot be more than one CA version + * waiting to be rotated in. + * + * The async variant is {@see SqlInstancesServiceClient::addServerCaAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/add_server_ca.php + * + * @param SqlInstancesAddServerCaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function addServerCa(SqlInstancesAddServerCaRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('AddServerCa', $request, $callOptions)->wait(); + } + + /** + * Creates a Cloud SQL instance as a clone of the source instance. Using this + * operation might cause your instance to restart. + * + * The async variant is {@see SqlInstancesServiceClient::cloneAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/clone.php + * + * @param SqlInstancesCloneRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function clone(SqlInstancesCloneRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Clone', $request, $callOptions)->wait(); + } + + /** + * Generates a short-lived X509 certificate containing the provided public key + * and signed by a private key specific to the target instance. Users may use + * the certificate to authenticate as themselves when connecting to the + * database. + * + * The async variant is {@see SqlInstancesServiceClient::createEphemeralAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/create_ephemeral.php + * + * @param SqlInstancesCreateEphemeralCertRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SslCert + * + * @throws ApiException Thrown if the API call fails. + */ + public function createEphemeral(SqlInstancesCreateEphemeralCertRequest $request, array $callOptions = []): SslCert + { + return $this->startApiCall('CreateEphemeral', $request, $callOptions)->wait(); + } + + /** + * Deletes a Cloud SQL instance. + * + * The async variant is {@see SqlInstancesServiceClient::deleteAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/delete.php + * + * @param SqlInstancesDeleteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(SqlInstancesDeleteRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Demotes the stand-alone instance to be a Cloud SQL read replica for an + * external database server. + * + * The async variant is {@see SqlInstancesServiceClient::demoteMasterAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/demote_master.php + * + * @param SqlInstancesDemoteMasterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function demoteMaster(SqlInstancesDemoteMasterRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('DemoteMaster', $request, $callOptions)->wait(); + } + + /** + * Exports data from a Cloud SQL instance to a Cloud Storage bucket as a SQL + * dump or CSV file. + * + * The async variant is {@see SqlInstancesServiceClient::exportAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/export.php + * + * @param SqlInstancesExportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function export(SqlInstancesExportRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Export', $request, $callOptions)->wait(); + } + + /** + * Initiates a manual failover of a high availability (HA) primary instance + * to a standby instance, which becomes the primary instance. Users are + * then rerouted to the new primary. For more information, see the + * [Overview of high + * availability](https://cloud.google.com/sql/docs/mysql/high-availability) + * page in the Cloud SQL documentation. + * If using Legacy HA (MySQL only), this causes the instance to failover to + * its failover replica instance. + * + * The async variant is {@see SqlInstancesServiceClient::failoverAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/failover.php + * + * @param SqlInstancesFailoverRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function failover(SqlInstancesFailoverRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Failover', $request, $callOptions)->wait(); + } + + /** + * Retrieves a resource containing information about a Cloud SQL instance. + * + * The async variant is {@see SqlInstancesServiceClient::getAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/get.php + * + * @param SqlInstancesGetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DatabaseInstance + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(SqlInstancesGetRequest $request, array $callOptions = []): DatabaseInstance + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Get Disk Shrink Config for a given instance. + * + * The async variant is + * {@see SqlInstancesServiceClient::getDiskShrinkConfigAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/get_disk_shrink_config.php + * + * @param SqlInstancesGetDiskShrinkConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SqlInstancesGetDiskShrinkConfigResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDiskShrinkConfig(SqlInstancesGetDiskShrinkConfigRequest $request, array $callOptions = []): SqlInstancesGetDiskShrinkConfigResponse + { + return $this->startApiCall('GetDiskShrinkConfig', $request, $callOptions)->wait(); + } + + /** + * Get Latest Recovery Time for a given instance. + * + * The async variant is + * {@see SqlInstancesServiceClient::getLatestRecoveryTimeAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/get_latest_recovery_time.php + * + * @param SqlInstancesGetLatestRecoveryTimeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SqlInstancesGetLatestRecoveryTimeResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLatestRecoveryTime(SqlInstancesGetLatestRecoveryTimeRequest $request, array $callOptions = []): SqlInstancesGetLatestRecoveryTimeResponse + { + return $this->startApiCall('GetLatestRecoveryTime', $request, $callOptions)->wait(); + } + + /** + * Imports data into a Cloud SQL instance from a SQL dump or CSV file in + * Cloud Storage. + * + * The async variant is {@see SqlInstancesServiceClient::importAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/import.php + * + * @param SqlInstancesImportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function import(SqlInstancesImportRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Import', $request, $callOptions)->wait(); + } + + /** + * Creates a new Cloud SQL instance. + * + * The async variant is {@see SqlInstancesServiceClient::insertAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/insert.php + * + * @param SqlInstancesInsertRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(SqlInstancesInsertRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Lists instances under a given project. + * + * The async variant is {@see SqlInstancesServiceClient::listAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/list.php + * + * @param SqlInstancesListRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InstancesListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(SqlInstancesListRequest $request, array $callOptions = []): InstancesListResponse + { + return $this->startApiCall('List', $request, $callOptions)->wait(); + } + + /** + * Lists all of the trusted Certificate Authorities (CAs) for the specified + * instance. There can be up to three CAs listed: the CA that was used to sign + * the certificate that is currently in use, a CA that has been added but not + * yet used to sign a certificate, and a CA used to sign a certificate that + * has previously rotated out. + * + * The async variant is {@see SqlInstancesServiceClient::listServerCasAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/list_server_cas.php + * + * @param SqlInstancesListServerCasRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 InstancesListServerCasResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listServerCas(SqlInstancesListServerCasRequest $request, array $callOptions = []): InstancesListServerCasResponse + { + return $this->startApiCall('ListServerCas', $request, $callOptions)->wait(); + } + + /** + * Partially updates settings of a Cloud SQL instance by merging the request + * with the current configuration. This method supports patch semantics. + * + * The async variant is {@see SqlInstancesServiceClient::patchAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/patch.php + * + * @param SqlInstancesPatchRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function patch(SqlInstancesPatchRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Patch', $request, $callOptions)->wait(); + } + + /** + * Perform Disk Shrink on primary instance. + * + * The async variant is {@see SqlInstancesServiceClient::performDiskShrinkAsync()} + * . + * + * @example samples/V1/SqlInstancesServiceClient/perform_disk_shrink.php + * + * @param SqlInstancesPerformDiskShrinkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function performDiskShrink(SqlInstancesPerformDiskShrinkRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('PerformDiskShrink', $request, $callOptions)->wait(); + } + + /** + * Promotes the read replica instance to be a stand-alone Cloud SQL instance. + * Using this operation might cause your instance to restart. + * + * The async variant is {@see SqlInstancesServiceClient::promoteReplicaAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/promote_replica.php + * + * @param SqlInstancesPromoteReplicaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function promoteReplica(SqlInstancesPromoteReplicaRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('PromoteReplica', $request, $callOptions)->wait(); + } + + /** + * Reencrypt CMEK instance with latest key version. + * + * The async variant is {@see SqlInstancesServiceClient::reencryptAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/reencrypt.php + * + * @param SqlInstancesReencryptRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function reencrypt(SqlInstancesReencryptRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Reencrypt', $request, $callOptions)->wait(); + } + + /** + * Reschedules the maintenance on the given instance. + * + * The async variant is + * {@see SqlInstancesServiceClient::rescheduleMaintenanceAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/reschedule_maintenance.php + * + * @param SqlInstancesRescheduleMaintenanceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function rescheduleMaintenance(SqlInstancesRescheduleMaintenanceRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('RescheduleMaintenance', $request, $callOptions)->wait(); + } + + /** + * Reset Replica Size to primary instance disk size. + * + * The async variant is {@see SqlInstancesServiceClient::resetReplicaSizeAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/reset_replica_size.php + * + * @param SqlInstancesResetReplicaSizeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function resetReplicaSize(SqlInstancesResetReplicaSizeRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('ResetReplicaSize', $request, $callOptions)->wait(); + } + + /** + * Deletes all client certificates and generates a new server SSL certificate + * for the instance. + * + * The async variant is {@see SqlInstancesServiceClient::resetSslConfigAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/reset_ssl_config.php + * + * @param SqlInstancesResetSslConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function resetSslConfig(SqlInstancesResetSslConfigRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('ResetSslConfig', $request, $callOptions)->wait(); + } + + /** + * Restarts a Cloud SQL instance. + * + * The async variant is {@see SqlInstancesServiceClient::restartAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/restart.php + * + * @param SqlInstancesRestartRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function restart(SqlInstancesRestartRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Restart', $request, $callOptions)->wait(); + } + + /** + * Restores a backup of a Cloud SQL instance. Using this operation might cause + * your instance to restart. + * + * The async variant is {@see SqlInstancesServiceClient::restoreBackupAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/restore_backup.php + * + * @param SqlInstancesRestoreBackupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function restoreBackup(SqlInstancesRestoreBackupRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('RestoreBackup', $request, $callOptions)->wait(); + } + + /** + * Rotates the server certificate to one signed by the Certificate Authority + * (CA) version previously added with the addServerCA method. + * + * The async variant is {@see SqlInstancesServiceClient::rotateServerCaAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/rotate_server_ca.php + * + * @param SqlInstancesRotateServerCaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function rotateServerCa(SqlInstancesRotateServerCaRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('RotateServerCa', $request, $callOptions)->wait(); + } + + /** + * Start External primary instance migration. + * + * The async variant is {@see SqlInstancesServiceClient::startExternalSyncAsync()} + * . + * + * @example samples/V1/SqlInstancesServiceClient/start_external_sync.php + * + * @param SqlInstancesStartExternalSyncRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function startExternalSync(SqlInstancesStartExternalSyncRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('StartExternalSync', $request, $callOptions)->wait(); + } + + /** + * Starts the replication in the read replica instance. + * + * The async variant is {@see SqlInstancesServiceClient::startReplicaAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/start_replica.php + * + * @param SqlInstancesStartReplicaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function startReplica(SqlInstancesStartReplicaRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('StartReplica', $request, $callOptions)->wait(); + } + + /** + * Stops the replication in the read replica instance. + * + * The async variant is {@see SqlInstancesServiceClient::stopReplicaAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/stop_replica.php + * + * @param SqlInstancesStopReplicaRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function stopReplica(SqlInstancesStopReplicaRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('StopReplica', $request, $callOptions)->wait(); + } + + /** + * Truncate MySQL general and slow query log tables + * MySQL only. + * + * The async variant is {@see SqlInstancesServiceClient::truncateLogAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/truncate_log.php + * + * @param SqlInstancesTruncateLogRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function truncateLog(SqlInstancesTruncateLogRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('TruncateLog', $request, $callOptions)->wait(); + } + + /** + * Updates settings of a Cloud SQL instance. Using this operation might cause + * your instance to restart. + * + * The async variant is {@see SqlInstancesServiceClient::updateAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/update.php + * + * @param SqlInstancesUpdateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function update(SqlInstancesUpdateRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Update', $request, $callOptions)->wait(); + } + + /** + * Verify External primary instance external sync settings. + * + * The async variant is + * {@see SqlInstancesServiceClient::verifyExternalSyncSettingsAsync()} . + * + * @example samples/V1/SqlInstancesServiceClient/verify_external_sync_settings.php + * + * @param SqlInstancesVerifyExternalSyncSettingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SqlInstancesVerifyExternalSyncSettingsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function verifyExternalSyncSettings(SqlInstancesVerifyExternalSyncSettingsRequest $request, array $callOptions = []): SqlInstancesVerifyExternalSyncSettingsResponse + { + return $this->startApiCall('VerifyExternalSyncSettings', $request, $callOptions)->wait(); + } } diff --git a/SqlAdmin/src/V1/Client/SqlOperationsServiceClient.php b/SqlAdmin/src/V1/Client/SqlOperationsServiceClient.php index 4b088df4a915..ddb1eb6f9776 100644 --- a/SqlAdmin/src/V1/Client/SqlOperationsServiceClient.php +++ b/SqlAdmin/src/V1/Client/SqlOperationsServiceClient.php @@ -24,17 +24,220 @@ namespace Google\Cloud\Sql\V1\Client; -use Google\Cloud\Sql\V1\Client\BaseClient\SqlOperationsServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Sql\V1\Operation; +use Google\Cloud\Sql\V1\OperationsListResponse; +use Google\Cloud\Sql\V1\SqlOperationsCancelRequest; +use Google\Cloud\Sql\V1\SqlOperationsGetRequest; +use Google\Cloud\Sql\V1\SqlOperationsListRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service to fetch operations for database instances. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface cancelAsync(SqlOperationsCancelRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(SqlOperationsGetRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(SqlOperationsListRequest $request, array $optionalArgs = []) */ -final class SqlOperationsServiceClient extends SqlOperationsServiceBaseClient +final class SqlOperationsServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SqlOperationsServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.sql.v1.SqlOperationsService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'sqladmin.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/sqlservice.admin', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/sql_operations_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/sql_operations_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/sql_operations_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/sql_operations_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'sqladmin.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Cancels an instance operation that has been performed on an instance. + * + * The async variant is {@see SqlOperationsServiceClient::cancelAsync()} . + * + * @example samples/V1/SqlOperationsServiceClient/cancel.php + * + * @param SqlOperationsCancelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function cancel(SqlOperationsCancelRequest $request, array $callOptions = []): void + { + $this->startApiCall('Cancel', $request, $callOptions)->wait(); + } + + /** + * Retrieves an instance operation that has been performed on an instance. + * + * The async variant is {@see SqlOperationsServiceClient::getAsync()} . + * + * @example samples/V1/SqlOperationsServiceClient/get.php + * + * @param SqlOperationsGetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(SqlOperationsGetRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Lists all instance operations that have been performed on the given Cloud + * SQL instance in the reverse chronological order of the start time. + * + * The async variant is {@see SqlOperationsServiceClient::listAsync()} . + * + * @example samples/V1/SqlOperationsServiceClient/list.php + * + * @param SqlOperationsListRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationsListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(SqlOperationsListRequest $request, array $callOptions = []): OperationsListResponse + { + return $this->startApiCall('List', $request, $callOptions)->wait(); + } } diff --git a/SqlAdmin/src/V1/Client/SqlRegionsServiceClient.php b/SqlAdmin/src/V1/Client/SqlRegionsServiceClient.php index b7039bd8598b..3d6e013c2924 100644 --- a/SqlAdmin/src/V1/Client/SqlRegionsServiceClient.php +++ b/SqlAdmin/src/V1/Client/SqlRegionsServiceClient.php @@ -24,17 +24,118 @@ namespace Google\Cloud\Sql\V1\Client; -use Google\Cloud\Sql\V1\Client\BaseClient\SqlRegionsServiceBaseClient; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; /** - * {@inheritdoc} + * Service Description: Service that exposes Cloud SQL region information. This service is only used + * internally and does not follow the same patterns as the other v1 RPCs. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental */ -final class SqlRegionsServiceClient extends SqlRegionsServiceBaseClient +final class SqlRegionsServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SqlRegionsServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.sql.v1.SqlRegionsService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'sqladmin.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = []; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/sql_regions_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/sql_regions_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/sql_regions_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/sql_regions_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'sqladmin.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } } diff --git a/SqlAdmin/src/V1/Client/SqlSslCertsServiceClient.php b/SqlAdmin/src/V1/Client/SqlSslCertsServiceClient.php index fca84afe376e..04ef945cc840 100644 --- a/SqlAdmin/src/V1/Client/SqlSslCertsServiceClient.php +++ b/SqlAdmin/src/V1/Client/SqlSslCertsServiceClient.php @@ -24,17 +24,256 @@ namespace Google\Cloud\Sql\V1\Client; -use Google\Cloud\Sql\V1\Client\BaseClient\SqlSslCertsServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Sql\V1\Operation; +use Google\Cloud\Sql\V1\SqlSslCertsDeleteRequest; +use Google\Cloud\Sql\V1\SqlSslCertsGetRequest; +use Google\Cloud\Sql\V1\SqlSslCertsInsertRequest; +use Google\Cloud\Sql\V1\SqlSslCertsListRequest; +use Google\Cloud\Sql\V1\SslCert; +use Google\Cloud\Sql\V1\SslCertsInsertResponse; +use Google\Cloud\Sql\V1\SslCertsListResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service to manage SSL certs for Cloud SQL instances. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface deleteAsync(SqlSslCertsDeleteRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(SqlSslCertsGetRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(SqlSslCertsInsertRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(SqlSslCertsListRequest $request, array $optionalArgs = []) */ -final class SqlSslCertsServiceClient extends SqlSslCertsServiceBaseClient +final class SqlSslCertsServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SqlSslCertsServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.sql.v1.SqlSslCertsService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'sqladmin.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/sqlservice.admin', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/sql_ssl_certs_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/sql_ssl_certs_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/sql_ssl_certs_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/sql_ssl_certs_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'sqladmin.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes the SSL certificate. For First Generation instances, the + * certificate remains valid until the instance is restarted. + * + * The async variant is {@see SqlSslCertsServiceClient::deleteAsync()} . + * + * @example samples/V1/SqlSslCertsServiceClient/delete.php + * + * @param SqlSslCertsDeleteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(SqlSslCertsDeleteRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Retrieves a particular SSL certificate. Does not include the private key + * (required for usage). The private key must be saved from the response to + * initial creation. + * + * The async variant is {@see SqlSslCertsServiceClient::getAsync()} . + * + * @example samples/V1/SqlSslCertsServiceClient/get.php + * + * @param SqlSslCertsGetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SslCert + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(SqlSslCertsGetRequest $request, array $callOptions = []): SslCert + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates an SSL certificate and returns it along with the private key and + * server certificate authority. The new certificate will not be usable until + * the instance is restarted. + * + * The async variant is {@see SqlSslCertsServiceClient::insertAsync()} . + * + * @example samples/V1/SqlSslCertsServiceClient/insert.php + * + * @param SqlSslCertsInsertRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SslCertsInsertResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(SqlSslCertsInsertRequest $request, array $callOptions = []): SslCertsInsertResponse + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Lists all of the current SSL certificates for the instance. + * + * The async variant is {@see SqlSslCertsServiceClient::listAsync()} . + * + * @example samples/V1/SqlSslCertsServiceClient/list.php + * + * @param SqlSslCertsListRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SslCertsListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(SqlSslCertsListRequest $request, array $callOptions = []): SslCertsListResponse + { + return $this->startApiCall('List', $request, $callOptions)->wait(); + } } diff --git a/SqlAdmin/src/V1/Client/SqlTiersServiceClient.php b/SqlAdmin/src/V1/Client/SqlTiersServiceClient.php index 742d4e1ce041..e20b84bee8fb 100644 --- a/SqlAdmin/src/V1/Client/SqlTiersServiceClient.php +++ b/SqlAdmin/src/V1/Client/SqlTiersServiceClient.php @@ -24,17 +24,166 @@ namespace Google\Cloud\Sql\V1\Client; -use Google\Cloud\Sql\V1\Client\BaseClient\SqlTiersServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Sql\V1\SqlTiersListRequest; +use Google\Cloud\Sql\V1\TiersListResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for providing machine types (tiers) for Cloud SQL instances. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface listAsync(SqlTiersListRequest $request, array $optionalArgs = []) */ -final class SqlTiersServiceClient extends SqlTiersServiceBaseClient +final class SqlTiersServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SqlTiersServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.sql.v1.SqlTiersService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'sqladmin.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/sqlservice.admin', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/sql_tiers_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/sql_tiers_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/sql_tiers_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/sql_tiers_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'sqladmin.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Lists all available machine types (tiers) for Cloud SQL, for example, + * `db-custom-1-3840`. For more information, see + * https://cloud.google.com/sql/pricing. + * + * The async variant is {@see SqlTiersServiceClient::listAsync()} . + * + * @example samples/V1/SqlTiersServiceClient/list.php + * + * @param SqlTiersListRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TiersListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(SqlTiersListRequest $request, array $callOptions = []): TiersListResponse + { + return $this->startApiCall('List', $request, $callOptions)->wait(); + } } diff --git a/SqlAdmin/src/V1/Client/SqlUsersServiceClient.php b/SqlAdmin/src/V1/Client/SqlUsersServiceClient.php index 176f0bd8ffd7..aa71984bf03b 100644 --- a/SqlAdmin/src/V1/Client/SqlUsersServiceClient.php +++ b/SqlAdmin/src/V1/Client/SqlUsersServiceClient.php @@ -24,17 +24,278 @@ namespace Google\Cloud\Sql\V1\Client; -use Google\Cloud\Sql\V1\Client\BaseClient\SqlUsersServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Sql\V1\Operation; +use Google\Cloud\Sql\V1\SqlUsersDeleteRequest; +use Google\Cloud\Sql\V1\SqlUsersGetRequest; +use Google\Cloud\Sql\V1\SqlUsersInsertRequest; +use Google\Cloud\Sql\V1\SqlUsersListRequest; +use Google\Cloud\Sql\V1\SqlUsersUpdateRequest; +use Google\Cloud\Sql\V1\User; +use Google\Cloud\Sql\V1\UsersListResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Cloud SQL users service. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface deleteAsync(SqlUsersDeleteRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAsync(SqlUsersGetRequest $request, array $optionalArgs = []) + * @method PromiseInterface insertAsync(SqlUsersInsertRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAsync(SqlUsersListRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAsync(SqlUsersUpdateRequest $request, array $optionalArgs = []) */ -final class SqlUsersServiceClient extends SqlUsersServiceBaseClient +final class SqlUsersServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see SqlUsersServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.sql.v1.SqlUsersService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'sqladmin.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/sqlservice.admin', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/sql_users_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/sql_users_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/sql_users_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/sql_users_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'sqladmin.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Deletes a user from a Cloud SQL instance. + * + * The async variant is {@see SqlUsersServiceClient::deleteAsync()} . + * + * @example samples/V1/SqlUsersServiceClient/delete.php + * + * @param SqlUsersDeleteRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function delete(SqlUsersDeleteRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Delete', $request, $callOptions)->wait(); + } + + /** + * Retrieves a resource containing information about a user. + * + * The async variant is {@see SqlUsersServiceClient::getAsync()} . + * + * @example samples/V1/SqlUsersServiceClient/get.php + * + * @param SqlUsersGetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 User + * + * @throws ApiException Thrown if the API call fails. + */ + public function get(SqlUsersGetRequest $request, array $callOptions = []): User + { + return $this->startApiCall('Get', $request, $callOptions)->wait(); + } + + /** + * Creates a new user in a Cloud SQL instance. + * + * The async variant is {@see SqlUsersServiceClient::insertAsync()} . + * + * @example samples/V1/SqlUsersServiceClient/insert.php + * + * @param SqlUsersInsertRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function insert(SqlUsersInsertRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Insert', $request, $callOptions)->wait(); + } + + /** + * Lists users in the specified Cloud SQL instance. + * + * The async variant is {@see SqlUsersServiceClient::listAsync()} . + * + * @example samples/V1/SqlUsersServiceClient/list.php + * + * @param SqlUsersListRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 UsersListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function list(SqlUsersListRequest $request, array $callOptions = []): UsersListResponse + { + return $this->startApiCall('List', $request, $callOptions)->wait(); + } + + /** + * Updates an existing user in a Cloud SQL instance. + * + * The async variant is {@see SqlUsersServiceClient::updateAsync()} . + * + * @example samples/V1/SqlUsersServiceClient/update.php + * + * @param SqlUsersUpdateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Operation + * + * @throws ApiException Thrown if the API call fails. + */ + public function update(SqlUsersUpdateRequest $request, array $callOptions = []): Operation + { + return $this->startApiCall('Update', $request, $callOptions)->wait(); + } } diff --git a/SqlAdmin/src/V1/DatabaseInstance.php b/SqlAdmin/src/V1/DatabaseInstance.php index 424db0fa0446..cf7188c453a3 100644 --- a/SqlAdmin/src/V1/DatabaseInstance.php +++ b/SqlAdmin/src/V1/DatabaseInstance.php @@ -283,6 +283,12 @@ class DatabaseInstance extends \Google\Protobuf\Internal\Message * Generated from protobuf field optional string dns_name = 49 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ private $dns_name = null; + /** + * Output only. The dns name of the primary instance in a replication group. + * + * Generated from protobuf field optional string primary_dns_name = 51 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $primary_dns_name = null; /** * Constructor. @@ -403,6 +409,8 @@ class DatabaseInstance extends \Google\Protobuf\Internal\Message * Output only. The link to service attachment of PSC instance. * @type string $dns_name * Output only. The dns name of the instance. + * @type string $primary_dns_name + * Output only. The dns name of the primary instance in a replication group. * } */ public function __construct($data = NULL) { @@ -1733,5 +1741,41 @@ public function setDnsName($var) return $this; } + /** + * Output only. The dns name of the primary instance in a replication group. + * + * Generated from protobuf field optional string primary_dns_name = 51 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getPrimaryDnsName() + { + return isset($this->primary_dns_name) ? $this->primary_dns_name : ''; + } + + public function hasPrimaryDnsName() + { + return isset($this->primary_dns_name); + } + + public function clearPrimaryDnsName() + { + unset($this->primary_dns_name); + } + + /** + * Output only. The dns name of the primary instance in a replication group. + * + * Generated from protobuf field optional string primary_dns_name = 51 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setPrimaryDnsName($var) + { + GPBUtil::checkString($var, True); + $this->primary_dns_name = $var; + + return $this; + } + } diff --git a/SqlAdmin/src/V1/SqlInstancesStartExternalSyncRequest/ExternalSyncParallelLevel.php b/SqlAdmin/src/V1/ExternalSyncParallelLevel.php similarity index 90% rename from SqlAdmin/src/V1/SqlInstancesStartExternalSyncRequest/ExternalSyncParallelLevel.php rename to SqlAdmin/src/V1/ExternalSyncParallelLevel.php index 7dc7f64921eb..c3d02dee27f5 100644 --- a/SqlAdmin/src/V1/SqlInstancesStartExternalSyncRequest/ExternalSyncParallelLevel.php +++ b/SqlAdmin/src/V1/ExternalSyncParallelLevel.php @@ -2,14 +2,14 @@ # Generated by the protocol buffer compiler. DO NOT EDIT! # source: google/cloud/sql/v1/cloud_sql_instances.proto -namespace Google\Cloud\Sql\V1\SqlInstancesStartExternalSyncRequest; +namespace Google\Cloud\Sql\V1; use UnexpectedValueException; /** * External Sync parallel level. * - * Protobuf type google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest.ExternalSyncParallelLevel + * Protobuf type google.cloud.sql.v1.ExternalSyncParallelLevel */ class ExternalSyncParallelLevel { @@ -66,4 +66,3 @@ public static function value($name) } } - diff --git a/SqlAdmin/src/V1/LocationPreference.php b/SqlAdmin/src/V1/LocationPreference.php index 4a977e012b37..a92e75a3fa80 100644 --- a/SqlAdmin/src/V1/LocationPreference.php +++ b/SqlAdmin/src/V1/LocationPreference.php @@ -36,6 +36,7 @@ class LocationPreference extends \Google\Protobuf\Internal\Message /** * The preferred Compute Engine zone for the secondary/failover * (for example: us-central1-a, us-central1-b, etc.). + * To disable this field, set it to 'no_secondary_zone'. * * Generated from protobuf field string secondary_zone = 4; */ @@ -62,6 +63,7 @@ class LocationPreference extends \Google\Protobuf\Internal\Message * @type string $secondary_zone * The preferred Compute Engine zone for the secondary/failover * (for example: us-central1-a, us-central1-b, etc.). + * To disable this field, set it to 'no_secondary_zone'. * @type string $kind * This is always `sql#locationPreference`. * } @@ -134,6 +136,7 @@ public function setZone($var) /** * The preferred Compute Engine zone for the secondary/failover * (for example: us-central1-a, us-central1-b, etc.). + * To disable this field, set it to 'no_secondary_zone'. * * Generated from protobuf field string secondary_zone = 4; * @return string @@ -146,6 +149,7 @@ public function getSecondaryZone() /** * The preferred Compute Engine zone for the secondary/failover * (for example: us-central1-a, us-central1-b, etc.). + * To disable this field, set it to 'no_secondary_zone'. * * Generated from protobuf field string secondary_zone = 4; * @param string $var diff --git a/SqlAdmin/src/V1/PscConfig.php b/SqlAdmin/src/V1/PscConfig.php index 072e67557321..73a9d8e00ac4 100644 --- a/SqlAdmin/src/V1/PscConfig.php +++ b/SqlAdmin/src/V1/PscConfig.php @@ -22,9 +22,9 @@ class PscConfig extends \Google\Protobuf\Internal\Message */ private $psc_enabled = null; /** - * List of consumer projects that are allow-listed for PSC connections to this - * instance. This instance can be connected to with PSC from any network in - * these projects. + * The list of consumer projects that are allow-listed for PSC connections to + * this instance. This instance can be connected to with PSC from any network + * in these projects. * Each consumer project in this list may be represented by a project number * (numeric) or by a project id (alphanumeric). * @@ -41,9 +41,9 @@ class PscConfig extends \Google\Protobuf\Internal\Message * @type bool $psc_enabled * Whether PSC connectivity is enabled for this instance. * @type array|\Google\Protobuf\Internal\RepeatedField $allowed_consumer_projects - * List of consumer projects that are allow-listed for PSC connections to this - * instance. This instance can be connected to with PSC from any network in - * these projects. + * The list of consumer projects that are allow-listed for PSC connections to + * this instance. This instance can be connected to with PSC from any network + * in these projects. * Each consumer project in this list may be represented by a project number * (numeric) or by a project id (alphanumeric). * } @@ -90,9 +90,9 @@ public function setPscEnabled($var) } /** - * List of consumer projects that are allow-listed for PSC connections to this - * instance. This instance can be connected to with PSC from any network in - * these projects. + * The list of consumer projects that are allow-listed for PSC connections to + * this instance. This instance can be connected to with PSC from any network + * in these projects. * Each consumer project in this list may be represented by a project number * (numeric) or by a project id (alphanumeric). * @@ -105,9 +105,9 @@ public function getAllowedConsumerProjects() } /** - * List of consumer projects that are allow-listed for PSC connections to this - * instance. This instance can be connected to with PSC from any network in - * these projects. + * The list of consumer projects that are allow-listed for PSC connections to + * this instance. This instance can be connected to with PSC from any network + * in these projects. * Each consumer project in this list may be represented by a project number * (numeric) or by a project id (alphanumeric). * diff --git a/SqlAdmin/src/V1/SqlInstancesStartExternalSyncRequest.php b/SqlAdmin/src/V1/SqlInstancesStartExternalSyncRequest.php index 999f5b415ade..9cea84047e77 100644 --- a/SqlAdmin/src/V1/SqlInstancesStartExternalSyncRequest.php +++ b/SqlAdmin/src/V1/SqlInstancesStartExternalSyncRequest.php @@ -43,7 +43,7 @@ class SqlInstancesStartExternalSyncRequest extends \Google\Protobuf\Internal\Mes * Optional. Parallel level for initial data sync. Currently only applicable * for MySQL. * - * Generated from protobuf field .google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest.ExternalSyncParallelLevel sync_parallel_level = 7 [(.google.api.field_behavior) = OPTIONAL]; + * Generated from protobuf field .google.cloud.sql.v1.ExternalSyncParallelLevel sync_parallel_level = 7 [(.google.api.field_behavior) = OPTIONAL]; */ private $sync_parallel_level = 0; protected $sync_config; @@ -213,7 +213,7 @@ public function setMysqlSyncConfig($var) * Optional. Parallel level for initial data sync. Currently only applicable * for MySQL. * - * Generated from protobuf field .google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest.ExternalSyncParallelLevel sync_parallel_level = 7 [(.google.api.field_behavior) = OPTIONAL]; + * Generated from protobuf field .google.cloud.sql.v1.ExternalSyncParallelLevel sync_parallel_level = 7 [(.google.api.field_behavior) = OPTIONAL]; * @return int */ public function getSyncParallelLevel() @@ -225,13 +225,13 @@ public function getSyncParallelLevel() * Optional. Parallel level for initial data sync. Currently only applicable * for MySQL. * - * Generated from protobuf field .google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest.ExternalSyncParallelLevel sync_parallel_level = 7 [(.google.api.field_behavior) = OPTIONAL]; + * Generated from protobuf field .google.cloud.sql.v1.ExternalSyncParallelLevel sync_parallel_level = 7 [(.google.api.field_behavior) = OPTIONAL]; * @param int $var * @return $this */ public function setSyncParallelLevel($var) { - GPBUtil::checkEnum($var, \Google\Cloud\Sql\V1\SqlInstancesStartExternalSyncRequest\ExternalSyncParallelLevel::class); + GPBUtil::checkEnum($var, \Google\Cloud\Sql\V1\ExternalSyncParallelLevel::class); $this->sync_parallel_level = $var; return $this; diff --git a/SqlAdmin/src/V1beta4/DatabaseInstance.php b/SqlAdmin/src/V1beta4/DatabaseInstance.php index 8e2639bbe30c..ea2155ed74b1 100644 --- a/SqlAdmin/src/V1beta4/DatabaseInstance.php +++ b/SqlAdmin/src/V1beta4/DatabaseInstance.php @@ -283,6 +283,12 @@ class DatabaseInstance extends \Google\Protobuf\Internal\Message * Generated from protobuf field optional string dns_name = 49 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ private $dns_name = null; + /** + * Output only. The dns name of the primary instance in a replication group. + * + * Generated from protobuf field optional string primary_dns_name = 51 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $primary_dns_name = null; /** * Constructor. @@ -403,6 +409,8 @@ class DatabaseInstance extends \Google\Protobuf\Internal\Message * Output only. The link to service attachment of PSC instance. * @type string $dns_name * Output only. The dns name of the instance. + * @type string $primary_dns_name + * Output only. The dns name of the primary instance in a replication group. * } */ public function __construct($data = NULL) { @@ -1733,5 +1741,41 @@ public function setDnsName($var) return $this; } + /** + * Output only. The dns name of the primary instance in a replication group. + * + * Generated from protobuf field optional string primary_dns_name = 51 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getPrimaryDnsName() + { + return isset($this->primary_dns_name) ? $this->primary_dns_name : ''; + } + + public function hasPrimaryDnsName() + { + return isset($this->primary_dns_name); + } + + public function clearPrimaryDnsName() + { + unset($this->primary_dns_name); + } + + /** + * Output only. The dns name of the primary instance in a replication group. + * + * Generated from protobuf field optional string primary_dns_name = 51 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setPrimaryDnsName($var) + { + GPBUtil::checkString($var, True); + $this->primary_dns_name = $var; + + return $this; + } + } diff --git a/SqlAdmin/src/V1beta4/SqlInstancesStartExternalSyncRequest/ExternalSyncParallelLevel.php b/SqlAdmin/src/V1beta4/ExternalSyncParallelLevel.php similarity index 90% rename from SqlAdmin/src/V1beta4/SqlInstancesStartExternalSyncRequest/ExternalSyncParallelLevel.php rename to SqlAdmin/src/V1beta4/ExternalSyncParallelLevel.php index 195805d19fe0..c357eb91698c 100644 --- a/SqlAdmin/src/V1beta4/SqlInstancesStartExternalSyncRequest/ExternalSyncParallelLevel.php +++ b/SqlAdmin/src/V1beta4/ExternalSyncParallelLevel.php @@ -2,14 +2,14 @@ # Generated by the protocol buffer compiler. DO NOT EDIT! # source: google/cloud/sql/v1beta4/cloud_sql.proto -namespace Google\Cloud\Sql\V1beta4\SqlInstancesStartExternalSyncRequest; +namespace Google\Cloud\Sql\V1beta4; use UnexpectedValueException; /** * External Sync parallel level. * - * Protobuf type google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest.ExternalSyncParallelLevel + * Protobuf type google.cloud.sql.v1beta4.ExternalSyncParallelLevel */ class ExternalSyncParallelLevel { @@ -66,4 +66,3 @@ public static function value($name) } } - diff --git a/SqlAdmin/src/V1beta4/Gapic/SqlInstancesServiceGapicClient.php b/SqlAdmin/src/V1beta4/Gapic/SqlInstancesServiceGapicClient.php index cec580072ddb..8eb1838c459b 100644 --- a/SqlAdmin/src/V1beta4/Gapic/SqlInstancesServiceGapicClient.php +++ b/SqlAdmin/src/V1beta4/Gapic/SqlInstancesServiceGapicClient.php @@ -558,7 +558,7 @@ public function demoteMaster(array $optionalArgs = []) * Optional. * * @type string $instance - * Cloud SQL instance ID. This does not include the project ID. + * The Cloud SQL instance ID. This doesn't include the project ID. * @type string $project * Project ID of the project that contains the instance to be exported. * @type InstancesExportRequest $body @@ -1797,7 +1797,7 @@ public function rotateServerCa(array $optionalArgs = []) * @type int $syncParallelLevel * Optional. Parallel level for initial data sync. Currently only applicable * for MySQL. - * For allowed values, use constants defined on {@see \Google\Cloud\Sql\V1beta4\SqlInstancesStartExternalSyncRequest\ExternalSyncParallelLevel} + * For allowed values, use constants defined on {@see \Google\Cloud\Sql\V1beta4\ExternalSyncParallelLevel} * @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 diff --git a/SqlAdmin/src/V1beta4/LocationPreference.php b/SqlAdmin/src/V1beta4/LocationPreference.php index 2d4b40e66838..510df7b3c4d4 100644 --- a/SqlAdmin/src/V1beta4/LocationPreference.php +++ b/SqlAdmin/src/V1beta4/LocationPreference.php @@ -36,6 +36,7 @@ class LocationPreference extends \Google\Protobuf\Internal\Message /** * The preferred Compute Engine zone for the secondary/failover * (for example: us-central1-a, us-central1-b, etc.). + * To disable this field, set it to 'no_secondary_zone'. * * Generated from protobuf field string secondary_zone = 4; */ @@ -62,6 +63,7 @@ class LocationPreference extends \Google\Protobuf\Internal\Message * @type string $secondary_zone * The preferred Compute Engine zone for the secondary/failover * (for example: us-central1-a, us-central1-b, etc.). + * To disable this field, set it to 'no_secondary_zone'. * @type string $kind * This is always `sql#locationPreference`. * } @@ -134,6 +136,7 @@ public function setZone($var) /** * The preferred Compute Engine zone for the secondary/failover * (for example: us-central1-a, us-central1-b, etc.). + * To disable this field, set it to 'no_secondary_zone'. * * Generated from protobuf field string secondary_zone = 4; * @return string @@ -146,6 +149,7 @@ public function getSecondaryZone() /** * The preferred Compute Engine zone for the secondary/failover * (for example: us-central1-a, us-central1-b, etc.). + * To disable this field, set it to 'no_secondary_zone'. * * Generated from protobuf field string secondary_zone = 4; * @param string $var diff --git a/SqlAdmin/src/V1beta4/PscConfig.php b/SqlAdmin/src/V1beta4/PscConfig.php index f8d430d3e83e..e9f619b6f022 100644 --- a/SqlAdmin/src/V1beta4/PscConfig.php +++ b/SqlAdmin/src/V1beta4/PscConfig.php @@ -22,9 +22,9 @@ class PscConfig extends \Google\Protobuf\Internal\Message */ private $psc_enabled = null; /** - * List of consumer projects that are allow-listed for PSC connections to this - * instance. This instance can be connected to with PSC from any network in - * these projects. + * The list of consumer projects that are allow-listed for PSC connections to + * this instance. This instance can be connected to with PSC from any network + * in these projects. * Each consumer project in this list may be represented by a project number * (numeric) or by a project id (alphanumeric). * @@ -41,9 +41,9 @@ class PscConfig extends \Google\Protobuf\Internal\Message * @type bool $psc_enabled * Whether PSC connectivity is enabled for this instance. * @type array|\Google\Protobuf\Internal\RepeatedField $allowed_consumer_projects - * List of consumer projects that are allow-listed for PSC connections to this - * instance. This instance can be connected to with PSC from any network in - * these projects. + * The list of consumer projects that are allow-listed for PSC connections to + * this instance. This instance can be connected to with PSC from any network + * in these projects. * Each consumer project in this list may be represented by a project number * (numeric) or by a project id (alphanumeric). * } @@ -90,9 +90,9 @@ public function setPscEnabled($var) } /** - * List of consumer projects that are allow-listed for PSC connections to this - * instance. This instance can be connected to with PSC from any network in - * these projects. + * The list of consumer projects that are allow-listed for PSC connections to + * this instance. This instance can be connected to with PSC from any network + * in these projects. * Each consumer project in this list may be represented by a project number * (numeric) or by a project id (alphanumeric). * @@ -105,9 +105,9 @@ public function getAllowedConsumerProjects() } /** - * List of consumer projects that are allow-listed for PSC connections to this - * instance. This instance can be connected to with PSC from any network in - * these projects. + * The list of consumer projects that are allow-listed for PSC connections to + * this instance. This instance can be connected to with PSC from any network + * in these projects. * Each consumer project in this list may be represented by a project number * (numeric) or by a project id (alphanumeric). * diff --git a/SqlAdmin/src/V1beta4/SqlInstancesExportRequest.php b/SqlAdmin/src/V1beta4/SqlInstancesExportRequest.php index 0befbffcf76e..98e823702e25 100644 --- a/SqlAdmin/src/V1beta4/SqlInstancesExportRequest.php +++ b/SqlAdmin/src/V1beta4/SqlInstancesExportRequest.php @@ -14,7 +14,7 @@ class SqlInstancesExportRequest extends \Google\Protobuf\Internal\Message { /** - * Cloud SQL instance ID. This does not include the project ID. + * The Cloud SQL instance ID. This doesn't include the project ID. * * Generated from protobuf field string instance = 1; */ @@ -37,7 +37,7 @@ class SqlInstancesExportRequest extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type string $instance - * Cloud SQL instance ID. This does not include the project ID. + * The Cloud SQL instance ID. This doesn't include the project ID. * @type string $project * Project ID of the project that contains the instance to be exported. * @type \Google\Cloud\Sql\V1beta4\InstancesExportRequest $body @@ -49,7 +49,7 @@ public function __construct($data = NULL) { } /** - * Cloud SQL instance ID. This does not include the project ID. + * The Cloud SQL instance ID. This doesn't include the project ID. * * Generated from protobuf field string instance = 1; * @return string @@ -60,7 +60,7 @@ public function getInstance() } /** - * Cloud SQL instance ID. This does not include the project ID. + * The Cloud SQL instance ID. This doesn't include the project ID. * * Generated from protobuf field string instance = 1; * @param string $var diff --git a/SqlAdmin/src/V1beta4/SqlInstancesStartExternalSyncRequest.php b/SqlAdmin/src/V1beta4/SqlInstancesStartExternalSyncRequest.php index 15b20a23012c..3d469525bc2d 100644 --- a/SqlAdmin/src/V1beta4/SqlInstancesStartExternalSyncRequest.php +++ b/SqlAdmin/src/V1beta4/SqlInstancesStartExternalSyncRequest.php @@ -41,7 +41,7 @@ class SqlInstancesStartExternalSyncRequest extends \Google\Protobuf\Internal\Mes * Optional. Parallel level for initial data sync. Currently only applicable * for MySQL. * - * Generated from protobuf field .google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest.ExternalSyncParallelLevel sync_parallel_level = 7 [(.google.api.field_behavior) = OPTIONAL]; + * Generated from protobuf field .google.cloud.sql.v1beta4.ExternalSyncParallelLevel sync_parallel_level = 7 [(.google.api.field_behavior) = OPTIONAL]; */ private $sync_parallel_level = 0; protected $sync_config; @@ -211,7 +211,7 @@ public function setMysqlSyncConfig($var) * Optional. Parallel level for initial data sync. Currently only applicable * for MySQL. * - * Generated from protobuf field .google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest.ExternalSyncParallelLevel sync_parallel_level = 7 [(.google.api.field_behavior) = OPTIONAL]; + * Generated from protobuf field .google.cloud.sql.v1beta4.ExternalSyncParallelLevel sync_parallel_level = 7 [(.google.api.field_behavior) = OPTIONAL]; * @return int */ public function getSyncParallelLevel() @@ -223,13 +223,13 @@ public function getSyncParallelLevel() * Optional. Parallel level for initial data sync. Currently only applicable * for MySQL. * - * Generated from protobuf field .google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest.ExternalSyncParallelLevel sync_parallel_level = 7 [(.google.api.field_behavior) = OPTIONAL]; + * Generated from protobuf field .google.cloud.sql.v1beta4.ExternalSyncParallelLevel sync_parallel_level = 7 [(.google.api.field_behavior) = OPTIONAL]; * @param int $var * @return $this */ public function setSyncParallelLevel($var) { - GPBUtil::checkEnum($var, \Google\Cloud\Sql\V1beta4\SqlInstancesStartExternalSyncRequest\ExternalSyncParallelLevel::class); + GPBUtil::checkEnum($var, \Google\Cloud\Sql\V1beta4\ExternalSyncParallelLevel::class); $this->sync_parallel_level = $var; return $this; diff --git a/SqlAdmin/tests/Unit/V1/Client/SqlInstancesServiceClientTest.php b/SqlAdmin/tests/Unit/V1/Client/SqlInstancesServiceClientTest.php index cdfe70b50a43..3479e36f860f 100644 --- a/SqlAdmin/tests/Unit/V1/Client/SqlInstancesServiceClientTest.php +++ b/SqlAdmin/tests/Unit/V1/Client/SqlInstancesServiceClientTest.php @@ -598,6 +598,7 @@ public function getTest() $maintenanceVersion = 'maintenanceVersion-588975188'; $pscServiceAttachmentLink = 'pscServiceAttachmentLink309057421'; $dnsName = 'dnsName411992033'; + $primaryDnsName = 'primaryDnsName-1306966658'; $expectedResponse = new DatabaseInstance(); $expectedResponse->setKind($kind); $expectedResponse->setEtag($etag); @@ -616,6 +617,7 @@ public function getTest() $expectedResponse->setMaintenanceVersion($maintenanceVersion); $expectedResponse->setPscServiceAttachmentLink($pscServiceAttachmentLink); $expectedResponse->setDnsName($dnsName); + $expectedResponse->setPrimaryDnsName($primaryDnsName); $transport->addResponse($expectedResponse); $request = new SqlInstancesGetRequest(); $response = $gapicClient->get($request); diff --git a/SqlAdmin/tests/Unit/V1beta4/SqlInstancesServiceClientTest.php b/SqlAdmin/tests/Unit/V1beta4/SqlInstancesServiceClientTest.php index 441a8a01e7f2..202ff43e6146 100644 --- a/SqlAdmin/tests/Unit/V1beta4/SqlInstancesServiceClientTest.php +++ b/SqlAdmin/tests/Unit/V1beta4/SqlInstancesServiceClientTest.php @@ -554,6 +554,7 @@ public function getTest() $maintenanceVersion = 'maintenanceVersion-588975188'; $pscServiceAttachmentLink = 'pscServiceAttachmentLink309057421'; $dnsName = 'dnsName411992033'; + $primaryDnsName = 'primaryDnsName-1306966658'; $expectedResponse = new DatabaseInstance(); $expectedResponse->setKind($kind); $expectedResponse->setEtag($etag); @@ -572,6 +573,7 @@ public function getTest() $expectedResponse->setMaintenanceVersion($maintenanceVersion); $expectedResponse->setPscServiceAttachmentLink($pscServiceAttachmentLink); $expectedResponse->setDnsName($dnsName); + $expectedResponse->setPrimaryDnsName($primaryDnsName); $transport->addResponse($expectedResponse); $response = $gapicClient->get(); $this->assertEquals($expectedResponse, $response); diff --git a/Storage/composer.json b/Storage/composer.json index b5d14554ae1d..a5d1195dbe0d 100644 --- a/Storage/composer.json +++ b/Storage/composer.json @@ -5,7 +5,7 @@ "minimum-stability": "stable", "require": { "php": ">=7.4", - "google/cloud-core": "^1.51.3", + "google/cloud-core": "^1.52.7", "ramsey/uuid": "^4.2.3" }, "require-dev": { diff --git a/StorageInsights/composer.json b/StorageInsights/composer.json index 5c6f57bec633..a4d438e14e8c 100644 --- a/StorageInsights/composer.json +++ b/StorageInsights/composer.json @@ -18,7 +18,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.20.0" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/StorageInsights/src/V1/Client/BaseClient/StorageInsightsBaseClient.php b/StorageInsights/src/V1/Client/BaseClient/StorageInsightsBaseClient.php deleted file mode 100644 index 0b2526998736..000000000000 --- a/StorageInsights/src/V1/Client/BaseClient/StorageInsightsBaseClient.php +++ /dev/null @@ -1,505 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/storage_insights_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/storage_insights_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/storage_insights_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/storage_insights_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * report_config resource. - * - * @param string $project - * @param string $location - * @param string $reportConfig - * - * @return string The formatted report_config resource. - */ - public static function reportConfigName(string $project, string $location, string $reportConfig): string - { - return self::getPathTemplate('reportConfig')->render([ - 'project' => $project, - 'location' => $location, - 'report_config' => $reportConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * report_detail resource. - * - * @param string $project - * @param string $location - * @param string $reportConfig - * @param string $reportDetail - * - * @return string The formatted report_detail resource. - */ - public static function reportDetailName(string $project, string $location, string $reportConfig, string $reportDetail): string - { - return self::getPathTemplate('reportDetail')->render([ - 'project' => $project, - 'location' => $location, - 'report_config' => $reportConfig, - 'report_detail' => $reportDetail, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - location: projects/{project}/locations/{location} - * - reportConfig: projects/{project}/locations/{location}/reportConfigs/{report_config} - * - reportDetail: projects/{project}/locations/{location}/reportConfigs/{report_config}/reportDetails/{report_detail} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'storageinsights.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new ReportConfig in a given project and location. - * - * The async variant is {@see self::createReportConfigAsync()} . - * - * @example samples/V1/StorageInsightsClient/create_report_config.php - * - * @param CreateReportConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ReportConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function createReportConfig(CreateReportConfigRequest $request, array $callOptions = []): ReportConfig - { - return $this->startApiCall('CreateReportConfig', $request, $callOptions)->wait(); - } - - /** - * Deletes a single ReportConfig. - * - * The async variant is {@see self::deleteReportConfigAsync()} . - * - * @example samples/V1/StorageInsightsClient/delete_report_config.php - * - * @param DeleteReportConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteReportConfig(DeleteReportConfigRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteReportConfig', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single ReportConfig. - * - * The async variant is {@see self::getReportConfigAsync()} . - * - * @example samples/V1/StorageInsightsClient/get_report_config.php - * - * @param GetReportConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ReportConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getReportConfig(GetReportConfigRequest $request, array $callOptions = []): ReportConfig - { - return $this->startApiCall('GetReportConfig', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single ReportDetail. - * - * The async variant is {@see self::getReportDetailAsync()} . - * - * @example samples/V1/StorageInsightsClient/get_report_detail.php - * - * @param GetReportDetailRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ReportDetail - * - * @throws ApiException Thrown if the API call fails. - */ - public function getReportDetail(GetReportDetailRequest $request, array $callOptions = []): ReportDetail - { - return $this->startApiCall('GetReportDetail', $request, $callOptions)->wait(); - } - - /** - * Lists ReportConfigs in a given project and location. - * - * The async variant is {@see self::listReportConfigsAsync()} . - * - * @example samples/V1/StorageInsightsClient/list_report_configs.php - * - * @param ListReportConfigsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listReportConfigs(ListReportConfigsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListReportConfigs', $request, $callOptions); - } - - /** - * Lists ReportDetails in a given project and location. - * - * The async variant is {@see self::listReportDetailsAsync()} . - * - * @example samples/V1/StorageInsightsClient/list_report_details.php - * - * @param ListReportDetailsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listReportDetails(ListReportDetailsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListReportDetails', $request, $callOptions); - } - - /** - * Updates the parameters of a single ReportConfig. - * - * The async variant is {@see self::updateReportConfigAsync()} . - * - * @example samples/V1/StorageInsightsClient/update_report_config.php - * - * @param UpdateReportConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ReportConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateReportConfig(UpdateReportConfigRequest $request, array $callOptions = []): ReportConfig - { - return $this->startApiCall('UpdateReportConfig', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/StorageInsightsClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/StorageInsightsClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/StorageInsights/src/V1/Client/StorageInsightsClient.php b/StorageInsights/src/V1/Client/StorageInsightsClient.php index cd71ddc66d8e..b25e9a6f3369 100644 --- a/StorageInsights/src/V1/Client/StorageInsightsClient.php +++ b/StorageInsights/src/V1/Client/StorageInsightsClient.php @@ -24,17 +24,480 @@ namespace Google\Cloud\StorageInsights\V1\Client; -use Google\Cloud\StorageInsights\V1\Client\BaseClient\StorageInsightsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\StorageInsights\V1\CreateReportConfigRequest; +use Google\Cloud\StorageInsights\V1\DeleteReportConfigRequest; +use Google\Cloud\StorageInsights\V1\GetReportConfigRequest; +use Google\Cloud\StorageInsights\V1\GetReportDetailRequest; +use Google\Cloud\StorageInsights\V1\ListReportConfigsRequest; +use Google\Cloud\StorageInsights\V1\ListReportDetailsRequest; +use Google\Cloud\StorageInsights\V1\ReportConfig; +use Google\Cloud\StorageInsights\V1\ReportDetail; +use Google\Cloud\StorageInsights\V1\UpdateReportConfigRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service describing handlers for resources * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\StorageInsights\V1\StorageInsightsClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createReportConfigAsync(CreateReportConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteReportConfigAsync(DeleteReportConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getReportConfigAsync(GetReportConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getReportDetailAsync(GetReportDetailRequest $request, array $optionalArgs = []) + * @method PromiseInterface listReportConfigsAsync(ListReportConfigsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listReportDetailsAsync(ListReportDetailsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateReportConfigAsync(UpdateReportConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class StorageInsightsClient extends StorageInsightsBaseClient +final class StorageInsightsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see StorageInsightsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.storageinsights.v1.StorageInsights'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'storageinsights.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/storage_insights_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/storage_insights_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/storage_insights_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/storage_insights_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * report_config resource. + * + * @param string $project + * @param string $location + * @param string $reportConfig + * + * @return string The formatted report_config resource. + */ + public static function reportConfigName(string $project, string $location, string $reportConfig): string + { + return self::getPathTemplate('reportConfig')->render([ + 'project' => $project, + 'location' => $location, + 'report_config' => $reportConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * report_detail resource. + * + * @param string $project + * @param string $location + * @param string $reportConfig + * @param string $reportDetail + * + * @return string The formatted report_detail resource. + */ + public static function reportDetailName(string $project, string $location, string $reportConfig, string $reportDetail): string + { + return self::getPathTemplate('reportDetail')->render([ + 'project' => $project, + 'location' => $location, + 'report_config' => $reportConfig, + 'report_detail' => $reportDetail, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - location: projects/{project}/locations/{location} + * - reportConfig: projects/{project}/locations/{location}/reportConfigs/{report_config} + * - reportDetail: projects/{project}/locations/{location}/reportConfigs/{report_config}/reportDetails/{report_detail} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'storageinsights.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new ReportConfig in a given project and location. + * + * The async variant is {@see StorageInsightsClient::createReportConfigAsync()} . + * + * @example samples/V1/StorageInsightsClient/create_report_config.php + * + * @param CreateReportConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ReportConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function createReportConfig(CreateReportConfigRequest $request, array $callOptions = []): ReportConfig + { + return $this->startApiCall('CreateReportConfig', $request, $callOptions)->wait(); + } + + /** + * Deletes a single ReportConfig. + * + * The async variant is {@see StorageInsightsClient::deleteReportConfigAsync()} . + * + * @example samples/V1/StorageInsightsClient/delete_report_config.php + * + * @param DeleteReportConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteReportConfig(DeleteReportConfigRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteReportConfig', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single ReportConfig. + * + * The async variant is {@see StorageInsightsClient::getReportConfigAsync()} . + * + * @example samples/V1/StorageInsightsClient/get_report_config.php + * + * @param GetReportConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ReportConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getReportConfig(GetReportConfigRequest $request, array $callOptions = []): ReportConfig + { + return $this->startApiCall('GetReportConfig', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single ReportDetail. + * + * The async variant is {@see StorageInsightsClient::getReportDetailAsync()} . + * + * @example samples/V1/StorageInsightsClient/get_report_detail.php + * + * @param GetReportDetailRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ReportDetail + * + * @throws ApiException Thrown if the API call fails. + */ + public function getReportDetail(GetReportDetailRequest $request, array $callOptions = []): ReportDetail + { + return $this->startApiCall('GetReportDetail', $request, $callOptions)->wait(); + } + + /** + * Lists ReportConfigs in a given project and location. + * + * The async variant is {@see StorageInsightsClient::listReportConfigsAsync()} . + * + * @example samples/V1/StorageInsightsClient/list_report_configs.php + * + * @param ListReportConfigsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listReportConfigs(ListReportConfigsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListReportConfigs', $request, $callOptions); + } + + /** + * Lists ReportDetails in a given project and location. + * + * The async variant is {@see StorageInsightsClient::listReportDetailsAsync()} . + * + * @example samples/V1/StorageInsightsClient/list_report_details.php + * + * @param ListReportDetailsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listReportDetails(ListReportDetailsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListReportDetails', $request, $callOptions); + } + + /** + * Updates the parameters of a single ReportConfig. + * + * The async variant is {@see StorageInsightsClient::updateReportConfigAsync()} . + * + * @example samples/V1/StorageInsightsClient/update_report_config.php + * + * @param UpdateReportConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ReportConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateReportConfig(UpdateReportConfigRequest $request, array $callOptions = []): ReportConfig + { + return $this->startApiCall('UpdateReportConfig', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see StorageInsightsClient::getLocationAsync()} . + * + * @example samples/V1/StorageInsightsClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see StorageInsightsClient::listLocationsAsync()} . + * + * @example samples/V1/StorageInsightsClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/StorageTransfer/composer.json b/StorageTransfer/composer.json index b3f9aab73553..0ab4b960fce2 100644 --- a/StorageTransfer/composer.json +++ b/StorageTransfer/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/StorageTransfer/src/V1/Client/BaseClient/StorageTransferServiceBaseClient.php b/StorageTransfer/src/V1/Client/BaseClient/StorageTransferServiceBaseClient.php deleted file mode 100644 index b7993d67df36..000000000000 --- a/StorageTransfer/src/V1/Client/BaseClient/StorageTransferServiceBaseClient.php +++ /dev/null @@ -1,625 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/storage_transfer_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/storage_transfer_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/storage_transfer_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/storage_transfer_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a agent_pools - * resource. - * - * @param string $projectId - * @param string $agentPoolId - * - * @return string The formatted agent_pools resource. - */ - public static function agentPoolsName(string $projectId, string $agentPoolId): string - { - return self::getPathTemplate('agentPools')->render([ - 'project_id' => $projectId, - 'agent_pool_id' => $agentPoolId, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - agentPools: projects/{project_id}/agentPools/{agent_pool_id} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'storagetransfer.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates an agent pool resource. - * - * The async variant is {@see self::createAgentPoolAsync()} . - * - * @param CreateAgentPoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AgentPool - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAgentPool(CreateAgentPoolRequest $request, array $callOptions = []): AgentPool - { - return $this->startApiCall('CreateAgentPool', $request, $callOptions)->wait(); - } - - /** - * Creates a transfer job that runs periodically. - * - * The async variant is {@see self::createTransferJobAsync()} . - * - * @param CreateTransferJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TransferJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTransferJob(CreateTransferJobRequest $request, array $callOptions = []): TransferJob - { - return $this->startApiCall('CreateTransferJob', $request, $callOptions)->wait(); - } - - /** - * Deletes an agent pool. - * - * The async variant is {@see self::deleteAgentPoolAsync()} . - * - * @param DeleteAgentPoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAgentPool(DeleteAgentPoolRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteAgentPool', $request, $callOptions)->wait(); - } - - /** - * Deletes a transfer job. Deleting a transfer job sets its status to - * [DELETED][google.storagetransfer.v1.TransferJob.Status.DELETED]. - * - * The async variant is {@see self::deleteTransferJobAsync()} . - * - * @param DeleteTransferJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTransferJob(DeleteTransferJobRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteTransferJob', $request, $callOptions)->wait(); - } - - /** - * Gets an agent pool. - * - * The async variant is {@see self::getAgentPoolAsync()} . - * - * @param GetAgentPoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AgentPool - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAgentPool(GetAgentPoolRequest $request, array $callOptions = []): AgentPool - { - return $this->startApiCall('GetAgentPool', $request, $callOptions)->wait(); - } - - /** - * Returns the Google service account that is used by Storage Transfer - * Service to access buckets in the project where transfers - * run or in other projects. Each Google service account is associated - * with one Google Cloud project. Users - * should add this service account to the Google Cloud Storage bucket - * ACLs to grant access to Storage Transfer Service. This service - * account is created and owned by Storage Transfer Service and can - * only be used by Storage Transfer Service. - * - * The async variant is {@see self::getGoogleServiceAccountAsync()} . - * - * @param GetGoogleServiceAccountRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GoogleServiceAccount - * - * @throws ApiException Thrown if the API call fails. - */ - public function getGoogleServiceAccount(GetGoogleServiceAccountRequest $request, array $callOptions = []): GoogleServiceAccount - { - return $this->startApiCall('GetGoogleServiceAccount', $request, $callOptions)->wait(); - } - - /** - * Gets a transfer job. - * - * The async variant is {@see self::getTransferJobAsync()} . - * - * @param GetTransferJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TransferJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTransferJob(GetTransferJobRequest $request, array $callOptions = []): TransferJob - { - return $this->startApiCall('GetTransferJob', $request, $callOptions)->wait(); - } - - /** - * Lists agent pools. - * - * The async variant is {@see self::listAgentPoolsAsync()} . - * - * @param ListAgentPoolsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAgentPools(ListAgentPoolsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAgentPools', $request, $callOptions); - } - - /** - * Lists transfer jobs. - * - * The async variant is {@see self::listTransferJobsAsync()} . - * - * @param ListTransferJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTransferJobs(ListTransferJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTransferJobs', $request, $callOptions); - } - - /** - * Pauses a transfer operation. - * - * The async variant is {@see self::pauseTransferOperationAsync()} . - * - * @param PauseTransferOperationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function pauseTransferOperation(PauseTransferOperationRequest $request, array $callOptions = []): void - { - $this->startApiCall('PauseTransferOperation', $request, $callOptions)->wait(); - } - - /** - * Resumes a transfer operation that is paused. - * - * The async variant is {@see self::resumeTransferOperationAsync()} . - * - * @param ResumeTransferOperationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function resumeTransferOperation(ResumeTransferOperationRequest $request, array $callOptions = []): void - { - $this->startApiCall('ResumeTransferOperation', $request, $callOptions)->wait(); - } - - /** - * Starts a new operation for the specified transfer job. - * A `TransferJob` has a maximum of one active `TransferOperation`. If this - * method is called while a `TransferOperation` is active, an error is - * returned. - * - * The async variant is {@see self::runTransferJobAsync()} . - * - * @param RunTransferJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function runTransferJob(RunTransferJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RunTransferJob', $request, $callOptions)->wait(); - } - - /** - * Updates an existing agent pool resource. - * - * The async variant is {@see self::updateAgentPoolAsync()} . - * - * @param UpdateAgentPoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AgentPool - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateAgentPool(UpdateAgentPoolRequest $request, array $callOptions = []): AgentPool - { - return $this->startApiCall('UpdateAgentPool', $request, $callOptions)->wait(); - } - - /** - * Updates a transfer job. Updating a job's transfer spec does not affect - * transfer operations that are running already. - * - * **Note:** The job's [status][google.storagetransfer.v1.TransferJob.status] - * field can be modified using this RPC (for example, to set a job's status to - * [DELETED][google.storagetransfer.v1.TransferJob.Status.DELETED], - * [DISABLED][google.storagetransfer.v1.TransferJob.Status.DISABLED], or - * [ENABLED][google.storagetransfer.v1.TransferJob.Status.ENABLED]). - * - * The async variant is {@see self::updateTransferJobAsync()} . - * - * @param UpdateTransferJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TransferJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateTransferJob(UpdateTransferJobRequest $request, array $callOptions = []): TransferJob - { - return $this->startApiCall('UpdateTransferJob', $request, $callOptions)->wait(); - } -} diff --git a/StorageTransfer/src/V1/Client/StorageTransferServiceClient.php b/StorageTransfer/src/V1/Client/StorageTransferServiceClient.php index 06b7496e6835..6b79944c017f 100644 --- a/StorageTransfer/src/V1/Client/StorageTransferServiceClient.php +++ b/StorageTransfer/src/V1/Client/StorageTransferServiceClient.php @@ -24,17 +24,613 @@ namespace Google\Cloud\StorageTransfer\V1\Client; -use Google\Cloud\StorageTransfer\V1\Client\BaseClient\StorageTransferServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\StorageTransfer\V1\AgentPool; +use Google\Cloud\StorageTransfer\V1\CreateAgentPoolRequest; +use Google\Cloud\StorageTransfer\V1\CreateTransferJobRequest; +use Google\Cloud\StorageTransfer\V1\DeleteAgentPoolRequest; +use Google\Cloud\StorageTransfer\V1\DeleteTransferJobRequest; +use Google\Cloud\StorageTransfer\V1\GetAgentPoolRequest; +use Google\Cloud\StorageTransfer\V1\GetGoogleServiceAccountRequest; +use Google\Cloud\StorageTransfer\V1\GetTransferJobRequest; +use Google\Cloud\StorageTransfer\V1\GoogleServiceAccount; +use Google\Cloud\StorageTransfer\V1\ListAgentPoolsRequest; +use Google\Cloud\StorageTransfer\V1\ListTransferJobsRequest; +use Google\Cloud\StorageTransfer\V1\PauseTransferOperationRequest; +use Google\Cloud\StorageTransfer\V1\ResumeTransferOperationRequest; +use Google\Cloud\StorageTransfer\V1\RunTransferJobRequest; +use Google\Cloud\StorageTransfer\V1\TransferJob; +use Google\Cloud\StorageTransfer\V1\TransferOperation; +use Google\Cloud\StorageTransfer\V1\UpdateAgentPoolRequest; +use Google\Cloud\StorageTransfer\V1\UpdateTransferJobRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Storage Transfer Service and its protos. + * Transfers data between between Google Cloud Storage buckets or from a data + * source external to Google to a Cloud Storage bucket. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\StorageTransfer\V1\StorageTransferServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createAgentPoolAsync(CreateAgentPoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface createTransferJobAsync(CreateTransferJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAgentPoolAsync(DeleteAgentPoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTransferJobAsync(DeleteTransferJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAgentPoolAsync(GetAgentPoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface getGoogleServiceAccountAsync(GetGoogleServiceAccountRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTransferJobAsync(GetTransferJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAgentPoolsAsync(ListAgentPoolsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTransferJobsAsync(ListTransferJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface pauseTransferOperationAsync(PauseTransferOperationRequest $request, array $optionalArgs = []) + * @method PromiseInterface resumeTransferOperationAsync(ResumeTransferOperationRequest $request, array $optionalArgs = []) + * @method PromiseInterface runTransferJobAsync(RunTransferJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAgentPoolAsync(UpdateAgentPoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateTransferJobAsync(UpdateTransferJobRequest $request, array $optionalArgs = []) */ -final class StorageTransferServiceClient extends StorageTransferServiceBaseClient +final class StorageTransferServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see StorageTransferServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.storagetransfer.v1.StorageTransferService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'storagetransfer.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/storage_transfer_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/storage_transfer_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/storage_transfer_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/storage_transfer_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a agent_pools + * resource. + * + * @param string $projectId + * @param string $agentPoolId + * + * @return string The formatted agent_pools resource. + */ + public static function agentPoolsName(string $projectId, string $agentPoolId): string + { + return self::getPathTemplate('agentPools')->render([ + 'project_id' => $projectId, + 'agent_pool_id' => $agentPoolId, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - agentPools: projects/{project_id}/agentPools/{agent_pool_id} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'storagetransfer.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates an agent pool resource. + * + * The async variant is {@see StorageTransferServiceClient::createAgentPoolAsync()} + * . + * + * @param CreateAgentPoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AgentPool + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAgentPool(CreateAgentPoolRequest $request, array $callOptions = []): AgentPool + { + return $this->startApiCall('CreateAgentPool', $request, $callOptions)->wait(); + } + + /** + * Creates a transfer job that runs periodically. + * + * The async variant is + * {@see StorageTransferServiceClient::createTransferJobAsync()} . + * + * @param CreateTransferJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TransferJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTransferJob(CreateTransferJobRequest $request, array $callOptions = []): TransferJob + { + return $this->startApiCall('CreateTransferJob', $request, $callOptions)->wait(); + } + + /** + * Deletes an agent pool. + * + * The async variant is {@see StorageTransferServiceClient::deleteAgentPoolAsync()} + * . + * + * @param DeleteAgentPoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAgentPool(DeleteAgentPoolRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteAgentPool', $request, $callOptions)->wait(); + } + + /** + * Deletes a transfer job. Deleting a transfer job sets its status to + * [DELETED][google.storagetransfer.v1.TransferJob.Status.DELETED]. + * + * The async variant is + * {@see StorageTransferServiceClient::deleteTransferJobAsync()} . + * + * @param DeleteTransferJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTransferJob(DeleteTransferJobRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteTransferJob', $request, $callOptions)->wait(); + } + + /** + * Gets an agent pool. + * + * The async variant is {@see StorageTransferServiceClient::getAgentPoolAsync()} . + * + * @param GetAgentPoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AgentPool + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAgentPool(GetAgentPoolRequest $request, array $callOptions = []): AgentPool + { + return $this->startApiCall('GetAgentPool', $request, $callOptions)->wait(); + } + + /** + * Returns the Google service account that is used by Storage Transfer + * Service to access buckets in the project where transfers + * run or in other projects. Each Google service account is associated + * with one Google Cloud project. Users + * should add this service account to the Google Cloud Storage bucket + * ACLs to grant access to Storage Transfer Service. This service + * account is created and owned by Storage Transfer Service and can + * only be used by Storage Transfer Service. + * + * The async variant is + * {@see StorageTransferServiceClient::getGoogleServiceAccountAsync()} . + * + * @param GetGoogleServiceAccountRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GoogleServiceAccount + * + * @throws ApiException Thrown if the API call fails. + */ + public function getGoogleServiceAccount(GetGoogleServiceAccountRequest $request, array $callOptions = []): GoogleServiceAccount + { + return $this->startApiCall('GetGoogleServiceAccount', $request, $callOptions)->wait(); + } + + /** + * Gets a transfer job. + * + * The async variant is {@see StorageTransferServiceClient::getTransferJobAsync()} + * . + * + * @param GetTransferJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TransferJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTransferJob(GetTransferJobRequest $request, array $callOptions = []): TransferJob + { + return $this->startApiCall('GetTransferJob', $request, $callOptions)->wait(); + } + + /** + * Lists agent pools. + * + * The async variant is {@see StorageTransferServiceClient::listAgentPoolsAsync()} + * . + * + * @param ListAgentPoolsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAgentPools(ListAgentPoolsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAgentPools', $request, $callOptions); + } + + /** + * Lists transfer jobs. + * + * The async variant is + * {@see StorageTransferServiceClient::listTransferJobsAsync()} . + * + * @param ListTransferJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTransferJobs(ListTransferJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTransferJobs', $request, $callOptions); + } + + /** + * Pauses a transfer operation. + * + * The async variant is + * {@see StorageTransferServiceClient::pauseTransferOperationAsync()} . + * + * @param PauseTransferOperationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function pauseTransferOperation(PauseTransferOperationRequest $request, array $callOptions = []): void + { + $this->startApiCall('PauseTransferOperation', $request, $callOptions)->wait(); + } + + /** + * Resumes a transfer operation that is paused. + * + * The async variant is + * {@see StorageTransferServiceClient::resumeTransferOperationAsync()} . + * + * @param ResumeTransferOperationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function resumeTransferOperation(ResumeTransferOperationRequest $request, array $callOptions = []): void + { + $this->startApiCall('ResumeTransferOperation', $request, $callOptions)->wait(); + } + + /** + * Starts a new operation for the specified transfer job. + * A `TransferJob` has a maximum of one active `TransferOperation`. If this + * method is called while a `TransferOperation` is active, an error is + * returned. + * + * The async variant is {@see StorageTransferServiceClient::runTransferJobAsync()} + * . + * + * @param RunTransferJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function runTransferJob(RunTransferJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RunTransferJob', $request, $callOptions)->wait(); + } + + /** + * Updates an existing agent pool resource. + * + * The async variant is {@see StorageTransferServiceClient::updateAgentPoolAsync()} + * . + * + * @param UpdateAgentPoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AgentPool + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAgentPool(UpdateAgentPoolRequest $request, array $callOptions = []): AgentPool + { + return $this->startApiCall('UpdateAgentPool', $request, $callOptions)->wait(); + } + + /** + * Updates a transfer job. Updating a job's transfer spec does not affect + * transfer operations that are running already. + * + * **Note:** The job's [status][google.storagetransfer.v1.TransferJob.status] + * field can be modified using this RPC (for example, to set a job's status to + * [DELETED][google.storagetransfer.v1.TransferJob.Status.DELETED], + * [DISABLED][google.storagetransfer.v1.TransferJob.Status.DISABLED], or + * [ENABLED][google.storagetransfer.v1.TransferJob.Status.ENABLED]). + * + * The async variant is + * {@see StorageTransferServiceClient::updateTransferJobAsync()} . + * + * @param UpdateTransferJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TransferJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTransferJob(UpdateTransferJobRequest $request, array $callOptions = []): TransferJob + { + return $this->startApiCall('UpdateTransferJob', $request, $callOptions)->wait(); + } } diff --git a/Support/composer.json b/Support/composer.json index c1f22b422b88..140f6ca2a73e 100644 --- a/Support/composer.json +++ b/Support/composer.json @@ -18,7 +18,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.20.0" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Support/src/V2/Client/BaseClient/CaseAttachmentServiceBaseClient.php b/Support/src/V2/Client/BaseClient/CaseAttachmentServiceBaseClient.php deleted file mode 100644 index 1a5da6799bf5..000000000000 --- a/Support/src/V2/Client/BaseClient/CaseAttachmentServiceBaseClient.php +++ /dev/null @@ -1,272 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/case_attachment_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/case_attachment_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/case_attachment_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/case_attachment_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a case - * resource. - * - * @param string $organization - * @param string $case - * - * @return string The formatted case resource. - */ - public static function caseName(string $organization, string $case): string - { - return self::getPathTemplate('case')->render([ - 'organization' => $organization, - 'case' => $case, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_case resource. - * - * @param string $organization - * @param string $case - * - * @return string The formatted organization_case resource. - */ - public static function organizationCaseName(string $organization, string $case): string - { - return self::getPathTemplate('organizationCase')->render([ - 'organization' => $organization, - 'case' => $case, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a project_case - * resource. - * - * @param string $project - * @param string $case - * - * @return string The formatted project_case resource. - */ - public static function projectCaseName(string $project, string $case): string - { - return self::getPathTemplate('projectCase')->render([ - 'project' => $project, - 'case' => $case, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - case: organizations/{organization}/cases/{case} - * - organizationCase: organizations/{organization}/cases/{case} - * - projectCase: projects/{project}/cases/{case} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudsupport.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Retrieve all attachments associated with a support case. - * - * The async variant is {@see self::listAttachmentsAsync()} . - * - * @example samples/V2/CaseAttachmentServiceClient/list_attachments.php - * - * @param ListAttachmentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAttachments(ListAttachmentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAttachments', $request, $callOptions); - } -} diff --git a/Support/src/V2/Client/BaseClient/CaseServiceBaseClient.php b/Support/src/V2/Client/BaseClient/CaseServiceBaseClient.php deleted file mode 100644 index 54f9c8a402b4..000000000000 --- a/Support/src/V2/Client/BaseClient/CaseServiceBaseClient.php +++ /dev/null @@ -1,517 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/case_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/case_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/case_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/case_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a case - * resource. - * - * @param string $organization - * @param string $case - * - * @return string The formatted case resource. - */ - public static function caseName(string $organization, string $case): string - { - return self::getPathTemplate('case')->render([ - 'organization' => $organization, - 'case' => $case, - ]); - } - - /** - * 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(string $organization): string - { - return self::getPathTemplate('organization')->render([ - 'organization' => $organization, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_case resource. - * - * @param string $organization - * @param string $case - * - * @return string The formatted organization_case resource. - */ - public static function organizationCaseName(string $organization, string $case): string - { - return self::getPathTemplate('organizationCase')->render([ - 'organization' => $organization, - 'case' => $case, - ]); - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a project_case - * resource. - * - * @param string $project - * @param string $case - * - * @return string The formatted project_case resource. - */ - public static function projectCaseName(string $project, string $case): string - { - return self::getPathTemplate('projectCase')->render([ - 'project' => $project, - 'case' => $case, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - case: organizations/{organization}/cases/{case} - * - organization: organizations/{organization} - * - organizationCase: organizations/{organization}/cases/{case} - * - project: projects/{project} - * - projectCase: projects/{project}/cases/{case} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudsupport.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Close the specified case. - * - * The async variant is {@see self::closeCaseAsync()} . - * - * @example samples/V2/CaseServiceClient/close_case.php - * - * @param CloseCaseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PBCase - * - * @throws ApiException Thrown if the API call fails. - */ - public function closeCase(CloseCaseRequest $request, array $callOptions = []): PBCase - { - return $this->startApiCall('CloseCase', $request, $callOptions)->wait(); - } - - /** - * Create a new case and associate it with the given Google Cloud Resource. - * The case object must have the following fields set: `display_name`, - * `description`, `classification`, and `priority`. - * - * The async variant is {@see self::createCaseAsync()} . - * - * @example samples/V2/CaseServiceClient/create_case.php - * - * @param CreateCaseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PBCase - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCase(CreateCaseRequest $request, array $callOptions = []): PBCase - { - return $this->startApiCall('CreateCase', $request, $callOptions)->wait(); - } - - /** - * Escalate a case. Escalating a case will initiate the Google Cloud Support - * escalation management process. - * - * This operation is only available to certain Customer Care tiers. Go to - * https://cloud.google.com/support and look for 'Technical support - * escalations' in the feature list to find out which tiers are able to - * perform escalations. - * - * The async variant is {@see self::escalateCaseAsync()} . - * - * @example samples/V2/CaseServiceClient/escalate_case.php - * - * @param EscalateCaseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PBCase - * - * @throws ApiException Thrown if the API call fails. - */ - public function escalateCase(EscalateCaseRequest $request, array $callOptions = []): PBCase - { - return $this->startApiCall('EscalateCase', $request, $callOptions)->wait(); - } - - /** - * Retrieve the specified case. - * - * The async variant is {@see self::getCaseAsync()} . - * - * @example samples/V2/CaseServiceClient/get_case.php - * - * @param GetCaseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PBCase - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCase(GetCaseRequest $request, array $callOptions = []): PBCase - { - return $this->startApiCall('GetCase', $request, $callOptions)->wait(); - } - - /** - * Retrieve all cases under the specified parent. - * - * Note: Listing cases under an Organization returns only the cases directly - * parented by that organization. To retrieve all cases under an organization, - * including cases parented by projects under that organization, use - * `cases.search`. - * - * The async variant is {@see self::listCasesAsync()} . - * - * @example samples/V2/CaseServiceClient/list_cases.php - * - * @param ListCasesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCases(ListCasesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCases', $request, $callOptions); - } - - /** - * Retrieve valid classifications to be used when creating a support case. - * The classications are hierarchical, with each classification containing - * all levels of the hierarchy, separated by " > ". For example "Technical - * Issue > Compute > Compute Engine". - * - * The async variant is {@see self::searchCaseClassificationsAsync()} . - * - * @example samples/V2/CaseServiceClient/search_case_classifications.php - * - * @param SearchCaseClassificationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchCaseClassifications(SearchCaseClassificationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchCaseClassifications', $request, $callOptions); - } - - /** - * Search cases using the specified query. - * - * The async variant is {@see self::searchCasesAsync()} . - * - * @example samples/V2/CaseServiceClient/search_cases.php - * - * @param SearchCasesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchCases(SearchCasesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('SearchCases', $request, $callOptions); - } - - /** - * Update the specified case. Only a subset of fields can be updated. - * - * The async variant is {@see self::updateCaseAsync()} . - * - * @example samples/V2/CaseServiceClient/update_case.php - * - * @param UpdateCaseRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PBCase - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCase(UpdateCaseRequest $request, array $callOptions = []): PBCase - { - return $this->startApiCall('UpdateCase', $request, $callOptions)->wait(); - } -} diff --git a/Support/src/V2/Client/BaseClient/CommentServiceBaseClient.php b/Support/src/V2/Client/BaseClient/CommentServiceBaseClient.php deleted file mode 100644 index d8690ab7d0df..000000000000 --- a/Support/src/V2/Client/BaseClient/CommentServiceBaseClient.php +++ /dev/null @@ -1,362 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/comment_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/comment_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/comment_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/comment_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a case - * resource. - * - * @param string $organization - * @param string $case - * - * @return string The formatted case resource. - */ - public static function caseName(string $organization, string $case): string - { - return self::getPathTemplate('case')->render([ - 'organization' => $organization, - 'case' => $case, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a comment - * resource. - * - * @param string $organization - * @param string $case - * @param string $comment - * - * @return string The formatted comment resource. - */ - public static function commentName(string $organization, string $case, string $comment): string - { - return self::getPathTemplate('comment')->render([ - 'organization' => $organization, - 'case' => $case, - 'comment' => $comment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_case resource. - * - * @param string $organization - * @param string $case - * - * @return string The formatted organization_case resource. - */ - public static function organizationCaseName(string $organization, string $case): string - { - return self::getPathTemplate('organizationCase')->render([ - 'organization' => $organization, - 'case' => $case, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * organization_case_comment resource. - * - * @param string $organization - * @param string $case - * @param string $comment - * - * @return string The formatted organization_case_comment resource. - */ - public static function organizationCaseCommentName(string $organization, string $case, string $comment): string - { - return self::getPathTemplate('organizationCaseComment')->render([ - 'organization' => $organization, - 'case' => $case, - 'comment' => $comment, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a project_case - * resource. - * - * @param string $project - * @param string $case - * - * @return string The formatted project_case resource. - */ - public static function projectCaseName(string $project, string $case): string - { - return self::getPathTemplate('projectCase')->render([ - 'project' => $project, - 'case' => $case, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * project_case_comment resource. - * - * @param string $project - * @param string $case - * @param string $comment - * - * @return string The formatted project_case_comment resource. - */ - public static function projectCaseCommentName(string $project, string $case, string $comment): string - { - return self::getPathTemplate('projectCaseComment')->render([ - 'project' => $project, - 'case' => $case, - 'comment' => $comment, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - case: organizations/{organization}/cases/{case} - * - comment: organizations/{organization}/cases/{case}/comments/{comment} - * - organizationCase: organizations/{organization}/cases/{case} - * - organizationCaseComment: organizations/{organization}/cases/{case}/comments/{comment} - * - projectCase: projects/{project}/cases/{case} - * - projectCaseComment: projects/{project}/cases/{case}/comments/{comment} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudsupport.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Add a new comment to the specified Case. - * The comment object must have the following fields set: body. - * - * The async variant is {@see self::createCommentAsync()} . - * - * @example samples/V2/CommentServiceClient/create_comment.php - * - * @param CreateCommentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Comment - * - * @throws ApiException Thrown if the API call fails. - */ - public function createComment(CreateCommentRequest $request, array $callOptions = []): Comment - { - return $this->startApiCall('CreateComment', $request, $callOptions)->wait(); - } - - /** - * Retrieve all Comments associated with the Case object. - * - * The async variant is {@see self::listCommentsAsync()} . - * - * @example samples/V2/CommentServiceClient/list_comments.php - * - * @param ListCommentsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listComments(ListCommentsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListComments', $request, $callOptions); - } -} diff --git a/Support/src/V2/Client/CaseAttachmentServiceClient.php b/Support/src/V2/Client/CaseAttachmentServiceClient.php index d72db7681f22..401a5c5ebcc2 100644 --- a/Support/src/V2/Client/CaseAttachmentServiceClient.php +++ b/Support/src/V2/Client/CaseAttachmentServiceClient.php @@ -24,17 +24,248 @@ namespace Google\Cloud\Support\V2\Client; -use Google\Cloud\Support\V2\Client\BaseClient\CaseAttachmentServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Support\V2\ListAttachmentsRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service to manage file attachment for Google Cloud support cases. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface listAttachmentsAsync(ListAttachmentsRequest $request, array $optionalArgs = []) */ -final class CaseAttachmentServiceClient extends CaseAttachmentServiceBaseClient +final class CaseAttachmentServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CaseAttachmentServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.support.v2.CaseAttachmentService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudsupport.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/case_attachment_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/case_attachment_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/case_attachment_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/case_attachment_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a case + * resource. + * + * @param string $organization + * @param string $case + * + * @return string The formatted case resource. + */ + public static function caseName(string $organization, string $case): string + { + return self::getPathTemplate('case')->render([ + 'organization' => $organization, + 'case' => $case, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_case resource. + * + * @param string $organization + * @param string $case + * + * @return string The formatted organization_case resource. + */ + public static function organizationCaseName(string $organization, string $case): string + { + return self::getPathTemplate('organizationCase')->render([ + 'organization' => $organization, + 'case' => $case, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a project_case + * resource. + * + * @param string $project + * @param string $case + * + * @return string The formatted project_case resource. + */ + public static function projectCaseName(string $project, string $case): string + { + return self::getPathTemplate('projectCase')->render([ + 'project' => $project, + 'case' => $case, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - case: organizations/{organization}/cases/{case} + * - organizationCase: organizations/{organization}/cases/{case} + * - projectCase: projects/{project}/cases/{case} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudsupport.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Retrieve all attachments associated with a support case. + * + * The async variant is {@see CaseAttachmentServiceClient::listAttachmentsAsync()} + * . + * + * @example samples/V2/CaseAttachmentServiceClient/list_attachments.php + * + * @param ListAttachmentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAttachments(ListAttachmentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAttachments', $request, $callOptions); + } } diff --git a/Support/src/V2/Client/CaseServiceClient.php b/Support/src/V2/Client/CaseServiceClient.php index 22a8a1b92fd0..cf8e1fcff3e3 100644 --- a/Support/src/V2/Client/CaseServiceClient.php +++ b/Support/src/V2/Client/CaseServiceClient.php @@ -24,17 +24,493 @@ namespace Google\Cloud\Support\V2\Client; -use Google\Cloud\Support\V2\Client\BaseClient\CaseServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Support\V2\CloseCaseRequest; +use Google\Cloud\Support\V2\CreateCaseRequest; +use Google\Cloud\Support\V2\EscalateCaseRequest; +use Google\Cloud\Support\V2\GetCaseRequest; +use Google\Cloud\Support\V2\ListCasesRequest; +use Google\Cloud\Support\V2\PBCase; +use Google\Cloud\Support\V2\SearchCaseClassificationsRequest; +use Google\Cloud\Support\V2\SearchCasesRequest; +use Google\Cloud\Support\V2\UpdateCaseRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service to manage Google Cloud support cases. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface closeCaseAsync(CloseCaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface createCaseAsync(CreateCaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface escalateCaseAsync(EscalateCaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCaseAsync(GetCaseRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCasesAsync(ListCasesRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchCaseClassificationsAsync(SearchCaseClassificationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchCasesAsync(SearchCasesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCaseAsync(UpdateCaseRequest $request, array $optionalArgs = []) */ -final class CaseServiceClient extends CaseServiceBaseClient +final class CaseServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CaseServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.support.v2.CaseService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudsupport.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/case_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/case_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/case_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/case_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a case + * resource. + * + * @param string $organization + * @param string $case + * + * @return string The formatted case resource. + */ + public static function caseName(string $organization, string $case): string + { + return self::getPathTemplate('case')->render([ + 'organization' => $organization, + 'case' => $case, + ]); + } + + /** + * 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(string $organization): string + { + return self::getPathTemplate('organization')->render([ + 'organization' => $organization, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_case resource. + * + * @param string $organization + * @param string $case + * + * @return string The formatted organization_case resource. + */ + public static function organizationCaseName(string $organization, string $case): string + { + return self::getPathTemplate('organizationCase')->render([ + 'organization' => $organization, + 'case' => $case, + ]); + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a project_case + * resource. + * + * @param string $project + * @param string $case + * + * @return string The formatted project_case resource. + */ + public static function projectCaseName(string $project, string $case): string + { + return self::getPathTemplate('projectCase')->render([ + 'project' => $project, + 'case' => $case, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - case: organizations/{organization}/cases/{case} + * - organization: organizations/{organization} + * - organizationCase: organizations/{organization}/cases/{case} + * - project: projects/{project} + * - projectCase: projects/{project}/cases/{case} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudsupport.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Close the specified case. + * + * The async variant is {@see CaseServiceClient::closeCaseAsync()} . + * + * @example samples/V2/CaseServiceClient/close_case.php + * + * @param CloseCaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PBCase + * + * @throws ApiException Thrown if the API call fails. + */ + public function closeCase(CloseCaseRequest $request, array $callOptions = []): PBCase + { + return $this->startApiCall('CloseCase', $request, $callOptions)->wait(); + } + + /** + * Create a new case and associate it with the given Google Cloud Resource. + * The case object must have the following fields set: `display_name`, + * `description`, `classification`, and `priority`. + * + * The async variant is {@see CaseServiceClient::createCaseAsync()} . + * + * @example samples/V2/CaseServiceClient/create_case.php + * + * @param CreateCaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PBCase + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCase(CreateCaseRequest $request, array $callOptions = []): PBCase + { + return $this->startApiCall('CreateCase', $request, $callOptions)->wait(); + } + + /** + * Escalate a case. Escalating a case will initiate the Google Cloud Support + * escalation management process. + * + * This operation is only available to certain Customer Care tiers. Go to + * https://cloud.google.com/support and look for 'Technical support + * escalations' in the feature list to find out which tiers are able to + * perform escalations. + * + * The async variant is {@see CaseServiceClient::escalateCaseAsync()} . + * + * @example samples/V2/CaseServiceClient/escalate_case.php + * + * @param EscalateCaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PBCase + * + * @throws ApiException Thrown if the API call fails. + */ + public function escalateCase(EscalateCaseRequest $request, array $callOptions = []): PBCase + { + return $this->startApiCall('EscalateCase', $request, $callOptions)->wait(); + } + + /** + * Retrieve the specified case. + * + * The async variant is {@see CaseServiceClient::getCaseAsync()} . + * + * @example samples/V2/CaseServiceClient/get_case.php + * + * @param GetCaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PBCase + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCase(GetCaseRequest $request, array $callOptions = []): PBCase + { + return $this->startApiCall('GetCase', $request, $callOptions)->wait(); + } + + /** + * Retrieve all cases under the specified parent. + * + * Note: Listing cases under an Organization returns only the cases directly + * parented by that organization. To retrieve all cases under an organization, + * including cases parented by projects under that organization, use + * `cases.search`. + * + * The async variant is {@see CaseServiceClient::listCasesAsync()} . + * + * @example samples/V2/CaseServiceClient/list_cases.php + * + * @param ListCasesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCases(ListCasesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCases', $request, $callOptions); + } + + /** + * Retrieve valid classifications to be used when creating a support case. + * The classications are hierarchical, with each classification containing + * all levels of the hierarchy, separated by " > ". For example "Technical + * Issue > Compute > Compute Engine". + * + * The async variant is {@see CaseServiceClient::searchCaseClassificationsAsync()} + * . + * + * @example samples/V2/CaseServiceClient/search_case_classifications.php + * + * @param SearchCaseClassificationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchCaseClassifications(SearchCaseClassificationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchCaseClassifications', $request, $callOptions); + } + + /** + * Search cases using the specified query. + * + * The async variant is {@see CaseServiceClient::searchCasesAsync()} . + * + * @example samples/V2/CaseServiceClient/search_cases.php + * + * @param SearchCasesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchCases(SearchCasesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('SearchCases', $request, $callOptions); + } + + /** + * Update the specified case. Only a subset of fields can be updated. + * + * The async variant is {@see CaseServiceClient::updateCaseAsync()} . + * + * @example samples/V2/CaseServiceClient/update_case.php + * + * @param UpdateCaseRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PBCase + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCase(UpdateCaseRequest $request, array $callOptions = []): PBCase + { + return $this->startApiCall('UpdateCase', $request, $callOptions)->wait(); + } } diff --git a/Support/src/V2/Client/CommentServiceClient.php b/Support/src/V2/Client/CommentServiceClient.php index b348271434e0..ec8140d20cf5 100644 --- a/Support/src/V2/Client/CommentServiceClient.php +++ b/Support/src/V2/Client/CommentServiceClient.php @@ -24,17 +24,337 @@ namespace Google\Cloud\Support\V2\Client; -use Google\Cloud\Support\V2\Client\BaseClient\CommentServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Support\V2\Comment; +use Google\Cloud\Support\V2\CreateCommentRequest; +use Google\Cloud\Support\V2\ListCommentsRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service to manage comments on cases. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createCommentAsync(CreateCommentRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCommentsAsync(ListCommentsRequest $request, array $optionalArgs = []) */ -final class CommentServiceClient extends CommentServiceBaseClient +final class CommentServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CommentServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.support.v2.CommentService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudsupport.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/comment_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/comment_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/comment_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/comment_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a case + * resource. + * + * @param string $organization + * @param string $case + * + * @return string The formatted case resource. + */ + public static function caseName(string $organization, string $case): string + { + return self::getPathTemplate('case')->render([ + 'organization' => $organization, + 'case' => $case, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a comment + * resource. + * + * @param string $organization + * @param string $case + * @param string $comment + * + * @return string The formatted comment resource. + */ + public static function commentName(string $organization, string $case, string $comment): string + { + return self::getPathTemplate('comment')->render([ + 'organization' => $organization, + 'case' => $case, + 'comment' => $comment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_case resource. + * + * @param string $organization + * @param string $case + * + * @return string The formatted organization_case resource. + */ + public static function organizationCaseName(string $organization, string $case): string + { + return self::getPathTemplate('organizationCase')->render([ + 'organization' => $organization, + 'case' => $case, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * organization_case_comment resource. + * + * @param string $organization + * @param string $case + * @param string $comment + * + * @return string The formatted organization_case_comment resource. + */ + public static function organizationCaseCommentName(string $organization, string $case, string $comment): string + { + return self::getPathTemplate('organizationCaseComment')->render([ + 'organization' => $organization, + 'case' => $case, + 'comment' => $comment, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a project_case + * resource. + * + * @param string $project + * @param string $case + * + * @return string The formatted project_case resource. + */ + public static function projectCaseName(string $project, string $case): string + { + return self::getPathTemplate('projectCase')->render([ + 'project' => $project, + 'case' => $case, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * project_case_comment resource. + * + * @param string $project + * @param string $case + * @param string $comment + * + * @return string The formatted project_case_comment resource. + */ + public static function projectCaseCommentName(string $project, string $case, string $comment): string + { + return self::getPathTemplate('projectCaseComment')->render([ + 'project' => $project, + 'case' => $case, + 'comment' => $comment, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - case: organizations/{organization}/cases/{case} + * - comment: organizations/{organization}/cases/{case}/comments/{comment} + * - organizationCase: organizations/{organization}/cases/{case} + * - organizationCaseComment: organizations/{organization}/cases/{case}/comments/{comment} + * - projectCase: projects/{project}/cases/{case} + * - projectCaseComment: projects/{project}/cases/{case}/comments/{comment} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudsupport.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Add a new comment to the specified Case. + * The comment object must have the following fields set: body. + * + * The async variant is {@see CommentServiceClient::createCommentAsync()} . + * + * @example samples/V2/CommentServiceClient/create_comment.php + * + * @param CreateCommentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Comment + * + * @throws ApiException Thrown if the API call fails. + */ + public function createComment(CreateCommentRequest $request, array $callOptions = []): Comment + { + return $this->startApiCall('CreateComment', $request, $callOptions)->wait(); + } + + /** + * Retrieve all Comments associated with the Case object. + * + * The async variant is {@see CommentServiceClient::listCommentsAsync()} . + * + * @example samples/V2/CommentServiceClient/list_comments.php + * + * @param ListCommentsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listComments(ListCommentsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListComments', $request, $callOptions); + } } diff --git a/Talent/composer.json b/Talent/composer.json index d17ae2585ced..036051ca7ec3 100644 --- a/Talent/composer.json +++ b/Talent/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Talent/src/V4/Client/BaseClient/CompanyServiceBaseClient.php b/Talent/src/V4/Client/BaseClient/CompanyServiceBaseClient.php deleted file mode 100644 index c9bc16680683..000000000000 --- a/Talent/src/V4/Client/BaseClient/CompanyServiceBaseClient.php +++ /dev/null @@ -1,360 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/company_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/company_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/company_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/company_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a company - * resource. - * - * @param string $project - * @param string $tenant - * @param string $company - * - * @return string The formatted company resource. - */ - public static function companyName(string $project, string $tenant, string $company): string - { - return self::getPathTemplate('company')->render([ - 'project' => $project, - 'tenant' => $tenant, - 'company' => $company, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a tenant - * resource. - * - * @param string $project - * @param string $tenant - * - * @return string The formatted tenant resource. - */ - public static function tenantName(string $project, string $tenant): string - { - return self::getPathTemplate('tenant')->render([ - 'project' => $project, - 'tenant' => $tenant, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - company: projects/{project}/tenants/{tenant}/companies/{company} - * - tenant: projects/{project}/tenants/{tenant} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'jobs.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new company entity. - * - * The async variant is {@see self::createCompanyAsync()} . - * - * @param CreateCompanyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Company - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCompany(CreateCompanyRequest $request, array $callOptions = []): Company - { - return $this->startApiCall('CreateCompany', $request, $callOptions)->wait(); - } - - /** - * Deletes specified company. - * Prerequisite: The company has no jobs associated with it. - * - * The async variant is {@see self::deleteCompanyAsync()} . - * - * @param DeleteCompanyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteCompany(DeleteCompanyRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteCompany', $request, $callOptions)->wait(); - } - - /** - * Retrieves specified company. - * - * The async variant is {@see self::getCompanyAsync()} . - * - * @param GetCompanyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Company - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCompany(GetCompanyRequest $request, array $callOptions = []): Company - { - return $this->startApiCall('GetCompany', $request, $callOptions)->wait(); - } - - /** - * Lists all companies associated with the project. - * - * The async variant is {@see self::listCompaniesAsync()} . - * - * @param ListCompaniesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCompanies(ListCompaniesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCompanies', $request, $callOptions); - } - - /** - * Updates specified company. - * - * The async variant is {@see self::updateCompanyAsync()} . - * - * @param UpdateCompanyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Company - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCompany(UpdateCompanyRequest $request, array $callOptions = []): Company - { - return $this->startApiCall('UpdateCompany', $request, $callOptions)->wait(); - } -} diff --git a/Talent/src/V4/Client/BaseClient/CompletionBaseClient.php b/Talent/src/V4/Client/BaseClient/CompletionBaseClient.php deleted file mode 100644 index 2e8d4761becf..000000000000 --- a/Talent/src/V4/Client/BaseClient/CompletionBaseClient.php +++ /dev/null @@ -1,257 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/completion_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/completion_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/completion_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/completion_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a company - * resource. - * - * @param string $project - * @param string $tenant - * @param string $company - * - * @return string The formatted company resource. - */ - public static function companyName(string $project, string $tenant, string $company): string - { - return self::getPathTemplate('company')->render([ - 'project' => $project, - 'tenant' => $tenant, - 'company' => $company, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a tenant - * resource. - * - * @param string $project - * @param string $tenant - * - * @return string The formatted tenant resource. - */ - public static function tenantName(string $project, string $tenant): string - { - return self::getPathTemplate('tenant')->render([ - 'project' => $project, - 'tenant' => $tenant, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - company: projects/{project}/tenants/{tenant}/companies/{company} - * - tenant: projects/{project}/tenants/{tenant} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'jobs.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Completes the specified prefix with keyword suggestions. - * Intended for use by a job search auto-complete search box. - * - * The async variant is {@see self::completeQueryAsync()} . - * - * @param CompleteQueryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CompleteQueryResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function completeQuery(CompleteQueryRequest $request, array $callOptions = []): CompleteQueryResponse - { - return $this->startApiCall('CompleteQuery', $request, $callOptions)->wait(); - } -} diff --git a/Talent/src/V4/Client/BaseClient/EventServiceBaseClient.php b/Talent/src/V4/Client/BaseClient/EventServiceBaseClient.php deleted file mode 100644 index 4641c1fd4b27..000000000000 --- a/Talent/src/V4/Client/BaseClient/EventServiceBaseClient.php +++ /dev/null @@ -1,242 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/event_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/event_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/event_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/event_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a tenant - * resource. - * - * @param string $project - * @param string $tenant - * - * @return string The formatted tenant resource. - */ - public static function tenantName(string $project, string $tenant): string - { - return self::getPathTemplate('tenant')->render([ - 'project' => $project, - 'tenant' => $tenant, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - tenant: projects/{project}/tenants/{tenant} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'jobs.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Report events issued when end user interacts with customer's application - * that uses Cloud Talent Solution. You may inspect the created events in - * [self service - * tools](https://console.cloud.google.com/talent-solution/overview). - * [Learn - * more](https://cloud.google.com/talent-solution/docs/management-tools) - * about self service tools. - * - * The async variant is {@see self::createClientEventAsync()} . - * - * @param CreateClientEventRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ClientEvent - * - * @throws ApiException Thrown if the API call fails. - */ - public function createClientEvent(CreateClientEventRequest $request, array $callOptions = []): ClientEvent - { - return $this->startApiCall('CreateClientEvent', $request, $callOptions)->wait(); - } -} diff --git a/Talent/src/V4/Client/BaseClient/JobServiceBaseClient.php b/Talent/src/V4/Client/BaseClient/JobServiceBaseClient.php deleted file mode 100644 index 03ba8718b5d6..000000000000 --- a/Talent/src/V4/Client/BaseClient/JobServiceBaseClient.php +++ /dev/null @@ -1,571 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/job_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/job_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/job_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/job_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a company - * resource. - * - * @param string $project - * @param string $tenant - * @param string $company - * - * @return string The formatted company resource. - */ - public static function companyName(string $project, string $tenant, string $company): string - { - return self::getPathTemplate('company')->render([ - 'project' => $project, - 'tenant' => $tenant, - 'company' => $company, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a job - * resource. - * - * @param string $project - * @param string $tenant - * @param string $job - * - * @return string The formatted job resource. - */ - public static function jobName(string $project, string $tenant, string $job): string - { - return self::getPathTemplate('job')->render([ - 'project' => $project, - 'tenant' => $tenant, - 'job' => $job, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a tenant - * resource. - * - * @param string $project - * @param string $tenant - * - * @return string The formatted tenant resource. - */ - public static function tenantName(string $project, string $tenant): string - { - return self::getPathTemplate('tenant')->render([ - 'project' => $project, - 'tenant' => $tenant, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - company: projects/{project}/tenants/{tenant}/companies/{company} - * - job: projects/{project}/tenants/{tenant}/jobs/{job} - * - tenant: projects/{project}/tenants/{tenant} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'jobs.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Begins executing a batch create jobs operation. - * - * The async variant is {@see self::batchCreateJobsAsync()} . - * - * @param BatchCreateJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchCreateJobs(BatchCreateJobsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BatchCreateJobs', $request, $callOptions)->wait(); - } - - /** - * Begins executing a batch delete jobs operation. - * - * The async variant is {@see self::batchDeleteJobsAsync()} . - * - * @param BatchDeleteJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchDeleteJobs(BatchDeleteJobsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BatchDeleteJobs', $request, $callOptions)->wait(); - } - - /** - * Begins executing a batch update jobs operation. - * - * The async variant is {@see self::batchUpdateJobsAsync()} . - * - * @param BatchUpdateJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchUpdateJobs(BatchUpdateJobsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BatchUpdateJobs', $request, $callOptions)->wait(); - } - - /** - * Creates a new job. - * - * Typically, the job becomes searchable within 10 seconds, but it may take - * up to 5 minutes. - * - * The async variant is {@see self::createJobAsync()} . - * - * @param CreateJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - */ - public function createJob(CreateJobRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('CreateJob', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified job. - * - * Typically, the job becomes unsearchable within 10 seconds, but it may take - * up to 5 minutes. - * - * The async variant is {@see self::deleteJobAsync()} . - * - * @param DeleteJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteJob(DeleteJobRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteJob', $request, $callOptions)->wait(); - } - - /** - * Retrieves the specified job, whose status is OPEN or recently EXPIRED - * within the last 90 days. - * - * The async variant is {@see self::getJobAsync()} . - * - * @param GetJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - */ - public function getJob(GetJobRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('GetJob', $request, $callOptions)->wait(); - } - - /** - * Lists jobs by filter. - * - * The async variant is {@see self::listJobsAsync()} . - * - * @param ListJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listJobs(ListJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListJobs', $request, $callOptions); - } - - /** - * Searches for jobs using the provided - * [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. - * - * This call constrains the - * [visibility][google.cloud.talent.v4.Job.visibility] of jobs present in the - * database, and only returns jobs that the caller has permission to search - * against. - * - * The async variant is {@see self::searchJobsAsync()} . - * - * @param SearchJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SearchJobsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchJobs(SearchJobsRequest $request, array $callOptions = []): SearchJobsResponse - { - return $this->startApiCall('SearchJobs', $request, $callOptions)->wait(); - } - - /** - * Searches for jobs using the provided - * [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. - * - * This API call is intended for the use case of targeting passive job - * seekers (for example, job seekers who have signed up to receive email - * alerts about potential job opportunities), it has different algorithmic - * adjustments that are designed to specifically target passive job seekers. - * - * This call constrains the - * [visibility][google.cloud.talent.v4.Job.visibility] of jobs present in the - * database, and only returns jobs the caller has permission to search - * against. - * - * The async variant is {@see self::searchJobsForAlertAsync()} . - * - * @param SearchJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SearchJobsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchJobsForAlert(SearchJobsRequest $request, array $callOptions = []): SearchJobsResponse - { - return $this->startApiCall('SearchJobsForAlert', $request, $callOptions)->wait(); - } - - /** - * Updates specified job. - * - * Typically, updated contents become visible in search results within 10 - * seconds, but it may take up to 5 minutes. - * - * The async variant is {@see self::updateJobAsync()} . - * - * @param UpdateJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateJob(UpdateJobRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('UpdateJob', $request, $callOptions)->wait(); - } -} diff --git a/Talent/src/V4/Client/BaseClient/TenantServiceBaseClient.php b/Talent/src/V4/Client/BaseClient/TenantServiceBaseClient.php deleted file mode 100644 index 07826dae7728..000000000000 --- a/Talent/src/V4/Client/BaseClient/TenantServiceBaseClient.php +++ /dev/null @@ -1,355 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/tenant_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/tenant_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/tenant_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/tenant_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a tenant - * resource. - * - * @param string $project - * @param string $tenant - * - * @return string The formatted tenant resource. - */ - public static function tenantName(string $project, string $tenant): string - { - return self::getPathTemplate('tenant')->render([ - 'project' => $project, - 'tenant' => $tenant, - ]); - } - - /** - * 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} - * - tenant: projects/{project}/tenants/{tenant} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'jobs.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new tenant entity. - * - * The async variant is {@see self::createTenantAsync()} . - * - * @param CreateTenantRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Tenant - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTenant(CreateTenantRequest $request, array $callOptions = []): Tenant - { - return $this->startApiCall('CreateTenant', $request, $callOptions)->wait(); - } - - /** - * Deletes specified tenant. - * - * The async variant is {@see self::deleteTenantAsync()} . - * - * @param DeleteTenantRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTenant(DeleteTenantRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteTenant', $request, $callOptions)->wait(); - } - - /** - * Retrieves specified tenant. - * - * The async variant is {@see self::getTenantAsync()} . - * - * @param GetTenantRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Tenant - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTenant(GetTenantRequest $request, array $callOptions = []): Tenant - { - return $this->startApiCall('GetTenant', $request, $callOptions)->wait(); - } - - /** - * Lists all tenants associated with the project. - * - * The async variant is {@see self::listTenantsAsync()} . - * - * @param ListTenantsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTenants(ListTenantsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTenants', $request, $callOptions); - } - - /** - * Updates specified tenant. - * - * The async variant is {@see self::updateTenantAsync()} . - * - * @param UpdateTenantRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Tenant - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateTenant(UpdateTenantRequest $request, array $callOptions = []): Tenant - { - return $this->startApiCall('UpdateTenant', $request, $callOptions)->wait(); - } -} diff --git a/Talent/src/V4/Client/CompanyServiceClient.php b/Talent/src/V4/Client/CompanyServiceClient.php index 90b6ea65ab15..afaceb25b2d1 100644 --- a/Talent/src/V4/Client/CompanyServiceClient.php +++ b/Talent/src/V4/Client/CompanyServiceClient.php @@ -24,17 +24,335 @@ namespace Google\Cloud\Talent\V4\Client; -use Google\Cloud\Talent\V4\Client\BaseClient\CompanyServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Talent\V4\Company; +use Google\Cloud\Talent\V4\CreateCompanyRequest; +use Google\Cloud\Talent\V4\DeleteCompanyRequest; +use Google\Cloud\Talent\V4\GetCompanyRequest; +use Google\Cloud\Talent\V4\ListCompaniesRequest; +use Google\Cloud\Talent\V4\UpdateCompanyRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service that handles company management, including CRUD and enumeration. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Talent\V4\CompanyServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createCompanyAsync(CreateCompanyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteCompanyAsync(DeleteCompanyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCompanyAsync(GetCompanyRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCompaniesAsync(ListCompaniesRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCompanyAsync(UpdateCompanyRequest $request, array $optionalArgs = []) */ -final class CompanyServiceClient extends CompanyServiceBaseClient +final class CompanyServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CompanyServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.talent.v4.CompanyService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'jobs.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/jobs', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/company_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/company_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/company_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/company_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a company + * resource. + * + * @param string $project + * @param string $tenant + * @param string $company + * + * @return string The formatted company resource. + */ + public static function companyName(string $project, string $tenant, string $company): string + { + return self::getPathTemplate('company')->render([ + 'project' => $project, + 'tenant' => $tenant, + 'company' => $company, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a tenant + * resource. + * + * @param string $project + * @param string $tenant + * + * @return string The formatted tenant resource. + */ + public static function tenantName(string $project, string $tenant): string + { + return self::getPathTemplate('tenant')->render([ + 'project' => $project, + 'tenant' => $tenant, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - company: projects/{project}/tenants/{tenant}/companies/{company} + * - tenant: projects/{project}/tenants/{tenant} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'jobs.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new company entity. + * + * The async variant is {@see CompanyServiceClient::createCompanyAsync()} . + * + * @param CreateCompanyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Company + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCompany(CreateCompanyRequest $request, array $callOptions = []): Company + { + return $this->startApiCall('CreateCompany', $request, $callOptions)->wait(); + } + + /** + * Deletes specified company. + * Prerequisite: The company has no jobs associated with it. + * + * The async variant is {@see CompanyServiceClient::deleteCompanyAsync()} . + * + * @param DeleteCompanyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteCompany(DeleteCompanyRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteCompany', $request, $callOptions)->wait(); + } + + /** + * Retrieves specified company. + * + * The async variant is {@see CompanyServiceClient::getCompanyAsync()} . + * + * @param GetCompanyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Company + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCompany(GetCompanyRequest $request, array $callOptions = []): Company + { + return $this->startApiCall('GetCompany', $request, $callOptions)->wait(); + } + + /** + * Lists all companies associated with the project. + * + * The async variant is {@see CompanyServiceClient::listCompaniesAsync()} . + * + * @param ListCompaniesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCompanies(ListCompaniesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCompanies', $request, $callOptions); + } + + /** + * Updates specified company. + * + * The async variant is {@see CompanyServiceClient::updateCompanyAsync()} . + * + * @param UpdateCompanyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Company + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCompany(UpdateCompanyRequest $request, array $callOptions = []): Company + { + return $this->startApiCall('UpdateCompany', $request, $callOptions)->wait(); + } } diff --git a/Talent/src/V4/Client/CompletionClient.php b/Talent/src/V4/Client/CompletionClient.php index 24cb8002d97e..d5c74394f7d1 100644 --- a/Talent/src/V4/Client/CompletionClient.php +++ b/Talent/src/V4/Client/CompletionClient.php @@ -24,17 +24,232 @@ namespace Google\Cloud\Talent\V4\Client; -use Google\Cloud\Talent\V4\Client\BaseClient\CompletionBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Talent\V4\CompleteQueryRequest; +use Google\Cloud\Talent\V4\CompleteQueryResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service handles auto completion. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Talent\V4\CompletionClient} for the stable implementation * * @experimental + * + * @method PromiseInterface completeQueryAsync(CompleteQueryRequest $request, array $optionalArgs = []) */ -final class CompletionClient extends CompletionBaseClient +final class CompletionClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CompletionBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.talent.v4.Completion'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'jobs.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/jobs', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/completion_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/completion_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/completion_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/completion_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a company + * resource. + * + * @param string $project + * @param string $tenant + * @param string $company + * + * @return string The formatted company resource. + */ + public static function companyName(string $project, string $tenant, string $company): string + { + return self::getPathTemplate('company')->render([ + 'project' => $project, + 'tenant' => $tenant, + 'company' => $company, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a tenant + * resource. + * + * @param string $project + * @param string $tenant + * + * @return string The formatted tenant resource. + */ + public static function tenantName(string $project, string $tenant): string + { + return self::getPathTemplate('tenant')->render([ + 'project' => $project, + 'tenant' => $tenant, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - company: projects/{project}/tenants/{tenant}/companies/{company} + * - tenant: projects/{project}/tenants/{tenant} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'jobs.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Completes the specified prefix with keyword suggestions. + * Intended for use by a job search auto-complete search box. + * + * The async variant is {@see CompletionClient::completeQueryAsync()} . + * + * @param CompleteQueryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CompleteQueryResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function completeQuery(CompleteQueryRequest $request, array $callOptions = []): CompleteQueryResponse + { + return $this->startApiCall('CompleteQuery', $request, $callOptions)->wait(); + } } diff --git a/Talent/src/V4/Client/EventServiceClient.php b/Talent/src/V4/Client/EventServiceClient.php index 429b8c27debd..182aeecdbd95 100644 --- a/Talent/src/V4/Client/EventServiceClient.php +++ b/Talent/src/V4/Client/EventServiceClient.php @@ -24,17 +24,217 @@ namespace Google\Cloud\Talent\V4\Client; -use Google\Cloud\Talent\V4\Client\BaseClient\EventServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Talent\V4\ClientEvent; +use Google\Cloud\Talent\V4\CreateClientEventRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service handles client event report. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Talent\V4\EventServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createClientEventAsync(CreateClientEventRequest $request, array $optionalArgs = []) */ -final class EventServiceClient extends EventServiceBaseClient +final class EventServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see EventServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.talent.v4.EventService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'jobs.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/jobs', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/event_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/event_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/event_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/event_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a tenant + * resource. + * + * @param string $project + * @param string $tenant + * + * @return string The formatted tenant resource. + */ + public static function tenantName(string $project, string $tenant): string + { + return self::getPathTemplate('tenant')->render([ + 'project' => $project, + 'tenant' => $tenant, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - tenant: projects/{project}/tenants/{tenant} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'jobs.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Report events issued when end user interacts with customer's application + * that uses Cloud Talent Solution. You may inspect the created events in + * [self service + * tools](https://console.cloud.google.com/talent-solution/overview). + * [Learn + * more](https://cloud.google.com/talent-solution/docs/management-tools) + * about self service tools. + * + * The async variant is {@see EventServiceClient::createClientEventAsync()} . + * + * @param CreateClientEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ClientEvent + * + * @throws ApiException Thrown if the API call fails. + */ + public function createClientEvent(CreateClientEventRequest $request, array $callOptions = []): ClientEvent + { + return $this->startApiCall('CreateClientEvent', $request, $callOptions)->wait(); + } } diff --git a/Talent/src/V4/Client/JobServiceClient.php b/Talent/src/V4/Client/JobServiceClient.php index 41eeb6028837..53c690d172e0 100644 --- a/Talent/src/V4/Client/JobServiceClient.php +++ b/Talent/src/V4/Client/JobServiceClient.php @@ -24,17 +24,546 @@ namespace Google\Cloud\Talent\V4\Client; -use Google\Cloud\Talent\V4\Client\BaseClient\JobServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Talent\V4\BatchCreateJobsRequest; +use Google\Cloud\Talent\V4\BatchDeleteJobsRequest; +use Google\Cloud\Talent\V4\BatchUpdateJobsRequest; +use Google\Cloud\Talent\V4\CreateJobRequest; +use Google\Cloud\Talent\V4\DeleteJobRequest; +use Google\Cloud\Talent\V4\GetJobRequest; +use Google\Cloud\Talent\V4\Job; +use Google\Cloud\Talent\V4\ListJobsRequest; +use Google\Cloud\Talent\V4\SearchJobsRequest; +use Google\Cloud\Talent\V4\SearchJobsResponse; +use Google\Cloud\Talent\V4\UpdateJobRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service handles job management, including job CRUD, enumeration and search. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Talent\V4\JobServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface batchCreateJobsAsync(BatchCreateJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface batchDeleteJobsAsync(BatchDeleteJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface batchUpdateJobsAsync(BatchUpdateJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface createJobAsync(CreateJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteJobAsync(DeleteJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getJobAsync(GetJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface listJobsAsync(ListJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchJobsAsync(SearchJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchJobsForAlertAsync(SearchJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateJobAsync(UpdateJobRequest $request, array $optionalArgs = []) */ -final class JobServiceClient extends JobServiceBaseClient +final class JobServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see JobServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.talent.v4.JobService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'jobs.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/jobs', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/job_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/job_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/job_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/job_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a company + * resource. + * + * @param string $project + * @param string $tenant + * @param string $company + * + * @return string The formatted company resource. + */ + public static function companyName(string $project, string $tenant, string $company): string + { + return self::getPathTemplate('company')->render([ + 'project' => $project, + 'tenant' => $tenant, + 'company' => $company, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a job + * resource. + * + * @param string $project + * @param string $tenant + * @param string $job + * + * @return string The formatted job resource. + */ + public static function jobName(string $project, string $tenant, string $job): string + { + return self::getPathTemplate('job')->render([ + 'project' => $project, + 'tenant' => $tenant, + 'job' => $job, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a tenant + * resource. + * + * @param string $project + * @param string $tenant + * + * @return string The formatted tenant resource. + */ + public static function tenantName(string $project, string $tenant): string + { + return self::getPathTemplate('tenant')->render([ + 'project' => $project, + 'tenant' => $tenant, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - company: projects/{project}/tenants/{tenant}/companies/{company} + * - job: projects/{project}/tenants/{tenant}/jobs/{job} + * - tenant: projects/{project}/tenants/{tenant} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'jobs.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Begins executing a batch create jobs operation. + * + * The async variant is {@see JobServiceClient::batchCreateJobsAsync()} . + * + * @param BatchCreateJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchCreateJobs(BatchCreateJobsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchCreateJobs', $request, $callOptions)->wait(); + } + + /** + * Begins executing a batch delete jobs operation. + * + * The async variant is {@see JobServiceClient::batchDeleteJobsAsync()} . + * + * @param BatchDeleteJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchDeleteJobs(BatchDeleteJobsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchDeleteJobs', $request, $callOptions)->wait(); + } + + /** + * Begins executing a batch update jobs operation. + * + * The async variant is {@see JobServiceClient::batchUpdateJobsAsync()} . + * + * @param BatchUpdateJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchUpdateJobs(BatchUpdateJobsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchUpdateJobs', $request, $callOptions)->wait(); + } + + /** + * Creates a new job. + * + * Typically, the job becomes searchable within 10 seconds, but it may take + * up to 5 minutes. + * + * The async variant is {@see JobServiceClient::createJobAsync()} . + * + * @param CreateJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + */ + public function createJob(CreateJobRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('CreateJob', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified job. + * + * Typically, the job becomes unsearchable within 10 seconds, but it may take + * up to 5 minutes. + * + * The async variant is {@see JobServiceClient::deleteJobAsync()} . + * + * @param DeleteJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteJob(DeleteJobRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteJob', $request, $callOptions)->wait(); + } + + /** + * Retrieves the specified job, whose status is OPEN or recently EXPIRED + * within the last 90 days. + * + * The async variant is {@see JobServiceClient::getJobAsync()} . + * + * @param GetJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + */ + public function getJob(GetJobRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('GetJob', $request, $callOptions)->wait(); + } + + /** + * Lists jobs by filter. + * + * The async variant is {@see JobServiceClient::listJobsAsync()} . + * + * @param ListJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listJobs(ListJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListJobs', $request, $callOptions); + } + + /** + * Searches for jobs using the provided + * [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. + * + * This call constrains the + * [visibility][google.cloud.talent.v4.Job.visibility] of jobs present in the + * database, and only returns jobs that the caller has permission to search + * against. + * + * The async variant is {@see JobServiceClient::searchJobsAsync()} . + * + * @param SearchJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SearchJobsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchJobs(SearchJobsRequest $request, array $callOptions = []): SearchJobsResponse + { + return $this->startApiCall('SearchJobs', $request, $callOptions)->wait(); + } + + /** + * Searches for jobs using the provided + * [SearchJobsRequest][google.cloud.talent.v4.SearchJobsRequest]. + * + * This API call is intended for the use case of targeting passive job + * seekers (for example, job seekers who have signed up to receive email + * alerts about potential job opportunities), it has different algorithmic + * adjustments that are designed to specifically target passive job seekers. + * + * This call constrains the + * [visibility][google.cloud.talent.v4.Job.visibility] of jobs present in the + * database, and only returns jobs the caller has permission to search + * against. + * + * The async variant is {@see JobServiceClient::searchJobsForAlertAsync()} . + * + * @param SearchJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SearchJobsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchJobsForAlert(SearchJobsRequest $request, array $callOptions = []): SearchJobsResponse + { + return $this->startApiCall('SearchJobsForAlert', $request, $callOptions)->wait(); + } + + /** + * Updates specified job. + * + * Typically, updated contents become visible in search results within 10 + * seconds, but it may take up to 5 minutes. + * + * The async variant is {@see JobServiceClient::updateJobAsync()} . + * + * @param UpdateJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateJob(UpdateJobRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('UpdateJob', $request, $callOptions)->wait(); + } } diff --git a/Talent/src/V4/Client/TenantServiceClient.php b/Talent/src/V4/Client/TenantServiceClient.php index 5fd9bed68911..d36d20090895 100644 --- a/Talent/src/V4/Client/TenantServiceClient.php +++ b/Talent/src/V4/Client/TenantServiceClient.php @@ -24,17 +24,330 @@ namespace Google\Cloud\Talent\V4\Client; -use Google\Cloud\Talent\V4\Client\BaseClient\TenantServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Talent\V4\CreateTenantRequest; +use Google\Cloud\Talent\V4\DeleteTenantRequest; +use Google\Cloud\Talent\V4\GetTenantRequest; +use Google\Cloud\Talent\V4\ListTenantsRequest; +use Google\Cloud\Talent\V4\Tenant; +use Google\Cloud\Talent\V4\UpdateTenantRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: A service that handles tenant management, including CRUD and enumeration. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Talent\V4\TenantServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createTenantAsync(CreateTenantRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTenantAsync(DeleteTenantRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTenantAsync(GetTenantRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTenantsAsync(ListTenantsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateTenantAsync(UpdateTenantRequest $request, array $optionalArgs = []) */ -final class TenantServiceClient extends TenantServiceBaseClient +final class TenantServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TenantServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.talent.v4.TenantService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'jobs.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/jobs', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/tenant_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/tenant_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/tenant_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/tenant_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a tenant + * resource. + * + * @param string $project + * @param string $tenant + * + * @return string The formatted tenant resource. + */ + public static function tenantName(string $project, string $tenant): string + { + return self::getPathTemplate('tenant')->render([ + 'project' => $project, + 'tenant' => $tenant, + ]); + } + + /** + * 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} + * - tenant: projects/{project}/tenants/{tenant} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'jobs.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new tenant entity. + * + * The async variant is {@see TenantServiceClient::createTenantAsync()} . + * + * @param CreateTenantRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Tenant + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTenant(CreateTenantRequest $request, array $callOptions = []): Tenant + { + return $this->startApiCall('CreateTenant', $request, $callOptions)->wait(); + } + + /** + * Deletes specified tenant. + * + * The async variant is {@see TenantServiceClient::deleteTenantAsync()} . + * + * @param DeleteTenantRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTenant(DeleteTenantRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteTenant', $request, $callOptions)->wait(); + } + + /** + * Retrieves specified tenant. + * + * The async variant is {@see TenantServiceClient::getTenantAsync()} . + * + * @param GetTenantRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Tenant + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTenant(GetTenantRequest $request, array $callOptions = []): Tenant + { + return $this->startApiCall('GetTenant', $request, $callOptions)->wait(); + } + + /** + * Lists all tenants associated with the project. + * + * The async variant is {@see TenantServiceClient::listTenantsAsync()} . + * + * @param ListTenantsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTenants(ListTenantsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTenants', $request, $callOptions); + } + + /** + * Updates specified tenant. + * + * The async variant is {@see TenantServiceClient::updateTenantAsync()} . + * + * @param UpdateTenantRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Tenant + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTenant(UpdateTenantRequest $request, array $callOptions = []): Tenant + { + return $this->startApiCall('UpdateTenant', $request, $callOptions)->wait(); + } } diff --git a/Tasks/composer.json b/Tasks/composer.json index 570a98c33283..65413cec6c49 100644 --- a/Tasks/composer.json +++ b/Tasks/composer.json @@ -24,11 +24,11 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", - "google/cloud-core": "^1.39" + "google/cloud-core": "^1.52.7" }, "suggest": { "ext-grpc": "Enables use of gRPC, a universal high-performance RPC framework created by Google.", diff --git a/Tasks/src/V2/Client/BaseClient/CloudTasksBaseClient.php b/Tasks/src/V2/Client/BaseClient/CloudTasksBaseClient.php deleted file mode 100644 index dc88f0a9abcd..000000000000 --- a/Tasks/src/V2/Client/BaseClient/CloudTasksBaseClient.php +++ /dev/null @@ -1,849 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/cloud_tasks_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/cloud_tasks_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/cloud_tasks_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/cloud_tasks_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a queue - * resource. - * - * @param string $project - * @param string $location - * @param string $queue - * - * @return string The formatted queue resource. - */ - public static function queueName(string $project, string $location, string $queue): string - { - return self::getPathTemplate('queue')->render([ - 'project' => $project, - 'location' => $location, - 'queue' => $queue, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a task - * resource. - * - * @param string $project - * @param string $location - * @param string $queue - * @param string $task - * - * @return string The formatted task resource. - */ - public static function taskName(string $project, string $location, string $queue, string $task): string - { - return self::getPathTemplate('task')->render([ - 'project' => $project, - 'location' => $location, - 'queue' => $queue, - 'task' => $task, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - location: projects/{project}/locations/{location} - * - queue: projects/{project}/locations/{location}/queues/{queue} - * - task: projects/{project}/locations/{location}/queues/{queue}/tasks/{task} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudtasks.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a queue. - * - * Queues created with this method allow tasks to live for a maximum of 31 - * days. After a task is 31 days old, the task will be deleted regardless of - * whether it was dispatched or not. - * - * WARNING: Using this method may have unintended side effects if you are - * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. - * Read - * [Overview of Queue Management and - * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using - * this method. - * - * The async variant is {@see self::createQueueAsync()} . - * - * @param CreateQueueRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Queue - * - * @throws ApiException Thrown if the API call fails. - */ - public function createQueue(CreateQueueRequest $request, array $callOptions = []): Queue - { - return $this->startApiCall('CreateQueue', $request, $callOptions)->wait(); - } - - /** - * Creates a task and adds it to a queue. - * - * Tasks cannot be updated after creation; there is no UpdateTask command. - * - * * The maximum task size is 100KB. - * - * The async variant is {@see self::createTaskAsync()} . - * - * @param CreateTaskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Task - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTask(CreateTaskRequest $request, array $callOptions = []): Task - { - return $this->startApiCall('CreateTask', $request, $callOptions)->wait(); - } - - /** - * Deletes a queue. - * - * This command will delete the queue even if it has tasks in it. - * - * Note: If you delete a queue, a queue with the same name can't be created - * for 7 days. - * - * WARNING: Using this method may have unintended side effects if you are - * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. - * Read - * [Overview of Queue Management and - * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using - * this method. - * - * The async variant is {@see self::deleteQueueAsync()} . - * - * @param DeleteQueueRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteQueue(DeleteQueueRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteQueue', $request, $callOptions)->wait(); - } - - /** - * Deletes a task. - * - * A task can be deleted if it is scheduled or dispatched. A task - * cannot be deleted if it has executed successfully or permanently - * failed. - * - * The async variant is {@see self::deleteTaskAsync()} . - * - * @param DeleteTaskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTask(DeleteTaskRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteTask', $request, $callOptions)->wait(); - } - - /** - * Gets the access control policy for a [Queue][google.cloud.tasks.v2.Queue]. - * Returns an empty policy if the resource exists and does not have a policy - * set. - * - * Authorization requires the following - * [Google IAM](https://cloud.google.com/iam) permission on the specified - * resource parent: - * - * * `cloudtasks.queues.getIamPolicy` - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets a queue. - * - * The async variant is {@see self::getQueueAsync()} . - * - * @param GetQueueRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Queue - * - * @throws ApiException Thrown if the API call fails. - */ - public function getQueue(GetQueueRequest $request, array $callOptions = []): Queue - { - return $this->startApiCall('GetQueue', $request, $callOptions)->wait(); - } - - /** - * Gets a task. - * - * The async variant is {@see self::getTaskAsync()} . - * - * @param GetTaskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Task - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTask(GetTaskRequest $request, array $callOptions = []): Task - { - return $this->startApiCall('GetTask', $request, $callOptions)->wait(); - } - - /** - * Lists queues. - * - * Queues are returned in lexicographical order. - * - * The async variant is {@see self::listQueuesAsync()} . - * - * @param ListQueuesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listQueues(ListQueuesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListQueues', $request, $callOptions); - } - - /** - * Lists the tasks in a queue. - * - * By default, only the [BASIC][google.cloud.tasks.v2.Task.View.BASIC] view is - * retrieved due to performance considerations; - * [response_view][google.cloud.tasks.v2.ListTasksRequest.response_view] - * controls the subset of information which is returned. - * - * The tasks may be returned in any order. The ordering may change at any - * time. - * - * The async variant is {@see self::listTasksAsync()} . - * - * @param ListTasksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTasks(ListTasksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTasks', $request, $callOptions); - } - - /** - * Pauses the queue. - * - * If a queue is paused then the system will stop dispatching tasks - * until the queue is resumed via - * [ResumeQueue][google.cloud.tasks.v2.CloudTasks.ResumeQueue]. Tasks can - * still be added when the queue is paused. A queue is paused if its - * [state][google.cloud.tasks.v2.Queue.state] is - * [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED]. - * - * The async variant is {@see self::pauseQueueAsync()} . - * - * @param PauseQueueRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Queue - * - * @throws ApiException Thrown if the API call fails. - */ - public function pauseQueue(PauseQueueRequest $request, array $callOptions = []): Queue - { - return $this->startApiCall('PauseQueue', $request, $callOptions)->wait(); - } - - /** - * Purges a queue by deleting all of its tasks. - * - * All tasks created before this method is called are permanently deleted. - * - * Purge operations can take up to one minute to take effect. Tasks - * might be dispatched before the purge takes effect. A purge is irreversible. - * - * The async variant is {@see self::purgeQueueAsync()} . - * - * @param PurgeQueueRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Queue - * - * @throws ApiException Thrown if the API call fails. - */ - public function purgeQueue(PurgeQueueRequest $request, array $callOptions = []): Queue - { - return $this->startApiCall('PurgeQueue', $request, $callOptions)->wait(); - } - - /** - * Resume a queue. - * - * This method resumes a queue after it has been - * [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED] or - * [DISABLED][google.cloud.tasks.v2.Queue.State.DISABLED]. The state of a - * queue is stored in the queue's [state][google.cloud.tasks.v2.Queue.state]; - * after calling this method it will be set to - * [RUNNING][google.cloud.tasks.v2.Queue.State.RUNNING]. - * - * WARNING: Resuming many high-QPS queues at the same time can - * lead to target overloading. If you are resuming high-QPS - * queues, follow the 500/50/5 pattern described in - * [Managing Cloud Tasks Scaling - * Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling). - * - * The async variant is {@see self::resumeQueueAsync()} . - * - * @param ResumeQueueRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Queue - * - * @throws ApiException Thrown if the API call fails. - */ - public function resumeQueue(ResumeQueueRequest $request, array $callOptions = []): Queue - { - return $this->startApiCall('ResumeQueue', $request, $callOptions)->wait(); - } - - /** - * Forces a task to run now. - * - * When this method is called, Cloud Tasks will dispatch the task, even if - * the task is already running, the queue has reached its - * [RateLimits][google.cloud.tasks.v2.RateLimits] or is - * [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED]. - * - * This command is meant to be used for manual debugging. For - * example, [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask] can be used to - * retry a failed task after a fix has been made or to manually force a task - * to be dispatched now. - * - * The dispatched task is returned. That is, the task that is returned - * contains the [status][Task.status] after the task is dispatched but - * before the task is received by its target. - * - * If Cloud Tasks receives a successful response from the task's - * target, then the task will be deleted; otherwise the task's - * [schedule_time][google.cloud.tasks.v2.Task.schedule_time] will be reset to - * the time that [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask] was - * called plus the retry delay specified in the queue's - * [RetryConfig][google.cloud.tasks.v2.RetryConfig]. - * - * [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask] returns - * [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a - * task that has already succeeded or permanently failed. - * - * The async variant is {@see self::runTaskAsync()} . - * - * @param RunTaskRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Task - * - * @throws ApiException Thrown if the API call fails. - */ - public function runTask(RunTaskRequest $request, array $callOptions = []): Task - { - return $this->startApiCall('RunTask', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy for a [Queue][google.cloud.tasks.v2.Queue]. - * Replaces any existing policy. - * - * Note: The Cloud Console does not check queue-level IAM permissions yet. - * Project-level permissions are required to use the Cloud Console. - * - * Authorization requires the following - * [Google IAM](https://cloud.google.com/iam) permission on the specified - * resource parent: - * - * * `cloudtasks.queues.setIamPolicy` - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on a - * [Queue][google.cloud.tasks.v2.Queue]. If the resource does not exist, this - * will return an empty set of permissions, not a - * [NOT_FOUND][google.rpc.Code.NOT_FOUND] error. - * - * Note: This operation is designed to be used for building permission-aware - * UIs and command-line tools, not for authorization checking. This operation - * may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } - - /** - * Updates a queue. - * - * This method creates the queue if it does not exist and updates - * the queue if it does exist. - * - * Queues created with this method allow tasks to live for a maximum of 31 - * days. After a task is 31 days old, the task will be deleted regardless of - * whether it was dispatched or not. - * - * WARNING: Using this method may have unintended side effects if you are - * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. - * Read - * [Overview of Queue Management and - * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using - * this method. - * - * The async variant is {@see self::updateQueueAsync()} . - * - * @param UpdateQueueRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Queue - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateQueue(UpdateQueueRequest $request, array $callOptions = []): Queue - { - return $this->startApiCall('UpdateQueue', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Tasks/src/V2/Client/CloudTasksClient.php b/Tasks/src/V2/Client/CloudTasksClient.php index 49c3f971388c..bfea5bbf0169 100644 --- a/Tasks/src/V2/Client/CloudTasksClient.php +++ b/Tasks/src/V2/Client/CloudTasksClient.php @@ -24,15 +24,824 @@ namespace Google\Cloud\Tasks\V2\Client; -use Google\Cloud\Tasks\V2\Client\BaseClient\CloudTasksBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\Tasks\V2\CreateQueueRequest; +use Google\Cloud\Tasks\V2\CreateTaskRequest; +use Google\Cloud\Tasks\V2\DeleteQueueRequest; +use Google\Cloud\Tasks\V2\DeleteTaskRequest; +use Google\Cloud\Tasks\V2\GetQueueRequest; +use Google\Cloud\Tasks\V2\GetTaskRequest; +use Google\Cloud\Tasks\V2\ListQueuesRequest; +use Google\Cloud\Tasks\V2\ListTasksRequest; +use Google\Cloud\Tasks\V2\PauseQueueRequest; +use Google\Cloud\Tasks\V2\PurgeQueueRequest; +use Google\Cloud\Tasks\V2\Queue; +use Google\Cloud\Tasks\V2\ResumeQueueRequest; +use Google\Cloud\Tasks\V2\RunTaskRequest; +use Google\Cloud\Tasks\V2\Task; +use Google\Cloud\Tasks\V2\UpdateQueueRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Cloud Tasks allows developers to manage the execution of background + * work in their applications. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Tasks\V2\CloudTasksClient} for the stable implementation + * + * @method PromiseInterface createQueueAsync(CreateQueueRequest $request, array $optionalArgs = []) + * @method PromiseInterface createTaskAsync(CreateTaskRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteQueueAsync(DeleteQueueRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTaskAsync(DeleteTaskRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getQueueAsync(GetQueueRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTaskAsync(GetTaskRequest $request, array $optionalArgs = []) + * @method PromiseInterface listQueuesAsync(ListQueuesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTasksAsync(ListTasksRequest $request, array $optionalArgs = []) + * @method PromiseInterface pauseQueueAsync(PauseQueueRequest $request, array $optionalArgs = []) + * @method PromiseInterface purgeQueueAsync(PurgeQueueRequest $request, array $optionalArgs = []) + * @method PromiseInterface resumeQueueAsync(ResumeQueueRequest $request, array $optionalArgs = []) + * @method PromiseInterface runTaskAsync(RunTaskRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateQueueAsync(UpdateQueueRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class CloudTasksClient extends CloudTasksBaseClient +final class CloudTasksClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see CloudTasksBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.tasks.v2.CloudTasks'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudtasks.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/cloud_tasks_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/cloud_tasks_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/cloud_tasks_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/cloud_tasks_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a queue + * resource. + * + * @param string $project + * @param string $location + * @param string $queue + * + * @return string The formatted queue resource. + */ + public static function queueName(string $project, string $location, string $queue): string + { + return self::getPathTemplate('queue')->render([ + 'project' => $project, + 'location' => $location, + 'queue' => $queue, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a task + * resource. + * + * @param string $project + * @param string $location + * @param string $queue + * @param string $task + * + * @return string The formatted task resource. + */ + public static function taskName(string $project, string $location, string $queue, string $task): string + { + return self::getPathTemplate('task')->render([ + 'project' => $project, + 'location' => $location, + 'queue' => $queue, + 'task' => $task, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - location: projects/{project}/locations/{location} + * - queue: projects/{project}/locations/{location}/queues/{queue} + * - task: projects/{project}/locations/{location}/queues/{queue}/tasks/{task} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudtasks.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a queue. + * + * Queues created with this method allow tasks to live for a maximum of 31 + * days. After a task is 31 days old, the task will be deleted regardless of + * whether it was dispatched or not. + * + * WARNING: Using this method may have unintended side effects if you are + * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. + * Read + * [Overview of Queue Management and + * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using + * this method. + * + * The async variant is {@see CloudTasksClient::createQueueAsync()} . + * + * @param CreateQueueRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Queue + * + * @throws ApiException Thrown if the API call fails. + */ + public function createQueue(CreateQueueRequest $request, array $callOptions = []): Queue + { + return $this->startApiCall('CreateQueue', $request, $callOptions)->wait(); + } + + /** + * Creates a task and adds it to a queue. + * + * Tasks cannot be updated after creation; there is no UpdateTask command. + * + * * The maximum task size is 100KB. + * + * The async variant is {@see CloudTasksClient::createTaskAsync()} . + * + * @param CreateTaskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Task + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTask(CreateTaskRequest $request, array $callOptions = []): Task + { + return $this->startApiCall('CreateTask', $request, $callOptions)->wait(); + } + + /** + * Deletes a queue. + * + * This command will delete the queue even if it has tasks in it. + * + * Note: If you delete a queue, a queue with the same name can't be created + * for 7 days. + * + * WARNING: Using this method may have unintended side effects if you are + * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. + * Read + * [Overview of Queue Management and + * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using + * this method. + * + * The async variant is {@see CloudTasksClient::deleteQueueAsync()} . + * + * @param DeleteQueueRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteQueue(DeleteQueueRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteQueue', $request, $callOptions)->wait(); + } + + /** + * Deletes a task. + * + * A task can be deleted if it is scheduled or dispatched. A task + * cannot be deleted if it has executed successfully or permanently + * failed. + * + * The async variant is {@see CloudTasksClient::deleteTaskAsync()} . + * + * @param DeleteTaskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTask(DeleteTaskRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteTask', $request, $callOptions)->wait(); + } + + /** + * Gets the access control policy for a [Queue][google.cloud.tasks.v2.Queue]. + * Returns an empty policy if the resource exists and does not have a policy + * set. + * + * Authorization requires the following + * [Google IAM](https://cloud.google.com/iam) permission on the specified + * resource parent: + * + * * `cloudtasks.queues.getIamPolicy` + * + * The async variant is {@see CloudTasksClient::getIamPolicyAsync()} . + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets a queue. + * + * The async variant is {@see CloudTasksClient::getQueueAsync()} . + * + * @param GetQueueRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Queue + * + * @throws ApiException Thrown if the API call fails. + */ + public function getQueue(GetQueueRequest $request, array $callOptions = []): Queue + { + return $this->startApiCall('GetQueue', $request, $callOptions)->wait(); + } + + /** + * Gets a task. + * + * The async variant is {@see CloudTasksClient::getTaskAsync()} . + * + * @param GetTaskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Task + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTask(GetTaskRequest $request, array $callOptions = []): Task + { + return $this->startApiCall('GetTask', $request, $callOptions)->wait(); + } + + /** + * Lists queues. + * + * Queues are returned in lexicographical order. + * + * The async variant is {@see CloudTasksClient::listQueuesAsync()} . + * + * @param ListQueuesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listQueues(ListQueuesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListQueues', $request, $callOptions); + } + + /** + * Lists the tasks in a queue. + * + * By default, only the [BASIC][google.cloud.tasks.v2.Task.View.BASIC] view is + * retrieved due to performance considerations; + * [response_view][google.cloud.tasks.v2.ListTasksRequest.response_view] + * controls the subset of information which is returned. + * + * The tasks may be returned in any order. The ordering may change at any + * time. + * + * The async variant is {@see CloudTasksClient::listTasksAsync()} . + * + * @param ListTasksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTasks(ListTasksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTasks', $request, $callOptions); + } + + /** + * Pauses the queue. + * + * If a queue is paused then the system will stop dispatching tasks + * until the queue is resumed via + * [ResumeQueue][google.cloud.tasks.v2.CloudTasks.ResumeQueue]. Tasks can + * still be added when the queue is paused. A queue is paused if its + * [state][google.cloud.tasks.v2.Queue.state] is + * [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED]. + * + * The async variant is {@see CloudTasksClient::pauseQueueAsync()} . + * + * @param PauseQueueRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Queue + * + * @throws ApiException Thrown if the API call fails. + */ + public function pauseQueue(PauseQueueRequest $request, array $callOptions = []): Queue + { + return $this->startApiCall('PauseQueue', $request, $callOptions)->wait(); + } + + /** + * Purges a queue by deleting all of its tasks. + * + * All tasks created before this method is called are permanently deleted. + * + * Purge operations can take up to one minute to take effect. Tasks + * might be dispatched before the purge takes effect. A purge is irreversible. + * + * The async variant is {@see CloudTasksClient::purgeQueueAsync()} . + * + * @param PurgeQueueRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Queue + * + * @throws ApiException Thrown if the API call fails. + */ + public function purgeQueue(PurgeQueueRequest $request, array $callOptions = []): Queue + { + return $this->startApiCall('PurgeQueue', $request, $callOptions)->wait(); + } + + /** + * Resume a queue. + * + * This method resumes a queue after it has been + * [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED] or + * [DISABLED][google.cloud.tasks.v2.Queue.State.DISABLED]. The state of a + * queue is stored in the queue's [state][google.cloud.tasks.v2.Queue.state]; + * after calling this method it will be set to + * [RUNNING][google.cloud.tasks.v2.Queue.State.RUNNING]. + * + * WARNING: Resuming many high-QPS queues at the same time can + * lead to target overloading. If you are resuming high-QPS + * queues, follow the 500/50/5 pattern described in + * [Managing Cloud Tasks Scaling + * Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling). + * + * The async variant is {@see CloudTasksClient::resumeQueueAsync()} . + * + * @param ResumeQueueRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Queue + * + * @throws ApiException Thrown if the API call fails. + */ + public function resumeQueue(ResumeQueueRequest $request, array $callOptions = []): Queue + { + return $this->startApiCall('ResumeQueue', $request, $callOptions)->wait(); + } + + /** + * Forces a task to run now. + * + * When this method is called, Cloud Tasks will dispatch the task, even if + * the task is already running, the queue has reached its + * [RateLimits][google.cloud.tasks.v2.RateLimits] or is + * [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED]. + * + * This command is meant to be used for manual debugging. For + * example, [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask] can be used to + * retry a failed task after a fix has been made or to manually force a task + * to be dispatched now. + * + * The dispatched task is returned. That is, the task that is returned + * contains the [status][Task.status] after the task is dispatched but + * before the task is received by its target. + * + * If Cloud Tasks receives a successful response from the task's + * target, then the task will be deleted; otherwise the task's + * [schedule_time][google.cloud.tasks.v2.Task.schedule_time] will be reset to + * the time that [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask] was + * called plus the retry delay specified in the queue's + * [RetryConfig][google.cloud.tasks.v2.RetryConfig]. + * + * [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask] returns + * [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a + * task that has already succeeded or permanently failed. + * + * The async variant is {@see CloudTasksClient::runTaskAsync()} . + * + * @param RunTaskRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Task + * + * @throws ApiException Thrown if the API call fails. + */ + public function runTask(RunTaskRequest $request, array $callOptions = []): Task + { + return $this->startApiCall('RunTask', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy for a [Queue][google.cloud.tasks.v2.Queue]. + * Replaces any existing policy. + * + * Note: The Cloud Console does not check queue-level IAM permissions yet. + * Project-level permissions are required to use the Cloud Console. + * + * Authorization requires the following + * [Google IAM](https://cloud.google.com/iam) permission on the specified + * resource parent: + * + * * `cloudtasks.queues.setIamPolicy` + * + * The async variant is {@see CloudTasksClient::setIamPolicyAsync()} . + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on a + * [Queue][google.cloud.tasks.v2.Queue]. If the resource does not exist, this + * will return an empty set of permissions, not a + * [NOT_FOUND][google.rpc.Code.NOT_FOUND] error. + * + * Note: This operation is designed to be used for building permission-aware + * UIs and command-line tools, not for authorization checking. This operation + * may "fail open" without warning. + * + * The async variant is {@see CloudTasksClient::testIamPermissionsAsync()} . + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } + + /** + * Updates a queue. + * + * This method creates the queue if it does not exist and updates + * the queue if it does exist. + * + * Queues created with this method allow tasks to live for a maximum of 31 + * days. After a task is 31 days old, the task will be deleted regardless of + * whether it was dispatched or not. + * + * WARNING: Using this method may have unintended side effects if you are + * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. + * Read + * [Overview of Queue Management and + * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using + * this method. + * + * The async variant is {@see CloudTasksClient::updateQueueAsync()} . + * + * @param UpdateQueueRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Queue + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateQueue(UpdateQueueRequest $request, array $callOptions = []): Queue + { + return $this->startApiCall('UpdateQueue', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see CloudTasksClient::getLocationAsync()} . + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see CloudTasksClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/TextToSpeech/composer.json b/TextToSpeech/composer.json index 6e1b7e162c89..599b9eb5b565 100644 --- a/TextToSpeech/composer.json +++ b/TextToSpeech/composer.json @@ -24,11 +24,11 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", - "google/cloud-core": "^1.39" + "google/cloud-core": "^1.52.7" }, "suggest": { "ext-grpc": "Enables use of gRPC, a universal high-performance RPC framework created by Google.", diff --git a/TextToSpeech/src/V1/Client/BaseClient/TextToSpeechBaseClient.php b/TextToSpeech/src/V1/Client/BaseClient/TextToSpeechBaseClient.php deleted file mode 100644 index b635480a022f..000000000000 --- a/TextToSpeech/src/V1/Client/BaseClient/TextToSpeechBaseClient.php +++ /dev/null @@ -1,265 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/text_to_speech_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/text_to_speech_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/text_to_speech_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/text_to_speech_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a model - * resource. - * - * @param string $project - * @param string $location - * @param string $model - * - * @return string The formatted model resource. - */ - public static function modelName(string $project, string $location, string $model): string - { - return self::getPathTemplate('model')->render([ - 'project' => $project, - 'location' => $location, - 'model' => $model, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - model: projects/{project}/locations/{location}/models/{model} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'texttospeech.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Returns a list of Voice supported for synthesis. - * - * The async variant is {@see self::listVoicesAsync()} . - * - * @param ListVoicesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ListVoicesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listVoices(ListVoicesRequest $request, array $callOptions = []): ListVoicesResponse - { - return $this->startApiCall('ListVoices', $request, $callOptions)->wait(); - } - - /** - * Synthesizes speech synchronously: receive results after all text input - * has been processed. - * - * The async variant is {@see self::synthesizeSpeechAsync()} . - * - * @param SynthesizeSpeechRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SynthesizeSpeechResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function synthesizeSpeech(SynthesizeSpeechRequest $request, array $callOptions = []): SynthesizeSpeechResponse - { - return $this->startApiCall('SynthesizeSpeech', $request, $callOptions)->wait(); - } -} diff --git a/TextToSpeech/src/V1/Client/BaseClient/TextToSpeechLongAudioSynthesizeBaseClient.php b/TextToSpeech/src/V1/Client/BaseClient/TextToSpeechLongAudioSynthesizeBaseClient.php deleted file mode 100644 index 560484ce43f5..000000000000 --- a/TextToSpeech/src/V1/Client/BaseClient/TextToSpeechLongAudioSynthesizeBaseClient.php +++ /dev/null @@ -1,272 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/text_to_speech_long_audio_synthesize_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/text_to_speech_long_audio_synthesize_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/text_to_speech_long_audio_synthesize_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/text_to_speech_long_audio_synthesize_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a model - * resource. - * - * @param string $project - * @param string $location - * @param string $model - * - * @return string The formatted model resource. - */ - public static function modelName(string $project, string $location, string $model): string - { - return self::getPathTemplate('model')->render([ - 'project' => $project, - 'location' => $location, - 'model' => $model, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - model: projects/{project}/locations/{location}/models/{model} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'texttospeech.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Synthesizes long form text asynchronously. - * - * The async variant is {@see self::synthesizeLongAudioAsync()} . - * - * @param SynthesizeLongAudioRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function synthesizeLongAudio(SynthesizeLongAudioRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SynthesizeLongAudio', $request, $callOptions)->wait(); - } -} diff --git a/TextToSpeech/src/V1/Client/TextToSpeechClient.php b/TextToSpeech/src/V1/Client/TextToSpeechClient.php index b48909e57430..8c24d6893bf4 100644 --- a/TextToSpeech/src/V1/Client/TextToSpeechClient.php +++ b/TextToSpeech/src/V1/Client/TextToSpeechClient.php @@ -24,17 +24,240 @@ namespace Google\Cloud\TextToSpeech\V1\Client; -use Google\Cloud\TextToSpeech\V1\Client\BaseClient\TextToSpeechBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\TextToSpeech\V1\ListVoicesRequest; +use Google\Cloud\TextToSpeech\V1\ListVoicesResponse; +use Google\Cloud\TextToSpeech\V1\SynthesizeSpeechRequest; +use Google\Cloud\TextToSpeech\V1\SynthesizeSpeechResponse; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service that implements Google Cloud Text-to-Speech API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\TextToSpeech\V1\TextToSpeechClient} for the stable implementation * * @experimental + * + * @method PromiseInterface listVoicesAsync(ListVoicesRequest $request, array $optionalArgs = []) + * @method PromiseInterface synthesizeSpeechAsync(SynthesizeSpeechRequest $request, array $optionalArgs = []) */ -final class TextToSpeechClient extends TextToSpeechBaseClient +final class TextToSpeechClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TextToSpeechBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.texttospeech.v1.TextToSpeech'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'texttospeech.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/text_to_speech_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/text_to_speech_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/text_to_speech_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/text_to_speech_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a model + * resource. + * + * @param string $project + * @param string $location + * @param string $model + * + * @return string The formatted model resource. + */ + public static function modelName(string $project, string $location, string $model): string + { + return self::getPathTemplate('model')->render([ + 'project' => $project, + 'location' => $location, + 'model' => $model, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - model: projects/{project}/locations/{location}/models/{model} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'texttospeech.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Returns a list of Voice supported for synthesis. + * + * The async variant is {@see TextToSpeechClient::listVoicesAsync()} . + * + * @param ListVoicesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ListVoicesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listVoices(ListVoicesRequest $request, array $callOptions = []): ListVoicesResponse + { + return $this->startApiCall('ListVoices', $request, $callOptions)->wait(); + } + + /** + * Synthesizes speech synchronously: receive results after all text input + * has been processed. + * + * The async variant is {@see TextToSpeechClient::synthesizeSpeechAsync()} . + * + * @param SynthesizeSpeechRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SynthesizeSpeechResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function synthesizeSpeech(SynthesizeSpeechRequest $request, array $callOptions = []): SynthesizeSpeechResponse + { + return $this->startApiCall('SynthesizeSpeech', $request, $callOptions)->wait(); + } } diff --git a/TextToSpeech/src/V1/Client/TextToSpeechLongAudioSynthesizeClient.php b/TextToSpeech/src/V1/Client/TextToSpeechLongAudioSynthesizeClient.php index 77eb1e1edc7d..9197d6efffd5 100644 --- a/TextToSpeech/src/V1/Client/TextToSpeechLongAudioSynthesizeClient.php +++ b/TextToSpeech/src/V1/Client/TextToSpeechLongAudioSynthesizeClient.php @@ -24,17 +24,248 @@ namespace Google\Cloud\TextToSpeech\V1\Client; -use Google\Cloud\TextToSpeech\V1\Client\BaseClient\TextToSpeechLongAudioSynthesizeBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\TextToSpeech\V1\SynthesizeLongAudioRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service that implements Google Cloud Text-to-Speech API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\TextToSpeech\V1\TextToSpeechLongAudioSynthesizeClient} for the + * stable implementation * * @experimental + * + * @method PromiseInterface synthesizeLongAudioAsync(SynthesizeLongAudioRequest $request, array $optionalArgs = []) */ -final class TextToSpeechLongAudioSynthesizeClient extends TextToSpeechLongAudioSynthesizeBaseClient +final class TextToSpeechLongAudioSynthesizeClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TextToSpeechLongAudioSynthesizeBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.texttospeech.v1.TextToSpeechLongAudioSynthesize'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'texttospeech.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/text_to_speech_long_audio_synthesize_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/text_to_speech_long_audio_synthesize_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/text_to_speech_long_audio_synthesize_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/text_to_speech_long_audio_synthesize_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a model + * resource. + * + * @param string $project + * @param string $location + * @param string $model + * + * @return string The formatted model resource. + */ + public static function modelName(string $project, string $location, string $model): string + { + return self::getPathTemplate('model')->render([ + 'project' => $project, + 'location' => $location, + 'model' => $model, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - model: projects/{project}/locations/{location}/models/{model} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'texttospeech.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Synthesizes long form text asynchronously. + * + * The async variant is + * {@see TextToSpeechLongAudioSynthesizeClient::synthesizeLongAudioAsync()} . + * + * @param SynthesizeLongAudioRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function synthesizeLongAudio(SynthesizeLongAudioRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SynthesizeLongAudio', $request, $callOptions)->wait(); + } } diff --git a/Tpu/composer.json b/Tpu/composer.json index 7848faa9095a..b1c1948cd886 100644 --- a/Tpu/composer.json +++ b/Tpu/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Tpu/src/V2/Client/BaseClient/TpuBaseClient.php b/Tpu/src/V2/Client/BaseClient/TpuBaseClient.php deleted file mode 100644 index 8e20c81bb5fe..000000000000 --- a/Tpu/src/V2/Client/BaseClient/TpuBaseClient.php +++ /dev/null @@ -1,731 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/tpu_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/tpu_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/tpu_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/tpu_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * accelerator_type resource. - * - * @param string $project - * @param string $location - * @param string $acceleratorType - * - * @return string The formatted accelerator_type resource. - */ - public static function acceleratorTypeName(string $project, string $location, string $acceleratorType): string - { - return self::getPathTemplate('acceleratorType')->render([ - 'project' => $project, - 'location' => $location, - 'accelerator_type' => $acceleratorType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a node - * resource. - * - * @param string $project - * @param string $location - * @param string $node - * - * @return string The formatted node resource. - */ - public static function nodeName(string $project, string $location, string $node): string - { - return self::getPathTemplate('node')->render([ - 'project' => $project, - 'location' => $location, - 'node' => $node, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * runtime_version resource. - * - * @param string $project - * @param string $location - * @param string $runtimeVersion - * - * @return string The formatted runtime_version resource. - */ - public static function runtimeVersionName(string $project, string $location, string $runtimeVersion): string - { - return self::getPathTemplate('runtimeVersion')->render([ - 'project' => $project, - 'location' => $location, - 'runtime_version' => $runtimeVersion, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - acceleratorType: projects/{project}/locations/{location}/acceleratorTypes/{accelerator_type} - * - location: projects/{project}/locations/{location} - * - node: projects/{project}/locations/{location}/nodes/{node} - * - runtimeVersion: projects/{project}/locations/{location}/runtimeVersions/{runtime_version} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'tpu.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a node. - * - * The async variant is {@see self::createNodeAsync()} . - * - * @example samples/V2/TpuClient/create_node.php - * - * @param CreateNodeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createNode(CreateNodeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateNode', $request, $callOptions)->wait(); - } - - /** - * Deletes a node. - * - * The async variant is {@see self::deleteNodeAsync()} . - * - * @example samples/V2/TpuClient/delete_node.php - * - * @param DeleteNodeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteNode(DeleteNodeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteNode', $request, $callOptions)->wait(); - } - - /** - * Generates the Cloud TPU service identity for the project. - * - * The async variant is {@see self::generateServiceIdentityAsync()} . - * - * @example samples/V2/TpuClient/generate_service_identity.php - * - * @param GenerateServiceIdentityRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GenerateServiceIdentityResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function generateServiceIdentity(GenerateServiceIdentityRequest $request, array $callOptions = []): GenerateServiceIdentityResponse - { - return $this->startApiCall('GenerateServiceIdentity', $request, $callOptions)->wait(); - } - - /** - * Gets AcceleratorType. - * - * The async variant is {@see self::getAcceleratorTypeAsync()} . - * - * @example samples/V2/TpuClient/get_accelerator_type.php - * - * @param GetAcceleratorTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 AcceleratorType - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAcceleratorType(GetAcceleratorTypeRequest $request, array $callOptions = []): AcceleratorType - { - return $this->startApiCall('GetAcceleratorType', $request, $callOptions)->wait(); - } - - /** - * Retrieves the guest attributes for the node. - * - * The async variant is {@see self::getGuestAttributesAsync()} . - * - * @example samples/V2/TpuClient/get_guest_attributes.php - * - * @param GetGuestAttributesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 GetGuestAttributesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function getGuestAttributes(GetGuestAttributesRequest $request, array $callOptions = []): GetGuestAttributesResponse - { - return $this->startApiCall('GetGuestAttributes', $request, $callOptions)->wait(); - } - - /** - * Gets the details of a node. - * - * The async variant is {@see self::getNodeAsync()} . - * - * @example samples/V2/TpuClient/get_node.php - * - * @param GetNodeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Node - * - * @throws ApiException Thrown if the API call fails. - */ - public function getNode(GetNodeRequest $request, array $callOptions = []): Node - { - return $this->startApiCall('GetNode', $request, $callOptions)->wait(); - } - - /** - * Gets a runtime version. - * - * The async variant is {@see self::getRuntimeVersionAsync()} . - * - * @example samples/V2/TpuClient/get_runtime_version.php - * - * @param GetRuntimeVersionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 RuntimeVersion - * - * @throws ApiException Thrown if the API call fails. - */ - public function getRuntimeVersion(GetRuntimeVersionRequest $request, array $callOptions = []): RuntimeVersion - { - return $this->startApiCall('GetRuntimeVersion', $request, $callOptions)->wait(); - } - - /** - * Lists accelerator types supported by this API. - * - * The async variant is {@see self::listAcceleratorTypesAsync()} . - * - * @example samples/V2/TpuClient/list_accelerator_types.php - * - * @param ListAcceleratorTypesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAcceleratorTypes(ListAcceleratorTypesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAcceleratorTypes', $request, $callOptions); - } - - /** - * Lists nodes. - * - * The async variant is {@see self::listNodesAsync()} . - * - * @example samples/V2/TpuClient/list_nodes.php - * - * @param ListNodesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listNodes(ListNodesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListNodes', $request, $callOptions); - } - - /** - * Lists runtime versions supported by this API. - * - * The async variant is {@see self::listRuntimeVersionsAsync()} . - * - * @example samples/V2/TpuClient/list_runtime_versions.php - * - * @param ListRuntimeVersionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listRuntimeVersions(ListRuntimeVersionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListRuntimeVersions', $request, $callOptions); - } - - /** - * Starts a node. - * - * The async variant is {@see self::startNodeAsync()} . - * - * @example samples/V2/TpuClient/start_node.php - * - * @param StartNodeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function startNode(StartNodeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StartNode', $request, $callOptions)->wait(); - } - - /** - * Stops a node. This operation is only available with single TPU nodes. - * - * The async variant is {@see self::stopNodeAsync()} . - * - * @example samples/V2/TpuClient/stop_node.php - * - * @param StopNodeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function stopNode(StopNodeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StopNode', $request, $callOptions)->wait(); - } - - /** - * Updates the configurations of a node. - * - * The async variant is {@see self::updateNodeAsync()} . - * - * @example samples/V2/TpuClient/update_node.php - * - * @param UpdateNodeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateNode(UpdateNodeRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateNode', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V2/TpuClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V2/TpuClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Tpu/src/V2/Client/TpuClient.php b/Tpu/src/V2/Client/TpuClient.php index 83eb8ebaa92e..e211c7d16e83 100644 --- a/Tpu/src/V2/Client/TpuClient.php +++ b/Tpu/src/V2/Client/TpuClient.php @@ -24,17 +24,706 @@ namespace Google\Cloud\Tpu\V2\Client; -use Google\Cloud\Tpu\V2\Client\BaseClient\TpuBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\Tpu\V2\AcceleratorType; +use Google\Cloud\Tpu\V2\CreateNodeRequest; +use Google\Cloud\Tpu\V2\DeleteNodeRequest; +use Google\Cloud\Tpu\V2\GenerateServiceIdentityRequest; +use Google\Cloud\Tpu\V2\GenerateServiceIdentityResponse; +use Google\Cloud\Tpu\V2\GetAcceleratorTypeRequest; +use Google\Cloud\Tpu\V2\GetGuestAttributesRequest; +use Google\Cloud\Tpu\V2\GetGuestAttributesResponse; +use Google\Cloud\Tpu\V2\GetNodeRequest; +use Google\Cloud\Tpu\V2\GetRuntimeVersionRequest; +use Google\Cloud\Tpu\V2\ListAcceleratorTypesRequest; +use Google\Cloud\Tpu\V2\ListNodesRequest; +use Google\Cloud\Tpu\V2\ListRuntimeVersionsRequest; +use Google\Cloud\Tpu\V2\Node; +use Google\Cloud\Tpu\V2\RuntimeVersion; +use Google\Cloud\Tpu\V2\StartNodeRequest; +use Google\Cloud\Tpu\V2\StopNodeRequest; +use Google\Cloud\Tpu\V2\UpdateNodeRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Manages TPU nodes and other resources + * + * TPU API v2 + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createNodeAsync(CreateNodeRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteNodeAsync(DeleteNodeRequest $request, array $optionalArgs = []) + * @method PromiseInterface generateServiceIdentityAsync(GenerateServiceIdentityRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAcceleratorTypeAsync(GetAcceleratorTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getGuestAttributesAsync(GetGuestAttributesRequest $request, array $optionalArgs = []) + * @method PromiseInterface getNodeAsync(GetNodeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getRuntimeVersionAsync(GetRuntimeVersionRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAcceleratorTypesAsync(ListAcceleratorTypesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listNodesAsync(ListNodesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listRuntimeVersionsAsync(ListRuntimeVersionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface startNodeAsync(StartNodeRequest $request, array $optionalArgs = []) + * @method PromiseInterface stopNodeAsync(StopNodeRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateNodeAsync(UpdateNodeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class TpuClient extends TpuBaseClient +final class TpuClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TpuBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.tpu.v2.Tpu'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'tpu.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/tpu_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/tpu_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/tpu_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/tpu_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a + * accelerator_type resource. + * + * @param string $project + * @param string $location + * @param string $acceleratorType + * + * @return string The formatted accelerator_type resource. + */ + public static function acceleratorTypeName(string $project, string $location, string $acceleratorType): string + { + return self::getPathTemplate('acceleratorType')->render([ + 'project' => $project, + 'location' => $location, + 'accelerator_type' => $acceleratorType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a node + * resource. + * + * @param string $project + * @param string $location + * @param string $node + * + * @return string The formatted node resource. + */ + public static function nodeName(string $project, string $location, string $node): string + { + return self::getPathTemplate('node')->render([ + 'project' => $project, + 'location' => $location, + 'node' => $node, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * runtime_version resource. + * + * @param string $project + * @param string $location + * @param string $runtimeVersion + * + * @return string The formatted runtime_version resource. + */ + public static function runtimeVersionName(string $project, string $location, string $runtimeVersion): string + { + return self::getPathTemplate('runtimeVersion')->render([ + 'project' => $project, + 'location' => $location, + 'runtime_version' => $runtimeVersion, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - acceleratorType: projects/{project}/locations/{location}/acceleratorTypes/{accelerator_type} + * - location: projects/{project}/locations/{location} + * - node: projects/{project}/locations/{location}/nodes/{node} + * - runtimeVersion: projects/{project}/locations/{location}/runtimeVersions/{runtime_version} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'tpu.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a node. + * + * The async variant is {@see TpuClient::createNodeAsync()} . + * + * @example samples/V2/TpuClient/create_node.php + * + * @param CreateNodeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createNode(CreateNodeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateNode', $request, $callOptions)->wait(); + } + + /** + * Deletes a node. + * + * The async variant is {@see TpuClient::deleteNodeAsync()} . + * + * @example samples/V2/TpuClient/delete_node.php + * + * @param DeleteNodeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteNode(DeleteNodeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteNode', $request, $callOptions)->wait(); + } + + /** + * Generates the Cloud TPU service identity for the project. + * + * The async variant is {@see TpuClient::generateServiceIdentityAsync()} . + * + * @example samples/V2/TpuClient/generate_service_identity.php + * + * @param GenerateServiceIdentityRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GenerateServiceIdentityResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function generateServiceIdentity(GenerateServiceIdentityRequest $request, array $callOptions = []): GenerateServiceIdentityResponse + { + return $this->startApiCall('GenerateServiceIdentity', $request, $callOptions)->wait(); + } + + /** + * Gets AcceleratorType. + * + * The async variant is {@see TpuClient::getAcceleratorTypeAsync()} . + * + * @example samples/V2/TpuClient/get_accelerator_type.php + * + * @param GetAcceleratorTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 AcceleratorType + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAcceleratorType(GetAcceleratorTypeRequest $request, array $callOptions = []): AcceleratorType + { + return $this->startApiCall('GetAcceleratorType', $request, $callOptions)->wait(); + } + + /** + * Retrieves the guest attributes for the node. + * + * The async variant is {@see TpuClient::getGuestAttributesAsync()} . + * + * @example samples/V2/TpuClient/get_guest_attributes.php + * + * @param GetGuestAttributesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 GetGuestAttributesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function getGuestAttributes(GetGuestAttributesRequest $request, array $callOptions = []): GetGuestAttributesResponse + { + return $this->startApiCall('GetGuestAttributes', $request, $callOptions)->wait(); + } + + /** + * Gets the details of a node. + * + * The async variant is {@see TpuClient::getNodeAsync()} . + * + * @example samples/V2/TpuClient/get_node.php + * + * @param GetNodeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Node + * + * @throws ApiException Thrown if the API call fails. + */ + public function getNode(GetNodeRequest $request, array $callOptions = []): Node + { + return $this->startApiCall('GetNode', $request, $callOptions)->wait(); + } + + /** + * Gets a runtime version. + * + * The async variant is {@see TpuClient::getRuntimeVersionAsync()} . + * + * @example samples/V2/TpuClient/get_runtime_version.php + * + * @param GetRuntimeVersionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 RuntimeVersion + * + * @throws ApiException Thrown if the API call fails. + */ + public function getRuntimeVersion(GetRuntimeVersionRequest $request, array $callOptions = []): RuntimeVersion + { + return $this->startApiCall('GetRuntimeVersion', $request, $callOptions)->wait(); + } + + /** + * Lists accelerator types supported by this API. + * + * The async variant is {@see TpuClient::listAcceleratorTypesAsync()} . + * + * @example samples/V2/TpuClient/list_accelerator_types.php + * + * @param ListAcceleratorTypesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAcceleratorTypes(ListAcceleratorTypesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAcceleratorTypes', $request, $callOptions); + } + + /** + * Lists nodes. + * + * The async variant is {@see TpuClient::listNodesAsync()} . + * + * @example samples/V2/TpuClient/list_nodes.php + * + * @param ListNodesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listNodes(ListNodesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListNodes', $request, $callOptions); + } + + /** + * Lists runtime versions supported by this API. + * + * The async variant is {@see TpuClient::listRuntimeVersionsAsync()} . + * + * @example samples/V2/TpuClient/list_runtime_versions.php + * + * @param ListRuntimeVersionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listRuntimeVersions(ListRuntimeVersionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListRuntimeVersions', $request, $callOptions); + } + + /** + * Starts a node. + * + * The async variant is {@see TpuClient::startNodeAsync()} . + * + * @example samples/V2/TpuClient/start_node.php + * + * @param StartNodeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function startNode(StartNodeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StartNode', $request, $callOptions)->wait(); + } + + /** + * Stops a node. This operation is only available with single TPU nodes. + * + * The async variant is {@see TpuClient::stopNodeAsync()} . + * + * @example samples/V2/TpuClient/stop_node.php + * + * @param StopNodeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function stopNode(StopNodeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StopNode', $request, $callOptions)->wait(); + } + + /** + * Updates the configurations of a node. + * + * The async variant is {@see TpuClient::updateNodeAsync()} . + * + * @example samples/V2/TpuClient/update_node.php + * + * @param UpdateNodeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateNode(UpdateNodeRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateNode', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see TpuClient::getLocationAsync()} . + * + * @example samples/V2/TpuClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see TpuClient::listLocationsAsync()} . + * + * @example samples/V2/TpuClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/Trace/composer.json b/Trace/composer.json index 701dcc89abd0..2ef1c5aaef87 100644 --- a/Trace/composer.json +++ b/Trace/composer.json @@ -5,9 +5,9 @@ "minimum-stability": "stable", "require": { "php": ">=7.4", - "google/cloud-core": "^1.39", + "google/cloud-core": "^1.52.7", "ramsey/uuid": "^3.0|^4.0", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", diff --git a/Trace/src/V2/Client/BaseClient/TraceServiceBaseClient.php b/Trace/src/V2/Client/BaseClient/TraceServiceBaseClient.php deleted file mode 100644 index f7e8b0b1fa25..000000000000 --- a/Trace/src/V2/Client/BaseClient/TraceServiceBaseClient.php +++ /dev/null @@ -1,284 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/trace_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/trace_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/trace_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/trace_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->render([ - 'project' => $project, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a span - * resource. - * - * @param string $project - * @param string $trace - * @param string $span - * - * @return string The formatted span resource. - */ - public static function spanName(string $project, string $trace, string $span): string - { - return self::getPathTemplate('span')->render([ - 'project' => $project, - 'trace' => $trace, - 'span' => $span, - ]); - } - - /** - * 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} - * - span: projects/{project}/traces/{trace}/spans/{span} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'cloudtrace.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Batch writes new spans to new or existing traces. You cannot update - * existing spans. - * - * The async variant is {@see self::batchWriteSpansAsync()} . - * - * @param BatchWriteSpansRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchWriteSpans(BatchWriteSpansRequest $request, array $callOptions = []): void - { - $this->startApiCall('BatchWriteSpans', $request, $callOptions)->wait(); - } - - /** - * Creates a new span. - * - * The async variant is {@see self::createSpanAsync()} . - * - * @param Span $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Span - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSpan(Span $request, array $callOptions = []): Span - { - return $this->startApiCall('CreateSpan', $request, $callOptions)->wait(); - } -} diff --git a/Trace/src/V2/Client/TraceServiceClient.php b/Trace/src/V2/Client/TraceServiceClient.php index b412a15c20ae..128c35d3292a 100644 --- a/Trace/src/V2/Client/TraceServiceClient.php +++ b/Trace/src/V2/Client/TraceServiceClient.php @@ -24,17 +24,259 @@ namespace Google\Cloud\Trace\V2\Client; -use Google\Cloud\Trace\V2\Client\BaseClient\TraceServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Trace\V2\BatchWriteSpansRequest; +use Google\Cloud\Trace\V2\Span; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service for collecting and viewing traces and spans within a trace. * - * This class is currently experimental and may be subject to changes. + * A trace is a collection of spans corresponding to a single + * operation or a set of operations in an application. + * + * A span is an individual timed event which forms a node of the trace tree. + * A single trace can contain spans from multiple services. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Trace\V2\TraceServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface batchWriteSpansAsync(BatchWriteSpansRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSpanAsync(Span $request, array $optionalArgs = []) */ -final class TraceServiceClient extends TraceServiceBaseClient +final class TraceServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TraceServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.devtools.cloudtrace.v2.TraceService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'cloudtrace.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/trace.append', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/trace_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/trace_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/trace_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/trace_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->render([ + 'project' => $project, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a span + * resource. + * + * @param string $project + * @param string $trace + * @param string $span + * + * @return string The formatted span resource. + */ + public static function spanName(string $project, string $trace, string $span): string + { + return self::getPathTemplate('span')->render([ + 'project' => $project, + 'trace' => $trace, + 'span' => $span, + ]); + } + + /** + * 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} + * - span: projects/{project}/traces/{trace}/spans/{span} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'cloudtrace.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Batch writes new spans to new or existing traces. You cannot update + * existing spans. + * + * The async variant is {@see TraceServiceClient::batchWriteSpansAsync()} . + * + * @param BatchWriteSpansRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchWriteSpans(BatchWriteSpansRequest $request, array $callOptions = []): void + { + $this->startApiCall('BatchWriteSpans', $request, $callOptions)->wait(); + } + + /** + * Creates a new span. + * + * The async variant is {@see TraceServiceClient::createSpanAsync()} . + * + * @param Span $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Span + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSpan(Span $request, array $callOptions = []): Span + { + return $this->startApiCall('CreateSpan', $request, $callOptions)->wait(); + } } diff --git a/Translate/composer.json b/Translate/composer.json index e97a1722bd1c..4aa2c59ebc3f 100644 --- a/Translate/composer.json +++ b/Translate/composer.json @@ -5,8 +5,8 @@ "minimum-stability": "stable", "require": { "php": ">=7.4", - "google/cloud-core": "^1.39", - "google/gax": "^1.19.1" + "google/cloud-core": "^1.52.7", + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", diff --git a/Translate/src/V3/Client/BaseClient/TranslationServiceBaseClient.php b/Translate/src/V3/Client/BaseClient/TranslationServiceBaseClient.php deleted file mode 100644 index c8869b6916f6..000000000000 --- a/Translate/src/V3/Client/BaseClient/TranslationServiceBaseClient.php +++ /dev/null @@ -1,548 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/translation_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/translation_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/translation_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/translation_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a glossary - * resource. - * - * @param string $project - * @param string $location - * @param string $glossary - * - * @return string The formatted glossary resource. - */ - public static function glossaryName(string $project, string $location, string $glossary): string - { - return self::getPathTemplate('glossary')->render([ - 'project' => $project, - 'location' => $location, - 'glossary' => $glossary, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - glossary: projects/{project}/locations/{location}/glossaries/{glossary} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'translate.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Translates a large volume of document in asynchronous batch mode. - * This function provides real-time output as the inputs are being processed. - * If caller cancels a request, the partial results (for an input file, it's - * all or nothing) may still be available on the specified output location. - * - * This call returns immediately and you can use - * google.longrunning.Operation.name to poll the status of the call. - * - * The async variant is {@see self::batchTranslateDocumentAsync()} . - * - * @param BatchTranslateDocumentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchTranslateDocument(BatchTranslateDocumentRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BatchTranslateDocument', $request, $callOptions)->wait(); - } - - /** - * Translates a large volume of text in asynchronous batch mode. - * This function provides real-time output as the inputs are being processed. - * If caller cancels a request, the partial results (for an input file, it's - * all or nothing) may still be available on the specified output location. - * - * This call returns immediately and you can - * use google.longrunning.Operation.name to poll the status of the call. - * - * The async variant is {@see self::batchTranslateTextAsync()} . - * - * @param BatchTranslateTextRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchTranslateText(BatchTranslateTextRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('BatchTranslateText', $request, $callOptions)->wait(); - } - - /** - * Creates a glossary and returns the long-running operation. Returns - * NOT_FOUND, if the project doesn't exist. - * - * The async variant is {@see self::createGlossaryAsync()} . - * - * @param CreateGlossaryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createGlossary(CreateGlossaryRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateGlossary', $request, $callOptions)->wait(); - } - - /** - * Deletes a glossary, or cancels glossary construction - * if the glossary isn't created yet. - * Returns NOT_FOUND, if the glossary doesn't exist. - * - * The async variant is {@see self::deleteGlossaryAsync()} . - * - * @param DeleteGlossaryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteGlossary(DeleteGlossaryRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteGlossary', $request, $callOptions)->wait(); - } - - /** - * Detects the language of text within a request. - * - * The async variant is {@see self::detectLanguageAsync()} . - * - * @param DetectLanguageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DetectLanguageResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function detectLanguage(DetectLanguageRequest $request, array $callOptions = []): DetectLanguageResponse - { - return $this->startApiCall('DetectLanguage', $request, $callOptions)->wait(); - } - - /** - * Gets a glossary. Returns NOT_FOUND, if the glossary doesn't - * exist. - * - * The async variant is {@see self::getGlossaryAsync()} . - * - * @param GetGlossaryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Glossary - * - * @throws ApiException Thrown if the API call fails. - */ - public function getGlossary(GetGlossaryRequest $request, array $callOptions = []): Glossary - { - return $this->startApiCall('GetGlossary', $request, $callOptions)->wait(); - } - - /** - * Returns a list of supported languages for translation. - * - * The async variant is {@see self::getSupportedLanguagesAsync()} . - * - * @param GetSupportedLanguagesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SupportedLanguages - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSupportedLanguages(GetSupportedLanguagesRequest $request, array $callOptions = []): SupportedLanguages - { - return $this->startApiCall('GetSupportedLanguages', $request, $callOptions)->wait(); - } - - /** - * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't - * exist. - * - * The async variant is {@see self::listGlossariesAsync()} . - * - * @param ListGlossariesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listGlossaries(ListGlossariesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListGlossaries', $request, $callOptions); - } - - /** - * Translates documents in synchronous mode. - * - * The async variant is {@see self::translateDocumentAsync()} . - * - * @param TranslateDocumentRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TranslateDocumentResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function translateDocument(TranslateDocumentRequest $request, array $callOptions = []): TranslateDocumentResponse - { - return $this->startApiCall('TranslateDocument', $request, $callOptions)->wait(); - } - - /** - * Translates input text and returns translated text. - * - * The async variant is {@see self::translateTextAsync()} . - * - * @param TranslateTextRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TranslateTextResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function translateText(TranslateTextRequest $request, array $callOptions = []): TranslateTextResponse - { - return $this->startApiCall('TranslateText', $request, $callOptions)->wait(); - } -} diff --git a/Translate/src/V3/Client/TranslationServiceClient.php b/Translate/src/V3/Client/TranslationServiceClient.php index ee1d17781fe9..9e90e5e115b2 100644 --- a/Translate/src/V3/Client/TranslationServiceClient.php +++ b/Translate/src/V3/Client/TranslationServiceClient.php @@ -24,17 +24,526 @@ namespace Google\Cloud\Translate\V3\Client; -use Google\Cloud\Translate\V3\Client\BaseClient\TranslationServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Translate\V3\BatchTranslateDocumentRequest; +use Google\Cloud\Translate\V3\BatchTranslateTextRequest; +use Google\Cloud\Translate\V3\CreateGlossaryRequest; +use Google\Cloud\Translate\V3\DeleteGlossaryRequest; +use Google\Cloud\Translate\V3\DetectLanguageRequest; +use Google\Cloud\Translate\V3\DetectLanguageResponse; +use Google\Cloud\Translate\V3\GetGlossaryRequest; +use Google\Cloud\Translate\V3\GetSupportedLanguagesRequest; +use Google\Cloud\Translate\V3\Glossary; +use Google\Cloud\Translate\V3\ListGlossariesRequest; +use Google\Cloud\Translate\V3\SupportedLanguages; +use Google\Cloud\Translate\V3\TranslateDocumentRequest; +use Google\Cloud\Translate\V3\TranslateDocumentResponse; +use Google\Cloud\Translate\V3\TranslateTextRequest; +use Google\Cloud\Translate\V3\TranslateTextResponse; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Provides natural language translation operations. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Translate\V3\TranslationServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface batchTranslateDocumentAsync(BatchTranslateDocumentRequest $request, array $optionalArgs = []) + * @method PromiseInterface batchTranslateTextAsync(BatchTranslateTextRequest $request, array $optionalArgs = []) + * @method PromiseInterface createGlossaryAsync(CreateGlossaryRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteGlossaryAsync(DeleteGlossaryRequest $request, array $optionalArgs = []) + * @method PromiseInterface detectLanguageAsync(DetectLanguageRequest $request, array $optionalArgs = []) + * @method PromiseInterface getGlossaryAsync(GetGlossaryRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSupportedLanguagesAsync(GetSupportedLanguagesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listGlossariesAsync(ListGlossariesRequest $request, array $optionalArgs = []) + * @method PromiseInterface translateDocumentAsync(TranslateDocumentRequest $request, array $optionalArgs = []) + * @method PromiseInterface translateTextAsync(TranslateTextRequest $request, array $optionalArgs = []) */ -final class TranslationServiceClient extends TranslationServiceBaseClient +final class TranslationServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TranslationServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.translation.v3.TranslationService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'translate.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-translation', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/translation_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/translation_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/translation_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/translation_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a glossary + * resource. + * + * @param string $project + * @param string $location + * @param string $glossary + * + * @return string The formatted glossary resource. + */ + public static function glossaryName(string $project, string $location, string $glossary): string + { + return self::getPathTemplate('glossary')->render([ + 'project' => $project, + 'location' => $location, + 'glossary' => $glossary, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - glossary: projects/{project}/locations/{location}/glossaries/{glossary} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'translate.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Translates a large volume of document in asynchronous batch mode. + * This function provides real-time output as the inputs are being processed. + * If caller cancels a request, the partial results (for an input file, it's + * all or nothing) may still be available on the specified output location. + * + * This call returns immediately and you can use + * google.longrunning.Operation.name to poll the status of the call. + * + * The async variant is + * {@see TranslationServiceClient::batchTranslateDocumentAsync()} . + * + * @param BatchTranslateDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchTranslateDocument(BatchTranslateDocumentRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchTranslateDocument', $request, $callOptions)->wait(); + } + + /** + * Translates a large volume of text in asynchronous batch mode. + * This function provides real-time output as the inputs are being processed. + * If caller cancels a request, the partial results (for an input file, it's + * all or nothing) may still be available on the specified output location. + * + * This call returns immediately and you can + * use google.longrunning.Operation.name to poll the status of the call. + * + * The async variant is {@see TranslationServiceClient::batchTranslateTextAsync()} + * . + * + * @param BatchTranslateTextRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchTranslateText(BatchTranslateTextRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('BatchTranslateText', $request, $callOptions)->wait(); + } + + /** + * Creates a glossary and returns the long-running operation. Returns + * NOT_FOUND, if the project doesn't exist. + * + * The async variant is {@see TranslationServiceClient::createGlossaryAsync()} . + * + * @param CreateGlossaryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createGlossary(CreateGlossaryRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateGlossary', $request, $callOptions)->wait(); + } + + /** + * Deletes a glossary, or cancels glossary construction + * if the glossary isn't created yet. + * Returns NOT_FOUND, if the glossary doesn't exist. + * + * The async variant is {@see TranslationServiceClient::deleteGlossaryAsync()} . + * + * @param DeleteGlossaryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteGlossary(DeleteGlossaryRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteGlossary', $request, $callOptions)->wait(); + } + + /** + * Detects the language of text within a request. + * + * The async variant is {@see TranslationServiceClient::detectLanguageAsync()} . + * + * @param DetectLanguageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DetectLanguageResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function detectLanguage(DetectLanguageRequest $request, array $callOptions = []): DetectLanguageResponse + { + return $this->startApiCall('DetectLanguage', $request, $callOptions)->wait(); + } + + /** + * Gets a glossary. Returns NOT_FOUND, if the glossary doesn't + * exist. + * + * The async variant is {@see TranslationServiceClient::getGlossaryAsync()} . + * + * @param GetGlossaryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Glossary + * + * @throws ApiException Thrown if the API call fails. + */ + public function getGlossary(GetGlossaryRequest $request, array $callOptions = []): Glossary + { + return $this->startApiCall('GetGlossary', $request, $callOptions)->wait(); + } + + /** + * Returns a list of supported languages for translation. + * + * The async variant is + * {@see TranslationServiceClient::getSupportedLanguagesAsync()} . + * + * @param GetSupportedLanguagesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SupportedLanguages + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSupportedLanguages(GetSupportedLanguagesRequest $request, array $callOptions = []): SupportedLanguages + { + return $this->startApiCall('GetSupportedLanguages', $request, $callOptions)->wait(); + } + + /** + * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't + * exist. + * + * The async variant is {@see TranslationServiceClient::listGlossariesAsync()} . + * + * @param ListGlossariesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listGlossaries(ListGlossariesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListGlossaries', $request, $callOptions); + } + + /** + * Translates documents in synchronous mode. + * + * The async variant is {@see TranslationServiceClient::translateDocumentAsync()} . + * + * @param TranslateDocumentRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TranslateDocumentResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function translateDocument(TranslateDocumentRequest $request, array $callOptions = []): TranslateDocumentResponse + { + return $this->startApiCall('TranslateDocument', $request, $callOptions)->wait(); + } + + /** + * Translates input text and returns translated text. + * + * The async variant is {@see TranslationServiceClient::translateTextAsync()} . + * + * @param TranslateTextRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TranslateTextResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function translateText(TranslateTextRequest $request, array $callOptions = []): TranslateTextResponse + { + return $this->startApiCall('TranslateText', $request, $callOptions)->wait(); + } } diff --git a/VideoIntelligence/composer.json b/VideoIntelligence/composer.json index 9db466e6c1f3..713af67f9724 100644 --- a/VideoIntelligence/composer.json +++ b/VideoIntelligence/composer.json @@ -5,11 +5,11 @@ "minimum-stability": "stable", "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", - "google/cloud-core": "^1.39" + "google/cloud-core": "^1.52.7" }, "suggest": { "ext-protobuf": "Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions." diff --git a/VideoIntelligence/src/V1/Client/BaseClient/VideoIntelligenceServiceBaseClient.php b/VideoIntelligence/src/V1/Client/BaseClient/VideoIntelligenceServiceBaseClient.php deleted file mode 100644 index 78ac9b9e4836..000000000000 --- a/VideoIntelligence/src/V1/Client/BaseClient/VideoIntelligenceServiceBaseClient.php +++ /dev/null @@ -1,227 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/video_intelligence_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/video_intelligence_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/video_intelligence_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/video_intelligence_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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 'videointelligence.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Performs asynchronous video annotation. Progress and results can be - * retrieved through the `google.longrunning.Operations` interface. - * `Operation.metadata` contains `AnnotateVideoProgress` (progress). - * `Operation.response` contains `AnnotateVideoResponse` (results). - * - * The async variant is {@see self::annotateVideoAsync()} . - * - * @param AnnotateVideoRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function annotateVideo(AnnotateVideoRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AnnotateVideo', $request, $callOptions)->wait(); - } -} diff --git a/VideoIntelligence/src/V1/Client/VideoIntelligenceServiceClient.php b/VideoIntelligence/src/V1/Client/VideoIntelligenceServiceClient.php index 58a17836654c..157f1a410438 100644 --- a/VideoIntelligence/src/V1/Client/VideoIntelligenceServiceClient.php +++ b/VideoIntelligence/src/V1/Client/VideoIntelligenceServiceClient.php @@ -24,17 +24,203 @@ namespace Google\Cloud\VideoIntelligence\V1\Client; -use Google\Cloud\VideoIntelligence\V1\Client\BaseClient\VideoIntelligenceServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\VideoIntelligence\V1\AnnotateVideoProgress; +use Google\Cloud\VideoIntelligence\V1\AnnotateVideoRequest; +use Google\Cloud\VideoIntelligence\V1\AnnotateVideoResponse; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service that implements the Video Intelligence API. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\VideoIntelligence\V1\VideoIntelligenceServiceClient} for the + * stable implementation * * @experimental + * + * @method PromiseInterface annotateVideoAsync(AnnotateVideoRequest $request, array $optionalArgs = []) */ -final class VideoIntelligenceServiceClient extends VideoIntelligenceServiceBaseClient +final class VideoIntelligenceServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see VideoIntelligenceServiceBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.videointelligence.v1.VideoIntelligenceService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'videointelligence.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/video_intelligence_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/video_intelligence_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/video_intelligence_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/video_intelligence_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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 'videointelligence.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Performs asynchronous video annotation. Progress and results can be + * retrieved through the `google.longrunning.Operations` interface. + * `Operation.metadata` contains `AnnotateVideoProgress` (progress). + * `Operation.response` contains `AnnotateVideoResponse` (results). + * + * The async variant is {@see VideoIntelligenceServiceClient::annotateVideoAsync()} + * . + * + * @param AnnotateVideoRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function annotateVideo(AnnotateVideoRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AnnotateVideo', $request, $callOptions)->wait(); + } } diff --git a/VideoLiveStream/composer.json b/VideoLiveStream/composer.json index 24d2d984209d..14b12d4b385d 100644 --- a/VideoLiveStream/composer.json +++ b/VideoLiveStream/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/VideoLiveStream/src/V1/Client/BaseClient/LivestreamServiceBaseClient.php b/VideoLiveStream/src/V1/Client/BaseClient/LivestreamServiceBaseClient.php deleted file mode 100644 index dcd6527161d7..000000000000 --- a/VideoLiveStream/src/V1/Client/BaseClient/LivestreamServiceBaseClient.php +++ /dev/null @@ -1,1069 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/livestream_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/livestream_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/livestream_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/livestream_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a asset - * resource. - * - * @param string $project - * @param string $location - * @param string $asset - * - * @return string The formatted asset resource. - */ - public static function assetName(string $project, string $location, string $asset): string - { - return self::getPathTemplate('asset')->render([ - 'project' => $project, - 'location' => $location, - 'asset' => $asset, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a channel - * resource. - * - * @param string $project - * @param string $location - * @param string $channel - * - * @return string The formatted channel resource. - */ - public static function channelName(string $project, string $location, string $channel): string - { - return self::getPathTemplate('channel')->render([ - 'project' => $project, - 'location' => $location, - 'channel' => $channel, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a event - * resource. - * - * @param string $project - * @param string $location - * @param string $channel - * @param string $event - * - * @return string The formatted event resource. - */ - public static function eventName(string $project, string $location, string $channel, string $event): string - { - return self::getPathTemplate('event')->render([ - 'project' => $project, - 'location' => $location, - 'channel' => $channel, - 'event' => $event, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a input - * resource. - * - * @param string $project - * @param string $location - * @param string $input - * - * @return string The formatted input resource. - */ - public static function inputName(string $project, string $location, string $input): string - { - return self::getPathTemplate('input')->render([ - 'project' => $project, - 'location' => $location, - 'input' => $input, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a network - * resource. - * - * @param string $project - * @param string $network - * - * @return string The formatted network resource. - */ - public static function networkName(string $project, string $network): string - { - return self::getPathTemplate('network')->render([ - 'project' => $project, - 'network' => $network, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a pool - * resource. - * - * @param string $project - * @param string $location - * @param string $pool - * - * @return string The formatted pool resource. - */ - public static function poolName(string $project, string $location, string $pool): string - { - return self::getPathTemplate('pool')->render([ - 'project' => $project, - 'location' => $location, - 'pool' => $pool, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * secret_version resource. - * - * @param string $project - * @param string $secret - * @param string $version - * - * @return string The formatted secret_version resource. - */ - public static function secretVersionName(string $project, string $secret, string $version): string - { - return self::getPathTemplate('secretVersion')->render([ - 'project' => $project, - 'secret' => $secret, - 'version' => $version, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - asset: projects/{project}/locations/{location}/assets/{asset} - * - channel: projects/{project}/locations/{location}/channels/{channel} - * - event: projects/{project}/locations/{location}/channels/{channel}/events/{event} - * - input: projects/{project}/locations/{location}/inputs/{input} - * - location: projects/{project}/locations/{location} - * - network: projects/{project}/global/networks/{network} - * - pool: projects/{project}/locations/{location}/pools/{pool} - * - secretVersion: projects/{project}/secrets/{secret}/versions/{version} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'livestream.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a Asset with the provided unique ID in the specified - * region. - * - * The async variant is {@see self::createAssetAsync()} . - * - * @example samples/V1/LivestreamServiceClient/create_asset.php - * - * @param CreateAssetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createAsset(CreateAssetRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateAsset', $request, $callOptions)->wait(); - } - - /** - * Creates a channel with the provided unique ID in the specified - * region. - * - * The async variant is {@see self::createChannelAsync()} . - * - * @example samples/V1/LivestreamServiceClient/create_channel.php - * - * @param CreateChannelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createChannel(CreateChannelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateChannel', $request, $callOptions)->wait(); - } - - /** - * Creates an event with the provided unique ID in the specified channel. - * - * The async variant is {@see self::createEventAsync()} . - * - * @example samples/V1/LivestreamServiceClient/create_event.php - * - * @param CreateEventRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Event - * - * @throws ApiException Thrown if the API call fails. - */ - public function createEvent(CreateEventRequest $request, array $callOptions = []): Event - { - return $this->startApiCall('CreateEvent', $request, $callOptions)->wait(); - } - - /** - * Creates an input with the provided unique ID in the specified region. - * - * The async variant is {@see self::createInputAsync()} . - * - * @example samples/V1/LivestreamServiceClient/create_input.php - * - * @param CreateInputRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createInput(CreateInputRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateInput', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified asset if it is not used. - * - * The async variant is {@see self::deleteAssetAsync()} . - * - * @example samples/V1/LivestreamServiceClient/delete_asset.php - * - * @param DeleteAssetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteAsset(DeleteAssetRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteAsset', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified channel. - * - * The async variant is {@see self::deleteChannelAsync()} . - * - * @example samples/V1/LivestreamServiceClient/delete_channel.php - * - * @param DeleteChannelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteChannel(DeleteChannelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteChannel', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified event. - * - * The async variant is {@see self::deleteEventAsync()} . - * - * @example samples/V1/LivestreamServiceClient/delete_event.php - * - * @param DeleteEventRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteEvent(DeleteEventRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteEvent', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified input. - * - * The async variant is {@see self::deleteInputAsync()} . - * - * @example samples/V1/LivestreamServiceClient/delete_input.php - * - * @param DeleteInputRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteInput(DeleteInputRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteInput', $request, $callOptions)->wait(); - } - - /** - * Returns the specified asset. - * - * The async variant is {@see self::getAssetAsync()} . - * - * @example samples/V1/LivestreamServiceClient/get_asset.php - * - * @param GetAssetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Asset - * - * @throws ApiException Thrown if the API call fails. - */ - public function getAsset(GetAssetRequest $request, array $callOptions = []): Asset - { - return $this->startApiCall('GetAsset', $request, $callOptions)->wait(); - } - - /** - * Returns the specified channel. - * - * The async variant is {@see self::getChannelAsync()} . - * - * @example samples/V1/LivestreamServiceClient/get_channel.php - * - * @param GetChannelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Channel - * - * @throws ApiException Thrown if the API call fails. - */ - public function getChannel(GetChannelRequest $request, array $callOptions = []): Channel - { - return $this->startApiCall('GetChannel', $request, $callOptions)->wait(); - } - - /** - * Returns the specified event. - * - * The async variant is {@see self::getEventAsync()} . - * - * @example samples/V1/LivestreamServiceClient/get_event.php - * - * @param GetEventRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Event - * - * @throws ApiException Thrown if the API call fails. - */ - public function getEvent(GetEventRequest $request, array $callOptions = []): Event - { - return $this->startApiCall('GetEvent', $request, $callOptions)->wait(); - } - - /** - * Returns the specified input. - * - * The async variant is {@see self::getInputAsync()} . - * - * @example samples/V1/LivestreamServiceClient/get_input.php - * - * @param GetInputRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Input - * - * @throws ApiException Thrown if the API call fails. - */ - public function getInput(GetInputRequest $request, array $callOptions = []): Input - { - return $this->startApiCall('GetInput', $request, $callOptions)->wait(); - } - - /** - * Returns the specified pool. - * - * The async variant is {@see self::getPoolAsync()} . - * - * @example samples/V1/LivestreamServiceClient/get_pool.php - * - * @param GetPoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Pool - * - * @throws ApiException Thrown if the API call fails. - */ - public function getPool(GetPoolRequest $request, array $callOptions = []): Pool - { - return $this->startApiCall('GetPool', $request, $callOptions)->wait(); - } - - /** - * Returns a list of all assets in the specified region. - * - * The async variant is {@see self::listAssetsAsync()} . - * - * @example samples/V1/LivestreamServiceClient/list_assets.php - * - * @param ListAssetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listAssets(ListAssetsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListAssets', $request, $callOptions); - } - - /** - * Returns a list of all channels in the specified region. - * - * The async variant is {@see self::listChannelsAsync()} . - * - * @example samples/V1/LivestreamServiceClient/list_channels.php - * - * @param ListChannelsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listChannels(ListChannelsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListChannels', $request, $callOptions); - } - - /** - * Returns a list of all events in the specified channel. - * - * The async variant is {@see self::listEventsAsync()} . - * - * @example samples/V1/LivestreamServiceClient/list_events.php - * - * @param ListEventsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listEvents(ListEventsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListEvents', $request, $callOptions); - } - - /** - * Returns a list of all inputs in the specified region. - * - * The async variant is {@see self::listInputsAsync()} . - * - * @example samples/V1/LivestreamServiceClient/list_inputs.php - * - * @param ListInputsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listInputs(ListInputsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListInputs', $request, $callOptions); - } - - /** - * Starts the specified channel. Part of the video pipeline will be created - * only when the StartChannel request is received by the server. - * - * The async variant is {@see self::startChannelAsync()} . - * - * @example samples/V1/LivestreamServiceClient/start_channel.php - * - * @param StartChannelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function startChannel(StartChannelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StartChannel', $request, $callOptions)->wait(); - } - - /** - * Stops the specified channel. Part of the video pipeline will be released - * when the StopChannel request is received by the server. - * - * The async variant is {@see self::stopChannelAsync()} . - * - * @example samples/V1/LivestreamServiceClient/stop_channel.php - * - * @param StopChannelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function stopChannel(StopChannelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StopChannel', $request, $callOptions)->wait(); - } - - /** - * Updates the specified channel. - * - * The async variant is {@see self::updateChannelAsync()} . - * - * @example samples/V1/LivestreamServiceClient/update_channel.php - * - * @param UpdateChannelRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateChannel(UpdateChannelRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateChannel', $request, $callOptions)->wait(); - } - - /** - * Updates the specified input. - * - * The async variant is {@see self::updateInputAsync()} . - * - * @example samples/V1/LivestreamServiceClient/update_input.php - * - * @param UpdateInputRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateInput(UpdateInputRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateInput', $request, $callOptions)->wait(); - } - - /** - * Updates the specified pool. - * - * The async variant is {@see self::updatePoolAsync()} . - * - * @example samples/V1/LivestreamServiceClient/update_pool.php - * - * @param UpdatePoolRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updatePool(UpdatePoolRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdatePool', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/LivestreamServiceClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/LivestreamServiceClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/VideoLiveStream/src/V1/Client/LivestreamServiceClient.php b/VideoLiveStream/src/V1/Client/LivestreamServiceClient.php index 055a92e9d6ce..74c8b8ad456e 100644 --- a/VideoLiveStream/src/V1/Client/LivestreamServiceClient.php +++ b/VideoLiveStream/src/V1/Client/LivestreamServiceClient.php @@ -24,17 +24,1044 @@ namespace Google\Cloud\Video\LiveStream\V1\Client; -use Google\Cloud\Video\LiveStream\V1\Client\BaseClient\LivestreamServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\Video\LiveStream\V1\Asset; +use Google\Cloud\Video\LiveStream\V1\Channel; +use Google\Cloud\Video\LiveStream\V1\CreateAssetRequest; +use Google\Cloud\Video\LiveStream\V1\CreateChannelRequest; +use Google\Cloud\Video\LiveStream\V1\CreateEventRequest; +use Google\Cloud\Video\LiveStream\V1\CreateInputRequest; +use Google\Cloud\Video\LiveStream\V1\DeleteAssetRequest; +use Google\Cloud\Video\LiveStream\V1\DeleteChannelRequest; +use Google\Cloud\Video\LiveStream\V1\DeleteEventRequest; +use Google\Cloud\Video\LiveStream\V1\DeleteInputRequest; +use Google\Cloud\Video\LiveStream\V1\Event; +use Google\Cloud\Video\LiveStream\V1\GetAssetRequest; +use Google\Cloud\Video\LiveStream\V1\GetChannelRequest; +use Google\Cloud\Video\LiveStream\V1\GetEventRequest; +use Google\Cloud\Video\LiveStream\V1\GetInputRequest; +use Google\Cloud\Video\LiveStream\V1\GetPoolRequest; +use Google\Cloud\Video\LiveStream\V1\Input; +use Google\Cloud\Video\LiveStream\V1\ListAssetsRequest; +use Google\Cloud\Video\LiveStream\V1\ListChannelsRequest; +use Google\Cloud\Video\LiveStream\V1\ListEventsRequest; +use Google\Cloud\Video\LiveStream\V1\ListInputsRequest; +use Google\Cloud\Video\LiveStream\V1\Pool; +use Google\Cloud\Video\LiveStream\V1\StartChannelRequest; +use Google\Cloud\Video\LiveStream\V1\StopChannelRequest; +use Google\Cloud\Video\LiveStream\V1\UpdateChannelRequest; +use Google\Cloud\Video\LiveStream\V1\UpdateInputRequest; +use Google\Cloud\Video\LiveStream\V1\UpdatePoolRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Using Live Stream API, you can generate live streams in the various + * renditions and streaming formats. The streaming format include HTTP Live + * Streaming (HLS) and Dynamic Adaptive Streaming over HTTP (DASH). You can send + * a source stream in the various ways, including Real-Time Messaging + * Protocol (RTMP) and Secure Reliable Transport (SRT). * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createAssetAsync(CreateAssetRequest $request, array $optionalArgs = []) + * @method PromiseInterface createChannelAsync(CreateChannelRequest $request, array $optionalArgs = []) + * @method PromiseInterface createEventAsync(CreateEventRequest $request, array $optionalArgs = []) + * @method PromiseInterface createInputAsync(CreateInputRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteAssetAsync(DeleteAssetRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteChannelAsync(DeleteChannelRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteEventAsync(DeleteEventRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteInputAsync(DeleteInputRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAssetAsync(GetAssetRequest $request, array $optionalArgs = []) + * @method PromiseInterface getChannelAsync(GetChannelRequest $request, array $optionalArgs = []) + * @method PromiseInterface getEventAsync(GetEventRequest $request, array $optionalArgs = []) + * @method PromiseInterface getInputAsync(GetInputRequest $request, array $optionalArgs = []) + * @method PromiseInterface getPoolAsync(GetPoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface listAssetsAsync(ListAssetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listChannelsAsync(ListChannelsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listEventsAsync(ListEventsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listInputsAsync(ListInputsRequest $request, array $optionalArgs = []) + * @method PromiseInterface startChannelAsync(StartChannelRequest $request, array $optionalArgs = []) + * @method PromiseInterface stopChannelAsync(StopChannelRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateChannelAsync(UpdateChannelRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateInputAsync(UpdateInputRequest $request, array $optionalArgs = []) + * @method PromiseInterface updatePoolAsync(UpdatePoolRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class LivestreamServiceClient extends LivestreamServiceBaseClient +final class LivestreamServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see LivestreamServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.video.livestream.v1.LivestreamService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'livestream.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/livestream_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/livestream_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/livestream_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/livestream_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a asset + * resource. + * + * @param string $project + * @param string $location + * @param string $asset + * + * @return string The formatted asset resource. + */ + public static function assetName(string $project, string $location, string $asset): string + { + return self::getPathTemplate('asset')->render([ + 'project' => $project, + 'location' => $location, + 'asset' => $asset, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a channel + * resource. + * + * @param string $project + * @param string $location + * @param string $channel + * + * @return string The formatted channel resource. + */ + public static function channelName(string $project, string $location, string $channel): string + { + return self::getPathTemplate('channel')->render([ + 'project' => $project, + 'location' => $location, + 'channel' => $channel, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a event + * resource. + * + * @param string $project + * @param string $location + * @param string $channel + * @param string $event + * + * @return string The formatted event resource. + */ + public static function eventName(string $project, string $location, string $channel, string $event): string + { + return self::getPathTemplate('event')->render([ + 'project' => $project, + 'location' => $location, + 'channel' => $channel, + 'event' => $event, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a input + * resource. + * + * @param string $project + * @param string $location + * @param string $input + * + * @return string The formatted input resource. + */ + public static function inputName(string $project, string $location, string $input): string + { + return self::getPathTemplate('input')->render([ + 'project' => $project, + 'location' => $location, + 'input' => $input, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a network + * resource. + * + * @param string $project + * @param string $network + * + * @return string The formatted network resource. + */ + public static function networkName(string $project, string $network): string + { + return self::getPathTemplate('network')->render([ + 'project' => $project, + 'network' => $network, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a pool + * resource. + * + * @param string $project + * @param string $location + * @param string $pool + * + * @return string The formatted pool resource. + */ + public static function poolName(string $project, string $location, string $pool): string + { + return self::getPathTemplate('pool')->render([ + 'project' => $project, + 'location' => $location, + 'pool' => $pool, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * secret_version resource. + * + * @param string $project + * @param string $secret + * @param string $version + * + * @return string The formatted secret_version resource. + */ + public static function secretVersionName(string $project, string $secret, string $version): string + { + return self::getPathTemplate('secretVersion')->render([ + 'project' => $project, + 'secret' => $secret, + 'version' => $version, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - asset: projects/{project}/locations/{location}/assets/{asset} + * - channel: projects/{project}/locations/{location}/channels/{channel} + * - event: projects/{project}/locations/{location}/channels/{channel}/events/{event} + * - input: projects/{project}/locations/{location}/inputs/{input} + * - location: projects/{project}/locations/{location} + * - network: projects/{project}/global/networks/{network} + * - pool: projects/{project}/locations/{location}/pools/{pool} + * - secretVersion: projects/{project}/secrets/{secret}/versions/{version} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'livestream.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a Asset with the provided unique ID in the specified + * region. + * + * The async variant is {@see LivestreamServiceClient::createAssetAsync()} . + * + * @example samples/V1/LivestreamServiceClient/create_asset.php + * + * @param CreateAssetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createAsset(CreateAssetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateAsset', $request, $callOptions)->wait(); + } + + /** + * Creates a channel with the provided unique ID in the specified + * region. + * + * The async variant is {@see LivestreamServiceClient::createChannelAsync()} . + * + * @example samples/V1/LivestreamServiceClient/create_channel.php + * + * @param CreateChannelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createChannel(CreateChannelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateChannel', $request, $callOptions)->wait(); + } + + /** + * Creates an event with the provided unique ID in the specified channel. + * + * The async variant is {@see LivestreamServiceClient::createEventAsync()} . + * + * @example samples/V1/LivestreamServiceClient/create_event.php + * + * @param CreateEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Event + * + * @throws ApiException Thrown if the API call fails. + */ + public function createEvent(CreateEventRequest $request, array $callOptions = []): Event + { + return $this->startApiCall('CreateEvent', $request, $callOptions)->wait(); + } + + /** + * Creates an input with the provided unique ID in the specified region. + * + * The async variant is {@see LivestreamServiceClient::createInputAsync()} . + * + * @example samples/V1/LivestreamServiceClient/create_input.php + * + * @param CreateInputRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createInput(CreateInputRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateInput', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified asset if it is not used. + * + * The async variant is {@see LivestreamServiceClient::deleteAssetAsync()} . + * + * @example samples/V1/LivestreamServiceClient/delete_asset.php + * + * @param DeleteAssetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteAsset(DeleteAssetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteAsset', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified channel. + * + * The async variant is {@see LivestreamServiceClient::deleteChannelAsync()} . + * + * @example samples/V1/LivestreamServiceClient/delete_channel.php + * + * @param DeleteChannelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteChannel(DeleteChannelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteChannel', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified event. + * + * The async variant is {@see LivestreamServiceClient::deleteEventAsync()} . + * + * @example samples/V1/LivestreamServiceClient/delete_event.php + * + * @param DeleteEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteEvent(DeleteEventRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteEvent', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified input. + * + * The async variant is {@see LivestreamServiceClient::deleteInputAsync()} . + * + * @example samples/V1/LivestreamServiceClient/delete_input.php + * + * @param DeleteInputRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteInput(DeleteInputRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteInput', $request, $callOptions)->wait(); + } + + /** + * Returns the specified asset. + * + * The async variant is {@see LivestreamServiceClient::getAssetAsync()} . + * + * @example samples/V1/LivestreamServiceClient/get_asset.php + * + * @param GetAssetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Asset + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAsset(GetAssetRequest $request, array $callOptions = []): Asset + { + return $this->startApiCall('GetAsset', $request, $callOptions)->wait(); + } + + /** + * Returns the specified channel. + * + * The async variant is {@see LivestreamServiceClient::getChannelAsync()} . + * + * @example samples/V1/LivestreamServiceClient/get_channel.php + * + * @param GetChannelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Channel + * + * @throws ApiException Thrown if the API call fails. + */ + public function getChannel(GetChannelRequest $request, array $callOptions = []): Channel + { + return $this->startApiCall('GetChannel', $request, $callOptions)->wait(); + } + + /** + * Returns the specified event. + * + * The async variant is {@see LivestreamServiceClient::getEventAsync()} . + * + * @example samples/V1/LivestreamServiceClient/get_event.php + * + * @param GetEventRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Event + * + * @throws ApiException Thrown if the API call fails. + */ + public function getEvent(GetEventRequest $request, array $callOptions = []): Event + { + return $this->startApiCall('GetEvent', $request, $callOptions)->wait(); + } + + /** + * Returns the specified input. + * + * The async variant is {@see LivestreamServiceClient::getInputAsync()} . + * + * @example samples/V1/LivestreamServiceClient/get_input.php + * + * @param GetInputRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Input + * + * @throws ApiException Thrown if the API call fails. + */ + public function getInput(GetInputRequest $request, array $callOptions = []): Input + { + return $this->startApiCall('GetInput', $request, $callOptions)->wait(); + } + + /** + * Returns the specified pool. + * + * The async variant is {@see LivestreamServiceClient::getPoolAsync()} . + * + * @example samples/V1/LivestreamServiceClient/get_pool.php + * + * @param GetPoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Pool + * + * @throws ApiException Thrown if the API call fails. + */ + public function getPool(GetPoolRequest $request, array $callOptions = []): Pool + { + return $this->startApiCall('GetPool', $request, $callOptions)->wait(); + } + + /** + * Returns a list of all assets in the specified region. + * + * The async variant is {@see LivestreamServiceClient::listAssetsAsync()} . + * + * @example samples/V1/LivestreamServiceClient/list_assets.php + * + * @param ListAssetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listAssets(ListAssetsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListAssets', $request, $callOptions); + } + + /** + * Returns a list of all channels in the specified region. + * + * The async variant is {@see LivestreamServiceClient::listChannelsAsync()} . + * + * @example samples/V1/LivestreamServiceClient/list_channels.php + * + * @param ListChannelsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listChannels(ListChannelsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListChannels', $request, $callOptions); + } + + /** + * Returns a list of all events in the specified channel. + * + * The async variant is {@see LivestreamServiceClient::listEventsAsync()} . + * + * @example samples/V1/LivestreamServiceClient/list_events.php + * + * @param ListEventsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listEvents(ListEventsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListEvents', $request, $callOptions); + } + + /** + * Returns a list of all inputs in the specified region. + * + * The async variant is {@see LivestreamServiceClient::listInputsAsync()} . + * + * @example samples/V1/LivestreamServiceClient/list_inputs.php + * + * @param ListInputsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listInputs(ListInputsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListInputs', $request, $callOptions); + } + + /** + * Starts the specified channel. Part of the video pipeline will be created + * only when the StartChannel request is received by the server. + * + * The async variant is {@see LivestreamServiceClient::startChannelAsync()} . + * + * @example samples/V1/LivestreamServiceClient/start_channel.php + * + * @param StartChannelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function startChannel(StartChannelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StartChannel', $request, $callOptions)->wait(); + } + + /** + * Stops the specified channel. Part of the video pipeline will be released + * when the StopChannel request is received by the server. + * + * The async variant is {@see LivestreamServiceClient::stopChannelAsync()} . + * + * @example samples/V1/LivestreamServiceClient/stop_channel.php + * + * @param StopChannelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function stopChannel(StopChannelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StopChannel', $request, $callOptions)->wait(); + } + + /** + * Updates the specified channel. + * + * The async variant is {@see LivestreamServiceClient::updateChannelAsync()} . + * + * @example samples/V1/LivestreamServiceClient/update_channel.php + * + * @param UpdateChannelRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateChannel(UpdateChannelRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateChannel', $request, $callOptions)->wait(); + } + + /** + * Updates the specified input. + * + * The async variant is {@see LivestreamServiceClient::updateInputAsync()} . + * + * @example samples/V1/LivestreamServiceClient/update_input.php + * + * @param UpdateInputRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateInput(UpdateInputRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateInput', $request, $callOptions)->wait(); + } + + /** + * Updates the specified pool. + * + * The async variant is {@see LivestreamServiceClient::updatePoolAsync()} . + * + * @example samples/V1/LivestreamServiceClient/update_pool.php + * + * @param UpdatePoolRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updatePool(UpdatePoolRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdatePool', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see LivestreamServiceClient::getLocationAsync()} . + * + * @example samples/V1/LivestreamServiceClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see LivestreamServiceClient::listLocationsAsync()} . + * + * @example samples/V1/LivestreamServiceClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/VideoStitcher/composer.json b/VideoStitcher/composer.json index 3d5e6f1faa3c..6535d5e990f9 100644 --- a/VideoStitcher/composer.json +++ b/VideoStitcher/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/VideoStitcher/src/V1/Client/BaseClient/VideoStitcherServiceBaseClient.php b/VideoStitcher/src/V1/Client/BaseClient/VideoStitcherServiceBaseClient.php deleted file mode 100644 index 088fd926b284..000000000000 --- a/VideoStitcher/src/V1/Client/BaseClient/VideoStitcherServiceBaseClient.php +++ /dev/null @@ -1,1102 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/video_stitcher_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/video_stitcher_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/video_stitcher_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/video_stitcher_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a cdn_key - * resource. - * - * @param string $project - * @param string $location - * @param string $cdnKey - * - * @return string The formatted cdn_key resource. - */ - public static function cdnKeyName(string $project, string $location, string $cdnKey): string - { - return self::getPathTemplate('cdnKey')->render([ - 'project' => $project, - 'location' => $location, - 'cdn_key' => $cdnKey, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * live_ad_tag_detail resource. - * - * @param string $project - * @param string $location - * @param string $liveSession - * @param string $liveAdTagDetail - * - * @return string The formatted live_ad_tag_detail resource. - */ - public static function liveAdTagDetailName(string $project, string $location, string $liveSession, string $liveAdTagDetail): string - { - return self::getPathTemplate('liveAdTagDetail')->render([ - 'project' => $project, - 'location' => $location, - 'live_session' => $liveSession, - 'live_ad_tag_detail' => $liveAdTagDetail, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a live_config - * resource. - * - * @param string $project - * @param string $location - * @param string $liveConfig - * - * @return string The formatted live_config resource. - */ - public static function liveConfigName(string $project, string $location, string $liveConfig): string - { - return self::getPathTemplate('liveConfig')->render([ - 'project' => $project, - 'location' => $location, - 'live_config' => $liveConfig, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a live_session - * resource. - * - * @param string $project - * @param string $location - * @param string $liveSession - * - * @return string The formatted live_session resource. - */ - public static function liveSessionName(string $project, string $location, string $liveSession): string - { - return self::getPathTemplate('liveSession')->render([ - 'project' => $project, - 'location' => $location, - 'live_session' => $liveSession, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a slate - * resource. - * - * @param string $project - * @param string $location - * @param string $slate - * - * @return string The formatted slate resource. - */ - public static function slateName(string $project, string $location, string $slate): string - { - return self::getPathTemplate('slate')->render([ - 'project' => $project, - 'location' => $location, - 'slate' => $slate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * vod_ad_tag_detail resource. - * - * @param string $project - * @param string $location - * @param string $vodSession - * @param string $vodAdTagDetail - * - * @return string The formatted vod_ad_tag_detail resource. - */ - public static function vodAdTagDetailName(string $project, string $location, string $vodSession, string $vodAdTagDetail): string - { - return self::getPathTemplate('vodAdTagDetail')->render([ - 'project' => $project, - 'location' => $location, - 'vod_session' => $vodSession, - 'vod_ad_tag_detail' => $vodAdTagDetail, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a vod_session - * resource. - * - * @param string $project - * @param string $location - * @param string $vodSession - * - * @return string The formatted vod_session resource. - */ - public static function vodSessionName(string $project, string $location, string $vodSession): string - { - return self::getPathTemplate('vodSession')->render([ - 'project' => $project, - 'location' => $location, - 'vod_session' => $vodSession, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * vod_stitch_detail resource. - * - * @param string $project - * @param string $location - * @param string $vodSession - * @param string $vodStitchDetail - * - * @return string The formatted vod_stitch_detail resource. - */ - public static function vodStitchDetailName(string $project, string $location, string $vodSession, string $vodStitchDetail): string - { - return self::getPathTemplate('vodStitchDetail')->render([ - 'project' => $project, - 'location' => $location, - 'vod_session' => $vodSession, - 'vod_stitch_detail' => $vodStitchDetail, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - cdnKey: projects/{project}/locations/{location}/cdnKeys/{cdn_key} - * - liveAdTagDetail: projects/{project}/locations/{location}/liveSessions/{live_session}/liveAdTagDetails/{live_ad_tag_detail} - * - liveConfig: projects/{project}/locations/{location}/liveConfigs/{live_config} - * - liveSession: projects/{project}/locations/{location}/liveSessions/{live_session} - * - location: projects/{project}/locations/{location} - * - slate: projects/{project}/locations/{location}/slates/{slate} - * - vodAdTagDetail: projects/{project}/locations/{location}/vodSessions/{vod_session}/vodAdTagDetails/{vod_ad_tag_detail} - * - vodSession: projects/{project}/locations/{location}/vodSessions/{vod_session} - * - vodStitchDetail: projects/{project}/locations/{location}/vodSessions/{vod_session}/vodStitchDetails/{vod_stitch_detail} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'videostitcher.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new CDN key. - * - * The async variant is {@see self::createCdnKeyAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/create_cdn_key.php - * - * @param CreateCdnKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCdnKey(CreateCdnKeyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateCdnKey', $request, $callOptions)->wait(); - } - - /** - * Registers the live config with the provided unique ID in - * the specified region. - * - * The async variant is {@see self::createLiveConfigAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/create_live_config.php - * - * @param CreateLiveConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createLiveConfig(CreateLiveConfigRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateLiveConfig', $request, $callOptions)->wait(); - } - - /** - * Creates a new live session. - * - * The async variant is {@see self::createLiveSessionAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/create_live_session.php - * - * @param CreateLiveSessionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LiveSession - * - * @throws ApiException Thrown if the API call fails. - */ - public function createLiveSession(CreateLiveSessionRequest $request, array $callOptions = []): LiveSession - { - return $this->startApiCall('CreateLiveSession', $request, $callOptions)->wait(); - } - - /** - * Creates a slate. - * - * The async variant is {@see self::createSlateAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/create_slate.php - * - * @param CreateSlateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSlate(CreateSlateRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateSlate', $request, $callOptions)->wait(); - } - - /** - * Creates a client side playback VOD session and returns the full - * tracking and playback metadata of the session. - * - * The async variant is {@see self::createVodSessionAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/create_vod_session.php - * - * @param CreateVodSessionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 VodSession - * - * @throws ApiException Thrown if the API call fails. - */ - public function createVodSession(CreateVodSessionRequest $request, array $callOptions = []): VodSession - { - return $this->startApiCall('CreateVodSession', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified CDN key. - * - * The async variant is {@see self::deleteCdnKeyAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/delete_cdn_key.php - * - * @param DeleteCdnKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteCdnKey(DeleteCdnKeyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteCdnKey', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified live config. - * - * The async variant is {@see self::deleteLiveConfigAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/delete_live_config.php - * - * @param DeleteLiveConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteLiveConfig(DeleteLiveConfigRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteLiveConfig', $request, $callOptions)->wait(); - } - - /** - * Deletes the specified slate. - * - * The async variant is {@see self::deleteSlateAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/delete_slate.php - * - * @param DeleteSlateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSlate(DeleteSlateRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteSlate', $request, $callOptions)->wait(); - } - - /** - * Returns the specified CDN key. - * - * The async variant is {@see self::getCdnKeyAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/get_cdn_key.php - * - * @param GetCdnKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CdnKey - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCdnKey(GetCdnKeyRequest $request, array $callOptions = []): CdnKey - { - return $this->startApiCall('GetCdnKey', $request, $callOptions)->wait(); - } - - /** - * Returns the specified ad tag detail for the specified live session. - * - * The async variant is {@see self::getLiveAdTagDetailAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/get_live_ad_tag_detail.php - * - * @param GetLiveAdTagDetailRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LiveAdTagDetail - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLiveAdTagDetail(GetLiveAdTagDetailRequest $request, array $callOptions = []): LiveAdTagDetail - { - return $this->startApiCall('GetLiveAdTagDetail', $request, $callOptions)->wait(); - } - - /** - * Returns the specified live config managed by the Video - * Stitcher service. - * - * The async variant is {@see self::getLiveConfigAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/get_live_config.php - * - * @param GetLiveConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LiveConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLiveConfig(GetLiveConfigRequest $request, array $callOptions = []): LiveConfig - { - return $this->startApiCall('GetLiveConfig', $request, $callOptions)->wait(); - } - - /** - * Returns the details for the specified live session. - * - * The async variant is {@see self::getLiveSessionAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/get_live_session.php - * - * @param GetLiveSessionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 LiveSession - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLiveSession(GetLiveSessionRequest $request, array $callOptions = []): LiveSession - { - return $this->startApiCall('GetLiveSession', $request, $callOptions)->wait(); - } - - /** - * Returns the specified slate. - * - * The async variant is {@see self::getSlateAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/get_slate.php - * - * @param GetSlateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Slate - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSlate(GetSlateRequest $request, array $callOptions = []): Slate - { - return $this->startApiCall('GetSlate', $request, $callOptions)->wait(); - } - - /** - * Returns the specified ad tag detail for the specified VOD session. - * - * The async variant is {@see self::getVodAdTagDetailAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/get_vod_ad_tag_detail.php - * - * @param GetVodAdTagDetailRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 VodAdTagDetail - * - * @throws ApiException Thrown if the API call fails. - */ - public function getVodAdTagDetail(GetVodAdTagDetailRequest $request, array $callOptions = []): VodAdTagDetail - { - return $this->startApiCall('GetVodAdTagDetail', $request, $callOptions)->wait(); - } - - /** - * Returns the full tracking, playback metadata, and relevant ad-ops - * logs for the specified VOD session. - * - * The async variant is {@see self::getVodSessionAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/get_vod_session.php - * - * @param GetVodSessionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 VodSession - * - * @throws ApiException Thrown if the API call fails. - */ - public function getVodSession(GetVodSessionRequest $request, array $callOptions = []): VodSession - { - return $this->startApiCall('GetVodSession', $request, $callOptions)->wait(); - } - - /** - * Returns the specified stitching information for the specified VOD session. - * - * The async variant is {@see self::getVodStitchDetailAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/get_vod_stitch_detail.php - * - * @param GetVodStitchDetailRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 VodStitchDetail - * - * @throws ApiException Thrown if the API call fails. - */ - public function getVodStitchDetail(GetVodStitchDetailRequest $request, array $callOptions = []): VodStitchDetail - { - return $this->startApiCall('GetVodStitchDetail', $request, $callOptions)->wait(); - } - - /** - * Lists all CDN keys in the specified project and location. - * - * The async variant is {@see self::listCdnKeysAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/list_cdn_keys.php - * - * @param ListCdnKeysRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCdnKeys(ListCdnKeysRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCdnKeys', $request, $callOptions); - } - - /** - * Return the list of ad tag details for the specified live session. - * - * The async variant is {@see self::listLiveAdTagDetailsAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/list_live_ad_tag_details.php - * - * @param ListLiveAdTagDetailsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLiveAdTagDetails(ListLiveAdTagDetailsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLiveAdTagDetails', $request, $callOptions); - } - - /** - * Lists all live configs managed by the Video Stitcher that - * belong to the specified project and region. - * - * The async variant is {@see self::listLiveConfigsAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/list_live_configs.php - * - * @param ListLiveConfigsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLiveConfigs(ListLiveConfigsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLiveConfigs', $request, $callOptions); - } - - /** - * Lists all slates in the specified project and location. - * - * The async variant is {@see self::listSlatesAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/list_slates.php - * - * @param ListSlatesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSlates(ListSlatesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSlates', $request, $callOptions); - } - - /** - * Return the list of ad tag details for the specified VOD session. - * - * The async variant is {@see self::listVodAdTagDetailsAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/list_vod_ad_tag_details.php - * - * @param ListVodAdTagDetailsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listVodAdTagDetails(ListVodAdTagDetailsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListVodAdTagDetails', $request, $callOptions); - } - - /** - * Returns a list of detailed stitching information of the specified VOD - * session. - * - * The async variant is {@see self::listVodStitchDetailsAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/list_vod_stitch_details.php - * - * @param ListVodStitchDetailsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listVodStitchDetails(ListVodStitchDetailsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListVodStitchDetails', $request, $callOptions); - } - - /** - * Updates the specified CDN key. Only update fields specified - * in the call method body. - * - * The async variant is {@see self::updateCdnKeyAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/update_cdn_key.php - * - * @param UpdateCdnKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCdnKey(UpdateCdnKeyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateCdnKey', $request, $callOptions)->wait(); - } - - /** - * Updates the specified slate. - * - * The async variant is {@see self::updateSlateAsync()} . - * - * @example samples/V1/VideoStitcherServiceClient/update_slate.php - * - * @param UpdateSlateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSlate(UpdateSlateRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateSlate', $request, $callOptions)->wait(); - } -} diff --git a/VideoStitcher/src/V1/Client/VideoStitcherServiceClient.php b/VideoStitcher/src/V1/Client/VideoStitcherServiceClient.php index 214ff555e8fc..b9b576beca75 100644 --- a/VideoStitcher/src/V1/Client/VideoStitcherServiceClient.php +++ b/VideoStitcher/src/V1/Client/VideoStitcherServiceClient.php @@ -24,17 +24,1087 @@ namespace Google\Cloud\Video\Stitcher\V1\Client; -use Google\Cloud\Video\Stitcher\V1\Client\BaseClient\VideoStitcherServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Video\Stitcher\V1\CdnKey; +use Google\Cloud\Video\Stitcher\V1\CreateCdnKeyRequest; +use Google\Cloud\Video\Stitcher\V1\CreateLiveConfigRequest; +use Google\Cloud\Video\Stitcher\V1\CreateLiveSessionRequest; +use Google\Cloud\Video\Stitcher\V1\CreateSlateRequest; +use Google\Cloud\Video\Stitcher\V1\CreateVodSessionRequest; +use Google\Cloud\Video\Stitcher\V1\DeleteCdnKeyRequest; +use Google\Cloud\Video\Stitcher\V1\DeleteLiveConfigRequest; +use Google\Cloud\Video\Stitcher\V1\DeleteSlateRequest; +use Google\Cloud\Video\Stitcher\V1\GetCdnKeyRequest; +use Google\Cloud\Video\Stitcher\V1\GetLiveAdTagDetailRequest; +use Google\Cloud\Video\Stitcher\V1\GetLiveConfigRequest; +use Google\Cloud\Video\Stitcher\V1\GetLiveSessionRequest; +use Google\Cloud\Video\Stitcher\V1\GetSlateRequest; +use Google\Cloud\Video\Stitcher\V1\GetVodAdTagDetailRequest; +use Google\Cloud\Video\Stitcher\V1\GetVodSessionRequest; +use Google\Cloud\Video\Stitcher\V1\GetVodStitchDetailRequest; +use Google\Cloud\Video\Stitcher\V1\ListCdnKeysRequest; +use Google\Cloud\Video\Stitcher\V1\ListLiveAdTagDetailsRequest; +use Google\Cloud\Video\Stitcher\V1\ListLiveConfigsRequest; +use Google\Cloud\Video\Stitcher\V1\ListSlatesRequest; +use Google\Cloud\Video\Stitcher\V1\ListVodAdTagDetailsRequest; +use Google\Cloud\Video\Stitcher\V1\ListVodStitchDetailsRequest; +use Google\Cloud\Video\Stitcher\V1\LiveAdTagDetail; +use Google\Cloud\Video\Stitcher\V1\LiveConfig; +use Google\Cloud\Video\Stitcher\V1\LiveSession; +use Google\Cloud\Video\Stitcher\V1\Slate; +use Google\Cloud\Video\Stitcher\V1\UpdateCdnKeyRequest; +use Google\Cloud\Video\Stitcher\V1\UpdateSlateRequest; +use Google\Cloud\Video\Stitcher\V1\VodAdTagDetail; +use Google\Cloud\Video\Stitcher\V1\VodSession; +use Google\Cloud\Video\Stitcher\V1\VodStitchDetail; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Video-On-Demand content stitching API allows you to insert ads + * into (VoD) video on demand files. You will be able to render custom + * scrubber bars with highlighted ads, enforce ad policies, allow + * seamless playback and tracking on native players and monetize + * content with any standard VMAP compliant ad server. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Video\Stitcher\V1\VideoStitcherServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createCdnKeyAsync(CreateCdnKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface createLiveConfigAsync(CreateLiveConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface createLiveSessionAsync(CreateLiveSessionRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSlateAsync(CreateSlateRequest $request, array $optionalArgs = []) + * @method PromiseInterface createVodSessionAsync(CreateVodSessionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteCdnKeyAsync(DeleteCdnKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteLiveConfigAsync(DeleteLiveConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSlateAsync(DeleteSlateRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCdnKeyAsync(GetCdnKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLiveAdTagDetailAsync(GetLiveAdTagDetailRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLiveConfigAsync(GetLiveConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLiveSessionAsync(GetLiveSessionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSlateAsync(GetSlateRequest $request, array $optionalArgs = []) + * @method PromiseInterface getVodAdTagDetailAsync(GetVodAdTagDetailRequest $request, array $optionalArgs = []) + * @method PromiseInterface getVodSessionAsync(GetVodSessionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getVodStitchDetailAsync(GetVodStitchDetailRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCdnKeysAsync(ListCdnKeysRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLiveAdTagDetailsAsync(ListLiveAdTagDetailsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLiveConfigsAsync(ListLiveConfigsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSlatesAsync(ListSlatesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listVodAdTagDetailsAsync(ListVodAdTagDetailsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listVodStitchDetailsAsync(ListVodStitchDetailsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateCdnKeyAsync(UpdateCdnKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSlateAsync(UpdateSlateRequest $request, array $optionalArgs = []) */ -final class VideoStitcherServiceClient extends VideoStitcherServiceBaseClient +final class VideoStitcherServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see VideoStitcherServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.video.stitcher.v1.VideoStitcherService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'videostitcher.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/video_stitcher_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/video_stitcher_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/video_stitcher_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/video_stitcher_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a cdn_key + * resource. + * + * @param string $project + * @param string $location + * @param string $cdnKey + * + * @return string The formatted cdn_key resource. + */ + public static function cdnKeyName(string $project, string $location, string $cdnKey): string + { + return self::getPathTemplate('cdnKey')->render([ + 'project' => $project, + 'location' => $location, + 'cdn_key' => $cdnKey, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * live_ad_tag_detail resource. + * + * @param string $project + * @param string $location + * @param string $liveSession + * @param string $liveAdTagDetail + * + * @return string The formatted live_ad_tag_detail resource. + */ + public static function liveAdTagDetailName(string $project, string $location, string $liveSession, string $liveAdTagDetail): string + { + return self::getPathTemplate('liveAdTagDetail')->render([ + 'project' => $project, + 'location' => $location, + 'live_session' => $liveSession, + 'live_ad_tag_detail' => $liveAdTagDetail, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a live_config + * resource. + * + * @param string $project + * @param string $location + * @param string $liveConfig + * + * @return string The formatted live_config resource. + */ + public static function liveConfigName(string $project, string $location, string $liveConfig): string + { + return self::getPathTemplate('liveConfig')->render([ + 'project' => $project, + 'location' => $location, + 'live_config' => $liveConfig, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a live_session + * resource. + * + * @param string $project + * @param string $location + * @param string $liveSession + * + * @return string The formatted live_session resource. + */ + public static function liveSessionName(string $project, string $location, string $liveSession): string + { + return self::getPathTemplate('liveSession')->render([ + 'project' => $project, + 'location' => $location, + 'live_session' => $liveSession, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a slate + * resource. + * + * @param string $project + * @param string $location + * @param string $slate + * + * @return string The formatted slate resource. + */ + public static function slateName(string $project, string $location, string $slate): string + { + return self::getPathTemplate('slate')->render([ + 'project' => $project, + 'location' => $location, + 'slate' => $slate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * vod_ad_tag_detail resource. + * + * @param string $project + * @param string $location + * @param string $vodSession + * @param string $vodAdTagDetail + * + * @return string The formatted vod_ad_tag_detail resource. + */ + public static function vodAdTagDetailName(string $project, string $location, string $vodSession, string $vodAdTagDetail): string + { + return self::getPathTemplate('vodAdTagDetail')->render([ + 'project' => $project, + 'location' => $location, + 'vod_session' => $vodSession, + 'vod_ad_tag_detail' => $vodAdTagDetail, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a vod_session + * resource. + * + * @param string $project + * @param string $location + * @param string $vodSession + * + * @return string The formatted vod_session resource. + */ + public static function vodSessionName(string $project, string $location, string $vodSession): string + { + return self::getPathTemplate('vodSession')->render([ + 'project' => $project, + 'location' => $location, + 'vod_session' => $vodSession, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * vod_stitch_detail resource. + * + * @param string $project + * @param string $location + * @param string $vodSession + * @param string $vodStitchDetail + * + * @return string The formatted vod_stitch_detail resource. + */ + public static function vodStitchDetailName(string $project, string $location, string $vodSession, string $vodStitchDetail): string + { + return self::getPathTemplate('vodStitchDetail')->render([ + 'project' => $project, + 'location' => $location, + 'vod_session' => $vodSession, + 'vod_stitch_detail' => $vodStitchDetail, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - cdnKey: projects/{project}/locations/{location}/cdnKeys/{cdn_key} + * - liveAdTagDetail: projects/{project}/locations/{location}/liveSessions/{live_session}/liveAdTagDetails/{live_ad_tag_detail} + * - liveConfig: projects/{project}/locations/{location}/liveConfigs/{live_config} + * - liveSession: projects/{project}/locations/{location}/liveSessions/{live_session} + * - location: projects/{project}/locations/{location} + * - slate: projects/{project}/locations/{location}/slates/{slate} + * - vodAdTagDetail: projects/{project}/locations/{location}/vodSessions/{vod_session}/vodAdTagDetails/{vod_ad_tag_detail} + * - vodSession: projects/{project}/locations/{location}/vodSessions/{vod_session} + * - vodStitchDetail: projects/{project}/locations/{location}/vodSessions/{vod_session}/vodStitchDetails/{vod_stitch_detail} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'videostitcher.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new CDN key. + * + * The async variant is {@see VideoStitcherServiceClient::createCdnKeyAsync()} . + * + * @example samples/V1/VideoStitcherServiceClient/create_cdn_key.php + * + * @param CreateCdnKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCdnKey(CreateCdnKeyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateCdnKey', $request, $callOptions)->wait(); + } + + /** + * Registers the live config with the provided unique ID in + * the specified region. + * + * The async variant is {@see VideoStitcherServiceClient::createLiveConfigAsync()} + * . + * + * @example samples/V1/VideoStitcherServiceClient/create_live_config.php + * + * @param CreateLiveConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createLiveConfig(CreateLiveConfigRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateLiveConfig', $request, $callOptions)->wait(); + } + + /** + * Creates a new live session. + * + * The async variant is {@see VideoStitcherServiceClient::createLiveSessionAsync()} + * . + * + * @example samples/V1/VideoStitcherServiceClient/create_live_session.php + * + * @param CreateLiveSessionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LiveSession + * + * @throws ApiException Thrown if the API call fails. + */ + public function createLiveSession(CreateLiveSessionRequest $request, array $callOptions = []): LiveSession + { + return $this->startApiCall('CreateLiveSession', $request, $callOptions)->wait(); + } + + /** + * Creates a slate. + * + * The async variant is {@see VideoStitcherServiceClient::createSlateAsync()} . + * + * @example samples/V1/VideoStitcherServiceClient/create_slate.php + * + * @param CreateSlateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSlate(CreateSlateRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateSlate', $request, $callOptions)->wait(); + } + + /** + * Creates a client side playback VOD session and returns the full + * tracking and playback metadata of the session. + * + * The async variant is {@see VideoStitcherServiceClient::createVodSessionAsync()} + * . + * + * @example samples/V1/VideoStitcherServiceClient/create_vod_session.php + * + * @param CreateVodSessionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 VodSession + * + * @throws ApiException Thrown if the API call fails. + */ + public function createVodSession(CreateVodSessionRequest $request, array $callOptions = []): VodSession + { + return $this->startApiCall('CreateVodSession', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified CDN key. + * + * The async variant is {@see VideoStitcherServiceClient::deleteCdnKeyAsync()} . + * + * @example samples/V1/VideoStitcherServiceClient/delete_cdn_key.php + * + * @param DeleteCdnKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteCdnKey(DeleteCdnKeyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteCdnKey', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified live config. + * + * The async variant is {@see VideoStitcherServiceClient::deleteLiveConfigAsync()} + * . + * + * @example samples/V1/VideoStitcherServiceClient/delete_live_config.php + * + * @param DeleteLiveConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteLiveConfig(DeleteLiveConfigRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteLiveConfig', $request, $callOptions)->wait(); + } + + /** + * Deletes the specified slate. + * + * The async variant is {@see VideoStitcherServiceClient::deleteSlateAsync()} . + * + * @example samples/V1/VideoStitcherServiceClient/delete_slate.php + * + * @param DeleteSlateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSlate(DeleteSlateRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteSlate', $request, $callOptions)->wait(); + } + + /** + * Returns the specified CDN key. + * + * The async variant is {@see VideoStitcherServiceClient::getCdnKeyAsync()} . + * + * @example samples/V1/VideoStitcherServiceClient/get_cdn_key.php + * + * @param GetCdnKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CdnKey + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCdnKey(GetCdnKeyRequest $request, array $callOptions = []): CdnKey + { + return $this->startApiCall('GetCdnKey', $request, $callOptions)->wait(); + } + + /** + * Returns the specified ad tag detail for the specified live session. + * + * The async variant is + * {@see VideoStitcherServiceClient::getLiveAdTagDetailAsync()} . + * + * @example samples/V1/VideoStitcherServiceClient/get_live_ad_tag_detail.php + * + * @param GetLiveAdTagDetailRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LiveAdTagDetail + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLiveAdTagDetail(GetLiveAdTagDetailRequest $request, array $callOptions = []): LiveAdTagDetail + { + return $this->startApiCall('GetLiveAdTagDetail', $request, $callOptions)->wait(); + } + + /** + * Returns the specified live config managed by the Video + * Stitcher service. + * + * The async variant is {@see VideoStitcherServiceClient::getLiveConfigAsync()} . + * + * @example samples/V1/VideoStitcherServiceClient/get_live_config.php + * + * @param GetLiveConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LiveConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLiveConfig(GetLiveConfigRequest $request, array $callOptions = []): LiveConfig + { + return $this->startApiCall('GetLiveConfig', $request, $callOptions)->wait(); + } + + /** + * Returns the details for the specified live session. + * + * The async variant is {@see VideoStitcherServiceClient::getLiveSessionAsync()} . + * + * @example samples/V1/VideoStitcherServiceClient/get_live_session.php + * + * @param GetLiveSessionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 LiveSession + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLiveSession(GetLiveSessionRequest $request, array $callOptions = []): LiveSession + { + return $this->startApiCall('GetLiveSession', $request, $callOptions)->wait(); + } + + /** + * Returns the specified slate. + * + * The async variant is {@see VideoStitcherServiceClient::getSlateAsync()} . + * + * @example samples/V1/VideoStitcherServiceClient/get_slate.php + * + * @param GetSlateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Slate + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSlate(GetSlateRequest $request, array $callOptions = []): Slate + { + return $this->startApiCall('GetSlate', $request, $callOptions)->wait(); + } + + /** + * Returns the specified ad tag detail for the specified VOD session. + * + * The async variant is {@see VideoStitcherServiceClient::getVodAdTagDetailAsync()} + * . + * + * @example samples/V1/VideoStitcherServiceClient/get_vod_ad_tag_detail.php + * + * @param GetVodAdTagDetailRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 VodAdTagDetail + * + * @throws ApiException Thrown if the API call fails. + */ + public function getVodAdTagDetail(GetVodAdTagDetailRequest $request, array $callOptions = []): VodAdTagDetail + { + return $this->startApiCall('GetVodAdTagDetail', $request, $callOptions)->wait(); + } + + /** + * Returns the full tracking, playback metadata, and relevant ad-ops + * logs for the specified VOD session. + * + * The async variant is {@see VideoStitcherServiceClient::getVodSessionAsync()} . + * + * @example samples/V1/VideoStitcherServiceClient/get_vod_session.php + * + * @param GetVodSessionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 VodSession + * + * @throws ApiException Thrown if the API call fails. + */ + public function getVodSession(GetVodSessionRequest $request, array $callOptions = []): VodSession + { + return $this->startApiCall('GetVodSession', $request, $callOptions)->wait(); + } + + /** + * Returns the specified stitching information for the specified VOD session. + * + * The async variant is + * {@see VideoStitcherServiceClient::getVodStitchDetailAsync()} . + * + * @example samples/V1/VideoStitcherServiceClient/get_vod_stitch_detail.php + * + * @param GetVodStitchDetailRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 VodStitchDetail + * + * @throws ApiException Thrown if the API call fails. + */ + public function getVodStitchDetail(GetVodStitchDetailRequest $request, array $callOptions = []): VodStitchDetail + { + return $this->startApiCall('GetVodStitchDetail', $request, $callOptions)->wait(); + } + + /** + * Lists all CDN keys in the specified project and location. + * + * The async variant is {@see VideoStitcherServiceClient::listCdnKeysAsync()} . + * + * @example samples/V1/VideoStitcherServiceClient/list_cdn_keys.php + * + * @param ListCdnKeysRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCdnKeys(ListCdnKeysRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCdnKeys', $request, $callOptions); + } + + /** + * Return the list of ad tag details for the specified live session. + * + * The async variant is + * {@see VideoStitcherServiceClient::listLiveAdTagDetailsAsync()} . + * + * @example samples/V1/VideoStitcherServiceClient/list_live_ad_tag_details.php + * + * @param ListLiveAdTagDetailsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLiveAdTagDetails(ListLiveAdTagDetailsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLiveAdTagDetails', $request, $callOptions); + } + + /** + * Lists all live configs managed by the Video Stitcher that + * belong to the specified project and region. + * + * The async variant is {@see VideoStitcherServiceClient::listLiveConfigsAsync()} . + * + * @example samples/V1/VideoStitcherServiceClient/list_live_configs.php + * + * @param ListLiveConfigsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLiveConfigs(ListLiveConfigsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLiveConfigs', $request, $callOptions); + } + + /** + * Lists all slates in the specified project and location. + * + * The async variant is {@see VideoStitcherServiceClient::listSlatesAsync()} . + * + * @example samples/V1/VideoStitcherServiceClient/list_slates.php + * + * @param ListSlatesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSlates(ListSlatesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSlates', $request, $callOptions); + } + + /** + * Return the list of ad tag details for the specified VOD session. + * + * The async variant is + * {@see VideoStitcherServiceClient::listVodAdTagDetailsAsync()} . + * + * @example samples/V1/VideoStitcherServiceClient/list_vod_ad_tag_details.php + * + * @param ListVodAdTagDetailsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listVodAdTagDetails(ListVodAdTagDetailsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListVodAdTagDetails', $request, $callOptions); + } + + /** + * Returns a list of detailed stitching information of the specified VOD + * session. + * + * The async variant is + * {@see VideoStitcherServiceClient::listVodStitchDetailsAsync()} . + * + * @example samples/V1/VideoStitcherServiceClient/list_vod_stitch_details.php + * + * @param ListVodStitchDetailsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listVodStitchDetails(ListVodStitchDetailsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListVodStitchDetails', $request, $callOptions); + } + + /** + * Updates the specified CDN key. Only update fields specified + * in the call method body. + * + * The async variant is {@see VideoStitcherServiceClient::updateCdnKeyAsync()} . + * + * @example samples/V1/VideoStitcherServiceClient/update_cdn_key.php + * + * @param UpdateCdnKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCdnKey(UpdateCdnKeyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateCdnKey', $request, $callOptions)->wait(); + } + + /** + * Updates the specified slate. + * + * The async variant is {@see VideoStitcherServiceClient::updateSlateAsync()} . + * + * @example samples/V1/VideoStitcherServiceClient/update_slate.php + * + * @param UpdateSlateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSlate(UpdateSlateRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateSlate', $request, $callOptions)->wait(); + } } diff --git a/VideoTranscoder/composer.json b/VideoTranscoder/composer.json index f976daed5e17..88ea04e6fb57 100644 --- a/VideoTranscoder/composer.json +++ b/VideoTranscoder/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/VideoTranscoder/src/V1/Client/BaseClient/TranscoderServiceBaseClient.php b/VideoTranscoder/src/V1/Client/BaseClient/TranscoderServiceBaseClient.php deleted file mode 100644 index 341d47df0f24..000000000000 --- a/VideoTranscoder/src/V1/Client/BaseClient/TranscoderServiceBaseClient.php +++ /dev/null @@ -1,477 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/transcoder_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/transcoder_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/transcoder_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/transcoder_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a job - * resource. - * - * @param string $project - * @param string $location - * @param string $job - * - * @return string The formatted job resource. - */ - public static function jobName(string $project, string $location, string $job): string - { - return self::getPathTemplate('job')->render([ - 'project' => $project, - 'location' => $location, - 'job' => $job, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a job_template - * resource. - * - * @param string $project - * @param string $location - * @param string $jobTemplate - * - * @return string The formatted job_template resource. - */ - public static function jobTemplateName(string $project, string $location, string $jobTemplate): string - { - return self::getPathTemplate('jobTemplate')->render([ - 'project' => $project, - 'location' => $location, - 'job_template' => $jobTemplate, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - job: projects/{project}/locations/{location}/jobs/{job} - * - jobTemplate: projects/{project}/locations/{location}/jobTemplates/{job_template} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'transcoder.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a job in the specified region. - * - * The async variant is {@see self::createJobAsync()} . - * - * @example samples/V1/TranscoderServiceClient/create_job.php - * - * @param CreateJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - */ - public function createJob(CreateJobRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('CreateJob', $request, $callOptions)->wait(); - } - - /** - * Creates a job template in the specified region. - * - * The async variant is {@see self::createJobTemplateAsync()} . - * - * @example samples/V1/TranscoderServiceClient/create_job_template.php - * - * @param CreateJobTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 JobTemplate - * - * @throws ApiException Thrown if the API call fails. - */ - public function createJobTemplate(CreateJobTemplateRequest $request, array $callOptions = []): JobTemplate - { - return $this->startApiCall('CreateJobTemplate', $request, $callOptions)->wait(); - } - - /** - * Deletes a job. - * - * The async variant is {@see self::deleteJobAsync()} . - * - * @example samples/V1/TranscoderServiceClient/delete_job.php - * - * @param DeleteJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteJob(DeleteJobRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteJob', $request, $callOptions)->wait(); - } - - /** - * Deletes a job template. - * - * The async variant is {@see self::deleteJobTemplateAsync()} . - * - * @example samples/V1/TranscoderServiceClient/delete_job_template.php - * - * @param DeleteJobTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteJobTemplate(DeleteJobTemplateRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteJobTemplate', $request, $callOptions)->wait(); - } - - /** - * Returns the job data. - * - * The async variant is {@see self::getJobAsync()} . - * - * @example samples/V1/TranscoderServiceClient/get_job.php - * - * @param GetJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Job - * - * @throws ApiException Thrown if the API call fails. - */ - public function getJob(GetJobRequest $request, array $callOptions = []): Job - { - return $this->startApiCall('GetJob', $request, $callOptions)->wait(); - } - - /** - * Returns the job template data. - * - * The async variant is {@see self::getJobTemplateAsync()} . - * - * @example samples/V1/TranscoderServiceClient/get_job_template.php - * - * @param GetJobTemplateRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 JobTemplate - * - * @throws ApiException Thrown if the API call fails. - */ - public function getJobTemplate(GetJobTemplateRequest $request, array $callOptions = []): JobTemplate - { - return $this->startApiCall('GetJobTemplate', $request, $callOptions)->wait(); - } - - /** - * Lists job templates in the specified region. - * - * The async variant is {@see self::listJobTemplatesAsync()} . - * - * @example samples/V1/TranscoderServiceClient/list_job_templates.php - * - * @param ListJobTemplatesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listJobTemplates(ListJobTemplatesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListJobTemplates', $request, $callOptions); - } - - /** - * Lists jobs in the specified region. - * - * The async variant is {@see self::listJobsAsync()} . - * - * @example samples/V1/TranscoderServiceClient/list_jobs.php - * - * @param ListJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listJobs(ListJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListJobs', $request, $callOptions); - } -} diff --git a/VideoTranscoder/src/V1/Client/TranscoderServiceClient.php b/VideoTranscoder/src/V1/Client/TranscoderServiceClient.php index 5052e44f31e2..acd91b32ee85 100644 --- a/VideoTranscoder/src/V1/Client/TranscoderServiceClient.php +++ b/VideoTranscoder/src/V1/Client/TranscoderServiceClient.php @@ -24,17 +24,452 @@ namespace Google\Cloud\Video\Transcoder\V1\Client; -use Google\Cloud\Video\Transcoder\V1\Client\BaseClient\TranscoderServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Video\Transcoder\V1\CreateJobRequest; +use Google\Cloud\Video\Transcoder\V1\CreateJobTemplateRequest; +use Google\Cloud\Video\Transcoder\V1\DeleteJobRequest; +use Google\Cloud\Video\Transcoder\V1\DeleteJobTemplateRequest; +use Google\Cloud\Video\Transcoder\V1\GetJobRequest; +use Google\Cloud\Video\Transcoder\V1\GetJobTemplateRequest; +use Google\Cloud\Video\Transcoder\V1\Job; +use Google\Cloud\Video\Transcoder\V1\JobTemplate; +use Google\Cloud\Video\Transcoder\V1\ListJobTemplatesRequest; +use Google\Cloud\Video\Transcoder\V1\ListJobsRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Using the Transcoder API, you can queue asynchronous jobs for transcoding + * media into various output formats. Output formats may include different + * streaming standards such as HTTP Live Streaming (HLS) and Dynamic Adaptive + * Streaming over HTTP (DASH). You can also customize jobs using advanced + * features such as Digital Rights Management (DRM), audio equalization, content + * concatenation, and digital ad-stitch ready content generation. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Video\Transcoder\V1\TranscoderServiceClient} for the stable + * implementation * * @experimental + * + * @method PromiseInterface createJobAsync(CreateJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface createJobTemplateAsync(CreateJobTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteJobAsync(DeleteJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteJobTemplateAsync(DeleteJobTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface getJobAsync(GetJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getJobTemplateAsync(GetJobTemplateRequest $request, array $optionalArgs = []) + * @method PromiseInterface listJobTemplatesAsync(ListJobTemplatesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listJobsAsync(ListJobsRequest $request, array $optionalArgs = []) */ -final class TranscoderServiceClient extends TranscoderServiceBaseClient +final class TranscoderServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see TranscoderServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.video.transcoder.v1.TranscoderService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'transcoder.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/transcoder_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/transcoder_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/transcoder_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/transcoder_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a job + * resource. + * + * @param string $project + * @param string $location + * @param string $job + * + * @return string The formatted job resource. + */ + public static function jobName(string $project, string $location, string $job): string + { + return self::getPathTemplate('job')->render([ + 'project' => $project, + 'location' => $location, + 'job' => $job, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a job_template + * resource. + * + * @param string $project + * @param string $location + * @param string $jobTemplate + * + * @return string The formatted job_template resource. + */ + public static function jobTemplateName(string $project, string $location, string $jobTemplate): string + { + return self::getPathTemplate('jobTemplate')->render([ + 'project' => $project, + 'location' => $location, + 'job_template' => $jobTemplate, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - job: projects/{project}/locations/{location}/jobs/{job} + * - jobTemplate: projects/{project}/locations/{location}/jobTemplates/{job_template} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'transcoder.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a job in the specified region. + * + * The async variant is {@see TranscoderServiceClient::createJobAsync()} . + * + * @example samples/V1/TranscoderServiceClient/create_job.php + * + * @param CreateJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + */ + public function createJob(CreateJobRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('CreateJob', $request, $callOptions)->wait(); + } + + /** + * Creates a job template in the specified region. + * + * The async variant is {@see TranscoderServiceClient::createJobTemplateAsync()} . + * + * @example samples/V1/TranscoderServiceClient/create_job_template.php + * + * @param CreateJobTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 JobTemplate + * + * @throws ApiException Thrown if the API call fails. + */ + public function createJobTemplate(CreateJobTemplateRequest $request, array $callOptions = []): JobTemplate + { + return $this->startApiCall('CreateJobTemplate', $request, $callOptions)->wait(); + } + + /** + * Deletes a job. + * + * The async variant is {@see TranscoderServiceClient::deleteJobAsync()} . + * + * @example samples/V1/TranscoderServiceClient/delete_job.php + * + * @param DeleteJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteJob(DeleteJobRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteJob', $request, $callOptions)->wait(); + } + + /** + * Deletes a job template. + * + * The async variant is {@see TranscoderServiceClient::deleteJobTemplateAsync()} . + * + * @example samples/V1/TranscoderServiceClient/delete_job_template.php + * + * @param DeleteJobTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteJobTemplate(DeleteJobTemplateRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteJobTemplate', $request, $callOptions)->wait(); + } + + /** + * Returns the job data. + * + * The async variant is {@see TranscoderServiceClient::getJobAsync()} . + * + * @example samples/V1/TranscoderServiceClient/get_job.php + * + * @param GetJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Job + * + * @throws ApiException Thrown if the API call fails. + */ + public function getJob(GetJobRequest $request, array $callOptions = []): Job + { + return $this->startApiCall('GetJob', $request, $callOptions)->wait(); + } + + /** + * Returns the job template data. + * + * The async variant is {@see TranscoderServiceClient::getJobTemplateAsync()} . + * + * @example samples/V1/TranscoderServiceClient/get_job_template.php + * + * @param GetJobTemplateRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 JobTemplate + * + * @throws ApiException Thrown if the API call fails. + */ + public function getJobTemplate(GetJobTemplateRequest $request, array $callOptions = []): JobTemplate + { + return $this->startApiCall('GetJobTemplate', $request, $callOptions)->wait(); + } + + /** + * Lists job templates in the specified region. + * + * The async variant is {@see TranscoderServiceClient::listJobTemplatesAsync()} . + * + * @example samples/V1/TranscoderServiceClient/list_job_templates.php + * + * @param ListJobTemplatesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listJobTemplates(ListJobTemplatesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListJobTemplates', $request, $callOptions); + } + + /** + * Lists jobs in the specified region. + * + * The async variant is {@see TranscoderServiceClient::listJobsAsync()} . + * + * @example samples/V1/TranscoderServiceClient/list_jobs.php + * + * @param ListJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listJobs(ListJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListJobs', $request, $callOptions); + } } diff --git a/Vision/composer.json b/Vision/composer.json index 3fcfd5c6b3ed..4b7e3ef831ce 100644 --- a/Vision/composer.json +++ b/Vision/composer.json @@ -5,8 +5,8 @@ "minimum-stability": "stable", "require": { "php": ">=7.4", - "google/cloud-core": "^1.43", - "google/gax": "^1.19.1" + "google/cloud-core": "^1.52.7", + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0", diff --git a/Vision/src/V1/Client/BaseClient/ImageAnnotatorBaseClient.php b/Vision/src/V1/Client/BaseClient/ImageAnnotatorBaseClient.php deleted file mode 100644 index bc4a86dd02e5..000000000000 --- a/Vision/src/V1/Client/BaseClient/ImageAnnotatorBaseClient.php +++ /dev/null @@ -1,377 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/image_annotator_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/image_annotator_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/image_annotator_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/image_annotator_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a product_set - * resource. - * - * @param string $project - * @param string $location - * @param string $productSet - * - * @return string The formatted product_set resource. - */ - public static function productSetName(string $project, string $location, string $productSet): string - { - return self::getPathTemplate('productSet')->render([ - 'project' => $project, - 'location' => $location, - 'product_set' => $productSet, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - productSet: projects/{project}/locations/{location}/productSets/{product_set} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'vision.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Run asynchronous image detection and annotation for a list of generic - * files, such as PDF files, which may contain multiple pages and multiple - * images per page. Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). - * - * The async variant is {@see self::asyncBatchAnnotateFilesAsync()} . - * - * @param AsyncBatchAnnotateFilesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function asyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AsyncBatchAnnotateFiles', $request, $callOptions)->wait(); - } - - /** - * Run asynchronous image detection and annotation for a list of images. - * - * Progress and results can be retrieved through the - * `google.longrunning.Operations` interface. - * `Operation.metadata` contains `OperationMetadata` (metadata). - * `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). - * - * This service will write image annotation outputs to json files in customer - * GCS bucket, each json file containing BatchAnnotateImagesResponse proto. - * - * The async variant is {@see self::asyncBatchAnnotateImagesAsync()} . - * - * @param AsyncBatchAnnotateImagesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function asyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AsyncBatchAnnotateImages', $request, $callOptions)->wait(); - } - - /** - * Service that performs image detection and annotation for a batch of files. - * Now only "application/pdf", "image/tiff" and "image/gif" are supported. - * - * This service will extract at most 5 (customers can specify which 5 in - * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each - * file provided and perform detection and annotation for each image - * extracted. - * - * The async variant is {@see self::batchAnnotateFilesAsync()} . - * - * @param BatchAnnotateFilesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BatchAnnotateFilesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchAnnotateFiles(BatchAnnotateFilesRequest $request, array $callOptions = []): BatchAnnotateFilesResponse - { - return $this->startApiCall('BatchAnnotateFiles', $request, $callOptions)->wait(); - } - - /** - * Run image detection and annotation for a batch of images. - * - * The async variant is {@see self::batchAnnotateImagesAsync()} . - * - * @param BatchAnnotateImagesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 BatchAnnotateImagesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function batchAnnotateImages(BatchAnnotateImagesRequest $request, array $callOptions = []): BatchAnnotateImagesResponse - { - return $this->startApiCall('BatchAnnotateImages', $request, $callOptions)->wait(); - } -} diff --git a/Vision/src/V1/Client/BaseClient/ProductSearchBaseClient.php b/Vision/src/V1/Client/BaseClient/ProductSearchBaseClient.php deleted file mode 100644 index 5a56f5067c19..000000000000 --- a/Vision/src/V1/Client/BaseClient/ProductSearchBaseClient.php +++ /dev/null @@ -1,946 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/product_search_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/product_search_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/product_search_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/product_search_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a product - * resource. - * - * @param string $project - * @param string $location - * @param string $product - * - * @return string The formatted product resource. - */ - public static function productName(string $project, string $location, string $product): string - { - return self::getPathTemplate('product')->render([ - 'project' => $project, - 'location' => $location, - 'product' => $product, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a product_set - * resource. - * - * @param string $project - * @param string $location - * @param string $productSet - * - * @return string The formatted product_set resource. - */ - public static function productSetName(string $project, string $location, string $productSet): string - { - return self::getPathTemplate('productSet')->render([ - 'project' => $project, - 'location' => $location, - 'product_set' => $productSet, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * reference_image resource. - * - * @param string $project - * @param string $location - * @param string $product - * @param string $referenceImage - * - * @return string The formatted reference_image resource. - */ - public static function referenceImageName(string $project, string $location, string $product, string $referenceImage): string - { - return self::getPathTemplate('referenceImage')->render([ - 'project' => $project, - 'location' => $location, - 'product' => $product, - 'reference_image' => $referenceImage, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - location: projects/{project}/locations/{location} - * - product: projects/{project}/locations/{location}/products/{product} - * - productSet: projects/{project}/locations/{location}/productSets/{product_set} - * - referenceImage: projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'vision.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Adds a Product to the specified ProductSet. If the Product is already - * present, no change is made. - * - * One Product can be added to at most 100 ProductSets. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. - * - * The async variant is {@see self::addProductToProductSetAsync()} . - * - * @param AddProductToProductSetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function addProductToProductSet(AddProductToProductSetRequest $request, array $callOptions = []): void - { - $this->startApiCall('AddProductToProductSet', $request, $callOptions)->wait(); - } - - /** - * Creates and returns a new product resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is missing or invalid. - * - * The async variant is {@see self::createProductAsync()} . - * - * @param CreateProductRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Product - * - * @throws ApiException Thrown if the API call fails. - */ - public function createProduct(CreateProductRequest $request, array $callOptions = []): Product - { - return $this->startApiCall('CreateProduct', $request, $callOptions)->wait(); - } - - /** - * Creates and returns a new ProductSet resource. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than - * 4096 characters. - * - * The async variant is {@see self::createProductSetAsync()} . - * - * @param CreateProductSetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ProductSet - * - * @throws ApiException Thrown if the API call fails. - */ - public function createProductSet(CreateProductSetRequest $request, array $callOptions = []): ProductSet - { - return $this->startApiCall('CreateProductSet', $request, $callOptions)->wait(); - } - - /** - * Creates and returns a new ReferenceImage resource. - * - * The `bounding_poly` field is optional. If `bounding_poly` is not specified, - * the system will try to detect regions of interest in the image that are - * compatible with the product_category on the parent product. If it is - * specified, detection is ALWAYS skipped. The system converts polygons into - * non-rotated rectangles. - * - * Note that the pipeline will resize the image if the image resolution is too - * large to process (above 50MP). - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 - * characters. - * * Returns INVALID_ARGUMENT if the product does not exist. - * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing - * compatible with the parent product's product_category is detected. - * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. - * - * The async variant is {@see self::createReferenceImageAsync()} . - * - * @param CreateReferenceImageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ReferenceImage - * - * @throws ApiException Thrown if the API call fails. - */ - public function createReferenceImage(CreateReferenceImageRequest $request, array $callOptions = []): ReferenceImage - { - return $this->startApiCall('CreateReferenceImage', $request, $callOptions)->wait(); - } - - /** - * Permanently deletes a product and its reference images. - * - * Metadata of the product and all its images will be deleted right away, but - * search queries against ProductSets containing the product may still work - * until all related caches are refreshed. - * - * The async variant is {@see self::deleteProductAsync()} . - * - * @param DeleteProductRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteProduct(DeleteProductRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteProduct', $request, $callOptions)->wait(); - } - - /** - * Permanently deletes a ProductSet. Products and ReferenceImages in the - * ProductSet are not deleted. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * The async variant is {@see self::deleteProductSetAsync()} . - * - * @param DeleteProductSetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteProductSet(DeleteProductSetRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteProductSet', $request, $callOptions)->wait(); - } - - /** - * Permanently deletes a reference image. - * - * The image metadata will be deleted right away, but search queries - * against ProductSets containing the image may still work until all related - * caches are refreshed. - * - * The actual image files are not deleted from Google Cloud Storage. - * - * The async variant is {@see self::deleteReferenceImageAsync()} . - * - * @param DeleteReferenceImageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteReferenceImage(DeleteReferenceImageRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteReferenceImage', $request, $callOptions)->wait(); - } - - /** - * Gets information associated with a Product. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * - * The async variant is {@see self::getProductAsync()} . - * - * @param GetProductRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Product - * - * @throws ApiException Thrown if the API call fails. - */ - public function getProduct(GetProductRequest $request, array $callOptions = []): Product - { - return $this->startApiCall('GetProduct', $request, $callOptions)->wait(); - } - - /** - * Gets information associated with a ProductSet. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * - * The async variant is {@see self::getProductSetAsync()} . - * - * @param GetProductSetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ProductSet - * - * @throws ApiException Thrown if the API call fails. - */ - public function getProductSet(GetProductSetRequest $request, array $callOptions = []): ProductSet - { - return $this->startApiCall('GetProductSet', $request, $callOptions)->wait(); - } - - /** - * Gets information associated with a ReferenceImage. - * - * Possible errors: - * - * * Returns NOT_FOUND if the specified image does not exist. - * - * The async variant is {@see self::getReferenceImageAsync()} . - * - * @param GetReferenceImageRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ReferenceImage - * - * @throws ApiException Thrown if the API call fails. - */ - public function getReferenceImage(GetReferenceImageRequest $request, array $callOptions = []): ReferenceImage - { - return $this->startApiCall('GetReferenceImage', $request, $callOptions)->wait(); - } - - /** - * Asynchronous API that imports a list of reference images to specified - * product sets based on a list of image information. - * - * The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the - * progress and results of the request. - * `Operation.metadata` contains `BatchOperationMetadata`. (progress) - * `Operation.response` contains `ImportProductSetsResponse`. (results) - * - * The input source of this method is a csv file on Google Cloud Storage. - * For the format of the csv file please see - * [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri]. - * - * The async variant is {@see self::importProductSetsAsync()} . - * - * @param ImportProductSetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function importProductSets(ImportProductSetsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ImportProductSets', $request, $callOptions)->wait(); - } - - /** - * Lists ProductSets in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less - * than 1. - * - * The async variant is {@see self::listProductSetsAsync()} . - * - * @param ListProductSetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listProductSets(ListProductSetsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListProductSets', $request, $callOptions); - } - - /** - * Lists products in an unspecified order. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * The async variant is {@see self::listProductsAsync()} . - * - * @param ListProductsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listProducts(ListProductsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListProducts', $request, $callOptions); - } - - /** - * Lists the Products in a ProductSet, in an unspecified order. If the - * ProductSet does not exist, the products field of the response will be - * empty. - * - * Possible errors: - * - * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. - * - * The async variant is {@see self::listProductsInProductSetAsync()} . - * - * @param ListProductsInProductSetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listProductsInProductSet(ListProductsInProductSetRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListProductsInProductSet', $request, $callOptions); - } - - /** - * Lists reference images. - * - * Possible errors: - * - * * Returns NOT_FOUND if the parent product does not exist. - * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less - * than 1. - * - * The async variant is {@see self::listReferenceImagesAsync()} . - * - * @param ListReferenceImagesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listReferenceImages(ListReferenceImagesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListReferenceImages', $request, $callOptions); - } - - /** - * Asynchronous API to delete all Products in a ProductSet or all Products - * that are in no ProductSet. - * - * If a Product is a member of the specified ProductSet in addition to other - * ProductSets, the Product will still be deleted. - * - * It is recommended to not delete the specified ProductSet until after this - * operation has completed. It is also recommended to not add any of the - * Products involved in the batch delete to a new ProductSet while this - * operation is running because those Products may still end up deleted. - * - * It's not possible to undo the PurgeProducts operation. Therefore, it is - * recommended to keep the csv files used in ImportProductSets (if that was - * how you originally built the Product Set) before starting PurgeProducts, in - * case you need to re-import the data after deletion. - * - * If the plan is to purge all of the Products from a ProductSet and then - * re-use the empty ProductSet to re-import new Products into the empty - * ProductSet, you must wait until the PurgeProducts operation has finished - * for that ProductSet. - * - * The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the - * progress and results of the request. - * `Operation.metadata` contains `BatchOperationMetadata`. (progress) - * - * The async variant is {@see self::purgeProductsAsync()} . - * - * @param PurgeProductsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function purgeProducts(PurgeProductsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('PurgeProducts', $request, $callOptions)->wait(); - } - - /** - * Removes a Product from the specified ProductSet. - * - * The async variant is {@see self::removeProductFromProductSetAsync()} . - * - * @param RemoveProductFromProductSetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function removeProductFromProductSet(RemoveProductFromProductSetRequest $request, array $callOptions = []): void - { - $this->startApiCall('RemoveProductFromProductSet', $request, $callOptions)->wait(); - } - - /** - * Makes changes to a Product resource. - * Only the `display_name`, `description`, and `labels` fields can be updated - * right now. - * - * If labels are updated, the change will not be reflected in queries until - * the next index time. - * - * Possible errors: - * - * * Returns NOT_FOUND if the Product does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is - * missing from the request or longer than 4096 characters. - * * Returns INVALID_ARGUMENT if description is present in update_mask but is - * longer than 4096 characters. - * * Returns INVALID_ARGUMENT if product_category is present in update_mask. - * - * The async variant is {@see self::updateProductAsync()} . - * - * @param UpdateProductRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Product - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateProduct(UpdateProductRequest $request, array $callOptions = []): Product - { - return $this->startApiCall('UpdateProduct', $request, $callOptions)->wait(); - } - - /** - * Makes changes to a ProductSet resource. - * Only display_name can be updated currently. - * - * Possible errors: - * - * * Returns NOT_FOUND if the ProductSet does not exist. - * * Returns INVALID_ARGUMENT if display_name is present in update_mask but - * missing from the request or longer than 4096 characters. - * - * The async variant is {@see self::updateProductSetAsync()} . - * - * @param UpdateProductSetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ProductSet - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateProductSet(UpdateProductSetRequest $request, array $callOptions = []): ProductSet - { - return $this->startApiCall('UpdateProductSet', $request, $callOptions)->wait(); - } -} diff --git a/Vision/src/V1/Client/ImageAnnotatorClient.php b/Vision/src/V1/Client/ImageAnnotatorClient.php index 1f37298a8baa..4d3409bf69b3 100644 --- a/Vision/src/V1/Client/ImageAnnotatorClient.php +++ b/Vision/src/V1/Client/ImageAnnotatorClient.php @@ -24,17 +24,354 @@ namespace Google\Cloud\Vision\V1\Client; -use Google\Cloud\Vision\V1\Client\BaseClient\ImageAnnotatorBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Vision\V1\AnnotateFileRequest; +use Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest; +use Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesResponse; +use Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest; +use Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesResponse; +use Google\Cloud\Vision\V1\BatchAnnotateFilesRequest; +use Google\Cloud\Vision\V1\BatchAnnotateFilesResponse; +use Google\Cloud\Vision\V1\BatchAnnotateImagesRequest; +use Google\Cloud\Vision\V1\BatchAnnotateImagesResponse; +use Google\Cloud\Vision\V1\OperationMetadata; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Service that performs Google Cloud Vision API detection tasks over client + * images, such as face, landmark, logo, label, and text detection. The + * ImageAnnotator service returns detected entities from the images. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Vision\V1\ImageAnnotatorClient} for the stable implementation * * @experimental + * + * @method PromiseInterface asyncBatchAnnotateFilesAsync(AsyncBatchAnnotateFilesRequest $request, array $optionalArgs = []) + * @method PromiseInterface asyncBatchAnnotateImagesAsync(AsyncBatchAnnotateImagesRequest $request, array $optionalArgs = []) + * @method PromiseInterface batchAnnotateFilesAsync(BatchAnnotateFilesRequest $request, array $optionalArgs = []) + * @method PromiseInterface batchAnnotateImagesAsync(BatchAnnotateImagesRequest $request, array $optionalArgs = []) */ -final class ImageAnnotatorClient extends ImageAnnotatorBaseClient +final class ImageAnnotatorClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ImageAnnotatorBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.vision.v1.ImageAnnotator'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'vision.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-vision', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/image_annotator_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/image_annotator_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/image_annotator_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/image_annotator_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a product_set + * resource. + * + * @param string $project + * @param string $location + * @param string $productSet + * + * @return string The formatted product_set resource. + */ + public static function productSetName(string $project, string $location, string $productSet): string + { + return self::getPathTemplate('productSet')->render([ + 'project' => $project, + 'location' => $location, + 'product_set' => $productSet, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - productSet: projects/{project}/locations/{location}/productSets/{product_set} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'vision.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Run asynchronous image detection and annotation for a list of generic + * files, such as PDF files, which may contain multiple pages and multiple + * images per page. Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + * + * The async variant is {@see ImageAnnotatorClient::asyncBatchAnnotateFilesAsync()} + * . + * + * @param AsyncBatchAnnotateFilesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function asyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AsyncBatchAnnotateFiles', $request, $callOptions)->wait(); + } + + /** + * Run asynchronous image detection and annotation for a list of images. + * + * Progress and results can be retrieved through the + * `google.longrunning.Operations` interface. + * `Operation.metadata` contains `OperationMetadata` (metadata). + * `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). + * + * This service will write image annotation outputs to json files in customer + * GCS bucket, each json file containing BatchAnnotateImagesResponse proto. + * + * The async variant is + * {@see ImageAnnotatorClient::asyncBatchAnnotateImagesAsync()} . + * + * @param AsyncBatchAnnotateImagesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function asyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AsyncBatchAnnotateImages', $request, $callOptions)->wait(); + } + + /** + * Service that performs image detection and annotation for a batch of files. + * Now only "application/pdf", "image/tiff" and "image/gif" are supported. + * + * This service will extract at most 5 (customers can specify which 5 in + * AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each + * file provided and perform detection and annotation for each image + * extracted. + * + * The async variant is {@see ImageAnnotatorClient::batchAnnotateFilesAsync()} . + * + * @param BatchAnnotateFilesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BatchAnnotateFilesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchAnnotateFiles(BatchAnnotateFilesRequest $request, array $callOptions = []): BatchAnnotateFilesResponse + { + return $this->startApiCall('BatchAnnotateFiles', $request, $callOptions)->wait(); + } + + /** + * Run image detection and annotation for a batch of images. + * + * The async variant is {@see ImageAnnotatorClient::batchAnnotateImagesAsync()} . + * + * @param BatchAnnotateImagesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 BatchAnnotateImagesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function batchAnnotateImages(BatchAnnotateImagesRequest $request, array $callOptions = []): BatchAnnotateImagesResponse + { + return $this->startApiCall('BatchAnnotateImages', $request, $callOptions)->wait(); + } } diff --git a/Vision/src/V1/Client/ProductSearchClient.php b/Vision/src/V1/Client/ProductSearchClient.php index 4f43f23dd301..15cb24910481 100644 --- a/Vision/src/V1/Client/ProductSearchClient.php +++ b/Vision/src/V1/Client/ProductSearchClient.php @@ -24,17 +24,923 @@ namespace Google\Cloud\Vision\V1\Client; -use Google\Cloud\Vision\V1\Client\BaseClient\ProductSearchBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Vision\V1\AddProductToProductSetRequest; +use Google\Cloud\Vision\V1\BatchOperationMetadata; +use Google\Cloud\Vision\V1\CreateProductRequest; +use Google\Cloud\Vision\V1\CreateProductSetRequest; +use Google\Cloud\Vision\V1\CreateReferenceImageRequest; +use Google\Cloud\Vision\V1\DeleteProductRequest; +use Google\Cloud\Vision\V1\DeleteProductSetRequest; +use Google\Cloud\Vision\V1\DeleteReferenceImageRequest; +use Google\Cloud\Vision\V1\GetProductRequest; +use Google\Cloud\Vision\V1\GetProductSetRequest; +use Google\Cloud\Vision\V1\GetReferenceImageRequest; +use Google\Cloud\Vision\V1\ImportProductSetsRequest; +use Google\Cloud\Vision\V1\ImportProductSetsResponse; +use Google\Cloud\Vision\V1\ListProductSetsRequest; +use Google\Cloud\Vision\V1\ListProductsInProductSetRequest; +use Google\Cloud\Vision\V1\ListProductsRequest; +use Google\Cloud\Vision\V1\ListReferenceImagesRequest; +use Google\Cloud\Vision\V1\Product; +use Google\Cloud\Vision\V1\ProductSet; +use Google\Cloud\Vision\V1\PurgeProductsRequest; +use Google\Cloud\Vision\V1\ReferenceImage; +use Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest; +use Google\Cloud\Vision\V1\UpdateProductRequest; +use Google\Cloud\Vision\V1\UpdateProductSetRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Manages Products and ProductSets of reference images for use in product + * search. It uses the following resource model: * - * This class is currently experimental and may be subject to changes. + * - The API has a collection of [ProductSet][google.cloud.vision.v1.ProductSet] resources, named + * `projects/*/locations/*/productSets/*`, which acts as a way to put different + * products into groups to limit identification. + * + * In parallel, + * + * - The API has a collection of [Product][google.cloud.vision.v1.Product] resources, named + * `projects/*/locations/*/products/*` + * + * - Each [Product][google.cloud.vision.v1.Product] has a collection of [ReferenceImage][google.cloud.vision.v1.ReferenceImage] resources, named + * `projects/*/locations/*/products/*/referenceImages/*` + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\Vision\V1\ProductSearchClient} for the stable implementation * * @experimental + * + * @method PromiseInterface addProductToProductSetAsync(AddProductToProductSetRequest $request, array $optionalArgs = []) + * @method PromiseInterface createProductAsync(CreateProductRequest $request, array $optionalArgs = []) + * @method PromiseInterface createProductSetAsync(CreateProductSetRequest $request, array $optionalArgs = []) + * @method PromiseInterface createReferenceImageAsync(CreateReferenceImageRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteProductAsync(DeleteProductRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteProductSetAsync(DeleteProductSetRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteReferenceImageAsync(DeleteReferenceImageRequest $request, array $optionalArgs = []) + * @method PromiseInterface getProductAsync(GetProductRequest $request, array $optionalArgs = []) + * @method PromiseInterface getProductSetAsync(GetProductSetRequest $request, array $optionalArgs = []) + * @method PromiseInterface getReferenceImageAsync(GetReferenceImageRequest $request, array $optionalArgs = []) + * @method PromiseInterface importProductSetsAsync(ImportProductSetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listProductSetsAsync(ListProductSetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listProductsAsync(ListProductsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listProductsInProductSetAsync(ListProductsInProductSetRequest $request, array $optionalArgs = []) + * @method PromiseInterface listReferenceImagesAsync(ListReferenceImagesRequest $request, array $optionalArgs = []) + * @method PromiseInterface purgeProductsAsync(PurgeProductsRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeProductFromProductSetAsync(RemoveProductFromProductSetRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateProductAsync(UpdateProductRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateProductSetAsync(UpdateProductSetRequest $request, array $optionalArgs = []) */ -final class ProductSearchClient extends ProductSearchBaseClient +final class ProductSearchClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ProductSearchBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.vision.v1.ProductSearch'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'vision.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-vision', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/product_search_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/product_search_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/product_search_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/product_search_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a product + * resource. + * + * @param string $project + * @param string $location + * @param string $product + * + * @return string The formatted product resource. + */ + public static function productName(string $project, string $location, string $product): string + { + return self::getPathTemplate('product')->render([ + 'project' => $project, + 'location' => $location, + 'product' => $product, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a product_set + * resource. + * + * @param string $project + * @param string $location + * @param string $productSet + * + * @return string The formatted product_set resource. + */ + public static function productSetName(string $project, string $location, string $productSet): string + { + return self::getPathTemplate('productSet')->render([ + 'project' => $project, + 'location' => $location, + 'product_set' => $productSet, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * reference_image resource. + * + * @param string $project + * @param string $location + * @param string $product + * @param string $referenceImage + * + * @return string The formatted reference_image resource. + */ + public static function referenceImageName(string $project, string $location, string $product, string $referenceImage): string + { + return self::getPathTemplate('referenceImage')->render([ + 'project' => $project, + 'location' => $location, + 'product' => $product, + 'reference_image' => $referenceImage, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - location: projects/{project}/locations/{location} + * - product: projects/{project}/locations/{location}/products/{product} + * - productSet: projects/{project}/locations/{location}/productSets/{product_set} + * - referenceImage: projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'vision.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Adds a Product to the specified ProductSet. If the Product is already + * present, no change is made. + * + * One Product can be added to at most 100 ProductSets. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + * + * The async variant is {@see ProductSearchClient::addProductToProductSetAsync()} . + * + * @param AddProductToProductSetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function addProductToProductSet(AddProductToProductSetRequest $request, array $callOptions = []): void + { + $this->startApiCall('AddProductToProductSet', $request, $callOptions)->wait(); + } + + /** + * Creates and returns a new product resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is missing or invalid. + * + * The async variant is {@see ProductSearchClient::createProductAsync()} . + * + * @param CreateProductRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Product + * + * @throws ApiException Thrown if the API call fails. + */ + public function createProduct(CreateProductRequest $request, array $callOptions = []): Product + { + return $this->startApiCall('CreateProduct', $request, $callOptions)->wait(); + } + + /** + * Creates and returns a new ProductSet resource. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + * 4096 characters. + * + * The async variant is {@see ProductSearchClient::createProductSetAsync()} . + * + * @param CreateProductSetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ProductSet + * + * @throws ApiException Thrown if the API call fails. + */ + public function createProductSet(CreateProductSetRequest $request, array $callOptions = []): ProductSet + { + return $this->startApiCall('CreateProductSet', $request, $callOptions)->wait(); + } + + /** + * Creates and returns a new ReferenceImage resource. + * + * The `bounding_poly` field is optional. If `bounding_poly` is not specified, + * the system will try to detect regions of interest in the image that are + * compatible with the product_category on the parent product. If it is + * specified, detection is ALWAYS skipped. The system converts polygons into + * non-rotated rectangles. + * + * Note that the pipeline will resize the image if the image resolution is too + * large to process (above 50MP). + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + * characters. + * * Returns INVALID_ARGUMENT if the product does not exist. + * * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + * compatible with the parent product's product_category is detected. + * * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + * + * The async variant is {@see ProductSearchClient::createReferenceImageAsync()} . + * + * @param CreateReferenceImageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ReferenceImage + * + * @throws ApiException Thrown if the API call fails. + */ + public function createReferenceImage(CreateReferenceImageRequest $request, array $callOptions = []): ReferenceImage + { + return $this->startApiCall('CreateReferenceImage', $request, $callOptions)->wait(); + } + + /** + * Permanently deletes a product and its reference images. + * + * Metadata of the product and all its images will be deleted right away, but + * search queries against ProductSets containing the product may still work + * until all related caches are refreshed. + * + * The async variant is {@see ProductSearchClient::deleteProductAsync()} . + * + * @param DeleteProductRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteProduct(DeleteProductRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteProduct', $request, $callOptions)->wait(); + } + + /** + * Permanently deletes a ProductSet. Products and ReferenceImages in the + * ProductSet are not deleted. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * The async variant is {@see ProductSearchClient::deleteProductSetAsync()} . + * + * @param DeleteProductSetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteProductSet(DeleteProductSetRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteProductSet', $request, $callOptions)->wait(); + } + + /** + * Permanently deletes a reference image. + * + * The image metadata will be deleted right away, but search queries + * against ProductSets containing the image may still work until all related + * caches are refreshed. + * + * The actual image files are not deleted from Google Cloud Storage. + * + * The async variant is {@see ProductSearchClient::deleteReferenceImageAsync()} . + * + * @param DeleteReferenceImageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteReferenceImage(DeleteReferenceImageRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteReferenceImage', $request, $callOptions)->wait(); + } + + /** + * Gets information associated with a Product. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * + * The async variant is {@see ProductSearchClient::getProductAsync()} . + * + * @param GetProductRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Product + * + * @throws ApiException Thrown if the API call fails. + */ + public function getProduct(GetProductRequest $request, array $callOptions = []): Product + { + return $this->startApiCall('GetProduct', $request, $callOptions)->wait(); + } + + /** + * Gets information associated with a ProductSet. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * + * The async variant is {@see ProductSearchClient::getProductSetAsync()} . + * + * @param GetProductSetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ProductSet + * + * @throws ApiException Thrown if the API call fails. + */ + public function getProductSet(GetProductSetRequest $request, array $callOptions = []): ProductSet + { + return $this->startApiCall('GetProductSet', $request, $callOptions)->wait(); + } + + /** + * Gets information associated with a ReferenceImage. + * + * Possible errors: + * + * * Returns NOT_FOUND if the specified image does not exist. + * + * The async variant is {@see ProductSearchClient::getReferenceImageAsync()} . + * + * @param GetReferenceImageRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ReferenceImage + * + * @throws ApiException Thrown if the API call fails. + */ + public function getReferenceImage(GetReferenceImageRequest $request, array $callOptions = []): ReferenceImage + { + return $this->startApiCall('GetReferenceImage', $request, $callOptions)->wait(); + } + + /** + * Asynchronous API that imports a list of reference images to specified + * product sets based on a list of image information. + * + * The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the + * progress and results of the request. + * `Operation.metadata` contains `BatchOperationMetadata`. (progress) + * `Operation.response` contains `ImportProductSetsResponse`. (results) + * + * The input source of this method is a csv file on Google Cloud Storage. + * For the format of the csv file please see + * [ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri]. + * + * The async variant is {@see ProductSearchClient::importProductSetsAsync()} . + * + * @param ImportProductSetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function importProductSets(ImportProductSetsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ImportProductSets', $request, $callOptions)->wait(); + } + + /** + * Lists ProductSets in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + * than 1. + * + * The async variant is {@see ProductSearchClient::listProductSetsAsync()} . + * + * @param ListProductSetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listProductSets(ListProductSetsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListProductSets', $request, $callOptions); + } + + /** + * Lists products in an unspecified order. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * The async variant is {@see ProductSearchClient::listProductsAsync()} . + * + * @param ListProductsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listProducts(ListProductsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListProducts', $request, $callOptions); + } + + /** + * Lists the Products in a ProductSet, in an unspecified order. If the + * ProductSet does not exist, the products field of the response will be + * empty. + * + * Possible errors: + * + * * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + * + * The async variant is {@see ProductSearchClient::listProductsInProductSetAsync()} + * . + * + * @param ListProductsInProductSetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listProductsInProductSet(ListProductsInProductSetRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListProductsInProductSet', $request, $callOptions); + } + + /** + * Lists reference images. + * + * Possible errors: + * + * * Returns NOT_FOUND if the parent product does not exist. + * * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + * than 1. + * + * The async variant is {@see ProductSearchClient::listReferenceImagesAsync()} . + * + * @param ListReferenceImagesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listReferenceImages(ListReferenceImagesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListReferenceImages', $request, $callOptions); + } + + /** + * Asynchronous API to delete all Products in a ProductSet or all Products + * that are in no ProductSet. + * + * If a Product is a member of the specified ProductSet in addition to other + * ProductSets, the Product will still be deleted. + * + * It is recommended to not delete the specified ProductSet until after this + * operation has completed. It is also recommended to not add any of the + * Products involved in the batch delete to a new ProductSet while this + * operation is running because those Products may still end up deleted. + * + * It's not possible to undo the PurgeProducts operation. Therefore, it is + * recommended to keep the csv files used in ImportProductSets (if that was + * how you originally built the Product Set) before starting PurgeProducts, in + * case you need to re-import the data after deletion. + * + * If the plan is to purge all of the Products from a ProductSet and then + * re-use the empty ProductSet to re-import new Products into the empty + * ProductSet, you must wait until the PurgeProducts operation has finished + * for that ProductSet. + * + * The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the + * progress and results of the request. + * `Operation.metadata` contains `BatchOperationMetadata`. (progress) + * + * The async variant is {@see ProductSearchClient::purgeProductsAsync()} . + * + * @param PurgeProductsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function purgeProducts(PurgeProductsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('PurgeProducts', $request, $callOptions)->wait(); + } + + /** + * Removes a Product from the specified ProductSet. + * + * The async variant is + * {@see ProductSearchClient::removeProductFromProductSetAsync()} . + * + * @param RemoveProductFromProductSetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeProductFromProductSet(RemoveProductFromProductSetRequest $request, array $callOptions = []): void + { + $this->startApiCall('RemoveProductFromProductSet', $request, $callOptions)->wait(); + } + + /** + * Makes changes to a Product resource. + * Only the `display_name`, `description`, and `labels` fields can be updated + * right now. + * + * If labels are updated, the change will not be reflected in queries until + * the next index time. + * + * Possible errors: + * + * * Returns NOT_FOUND if the Product does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + * missing from the request or longer than 4096 characters. + * * Returns INVALID_ARGUMENT if description is present in update_mask but is + * longer than 4096 characters. + * * Returns INVALID_ARGUMENT if product_category is present in update_mask. + * + * The async variant is {@see ProductSearchClient::updateProductAsync()} . + * + * @param UpdateProductRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Product + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateProduct(UpdateProductRequest $request, array $callOptions = []): Product + { + return $this->startApiCall('UpdateProduct', $request, $callOptions)->wait(); + } + + /** + * Makes changes to a ProductSet resource. + * Only display_name can be updated currently. + * + * Possible errors: + * + * * Returns NOT_FOUND if the ProductSet does not exist. + * * Returns INVALID_ARGUMENT if display_name is present in update_mask but + * missing from the request or longer than 4096 characters. + * + * The async variant is {@see ProductSearchClient::updateProductSetAsync()} . + * + * @param UpdateProductSetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ProductSet + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateProductSet(UpdateProductSetRequest $request, array $callOptions = []): ProductSet + { + return $this->startApiCall('UpdateProductSet', $request, $callOptions)->wait(); + } } diff --git a/VmMigration/composer.json b/VmMigration/composer.json index 9d6514d84b26..256bacb8ed08 100644 --- a/VmMigration/composer.json +++ b/VmMigration/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/VmMigration/src/V1/Client/BaseClient/VmMigrationBaseClient.php b/VmMigration/src/V1/Client/BaseClient/VmMigrationBaseClient.php deleted file mode 100644 index 8100fa3c5f61..000000000000 --- a/VmMigration/src/V1/Client/BaseClient/VmMigrationBaseClient.php +++ /dev/null @@ -1,1826 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/vm_migration_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/vm_migration_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/vm_migration_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/vm_migration_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a clone_job - * resource. - * - * @param string $project - * @param string $location - * @param string $source - * @param string $migratingVm - * @param string $cloneJob - * - * @return string The formatted clone_job resource. - */ - public static function cloneJobName(string $project, string $location, string $source, string $migratingVm, string $cloneJob): string - { - return self::getPathTemplate('cloneJob')->render([ - 'project' => $project, - 'location' => $location, - 'source' => $source, - 'migrating_vm' => $migratingVm, - 'clone_job' => $cloneJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a cutover_job - * resource. - * - * @param string $project - * @param string $location - * @param string $source - * @param string $migratingVm - * @param string $cutoverJob - * - * @return string The formatted cutover_job resource. - */ - public static function cutoverJobName(string $project, string $location, string $source, string $migratingVm, string $cutoverJob): string - { - return self::getPathTemplate('cutoverJob')->render([ - 'project' => $project, - 'location' => $location, - 'source' => $source, - 'migrating_vm' => $migratingVm, - 'cutover_job' => $cutoverJob, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * datacenter_connector resource. - * - * @param string $project - * @param string $location - * @param string $source - * @param string $datacenterConnector - * - * @return string The formatted datacenter_connector resource. - */ - public static function datacenterConnectorName(string $project, string $location, string $source, string $datacenterConnector): string - { - return self::getPathTemplate('datacenterConnector')->render([ - 'project' => $project, - 'location' => $location, - 'source' => $source, - 'datacenter_connector' => $datacenterConnector, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a group - * resource. - * - * @param string $project - * @param string $location - * @param string $group - * - * @return string The formatted group resource. - */ - public static function groupName(string $project, string $location, string $group): string - { - return self::getPathTemplate('group')->render([ - 'project' => $project, - 'location' => $location, - 'group' => $group, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a migrating_vm - * resource. - * - * @param string $project - * @param string $location - * @param string $source - * @param string $migratingVm - * - * @return string The formatted migrating_vm resource. - */ - public static function migratingVmName(string $project, string $location, string $source, string $migratingVm): string - { - return self::getPathTemplate('migratingVm')->render([ - 'project' => $project, - 'location' => $location, - 'source' => $source, - 'migrating_vm' => $migratingVm, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * replication_cycle resource. - * - * @param string $project - * @param string $location - * @param string $source - * @param string $migratingVm - * @param string $replicationCycle - * - * @return string The formatted replication_cycle resource. - */ - public static function replicationCycleName(string $project, string $location, string $source, string $migratingVm, string $replicationCycle): string - { - return self::getPathTemplate('replicationCycle')->render([ - 'project' => $project, - 'location' => $location, - 'source' => $source, - 'migrating_vm' => $migratingVm, - 'replication_cycle' => $replicationCycle, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a source - * resource. - * - * @param string $project - * @param string $location - * @param string $source - * - * @return string The formatted source resource. - */ - public static function sourceName(string $project, string $location, string $source): string - { - return self::getPathTemplate('source')->render([ - 'project' => $project, - 'location' => $location, - 'source' => $source, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * target_project resource. - * - * @param string $project - * @param string $location - * @param string $targetProject - * - * @return string The formatted target_project resource. - */ - public static function targetProjectName(string $project, string $location, string $targetProject): string - { - return self::getPathTemplate('targetProject')->render([ - 'project' => $project, - 'location' => $location, - 'target_project' => $targetProject, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * utilization_report resource. - * - * @param string $project - * @param string $location - * @param string $source - * @param string $utilizationReport - * - * @return string The formatted utilization_report resource. - */ - public static function utilizationReportName(string $project, string $location, string $source, string $utilizationReport): string - { - return self::getPathTemplate('utilizationReport')->render([ - 'project' => $project, - 'location' => $location, - 'source' => $source, - 'utilization_report' => $utilizationReport, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - cloneJob: projects/{project}/locations/{location}/sources/{source}/migratingVms/{migrating_vm}/cloneJobs/{clone_job} - * - cutoverJob: projects/{project}/locations/{location}/sources/{source}/migratingVms/{migrating_vm}/cutoverJobs/{cutover_job} - * - datacenterConnector: projects/{project}/locations/{location}/sources/{source}/datacenterConnectors/{datacenter_connector} - * - group: projects/{project}/locations/{location}/groups/{group} - * - location: projects/{project}/locations/{location} - * - migratingVm: projects/{project}/locations/{location}/sources/{source}/migratingVms/{migrating_vm} - * - replicationCycle: projects/{project}/locations/{location}/sources/{source}/migratingVms/{migrating_vm}/replicationCycles/{replication_cycle} - * - source: projects/{project}/locations/{location}/sources/{source} - * - targetProject: projects/{project}/locations/{location}/targetProjects/{target_project} - * - utilizationReport: projects/{project}/locations/{location}/sources/{source}/utilizationReports/{utilization_report} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'vmmigration.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Adds a MigratingVm to a Group. - * - * The async variant is {@see self::addGroupMigrationAsync()} . - * - * @example samples/V1/VmMigrationClient/add_group_migration.php - * - * @param AddGroupMigrationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function addGroupMigration(AddGroupMigrationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('AddGroupMigration', $request, $callOptions)->wait(); - } - - /** - * Initiates the cancellation of a running clone job. - * - * The async variant is {@see self::cancelCloneJobAsync()} . - * - * @example samples/V1/VmMigrationClient/cancel_clone_job.php - * - * @param CancelCloneJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function cancelCloneJob(CancelCloneJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CancelCloneJob', $request, $callOptions)->wait(); - } - - /** - * Initiates the cancellation of a running cutover job. - * - * The async variant is {@see self::cancelCutoverJobAsync()} . - * - * @example samples/V1/VmMigrationClient/cancel_cutover_job.php - * - * @param CancelCutoverJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function cancelCutoverJob(CancelCutoverJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CancelCutoverJob', $request, $callOptions)->wait(); - } - - /** - * Initiates a Clone of a specific migrating VM. - * - * The async variant is {@see self::createCloneJobAsync()} . - * - * @example samples/V1/VmMigrationClient/create_clone_job.php - * - * @param CreateCloneJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCloneJob(CreateCloneJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateCloneJob', $request, $callOptions)->wait(); - } - - /** - * Initiates a Cutover of a specific migrating VM. - * The returned LRO is completed when the cutover job resource is created - * and the job is initiated. - * - * The async variant is {@see self::createCutoverJobAsync()} . - * - * @example samples/V1/VmMigrationClient/create_cutover_job.php - * - * @param CreateCutoverJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCutoverJob(CreateCutoverJobRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateCutoverJob', $request, $callOptions)->wait(); - } - - /** - * Creates a new DatacenterConnector in a given Source. - * - * The async variant is {@see self::createDatacenterConnectorAsync()} . - * - * @example samples/V1/VmMigrationClient/create_datacenter_connector.php - * - * @param CreateDatacenterConnectorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createDatacenterConnector(CreateDatacenterConnectorRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateDatacenterConnector', $request, $callOptions)->wait(); - } - - /** - * Creates a new Group in a given project and location. - * - * The async variant is {@see self::createGroupAsync()} . - * - * @example samples/V1/VmMigrationClient/create_group.php - * - * @param CreateGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createGroup(CreateGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateGroup', $request, $callOptions)->wait(); - } - - /** - * Creates a new MigratingVm in a given Source. - * - * The async variant is {@see self::createMigratingVmAsync()} . - * - * @example samples/V1/VmMigrationClient/create_migrating_vm.php - * - * @param CreateMigratingVmRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createMigratingVm(CreateMigratingVmRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateMigratingVm', $request, $callOptions)->wait(); - } - - /** - * Creates a new Source in a given project and location. - * - * The async variant is {@see self::createSourceAsync()} . - * - * @example samples/V1/VmMigrationClient/create_source.php - * - * @param CreateSourceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSource(CreateSourceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateSource', $request, $callOptions)->wait(); - } - - /** - * Creates a new TargetProject in a given project. - * - * NOTE: TargetProject is a global resource; hence the only supported value - * for location is `global`. - * - * The async variant is {@see self::createTargetProjectAsync()} . - * - * @example samples/V1/VmMigrationClient/create_target_project.php - * - * @param CreateTargetProjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createTargetProject(CreateTargetProjectRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateTargetProject', $request, $callOptions)->wait(); - } - - /** - * Creates a new UtilizationReport. - * - * The async variant is {@see self::createUtilizationReportAsync()} . - * - * @example samples/V1/VmMigrationClient/create_utilization_report.php - * - * @param CreateUtilizationReportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createUtilizationReport(CreateUtilizationReportRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateUtilizationReport', $request, $callOptions)->wait(); - } - - /** - * Deletes a single DatacenterConnector. - * - * The async variant is {@see self::deleteDatacenterConnectorAsync()} . - * - * @example samples/V1/VmMigrationClient/delete_datacenter_connector.php - * - * @param DeleteDatacenterConnectorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteDatacenterConnector(DeleteDatacenterConnectorRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteDatacenterConnector', $request, $callOptions)->wait(); - } - - /** - * Deletes a single Group. - * - * The async variant is {@see self::deleteGroupAsync()} . - * - * @example samples/V1/VmMigrationClient/delete_group.php - * - * @param DeleteGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteGroup(DeleteGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteGroup', $request, $callOptions)->wait(); - } - - /** - * Deletes a single MigratingVm. - * - * The async variant is {@see self::deleteMigratingVmAsync()} . - * - * @example samples/V1/VmMigrationClient/delete_migrating_vm.php - * - * @param DeleteMigratingVmRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteMigratingVm(DeleteMigratingVmRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteMigratingVm', $request, $callOptions)->wait(); - } - - /** - * Deletes a single Source. - * - * The async variant is {@see self::deleteSourceAsync()} . - * - * @example samples/V1/VmMigrationClient/delete_source.php - * - * @param DeleteSourceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteSource(DeleteSourceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteSource', $request, $callOptions)->wait(); - } - - /** - * Deletes a single TargetProject. - * - * NOTE: TargetProject is a global resource; hence the only supported value - * for location is `global`. - * - * The async variant is {@see self::deleteTargetProjectAsync()} . - * - * @example samples/V1/VmMigrationClient/delete_target_project.php - * - * @param DeleteTargetProjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteTargetProject(DeleteTargetProjectRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteTargetProject', $request, $callOptions)->wait(); - } - - /** - * Deletes a single Utilization Report. - * - * The async variant is {@see self::deleteUtilizationReportAsync()} . - * - * @example samples/V1/VmMigrationClient/delete_utilization_report.php - * - * @param DeleteUtilizationReportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteUtilizationReport(DeleteUtilizationReportRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteUtilizationReport', $request, $callOptions)->wait(); - } - - /** - * List remote source's inventory of VMs. - * The remote source is the onprem vCenter (remote in the sense it's not in - * Compute Engine). The inventory describes the list of existing VMs in that - * source. Note that this operation lists the VMs on the remote source, as - * opposed to listing the MigratingVms resources in the vmmigration service. - * - * The async variant is {@see self::fetchInventoryAsync()} . - * - * @example samples/V1/VmMigrationClient/fetch_inventory.php - * - * @param FetchInventoryRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 FetchInventoryResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function fetchInventory(FetchInventoryRequest $request, array $callOptions = []): FetchInventoryResponse - { - return $this->startApiCall('FetchInventory', $request, $callOptions)->wait(); - } - - /** - * Marks a migration as completed, deleting migration resources that are no - * longer being used. Only applicable after cutover is done. - * - * The async variant is {@see self::finalizeMigrationAsync()} . - * - * @example samples/V1/VmMigrationClient/finalize_migration.php - * - * @param FinalizeMigrationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function finalizeMigration(FinalizeMigrationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('FinalizeMigration', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single CloneJob. - * - * The async variant is {@see self::getCloneJobAsync()} . - * - * @example samples/V1/VmMigrationClient/get_clone_job.php - * - * @param GetCloneJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CloneJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCloneJob(GetCloneJobRequest $request, array $callOptions = []): CloneJob - { - return $this->startApiCall('GetCloneJob', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single CutoverJob. - * - * The async variant is {@see self::getCutoverJobAsync()} . - * - * @example samples/V1/VmMigrationClient/get_cutover_job.php - * - * @param GetCutoverJobRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 CutoverJob - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCutoverJob(GetCutoverJobRequest $request, array $callOptions = []): CutoverJob - { - return $this->startApiCall('GetCutoverJob', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single DatacenterConnector. - * - * The async variant is {@see self::getDatacenterConnectorAsync()} . - * - * @example samples/V1/VmMigrationClient/get_datacenter_connector.php - * - * @param GetDatacenterConnectorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 DatacenterConnector - * - * @throws ApiException Thrown if the API call fails. - */ - public function getDatacenterConnector(GetDatacenterConnectorRequest $request, array $callOptions = []): DatacenterConnector - { - return $this->startApiCall('GetDatacenterConnector', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single Group. - * - * The async variant is {@see self::getGroupAsync()} . - * - * @example samples/V1/VmMigrationClient/get_group.php - * - * @param GetGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Group - * - * @throws ApiException Thrown if the API call fails. - */ - public function getGroup(GetGroupRequest $request, array $callOptions = []): Group - { - return $this->startApiCall('GetGroup', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single MigratingVm. - * - * The async variant is {@see self::getMigratingVmAsync()} . - * - * @example samples/V1/VmMigrationClient/get_migrating_vm.php - * - * @param GetMigratingVmRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 MigratingVm - * - * @throws ApiException Thrown if the API call fails. - */ - public function getMigratingVm(GetMigratingVmRequest $request, array $callOptions = []): MigratingVm - { - return $this->startApiCall('GetMigratingVm', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single ReplicationCycle. - * - * The async variant is {@see self::getReplicationCycleAsync()} . - * - * @example samples/V1/VmMigrationClient/get_replication_cycle.php - * - * @param GetReplicationCycleRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ReplicationCycle - * - * @throws ApiException Thrown if the API call fails. - */ - public function getReplicationCycle(GetReplicationCycleRequest $request, array $callOptions = []): ReplicationCycle - { - return $this->startApiCall('GetReplicationCycle', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single Source. - * - * The async variant is {@see self::getSourceAsync()} . - * - * @example samples/V1/VmMigrationClient/get_source.php - * - * @param GetSourceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Source - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSource(GetSourceRequest $request, array $callOptions = []): Source - { - return $this->startApiCall('GetSource', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single TargetProject. - * - * NOTE: TargetProject is a global resource; hence the only supported value - * for location is `global`. - * - * The async variant is {@see self::getTargetProjectAsync()} . - * - * @example samples/V1/VmMigrationClient/get_target_project.php - * - * @param GetTargetProjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TargetProject - * - * @throws ApiException Thrown if the API call fails. - */ - public function getTargetProject(GetTargetProjectRequest $request, array $callOptions = []): TargetProject - { - return $this->startApiCall('GetTargetProject', $request, $callOptions)->wait(); - } - - /** - * Gets a single Utilization Report. - * - * The async variant is {@see self::getUtilizationReportAsync()} . - * - * @example samples/V1/VmMigrationClient/get_utilization_report.php - * - * @param GetUtilizationReportRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 UtilizationReport - * - * @throws ApiException Thrown if the API call fails. - */ - public function getUtilizationReport(GetUtilizationReportRequest $request, array $callOptions = []): UtilizationReport - { - return $this->startApiCall('GetUtilizationReport', $request, $callOptions)->wait(); - } - - /** - * Lists CloneJobs of a given migrating VM. - * - * The async variant is {@see self::listCloneJobsAsync()} . - * - * @example samples/V1/VmMigrationClient/list_clone_jobs.php - * - * @param ListCloneJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCloneJobs(ListCloneJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCloneJobs', $request, $callOptions); - } - - /** - * Lists CutoverJobs of a given migrating VM. - * - * The async variant is {@see self::listCutoverJobsAsync()} . - * - * @example samples/V1/VmMigrationClient/list_cutover_jobs.php - * - * @param ListCutoverJobsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCutoverJobs(ListCutoverJobsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCutoverJobs', $request, $callOptions); - } - - /** - * Lists DatacenterConnectors in a given Source. - * - * The async variant is {@see self::listDatacenterConnectorsAsync()} . - * - * @example samples/V1/VmMigrationClient/list_datacenter_connectors.php - * - * @param ListDatacenterConnectorsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listDatacenterConnectors(ListDatacenterConnectorsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListDatacenterConnectors', $request, $callOptions); - } - - /** - * Lists Groups in a given project and location. - * - * The async variant is {@see self::listGroupsAsync()} . - * - * @example samples/V1/VmMigrationClient/list_groups.php - * - * @param ListGroupsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listGroups(ListGroupsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListGroups', $request, $callOptions); - } - - /** - * Lists MigratingVms in a given Source. - * - * The async variant is {@see self::listMigratingVmsAsync()} . - * - * @example samples/V1/VmMigrationClient/list_migrating_vms.php - * - * @param ListMigratingVmsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listMigratingVms(ListMigratingVmsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListMigratingVms', $request, $callOptions); - } - - /** - * Lists ReplicationCycles in a given MigratingVM. - * - * The async variant is {@see self::listReplicationCyclesAsync()} . - * - * @example samples/V1/VmMigrationClient/list_replication_cycles.php - * - * @param ListReplicationCyclesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listReplicationCycles(ListReplicationCyclesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListReplicationCycles', $request, $callOptions); - } - - /** - * Lists Sources in a given project and location. - * - * The async variant is {@see self::listSourcesAsync()} . - * - * @example samples/V1/VmMigrationClient/list_sources.php - * - * @param ListSourcesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSources(ListSourcesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSources', $request, $callOptions); - } - - /** - * Lists TargetProjects in a given project. - * - * NOTE: TargetProject is a global resource; hence the only supported value - * for location is `global`. - * - * The async variant is {@see self::listTargetProjectsAsync()} . - * - * @example samples/V1/VmMigrationClient/list_target_projects.php - * - * @param ListTargetProjectsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listTargetProjects(ListTargetProjectsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListTargetProjects', $request, $callOptions); - } - - /** - * Lists Utilization Reports of the given Source. - * - * The async variant is {@see self::listUtilizationReportsAsync()} . - * - * @example samples/V1/VmMigrationClient/list_utilization_reports.php - * - * @param ListUtilizationReportsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listUtilizationReports(ListUtilizationReportsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListUtilizationReports', $request, $callOptions); - } - - /** - * Pauses a migration for a VM. If cycle tasks are running they will be - * cancelled, preserving source task data. Further replication cycles will not - * be triggered while the VM is paused. - * - * The async variant is {@see self::pauseMigrationAsync()} . - * - * @example samples/V1/VmMigrationClient/pause_migration.php - * - * @param PauseMigrationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function pauseMigration(PauseMigrationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('PauseMigration', $request, $callOptions)->wait(); - } - - /** - * Removes a MigratingVm from a Group. - * - * The async variant is {@see self::removeGroupMigrationAsync()} . - * - * @example samples/V1/VmMigrationClient/remove_group_migration.php - * - * @param RemoveGroupMigrationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function removeGroupMigration(RemoveGroupMigrationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('RemoveGroupMigration', $request, $callOptions)->wait(); - } - - /** - * Resumes a migration for a VM. When called on a paused migration, will start - * the process of uploading data and creating snapshots; when called on a - * completed cut-over migration, will update the migration to active state and - * start the process of uploading data and creating snapshots. - * - * The async variant is {@see self::resumeMigrationAsync()} . - * - * @example samples/V1/VmMigrationClient/resume_migration.php - * - * @param ResumeMigrationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function resumeMigration(ResumeMigrationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ResumeMigration', $request, $callOptions)->wait(); - } - - /** - * Starts migration for a VM. Starts the process of uploading - * data and creating snapshots, in replication cycles scheduled by the policy. - * - * The async variant is {@see self::startMigrationAsync()} . - * - * @example samples/V1/VmMigrationClient/start_migration.php - * - * @param StartMigrationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function startMigration(StartMigrationRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('StartMigration', $request, $callOptions)->wait(); - } - - /** - * Updates the parameters of a single Group. - * - * The async variant is {@see self::updateGroupAsync()} . - * - * @example samples/V1/VmMigrationClient/update_group.php - * - * @param UpdateGroupRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateGroup(UpdateGroupRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateGroup', $request, $callOptions)->wait(); - } - - /** - * Updates the parameters of a single MigratingVm. - * - * The async variant is {@see self::updateMigratingVmAsync()} . - * - * @example samples/V1/VmMigrationClient/update_migrating_vm.php - * - * @param UpdateMigratingVmRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateMigratingVm(UpdateMigratingVmRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateMigratingVm', $request, $callOptions)->wait(); - } - - /** - * Updates the parameters of a single Source. - * - * The async variant is {@see self::updateSourceAsync()} . - * - * @example samples/V1/VmMigrationClient/update_source.php - * - * @param UpdateSourceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSource(UpdateSourceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateSource', $request, $callOptions)->wait(); - } - - /** - * Updates the parameters of a single TargetProject. - * - * NOTE: TargetProject is a global resource; hence the only supported value - * for location is `global`. - * - * The async variant is {@see self::updateTargetProjectAsync()} . - * - * @example samples/V1/VmMigrationClient/update_target_project.php - * - * @param UpdateTargetProjectRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateTargetProject(UpdateTargetProjectRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateTargetProject', $request, $callOptions)->wait(); - } - - /** - * Upgrades the appliance relate to this DatacenterConnector to the in-place - * updateable version. - * - * The async variant is {@see self::upgradeApplianceAsync()} . - * - * @example samples/V1/VmMigrationClient/upgrade_appliance.php - * - * @param UpgradeApplianceRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function upgradeAppliance(UpgradeApplianceRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpgradeAppliance', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/VmMigrationClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/VmMigrationClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/VmMigration/src/V1/Client/VmMigrationClient.php b/VmMigration/src/V1/Client/VmMigrationClient.php index bb4815e7acdb..3110ca254e8c 100644 --- a/VmMigration/src/V1/Client/VmMigrationClient.php +++ b/VmMigration/src/V1/Client/VmMigrationClient.php @@ -24,17 +24,1803 @@ namespace Google\Cloud\VMMigration\V1\Client; -use Google\Cloud\VMMigration\V1\Client\BaseClient\VmMigrationBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\VMMigration\V1\AddGroupMigrationRequest; +use Google\Cloud\VMMigration\V1\CancelCloneJobRequest; +use Google\Cloud\VMMigration\V1\CancelCutoverJobRequest; +use Google\Cloud\VMMigration\V1\CloneJob; +use Google\Cloud\VMMigration\V1\CreateCloneJobRequest; +use Google\Cloud\VMMigration\V1\CreateCutoverJobRequest; +use Google\Cloud\VMMigration\V1\CreateDatacenterConnectorRequest; +use Google\Cloud\VMMigration\V1\CreateGroupRequest; +use Google\Cloud\VMMigration\V1\CreateMigratingVmRequest; +use Google\Cloud\VMMigration\V1\CreateSourceRequest; +use Google\Cloud\VMMigration\V1\CreateTargetProjectRequest; +use Google\Cloud\VMMigration\V1\CreateUtilizationReportRequest; +use Google\Cloud\VMMigration\V1\CutoverJob; +use Google\Cloud\VMMigration\V1\DatacenterConnector; +use Google\Cloud\VMMigration\V1\DeleteDatacenterConnectorRequest; +use Google\Cloud\VMMigration\V1\DeleteGroupRequest; +use Google\Cloud\VMMigration\V1\DeleteMigratingVmRequest; +use Google\Cloud\VMMigration\V1\DeleteSourceRequest; +use Google\Cloud\VMMigration\V1\DeleteTargetProjectRequest; +use Google\Cloud\VMMigration\V1\DeleteUtilizationReportRequest; +use Google\Cloud\VMMigration\V1\FetchInventoryRequest; +use Google\Cloud\VMMigration\V1\FetchInventoryResponse; +use Google\Cloud\VMMigration\V1\FinalizeMigrationRequest; +use Google\Cloud\VMMigration\V1\GetCloneJobRequest; +use Google\Cloud\VMMigration\V1\GetCutoverJobRequest; +use Google\Cloud\VMMigration\V1\GetDatacenterConnectorRequest; +use Google\Cloud\VMMigration\V1\GetGroupRequest; +use Google\Cloud\VMMigration\V1\GetMigratingVmRequest; +use Google\Cloud\VMMigration\V1\GetReplicationCycleRequest; +use Google\Cloud\VMMigration\V1\GetSourceRequest; +use Google\Cloud\VMMigration\V1\GetTargetProjectRequest; +use Google\Cloud\VMMigration\V1\GetUtilizationReportRequest; +use Google\Cloud\VMMigration\V1\Group; +use Google\Cloud\VMMigration\V1\ListCloneJobsRequest; +use Google\Cloud\VMMigration\V1\ListCutoverJobsRequest; +use Google\Cloud\VMMigration\V1\ListDatacenterConnectorsRequest; +use Google\Cloud\VMMigration\V1\ListGroupsRequest; +use Google\Cloud\VMMigration\V1\ListMigratingVmsRequest; +use Google\Cloud\VMMigration\V1\ListReplicationCyclesRequest; +use Google\Cloud\VMMigration\V1\ListSourcesRequest; +use Google\Cloud\VMMigration\V1\ListTargetProjectsRequest; +use Google\Cloud\VMMigration\V1\ListUtilizationReportsRequest; +use Google\Cloud\VMMigration\V1\MigratingVm; +use Google\Cloud\VMMigration\V1\PauseMigrationRequest; +use Google\Cloud\VMMigration\V1\RemoveGroupMigrationRequest; +use Google\Cloud\VMMigration\V1\ReplicationCycle; +use Google\Cloud\VMMigration\V1\ResumeMigrationRequest; +use Google\Cloud\VMMigration\V1\Source; +use Google\Cloud\VMMigration\V1\StartMigrationRequest; +use Google\Cloud\VMMigration\V1\TargetProject; +use Google\Cloud\VMMigration\V1\UpdateGroupRequest; +use Google\Cloud\VMMigration\V1\UpdateMigratingVmRequest; +use Google\Cloud\VMMigration\V1\UpdateSourceRequest; +use Google\Cloud\VMMigration\V1\UpdateTargetProjectRequest; +use Google\Cloud\VMMigration\V1\UpgradeApplianceRequest; +use Google\Cloud\VMMigration\V1\UtilizationReport; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: VM Migration Service * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\VMMigration\V1\VmMigrationClient} for the stable implementation * * @experimental + * + * @method PromiseInterface addGroupMigrationAsync(AddGroupMigrationRequest $request, array $optionalArgs = []) + * @method PromiseInterface cancelCloneJobAsync(CancelCloneJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface cancelCutoverJobAsync(CancelCutoverJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface createCloneJobAsync(CreateCloneJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface createCutoverJobAsync(CreateCutoverJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface createDatacenterConnectorAsync(CreateDatacenterConnectorRequest $request, array $optionalArgs = []) + * @method PromiseInterface createGroupAsync(CreateGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface createMigratingVmAsync(CreateMigratingVmRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSourceAsync(CreateSourceRequest $request, array $optionalArgs = []) + * @method PromiseInterface createTargetProjectAsync(CreateTargetProjectRequest $request, array $optionalArgs = []) + * @method PromiseInterface createUtilizationReportAsync(CreateUtilizationReportRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteDatacenterConnectorAsync(DeleteDatacenterConnectorRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteGroupAsync(DeleteGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteMigratingVmAsync(DeleteMigratingVmRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteSourceAsync(DeleteSourceRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteTargetProjectAsync(DeleteTargetProjectRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteUtilizationReportAsync(DeleteUtilizationReportRequest $request, array $optionalArgs = []) + * @method PromiseInterface fetchInventoryAsync(FetchInventoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface finalizeMigrationAsync(FinalizeMigrationRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCloneJobAsync(GetCloneJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getCutoverJobAsync(GetCutoverJobRequest $request, array $optionalArgs = []) + * @method PromiseInterface getDatacenterConnectorAsync(GetDatacenterConnectorRequest $request, array $optionalArgs = []) + * @method PromiseInterface getGroupAsync(GetGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface getMigratingVmAsync(GetMigratingVmRequest $request, array $optionalArgs = []) + * @method PromiseInterface getReplicationCycleAsync(GetReplicationCycleRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSourceAsync(GetSourceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getTargetProjectAsync(GetTargetProjectRequest $request, array $optionalArgs = []) + * @method PromiseInterface getUtilizationReportAsync(GetUtilizationReportRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCloneJobsAsync(ListCloneJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCutoverJobsAsync(ListCutoverJobsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listDatacenterConnectorsAsync(ListDatacenterConnectorsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listGroupsAsync(ListGroupsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listMigratingVmsAsync(ListMigratingVmsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listReplicationCyclesAsync(ListReplicationCyclesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSourcesAsync(ListSourcesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listTargetProjectsAsync(ListTargetProjectsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listUtilizationReportsAsync(ListUtilizationReportsRequest $request, array $optionalArgs = []) + * @method PromiseInterface pauseMigrationAsync(PauseMigrationRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeGroupMigrationAsync(RemoveGroupMigrationRequest $request, array $optionalArgs = []) + * @method PromiseInterface resumeMigrationAsync(ResumeMigrationRequest $request, array $optionalArgs = []) + * @method PromiseInterface startMigrationAsync(StartMigrationRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateGroupAsync(UpdateGroupRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateMigratingVmAsync(UpdateMigratingVmRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSourceAsync(UpdateSourceRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateTargetProjectAsync(UpdateTargetProjectRequest $request, array $optionalArgs = []) + * @method PromiseInterface upgradeApplianceAsync(UpgradeApplianceRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class VmMigrationClient extends VmMigrationBaseClient +final class VmMigrationClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see VmMigrationBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.vmmigration.v1.VmMigration'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'vmmigration.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/vm_migration_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/vm_migration_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/vm_migration_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/vm_migration_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a clone_job + * resource. + * + * @param string $project + * @param string $location + * @param string $source + * @param string $migratingVm + * @param string $cloneJob + * + * @return string The formatted clone_job resource. + */ + public static function cloneJobName(string $project, string $location, string $source, string $migratingVm, string $cloneJob): string + { + return self::getPathTemplate('cloneJob')->render([ + 'project' => $project, + 'location' => $location, + 'source' => $source, + 'migrating_vm' => $migratingVm, + 'clone_job' => $cloneJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a cutover_job + * resource. + * + * @param string $project + * @param string $location + * @param string $source + * @param string $migratingVm + * @param string $cutoverJob + * + * @return string The formatted cutover_job resource. + */ + public static function cutoverJobName(string $project, string $location, string $source, string $migratingVm, string $cutoverJob): string + { + return self::getPathTemplate('cutoverJob')->render([ + 'project' => $project, + 'location' => $location, + 'source' => $source, + 'migrating_vm' => $migratingVm, + 'cutover_job' => $cutoverJob, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * datacenter_connector resource. + * + * @param string $project + * @param string $location + * @param string $source + * @param string $datacenterConnector + * + * @return string The formatted datacenter_connector resource. + */ + public static function datacenterConnectorName(string $project, string $location, string $source, string $datacenterConnector): string + { + return self::getPathTemplate('datacenterConnector')->render([ + 'project' => $project, + 'location' => $location, + 'source' => $source, + 'datacenter_connector' => $datacenterConnector, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a group + * resource. + * + * @param string $project + * @param string $location + * @param string $group + * + * @return string The formatted group resource. + */ + public static function groupName(string $project, string $location, string $group): string + { + return self::getPathTemplate('group')->render([ + 'project' => $project, + 'location' => $location, + 'group' => $group, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a migrating_vm + * resource. + * + * @param string $project + * @param string $location + * @param string $source + * @param string $migratingVm + * + * @return string The formatted migrating_vm resource. + */ + public static function migratingVmName(string $project, string $location, string $source, string $migratingVm): string + { + return self::getPathTemplate('migratingVm')->render([ + 'project' => $project, + 'location' => $location, + 'source' => $source, + 'migrating_vm' => $migratingVm, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * replication_cycle resource. + * + * @param string $project + * @param string $location + * @param string $source + * @param string $migratingVm + * @param string $replicationCycle + * + * @return string The formatted replication_cycle resource. + */ + public static function replicationCycleName(string $project, string $location, string $source, string $migratingVm, string $replicationCycle): string + { + return self::getPathTemplate('replicationCycle')->render([ + 'project' => $project, + 'location' => $location, + 'source' => $source, + 'migrating_vm' => $migratingVm, + 'replication_cycle' => $replicationCycle, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a source + * resource. + * + * @param string $project + * @param string $location + * @param string $source + * + * @return string The formatted source resource. + */ + public static function sourceName(string $project, string $location, string $source): string + { + return self::getPathTemplate('source')->render([ + 'project' => $project, + 'location' => $location, + 'source' => $source, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * target_project resource. + * + * @param string $project + * @param string $location + * @param string $targetProject + * + * @return string The formatted target_project resource. + */ + public static function targetProjectName(string $project, string $location, string $targetProject): string + { + return self::getPathTemplate('targetProject')->render([ + 'project' => $project, + 'location' => $location, + 'target_project' => $targetProject, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * utilization_report resource. + * + * @param string $project + * @param string $location + * @param string $source + * @param string $utilizationReport + * + * @return string The formatted utilization_report resource. + */ + public static function utilizationReportName(string $project, string $location, string $source, string $utilizationReport): string + { + return self::getPathTemplate('utilizationReport')->render([ + 'project' => $project, + 'location' => $location, + 'source' => $source, + 'utilization_report' => $utilizationReport, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - cloneJob: projects/{project}/locations/{location}/sources/{source}/migratingVms/{migrating_vm}/cloneJobs/{clone_job} + * - cutoverJob: projects/{project}/locations/{location}/sources/{source}/migratingVms/{migrating_vm}/cutoverJobs/{cutover_job} + * - datacenterConnector: projects/{project}/locations/{location}/sources/{source}/datacenterConnectors/{datacenter_connector} + * - group: projects/{project}/locations/{location}/groups/{group} + * - location: projects/{project}/locations/{location} + * - migratingVm: projects/{project}/locations/{location}/sources/{source}/migratingVms/{migrating_vm} + * - replicationCycle: projects/{project}/locations/{location}/sources/{source}/migratingVms/{migrating_vm}/replicationCycles/{replication_cycle} + * - source: projects/{project}/locations/{location}/sources/{source} + * - targetProject: projects/{project}/locations/{location}/targetProjects/{target_project} + * - utilizationReport: projects/{project}/locations/{location}/sources/{source}/utilizationReports/{utilization_report} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'vmmigration.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Adds a MigratingVm to a Group. + * + * The async variant is {@see VmMigrationClient::addGroupMigrationAsync()} . + * + * @example samples/V1/VmMigrationClient/add_group_migration.php + * + * @param AddGroupMigrationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function addGroupMigration(AddGroupMigrationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('AddGroupMigration', $request, $callOptions)->wait(); + } + + /** + * Initiates the cancellation of a running clone job. + * + * The async variant is {@see VmMigrationClient::cancelCloneJobAsync()} . + * + * @example samples/V1/VmMigrationClient/cancel_clone_job.php + * + * @param CancelCloneJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function cancelCloneJob(CancelCloneJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CancelCloneJob', $request, $callOptions)->wait(); + } + + /** + * Initiates the cancellation of a running cutover job. + * + * The async variant is {@see VmMigrationClient::cancelCutoverJobAsync()} . + * + * @example samples/V1/VmMigrationClient/cancel_cutover_job.php + * + * @param CancelCutoverJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function cancelCutoverJob(CancelCutoverJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CancelCutoverJob', $request, $callOptions)->wait(); + } + + /** + * Initiates a Clone of a specific migrating VM. + * + * The async variant is {@see VmMigrationClient::createCloneJobAsync()} . + * + * @example samples/V1/VmMigrationClient/create_clone_job.php + * + * @param CreateCloneJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCloneJob(CreateCloneJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateCloneJob', $request, $callOptions)->wait(); + } + + /** + * Initiates a Cutover of a specific migrating VM. + * The returned LRO is completed when the cutover job resource is created + * and the job is initiated. + * + * The async variant is {@see VmMigrationClient::createCutoverJobAsync()} . + * + * @example samples/V1/VmMigrationClient/create_cutover_job.php + * + * @param CreateCutoverJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCutoverJob(CreateCutoverJobRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateCutoverJob', $request, $callOptions)->wait(); + } + + /** + * Creates a new DatacenterConnector in a given Source. + * + * The async variant is {@see VmMigrationClient::createDatacenterConnectorAsync()} + * . + * + * @example samples/V1/VmMigrationClient/create_datacenter_connector.php + * + * @param CreateDatacenterConnectorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createDatacenterConnector(CreateDatacenterConnectorRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateDatacenterConnector', $request, $callOptions)->wait(); + } + + /** + * Creates a new Group in a given project and location. + * + * The async variant is {@see VmMigrationClient::createGroupAsync()} . + * + * @example samples/V1/VmMigrationClient/create_group.php + * + * @param CreateGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createGroup(CreateGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateGroup', $request, $callOptions)->wait(); + } + + /** + * Creates a new MigratingVm in a given Source. + * + * The async variant is {@see VmMigrationClient::createMigratingVmAsync()} . + * + * @example samples/V1/VmMigrationClient/create_migrating_vm.php + * + * @param CreateMigratingVmRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createMigratingVm(CreateMigratingVmRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateMigratingVm', $request, $callOptions)->wait(); + } + + /** + * Creates a new Source in a given project and location. + * + * The async variant is {@see VmMigrationClient::createSourceAsync()} . + * + * @example samples/V1/VmMigrationClient/create_source.php + * + * @param CreateSourceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSource(CreateSourceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateSource', $request, $callOptions)->wait(); + } + + /** + * Creates a new TargetProject in a given project. + * + * NOTE: TargetProject is a global resource; hence the only supported value + * for location is `global`. + * + * The async variant is {@see VmMigrationClient::createTargetProjectAsync()} . + * + * @example samples/V1/VmMigrationClient/create_target_project.php + * + * @param CreateTargetProjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createTargetProject(CreateTargetProjectRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateTargetProject', $request, $callOptions)->wait(); + } + + /** + * Creates a new UtilizationReport. + * + * The async variant is {@see VmMigrationClient::createUtilizationReportAsync()} . + * + * @example samples/V1/VmMigrationClient/create_utilization_report.php + * + * @param CreateUtilizationReportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createUtilizationReport(CreateUtilizationReportRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateUtilizationReport', $request, $callOptions)->wait(); + } + + /** + * Deletes a single DatacenterConnector. + * + * The async variant is {@see VmMigrationClient::deleteDatacenterConnectorAsync()} + * . + * + * @example samples/V1/VmMigrationClient/delete_datacenter_connector.php + * + * @param DeleteDatacenterConnectorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteDatacenterConnector(DeleteDatacenterConnectorRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteDatacenterConnector', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Group. + * + * The async variant is {@see VmMigrationClient::deleteGroupAsync()} . + * + * @example samples/V1/VmMigrationClient/delete_group.php + * + * @param DeleteGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteGroup(DeleteGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteGroup', $request, $callOptions)->wait(); + } + + /** + * Deletes a single MigratingVm. + * + * The async variant is {@see VmMigrationClient::deleteMigratingVmAsync()} . + * + * @example samples/V1/VmMigrationClient/delete_migrating_vm.php + * + * @param DeleteMigratingVmRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteMigratingVm(DeleteMigratingVmRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteMigratingVm', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Source. + * + * The async variant is {@see VmMigrationClient::deleteSourceAsync()} . + * + * @example samples/V1/VmMigrationClient/delete_source.php + * + * @param DeleteSourceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteSource(DeleteSourceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteSource', $request, $callOptions)->wait(); + } + + /** + * Deletes a single TargetProject. + * + * NOTE: TargetProject is a global resource; hence the only supported value + * for location is `global`. + * + * The async variant is {@see VmMigrationClient::deleteTargetProjectAsync()} . + * + * @example samples/V1/VmMigrationClient/delete_target_project.php + * + * @param DeleteTargetProjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteTargetProject(DeleteTargetProjectRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteTargetProject', $request, $callOptions)->wait(); + } + + /** + * Deletes a single Utilization Report. + * + * The async variant is {@see VmMigrationClient::deleteUtilizationReportAsync()} . + * + * @example samples/V1/VmMigrationClient/delete_utilization_report.php + * + * @param DeleteUtilizationReportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteUtilizationReport(DeleteUtilizationReportRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteUtilizationReport', $request, $callOptions)->wait(); + } + + /** + * List remote source's inventory of VMs. + * The remote source is the onprem vCenter (remote in the sense it's not in + * Compute Engine). The inventory describes the list of existing VMs in that + * source. Note that this operation lists the VMs on the remote source, as + * opposed to listing the MigratingVms resources in the vmmigration service. + * + * The async variant is {@see VmMigrationClient::fetchInventoryAsync()} . + * + * @example samples/V1/VmMigrationClient/fetch_inventory.php + * + * @param FetchInventoryRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 FetchInventoryResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function fetchInventory(FetchInventoryRequest $request, array $callOptions = []): FetchInventoryResponse + { + return $this->startApiCall('FetchInventory', $request, $callOptions)->wait(); + } + + /** + * Marks a migration as completed, deleting migration resources that are no + * longer being used. Only applicable after cutover is done. + * + * The async variant is {@see VmMigrationClient::finalizeMigrationAsync()} . + * + * @example samples/V1/VmMigrationClient/finalize_migration.php + * + * @param FinalizeMigrationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function finalizeMigration(FinalizeMigrationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('FinalizeMigration', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single CloneJob. + * + * The async variant is {@see VmMigrationClient::getCloneJobAsync()} . + * + * @example samples/V1/VmMigrationClient/get_clone_job.php + * + * @param GetCloneJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CloneJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCloneJob(GetCloneJobRequest $request, array $callOptions = []): CloneJob + { + return $this->startApiCall('GetCloneJob', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single CutoverJob. + * + * The async variant is {@see VmMigrationClient::getCutoverJobAsync()} . + * + * @example samples/V1/VmMigrationClient/get_cutover_job.php + * + * @param GetCutoverJobRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 CutoverJob + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCutoverJob(GetCutoverJobRequest $request, array $callOptions = []): CutoverJob + { + return $this->startApiCall('GetCutoverJob', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single DatacenterConnector. + * + * The async variant is {@see VmMigrationClient::getDatacenterConnectorAsync()} . + * + * @example samples/V1/VmMigrationClient/get_datacenter_connector.php + * + * @param GetDatacenterConnectorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 DatacenterConnector + * + * @throws ApiException Thrown if the API call fails. + */ + public function getDatacenterConnector(GetDatacenterConnectorRequest $request, array $callOptions = []): DatacenterConnector + { + return $this->startApiCall('GetDatacenterConnector', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Group. + * + * The async variant is {@see VmMigrationClient::getGroupAsync()} . + * + * @example samples/V1/VmMigrationClient/get_group.php + * + * @param GetGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Group + * + * @throws ApiException Thrown if the API call fails. + */ + public function getGroup(GetGroupRequest $request, array $callOptions = []): Group + { + return $this->startApiCall('GetGroup', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single MigratingVm. + * + * The async variant is {@see VmMigrationClient::getMigratingVmAsync()} . + * + * @example samples/V1/VmMigrationClient/get_migrating_vm.php + * + * @param GetMigratingVmRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 MigratingVm + * + * @throws ApiException Thrown if the API call fails. + */ + public function getMigratingVm(GetMigratingVmRequest $request, array $callOptions = []): MigratingVm + { + return $this->startApiCall('GetMigratingVm', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single ReplicationCycle. + * + * The async variant is {@see VmMigrationClient::getReplicationCycleAsync()} . + * + * @example samples/V1/VmMigrationClient/get_replication_cycle.php + * + * @param GetReplicationCycleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ReplicationCycle + * + * @throws ApiException Thrown if the API call fails. + */ + public function getReplicationCycle(GetReplicationCycleRequest $request, array $callOptions = []): ReplicationCycle + { + return $this->startApiCall('GetReplicationCycle', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single Source. + * + * The async variant is {@see VmMigrationClient::getSourceAsync()} . + * + * @example samples/V1/VmMigrationClient/get_source.php + * + * @param GetSourceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Source + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSource(GetSourceRequest $request, array $callOptions = []): Source + { + return $this->startApiCall('GetSource', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single TargetProject. + * + * NOTE: TargetProject is a global resource; hence the only supported value + * for location is `global`. + * + * The async variant is {@see VmMigrationClient::getTargetProjectAsync()} . + * + * @example samples/V1/VmMigrationClient/get_target_project.php + * + * @param GetTargetProjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TargetProject + * + * @throws ApiException Thrown if the API call fails. + */ + public function getTargetProject(GetTargetProjectRequest $request, array $callOptions = []): TargetProject + { + return $this->startApiCall('GetTargetProject', $request, $callOptions)->wait(); + } + + /** + * Gets a single Utilization Report. + * + * The async variant is {@see VmMigrationClient::getUtilizationReportAsync()} . + * + * @example samples/V1/VmMigrationClient/get_utilization_report.php + * + * @param GetUtilizationReportRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 UtilizationReport + * + * @throws ApiException Thrown if the API call fails. + */ + public function getUtilizationReport(GetUtilizationReportRequest $request, array $callOptions = []): UtilizationReport + { + return $this->startApiCall('GetUtilizationReport', $request, $callOptions)->wait(); + } + + /** + * Lists CloneJobs of a given migrating VM. + * + * The async variant is {@see VmMigrationClient::listCloneJobsAsync()} . + * + * @example samples/V1/VmMigrationClient/list_clone_jobs.php + * + * @param ListCloneJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCloneJobs(ListCloneJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCloneJobs', $request, $callOptions); + } + + /** + * Lists CutoverJobs of a given migrating VM. + * + * The async variant is {@see VmMigrationClient::listCutoverJobsAsync()} . + * + * @example samples/V1/VmMigrationClient/list_cutover_jobs.php + * + * @param ListCutoverJobsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCutoverJobs(ListCutoverJobsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCutoverJobs', $request, $callOptions); + } + + /** + * Lists DatacenterConnectors in a given Source. + * + * The async variant is {@see VmMigrationClient::listDatacenterConnectorsAsync()} . + * + * @example samples/V1/VmMigrationClient/list_datacenter_connectors.php + * + * @param ListDatacenterConnectorsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listDatacenterConnectors(ListDatacenterConnectorsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListDatacenterConnectors', $request, $callOptions); + } + + /** + * Lists Groups in a given project and location. + * + * The async variant is {@see VmMigrationClient::listGroupsAsync()} . + * + * @example samples/V1/VmMigrationClient/list_groups.php + * + * @param ListGroupsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listGroups(ListGroupsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListGroups', $request, $callOptions); + } + + /** + * Lists MigratingVms in a given Source. + * + * The async variant is {@see VmMigrationClient::listMigratingVmsAsync()} . + * + * @example samples/V1/VmMigrationClient/list_migrating_vms.php + * + * @param ListMigratingVmsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listMigratingVms(ListMigratingVmsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListMigratingVms', $request, $callOptions); + } + + /** + * Lists ReplicationCycles in a given MigratingVM. + * + * The async variant is {@see VmMigrationClient::listReplicationCyclesAsync()} . + * + * @example samples/V1/VmMigrationClient/list_replication_cycles.php + * + * @param ListReplicationCyclesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listReplicationCycles(ListReplicationCyclesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListReplicationCycles', $request, $callOptions); + } + + /** + * Lists Sources in a given project and location. + * + * The async variant is {@see VmMigrationClient::listSourcesAsync()} . + * + * @example samples/V1/VmMigrationClient/list_sources.php + * + * @param ListSourcesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSources(ListSourcesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSources', $request, $callOptions); + } + + /** + * Lists TargetProjects in a given project. + * + * NOTE: TargetProject is a global resource; hence the only supported value + * for location is `global`. + * + * The async variant is {@see VmMigrationClient::listTargetProjectsAsync()} . + * + * @example samples/V1/VmMigrationClient/list_target_projects.php + * + * @param ListTargetProjectsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listTargetProjects(ListTargetProjectsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListTargetProjects', $request, $callOptions); + } + + /** + * Lists Utilization Reports of the given Source. + * + * The async variant is {@see VmMigrationClient::listUtilizationReportsAsync()} . + * + * @example samples/V1/VmMigrationClient/list_utilization_reports.php + * + * @param ListUtilizationReportsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listUtilizationReports(ListUtilizationReportsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListUtilizationReports', $request, $callOptions); + } + + /** + * Pauses a migration for a VM. If cycle tasks are running they will be + * cancelled, preserving source task data. Further replication cycles will not + * be triggered while the VM is paused. + * + * The async variant is {@see VmMigrationClient::pauseMigrationAsync()} . + * + * @example samples/V1/VmMigrationClient/pause_migration.php + * + * @param PauseMigrationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function pauseMigration(PauseMigrationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('PauseMigration', $request, $callOptions)->wait(); + } + + /** + * Removes a MigratingVm from a Group. + * + * The async variant is {@see VmMigrationClient::removeGroupMigrationAsync()} . + * + * @example samples/V1/VmMigrationClient/remove_group_migration.php + * + * @param RemoveGroupMigrationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeGroupMigration(RemoveGroupMigrationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('RemoveGroupMigration', $request, $callOptions)->wait(); + } + + /** + * Resumes a migration for a VM. When called on a paused migration, will start + * the process of uploading data and creating snapshots; when called on a + * completed cut-over migration, will update the migration to active state and + * start the process of uploading data and creating snapshots. + * + * The async variant is {@see VmMigrationClient::resumeMigrationAsync()} . + * + * @example samples/V1/VmMigrationClient/resume_migration.php + * + * @param ResumeMigrationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function resumeMigration(ResumeMigrationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ResumeMigration', $request, $callOptions)->wait(); + } + + /** + * Starts migration for a VM. Starts the process of uploading + * data and creating snapshots, in replication cycles scheduled by the policy. + * + * The async variant is {@see VmMigrationClient::startMigrationAsync()} . + * + * @example samples/V1/VmMigrationClient/start_migration.php + * + * @param StartMigrationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function startMigration(StartMigrationRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('StartMigration', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single Group. + * + * The async variant is {@see VmMigrationClient::updateGroupAsync()} . + * + * @example samples/V1/VmMigrationClient/update_group.php + * + * @param UpdateGroupRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateGroup(UpdateGroupRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateGroup', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single MigratingVm. + * + * The async variant is {@see VmMigrationClient::updateMigratingVmAsync()} . + * + * @example samples/V1/VmMigrationClient/update_migrating_vm.php + * + * @param UpdateMigratingVmRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateMigratingVm(UpdateMigratingVmRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateMigratingVm', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single Source. + * + * The async variant is {@see VmMigrationClient::updateSourceAsync()} . + * + * @example samples/V1/VmMigrationClient/update_source.php + * + * @param UpdateSourceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSource(UpdateSourceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateSource', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single TargetProject. + * + * NOTE: TargetProject is a global resource; hence the only supported value + * for location is `global`. + * + * The async variant is {@see VmMigrationClient::updateTargetProjectAsync()} . + * + * @example samples/V1/VmMigrationClient/update_target_project.php + * + * @param UpdateTargetProjectRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateTargetProject(UpdateTargetProjectRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateTargetProject', $request, $callOptions)->wait(); + } + + /** + * Upgrades the appliance relate to this DatacenterConnector to the in-place + * updateable version. + * + * The async variant is {@see VmMigrationClient::upgradeApplianceAsync()} . + * + * @example samples/V1/VmMigrationClient/upgrade_appliance.php + * + * @param UpgradeApplianceRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function upgradeAppliance(UpgradeApplianceRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpgradeAppliance', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see VmMigrationClient::getLocationAsync()} . + * + * @example samples/V1/VmMigrationClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see VmMigrationClient::listLocationsAsync()} . + * + * @example samples/V1/VmMigrationClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/VmwareEngine/composer.json b/VmwareEngine/composer.json index b85d733ae12a..0301b8135571 100644 --- a/VmwareEngine/composer.json +++ b/VmwareEngine/composer.json @@ -19,7 +19,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/VmwareEngine/src/V1/Client/BaseClient/VmwareEngineBaseClient.php b/VmwareEngine/src/V1/Client/BaseClient/VmwareEngineBaseClient.php deleted file mode 100644 index ea7be1f086aa..000000000000 --- a/VmwareEngine/src/V1/Client/BaseClient/VmwareEngineBaseClient.php +++ /dev/null @@ -1,1761 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/vmware_engine_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/vmware_engine_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/vmware_engine_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/vmware_engine_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a cluster - * resource. - * - * @param string $project - * @param string $location - * @param string $privateCloud - * @param string $cluster - * - * @return string The formatted cluster resource. - */ - public static function clusterName(string $project, string $location, string $privateCloud, string $cluster): string - { - return self::getPathTemplate('cluster')->render([ - 'project' => $project, - 'location' => $location, - 'private_cloud' => $privateCloud, - 'cluster' => $cluster, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * hcx_activation_key resource. - * - * @param string $project - * @param string $location - * @param string $privateCloud - * @param string $hcxActivationKey - * - * @return string The formatted hcx_activation_key resource. - */ - public static function hcxActivationKeyName(string $project, string $location, string $privateCloud, string $hcxActivationKey): string - { - return self::getPathTemplate('hcxActivationKey')->render([ - 'project' => $project, - 'location' => $location, - 'private_cloud' => $privateCloud, - 'hcx_activation_key' => $hcxActivationKey, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a network - * resource. - * - * @param string $project - * @param string $network - * - * @return string The formatted network resource. - */ - public static function networkName(string $project, string $network): string - { - return self::getPathTemplate('network')->render([ - 'project' => $project, - 'network' => $network, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * network_policy resource. - * - * @param string $project - * @param string $location - * @param string $networkPolicy - * - * @return string The formatted network_policy resource. - */ - public static function networkPolicyName(string $project, string $location, string $networkPolicy): string - { - return self::getPathTemplate('networkPolicy')->render([ - 'project' => $project, - 'location' => $location, - 'network_policy' => $networkPolicy, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a node_type - * resource. - * - * @param string $project - * @param string $location - * @param string $nodeType - * - * @return string The formatted node_type resource. - */ - public static function nodeTypeName(string $project, string $location, string $nodeType): string - { - return self::getPathTemplate('nodeType')->render([ - 'project' => $project, - 'location' => $location, - 'node_type' => $nodeType, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * private_cloud resource. - * - * @param string $project - * @param string $location - * @param string $privateCloud - * - * @return string The formatted private_cloud resource. - */ - public static function privateCloudName(string $project, string $location, string $privateCloud): string - { - return self::getPathTemplate('privateCloud')->render([ - 'project' => $project, - 'location' => $location, - 'private_cloud' => $privateCloud, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * private_connection resource. - * - * @param string $project - * @param string $location - * @param string $privateConnection - * - * @return string The formatted private_connection resource. - */ - public static function privateConnectionName(string $project, string $location, string $privateConnection): string - { - return self::getPathTemplate('privateConnection')->render([ - 'project' => $project, - 'location' => $location, - 'private_connection' => $privateConnection, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a subnet - * resource. - * - * @param string $project - * @param string $location - * @param string $privateCloud - * @param string $subnet - * - * @return string The formatted subnet resource. - */ - public static function subnetName(string $project, string $location, string $privateCloud, string $subnet): string - { - return self::getPathTemplate('subnet')->render([ - 'project' => $project, - 'location' => $location, - 'private_cloud' => $privateCloud, - 'subnet' => $subnet, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * vmware_engine_network resource. - * - * @param string $project - * @param string $location - * @param string $vmwareEngineNetwork - * - * @return string The formatted vmware_engine_network resource. - */ - public static function vmwareEngineNetworkName(string $project, string $location, string $vmwareEngineNetwork): string - { - return self::getPathTemplate('vmwareEngineNetwork')->render([ - 'project' => $project, - 'location' => $location, - 'vmware_engine_network' => $vmwareEngineNetwork, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - cluster: projects/{project}/locations/{location}/privateClouds/{private_cloud}/clusters/{cluster} - * - hcxActivationKey: projects/{project}/locations/{location}/privateClouds/{private_cloud}/hcxActivationKeys/{hcx_activation_key} - * - location: projects/{project}/locations/{location} - * - network: projects/{project}/global/networks/{network} - * - networkPolicy: projects/{project}/locations/{location}/networkPolicies/{network_policy} - * - nodeType: projects/{project}/locations/{location}/nodeTypes/{node_type} - * - privateCloud: projects/{project}/locations/{location}/privateClouds/{private_cloud} - * - privateConnection: projects/{project}/locations/{location}/privateConnections/{private_connection} - * - subnet: projects/{project}/locations/{location}/privateClouds/{private_cloud}/subnets/{subnet} - * - vmwareEngineNetwork: projects/{project}/locations/{location}/vmwareEngineNetworks/{vmware_engine_network} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'vmwareengine.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new cluster in a given private cloud. - * Creating a new cluster provides additional nodes for - * use in the parent private cloud and requires sufficient [node - * quota](https://cloud.google.com/vmware-engine/quotas). - * - * The async variant is {@see self::createClusterAsync()} . - * - * @example samples/V1/VmwareEngineClient/create_cluster.php - * - * @param CreateClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createCluster(CreateClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateCluster', $request, $callOptions)->wait(); - } - - /** - * Creates a new HCX activation key in a given private cloud. - * - * The async variant is {@see self::createHcxActivationKeyAsync()} . - * - * @example samples/V1/VmwareEngineClient/create_hcx_activation_key.php - * - * @param CreateHcxActivationKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createHcxActivationKey(CreateHcxActivationKeyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateHcxActivationKey', $request, $callOptions)->wait(); - } - - /** - * Creates a new network policy in a given VMware Engine network of a - * project and location (region). A new network policy cannot be created if - * another network policy already exists in the same scope. - * - * The async variant is {@see self::createNetworkPolicyAsync()} . - * - * @example samples/V1/VmwareEngineClient/create_network_policy.php - * - * @param CreateNetworkPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createNetworkPolicy(CreateNetworkPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateNetworkPolicy', $request, $callOptions)->wait(); - } - - /** - * Creates a new `PrivateCloud` resource in a given project and location. - * Private clouds can only be created in zones, regional private clouds are - * not supported. - * - * Creating a private cloud also creates a [management - * cluster](https://cloud.google.com/vmware-engine/docs/concepts-vmware-components) - * for that private cloud. - * - * The async variant is {@see self::createPrivateCloudAsync()} . - * - * @example samples/V1/VmwareEngineClient/create_private_cloud.php - * - * @param CreatePrivateCloudRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createPrivateCloud(CreatePrivateCloudRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreatePrivateCloud', $request, $callOptions)->wait(); - } - - /** - * Creates a new private connection that can be used for accessing private - * Clouds. - * - * The async variant is {@see self::createPrivateConnectionAsync()} . - * - * @example samples/V1/VmwareEngineClient/create_private_connection.php - * - * @param CreatePrivateConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createPrivateConnection(CreatePrivateConnectionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreatePrivateConnection', $request, $callOptions)->wait(); - } - - /** - * Creates a new VMware Engine network that can be used by a private cloud. - * - * The async variant is {@see self::createVmwareEngineNetworkAsync()} . - * - * @example samples/V1/VmwareEngineClient/create_vmware_engine_network.php - * - * @param CreateVmwareEngineNetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createVmwareEngineNetwork(CreateVmwareEngineNetworkRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateVmwareEngineNetwork', $request, $callOptions)->wait(); - } - - /** - * Deletes a `Cluster` resource. To avoid unintended data loss, migrate or - * gracefully shut down any workloads running on the cluster before deletion. - * You cannot delete the management cluster of a private cloud using this - * method. - * - * The async variant is {@see self::deleteClusterAsync()} . - * - * @example samples/V1/VmwareEngineClient/delete_cluster.php - * - * @param DeleteClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteCluster(DeleteClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteCluster', $request, $callOptions)->wait(); - } - - /** - * Deletes a `NetworkPolicy` resource. A network policy cannot be deleted - * when `NetworkService.state` is set to `RECONCILING` for either its external - * IP or internet access service. - * - * The async variant is {@see self::deleteNetworkPolicyAsync()} . - * - * @example samples/V1/VmwareEngineClient/delete_network_policy.php - * - * @param DeleteNetworkPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteNetworkPolicy(DeleteNetworkPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteNetworkPolicy', $request, $callOptions)->wait(); - } - - /** - * Schedules a `PrivateCloud` resource for deletion. - * - * A `PrivateCloud` resource scheduled for deletion has `PrivateCloud.state` - * set to `DELETED` and `expireTime` set to the time when deletion is final - * and can no longer be reversed. The delete operation is marked as done - * as soon as the `PrivateCloud` is successfully scheduled for deletion - * (this also applies when `delayHours` is set to zero), and the operation is - * not kept in pending state until `PrivateCloud` is purged. - * `PrivateCloud` can be restored using `UndeletePrivateCloud` method before - * the `expireTime` elapses. When `expireTime` is reached, deletion is final - * and all private cloud resources are irreversibly removed and billing stops. - * During the final removal process, `PrivateCloud.state` is set to `PURGING`. - * `PrivateCloud` can be polled using standard `GET` method for the whole - * period of deletion and purging. It will not be returned only - * when it is completely purged. - * - * The async variant is {@see self::deletePrivateCloudAsync()} . - * - * @example samples/V1/VmwareEngineClient/delete_private_cloud.php - * - * @param DeletePrivateCloudRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deletePrivateCloud(DeletePrivateCloudRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeletePrivateCloud', $request, $callOptions)->wait(); - } - - /** - * Deletes a `PrivateConnection` resource. When a private connection is - * deleted for a VMware Engine network, the connected network becomes - * inaccessible to that VMware Engine network. - * - * The async variant is {@see self::deletePrivateConnectionAsync()} . - * - * @example samples/V1/VmwareEngineClient/delete_private_connection.php - * - * @param DeletePrivateConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deletePrivateConnection(DeletePrivateConnectionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeletePrivateConnection', $request, $callOptions)->wait(); - } - - /** - * Deletes a `VmwareEngineNetwork` resource. You can only delete a VMware - * Engine network after all resources that refer to it are deleted. For - * example, a private cloud, a network peering, and a network policy can all - * refer to the same VMware Engine network. - * - * The async variant is {@see self::deleteVmwareEngineNetworkAsync()} . - * - * @example samples/V1/VmwareEngineClient/delete_vmware_engine_network.php - * - * @param DeleteVmwareEngineNetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteVmwareEngineNetwork(DeleteVmwareEngineNetworkRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteVmwareEngineNetwork', $request, $callOptions)->wait(); - } - - /** - * Retrieves a `Cluster` resource by its resource name. - * - * The async variant is {@see self::getClusterAsync()} . - * - * @example samples/V1/VmwareEngineClient/get_cluster.php - * - * @param GetClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Cluster - * - * @throws ApiException Thrown if the API call fails. - */ - public function getCluster(GetClusterRequest $request, array $callOptions = []): Cluster - { - return $this->startApiCall('GetCluster', $request, $callOptions)->wait(); - } - - /** - * Retrieves a `HcxActivationKey` resource by its resource name. - * - * The async variant is {@see self::getHcxActivationKeyAsync()} . - * - * @example samples/V1/VmwareEngineClient/get_hcx_activation_key.php - * - * @param GetHcxActivationKeyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 HcxActivationKey - * - * @throws ApiException Thrown if the API call fails. - */ - public function getHcxActivationKey(GetHcxActivationKeyRequest $request, array $callOptions = []): HcxActivationKey - { - return $this->startApiCall('GetHcxActivationKey', $request, $callOptions)->wait(); - } - - /** - * Retrieves a `NetworkPolicy` resource by its resource name. - * - * The async variant is {@see self::getNetworkPolicyAsync()} . - * - * @example samples/V1/VmwareEngineClient/get_network_policy.php - * - * @param GetNetworkPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NetworkPolicy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getNetworkPolicy(GetNetworkPolicyRequest $request, array $callOptions = []): NetworkPolicy - { - return $this->startApiCall('GetNetworkPolicy', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single `NodeType`. - * - * The async variant is {@see self::getNodeTypeAsync()} . - * - * @example samples/V1/VmwareEngineClient/get_node_type.php - * - * @param GetNodeTypeRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 NodeType - * - * @throws ApiException Thrown if the API call fails. - */ - public function getNodeType(GetNodeTypeRequest $request, array $callOptions = []): NodeType - { - return $this->startApiCall('GetNodeType', $request, $callOptions)->wait(); - } - - /** - * Retrieves a `PrivateCloud` resource by its resource name. - * - * The async variant is {@see self::getPrivateCloudAsync()} . - * - * @example samples/V1/VmwareEngineClient/get_private_cloud.php - * - * @param GetPrivateCloudRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PrivateCloud - * - * @throws ApiException Thrown if the API call fails. - */ - public function getPrivateCloud(GetPrivateCloudRequest $request, array $callOptions = []): PrivateCloud - { - return $this->startApiCall('GetPrivateCloud', $request, $callOptions)->wait(); - } - - /** - * Retrieves a `PrivateConnection` resource by its resource name. The resource - * contains details of the private connection, such as connected - * network, routing mode and state. - * - * The async variant is {@see self::getPrivateConnectionAsync()} . - * - * @example samples/V1/VmwareEngineClient/get_private_connection.php - * - * @param GetPrivateConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PrivateConnection - * - * @throws ApiException Thrown if the API call fails. - */ - public function getPrivateConnection(GetPrivateConnectionRequest $request, array $callOptions = []): PrivateConnection - { - return $this->startApiCall('GetPrivateConnection', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single subnet. - * - * The async variant is {@see self::getSubnetAsync()} . - * - * @example samples/V1/VmwareEngineClient/get_subnet.php - * - * @param GetSubnetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Subnet - * - * @throws ApiException Thrown if the API call fails. - */ - public function getSubnet(GetSubnetRequest $request, array $callOptions = []): Subnet - { - return $this->startApiCall('GetSubnet', $request, $callOptions)->wait(); - } - - /** - * Retrieves a `VmwareEngineNetwork` resource by its resource name. The - * resource contains details of the VMware Engine network, such as its VMware - * Engine network type, peered networks in a service project, and state - * (for example, `CREATING`, `ACTIVE`, `DELETING`). - * - * The async variant is {@see self::getVmwareEngineNetworkAsync()} . - * - * @example samples/V1/VmwareEngineClient/get_vmware_engine_network.php - * - * @param GetVmwareEngineNetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 VmwareEngineNetwork - * - * @throws ApiException Thrown if the API call fails. - */ - public function getVmwareEngineNetwork(GetVmwareEngineNetworkRequest $request, array $callOptions = []): VmwareEngineNetwork - { - return $this->startApiCall('GetVmwareEngineNetwork', $request, $callOptions)->wait(); - } - - /** - * Lists `Cluster` resources in a given private cloud. - * - * The async variant is {@see self::listClustersAsync()} . - * - * @example samples/V1/VmwareEngineClient/list_clusters.php - * - * @param ListClustersRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listClusters(ListClustersRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListClusters', $request, $callOptions); - } - - /** - * Lists `HcxActivationKey` resources in a given private cloud. - * - * The async variant is {@see self::listHcxActivationKeysAsync()} . - * - * @example samples/V1/VmwareEngineClient/list_hcx_activation_keys.php - * - * @param ListHcxActivationKeysRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listHcxActivationKeys(ListHcxActivationKeysRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListHcxActivationKeys', $request, $callOptions); - } - - /** - * Lists `NetworkPolicy` resources in a specified project and location. - * - * The async variant is {@see self::listNetworkPoliciesAsync()} . - * - * @example samples/V1/VmwareEngineClient/list_network_policies.php - * - * @param ListNetworkPoliciesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listNetworkPolicies(ListNetworkPoliciesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListNetworkPolicies', $request, $callOptions); - } - - /** - * Lists node types - * - * The async variant is {@see self::listNodeTypesAsync()} . - * - * @example samples/V1/VmwareEngineClient/list_node_types.php - * - * @param ListNodeTypesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listNodeTypes(ListNodeTypesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListNodeTypes', $request, $callOptions); - } - - /** - * Lists `PrivateCloud` resources in a given project and location. - * - * The async variant is {@see self::listPrivateCloudsAsync()} . - * - * @example samples/V1/VmwareEngineClient/list_private_clouds.php - * - * @param ListPrivateCloudsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPrivateClouds(ListPrivateCloudsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPrivateClouds', $request, $callOptions); - } - - /** - * Lists the private connection routes exchanged over a peering connection. - * - * The async variant is {@see self::listPrivateConnectionPeeringRoutesAsync()} . - * - * @example samples/V1/VmwareEngineClient/list_private_connection_peering_routes.php - * - * @param ListPrivateConnectionPeeringRoutesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPrivateConnectionPeeringRoutes(ListPrivateConnectionPeeringRoutesRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPrivateConnectionPeeringRoutes', $request, $callOptions); - } - - /** - * Lists `PrivateConnection` resources in a given project and location. - * - * The async variant is {@see self::listPrivateConnectionsAsync()} . - * - * @example samples/V1/VmwareEngineClient/list_private_connections.php - * - * @param ListPrivateConnectionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listPrivateConnections(ListPrivateConnectionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListPrivateConnections', $request, $callOptions); - } - - /** - * Lists subnets in a given private cloud. - * - * The async variant is {@see self::listSubnetsAsync()} . - * - * @example samples/V1/VmwareEngineClient/list_subnets.php - * - * @param ListSubnetsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listSubnets(ListSubnetsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListSubnets', $request, $callOptions); - } - - /** - * Lists `VmwareEngineNetwork` resources in a given project and location. - * - * The async variant is {@see self::listVmwareEngineNetworksAsync()} . - * - * @example samples/V1/VmwareEngineClient/list_vmware_engine_networks.php - * - * @param ListVmwareEngineNetworksRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listVmwareEngineNetworks(ListVmwareEngineNetworksRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListVmwareEngineNetworks', $request, $callOptions); - } - - /** - * Resets credentials of the NSX appliance. - * - * The async variant is {@see self::resetNsxCredentialsAsync()} . - * - * @example samples/V1/VmwareEngineClient/reset_nsx_credentials.php - * - * @param ResetNsxCredentialsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function resetNsxCredentials(ResetNsxCredentialsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ResetNsxCredentials', $request, $callOptions)->wait(); - } - - /** - * Resets credentials of the Vcenter appliance. - * - * The async variant is {@see self::resetVcenterCredentialsAsync()} . - * - * @example samples/V1/VmwareEngineClient/reset_vcenter_credentials.php - * - * @param ResetVcenterCredentialsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function resetVcenterCredentials(ResetVcenterCredentialsRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('ResetVcenterCredentials', $request, $callOptions)->wait(); - } - - /** - * Gets details of credentials for NSX appliance. - * - * The async variant is {@see self::showNsxCredentialsAsync()} . - * - * @example samples/V1/VmwareEngineClient/show_nsx_credentials.php - * - * @param ShowNsxCredentialsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Credentials - * - * @throws ApiException Thrown if the API call fails. - */ - public function showNsxCredentials(ShowNsxCredentialsRequest $request, array $callOptions = []): Credentials - { - return $this->startApiCall('ShowNsxCredentials', $request, $callOptions)->wait(); - } - - /** - * Gets details of credentials for Vcenter appliance. - * - * The async variant is {@see self::showVcenterCredentialsAsync()} . - * - * @example samples/V1/VmwareEngineClient/show_vcenter_credentials.php - * - * @param ShowVcenterCredentialsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Credentials - * - * @throws ApiException Thrown if the API call fails. - */ - public function showVcenterCredentials(ShowVcenterCredentialsRequest $request, array $callOptions = []): Credentials - { - return $this->startApiCall('ShowVcenterCredentials', $request, $callOptions)->wait(); - } - - /** - * Restores a private cloud that was previously scheduled for deletion by - * `DeletePrivateCloud`. A `PrivateCloud` resource scheduled for deletion has - * `PrivateCloud.state` set to `DELETED` and `PrivateCloud.expireTime` set to - * the time when deletion can no longer be reversed. - * - * The async variant is {@see self::undeletePrivateCloudAsync()} . - * - * @example samples/V1/VmwareEngineClient/undelete_private_cloud.php - * - * @param UndeletePrivateCloudRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function undeletePrivateCloud(UndeletePrivateCloudRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UndeletePrivateCloud', $request, $callOptions)->wait(); - } - - /** - * Modifies a `Cluster` resource. Only the following fields can be updated: - * `node_type_configs.*.node_count`. Only fields specified in `updateMask` are - * applied. - * - * During operation processing, the resource is temporarily in the `ACTIVE` - * state before the operation fully completes. For that period of time, you - * can't update the resource. Use the operation status to determine when the - * processing fully completes. - * - * The async variant is {@see self::updateClusterAsync()} . - * - * @example samples/V1/VmwareEngineClient/update_cluster.php - * - * @param UpdateClusterRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateCluster(UpdateClusterRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateCluster', $request, $callOptions)->wait(); - } - - /** - * Modifies a `NetworkPolicy` resource. Only the following fields can be - * updated: `internet_access`, `external_ip`, `edge_services_cidr`. - * Only fields specified in `updateMask` are applied. When updating a network - * policy, the external IP network service can only be disabled if there are - * no external IP addresses present in the scope of the policy. Also, a - * `NetworkService` cannot be updated when `NetworkService.state` is set - * to `RECONCILING`. - * - * During operation processing, the resource is temporarily in the `ACTIVE` - * state before the operation fully completes. For that period of time, you - * can't update the resource. Use the operation status to determine when the - * processing fully completes. - * - * The async variant is {@see self::updateNetworkPolicyAsync()} . - * - * @example samples/V1/VmwareEngineClient/update_network_policy.php - * - * @param UpdateNetworkPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateNetworkPolicy(UpdateNetworkPolicyRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateNetworkPolicy', $request, $callOptions)->wait(); - } - - /** - * Modifies a `PrivateCloud` resource. Only the following fields can be - * updated: `description`. - * Only fields specified in `updateMask` are applied. - * - * During operation processing, the resource is temporarily in the `ACTIVE` - * state before the operation fully completes. For that period of time, you - * can't update the resource. Use the operation status to determine when the - * processing fully completes. - * - * The async variant is {@see self::updatePrivateCloudAsync()} . - * - * @example samples/V1/VmwareEngineClient/update_private_cloud.php - * - * @param UpdatePrivateCloudRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updatePrivateCloud(UpdatePrivateCloudRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdatePrivateCloud', $request, $callOptions)->wait(); - } - - /** - * Modifies a `PrivateConnection` resource. Only `description` and - * `routing_mode` fields can be updated. Only fields specified in `updateMask` - * are applied. - * - * The async variant is {@see self::updatePrivateConnectionAsync()} . - * - * @example samples/V1/VmwareEngineClient/update_private_connection.php - * - * @param UpdatePrivateConnectionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updatePrivateConnection(UpdatePrivateConnectionRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdatePrivateConnection', $request, $callOptions)->wait(); - } - - /** - * Updates the parameters of a single subnet. Only fields specified in - * `update_mask` are applied. - * - * *Note*: This API is synchronous and always returns a successful - * `google.longrunning.Operation` (LRO). The returned LRO will only have - * `done` and `response` fields. - * - * The async variant is {@see self::updateSubnetAsync()} . - * - * @example samples/V1/VmwareEngineClient/update_subnet.php - * - * @param UpdateSubnetRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateSubnet(UpdateSubnetRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateSubnet', $request, $callOptions)->wait(); - } - - /** - * Modifies a VMware Engine network resource. Only the following fields can be - * updated: `description`. Only fields specified in `updateMask` are - * applied. - * - * The async variant is {@see self::updateVmwareEngineNetworkAsync()} . - * - * @example samples/V1/VmwareEngineClient/update_vmware_engine_network.php - * - * @param UpdateVmwareEngineNetworkRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateVmwareEngineNetwork(UpdateVmwareEngineNetworkRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateVmwareEngineNetwork', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/VmwareEngineClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/VmwareEngineClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } - - /** - * Gets the access control policy for a resource. Returns an empty policy - if the resource exists and does not have a policy set. - * - * The async variant is {@see self::getIamPolicyAsync()} . - * - * @example samples/V1/VmwareEngineClient/get_iam_policy.php - * - * @param GetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Sets the access control policy on the specified resource. Replaces - any existing policy. - - Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` - errors. - * - * The async variant is {@see self::setIamPolicyAsync()} . - * - * @example samples/V1/VmwareEngineClient/set_iam_policy.php - * - * @param SetIamPolicyRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Policy - * - * @throws ApiException Thrown if the API call fails. - */ - public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy - { - return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); - } - - /** - * Returns permissions that a caller has on the specified resource. If the - resource does not exist, this will return an empty set of - permissions, not a `NOT_FOUND` error. - - Note: This operation is designed to be used for building - permission-aware UIs and command-line tools, not for authorization - checking. This operation may "fail open" without warning. - * - * The async variant is {@see self::testIamPermissionsAsync()} . - * - * @example samples/V1/VmwareEngineClient/test_iam_permissions.php - * - * @param TestIamPermissionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 TestIamPermissionsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse - { - return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); - } -} diff --git a/VmwareEngine/src/V1/Client/VmwareEngineClient.php b/VmwareEngine/src/V1/Client/VmwareEngineClient.php index e10617998cd4..ce297e63ffde 100644 --- a/VmwareEngine/src/V1/Client/VmwareEngineClient.php +++ b/VmwareEngine/src/V1/Client/VmwareEngineClient.php @@ -24,17 +24,1741 @@ namespace Google\Cloud\VmwareEngine\V1\Client; -use Google\Cloud\VmwareEngine\V1\Client\BaseClient\VmwareEngineBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Iam\V1\GetIamPolicyRequest; +use Google\Cloud\Iam\V1\Policy; +use Google\Cloud\Iam\V1\SetIamPolicyRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsRequest; +use Google\Cloud\Iam\V1\TestIamPermissionsResponse; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\VmwareEngine\V1\Cluster; +use Google\Cloud\VmwareEngine\V1\CreateClusterRequest; +use Google\Cloud\VmwareEngine\V1\CreateHcxActivationKeyRequest; +use Google\Cloud\VmwareEngine\V1\CreateNetworkPolicyRequest; +use Google\Cloud\VmwareEngine\V1\CreatePrivateCloudRequest; +use Google\Cloud\VmwareEngine\V1\CreatePrivateConnectionRequest; +use Google\Cloud\VmwareEngine\V1\CreateVmwareEngineNetworkRequest; +use Google\Cloud\VmwareEngine\V1\Credentials; +use Google\Cloud\VmwareEngine\V1\DeleteClusterRequest; +use Google\Cloud\VmwareEngine\V1\DeleteNetworkPolicyRequest; +use Google\Cloud\VmwareEngine\V1\DeletePrivateCloudRequest; +use Google\Cloud\VmwareEngine\V1\DeletePrivateConnectionRequest; +use Google\Cloud\VmwareEngine\V1\DeleteVmwareEngineNetworkRequest; +use Google\Cloud\VmwareEngine\V1\GetClusterRequest; +use Google\Cloud\VmwareEngine\V1\GetHcxActivationKeyRequest; +use Google\Cloud\VmwareEngine\V1\GetNetworkPolicyRequest; +use Google\Cloud\VmwareEngine\V1\GetNodeTypeRequest; +use Google\Cloud\VmwareEngine\V1\GetPrivateCloudRequest; +use Google\Cloud\VmwareEngine\V1\GetPrivateConnectionRequest; +use Google\Cloud\VmwareEngine\V1\GetSubnetRequest; +use Google\Cloud\VmwareEngine\V1\GetVmwareEngineNetworkRequest; +use Google\Cloud\VmwareEngine\V1\HcxActivationKey; +use Google\Cloud\VmwareEngine\V1\ListClustersRequest; +use Google\Cloud\VmwareEngine\V1\ListHcxActivationKeysRequest; +use Google\Cloud\VmwareEngine\V1\ListNetworkPoliciesRequest; +use Google\Cloud\VmwareEngine\V1\ListNodeTypesRequest; +use Google\Cloud\VmwareEngine\V1\ListPrivateCloudsRequest; +use Google\Cloud\VmwareEngine\V1\ListPrivateConnectionPeeringRoutesRequest; +use Google\Cloud\VmwareEngine\V1\ListPrivateConnectionsRequest; +use Google\Cloud\VmwareEngine\V1\ListSubnetsRequest; +use Google\Cloud\VmwareEngine\V1\ListVmwareEngineNetworksRequest; +use Google\Cloud\VmwareEngine\V1\NetworkPolicy; +use Google\Cloud\VmwareEngine\V1\NodeType; +use Google\Cloud\VmwareEngine\V1\PrivateCloud; +use Google\Cloud\VmwareEngine\V1\PrivateConnection; +use Google\Cloud\VmwareEngine\V1\ResetNsxCredentialsRequest; +use Google\Cloud\VmwareEngine\V1\ResetVcenterCredentialsRequest; +use Google\Cloud\VmwareEngine\V1\ShowNsxCredentialsRequest; +use Google\Cloud\VmwareEngine\V1\ShowVcenterCredentialsRequest; +use Google\Cloud\VmwareEngine\V1\Subnet; +use Google\Cloud\VmwareEngine\V1\UndeletePrivateCloudRequest; +use Google\Cloud\VmwareEngine\V1\UpdateClusterRequest; +use Google\Cloud\VmwareEngine\V1\UpdateNetworkPolicyRequest; +use Google\Cloud\VmwareEngine\V1\UpdatePrivateCloudRequest; +use Google\Cloud\VmwareEngine\V1\UpdatePrivateConnectionRequest; +use Google\Cloud\VmwareEngine\V1\UpdateSubnetRequest; +use Google\Cloud\VmwareEngine\V1\UpdateVmwareEngineNetworkRequest; +use Google\Cloud\VmwareEngine\V1\VmwareEngineNetwork; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: VMwareEngine manages VMware's private clusters in the Cloud. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\VmwareEngine\V1\VmwareEngineClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createClusterAsync(CreateClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface createHcxActivationKeyAsync(CreateHcxActivationKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface createNetworkPolicyAsync(CreateNetworkPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface createPrivateCloudAsync(CreatePrivateCloudRequest $request, array $optionalArgs = []) + * @method PromiseInterface createPrivateConnectionAsync(CreatePrivateConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface createVmwareEngineNetworkAsync(CreateVmwareEngineNetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteClusterAsync(DeleteClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteNetworkPolicyAsync(DeleteNetworkPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface deletePrivateCloudAsync(DeletePrivateCloudRequest $request, array $optionalArgs = []) + * @method PromiseInterface deletePrivateConnectionAsync(DeletePrivateConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteVmwareEngineNetworkAsync(DeleteVmwareEngineNetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface getClusterAsync(GetClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface getHcxActivationKeyAsync(GetHcxActivationKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getNetworkPolicyAsync(GetNetworkPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface getNodeTypeAsync(GetNodeTypeRequest $request, array $optionalArgs = []) + * @method PromiseInterface getPrivateCloudAsync(GetPrivateCloudRequest $request, array $optionalArgs = []) + * @method PromiseInterface getPrivateConnectionAsync(GetPrivateConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getSubnetAsync(GetSubnetRequest $request, array $optionalArgs = []) + * @method PromiseInterface getVmwareEngineNetworkAsync(GetVmwareEngineNetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface listClustersAsync(ListClustersRequest $request, array $optionalArgs = []) + * @method PromiseInterface listHcxActivationKeysAsync(ListHcxActivationKeysRequest $request, array $optionalArgs = []) + * @method PromiseInterface listNetworkPoliciesAsync(ListNetworkPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listNodeTypesAsync(ListNodeTypesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPrivateCloudsAsync(ListPrivateCloudsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPrivateConnectionPeeringRoutesAsync(ListPrivateConnectionPeeringRoutesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listPrivateConnectionsAsync(ListPrivateConnectionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listSubnetsAsync(ListSubnetsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listVmwareEngineNetworksAsync(ListVmwareEngineNetworksRequest $request, array $optionalArgs = []) + * @method PromiseInterface resetNsxCredentialsAsync(ResetNsxCredentialsRequest $request, array $optionalArgs = []) + * @method PromiseInterface resetVcenterCredentialsAsync(ResetVcenterCredentialsRequest $request, array $optionalArgs = []) + * @method PromiseInterface showNsxCredentialsAsync(ShowNsxCredentialsRequest $request, array $optionalArgs = []) + * @method PromiseInterface showVcenterCredentialsAsync(ShowVcenterCredentialsRequest $request, array $optionalArgs = []) + * @method PromiseInterface undeletePrivateCloudAsync(UndeletePrivateCloudRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateClusterAsync(UpdateClusterRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateNetworkPolicyAsync(UpdateNetworkPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface updatePrivateCloudAsync(UpdatePrivateCloudRequest $request, array $optionalArgs = []) + * @method PromiseInterface updatePrivateConnectionAsync(UpdatePrivateConnectionRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateSubnetAsync(UpdateSubnetRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateVmwareEngineNetworkAsync(UpdateVmwareEngineNetworkRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) */ -final class VmwareEngineClient extends VmwareEngineBaseClient +final class VmwareEngineClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see VmwareEngineBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.vmwareengine.v1.VmwareEngine'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'vmwareengine.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/vmware_engine_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/vmware_engine_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/vmware_engine_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/vmware_engine_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a cluster + * resource. + * + * @param string $project + * @param string $location + * @param string $privateCloud + * @param string $cluster + * + * @return string The formatted cluster resource. + */ + public static function clusterName(string $project, string $location, string $privateCloud, string $cluster): string + { + return self::getPathTemplate('cluster')->render([ + 'project' => $project, + 'location' => $location, + 'private_cloud' => $privateCloud, + 'cluster' => $cluster, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * hcx_activation_key resource. + * + * @param string $project + * @param string $location + * @param string $privateCloud + * @param string $hcxActivationKey + * + * @return string The formatted hcx_activation_key resource. + */ + public static function hcxActivationKeyName(string $project, string $location, string $privateCloud, string $hcxActivationKey): string + { + return self::getPathTemplate('hcxActivationKey')->render([ + 'project' => $project, + 'location' => $location, + 'private_cloud' => $privateCloud, + 'hcx_activation_key' => $hcxActivationKey, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a network + * resource. + * + * @param string $project + * @param string $network + * + * @return string The formatted network resource. + */ + public static function networkName(string $project, string $network): string + { + return self::getPathTemplate('network')->render([ + 'project' => $project, + 'network' => $network, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * network_policy resource. + * + * @param string $project + * @param string $location + * @param string $networkPolicy + * + * @return string The formatted network_policy resource. + */ + public static function networkPolicyName(string $project, string $location, string $networkPolicy): string + { + return self::getPathTemplate('networkPolicy')->render([ + 'project' => $project, + 'location' => $location, + 'network_policy' => $networkPolicy, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a node_type + * resource. + * + * @param string $project + * @param string $location + * @param string $nodeType + * + * @return string The formatted node_type resource. + */ + public static function nodeTypeName(string $project, string $location, string $nodeType): string + { + return self::getPathTemplate('nodeType')->render([ + 'project' => $project, + 'location' => $location, + 'node_type' => $nodeType, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * private_cloud resource. + * + * @param string $project + * @param string $location + * @param string $privateCloud + * + * @return string The formatted private_cloud resource. + */ + public static function privateCloudName(string $project, string $location, string $privateCloud): string + { + return self::getPathTemplate('privateCloud')->render([ + 'project' => $project, + 'location' => $location, + 'private_cloud' => $privateCloud, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * private_connection resource. + * + * @param string $project + * @param string $location + * @param string $privateConnection + * + * @return string The formatted private_connection resource. + */ + public static function privateConnectionName(string $project, string $location, string $privateConnection): string + { + return self::getPathTemplate('privateConnection')->render([ + 'project' => $project, + 'location' => $location, + 'private_connection' => $privateConnection, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a subnet + * resource. + * + * @param string $project + * @param string $location + * @param string $privateCloud + * @param string $subnet + * + * @return string The formatted subnet resource. + */ + public static function subnetName(string $project, string $location, string $privateCloud, string $subnet): string + { + return self::getPathTemplate('subnet')->render([ + 'project' => $project, + 'location' => $location, + 'private_cloud' => $privateCloud, + 'subnet' => $subnet, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * vmware_engine_network resource. + * + * @param string $project + * @param string $location + * @param string $vmwareEngineNetwork + * + * @return string The formatted vmware_engine_network resource. + */ + public static function vmwareEngineNetworkName(string $project, string $location, string $vmwareEngineNetwork): string + { + return self::getPathTemplate('vmwareEngineNetwork')->render([ + 'project' => $project, + 'location' => $location, + 'vmware_engine_network' => $vmwareEngineNetwork, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - cluster: projects/{project}/locations/{location}/privateClouds/{private_cloud}/clusters/{cluster} + * - hcxActivationKey: projects/{project}/locations/{location}/privateClouds/{private_cloud}/hcxActivationKeys/{hcx_activation_key} + * - location: projects/{project}/locations/{location} + * - network: projects/{project}/global/networks/{network} + * - networkPolicy: projects/{project}/locations/{location}/networkPolicies/{network_policy} + * - nodeType: projects/{project}/locations/{location}/nodeTypes/{node_type} + * - privateCloud: projects/{project}/locations/{location}/privateClouds/{private_cloud} + * - privateConnection: projects/{project}/locations/{location}/privateConnections/{private_connection} + * - subnet: projects/{project}/locations/{location}/privateClouds/{private_cloud}/subnets/{subnet} + * - vmwareEngineNetwork: projects/{project}/locations/{location}/vmwareEngineNetworks/{vmware_engine_network} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'vmwareengine.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new cluster in a given private cloud. + * Creating a new cluster provides additional nodes for + * use in the parent private cloud and requires sufficient [node + * quota](https://cloud.google.com/vmware-engine/quotas). + * + * The async variant is {@see VmwareEngineClient::createClusterAsync()} . + * + * @example samples/V1/VmwareEngineClient/create_cluster.php + * + * @param CreateClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createCluster(CreateClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateCluster', $request, $callOptions)->wait(); + } + + /** + * Creates a new HCX activation key in a given private cloud. + * + * The async variant is {@see VmwareEngineClient::createHcxActivationKeyAsync()} . + * + * @example samples/V1/VmwareEngineClient/create_hcx_activation_key.php + * + * @param CreateHcxActivationKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createHcxActivationKey(CreateHcxActivationKeyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateHcxActivationKey', $request, $callOptions)->wait(); + } + + /** + * Creates a new network policy in a given VMware Engine network of a + * project and location (region). A new network policy cannot be created if + * another network policy already exists in the same scope. + * + * The async variant is {@see VmwareEngineClient::createNetworkPolicyAsync()} . + * + * @example samples/V1/VmwareEngineClient/create_network_policy.php + * + * @param CreateNetworkPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createNetworkPolicy(CreateNetworkPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateNetworkPolicy', $request, $callOptions)->wait(); + } + + /** + * Creates a new `PrivateCloud` resource in a given project and location. + * Private clouds can only be created in zones, regional private clouds are + * not supported. + * + * Creating a private cloud also creates a [management + * cluster](https://cloud.google.com/vmware-engine/docs/concepts-vmware-components) + * for that private cloud. + * + * The async variant is {@see VmwareEngineClient::createPrivateCloudAsync()} . + * + * @example samples/V1/VmwareEngineClient/create_private_cloud.php + * + * @param CreatePrivateCloudRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createPrivateCloud(CreatePrivateCloudRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreatePrivateCloud', $request, $callOptions)->wait(); + } + + /** + * Creates a new private connection that can be used for accessing private + * Clouds. + * + * The async variant is {@see VmwareEngineClient::createPrivateConnectionAsync()} . + * + * @example samples/V1/VmwareEngineClient/create_private_connection.php + * + * @param CreatePrivateConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createPrivateConnection(CreatePrivateConnectionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreatePrivateConnection', $request, $callOptions)->wait(); + } + + /** + * Creates a new VMware Engine network that can be used by a private cloud. + * + * The async variant is {@see VmwareEngineClient::createVmwareEngineNetworkAsync()} + * . + * + * @example samples/V1/VmwareEngineClient/create_vmware_engine_network.php + * + * @param CreateVmwareEngineNetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createVmwareEngineNetwork(CreateVmwareEngineNetworkRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateVmwareEngineNetwork', $request, $callOptions)->wait(); + } + + /** + * Deletes a `Cluster` resource. To avoid unintended data loss, migrate or + * gracefully shut down any workloads running on the cluster before deletion. + * You cannot delete the management cluster of a private cloud using this + * method. + * + * The async variant is {@see VmwareEngineClient::deleteClusterAsync()} . + * + * @example samples/V1/VmwareEngineClient/delete_cluster.php + * + * @param DeleteClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteCluster(DeleteClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteCluster', $request, $callOptions)->wait(); + } + + /** + * Deletes a `NetworkPolicy` resource. A network policy cannot be deleted + * when `NetworkService.state` is set to `RECONCILING` for either its external + * IP or internet access service. + * + * The async variant is {@see VmwareEngineClient::deleteNetworkPolicyAsync()} . + * + * @example samples/V1/VmwareEngineClient/delete_network_policy.php + * + * @param DeleteNetworkPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteNetworkPolicy(DeleteNetworkPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteNetworkPolicy', $request, $callOptions)->wait(); + } + + /** + * Schedules a `PrivateCloud` resource for deletion. + * + * A `PrivateCloud` resource scheduled for deletion has `PrivateCloud.state` + * set to `DELETED` and `expireTime` set to the time when deletion is final + * and can no longer be reversed. The delete operation is marked as done + * as soon as the `PrivateCloud` is successfully scheduled for deletion + * (this also applies when `delayHours` is set to zero), and the operation is + * not kept in pending state until `PrivateCloud` is purged. + * `PrivateCloud` can be restored using `UndeletePrivateCloud` method before + * the `expireTime` elapses. When `expireTime` is reached, deletion is final + * and all private cloud resources are irreversibly removed and billing stops. + * During the final removal process, `PrivateCloud.state` is set to `PURGING`. + * `PrivateCloud` can be polled using standard `GET` method for the whole + * period of deletion and purging. It will not be returned only + * when it is completely purged. + * + * The async variant is {@see VmwareEngineClient::deletePrivateCloudAsync()} . + * + * @example samples/V1/VmwareEngineClient/delete_private_cloud.php + * + * @param DeletePrivateCloudRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deletePrivateCloud(DeletePrivateCloudRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeletePrivateCloud', $request, $callOptions)->wait(); + } + + /** + * Deletes a `PrivateConnection` resource. When a private connection is + * deleted for a VMware Engine network, the connected network becomes + * inaccessible to that VMware Engine network. + * + * The async variant is {@see VmwareEngineClient::deletePrivateConnectionAsync()} . + * + * @example samples/V1/VmwareEngineClient/delete_private_connection.php + * + * @param DeletePrivateConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deletePrivateConnection(DeletePrivateConnectionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeletePrivateConnection', $request, $callOptions)->wait(); + } + + /** + * Deletes a `VmwareEngineNetwork` resource. You can only delete a VMware + * Engine network after all resources that refer to it are deleted. For + * example, a private cloud, a network peering, and a network policy can all + * refer to the same VMware Engine network. + * + * The async variant is {@see VmwareEngineClient::deleteVmwareEngineNetworkAsync()} + * . + * + * @example samples/V1/VmwareEngineClient/delete_vmware_engine_network.php + * + * @param DeleteVmwareEngineNetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteVmwareEngineNetwork(DeleteVmwareEngineNetworkRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteVmwareEngineNetwork', $request, $callOptions)->wait(); + } + + /** + * Retrieves a `Cluster` resource by its resource name. + * + * The async variant is {@see VmwareEngineClient::getClusterAsync()} . + * + * @example samples/V1/VmwareEngineClient/get_cluster.php + * + * @param GetClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Cluster + * + * @throws ApiException Thrown if the API call fails. + */ + public function getCluster(GetClusterRequest $request, array $callOptions = []): Cluster + { + return $this->startApiCall('GetCluster', $request, $callOptions)->wait(); + } + + /** + * Retrieves a `HcxActivationKey` resource by its resource name. + * + * The async variant is {@see VmwareEngineClient::getHcxActivationKeyAsync()} . + * + * @example samples/V1/VmwareEngineClient/get_hcx_activation_key.php + * + * @param GetHcxActivationKeyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 HcxActivationKey + * + * @throws ApiException Thrown if the API call fails. + */ + public function getHcxActivationKey(GetHcxActivationKeyRequest $request, array $callOptions = []): HcxActivationKey + { + return $this->startApiCall('GetHcxActivationKey', $request, $callOptions)->wait(); + } + + /** + * Retrieves a `NetworkPolicy` resource by its resource name. + * + * The async variant is {@see VmwareEngineClient::getNetworkPolicyAsync()} . + * + * @example samples/V1/VmwareEngineClient/get_network_policy.php + * + * @param GetNetworkPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NetworkPolicy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getNetworkPolicy(GetNetworkPolicyRequest $request, array $callOptions = []): NetworkPolicy + { + return $this->startApiCall('GetNetworkPolicy', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single `NodeType`. + * + * The async variant is {@see VmwareEngineClient::getNodeTypeAsync()} . + * + * @example samples/V1/VmwareEngineClient/get_node_type.php + * + * @param GetNodeTypeRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 NodeType + * + * @throws ApiException Thrown if the API call fails. + */ + public function getNodeType(GetNodeTypeRequest $request, array $callOptions = []): NodeType + { + return $this->startApiCall('GetNodeType', $request, $callOptions)->wait(); + } + + /** + * Retrieves a `PrivateCloud` resource by its resource name. + * + * The async variant is {@see VmwareEngineClient::getPrivateCloudAsync()} . + * + * @example samples/V1/VmwareEngineClient/get_private_cloud.php + * + * @param GetPrivateCloudRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PrivateCloud + * + * @throws ApiException Thrown if the API call fails. + */ + public function getPrivateCloud(GetPrivateCloudRequest $request, array $callOptions = []): PrivateCloud + { + return $this->startApiCall('GetPrivateCloud', $request, $callOptions)->wait(); + } + + /** + * Retrieves a `PrivateConnection` resource by its resource name. The resource + * contains details of the private connection, such as connected + * network, routing mode and state. + * + * The async variant is {@see VmwareEngineClient::getPrivateConnectionAsync()} . + * + * @example samples/V1/VmwareEngineClient/get_private_connection.php + * + * @param GetPrivateConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PrivateConnection + * + * @throws ApiException Thrown if the API call fails. + */ + public function getPrivateConnection(GetPrivateConnectionRequest $request, array $callOptions = []): PrivateConnection + { + return $this->startApiCall('GetPrivateConnection', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single subnet. + * + * The async variant is {@see VmwareEngineClient::getSubnetAsync()} . + * + * @example samples/V1/VmwareEngineClient/get_subnet.php + * + * @param GetSubnetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Subnet + * + * @throws ApiException Thrown if the API call fails. + */ + public function getSubnet(GetSubnetRequest $request, array $callOptions = []): Subnet + { + return $this->startApiCall('GetSubnet', $request, $callOptions)->wait(); + } + + /** + * Retrieves a `VmwareEngineNetwork` resource by its resource name. The + * resource contains details of the VMware Engine network, such as its VMware + * Engine network type, peered networks in a service project, and state + * (for example, `CREATING`, `ACTIVE`, `DELETING`). + * + * The async variant is {@see VmwareEngineClient::getVmwareEngineNetworkAsync()} . + * + * @example samples/V1/VmwareEngineClient/get_vmware_engine_network.php + * + * @param GetVmwareEngineNetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 VmwareEngineNetwork + * + * @throws ApiException Thrown if the API call fails. + */ + public function getVmwareEngineNetwork(GetVmwareEngineNetworkRequest $request, array $callOptions = []): VmwareEngineNetwork + { + return $this->startApiCall('GetVmwareEngineNetwork', $request, $callOptions)->wait(); + } + + /** + * Lists `Cluster` resources in a given private cloud. + * + * The async variant is {@see VmwareEngineClient::listClustersAsync()} . + * + * @example samples/V1/VmwareEngineClient/list_clusters.php + * + * @param ListClustersRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listClusters(ListClustersRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListClusters', $request, $callOptions); + } + + /** + * Lists `HcxActivationKey` resources in a given private cloud. + * + * The async variant is {@see VmwareEngineClient::listHcxActivationKeysAsync()} . + * + * @example samples/V1/VmwareEngineClient/list_hcx_activation_keys.php + * + * @param ListHcxActivationKeysRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listHcxActivationKeys(ListHcxActivationKeysRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListHcxActivationKeys', $request, $callOptions); + } + + /** + * Lists `NetworkPolicy` resources in a specified project and location. + * + * The async variant is {@see VmwareEngineClient::listNetworkPoliciesAsync()} . + * + * @example samples/V1/VmwareEngineClient/list_network_policies.php + * + * @param ListNetworkPoliciesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listNetworkPolicies(ListNetworkPoliciesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListNetworkPolicies', $request, $callOptions); + } + + /** + * Lists node types + * + * The async variant is {@see VmwareEngineClient::listNodeTypesAsync()} . + * + * @example samples/V1/VmwareEngineClient/list_node_types.php + * + * @param ListNodeTypesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listNodeTypes(ListNodeTypesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListNodeTypes', $request, $callOptions); + } + + /** + * Lists `PrivateCloud` resources in a given project and location. + * + * The async variant is {@see VmwareEngineClient::listPrivateCloudsAsync()} . + * + * @example samples/V1/VmwareEngineClient/list_private_clouds.php + * + * @param ListPrivateCloudsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPrivateClouds(ListPrivateCloudsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPrivateClouds', $request, $callOptions); + } + + /** + * Lists the private connection routes exchanged over a peering connection. + * + * The async variant is + * {@see VmwareEngineClient::listPrivateConnectionPeeringRoutesAsync()} . + * + * @example samples/V1/VmwareEngineClient/list_private_connection_peering_routes.php + * + * @param ListPrivateConnectionPeeringRoutesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPrivateConnectionPeeringRoutes(ListPrivateConnectionPeeringRoutesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPrivateConnectionPeeringRoutes', $request, $callOptions); + } + + /** + * Lists `PrivateConnection` resources in a given project and location. + * + * The async variant is {@see VmwareEngineClient::listPrivateConnectionsAsync()} . + * + * @example samples/V1/VmwareEngineClient/list_private_connections.php + * + * @param ListPrivateConnectionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listPrivateConnections(ListPrivateConnectionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListPrivateConnections', $request, $callOptions); + } + + /** + * Lists subnets in a given private cloud. + * + * The async variant is {@see VmwareEngineClient::listSubnetsAsync()} . + * + * @example samples/V1/VmwareEngineClient/list_subnets.php + * + * @param ListSubnetsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listSubnets(ListSubnetsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListSubnets', $request, $callOptions); + } + + /** + * Lists `VmwareEngineNetwork` resources in a given project and location. + * + * The async variant is {@see VmwareEngineClient::listVmwareEngineNetworksAsync()} + * . + * + * @example samples/V1/VmwareEngineClient/list_vmware_engine_networks.php + * + * @param ListVmwareEngineNetworksRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listVmwareEngineNetworks(ListVmwareEngineNetworksRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListVmwareEngineNetworks', $request, $callOptions); + } + + /** + * Resets credentials of the NSX appliance. + * + * The async variant is {@see VmwareEngineClient::resetNsxCredentialsAsync()} . + * + * @example samples/V1/VmwareEngineClient/reset_nsx_credentials.php + * + * @param ResetNsxCredentialsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function resetNsxCredentials(ResetNsxCredentialsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ResetNsxCredentials', $request, $callOptions)->wait(); + } + + /** + * Resets credentials of the Vcenter appliance. + * + * The async variant is {@see VmwareEngineClient::resetVcenterCredentialsAsync()} . + * + * @example samples/V1/VmwareEngineClient/reset_vcenter_credentials.php + * + * @param ResetVcenterCredentialsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function resetVcenterCredentials(ResetVcenterCredentialsRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('ResetVcenterCredentials', $request, $callOptions)->wait(); + } + + /** + * Gets details of credentials for NSX appliance. + * + * The async variant is {@see VmwareEngineClient::showNsxCredentialsAsync()} . + * + * @example samples/V1/VmwareEngineClient/show_nsx_credentials.php + * + * @param ShowNsxCredentialsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Credentials + * + * @throws ApiException Thrown if the API call fails. + */ + public function showNsxCredentials(ShowNsxCredentialsRequest $request, array $callOptions = []): Credentials + { + return $this->startApiCall('ShowNsxCredentials', $request, $callOptions)->wait(); + } + + /** + * Gets details of credentials for Vcenter appliance. + * + * The async variant is {@see VmwareEngineClient::showVcenterCredentialsAsync()} . + * + * @example samples/V1/VmwareEngineClient/show_vcenter_credentials.php + * + * @param ShowVcenterCredentialsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Credentials + * + * @throws ApiException Thrown if the API call fails. + */ + public function showVcenterCredentials(ShowVcenterCredentialsRequest $request, array $callOptions = []): Credentials + { + return $this->startApiCall('ShowVcenterCredentials', $request, $callOptions)->wait(); + } + + /** + * Restores a private cloud that was previously scheduled for deletion by + * `DeletePrivateCloud`. A `PrivateCloud` resource scheduled for deletion has + * `PrivateCloud.state` set to `DELETED` and `PrivateCloud.expireTime` set to + * the time when deletion can no longer be reversed. + * + * The async variant is {@see VmwareEngineClient::undeletePrivateCloudAsync()} . + * + * @example samples/V1/VmwareEngineClient/undelete_private_cloud.php + * + * @param UndeletePrivateCloudRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function undeletePrivateCloud(UndeletePrivateCloudRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UndeletePrivateCloud', $request, $callOptions)->wait(); + } + + /** + * Modifies a `Cluster` resource. Only the following fields can be updated: + * `node_type_configs.*.node_count`. Only fields specified in `updateMask` are + * applied. + * + * During operation processing, the resource is temporarily in the `ACTIVE` + * state before the operation fully completes. For that period of time, you + * can't update the resource. Use the operation status to determine when the + * processing fully completes. + * + * The async variant is {@see VmwareEngineClient::updateClusterAsync()} . + * + * @example samples/V1/VmwareEngineClient/update_cluster.php + * + * @param UpdateClusterRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateCluster(UpdateClusterRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateCluster', $request, $callOptions)->wait(); + } + + /** + * Modifies a `NetworkPolicy` resource. Only the following fields can be + * updated: `internet_access`, `external_ip`, `edge_services_cidr`. + * Only fields specified in `updateMask` are applied. When updating a network + * policy, the external IP network service can only be disabled if there are + * no external IP addresses present in the scope of the policy. Also, a + * `NetworkService` cannot be updated when `NetworkService.state` is set + * to `RECONCILING`. + * + * During operation processing, the resource is temporarily in the `ACTIVE` + * state before the operation fully completes. For that period of time, you + * can't update the resource. Use the operation status to determine when the + * processing fully completes. + * + * The async variant is {@see VmwareEngineClient::updateNetworkPolicyAsync()} . + * + * @example samples/V1/VmwareEngineClient/update_network_policy.php + * + * @param UpdateNetworkPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateNetworkPolicy(UpdateNetworkPolicyRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateNetworkPolicy', $request, $callOptions)->wait(); + } + + /** + * Modifies a `PrivateCloud` resource. Only the following fields can be + * updated: `description`. + * Only fields specified in `updateMask` are applied. + * + * During operation processing, the resource is temporarily in the `ACTIVE` + * state before the operation fully completes. For that period of time, you + * can't update the resource. Use the operation status to determine when the + * processing fully completes. + * + * The async variant is {@see VmwareEngineClient::updatePrivateCloudAsync()} . + * + * @example samples/V1/VmwareEngineClient/update_private_cloud.php + * + * @param UpdatePrivateCloudRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updatePrivateCloud(UpdatePrivateCloudRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdatePrivateCloud', $request, $callOptions)->wait(); + } + + /** + * Modifies a `PrivateConnection` resource. Only `description` and + * `routing_mode` fields can be updated. Only fields specified in `updateMask` + * are applied. + * + * The async variant is {@see VmwareEngineClient::updatePrivateConnectionAsync()} . + * + * @example samples/V1/VmwareEngineClient/update_private_connection.php + * + * @param UpdatePrivateConnectionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updatePrivateConnection(UpdatePrivateConnectionRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdatePrivateConnection', $request, $callOptions)->wait(); + } + + /** + * Updates the parameters of a single subnet. Only fields specified in + * `update_mask` are applied. + * + * *Note*: This API is synchronous and always returns a successful + * `google.longrunning.Operation` (LRO). The returned LRO will only have + * `done` and `response` fields. + * + * The async variant is {@see VmwareEngineClient::updateSubnetAsync()} . + * + * @example samples/V1/VmwareEngineClient/update_subnet.php + * + * @param UpdateSubnetRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateSubnet(UpdateSubnetRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateSubnet', $request, $callOptions)->wait(); + } + + /** + * Modifies a VMware Engine network resource. Only the following fields can be + * updated: `description`. Only fields specified in `updateMask` are + * applied. + * + * The async variant is {@see VmwareEngineClient::updateVmwareEngineNetworkAsync()} + * . + * + * @example samples/V1/VmwareEngineClient/update_vmware_engine_network.php + * + * @param UpdateVmwareEngineNetworkRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateVmwareEngineNetwork(UpdateVmwareEngineNetworkRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateVmwareEngineNetwork', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see VmwareEngineClient::getLocationAsync()} . + * + * @example samples/V1/VmwareEngineClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see VmwareEngineClient::listLocationsAsync()} . + * + * @example samples/V1/VmwareEngineClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see VmwareEngineClient::getIamPolicyAsync()} . + * + * @example samples/V1/VmwareEngineClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see VmwareEngineClient::setIamPolicyAsync()} . + * + * @example samples/V1/VmwareEngineClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is {@see VmwareEngineClient::testIamPermissionsAsync()} . + * + * @example samples/V1/VmwareEngineClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions(TestIamPermissionsRequest $request, array $callOptions = []): TestIamPermissionsResponse + { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } } diff --git a/VpcAccess/composer.json b/VpcAccess/composer.json index 5684a8a5213e..dc9f9b3f1db0 100644 --- a/VpcAccess/composer.json +++ b/VpcAccess/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/VpcAccess/src/V1/Client/BaseClient/VpcAccessServiceBaseClient.php b/VpcAccess/src/V1/Client/BaseClient/VpcAccessServiceBaseClient.php deleted file mode 100644 index e3695745dfa7..000000000000 --- a/VpcAccess/src/V1/Client/BaseClient/VpcAccessServiceBaseClient.php +++ /dev/null @@ -1,399 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/vpc_access_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/vpc_access_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/vpc_access_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/vpc_access_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a connector - * resource. - * - * @param string $project - * @param string $location - * @param string $connector - * - * @return string The formatted connector resource. - */ - public static function connectorName(string $project, string $location, string $connector): string - { - return self::getPathTemplate('connector')->render([ - 'project' => $project, - 'location' => $location, - 'connector' => $connector, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - connector: projects/{project}/locations/{location}/connectors/{connector} - * - location: projects/{project}/locations/{location} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'vpcaccess.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a Serverless VPC Access connector, returns an operation. - * - * The async variant is {@see self::createConnectorAsync()} . - * - * @param CreateConnectorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createConnector(CreateConnectorRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateConnector', $request, $callOptions)->wait(); - } - - /** - * Deletes a Serverless VPC Access connector. Returns NOT_FOUND if the - * resource does not exist. - * - * The async variant is {@see self::deleteConnectorAsync()} . - * - * @param DeleteConnectorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteConnector(DeleteConnectorRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteConnector', $request, $callOptions)->wait(); - } - - /** - * Gets a Serverless VPC Access connector. Returns NOT_FOUND if the resource - * does not exist. - * - * The async variant is {@see self::getConnectorAsync()} . - * - * @param GetConnectorRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Connector - * - * @throws ApiException Thrown if the API call fails. - */ - public function getConnector(GetConnectorRequest $request, array $callOptions = []): Connector - { - return $this->startApiCall('GetConnector', $request, $callOptions)->wait(); - } - - /** - * Lists Serverless VPC Access connectors. - * - * The async variant is {@see self::listConnectorsAsync()} . - * - * @param ListConnectorsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listConnectors(ListConnectorsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListConnectors', $request, $callOptions); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/VpcAccess/src/V1/Client/VpcAccessServiceClient.php b/VpcAccess/src/V1/Client/VpcAccessServiceClient.php index 7c6a17daa2fc..b80d8ede47a0 100644 --- a/VpcAccess/src/V1/Client/VpcAccessServiceClient.php +++ b/VpcAccess/src/V1/Client/VpcAccessServiceClient.php @@ -24,17 +24,374 @@ namespace Google\Cloud\VpcAccess\V1\Client; -use Google\Cloud\VpcAccess\V1\Client\BaseClient\VpcAccessServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\VpcAccess\V1\Connector; +use Google\Cloud\VpcAccess\V1\CreateConnectorRequest; +use Google\Cloud\VpcAccess\V1\DeleteConnectorRequest; +use Google\Cloud\VpcAccess\V1\GetConnectorRequest; +use Google\Cloud\VpcAccess\V1\ListConnectorsRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Serverless VPC Access API allows users to create and manage connectors for + * App Engine, Cloud Functions and Cloud Run to have internal connections to + * Virtual Private Cloud networks. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\VpcAccess\V1\VpcAccessServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface createConnectorAsync(CreateConnectorRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteConnectorAsync(DeleteConnectorRequest $request, array $optionalArgs = []) + * @method PromiseInterface getConnectorAsync(GetConnectorRequest $request, array $optionalArgs = []) + * @method PromiseInterface listConnectorsAsync(ListConnectorsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class VpcAccessServiceClient extends VpcAccessServiceBaseClient +final class VpcAccessServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see VpcAccessServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.vpcaccess.v1.VpcAccessService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'vpcaccess.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/vpc_access_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/vpc_access_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/vpc_access_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/vpc_access_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a connector + * resource. + * + * @param string $project + * @param string $location + * @param string $connector + * + * @return string The formatted connector resource. + */ + public static function connectorName(string $project, string $location, string $connector): string + { + return self::getPathTemplate('connector')->render([ + 'project' => $project, + 'location' => $location, + 'connector' => $connector, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - connector: projects/{project}/locations/{location}/connectors/{connector} + * - location: projects/{project}/locations/{location} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'vpcaccess.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a Serverless VPC Access connector, returns an operation. + * + * The async variant is {@see VpcAccessServiceClient::createConnectorAsync()} . + * + * @param CreateConnectorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createConnector(CreateConnectorRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateConnector', $request, $callOptions)->wait(); + } + + /** + * Deletes a Serverless VPC Access connector. Returns NOT_FOUND if the + * resource does not exist. + * + * The async variant is {@see VpcAccessServiceClient::deleteConnectorAsync()} . + * + * @param DeleteConnectorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteConnector(DeleteConnectorRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteConnector', $request, $callOptions)->wait(); + } + + /** + * Gets a Serverless VPC Access connector. Returns NOT_FOUND if the resource + * does not exist. + * + * The async variant is {@see VpcAccessServiceClient::getConnectorAsync()} . + * + * @param GetConnectorRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Connector + * + * @throws ApiException Thrown if the API call fails. + */ + public function getConnector(GetConnectorRequest $request, array $callOptions = []): Connector + { + return $this->startApiCall('GetConnector', $request, $callOptions)->wait(); + } + + /** + * Lists Serverless VPC Access connectors. + * + * The async variant is {@see VpcAccessServiceClient::listConnectorsAsync()} . + * + * @param ListConnectorsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listConnectors(ListConnectorsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListConnectors', $request, $callOptions); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see VpcAccessServiceClient::listLocationsAsync()} . + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/WebRisk/composer.json b/WebRisk/composer.json index ea55379467ff..e97569a2fddb 100644 --- a/WebRisk/composer.json +++ b/WebRisk/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/WebRisk/src/V1/Client/BaseClient/WebRiskServiceBaseClient.php b/WebRisk/src/V1/Client/BaseClient/WebRiskServiceBaseClient.php deleted file mode 100644 index 1f2bc4bb1b9c..000000000000 --- a/WebRisk/src/V1/Client/BaseClient/WebRiskServiceBaseClient.php +++ /dev/null @@ -1,404 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/web_risk_service_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/web_risk_service_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/web_risk_service_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/web_risk_service_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * 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(string $project): string - { - return self::getPathTemplate('project')->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. - */ - public static function parseName(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'webrisk.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Gets the most recent threat list diffs. These diffs should be applied to - * a local database of hashes to keep it up-to-date. If the local database is - * empty or excessively out-of-date, a complete snapshot of the database will - * be returned. This Method only updates a single ThreatList at a time. To - * update multiple ThreatList databases, this method needs to be called once - * for each list. - * - * The async variant is {@see self::computeThreatListDiffAsync()} . - * - * @param ComputeThreatListDiffRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ComputeThreatListDiffResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function computeThreatListDiff(ComputeThreatListDiffRequest $request, array $callOptions = []): ComputeThreatListDiffResponse - { - return $this->startApiCall('ComputeThreatListDiff', $request, $callOptions)->wait(); - } - - /** - * Creates a Submission of a URI suspected of containing phishing content to - * be reviewed. If the result verifies the existence of malicious phishing - * content, the site will be added to the [Google's Social Engineering - * lists](https://support.google.com/webmasters/answer/6350487/) in order to - * protect users that could get exposed to this threat in the future. Only - * allowlisted projects can use this method during Early Access. Please reach - * out to Sales or your customer engineer to obtain access. - * - * The async variant is {@see self::createSubmissionAsync()} . - * - * @param CreateSubmissionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Submission - * - * @throws ApiException Thrown if the API call fails. - */ - public function createSubmission(CreateSubmissionRequest $request, array $callOptions = []): Submission - { - return $this->startApiCall('CreateSubmission', $request, $callOptions)->wait(); - } - - /** - * Gets the full hashes that match the requested hash prefix. - * This is used after a hash prefix is looked up in a threatList - * and there is a match. The client side threatList only holds partial hashes - * so the client must query this method to determine if there is a full - * hash match of a threat. - * - * The async variant is {@see self::searchHashesAsync()} . - * - * @param SearchHashesRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SearchHashesResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchHashes(SearchHashesRequest $request, array $callOptions = []): SearchHashesResponse - { - return $this->startApiCall('SearchHashes', $request, $callOptions)->wait(); - } - - /** - * This method is used to check whether a URI is on a given threatList. - * Multiple threatLists may be searched in a single query. - * The response will list all requested threatLists the URI was found to - * match. If the URI is not found on any of the requested ThreatList an - * empty response will be returned. - * - * The async variant is {@see self::searchUrisAsync()} . - * - * @param SearchUrisRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 SearchUrisResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function searchUris(SearchUrisRequest $request, array $callOptions = []): SearchUrisResponse - { - return $this->startApiCall('SearchUris', $request, $callOptions)->wait(); - } - - /** - * Submits a URI suspected of containing malicious content to be reviewed. - * Returns a google.longrunning.Operation which, once the review is complete, - * is updated with its result. You can use the [Pub/Sub API] - * (https://cloud.google.com/pubsub) to receive notifications for the returned - * Operation. If the result verifies the existence of malicious content, the - * site will be added to the [Google's Social Engineering lists] - * (https://support.google.com/webmasters/answer/6350487/) in order to - * protect users that could get exposed to this threat in the future. Only - * allowlisted projects can use this method during Early Access. Please reach - * out to Sales or your customer engineer to obtain access. - * - * The async variant is {@see self::submitUriAsync()} . - * - * @param SubmitUriRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function submitUri(SubmitUriRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('SubmitUri', $request, $callOptions)->wait(); - } -} diff --git a/WebRisk/src/V1/Client/WebRiskServiceClient.php b/WebRisk/src/V1/Client/WebRiskServiceClient.php index 521b57ce5bc2..fad5fb5db411 100644 --- a/WebRisk/src/V1/Client/WebRiskServiceClient.php +++ b/WebRisk/src/V1/Client/WebRiskServiceClient.php @@ -24,17 +24,379 @@ namespace Google\Cloud\WebRisk\V1\Client; -use Google\Cloud\WebRisk\V1\Client\BaseClient\WebRiskServiceBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\WebRisk\V1\ComputeThreatListDiffRequest; +use Google\Cloud\WebRisk\V1\ComputeThreatListDiffResponse; +use Google\Cloud\WebRisk\V1\CreateSubmissionRequest; +use Google\Cloud\WebRisk\V1\SearchHashesRequest; +use Google\Cloud\WebRisk\V1\SearchHashesResponse; +use Google\Cloud\WebRisk\V1\SearchUrisRequest; +use Google\Cloud\WebRisk\V1\SearchUrisResponse; +use Google\Cloud\WebRisk\V1\Submission; +use Google\Cloud\WebRisk\V1\SubmitUriRequest; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Web Risk API defines an interface to detect malicious URLs on your + * website and in client applications. * - * This class is currently experimental and may be subject to changes. + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. + * + * This class is currently experimental and may be subject to changes. See {@see + * \Google\Cloud\WebRisk\V1\WebRiskServiceClient} for the stable implementation * * @experimental + * + * @method PromiseInterface computeThreatListDiffAsync(ComputeThreatListDiffRequest $request, array $optionalArgs = []) + * @method PromiseInterface createSubmissionAsync(CreateSubmissionRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchHashesAsync(SearchHashesRequest $request, array $optionalArgs = []) + * @method PromiseInterface searchUrisAsync(SearchUrisRequest $request, array $optionalArgs = []) + * @method PromiseInterface submitUriAsync(SubmitUriRequest $request, array $optionalArgs = []) */ -final class WebRiskServiceClient extends WebRiskServiceBaseClient +final class WebRiskServiceClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see WebRiskServiceBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.webrisk.v1.WebRiskService'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'webrisk.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/web_risk_service_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/web_risk_service_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/web_risk_service_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/web_risk_service_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * 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(string $project): string + { + return self::getPathTemplate('project')->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. + */ + public static function parseName(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'webrisk.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Gets the most recent threat list diffs. These diffs should be applied to + * a local database of hashes to keep it up-to-date. If the local database is + * empty or excessively out-of-date, a complete snapshot of the database will + * be returned. This Method only updates a single ThreatList at a time. To + * update multiple ThreatList databases, this method needs to be called once + * for each list. + * + * The async variant is {@see WebRiskServiceClient::computeThreatListDiffAsync()} . + * + * @param ComputeThreatListDiffRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ComputeThreatListDiffResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function computeThreatListDiff(ComputeThreatListDiffRequest $request, array $callOptions = []): ComputeThreatListDiffResponse + { + return $this->startApiCall('ComputeThreatListDiff', $request, $callOptions)->wait(); + } + + /** + * Creates a Submission of a URI suspected of containing phishing content to + * be reviewed. If the result verifies the existence of malicious phishing + * content, the site will be added to the [Google's Social Engineering + * lists](https://support.google.com/webmasters/answer/6350487/) in order to + * protect users that could get exposed to this threat in the future. Only + * allowlisted projects can use this method during Early Access. Please reach + * out to Sales or your customer engineer to obtain access. + * + * The async variant is {@see WebRiskServiceClient::createSubmissionAsync()} . + * + * @param CreateSubmissionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Submission + * + * @throws ApiException Thrown if the API call fails. + */ + public function createSubmission(CreateSubmissionRequest $request, array $callOptions = []): Submission + { + return $this->startApiCall('CreateSubmission', $request, $callOptions)->wait(); + } + + /** + * Gets the full hashes that match the requested hash prefix. + * This is used after a hash prefix is looked up in a threatList + * and there is a match. The client side threatList only holds partial hashes + * so the client must query this method to determine if there is a full + * hash match of a threat. + * + * The async variant is {@see WebRiskServiceClient::searchHashesAsync()} . + * + * @param SearchHashesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SearchHashesResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchHashes(SearchHashesRequest $request, array $callOptions = []): SearchHashesResponse + { + return $this->startApiCall('SearchHashes', $request, $callOptions)->wait(); + } + + /** + * This method is used to check whether a URI is on a given threatList. + * Multiple threatLists may be searched in a single query. + * The response will list all requested threatLists the URI was found to + * match. If the URI is not found on any of the requested ThreatList an + * empty response will be returned. + * + * The async variant is {@see WebRiskServiceClient::searchUrisAsync()} . + * + * @param SearchUrisRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 SearchUrisResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function searchUris(SearchUrisRequest $request, array $callOptions = []): SearchUrisResponse + { + return $this->startApiCall('SearchUris', $request, $callOptions)->wait(); + } + + /** + * Submits a URI suspected of containing malicious content to be reviewed. + * Returns a google.longrunning.Operation which, once the review is complete, + * is updated with its result. You can use the [Pub/Sub API] + * (https://cloud.google.com/pubsub) to receive notifications for the returned + * Operation. If the result verifies the existence of malicious content, the + * site will be added to the [Google's Social Engineering lists] + * (https://support.google.com/webmasters/answer/6350487/) in order to + * protect users that could get exposed to this threat in the future. Only + * allowlisted projects can use this method during Early Access. Please reach + * out to Sales or your customer engineer to obtain access. + * + * The async variant is {@see WebRiskServiceClient::submitUriAsync()} . + * + * @param SubmitUriRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function submitUri(SubmitUriRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('SubmitUri', $request, $callOptions)->wait(); + } } diff --git a/WebSecurityScanner/composer.json b/WebSecurityScanner/composer.json index ae91bdab70f0..4c537d53e4cf 100644 --- a/WebSecurityScanner/composer.json +++ b/WebSecurityScanner/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/WebSecurityScanner/src/V1/Client/BaseClient/WebSecurityScannerBaseClient.php b/WebSecurityScanner/src/V1/Client/BaseClient/WebSecurityScannerBaseClient.php deleted file mode 100644 index 967cc37063b9..000000000000 --- a/WebSecurityScanner/src/V1/Client/BaseClient/WebSecurityScannerBaseClient.php +++ /dev/null @@ -1,529 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/web_security_scanner_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/web_security_scanner_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/web_security_scanner_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/web_security_scanner_rest_client_config.php', - ], - ], - ]; - } - - /** - * 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 'websecurityscanner.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new ScanConfig. - * - * The async variant is {@see self::createScanConfigAsync()} . - * - * @example samples/V1/WebSecurityScannerClient/create_scan_config.php - * - * @param CreateScanConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ScanConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function createScanConfig(CreateScanConfigRequest $request, array $callOptions = []): ScanConfig - { - return $this->startApiCall('CreateScanConfig', $request, $callOptions)->wait(); - } - - /** - * Deletes an existing ScanConfig and its child resources. - * - * The async variant is {@see self::deleteScanConfigAsync()} . - * - * @example samples/V1/WebSecurityScannerClient/delete_scan_config.php - * - * @param DeleteScanConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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. - * } - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteScanConfig(DeleteScanConfigRequest $request, array $callOptions = []): void - { - $this->startApiCall('DeleteScanConfig', $request, $callOptions)->wait(); - } - - /** - * Gets a Finding. - * - * The async variant is {@see self::getFindingAsync()} . - * - * @example samples/V1/WebSecurityScannerClient/get_finding.php - * - * @param GetFindingRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Finding - * - * @throws ApiException Thrown if the API call fails. - */ - public function getFinding(GetFindingRequest $request, array $callOptions = []): Finding - { - return $this->startApiCall('GetFinding', $request, $callOptions)->wait(); - } - - /** - * Gets a ScanConfig. - * - * The async variant is {@see self::getScanConfigAsync()} . - * - * @example samples/V1/WebSecurityScannerClient/get_scan_config.php - * - * @param GetScanConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ScanConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function getScanConfig(GetScanConfigRequest $request, array $callOptions = []): ScanConfig - { - return $this->startApiCall('GetScanConfig', $request, $callOptions)->wait(); - } - - /** - * Gets a ScanRun. - * - * The async variant is {@see self::getScanRunAsync()} . - * - * @example samples/V1/WebSecurityScannerClient/get_scan_run.php - * - * @param GetScanRunRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ScanRun - * - * @throws ApiException Thrown if the API call fails. - */ - public function getScanRun(GetScanRunRequest $request, array $callOptions = []): ScanRun - { - return $this->startApiCall('GetScanRun', $request, $callOptions)->wait(); - } - - /** - * List CrawledUrls under a given ScanRun. - * - * The async variant is {@see self::listCrawledUrlsAsync()} . - * - * @example samples/V1/WebSecurityScannerClient/list_crawled_urls.php - * - * @param ListCrawledUrlsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listCrawledUrls(ListCrawledUrlsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListCrawledUrls', $request, $callOptions); - } - - /** - * List all FindingTypeStats under a given ScanRun. - * - * The async variant is {@see self::listFindingTypeStatsAsync()} . - * - * @example samples/V1/WebSecurityScannerClient/list_finding_type_stats.php - * - * @param ListFindingTypeStatsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ListFindingTypeStatsResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listFindingTypeStats(ListFindingTypeStatsRequest $request, array $callOptions = []): ListFindingTypeStatsResponse - { - return $this->startApiCall('ListFindingTypeStats', $request, $callOptions)->wait(); - } - - /** - * List Findings under a given ScanRun. - * - * The async variant is {@see self::listFindingsAsync()} . - * - * @example samples/V1/WebSecurityScannerClient/list_findings.php - * - * @param ListFindingsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listFindings(ListFindingsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListFindings', $request, $callOptions); - } - - /** - * Lists ScanConfigs under a given project. - * - * The async variant is {@see self::listScanConfigsAsync()} . - * - * @example samples/V1/WebSecurityScannerClient/list_scan_configs.php - * - * @param ListScanConfigsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listScanConfigs(ListScanConfigsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListScanConfigs', $request, $callOptions); - } - - /** - * Lists ScanRuns under a given ScanConfig, in descending order of ScanRun - * stop time. - * - * The async variant is {@see self::listScanRunsAsync()} . - * - * @example samples/V1/WebSecurityScannerClient/list_scan_runs.php - * - * @param ListScanRunsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listScanRuns(ListScanRunsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListScanRuns', $request, $callOptions); - } - - /** - * Start a ScanRun according to the given ScanConfig. - * - * The async variant is {@see self::startScanRunAsync()} . - * - * @example samples/V1/WebSecurityScannerClient/start_scan_run.php - * - * @param StartScanRunRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ScanRun - * - * @throws ApiException Thrown if the API call fails. - */ - public function startScanRun(StartScanRunRequest $request, array $callOptions = []): ScanRun - { - return $this->startApiCall('StartScanRun', $request, $callOptions)->wait(); - } - - /** - * Stops a ScanRun. The stopped ScanRun is returned. - * - * The async variant is {@see self::stopScanRunAsync()} . - * - * @example samples/V1/WebSecurityScannerClient/stop_scan_run.php - * - * @param StopScanRunRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ScanRun - * - * @throws ApiException Thrown if the API call fails. - */ - public function stopScanRun(StopScanRunRequest $request, array $callOptions = []): ScanRun - { - return $this->startApiCall('StopScanRun', $request, $callOptions)->wait(); - } - - /** - * Updates a ScanConfig. This method support partial update of a ScanConfig. - * - * The async variant is {@see self::updateScanConfigAsync()} . - * - * @example samples/V1/WebSecurityScannerClient/update_scan_config.php - * - * @param UpdateScanConfigRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 ScanConfig - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateScanConfig(UpdateScanConfigRequest $request, array $callOptions = []): ScanConfig - { - return $this->startApiCall('UpdateScanConfig', $request, $callOptions)->wait(); - } -} diff --git a/WebSecurityScanner/src/V1/Client/WebSecurityScannerClient.php b/WebSecurityScanner/src/V1/Client/WebSecurityScannerClient.php index 1bb8668679a7..5fee172efe98 100644 --- a/WebSecurityScanner/src/V1/Client/WebSecurityScannerClient.php +++ b/WebSecurityScanner/src/V1/Client/WebSecurityScannerClient.php @@ -24,17 +24,505 @@ namespace Google\Cloud\WebSecurityScanner\V1\Client; -use Google\Cloud\WebSecurityScanner\V1\Client\BaseClient\WebSecurityScannerBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\WebSecurityScanner\V1\CreateScanConfigRequest; +use Google\Cloud\WebSecurityScanner\V1\DeleteScanConfigRequest; +use Google\Cloud\WebSecurityScanner\V1\Finding; +use Google\Cloud\WebSecurityScanner\V1\GetFindingRequest; +use Google\Cloud\WebSecurityScanner\V1\GetScanConfigRequest; +use Google\Cloud\WebSecurityScanner\V1\GetScanRunRequest; +use Google\Cloud\WebSecurityScanner\V1\ListCrawledUrlsRequest; +use Google\Cloud\WebSecurityScanner\V1\ListFindingTypeStatsRequest; +use Google\Cloud\WebSecurityScanner\V1\ListFindingTypeStatsResponse; +use Google\Cloud\WebSecurityScanner\V1\ListFindingsRequest; +use Google\Cloud\WebSecurityScanner\V1\ListScanConfigsRequest; +use Google\Cloud\WebSecurityScanner\V1\ListScanRunsRequest; +use Google\Cloud\WebSecurityScanner\V1\ScanConfig; +use Google\Cloud\WebSecurityScanner\V1\ScanRun; +use Google\Cloud\WebSecurityScanner\V1\StartScanRunRequest; +use Google\Cloud\WebSecurityScanner\V1\StopScanRunRequest; +use Google\Cloud\WebSecurityScanner\V1\UpdateScanConfigRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Web Security Scanner Service identifies security vulnerabilities in web + * applications hosted on Google Cloud. It crawls your application, and + * attempts to exercise as many user inputs and event handlers as possible. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createScanConfigAsync(CreateScanConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteScanConfigAsync(DeleteScanConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getFindingAsync(GetFindingRequest $request, array $optionalArgs = []) + * @method PromiseInterface getScanConfigAsync(GetScanConfigRequest $request, array $optionalArgs = []) + * @method PromiseInterface getScanRunAsync(GetScanRunRequest $request, array $optionalArgs = []) + * @method PromiseInterface listCrawledUrlsAsync(ListCrawledUrlsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listFindingTypeStatsAsync(ListFindingTypeStatsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listFindingsAsync(ListFindingsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listScanConfigsAsync(ListScanConfigsRequest $request, array $optionalArgs = []) + * @method PromiseInterface listScanRunsAsync(ListScanRunsRequest $request, array $optionalArgs = []) + * @method PromiseInterface startScanRunAsync(StartScanRunRequest $request, array $optionalArgs = []) + * @method PromiseInterface stopScanRunAsync(StopScanRunRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateScanConfigAsync(UpdateScanConfigRequest $request, array $optionalArgs = []) */ -final class WebSecurityScannerClient extends WebSecurityScannerBaseClient +final class WebSecurityScannerClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see WebSecurityScannerBaseClient} class. + use GapicClientTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.websecurityscanner.v1.WebSecurityScanner'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'websecurityscanner.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/web_security_scanner_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/web_security_scanner_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/web_security_scanner_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/web_security_scanner_rest_client_config.php', + ], + ], + ]; + } + + /** + * 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 'websecurityscanner.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new ScanConfig. + * + * The async variant is {@see WebSecurityScannerClient::createScanConfigAsync()} . + * + * @example samples/V1/WebSecurityScannerClient/create_scan_config.php + * + * @param CreateScanConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ScanConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function createScanConfig(CreateScanConfigRequest $request, array $callOptions = []): ScanConfig + { + return $this->startApiCall('CreateScanConfig', $request, $callOptions)->wait(); + } + + /** + * Deletes an existing ScanConfig and its child resources. + * + * The async variant is {@see WebSecurityScannerClient::deleteScanConfigAsync()} . + * + * @example samples/V1/WebSecurityScannerClient/delete_scan_config.php + * + * @param DeleteScanConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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. + * } + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteScanConfig(DeleteScanConfigRequest $request, array $callOptions = []): void + { + $this->startApiCall('DeleteScanConfig', $request, $callOptions)->wait(); + } + + /** + * Gets a Finding. + * + * The async variant is {@see WebSecurityScannerClient::getFindingAsync()} . + * + * @example samples/V1/WebSecurityScannerClient/get_finding.php + * + * @param GetFindingRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Finding + * + * @throws ApiException Thrown if the API call fails. + */ + public function getFinding(GetFindingRequest $request, array $callOptions = []): Finding + { + return $this->startApiCall('GetFinding', $request, $callOptions)->wait(); + } + + /** + * Gets a ScanConfig. + * + * The async variant is {@see WebSecurityScannerClient::getScanConfigAsync()} . + * + * @example samples/V1/WebSecurityScannerClient/get_scan_config.php + * + * @param GetScanConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ScanConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getScanConfig(GetScanConfigRequest $request, array $callOptions = []): ScanConfig + { + return $this->startApiCall('GetScanConfig', $request, $callOptions)->wait(); + } + + /** + * Gets a ScanRun. + * + * The async variant is {@see WebSecurityScannerClient::getScanRunAsync()} . + * + * @example samples/V1/WebSecurityScannerClient/get_scan_run.php + * + * @param GetScanRunRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ScanRun + * + * @throws ApiException Thrown if the API call fails. + */ + public function getScanRun(GetScanRunRequest $request, array $callOptions = []): ScanRun + { + return $this->startApiCall('GetScanRun', $request, $callOptions)->wait(); + } + + /** + * List CrawledUrls under a given ScanRun. + * + * The async variant is {@see WebSecurityScannerClient::listCrawledUrlsAsync()} . + * + * @example samples/V1/WebSecurityScannerClient/list_crawled_urls.php + * + * @param ListCrawledUrlsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listCrawledUrls(ListCrawledUrlsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListCrawledUrls', $request, $callOptions); + } + + /** + * List all FindingTypeStats under a given ScanRun. + * + * The async variant is + * {@see WebSecurityScannerClient::listFindingTypeStatsAsync()} . + * + * @example samples/V1/WebSecurityScannerClient/list_finding_type_stats.php + * + * @param ListFindingTypeStatsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ListFindingTypeStatsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listFindingTypeStats(ListFindingTypeStatsRequest $request, array $callOptions = []): ListFindingTypeStatsResponse + { + return $this->startApiCall('ListFindingTypeStats', $request, $callOptions)->wait(); + } + + /** + * List Findings under a given ScanRun. + * + * The async variant is {@see WebSecurityScannerClient::listFindingsAsync()} . + * + * @example samples/V1/WebSecurityScannerClient/list_findings.php + * + * @param ListFindingsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listFindings(ListFindingsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListFindings', $request, $callOptions); + } + + /** + * Lists ScanConfigs under a given project. + * + * The async variant is {@see WebSecurityScannerClient::listScanConfigsAsync()} . + * + * @example samples/V1/WebSecurityScannerClient/list_scan_configs.php + * + * @param ListScanConfigsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listScanConfigs(ListScanConfigsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListScanConfigs', $request, $callOptions); + } + + /** + * Lists ScanRuns under a given ScanConfig, in descending order of ScanRun + * stop time. + * + * The async variant is {@see WebSecurityScannerClient::listScanRunsAsync()} . + * + * @example samples/V1/WebSecurityScannerClient/list_scan_runs.php + * + * @param ListScanRunsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listScanRuns(ListScanRunsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListScanRuns', $request, $callOptions); + } + + /** + * Start a ScanRun according to the given ScanConfig. + * + * The async variant is {@see WebSecurityScannerClient::startScanRunAsync()} . + * + * @example samples/V1/WebSecurityScannerClient/start_scan_run.php + * + * @param StartScanRunRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ScanRun + * + * @throws ApiException Thrown if the API call fails. + */ + public function startScanRun(StartScanRunRequest $request, array $callOptions = []): ScanRun + { + return $this->startApiCall('StartScanRun', $request, $callOptions)->wait(); + } + + /** + * Stops a ScanRun. The stopped ScanRun is returned. + * + * The async variant is {@see WebSecurityScannerClient::stopScanRunAsync()} . + * + * @example samples/V1/WebSecurityScannerClient/stop_scan_run.php + * + * @param StopScanRunRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ScanRun + * + * @throws ApiException Thrown if the API call fails. + */ + public function stopScanRun(StopScanRunRequest $request, array $callOptions = []): ScanRun + { + return $this->startApiCall('StopScanRun', $request, $callOptions)->wait(); + } + + /** + * Updates a ScanConfig. This method support partial update of a ScanConfig. + * + * The async variant is {@see WebSecurityScannerClient::updateScanConfigAsync()} . + * + * @example samples/V1/WebSecurityScannerClient/update_scan_config.php + * + * @param UpdateScanConfigRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 ScanConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateScanConfig(UpdateScanConfigRequest $request, array $callOptions = []): ScanConfig + { + return $this->startApiCall('UpdateScanConfig', $request, $callOptions)->wait(); + } } diff --git a/Workflows/composer.json b/Workflows/composer.json index b4a4e342bdd8..f95c12497233 100644 --- a/Workflows/composer.json +++ b/Workflows/composer.json @@ -24,7 +24,7 @@ }, "require": { "php": ">=7.4", - "google/gax": "^1.19.1" + "google/gax": "^1.24.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/Workflows/src/Executions/V1/Client/BaseClient/ExecutionsBaseClient.php b/Workflows/src/Executions/V1/Client/BaseClient/ExecutionsBaseClient.php deleted file mode 100644 index 011a711708ae..000000000000 --- a/Workflows/src/Executions/V1/Client/BaseClient/ExecutionsBaseClient.php +++ /dev/null @@ -1,349 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/executions_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/executions_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/executions_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/executions_rest_client_config.php', - ], - ], - ]; - } - - /** - * Formats a string containing the fully-qualified path to represent a execution - * resource. - * - * @param string $project - * @param string $location - * @param string $workflow - * @param string $execution - * - * @return string The formatted execution resource. - */ - public static function executionName(string $project, string $location, string $workflow, string $execution): string - { - return self::getPathTemplate('execution')->render([ - 'project' => $project, - 'location' => $location, - 'workflow' => $workflow, - 'execution' => $execution, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a workflow - * resource. - * - * @param string $project - * @param string $location - * @param string $workflow - * - * @return string The formatted workflow resource. - */ - public static function workflowName(string $project, string $location, string $workflow): string - { - return self::getPathTemplate('workflow')->render([ - 'project' => $project, - 'location' => $location, - 'workflow' => $workflow, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - execution: projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} - * - workflow: projects/{project}/locations/{location}/workflows/{workflow} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'workflowexecutions.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Cancels an execution of the given name. - * - * The async variant is {@see self::cancelExecutionAsync()} . - * - * @example samples/V1/ExecutionsClient/cancel_execution.php - * - * @param CancelExecutionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Execution - * - * @throws ApiException Thrown if the API call fails. - */ - public function cancelExecution(CancelExecutionRequest $request, array $callOptions = []): Execution - { - return $this->startApiCall('CancelExecution', $request, $callOptions)->wait(); - } - - /** - * Creates a new execution using the latest revision of the given workflow. - * - * The async variant is {@see self::createExecutionAsync()} . - * - * @example samples/V1/ExecutionsClient/create_execution.php - * - * @param CreateExecutionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Execution - * - * @throws ApiException Thrown if the API call fails. - */ - public function createExecution(CreateExecutionRequest $request, array $callOptions = []): Execution - { - return $this->startApiCall('CreateExecution', $request, $callOptions)->wait(); - } - - /** - * Returns an execution of the given name. - * - * The async variant is {@see self::getExecutionAsync()} . - * - * @example samples/V1/ExecutionsClient/get_execution.php - * - * @param GetExecutionRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Execution - * - * @throws ApiException Thrown if the API call fails. - */ - public function getExecution(GetExecutionRequest $request, array $callOptions = []): Execution - { - return $this->startApiCall('GetExecution', $request, $callOptions)->wait(); - } - - /** - * Returns a list of executions which belong to the workflow with - * the given name. The method returns executions of all workflow - * revisions. Returned executions are ordered by their start time (newest - * first). - * - * The async variant is {@see self::listExecutionsAsync()} . - * - * @example samples/V1/ExecutionsClient/list_executions.php - * - * @param ListExecutionsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listExecutions(ListExecutionsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListExecutions', $request, $callOptions); - } -} diff --git a/Workflows/src/Executions/V1/Client/ExecutionsClient.php b/Workflows/src/Executions/V1/Client/ExecutionsClient.php index 2ff8b03b6b80..eeaeb5ec7f81 100644 --- a/Workflows/src/Executions/V1/Client/ExecutionsClient.php +++ b/Workflows/src/Executions/V1/Client/ExecutionsClient.php @@ -24,17 +24,324 @@ namespace Google\Cloud\Workflows\Executions\V1\Client; -use Google\Cloud\Workflows\Executions\V1\Client\BaseClient\ExecutionsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Workflows\Executions\V1\CancelExecutionRequest; +use Google\Cloud\Workflows\Executions\V1\CreateExecutionRequest; +use Google\Cloud\Workflows\Executions\V1\Execution; +use Google\Cloud\Workflows\Executions\V1\GetExecutionRequest; +use Google\Cloud\Workflows\Executions\V1\ListExecutionsRequest; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Executions is used to start and manage running instances of + * [Workflows][google.cloud.workflows.v1.Workflow] called executions. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface cancelExecutionAsync(CancelExecutionRequest $request, array $optionalArgs = []) + * @method PromiseInterface createExecutionAsync(CreateExecutionRequest $request, array $optionalArgs = []) + * @method PromiseInterface getExecutionAsync(GetExecutionRequest $request, array $optionalArgs = []) + * @method PromiseInterface listExecutionsAsync(ListExecutionsRequest $request, array $optionalArgs = []) */ -final class ExecutionsClient extends ExecutionsBaseClient +final class ExecutionsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see ExecutionsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.workflows.executions.v1.Executions'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'workflowexecutions.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/executions_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/executions_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/executions_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/executions_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a execution + * resource. + * + * @param string $project + * @param string $location + * @param string $workflow + * @param string $execution + * + * @return string The formatted execution resource. + */ + public static function executionName(string $project, string $location, string $workflow, string $execution): string + { + return self::getPathTemplate('execution')->render([ + 'project' => $project, + 'location' => $location, + 'workflow' => $workflow, + 'execution' => $execution, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a workflow + * resource. + * + * @param string $project + * @param string $location + * @param string $workflow + * + * @return string The formatted workflow resource. + */ + public static function workflowName(string $project, string $location, string $workflow): string + { + return self::getPathTemplate('workflow')->render([ + 'project' => $project, + 'location' => $location, + 'workflow' => $workflow, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - execution: projects/{project}/locations/{location}/workflows/{workflow}/executions/{execution} + * - workflow: projects/{project}/locations/{location}/workflows/{workflow} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'workflowexecutions.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Cancels an execution of the given name. + * + * The async variant is {@see ExecutionsClient::cancelExecutionAsync()} . + * + * @example samples/V1/ExecutionsClient/cancel_execution.php + * + * @param CancelExecutionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Execution + * + * @throws ApiException Thrown if the API call fails. + */ + public function cancelExecution(CancelExecutionRequest $request, array $callOptions = []): Execution + { + return $this->startApiCall('CancelExecution', $request, $callOptions)->wait(); + } + + /** + * Creates a new execution using the latest revision of the given workflow. + * + * The async variant is {@see ExecutionsClient::createExecutionAsync()} . + * + * @example samples/V1/ExecutionsClient/create_execution.php + * + * @param CreateExecutionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Execution + * + * @throws ApiException Thrown if the API call fails. + */ + public function createExecution(CreateExecutionRequest $request, array $callOptions = []): Execution + { + return $this->startApiCall('CreateExecution', $request, $callOptions)->wait(); + } + + /** + * Returns an execution of the given name. + * + * The async variant is {@see ExecutionsClient::getExecutionAsync()} . + * + * @example samples/V1/ExecutionsClient/get_execution.php + * + * @param GetExecutionRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Execution + * + * @throws ApiException Thrown if the API call fails. + */ + public function getExecution(GetExecutionRequest $request, array $callOptions = []): Execution + { + return $this->startApiCall('GetExecution', $request, $callOptions)->wait(); + } + + /** + * Returns a list of executions which belong to the workflow with + * the given name. The method returns executions of all workflow + * revisions. Returned executions are ordered by their start time (newest + * first). + * + * The async variant is {@see ExecutionsClient::listExecutionsAsync()} . + * + * @example samples/V1/ExecutionsClient/list_executions.php + * + * @param ListExecutionsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listExecutions(ListExecutionsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListExecutions', $request, $callOptions); + } } diff --git a/Workflows/src/V1/Client/BaseClient/WorkflowsBaseClient.php b/Workflows/src/V1/Client/BaseClient/WorkflowsBaseClient.php deleted file mode 100644 index 0a3f2525cbca..000000000000 --- a/Workflows/src/V1/Client/BaseClient/WorkflowsBaseClient.php +++ /dev/null @@ -1,494 +0,0 @@ - self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../../resources/workflows_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../../resources/workflows_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../../resources/workflows_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../../resources/workflows_rest_client_config.php', - ], - ], - ]; - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * Resume an existing long running operation that was previously started by a long - * running API method. If $methodName is not provided, or does not match a long - * running API method, then the operation can still be resumed, but the - * OperationResponse object will not deserialize the final response. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Formats a string containing the fully-qualified path to represent a crypto_key - * resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * @param string $cryptoKey - * - * @return string The formatted crypto_key resource. - */ - public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string - { - return self::getPathTemplate('cryptoKey')->render([ - 'project' => $project, - 'location' => $location, - 'keyRing' => $keyRing, - 'cryptoKey' => $cryptoKey, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName(string $project, string $location): string - { - return self::getPathTemplate('location')->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a workflow - * resource. - * - * @param string $project - * @param string $location - * @param string $workflow - * - * @return string The formatted workflow resource. - */ - public static function workflowName(string $project, string $location, string $workflow): string - { - return self::getPathTemplate('workflow')->render([ - 'project' => $project, - 'location' => $location, - 'workflow' => $workflow, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - cryptoKey: projects/{project}/locations/{location}/keyRings/{keyRing}/cryptoKeys/{cryptoKey} - * - location: projects/{project}/locations/{location} - * - workflow: projects/{project}/locations/{location}/workflows/{workflow} - * - * 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(string $formattedName, string $template = null): array - { - return self::parseFormattedName($formattedName, $template); - } - - /** - * 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 'workflows.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 - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** Handles execution of the async variants for each documented method. */ - public function __call($method, $args) - { - if (substr($method, -5) !== 'Async') { - trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); - } - - array_unshift($args, substr($method, 0, -5)); - return call_user_func_array([$this, 'startAsyncCall'], $args); - } - - /** - * Creates a new workflow. If a workflow with the specified name already - * exists in the specified project and location, the long running operation - * returns a [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error. - * - * The async variant is {@see self::createWorkflowAsync()} . - * - * @example samples/V1/WorkflowsClient/create_workflow.php - * - * @param CreateWorkflowRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function createWorkflow(CreateWorkflowRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('CreateWorkflow', $request, $callOptions)->wait(); - } - - /** - * Deletes a workflow with the specified name. - * This method also cancels and deletes all running executions of the - * workflow. - * - * The async variant is {@see self::deleteWorkflowAsync()} . - * - * @example samples/V1/WorkflowsClient/delete_workflow.php - * - * @param DeleteWorkflowRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function deleteWorkflow(DeleteWorkflowRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('DeleteWorkflow', $request, $callOptions)->wait(); - } - - /** - * Gets details of a single workflow. - * - * The async variant is {@see self::getWorkflowAsync()} . - * - * @example samples/V1/WorkflowsClient/get_workflow.php - * - * @param GetWorkflowRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Workflow - * - * @throws ApiException Thrown if the API call fails. - */ - public function getWorkflow(GetWorkflowRequest $request, array $callOptions = []): Workflow - { - return $this->startApiCall('GetWorkflow', $request, $callOptions)->wait(); - } - - /** - * Lists workflows in a given project and location. - * The default order is not specified. - * - * The async variant is {@see self::listWorkflowsAsync()} . - * - * @example samples/V1/WorkflowsClient/list_workflows.php - * - * @param ListWorkflowsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listWorkflows(ListWorkflowsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListWorkflows', $request, $callOptions); - } - - /** - * Updates an existing workflow. - * Running this method has no impact on already running executions of the - * workflow. A new revision of the workflow might be created as a result of a - * successful update operation. In that case, the new revision is used - * in new workflow executions. - * - * The async variant is {@see self::updateWorkflowAsync()} . - * - * @example samples/V1/WorkflowsClient/update_workflow.php - * - * @param UpdateWorkflowRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 OperationResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function updateWorkflow(UpdateWorkflowRequest $request, array $callOptions = []): OperationResponse - { - return $this->startApiCall('UpdateWorkflow', $request, $callOptions)->wait(); - } - - /** - * Gets information about a location. - * - * The async variant is {@see self::getLocationAsync()} . - * - * @example samples/V1/WorkflowsClient/get_location.php - * - * @param GetLocationRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 Location - * - * @throws ApiException Thrown if the API call fails. - */ - public function getLocation(GetLocationRequest $request, array $callOptions = []): Location - { - return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); - } - - /** - * Lists information about the supported locations for this service. - * - * The async variant is {@see self::listLocationsAsync()} . - * - * @example samples/V1/WorkflowsClient/list_locations.php - * - * @param ListLocationsRequest $request A request to house fields associated with the call. - * @param array $callOptions { - * 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 PagedListResponse - * - * @throws ApiException Thrown if the API call fails. - */ - public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse - { - return $this->startApiCall('ListLocations', $request, $callOptions); - } -} diff --git a/Workflows/src/V1/Client/WorkflowsClient.php b/Workflows/src/V1/Client/WorkflowsClient.php index 4c5a9c18fa50..f928ba8e24fa 100644 --- a/Workflows/src/V1/Client/WorkflowsClient.php +++ b/Workflows/src/V1/Client/WorkflowsClient.php @@ -24,17 +24,469 @@ namespace Google\Cloud\Workflows\V1\Client; -use Google\Cloud\Workflows\V1\Client\BaseClient\WorkflowsBaseClient; +use Google\ApiCore\ApiException; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\GapicClientTrait; +use Google\ApiCore\LongRunning\OperationsClient; +use Google\ApiCore\OperationResponse; +use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ResourceHelperTrait; +use Google\ApiCore\RetrySettings; +use Google\ApiCore\Transport\TransportInterface; +use Google\ApiCore\ValidationException; +use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\Location; +use Google\Cloud\Workflows\V1\CreateWorkflowRequest; +use Google\Cloud\Workflows\V1\DeleteWorkflowRequest; +use Google\Cloud\Workflows\V1\GetWorkflowRequest; +use Google\Cloud\Workflows\V1\ListWorkflowsRequest; +use Google\Cloud\Workflows\V1\UpdateWorkflowRequest; +use Google\Cloud\Workflows\V1\Workflow; +use Google\LongRunning\Operation; +use GuzzleHttp\Promise\PromiseInterface; /** - * {@inheritdoc} + * Service Description: Workflows is used to deploy and execute workflow programs. + * Workflows makes sure the program executes reliably, despite hardware and + * networking interruptions. + * + * This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. + * + * 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. * * This class is currently experimental and may be subject to changes. * * @experimental + * + * @method PromiseInterface createWorkflowAsync(CreateWorkflowRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteWorkflowAsync(DeleteWorkflowRequest $request, array $optionalArgs = []) + * @method PromiseInterface getWorkflowAsync(GetWorkflowRequest $request, array $optionalArgs = []) + * @method PromiseInterface listWorkflowsAsync(ListWorkflowsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateWorkflowAsync(UpdateWorkflowRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) */ -final class WorkflowsClient extends WorkflowsBaseClient +final class WorkflowsClient { - // This class is intentionally empty, and is intended to hold manual additions to - // the generated {@see WorkflowsBaseClient} class. + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.workflows.v1.Workflows'; + + /** The default address of the service. */ + private const SERVICE_ADDRESS = 'workflows.googleapis.com'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = [ + 'https://www.googleapis.com/auth/cloud-platform', + ]; + + private $operationsClient; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/workflows_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/workflows_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/workflows_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => __DIR__ . '/../resources/workflows_rest_client_config.php', + ], + ], + ]; + } + + /** + * Return an OperationsClient object with the same endpoint as $this. + * + * @return OperationsClient + */ + public function getOperationsClient() + { + return $this->operationsClient; + } + + /** + * Resume an existing long running operation that was previously started by a long + * running API method. If $methodName is not provided, or does not match a long + * running API method, then the operation can still be resumed, but the + * OperationResponse object will not deserialize the final response. + * + * @param string $operationName The name of the long running operation + * @param string $methodName The name of the method used to start the operation + * + * @return OperationResponse + */ + public function resumeOperation($operationName, $methodName = null) + { + $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; + $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); + $operation->reload(); + return $operation; + } + + /** + * Formats a string containing the fully-qualified path to represent a crypto_key + * resource. + * + * @param string $project + * @param string $location + * @param string $keyRing + * @param string $cryptoKey + * + * @return string The formatted crypto_key resource. + */ + public static function cryptoKeyName(string $project, string $location, string $keyRing, string $cryptoKey): string + { + return self::getPathTemplate('cryptoKey')->render([ + 'project' => $project, + 'location' => $location, + 'keyRing' => $keyRing, + 'cryptoKey' => $cryptoKey, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Formats a string containing the fully-qualified path to represent a workflow + * resource. + * + * @param string $project + * @param string $location + * @param string $workflow + * + * @return string The formatted workflow resource. + */ + public static function workflowName(string $project, string $location, string $workflow): string + { + return self::getPathTemplate('workflow')->render([ + 'project' => $project, + 'location' => $location, + 'workflow' => $workflow, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - cryptoKey: projects/{project}/locations/{location}/keyRings/{keyRing}/cryptoKeys/{cryptoKey} + * - location: projects/{project}/locations/{location} + * - workflow: projects/{project}/locations/{location}/workflows/{workflow} + * + * 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(string $formattedName, string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * 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 'workflows.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 + */ + public function __construct(array $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + $this->operationsClient = $this->createOperationsClient($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Creates a new workflow. If a workflow with the specified name already + * exists in the specified project and location, the long running operation + * returns a [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS] error. + * + * The async variant is {@see WorkflowsClient::createWorkflowAsync()} . + * + * @example samples/V1/WorkflowsClient/create_workflow.php + * + * @param CreateWorkflowRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createWorkflow(CreateWorkflowRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateWorkflow', $request, $callOptions)->wait(); + } + + /** + * Deletes a workflow with the specified name. + * This method also cancels and deletes all running executions of the + * workflow. + * + * The async variant is {@see WorkflowsClient::deleteWorkflowAsync()} . + * + * @example samples/V1/WorkflowsClient/delete_workflow.php + * + * @param DeleteWorkflowRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteWorkflow(DeleteWorkflowRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteWorkflow', $request, $callOptions)->wait(); + } + + /** + * Gets details of a single workflow. + * + * The async variant is {@see WorkflowsClient::getWorkflowAsync()} . + * + * @example samples/V1/WorkflowsClient/get_workflow.php + * + * @param GetWorkflowRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Workflow + * + * @throws ApiException Thrown if the API call fails. + */ + public function getWorkflow(GetWorkflowRequest $request, array $callOptions = []): Workflow + { + return $this->startApiCall('GetWorkflow', $request, $callOptions)->wait(); + } + + /** + * Lists workflows in a given project and location. + * The default order is not specified. + * + * The async variant is {@see WorkflowsClient::listWorkflowsAsync()} . + * + * @example samples/V1/WorkflowsClient/list_workflows.php + * + * @param ListWorkflowsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listWorkflows(ListWorkflowsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListWorkflows', $request, $callOptions); + } + + /** + * Updates an existing workflow. + * Running this method has no impact on already running executions of the + * workflow. A new revision of the workflow might be created as a result of a + * successful update operation. In that case, the new revision is used + * in new workflow executions. + * + * The async variant is {@see WorkflowsClient::updateWorkflowAsync()} . + * + * @example samples/V1/WorkflowsClient/update_workflow.php + * + * @param UpdateWorkflowRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateWorkflow(UpdateWorkflowRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateWorkflow', $request, $callOptions)->wait(); + } + + /** + * Gets information about a location. + * + * The async variant is {@see WorkflowsClient::getLocationAsync()} . + * + * @example samples/V1/WorkflowsClient/get_location.php + * + * @param GetLocationRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is {@see WorkflowsClient::listLocationsAsync()} . + * + * @example samples/V1/WorkflowsClient/list_locations.php + * + * @param ListLocationsRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * 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 PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } } diff --git a/composer.json b/composer.json index d14d20e3db3d..d2836321b55c 100644 --- a/composer.json +++ b/composer.json @@ -2,6 +2,7 @@ "name": "google/cloud", "type": "library", "description": "Google Cloud Client Library", + "abandoned": true, "keywords": [ "google apis client", "google api client", @@ -50,7 +51,7 @@ "monolog/monolog": "^2.0||^3.0", "psr/http-message": "^1.0|^2.0", "ramsey/uuid": "^4.0", - "google/gax": "^1.19.1", + "google/gax": "^1.24.0", "google/common-protos": "^4.0", "google/auth": "^1.18" }, @@ -74,7 +75,7 @@ "google/analytics-data": "0.11.1", "google/cloud-access-approval": "1.1.2", "google/cloud-advisorynotifications": "0.5.0", - "google/cloud-ai-platform": "0.25.0", + "google/cloud-ai-platform": "0.26.0", "google/cloud-alloydb": "0.7.0", "google/cloud-api-gateway": "1.2.0", "google/cloud-api-keys": "0.3.1", @@ -86,7 +87,7 @@ "google/cloud-assured-workloads": "0.10.0", "google/cloud-automl": "1.5.2", "google/cloud-bare-metal-solution": "0.5.0", - "google/cloud-batch": "0.11.3", + "google/cloud-batch": "0.12.0", "google/cloud-beyondcorp-appconnections": "0.3.0", "google/cloud-beyondcorp-appconnectors": "0.3.0", "google/cloud-beyondcorp-appgateways": "0.3.0", @@ -101,7 +102,7 @@ "google/cloud-bigquery-reservation": "1.2.2", "google/cloud-bigquery-storage": "1.7.0", "google/cloud-bigquerydatatransfer": "1.6.1", - "google/cloud-bigtable": "1.28.3", + "google/cloud-bigtable": "1.29.0", "google/cloud-billing": "1.7.4", "google/cloud-billing-budgets": "1.3.0", "google/cloud-binary-authorization": "0.6.0", @@ -116,7 +117,7 @@ "google/cloud-contact-center-insights": "1.6.0", "google/cloud-container": "1.21.0", "google/cloud-container-analysis": "0.3.3", - "google/cloud-core": "1.52.5", + "google/cloud-core": "1.52.6", "google/cloud-data-catalog": "1.8.0", "google/cloud-data-fusion": "0.5.0", "google/cloud-datacatalog-lineage": "0.3.0", @@ -142,7 +143,7 @@ "google/cloud-eventarc": "1.2.0", "google/cloud-eventarc-publishing": "0.5.0", "google/cloud-filestore": "1.3.0", - "google/cloud-firestore": "1.37.2", + "google/cloud-firestore": "1.37.3", "google/cloud-functions": "1.4.0", "google/cloud-game-servers": "1.2.0", "google/cloud-gke-backup": "0.5.1", @@ -182,7 +183,7 @@ "google/cloud-profiler": "1.2.2", "google/cloud-pubsub": "1.46.3", "google/cloud-rapidmigrationassessment": "0.2.1", - "google/cloud-recaptcha-enterprise": "1.4.2", + "google/cloud-recaptcha-enterprise": "1.5.0", "google/cloud-recommendations-ai": "0.6.2", "google/cloud-recommender": "1.9.0", "google/cloud-redis": "1.8.2", @@ -202,7 +203,7 @@ "google/cloud-shell": "1.2.0", "google/cloud-spanner": "1.64.0", "google/cloud-speech": "1.14.2", - "google/cloud-sql-admin": "0.5.0", + "google/cloud-sql-admin": "0.6.0", "google/cloud-storage": "1.33.3", "google/cloud-storage-transfer": "1.3.0", "google/cloud-storageinsights": "0.2.2", diff --git a/dev/sh/bump-gax.sh b/dev/sh/bump-dep.sh similarity index 63% rename from dev/sh/bump-gax.sh rename to dev/sh/bump-dep.sh index 65c2256fb871..e5c0d25e23b0 100755 --- a/dev/sh/bump-gax.sh +++ b/dev/sh/bump-dep.sh @@ -7,8 +7,10 @@ set -ev # version to the specified command line argument. # # Usage (to update gax version to e.g. 0.1.2): -# $ ./dev/sh/bump-gax.sh 0.1.2 +# $ ./dev/sh/bump-dep.sh 'google/gax' 0.1.2 + +dep=$(echo $1 | sed 's/\//\\\//g') find . -maxdepth 2 -name composer.json \ -not -path "./vendor/*" \ - -exec sed -i "s/google\/gax[\"']: [\"']\^[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?[\"']/google\/gax\": \"\^$1\"/" "{}" \; + -exec sed -i "s/$dep[\"']: [\"']\^[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?[\"']/$dep\": \"\^$2\"/" "{}" \; diff --git a/dev/src/Command/ComponentInfoCommand.php b/dev/src/Command/ComponentInfoCommand.php index d1ed1f50a64a..a78a558a2dd8 100644 --- a/dev/src/Command/ComponentInfoCommand.php +++ b/dev/src/Command/ComponentInfoCommand.php @@ -141,49 +141,53 @@ protected function execute(InputInterface $input, OutputInterface $output) private function getComponentDetails(Component $component, array $requestedFields, bool $expanded): array { $rows = []; - // use "array_intersect_key" to filter out fields that were not requested. - // use "array_replace" to sort the fields in the order they were requested. - $details = array_replace($requestedFields, array_intersect_key([ - 'name' => $component->getName(), - 'package_name' => $component->getPackageName(), - 'package_version' => $component->getPackageVersion(), - 'api_versions' => $expanded ? '' : implode("\n", $component->getApiVersions()), - 'release_level' => $component->getReleaseLevel(), - 'migration' => $expanded ? '' : implode("\n", $component->getMigrationStatuses()), - 'php_namespaces' => implode("\n", array_keys($component->getNamespaces())), - 'github_repo' => $component->getRepoName(), - 'proto' => $expanded ? '' : implode("\n", $component->getProtoPackages()), - 'service_address' => $expanded ? '' : implode("\n", $component->getServiceAddresses()), - 'shortname' => $expanded ? '' : implode("\n", $component->getApiShortnames()), - 'description' => $component->getDescription(), - ], $requestedFields)); - - if (array_key_exists('available_api_versions', $requestedFields)) { - $details['available_api_versions'] = $this->getAvailableApiVersions($component); - } - - $rows[] = $details; - if ($expanded) { foreach ($component->getComponentPackages() as $pkg) { + $availableApiVersions = ''; + if (array_key_exists('available_api_versions', $requestedFields)) { + $availableApiVersions = $this->getAvailableApiVersions($component); + } // use "array_intersect_key" to filter out fields that were not requested. // use "array_replace" to sort the fields in the order they were requested. $rows[] = array_replace($requestedFields, array_intersect_key([ - 'name' => " " . $pkg->getName(), - 'package_name' => '', // defined by component - 'package_version' => '', // defined by component - 'api_versions' => '', // included in "name" - 'release_level' => '', // defined by component + 'name' => $component->getName() . "\\" . $pkg->getName(), + 'package_name' => $component->getPackageName(), + 'package_version' => $component->getPackageVersion(), + 'api_versions' => $pkg->getName(), + 'release_level' => $component->getReleaseLevel(), 'migration' => $pkg->getMigrationStatus(), - 'php_namespaces' => '', // defined by component - 'github_repo' => '', // defined by component + 'php_namespaces' => implode("\n", array_keys($component->getNamespaces())), + 'github_repo' => $component->getRepoName(), 'proto' => $pkg->getProtoPackage(), 'service_address' => $pkg->getServiceAddress(), 'shortname' => $pkg->getApiShortname(), - 'description' => '', // defined by component - 'available_api_versions' => '', // defined by component + 'description' => $component->getDescription(), + 'available_api_versions' => $availableApiVersions, ], $requestedFields)); } + } else { + // use "array_intersect_key" to filter out fields that were not requested. + // use "array_replace" to sort the fields in the order they were requested. + $details = array_replace($requestedFields, array_intersect_key([ + 'name' => $component->getName(), + 'package_name' => $component->getPackageName(), + 'package_version' => $component->getPackageVersion(), + 'api_versions' => implode("\n", $component->getApiVersions()), + 'release_level' => $component->getReleaseLevel(), + 'migration' => implode("\n", $component->getMigrationStatuses()), + 'php_namespaces' => implode("\n", array_keys($component->getNamespaces())), + 'github_repo' => $component->getRepoName(), + 'proto' => implode("\n", $component->getProtoPackages()), + 'service_address' => implode("\n", $component->getServiceAddresses()), + 'shortname' => implode("\n", $component->getApiShortnames()), + 'description' => $component->getDescription(), + ], $requestedFields)); + + if (array_key_exists('available_api_versions', $requestedFields)) { + $details['available_api_versions'] = $this->getAvailableApiVersions($component); + } + + $rows[] = $details; } return $rows; diff --git a/dev/src/ComponentPackage.php b/dev/src/ComponentPackage.php index 3667ef1ea4dd..74c61d84ec69 100644 --- a/dev/src/ComponentPackage.php +++ b/dev/src/ComponentPackage.php @@ -33,6 +33,11 @@ class ComponentPackage \* Updates to the above are reflected here through a refresh process#'; private string $path; + private const MIGRATION_V1 = 'v1'; + private const MIGRATION_V2 = 'v2'; + private const MIGRATION_V1_AND_V2 = 'v1 and v2'; + private const MIGRATION_NA = 'n/a'; + public function __construct(private Component $component, private string $name) { $this->path = $component->getPath() . '/src/' . $name; @@ -45,7 +50,7 @@ public function getName(): string public function getProtoPackage(): string { - $gapicClientFiles = $this->getV1GapicClientFiles() + $this->getV2BaseClientFiles(); + $gapicClientFiles = $this->getV1GapicClientFiles() + $this->getV2ClientFiles(); foreach ($gapicClientFiles as $file) { $gapicClientContent = file_get_contents($file); @@ -60,16 +65,16 @@ public function getProtoPackage(): string public function getMigrationStatus() { $hasV1Clients = count($this->getV1GapicClientFiles()) > 0; - $hasV2Clients = count($this->getV2BaseClientFiles()) > 0; + $hasV2Clients = count($this->getV2ClientFiles()) > 0; if ($hasV1Clients) { - return $hasV2Clients ? 'v1+v2' : 'v1'; + return $hasV2Clients ? self::MIGRATION_V1_AND_V2 : self::MIGRATION_V1; } - return $hasV2Clients ? 'v2' : 'n/a'; + return $hasV2Clients ? self::MIGRATION_V2 : self::MIGRATION_NA; } public function getServiceAddress(): string { - $gapicClientFiles = $this->getV1GapicClientFiles() + $this->getV2BaseClientFiles(); + $gapicClientFiles = $this->getV1GapicClientFiles() + $this->getV2ClientFiles(); $gapicClientClasses = array_map(fn ($fp) => $this->getClassFromFile($fp), $gapicClientFiles); foreach ($gapicClientClasses as $className) { @@ -96,17 +101,20 @@ public function getApiShortname(): string private function getV1GapicClientFiles(): array { - return $this->getFilesInDir('*GapicClient.php'); + return $this->getFilesInDir('*GapicClient.php', $this->path . '/Gapic'); } - private function getV2BaseClientFiles(): array + private function getV2ClientFiles(): array { - return $this->getFilesInDir('*BaseClient.php'); + return $this->getFilesInDir('*Client.php', $this->path . '/Client'); } - private function getFilesInDir(string $pattern): array + private function getFilesInDir(string $pattern, string $dir): array { - $result = (new Finder())->files()->name($pattern)->in($this->path); + if (!is_dir($dir)) { + return []; + } + $result = (new Finder())->files()->name($pattern)->in($dir); return array_map(fn ($file) => $file->getRealPath(), iterator_to_array($result)); } diff --git a/dev/src/DocFx/Node/ClassNode.php b/dev/src/DocFx/Node/ClassNode.php index 731011b5b56e..9ec6b0ad16eb 100644 --- a/dev/src/DocFx/Node/ClassNode.php +++ b/dev/src/DocFx/Node/ClassNode.php @@ -92,15 +92,18 @@ public function isV1ServiceClass(): bool public function isServiceBaseClass(): bool { // returns true if the class extends a generated GAPIC client - return 'GapicClient' === substr($this->getName(), -11) - || 'BaseClient' === substr($this->getName(), -10); + return 'GapicClient' === substr($this->getName(), -11); } public function isV2ServiceClass(): bool { - // returns true if the class extends a generated V2 GAPIC client - if ($extends = $this->getExtends()) { - return 'BaseClient' === substr($extends, -10); + // returns true if the class does not extend another class and isn't a + // base class + if (!$this->getExtends() + && !$this->isServiceBaseClass() + && 'Client' === substr($this->getName(), -6) + ) { + return true; } return false; } diff --git a/dev/src/DocFx/Page/PageTree.php b/dev/src/DocFx/Page/PageTree.php index d26108b97a6e..1c5797eb409c 100644 --- a/dev/src/DocFx/Page/PageTree.php +++ b/dev/src/DocFx/Page/PageTree.php @@ -79,24 +79,18 @@ private function loadPages(): array } // Manually skip GAPIC base clients - $fullName = $classNode->getFullname(); - if ('GapicClient' === substr($fullName, -11) - || 'BaseClient' === substr($fullName, -10)) { + if ($classNode->isServiceBaseClass()) { $gapicClients[] = $classNode; continue; } // Skip internal classes - // Do this after the GAPIC check because new base clients are internal if ($classNode->isInternal()) { continue; } - if ($classNode->isV1ServiceClass()) { - $this->hasV1Client = true; - } elseif ($classNode->isV2ServiceClass()) { - $this->hasV2Client = true; - } + $this->hasV1Client |= $classNode->isV1ServiceClass(); + $this->hasV2Client |= $classNode->isV2ServiceClass(); // Manually skip protobuf enums in favor of Gapic enums (see below). // @TODO: Do not generate them in V2, eventually mark them as deprecated @@ -104,6 +98,7 @@ private function loadPages(): array // Manually skip Grpc classes // @TODO: Do not generate Grpc classes in V2, eventually mark these as deprecated + $fullName = $classNode->getFullname(); if ( 'GrpcClient' === substr($fullName, -10) && '\Grpc\BaseStub' === $classNode->getExtends() @@ -142,6 +137,18 @@ private function loadPages(): array // We no longer need the array keys $pages = array_values($pageMap); + // Mark V2 services as "beta" if they have a V1 client + if ($this->hasV1Client && $this->hasV2Client) { + foreach ($pages as $page) { + if ($page->getClassNode()->isV2ServiceClass()) { + $page->getClassNode()->setTocName(sprintf( + '%s (beta)', + $page->getClassNode()->getName() + )); + } + } + } + /** * Set a map of protobuf package names to PHP namespaces for Xrefs. * This MUST be done after combining GAPIC clients. @@ -175,25 +182,13 @@ private function combineGapicClients(array $gapicClients, array $pageMap): array foreach ($gapicClients as $gapicClient) { // Find Classname $parts = explode('\\', $gapicClient->getFullName()); - $clientClassName = str_replace( - ['BaseClient', 'GapicClient'], - 'Client', - array_pop($parts) - ); - array_pop($parts); // remove "Gapic" or "Client" namespace + $clientClassName = str_replace('GapicClient', 'Client', array_pop($parts)); + array_pop($parts); // remove "Gapic" namespace $parts[] = $clientClassName; $clientFullName = implode('\\', $parts); if (isset($pageMap[$clientFullName])) { $parentClassNode = $pageMap[$clientFullName]->getClassNode(); $parentClassNode->setChildNode($gapicClient); - if ($this->hasV1Client && $this->hasV2Client) { - if ($parentClassNode->isV2ServiceClass()) { - $parentClassNode->setTocName(sprintf( - '%s (beta)', - $parentClassNode->getName() - )); - } - } } } diff --git a/dev/tests/Unit/Command/DocFxCommandTest.php b/dev/tests/Unit/Command/DocFxCommandTest.php index cff9f394ea01..9de63b67c3db 100644 --- a/dev/tests/Unit/Command/DocFxCommandTest.php +++ b/dev/tests/Unit/Command/DocFxCommandTest.php @@ -76,6 +76,21 @@ public function testGenerateNewClientStructureXml() $this->assertFileEqualsWithDiff($left, $right, '1' === getenv('UPDATE_FIXTURES')); } + public function testGenerateSnippetsStructureXml() + { + $structureXml = __DIR__ . '/../../fixtures/phpdoc/clientsnippets.xml'; + $componentPath = __DIR__ . '/../../fixtures/component/ClientSnippets'; + + $process = DocFxCommand::getPhpDocCommand($componentPath, self::$tmpDir); + $process->mustRun(); + + $this->assertFileEqualsWithDiff( + $structureXml, + self::$tmpDir . '/structure.xml', + '1' === getenv('UPDATE_FIXTURES') + ); + } + public function testGenerateDocFxFiles() { $fixturesFiles = array_diff(scandir(self::$fixturesDir . '/docfx/Vision'), ['..', '.']); @@ -92,7 +107,7 @@ public function testDocFxFiles(string $file) { $this->assertTrue( file_exists(self::$fixturesDir . '/docfx/Vision/' . $file), - sprintf('%s does not exist in fixtures (%s)', $file, self::$tmpDir . '/' . $file) + sprintf('tests/fixtures/docfx/%s does not exist (%s)', $file, self::$tmpDir . '/' . $file) ); $left = self::$fixturesDir . '/docfx/Vision/' . $file; diff --git a/dev/tests/fixtures/component/ClientSnippets/src/V1/Client/BaseClient/ClientSnippetsBaseClient.php b/dev/tests/fixtures/component/ClientSnippets/src/V1/Client/BaseClient/ClientSnippetsBaseClient.php deleted file mode 100644 index d5ac982289dc..000000000000 --- a/dev/tests/fixtures/component/ClientSnippets/src/V1/Client/BaseClient/ClientSnippetsBaseClient.php +++ /dev/null @@ -1,14 +0,0 @@ -Secret + * SecretVersion + + This class provides the ability to make remote calls to the backing service through method + calls that map to API methods. + + 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. + + This class is currently experimental and may be subject to changes. See Google\Cloud\SecretManager\V1\SecretManagerServiceClient for the stable + implementation status: beta type: class namespace: 'Google \ Cloud \ SecretManager \ V1 \ Client' @@ -49,6 +64,7 @@ items: - '\Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::projectName()' - '\Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::secretName()' - '\Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::secretVersionName()' + - '\Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::topicName()' - '\Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::parseName()' - uid: '\Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::__construct()' @@ -107,7 +123,8 @@ items: `projects/*/secrets/*/versions/latest` is an alias to the most recently created SecretVersion. - The async variant is Google\Cloud\SecretManager\V1\Client\BaseClient\self::accessSecretVersionAsync() . + The async variant is + Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::accessSecretVersionAsync() . parent: \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient type: method langs: @@ -137,7 +154,8 @@ items: Creates a new SecretVersion containing secret data and attaches it to an existing Secret. - The async variant is Google\Cloud\SecretManager\V1\Client\BaseClient\self::addSecretVersionAsync() . + The async variant is Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::addSecretVersionAsync() + . parent: \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient type: method langs: @@ -166,7 +184,7 @@ items: summary: |- Creates a new Secret containing no SecretVersions. - The async variant is Google\Cloud\SecretManager\V1\Client\BaseClient\self::createSecretAsync() . + The async variant is Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::createSecretAsync() . parent: \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient type: method langs: @@ -195,7 +213,7 @@ items: summary: |- Deletes a Secret. - The async variant is Google\Cloud\SecretManager\V1\Client\BaseClient\self::deleteSecretAsync() . + The async variant is Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::deleteSecretAsync() . parent: \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient type: method langs: @@ -225,7 +243,8 @@ items: DESTROYED and irrevocably destroys the secret data. - The async variant is Google\Cloud\SecretManager\V1\Client\BaseClient\self::destroySecretVersionAsync() . + The async variant is + Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::destroySecretVersionAsync() . parent: \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient type: method langs: @@ -257,7 +276,8 @@ items: Sets the state of the SecretVersion to DISABLED. - The async variant is Google\Cloud\SecretManager\V1\Client\BaseClient\self::disableSecretVersionAsync() . + The async variant is + Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::disableSecretVersionAsync() . parent: \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient type: method langs: @@ -289,7 +309,8 @@ items: Sets the state of the SecretVersion to ENABLED. - The async variant is Google\Cloud\SecretManager\V1\Client\BaseClient\self::enableSecretVersionAsync() . + The async variant is + Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::enableSecretVersionAsync() . parent: \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient type: method langs: @@ -320,7 +341,7 @@ items: Returns empty policy if the secret exists and does not have a policy set. - The async variant is Google\Cloud\SecretManager\V1\Client\BaseClient\self::getIamPolicyAsync() . + The async variant is Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::getIamPolicyAsync() . parent: \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient type: method langs: @@ -349,7 +370,7 @@ items: summary: |- Gets metadata for a given Secret. - The async variant is Google\Cloud\SecretManager\V1\Client\BaseClient\self::getSecretAsync() . + The async variant is Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::getSecretAsync() . parent: \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient type: method langs: @@ -381,7 +402,8 @@ items: `projects/*/secrets/*/versions/latest` is an alias to the most recently created SecretVersion. - The async variant is Google\Cloud\SecretManager\V1\Client\BaseClient\self::getSecretVersionAsync() . + The async variant is Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::getSecretVersionAsync() + . parent: \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient type: method langs: @@ -411,7 +433,8 @@ items: Lists SecretVersions. This call does not return secret data. - The async variant is Google\Cloud\SecretManager\V1\Client\BaseClient\self::listSecretVersionsAsync() . + The async variant is + Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::listSecretVersionsAsync() . parent: \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient type: method langs: @@ -440,7 +463,7 @@ items: summary: |- Lists Secrets. - The async variant is Google\Cloud\SecretManager\V1\Client\BaseClient\self::listSecretsAsync() . + The async variant is Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::listSecretsAsync() . parent: \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient type: method langs: @@ -473,7 +496,7 @@ items: Permissions on SecretVersions are enforced according to the policy set on the associated Secret. - The async variant is Google\Cloud\SecretManager\V1\Client\BaseClient\self::setIamPolicyAsync() . + The async variant is Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::setIamPolicyAsync() . parent: \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient type: method langs: @@ -509,7 +532,8 @@ items: UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning. - The async variant is Google\Cloud\SecretManager\V1\Client\BaseClient\self::testIamPermissionsAsync() . + The async variant is + Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::testIamPermissionsAsync() . parent: \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient type: method langs: @@ -538,7 +562,7 @@ items: summary: |- Updates metadata of an existing Secret. - The async variant is Google\Cloud\SecretManager\V1\Client\BaseClient\self::updateSecretAsync() . + The async variant is Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::updateSecretAsync() . parent: \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient type: method langs: @@ -950,6 +974,31 @@ items: - var_type: string description: 'The formatted secret_version resource.' + - + uid: '\Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::topicName()' + name: 'static::topicName' + id: topicName + summary: |- + Formats a string containing the fully-qualified path to represent a topic + resource. + parent: \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient + type: method + langs: + - php + syntax: + parameters: + - + id: project + var_type: string + description: '' + - + id: topic + var_type: string + description: '' + returns: + - + var_type: string + description: 'The formatted topic resource.' - uid: '\Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::parseName()' name: 'static::parseName' @@ -962,6 +1011,7 @@ items: - project: projects/{project} - secret: projects/{project}/secrets/{secret} - secretVersion: projects/{project}/secrets/{secret}/versions/{secret_version} + - topic: projects/{project}/topics/{topic} 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 diff --git a/dev/tests/fixtures/docfx/Vision/V1.AddProductToProductSetRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.AddProductToProductSetRequest.yml index f0e9487bc831..34958db123a2 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.AddProductToProductSetRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.AddProductToProductSetRequest.yml @@ -19,6 +19,7 @@ items: - '\Google\Cloud\Vision\V1\AddProductToProductSetRequest::setName()' - '\Google\Cloud\Vision\V1\AddProductToProductSetRequest::getProduct()' - '\Google\Cloud\Vision\V1\AddProductToProductSetRequest::setProduct()' + - '\Google\Cloud\Vision\V1\AddProductToProductSetRequest::build()' - uid: '\Google\Cloud\Vision\V1\AddProductToProductSetRequest::__construct()' name: __construct @@ -120,3 +121,34 @@ items: returns: - var_type: $this + - + uid: '\Google\Cloud\Vision\V1\AddProductToProductSetRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\AddProductToProductSetRequest + type: method + langs: + - php + syntax: + parameters: + - + id: name + var_type: string + description: |- + Required. The resource name for the ProductSet to modify. + + Format is: + `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + Please see Google\Cloud\Vision\V1\ProductSearchClient::productSetName() for help formatting this field. + - + id: product + var_type: string + description: |- + Required. The resource name for the Product to be added to this ProductSet. + + Format is: + `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + Please see Google\Cloud\Vision\V1\ProductSearchClient::productName() for help formatting this field. + returns: + - + var_type: 'Google\Cloud\Vision\V1\AddProductToProductSetRequest' diff --git a/dev/tests/fixtures/docfx/Vision/V1.AsyncBatchAnnotateFilesRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.AsyncBatchAnnotateFilesRequest.yml index 46ac9549f176..c56bf1c01de2 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.AsyncBatchAnnotateFilesRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.AsyncBatchAnnotateFilesRequest.yml @@ -20,6 +20,7 @@ items: - '\Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest::setRequests()' - '\Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest::getParent()' - '\Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest::setParent()' + - '\Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest::build()' - uid: '\Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest::__construct()' name: __construct @@ -123,3 +124,20 @@ items: returns: - var_type: $this + - + uid: '\Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest + type: method + langs: + - php + syntax: + parameters: + - + id: requests + var_type: 'array<Google\Cloud\Vision\V1\AsyncAnnotateFileRequest>' + description: 'Required. Individual async file annotation requests for this batch.' + returns: + - + var_type: 'Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest' diff --git a/dev/tests/fixtures/docfx/Vision/V1.AsyncBatchAnnotateImagesRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.AsyncBatchAnnotateImagesRequest.yml index 1d92e51a34cd..ab41fad5d0a8 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.AsyncBatchAnnotateImagesRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.AsyncBatchAnnotateImagesRequest.yml @@ -23,6 +23,7 @@ items: - '\Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest::setOutputConfig()' - '\Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest::getParent()' - '\Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest::setParent()' + - '\Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest::build()' - uid: '\Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest::__construct()' name: __construct @@ -177,3 +178,24 @@ items: returns: - var_type: $this + - + uid: '\Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest + type: method + langs: + - php + syntax: + parameters: + - + id: requests + var_type: 'array<Google\Cloud\Vision\V1\AnnotateImageRequest>' + description: 'Required. Individual image annotation requests for this batch.' + - + id: outputConfig + var_type: 'Google\Cloud\Vision\V1\OutputConfig' + description: 'Required. The desired output location and metadata (e.g. format).' + returns: + - + var_type: 'Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest' diff --git a/dev/tests/fixtures/docfx/Vision/V1.BatchAnnotateFilesRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.BatchAnnotateFilesRequest.yml index 37768211ef29..158dad6e67cc 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.BatchAnnotateFilesRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.BatchAnnotateFilesRequest.yml @@ -19,6 +19,7 @@ items: - '\Google\Cloud\Vision\V1\BatchAnnotateFilesRequest::setRequests()' - '\Google\Cloud\Vision\V1\BatchAnnotateFilesRequest::getParent()' - '\Google\Cloud\Vision\V1\BatchAnnotateFilesRequest::setParent()' + - '\Google\Cloud\Vision\V1\BatchAnnotateFilesRequest::build()' - uid: '\Google\Cloud\Vision\V1\BatchAnnotateFilesRequest::__construct()' name: __construct @@ -126,3 +127,22 @@ items: returns: - var_type: $this + - + uid: '\Google\Cloud\Vision\V1\BatchAnnotateFilesRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\BatchAnnotateFilesRequest + type: method + langs: + - php + syntax: + parameters: + - + id: requests + var_type: 'array<Google\Cloud\Vision\V1\AnnotateFileRequest>' + description: |- + Required. The list of file annotation requests. Right now we support only one + AnnotateFileRequest in BatchAnnotateFilesRequest. + returns: + - + var_type: 'Google\Cloud\Vision\V1\BatchAnnotateFilesRequest' diff --git a/dev/tests/fixtures/docfx/Vision/V1.BatchAnnotateImagesRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.BatchAnnotateImagesRequest.yml index 9c8df4961ff1..742eeb0f08fb 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.BatchAnnotateImagesRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.BatchAnnotateImagesRequest.yml @@ -19,6 +19,7 @@ items: - '\Google\Cloud\Vision\V1\BatchAnnotateImagesRequest::setRequests()' - '\Google\Cloud\Vision\V1\BatchAnnotateImagesRequest::getParent()' - '\Google\Cloud\Vision\V1\BatchAnnotateImagesRequest::setParent()' + - '\Google\Cloud\Vision\V1\BatchAnnotateImagesRequest::build()' - uid: '\Google\Cloud\Vision\V1\BatchAnnotateImagesRequest::__construct()' name: __construct @@ -122,3 +123,20 @@ items: returns: - var_type: $this + - + uid: '\Google\Cloud\Vision\V1\BatchAnnotateImagesRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\BatchAnnotateImagesRequest + type: method + langs: + - php + syntax: + parameters: + - + id: requests + var_type: 'array<Google\Cloud\Vision\V1\AnnotateImageRequest>' + description: 'Required. Individual image annotation requests for this batch.' + returns: + - + var_type: 'Google\Cloud\Vision\V1\BatchAnnotateImagesRequest' diff --git a/dev/tests/fixtures/docfx/Vision/V1.Client.ImageAnnotatorClient.yml b/dev/tests/fixtures/docfx/Vision/V1.Client.ImageAnnotatorClient.yml new file mode 100644 index 000000000000..08aafe34a931 --- /dev/null +++ b/dev/tests/fixtures/docfx/Vision/V1.Client.ImageAnnotatorClient.yml @@ -0,0 +1,412 @@ +### YamlMime:UniversalReference +items: + - + uid: \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient + name: ImageAnnotatorClient + friendlyApiName: 'Cloud Vision V1 Client' + id: ImageAnnotatorClient + summary: |- + Service Description: Service that performs Google Cloud Vision API detection tasks over client + images, such as face, landmark, logo, label, and text detection. The + ImageAnnotator service returns detected entities from the images. + + This class provides the ability to make remote calls to the backing service through method + calls that map to API methods. + + 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. + + This class is currently experimental and may be subject to changes. See Google\Cloud\Vision\V1\ImageAnnotatorClient for the stable implementation + status: beta + type: class + namespace: 'Google \ Cloud \ Vision \ V1 \ Client' + langs: + - php + children: + - '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::__construct()' + - '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::asyncBatchAnnotateFiles()' + - '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::asyncBatchAnnotateImages()' + - '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::batchAnnotateFiles()' + - '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::batchAnnotateImages()' + - '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::asyncBatchAnnotateFilesAsync()' + - '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::asyncBatchAnnotateImagesAsync()' + - '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::batchAnnotateFilesAsync()' + - '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::batchAnnotateImagesAsync()' + - '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::getOperationsClient()' + - '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::resumeOperation()' + - '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::productSetName()' + - '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::parseName()' + - + uid: '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::__construct()' + name: __construct + id: __construct + summary: Constructor. + parent: \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient + type: method + langs: + - php + syntax: + parameters: + - + id: options + var_type: array + description: 'Optional. Options for configuring the service API wrapper.' + - + id: '↳ apiEndpoint' + var_type: string + description: 'The address of the API remote host. May optionally include the port, formatted as ":". Default ''vision.googleapis.com:443''.' + - + id: '↳ credentials' + var_type: string|array|FetchAuthTokenInterface|CredentialsWrapper + description: '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 Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored.' + - + id: '↳ credentialsConfig' + var_type: array + description: 'Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .' + - + id: '↳ disableRetries' + var_type: bool + description: 'Determines whether or not retries defined by the client configuration should be disabled. Defaults to `false`.' + - + id: '↳ clientConfig' + var_type: string|array + description: '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.' + - + id: '↳ transport' + var_type: string|TransportInterface + description: '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 Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.' + - + id: '↳ transportConfig' + var_type: array + description: '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 Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options.' + - + id: '↳ clientCertSource' + var_type: callable + description: '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.' + - + uid: '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::asyncBatchAnnotateFiles()' + name: asyncBatchAnnotateFiles + id: asyncBatchAnnotateFiles + summary: |- + Run asynchronous image detection and annotation for a list of generic + files, such as PDF files, which may contain multiple pages and multiple + images per page. Progress and results can be retrieved through the + `google.longrunning.Operations` interface. + + `Operation.metadata` contains `OperationMetadata` (metadata). + `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + + The async variant is Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::asyncBatchAnnotateFilesAsync() + . + parent: \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + returns: + - + var_type: 'Google\ApiCore\OperationResponse' + - + uid: '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::asyncBatchAnnotateImages()' + name: asyncBatchAnnotateImages + id: asyncBatchAnnotateImages + summary: |- + Run asynchronous image detection and annotation for a list of images. + + Progress and results can be retrieved through the + `google.longrunning.Operations` interface. + `Operation.metadata` contains `OperationMetadata` (metadata). + `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). + + This service will write image annotation outputs to json files in customer + GCS bucket, each json file containing BatchAnnotateImagesResponse proto. + + The async variant is + Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::asyncBatchAnnotateImagesAsync() . + parent: \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + returns: + - + var_type: 'Google\ApiCore\OperationResponse' + - + uid: '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::batchAnnotateFiles()' + name: batchAnnotateFiles + id: batchAnnotateFiles + summary: |- + Service that performs image detection and annotation for a batch of files. + + Now only "application/pdf", "image/tiff" and "image/gif" are supported. + + This service will extract at most 5 (customers can specify which 5 in + AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each + file provided and perform detection and annotation for each image + extracted. + + The async variant is Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::batchAnnotateFilesAsync() . + parent: \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\BatchAnnotateFilesRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + returns: + - + var_type: 'Google\Cloud\Vision\V1\BatchAnnotateFilesResponse' + - + uid: '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::batchAnnotateImages()' + name: batchAnnotateImages + id: batchAnnotateImages + summary: |- + Run image detection and annotation for a batch of images. + + The async variant is Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::batchAnnotateImagesAsync() . + parent: \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\BatchAnnotateImagesRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + returns: + - + var_type: 'Google\Cloud\Vision\V1\BatchAnnotateImagesResponse' + - + uid: '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::asyncBatchAnnotateFilesAsync()' + name: asyncBatchAnnotateFilesAsync + id: asyncBatchAnnotateFilesAsync + parent: \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::asyncBatchAnnotateImagesAsync()' + name: asyncBatchAnnotateImagesAsync + id: asyncBatchAnnotateImagesAsync + parent: \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::batchAnnotateFilesAsync()' + name: batchAnnotateFilesAsync + id: batchAnnotateFilesAsync + parent: \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\BatchAnnotateFilesRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::batchAnnotateImagesAsync()' + name: batchAnnotateImagesAsync + id: batchAnnotateImagesAsync + parent: \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\BatchAnnotateImagesRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::getOperationsClient()' + name: getOperationsClient + id: getOperationsClient + summary: 'Return an OperationsClient object with the same endpoint as $this.' + parent: \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient + type: method + langs: + - php + syntax: + returns: + - + var_type: 'Google\ApiCore\LongRunning\OperationsClient' + - + uid: '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::resumeOperation()' + name: resumeOperation + id: resumeOperation + summary: |- + Resume an existing long running operation that was previously started by a long + running API method. If $methodName is not provided, or does not match a long + running API method, then the operation can still be resumed, but the + OperationResponse object will not deserialize the final response. + parent: \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient + type: method + langs: + - php + syntax: + parameters: + - + id: operationName + var_type: string + description: 'The name of the long running operation' + - + id: methodName + var_type: string + description: 'The name of the method used to start the operation' + returns: + - + var_type: 'Google\ApiCore\OperationResponse' + - + uid: '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::productSetName()' + name: 'static::productSetName' + id: productSetName + summary: |- + Formats a string containing the fully-qualified path to represent a product_set + resource. + parent: \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient + type: method + langs: + - php + syntax: + parameters: + - + id: project + var_type: string + description: '' + - + id: location + var_type: string + description: '' + - + id: productSet + var_type: string + description: '' + returns: + - + var_type: string + description: 'The formatted product_set resource.' + - + uid: '\Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::parseName()' + name: 'static::parseName' + id: parseName + summary: |- + Parses a formatted name string and returns an associative array of the components in the name. + + The following name formats are supported: + Template: Pattern + - productSet: projects/{project}/locations/{location}/productSets/{product_set} + + 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. + parent: \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient + type: method + langs: + - php + syntax: + parameters: + - + id: formattedName + var_type: string + description: 'The formatted name string' + - + id: template + var_type: string + description: 'Optional name of template to match' + returns: + - + var_type: array + description: 'An associative array from name component IDs to component values.' diff --git a/dev/tests/fixtures/docfx/Vision/V1.Client.ProductSearchClient.yml b/dev/tests/fixtures/docfx/Vision/V1.Client.ProductSearchClient.yml new file mode 100644 index 000000000000..60651c60739a --- /dev/null +++ b/dev/tests/fixtures/docfx/Vision/V1.Client.ProductSearchClient.yml @@ -0,0 +1,1399 @@ +### YamlMime:UniversalReference +items: + - + uid: \Google\Cloud\Vision\V1\Client\ProductSearchClient + name: ProductSearchClient + friendlyApiName: 'Cloud Vision V1 Client' + id: ProductSearchClient + summary: |- + Service Description: Manages Products and ProductSets of reference images for use in product + search. It uses the following resource model: + + - The API has a collection of ProductSet resources, named + `projects/*/locations/*/productSets/*`, which acts as a way to put different + products into groups to limit identification. + + In parallel, + + - The API has a collection of Product resources, named + `projects/*/locations/*/products/*` + + - Each Product has a collection of ReferenceImage resources, named + `projects/*/locations/*/products/*/referenceImages/*` + + This class provides the ability to make remote calls to the backing service through method + calls that map to API methods. + + 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. + + This class is currently experimental and may be subject to changes. See Google\Cloud\Vision\V1\ProductSearchClient for the stable implementation + status: beta + type: class + namespace: 'Google \ Cloud \ Vision \ V1 \ Client' + langs: + - php + children: + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::__construct()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::addProductToProductSet()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::createProduct()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::createProductSet()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::createReferenceImage()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteProduct()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteProductSet()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteReferenceImage()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::getProduct()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::getProductSet()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::getReferenceImage()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::importProductSets()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductSets()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::listProducts()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductsInProductSet()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::listReferenceImages()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::purgeProducts()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::removeProductFromProductSet()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::updateProduct()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::updateProductSet()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::addProductToProductSetAsync()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::createProductAsync()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::createProductSetAsync()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::createReferenceImageAsync()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteProductAsync()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteProductSetAsync()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteReferenceImageAsync()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::getProductAsync()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::getProductSetAsync()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::getReferenceImageAsync()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::importProductSetsAsync()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductSetsAsync()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductsAsync()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductsInProductSetAsync()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::listReferenceImagesAsync()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::purgeProductsAsync()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::removeProductFromProductSetAsync()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::updateProductAsync()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::updateProductSetAsync()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::getOperationsClient()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::resumeOperation()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::locationName()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::productName()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::productSetName()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::referenceImageName()' + - '\Google\Cloud\Vision\V1\Client\ProductSearchClient::parseName()' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::__construct()' + name: __construct + id: __construct + summary: Constructor. + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: options + var_type: array + description: 'Optional. Options for configuring the service API wrapper.' + - + id: '↳ apiEndpoint' + var_type: string + description: 'The address of the API remote host. May optionally include the port, formatted as ":". Default ''vision.googleapis.com:443''.' + - + id: '↳ credentials' + var_type: string|array|FetchAuthTokenInterface|CredentialsWrapper + description: '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 Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored.' + - + id: '↳ credentialsConfig' + var_type: array + description: 'Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .' + - + id: '↳ disableRetries' + var_type: bool + description: 'Determines whether or not retries defined by the client configuration should be disabled. Defaults to `false`.' + - + id: '↳ clientConfig' + var_type: string|array + description: '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.' + - + id: '↳ transport' + var_type: string|TransportInterface + description: '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 Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.' + - + id: '↳ transportConfig' + var_type: array + description: '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 Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options.' + - + id: '↳ clientCertSource' + var_type: callable + description: '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.' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::addProductToProductSet()' + name: addProductToProductSet + id: addProductToProductSet + summary: |- + Adds a Product to the specified ProductSet. If the Product is already + present, no change is made. + + One Product can be added to at most 100 ProductSets. + + Possible errors: + + * Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + + The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::addProductToProductSetAsync() . + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\AddProductToProductSetRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::createProduct()' + name: createProduct + id: createProduct + summary: |- + Creates and returns a new product resource. + + Possible errors: + + * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 + characters. + * Returns INVALID_ARGUMENT if description is longer than 4096 characters. + * Returns INVALID_ARGUMENT if product_category is missing or invalid. + + The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::createProductAsync() . + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\CreateProductRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + returns: + - + var_type: 'Google\Cloud\Vision\V1\Product' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::createProductSet()' + name: createProductSet + id: createProductSet + summary: |- + Creates and returns a new ProductSet resource. + + Possible errors: + + * Returns INVALID_ARGUMENT if display_name is missing, or is longer than + 4096 characters. + + The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::createProductSetAsync() . + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\CreateProductSetRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + returns: + - + var_type: 'Google\Cloud\Vision\V1\ProductSet' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::createReferenceImage()' + name: createReferenceImage + id: createReferenceImage + summary: |- + Creates and returns a new ReferenceImage resource. + + The `bounding_poly` field is optional. If `bounding_poly` is not specified, + the system will try to detect regions of interest in the image that are + compatible with the product_category on the parent product. If it is + specified, detection is ALWAYS skipped. The system converts polygons into + non-rotated rectangles. + + Note that the pipeline will resize the image if the image resolution is too + large to process (above 50MP). + + Possible errors: + + * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 + characters. + * Returns INVALID_ARGUMENT if the product does not exist. + * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing + compatible with the parent product's product_category is detected. + * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + + The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::createReferenceImageAsync() . + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\CreateReferenceImageRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + returns: + - + var_type: 'Google\Cloud\Vision\V1\ReferenceImage' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteProduct()' + name: deleteProduct + id: deleteProduct + summary: |- + Permanently deletes a product and its reference images. + + Metadata of the product and all its images will be deleted right away, but + search queries against ProductSets containing the product may still work + until all related caches are refreshed. + + The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteProductAsync() . + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\DeleteProductRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteProductSet()' + name: deleteProductSet + id: deleteProductSet + summary: |- + Permanently deletes a ProductSet. Products and ReferenceImages in the + ProductSet are not deleted. + + The actual image files are not deleted from Google Cloud Storage. + + The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteProductSetAsync() . + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\DeleteProductSetRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteReferenceImage()' + name: deleteReferenceImage + id: deleteReferenceImage + summary: |- + Permanently deletes a reference image. + + The image metadata will be deleted right away, but search queries + against ProductSets containing the image may still work until all related + caches are refreshed. + + The actual image files are not deleted from Google Cloud Storage. + + The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteReferenceImageAsync() . + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\DeleteReferenceImageRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::getProduct()' + name: getProduct + id: getProduct + summary: |- + Gets information associated with a Product. + + Possible errors: + + * Returns NOT_FOUND if the Product does not exist. + + The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::getProductAsync() . + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\GetProductRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + returns: + - + var_type: 'Google\Cloud\Vision\V1\Product' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::getProductSet()' + name: getProductSet + id: getProductSet + summary: |- + Gets information associated with a ProductSet. + + Possible errors: + + * Returns NOT_FOUND if the ProductSet does not exist. + + The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::getProductSetAsync() . + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\GetProductSetRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + returns: + - + var_type: 'Google\Cloud\Vision\V1\ProductSet' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::getReferenceImage()' + name: getReferenceImage + id: getReferenceImage + summary: |- + Gets information associated with a ReferenceImage. + + Possible errors: + + * Returns NOT_FOUND if the specified image does not exist. + + The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::getReferenceImageAsync() . + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\GetReferenceImageRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + returns: + - + var_type: 'Google\Cloud\Vision\V1\ReferenceImage' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::importProductSets()' + name: importProductSets + id: importProductSets + summary: |- + Asynchronous API that imports a list of reference images to specified + product sets based on a list of image information. + + The google.longrunning.Operation API can be used to keep track of the + progress and results of the request. + `Operation.metadata` contains `BatchOperationMetadata`. (progress) + `Operation.response` contains `ImportProductSetsResponse`. (results) + + The input source of this method is a csv file on Google Cloud Storage. + For the format of the csv file please see + ImportProductSetsGcsSource.csv_file_uri. + + The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::importProductSetsAsync() . + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\ImportProductSetsRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + returns: + - + var_type: 'Google\ApiCore\OperationResponse' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductSets()' + name: listProductSets + id: listProductSets + summary: |- + Lists ProductSets in an unspecified order. + + Possible errors: + + * Returns INVALID_ARGUMENT if page_size is greater than 100, or less + than 1. + + The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductSetsAsync() . + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\ListProductSetsRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + returns: + - + var_type: 'Google\ApiCore\PagedListResponse' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::listProducts()' + name: listProducts + id: listProducts + summary: |- + Lists products in an unspecified order. + + Possible errors: + + * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + + The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductsAsync() . + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\ListProductsRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + returns: + - + var_type: 'Google\ApiCore\PagedListResponse' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductsInProductSet()' + name: listProductsInProductSet + id: listProductsInProductSet + summary: |- + Lists the Products in a ProductSet, in an unspecified order. If the + ProductSet does not exist, the products field of the response will be + empty. + + Possible errors: + + * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + + The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductsInProductSetAsync() + . + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\ListProductsInProductSetRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + returns: + - + var_type: 'Google\ApiCore\PagedListResponse' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::listReferenceImages()' + name: listReferenceImages + id: listReferenceImages + summary: |- + Lists reference images. + + Possible errors: + + * Returns NOT_FOUND if the parent product does not exist. + * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less + than 1. + + The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::listReferenceImagesAsync() . + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\ListReferenceImagesRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + returns: + - + var_type: 'Google\ApiCore\PagedListResponse' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::purgeProducts()' + name: purgeProducts + id: purgeProducts + summary: |- + Asynchronous API to delete all Products in a ProductSet or all Products + that are in no ProductSet. + + If a Product is a member of the specified ProductSet in addition to other + ProductSets, the Product will still be deleted. + + It is recommended to not delete the specified ProductSet until after this + operation has completed. It is also recommended to not add any of the + Products involved in the batch delete to a new ProductSet while this + operation is running because those Products may still end up deleted. + + It's not possible to undo the PurgeProducts operation. Therefore, it is + recommended to keep the csv files used in ImportProductSets (if that was + how you originally built the Product Set) before starting PurgeProducts, in + case you need to re-import the data after deletion. + + If the plan is to purge all of the Products from a ProductSet and then + re-use the empty ProductSet to re-import new Products into the empty + ProductSet, you must wait until the PurgeProducts operation has finished + for that ProductSet. + + The google.longrunning.Operation API can be used to keep track of the + progress and results of the request. + `Operation.metadata` contains `BatchOperationMetadata`. (progress) + + The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::purgeProductsAsync() . + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\PurgeProductsRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + returns: + - + var_type: 'Google\ApiCore\OperationResponse' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::removeProductFromProductSet()' + name: removeProductFromProductSet + id: removeProductFromProductSet + summary: |- + Removes a Product from the specified ProductSet. + + The async variant is + Google\Cloud\Vision\V1\Client\ProductSearchClient::removeProductFromProductSetAsync() . + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::updateProduct()' + name: updateProduct + id: updateProduct + summary: |- + Makes changes to a Product resource. + + Only the `display_name`, `description`, and `labels` fields can be updated + right now. + + If labels are updated, the change will not be reflected in queries until + the next index time. + + Possible errors: + + * Returns NOT_FOUND if the Product does not exist. + * Returns INVALID_ARGUMENT if display_name is present in update_mask but is + missing from the request or longer than 4096 characters. + * Returns INVALID_ARGUMENT if description is present in update_mask but is + longer than 4096 characters. + * Returns INVALID_ARGUMENT if product_category is present in update_mask. + + The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::updateProductAsync() . + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\UpdateProductRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + returns: + - + var_type: 'Google\Cloud\Vision\V1\Product' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::updateProductSet()' + name: updateProductSet + id: updateProductSet + summary: |- + Makes changes to a ProductSet resource. + + Only display_name can be updated currently. + + Possible errors: + + * Returns NOT_FOUND if the ProductSet does not exist. + * Returns INVALID_ARGUMENT if display_name is present in update_mask but + missing from the request or longer than 4096 characters. + + The async variant is Google\Cloud\Vision\V1\Client\ProductSearchClient::updateProductSetAsync() . + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\UpdateProductSetRequest' + description: 'A request to house fields associated with the call.' + - + id: callOptions + var_type: array + description: Optional. + - + id: '↳ retrySettings' + var_type: RetrySettings|array + description: 'Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.' + returns: + - + var_type: 'Google\Cloud\Vision\V1\ProductSet' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::addProductToProductSetAsync()' + name: addProductToProductSetAsync + id: addProductToProductSetAsync + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\AddProductToProductSetRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::createProductAsync()' + name: createProductAsync + id: createProductAsync + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\CreateProductRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::createProductSetAsync()' + name: createProductSetAsync + id: createProductSetAsync + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\CreateProductSetRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::createReferenceImageAsync()' + name: createReferenceImageAsync + id: createReferenceImageAsync + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\CreateReferenceImageRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteProductAsync()' + name: deleteProductAsync + id: deleteProductAsync + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\DeleteProductRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteProductSetAsync()' + name: deleteProductSetAsync + id: deleteProductSetAsync + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\DeleteProductSetRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteReferenceImageAsync()' + name: deleteReferenceImageAsync + id: deleteReferenceImageAsync + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\DeleteReferenceImageRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::getProductAsync()' + name: getProductAsync + id: getProductAsync + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\GetProductRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::getProductSetAsync()' + name: getProductSetAsync + id: getProductSetAsync + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\GetProductSetRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::getReferenceImageAsync()' + name: getReferenceImageAsync + id: getReferenceImageAsync + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\GetReferenceImageRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::importProductSetsAsync()' + name: importProductSetsAsync + id: importProductSetsAsync + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\ImportProductSetsRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductSetsAsync()' + name: listProductSetsAsync + id: listProductSetsAsync + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\ListProductSetsRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductsAsync()' + name: listProductsAsync + id: listProductsAsync + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\ListProductsRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductsInProductSetAsync()' + name: listProductsInProductSetAsync + id: listProductsInProductSetAsync + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\ListProductsInProductSetRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::listReferenceImagesAsync()' + name: listReferenceImagesAsync + id: listReferenceImagesAsync + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\ListReferenceImagesRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::purgeProductsAsync()' + name: purgeProductsAsync + id: purgeProductsAsync + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\PurgeProductsRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::removeProductFromProductSetAsync()' + name: removeProductFromProductSetAsync + id: removeProductFromProductSetAsync + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::updateProductAsync()' + name: updateProductAsync + id: updateProductAsync + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\UpdateProductRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::updateProductSetAsync()' + name: updateProductSetAsync + id: updateProductSetAsync + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: request + var_type: 'Google\Cloud\Vision\V1\UpdateProductSetRequest' + description: '' + - + id: 'optionalArgs = []' + var_type: array + description: '' + returns: + - + var_type: 'GuzzleHttp\Promise\PromiseInterface' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::getOperationsClient()' + name: getOperationsClient + id: getOperationsClient + summary: 'Return an OperationsClient object with the same endpoint as $this.' + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + returns: + - + var_type: 'Google\ApiCore\LongRunning\OperationsClient' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::resumeOperation()' + name: resumeOperation + id: resumeOperation + summary: |- + Resume an existing long running operation that was previously started by a long + running API method. If $methodName is not provided, or does not match a long + running API method, then the operation can still be resumed, but the + OperationResponse object will not deserialize the final response. + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: operationName + var_type: string + description: 'The name of the long running operation' + - + id: methodName + var_type: string + description: 'The name of the method used to start the operation' + returns: + - + var_type: 'Google\ApiCore\OperationResponse' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::locationName()' + name: 'static::locationName' + id: locationName + summary: |- + Formats a string containing the fully-qualified path to represent a location + resource. + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: project + var_type: string + description: '' + - + id: location + var_type: string + description: '' + returns: + - + var_type: string + description: 'The formatted location resource.' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::productName()' + name: 'static::productName' + id: productName + summary: |- + Formats a string containing the fully-qualified path to represent a product + resource. + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: project + var_type: string + description: '' + - + id: location + var_type: string + description: '' + - + id: product + var_type: string + description: '' + returns: + - + var_type: string + description: 'The formatted product resource.' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::productSetName()' + name: 'static::productSetName' + id: productSetName + summary: |- + Formats a string containing the fully-qualified path to represent a product_set + resource. + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: project + var_type: string + description: '' + - + id: location + var_type: string + description: '' + - + id: productSet + var_type: string + description: '' + returns: + - + var_type: string + description: 'The formatted product_set resource.' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::referenceImageName()' + name: 'static::referenceImageName' + id: referenceImageName + summary: |- + Formats a string containing the fully-qualified path to represent a + reference_image resource. + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: project + var_type: string + description: '' + - + id: location + var_type: string + description: '' + - + id: product + var_type: string + description: '' + - + id: referenceImage + var_type: string + description: '' + returns: + - + var_type: string + description: 'The formatted reference_image resource.' + - + uid: '\Google\Cloud\Vision\V1\Client\ProductSearchClient::parseName()' + name: 'static::parseName' + id: parseName + summary: |- + Parses a formatted name string and returns an associative array of the components in the name. + + The following name formats are supported: + Template: Pattern + - location: projects/{project}/locations/{location} + - product: projects/{project}/locations/{location}/products/{product} + - productSet: projects/{project}/locations/{location}/productSets/{product_set} + - referenceImage: projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image} + + 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. + parent: \Google\Cloud\Vision\V1\Client\ProductSearchClient + type: method + langs: + - php + syntax: + parameters: + - + id: formattedName + var_type: string + description: 'The formatted name string' + - + id: template + var_type: string + description: 'Optional name of template to match' + returns: + - + var_type: array + description: 'An associative array from name component IDs to component values.' diff --git a/dev/tests/fixtures/docfx/Vision/V1.CreateProductRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.CreateProductRequest.yml index 5fd221563ed2..d40eeb396075 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.CreateProductRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.CreateProductRequest.yml @@ -23,6 +23,7 @@ items: - '\Google\Cloud\Vision\V1\CreateProductRequest::setProduct()' - '\Google\Cloud\Vision\V1\CreateProductRequest::getProductId()' - '\Google\Cloud\Vision\V1\CreateProductRequest::setProductId()' + - '\Google\Cloud\Vision\V1\CreateProductRequest::build()' - uid: '\Google\Cloud\Vision\V1\CreateProductRequest::__construct()' name: __construct @@ -175,3 +176,37 @@ items: returns: - var_type: $this + - + uid: '\Google\Cloud\Vision\V1\CreateProductRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\CreateProductRequest + type: method + langs: + - php + syntax: + parameters: + - + id: parent + var_type: string + description: |- + Required. The project in which the Product should be created. + + Format is + `projects/PROJECT_ID/locations/LOC_ID`. Please see + Google\Cloud\Vision\V1\ProductSearchClient::locationName() for help formatting this field. + - + id: product + var_type: 'Google\Cloud\Vision\V1\Product' + description: 'Required. The product to create.' + - + id: productId + var_type: string + description: |- + A user-supplied resource id for this Product. If set, the server will + attempt to use this value as the resource id. If it is already in use, an + error is returned with code ALREADY_EXISTS. Must be at most 128 characters + long. It cannot contain the character `/`. + returns: + - + var_type: 'Google\Cloud\Vision\V1\CreateProductRequest' diff --git a/dev/tests/fixtures/docfx/Vision/V1.CreateProductSetRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.CreateProductSetRequest.yml index d82c0b51b37f..3e9c272ffe29 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.CreateProductSetRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.CreateProductSetRequest.yml @@ -23,6 +23,7 @@ items: - '\Google\Cloud\Vision\V1\CreateProductSetRequest::setProductSet()' - '\Google\Cloud\Vision\V1\CreateProductSetRequest::getProductSetId()' - '\Google\Cloud\Vision\V1\CreateProductSetRequest::setProductSetId()' + - '\Google\Cloud\Vision\V1\CreateProductSetRequest::build()' - uid: '\Google\Cloud\Vision\V1\CreateProductSetRequest::__construct()' name: __construct @@ -173,3 +174,36 @@ items: returns: - var_type: $this + - + uid: '\Google\Cloud\Vision\V1\CreateProductSetRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\CreateProductSetRequest + type: method + langs: + - php + syntax: + parameters: + - + id: parent + var_type: string + description: |- + Required. The project in which the ProductSet should be created. + + Format is `projects/PROJECT_ID/locations/LOC_ID`. Please see + Google\Cloud\Vision\V1\ProductSearchClient::locationName() for help formatting this field. + - + id: productSet + var_type: 'Google\Cloud\Vision\V1\ProductSet' + description: 'Required. The ProductSet to create.' + - + id: productSetId + var_type: string + description: |- + A user-supplied resource id for this ProductSet. If set, the server will + attempt to use this value as the resource id. If it is already in use, an + error is returned with code ALREADY_EXISTS. Must be at most 128 characters + long. It cannot contain the character `/`. + returns: + - + var_type: 'Google\Cloud\Vision\V1\CreateProductSetRequest' diff --git a/dev/tests/fixtures/docfx/Vision/V1.CreateReferenceImageRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.CreateReferenceImageRequest.yml index 7c29c02970db..c79cd34fcbb7 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.CreateReferenceImageRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.CreateReferenceImageRequest.yml @@ -23,6 +23,7 @@ items: - '\Google\Cloud\Vision\V1\CreateReferenceImageRequest::setReferenceImage()' - '\Google\Cloud\Vision\V1\CreateReferenceImageRequest::getReferenceImageId()' - '\Google\Cloud\Vision\V1\CreateReferenceImageRequest::setReferenceImageId()' + - '\Google\Cloud\Vision\V1\CreateReferenceImageRequest::build()' - uid: '\Google\Cloud\Vision\V1\CreateReferenceImageRequest::__construct()' name: __construct @@ -181,3 +182,39 @@ items: returns: - var_type: $this + - + uid: '\Google\Cloud\Vision\V1\CreateReferenceImageRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\CreateReferenceImageRequest + type: method + langs: + - php + syntax: + parameters: + - + id: parent + var_type: string + description: |- + Required. Resource name of the product in which to create the reference image. + + Format is + `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. Please see + Google\Cloud\Vision\V1\ProductSearchClient::productName() for help formatting this field. + - + id: referenceImage + var_type: 'Google\Cloud\Vision\V1\ReferenceImage' + description: |- + Required. The reference image to create. + If an image ID is specified, it is ignored. + - + id: referenceImageId + var_type: string + description: |- + A user-supplied resource id for the ReferenceImage to be added. If set, + the server will attempt to use this value as the resource id. If it is + already in use, an error is returned with code ALREADY_EXISTS. Must be at + most 128 characters long. It cannot contain the character `/`. + returns: + - + var_type: 'Google\Cloud\Vision\V1\CreateReferenceImageRequest' diff --git a/dev/tests/fixtures/docfx/Vision/V1.DeleteProductRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.DeleteProductRequest.yml index 0efc9f9ad247..b84e28326c23 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.DeleteProductRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.DeleteProductRequest.yml @@ -17,6 +17,7 @@ items: - '\Google\Cloud\Vision\V1\DeleteProductRequest::__construct()' - '\Google\Cloud\Vision\V1\DeleteProductRequest::getName()' - '\Google\Cloud\Vision\V1\DeleteProductRequest::setName()' + - '\Google\Cloud\Vision\V1\DeleteProductRequest::build()' - uid: '\Google\Cloud\Vision\V1\DeleteProductRequest::__construct()' name: __construct @@ -75,3 +76,25 @@ items: returns: - var_type: $this + - + uid: '\Google\Cloud\Vision\V1\DeleteProductRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\DeleteProductRequest + type: method + langs: + - php + syntax: + parameters: + - + id: name + var_type: string + description: |- + Required. Resource name of product to delete. + + Format is: + `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + Please see Google\Cloud\Vision\V1\ProductSearchClient::productName() for help formatting this field. + returns: + - + var_type: 'Google\Cloud\Vision\V1\DeleteProductRequest' diff --git a/dev/tests/fixtures/docfx/Vision/V1.DeleteProductSetRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.DeleteProductSetRequest.yml index 835704f745c2..ef4ec85e344b 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.DeleteProductSetRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.DeleteProductSetRequest.yml @@ -17,6 +17,7 @@ items: - '\Google\Cloud\Vision\V1\DeleteProductSetRequest::__construct()' - '\Google\Cloud\Vision\V1\DeleteProductSetRequest::getName()' - '\Google\Cloud\Vision\V1\DeleteProductSetRequest::setName()' + - '\Google\Cloud\Vision\V1\DeleteProductSetRequest::build()' - uid: '\Google\Cloud\Vision\V1\DeleteProductSetRequest::__construct()' name: __construct @@ -75,3 +76,25 @@ items: returns: - var_type: $this + - + uid: '\Google\Cloud\Vision\V1\DeleteProductSetRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\DeleteProductSetRequest + type: method + langs: + - php + syntax: + parameters: + - + id: name + var_type: string + description: |- + Required. Resource name of the ProductSet to delete. + + Format is: + `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + Please see Google\Cloud\Vision\V1\ProductSearchClient::productSetName() for help formatting this field. + returns: + - + var_type: 'Google\Cloud\Vision\V1\DeleteProductSetRequest' diff --git a/dev/tests/fixtures/docfx/Vision/V1.DeleteReferenceImageRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.DeleteReferenceImageRequest.yml index 001f9feac66d..2e8a028f95af 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.DeleteReferenceImageRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.DeleteReferenceImageRequest.yml @@ -17,6 +17,7 @@ items: - '\Google\Cloud\Vision\V1\DeleteReferenceImageRequest::__construct()' - '\Google\Cloud\Vision\V1\DeleteReferenceImageRequest::getName()' - '\Google\Cloud\Vision\V1\DeleteReferenceImageRequest::setName()' + - '\Google\Cloud\Vision\V1\DeleteReferenceImageRequest::build()' - uid: '\Google\Cloud\Vision\V1\DeleteReferenceImageRequest::__construct()' name: __construct @@ -75,3 +76,25 @@ items: returns: - var_type: $this + - + uid: '\Google\Cloud\Vision\V1\DeleteReferenceImageRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\DeleteReferenceImageRequest + type: method + langs: + - php + syntax: + parameters: + - + id: name + var_type: string + description: |- + Required. The resource name of the reference image to delete. + + Format is: + `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` + Please see Google\Cloud\Vision\V1\ProductSearchClient::referenceImageName() for help formatting this field. + returns: + - + var_type: 'Google\Cloud\Vision\V1\DeleteReferenceImageRequest' diff --git a/dev/tests/fixtures/docfx/Vision/V1.GetProductRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.GetProductRequest.yml index 07127c232cc7..2a0b88f203c0 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.GetProductRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.GetProductRequest.yml @@ -17,6 +17,7 @@ items: - '\Google\Cloud\Vision\V1\GetProductRequest::__construct()' - '\Google\Cloud\Vision\V1\GetProductRequest::getName()' - '\Google\Cloud\Vision\V1\GetProductRequest::setName()' + - '\Google\Cloud\Vision\V1\GetProductRequest::build()' - uid: '\Google\Cloud\Vision\V1\GetProductRequest::__construct()' name: __construct @@ -75,3 +76,25 @@ items: returns: - var_type: $this + - + uid: '\Google\Cloud\Vision\V1\GetProductRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\GetProductRequest + type: method + langs: + - php + syntax: + parameters: + - + id: name + var_type: string + description: |- + Required. Resource name of the Product to get. + + Format is: + `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + Please see Google\Cloud\Vision\V1\ProductSearchClient::productName() for help formatting this field. + returns: + - + var_type: 'Google\Cloud\Vision\V1\GetProductRequest' diff --git a/dev/tests/fixtures/docfx/Vision/V1.GetProductSetRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.GetProductSetRequest.yml index 54022750855c..5190815aab49 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.GetProductSetRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.GetProductSetRequest.yml @@ -17,6 +17,7 @@ items: - '\Google\Cloud\Vision\V1\GetProductSetRequest::__construct()' - '\Google\Cloud\Vision\V1\GetProductSetRequest::getName()' - '\Google\Cloud\Vision\V1\GetProductSetRequest::setName()' + - '\Google\Cloud\Vision\V1\GetProductSetRequest::build()' - uid: '\Google\Cloud\Vision\V1\GetProductSetRequest::__construct()' name: __construct @@ -75,3 +76,25 @@ items: returns: - var_type: $this + - + uid: '\Google\Cloud\Vision\V1\GetProductSetRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\GetProductSetRequest + type: method + langs: + - php + syntax: + parameters: + - + id: name + var_type: string + description: |- + Required. Resource name of the ProductSet to get. + + Format is: + `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + Please see Google\Cloud\Vision\V1\ProductSearchClient::productSetName() for help formatting this field. + returns: + - + var_type: 'Google\Cloud\Vision\V1\GetProductSetRequest' diff --git a/dev/tests/fixtures/docfx/Vision/V1.GetReferenceImageRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.GetReferenceImageRequest.yml index 64e5c4e28cb5..0e9ebe00823d 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.GetReferenceImageRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.GetReferenceImageRequest.yml @@ -17,6 +17,7 @@ items: - '\Google\Cloud\Vision\V1\GetReferenceImageRequest::__construct()' - '\Google\Cloud\Vision\V1\GetReferenceImageRequest::getName()' - '\Google\Cloud\Vision\V1\GetReferenceImageRequest::setName()' + - '\Google\Cloud\Vision\V1\GetReferenceImageRequest::build()' - uid: '\Google\Cloud\Vision\V1\GetReferenceImageRequest::__construct()' name: __construct @@ -75,3 +76,25 @@ items: returns: - var_type: $this + - + uid: '\Google\Cloud\Vision\V1\GetReferenceImageRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\GetReferenceImageRequest + type: method + langs: + - php + syntax: + parameters: + - + id: name + var_type: string + description: |- + Required. The resource name of the ReferenceImage to get. + + Format is: + `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. Please see + Google\Cloud\Vision\V1\ProductSearchClient::referenceImageName() for help formatting this field. + returns: + - + var_type: 'Google\Cloud\Vision\V1\GetReferenceImageRequest' diff --git a/dev/tests/fixtures/docfx/Vision/V1.ImageAnnotatorClient.yml b/dev/tests/fixtures/docfx/Vision/V1.ImageAnnotatorClient.yml index 150e5717b66f..3a635515285c 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.ImageAnnotatorClient.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.ImageAnnotatorClient.yml @@ -21,7 +21,7 @@ items: $operationResponse->pollUntilComplete(); if ($operationResponse->operationSucceeded()) { $result = $operationResponse->getResult(); - // doSomethingWith($result) + // doSomethingWith($result) } else { $error = $operationResponse->getError(); // handleError($error) @@ -38,7 +38,7 @@ items: } if ($newOperationResponse->operationSucceeded()) { $result = $newOperationResponse->getResult(); - // doSomethingWith($result) + // doSomethingWith($result) } else { $error = $newOperationResponse->getError(); // handleError($error) @@ -47,6 +47,13 @@ items: $imageAnnotatorClient->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. + + This service has a new (beta) implementation. See Google\Cloud\Vision\V1\Client\ImageAnnotatorClient to use the new surface. type: class namespace: 'Google \ Cloud \ Vision \ V1' langs: @@ -73,6 +80,8 @@ items: - '\Google\Cloud\Vision\V1\ImageAnnotatorClient::batchAnnotateImages()' - '\Google\Cloud\Vision\V1\ImageAnnotatorClient::getOperationsClient()' - '\Google\Cloud\Vision\V1\ImageAnnotatorClient::resumeOperation()' + - '\Google\Cloud\Vision\V1\ImageAnnotatorClient::productSetName()' + - '\Google\Cloud\Vision\V1\ImageAnnotatorClient::parseName()' - '\Google\Cloud\Vision\V1\ImageAnnotatorClient::SERVICE_NAME' - '\Google\Cloud\Vision\V1\ImageAnnotatorClient::SERVICE_ADDRESS' - '\Google\Cloud\Vision\V1\ImageAnnotatorClient::DEFAULT_SERVICE_PORT' @@ -1023,6 +1032,69 @@ items: returns: - var_type: 'Google\ApiCore\OperationResponse' + - + uid: '\Google\Cloud\Vision\V1\ImageAnnotatorClient::productSetName()' + name: 'static::productSetName' + id: productSetName + summary: |- + Formats a string containing the fully-qualified path to represent a product_set + resource. + parent: \Google\Cloud\Vision\V1\ImageAnnotatorClient + type: method + langs: + - php + syntax: + parameters: + - + id: project + var_type: string + description: '' + - + id: location + var_type: string + description: '' + - + id: productSet + var_type: string + description: '' + returns: + - + var_type: string + description: 'The formatted product_set resource.' + - + uid: '\Google\Cloud\Vision\V1\ImageAnnotatorClient::parseName()' + name: 'static::parseName' + id: parseName + summary: |- + Parses a formatted name string and returns an associative array of the components in the name. + + The following name formats are supported: + Template: Pattern + - productSet: projects/{project}/locations/{location}/productSets/{product_set} + + 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. + parent: \Google\Cloud\Vision\V1\ImageAnnotatorClient + type: method + langs: + - php + syntax: + parameters: + - + id: formattedName + var_type: string + description: 'The formatted name string' + - + id: template + var_type: string + description: 'Optional name of template to match' + returns: + - + var_type: array + description: 'An associative array from name component IDs to component values.' - uid: '\Google\Cloud\Vision\V1\ImageAnnotatorClient::SERVICE_NAME' name: SERVICE_NAME diff --git a/dev/tests/fixtures/docfx/Vision/V1.ImportProductSetsRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.ImportProductSetsRequest.yml index d58f3141fc39..09b456dd80b4 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.ImportProductSetsRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.ImportProductSetsRequest.yml @@ -21,6 +21,7 @@ items: - '\Google\Cloud\Vision\V1\ImportProductSetsRequest::hasInputConfig()' - '\Google\Cloud\Vision\V1\ImportProductSetsRequest::clearInputConfig()' - '\Google\Cloud\Vision\V1\ImportProductSetsRequest::setInputConfig()' + - '\Google\Cloud\Vision\V1\ImportProductSetsRequest::build()' - uid: '\Google\Cloud\Vision\V1\ImportProductSetsRequest::__construct()' name: __construct @@ -128,3 +129,28 @@ items: returns: - var_type: $this + - + uid: '\Google\Cloud\Vision\V1\ImportProductSetsRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\ImportProductSetsRequest + type: method + langs: + - php + syntax: + parameters: + - + id: parent + var_type: string + description: |- + Required. The project in which the ProductSets should be imported. + + Format is `projects/PROJECT_ID/locations/LOC_ID`. Please see + Google\Cloud\Vision\V1\ProductSearchClient::locationName() for help formatting this field. + - + id: inputConfig + var_type: 'Google\Cloud\Vision\V1\ImportProductSetsInputConfig' + description: 'Required. The input content for the list of requests.' + returns: + - + var_type: 'Google\Cloud\Vision\V1\ImportProductSetsRequest' diff --git a/dev/tests/fixtures/docfx/Vision/V1.ListProductSetsRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.ListProductSetsRequest.yml index 49fd2a7edfab..582fda538f64 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.ListProductSetsRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.ListProductSetsRequest.yml @@ -21,6 +21,7 @@ items: - '\Google\Cloud\Vision\V1\ListProductSetsRequest::setPageSize()' - '\Google\Cloud\Vision\V1\ListProductSetsRequest::getPageToken()' - '\Google\Cloud\Vision\V1\ListProductSetsRequest::setPageToken()' + - '\Google\Cloud\Vision\V1\ListProductSetsRequest::build()' - uid: '\Google\Cloud\Vision\V1\ListProductSetsRequest::__construct()' name: __construct @@ -147,3 +148,24 @@ items: returns: - var_type: $this + - + uid: '\Google\Cloud\Vision\V1\ListProductSetsRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\ListProductSetsRequest + type: method + langs: + - php + syntax: + parameters: + - + id: parent + var_type: string + description: |- + Required. The project from which ProductSets should be listed. + + Format is `projects/PROJECT_ID/locations/LOC_ID`. Please see + Google\Cloud\Vision\V1\ProductSearchClient::locationName() for help formatting this field. + returns: + - + var_type: 'Google\Cloud\Vision\V1\ListProductSetsRequest' diff --git a/dev/tests/fixtures/docfx/Vision/V1.ListProductsInProductSetRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.ListProductsInProductSetRequest.yml index b5efc065bfab..372c0986d283 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.ListProductsInProductSetRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.ListProductsInProductSetRequest.yml @@ -21,6 +21,7 @@ items: - '\Google\Cloud\Vision\V1\ListProductsInProductSetRequest::setPageSize()' - '\Google\Cloud\Vision\V1\ListProductsInProductSetRequest::getPageToken()' - '\Google\Cloud\Vision\V1\ListProductsInProductSetRequest::setPageToken()' + - '\Google\Cloud\Vision\V1\ListProductsInProductSetRequest::build()' - uid: '\Google\Cloud\Vision\V1\ListProductsInProductSetRequest::__construct()' name: __construct @@ -149,3 +150,25 @@ items: returns: - var_type: $this + - + uid: '\Google\Cloud\Vision\V1\ListProductsInProductSetRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\ListProductsInProductSetRequest + type: method + langs: + - php + syntax: + parameters: + - + id: name + var_type: string + description: |- + Required. The ProductSet resource for which to retrieve Products. + + Format is: + `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + Please see Google\Cloud\Vision\V1\ProductSearchClient::productSetName() for help formatting this field. + returns: + - + var_type: 'Google\Cloud\Vision\V1\ListProductsInProductSetRequest' diff --git a/dev/tests/fixtures/docfx/Vision/V1.ListProductsRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.ListProductsRequest.yml index a189f21d5ea3..1425dd4f0106 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.ListProductsRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.ListProductsRequest.yml @@ -21,6 +21,7 @@ items: - '\Google\Cloud\Vision\V1\ListProductsRequest::setPageSize()' - '\Google\Cloud\Vision\V1\ListProductsRequest::getPageToken()' - '\Google\Cloud\Vision\V1\ListProductsRequest::setPageToken()' + - '\Google\Cloud\Vision\V1\ListProductsRequest::build()' - uid: '\Google\Cloud\Vision\V1\ListProductsRequest::__construct()' name: __construct @@ -149,3 +150,25 @@ items: returns: - var_type: $this + - + uid: '\Google\Cloud\Vision\V1\ListProductsRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\ListProductsRequest + type: method + langs: + - php + syntax: + parameters: + - + id: parent + var_type: string + description: |- + Required. The project OR ProductSet from which Products should be listed. + + Format: + `projects/PROJECT_ID/locations/LOC_ID` + Please see Google\Cloud\Vision\V1\ProductSearchClient::locationName() for help formatting this field. + returns: + - + var_type: 'Google\Cloud\Vision\V1\ListProductsRequest' diff --git a/dev/tests/fixtures/docfx/Vision/V1.ListReferenceImagesRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.ListReferenceImagesRequest.yml index f905485d5761..d81fd79467b8 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.ListReferenceImagesRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.ListReferenceImagesRequest.yml @@ -21,6 +21,7 @@ items: - '\Google\Cloud\Vision\V1\ListReferenceImagesRequest::setPageSize()' - '\Google\Cloud\Vision\V1\ListReferenceImagesRequest::getPageToken()' - '\Google\Cloud\Vision\V1\ListReferenceImagesRequest::setPageToken()' + - '\Google\Cloud\Vision\V1\ListReferenceImagesRequest::build()' - uid: '\Google\Cloud\Vision\V1\ListReferenceImagesRequest::__construct()' name: __construct @@ -157,3 +158,25 @@ items: returns: - var_type: $this + - + uid: '\Google\Cloud\Vision\V1\ListReferenceImagesRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\ListReferenceImagesRequest + type: method + langs: + - php + syntax: + parameters: + - + id: parent + var_type: string + description: |- + Required. Resource name of the product containing the reference images. + + Format is + `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. Please see + Google\Cloud\Vision\V1\ProductSearchClient::productName() for help formatting this field. + returns: + - + var_type: 'Google\Cloud\Vision\V1\ListReferenceImagesRequest' diff --git a/dev/tests/fixtures/docfx/Vision/V1.ProductSearchClient.yml b/dev/tests/fixtures/docfx/Vision/V1.ProductSearchClient.yml index a210d2205d42..12d2a03cb3d3 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.ProductSearchClient.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.ProductSearchClient.yml @@ -39,6 +39,8 @@ items: 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. + + This service has a new (beta) implementation. See Google\Cloud\Vision\V1\Client\ProductSearchClient to use the new surface. type: class namespace: 'Google \ Cloud \ Vision \ V1' langs: diff --git a/dev/tests/fixtures/docfx/Vision/V1.PurgeProductsRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.PurgeProductsRequest.yml index 9e02d0f891de..aa8b48552537 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.PurgeProductsRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.PurgeProductsRequest.yml @@ -26,6 +26,7 @@ items: - '\Google\Cloud\Vision\V1\PurgeProductsRequest::getForce()' - '\Google\Cloud\Vision\V1\PurgeProductsRequest::setForce()' - '\Google\Cloud\Vision\V1\PurgeProductsRequest::getTarget()' + - '\Google\Cloud\Vision\V1\PurgeProductsRequest::build()' - uid: '\Google\Cloud\Vision\V1\PurgeProductsRequest::__construct()' name: __construct @@ -223,3 +224,24 @@ items: returns: - var_type: string + - + uid: '\Google\Cloud\Vision\V1\PurgeProductsRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\PurgeProductsRequest + type: method + langs: + - php + syntax: + parameters: + - + id: parent + var_type: string + description: |- + Required. The project and location in which the Products should be deleted. + + Format is `projects/PROJECT_ID/locations/LOC_ID`. Please see + Google\Cloud\Vision\V1\ProductSearchClient::locationName() for help formatting this field. + returns: + - + var_type: 'Google\Cloud\Vision\V1\PurgeProductsRequest' diff --git a/dev/tests/fixtures/docfx/Vision/V1.RemoveProductFromProductSetRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.RemoveProductFromProductSetRequest.yml index 6192c2476720..39a85311a089 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.RemoveProductFromProductSetRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.RemoveProductFromProductSetRequest.yml @@ -19,6 +19,7 @@ items: - '\Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest::setName()' - '\Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest::getProduct()' - '\Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest::setProduct()' + - '\Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest::build()' - uid: '\Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest::__construct()' name: __construct @@ -120,3 +121,34 @@ items: returns: - var_type: $this + - + uid: '\Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest + type: method + langs: + - php + syntax: + parameters: + - + id: name + var_type: string + description: |- + Required. The resource name for the ProductSet to modify. + + Format is: + `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + Please see Google\Cloud\Vision\V1\ProductSearchClient::productSetName() for help formatting this field. + - + id: product + var_type: string + description: |- + Required. The resource name for the Product to be removed from this ProductSet. + + Format is: + `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + Please see Google\Cloud\Vision\V1\ProductSearchClient::productName() for help formatting this field. + returns: + - + var_type: 'Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest' diff --git a/dev/tests/fixtures/docfx/Vision/V1.UpdateProductRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.UpdateProductRequest.yml index 90883ee46f56..86c85fe1fc90 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.UpdateProductRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.UpdateProductRequest.yml @@ -23,6 +23,7 @@ items: - '\Google\Cloud\Vision\V1\UpdateProductRequest::hasUpdateMask()' - '\Google\Cloud\Vision\V1\UpdateProductRequest::clearUpdateMask()' - '\Google\Cloud\Vision\V1\UpdateProductRequest::setUpdateMask()' + - '\Google\Cloud\Vision\V1\UpdateProductRequest::build()' - uid: '\Google\Cloud\Vision\V1\UpdateProductRequest::__construct()' name: __construct @@ -158,3 +159,31 @@ items: returns: - var_type: $this + - + uid: '\Google\Cloud\Vision\V1\UpdateProductRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\UpdateProductRequest + type: method + langs: + - php + syntax: + parameters: + - + id: product + var_type: 'Google\Cloud\Vision\V1\Product' + description: |- + Required. The Product resource which replaces the one on the server. + product.name is immutable. + - + id: updateMask + var_type: 'Google\Protobuf\FieldMask' + description: |- + The FieldMask that specifies which fields + to update. + If update_mask isn't specified, all mutable fields are to be updated. + Valid mask paths include `product_labels`, `display_name`, and + `description`. + returns: + - + var_type: 'Google\Cloud\Vision\V1\UpdateProductRequest' diff --git a/dev/tests/fixtures/docfx/Vision/V1.UpdateProductSetRequest.yml b/dev/tests/fixtures/docfx/Vision/V1.UpdateProductSetRequest.yml index a14c498df91a..b496b8929985 100644 --- a/dev/tests/fixtures/docfx/Vision/V1.UpdateProductSetRequest.yml +++ b/dev/tests/fixtures/docfx/Vision/V1.UpdateProductSetRequest.yml @@ -23,6 +23,7 @@ items: - '\Google\Cloud\Vision\V1\UpdateProductSetRequest::hasUpdateMask()' - '\Google\Cloud\Vision\V1\UpdateProductSetRequest::clearUpdateMask()' - '\Google\Cloud\Vision\V1\UpdateProductSetRequest::setUpdateMask()' + - '\Google\Cloud\Vision\V1\UpdateProductSetRequest::build()' - uid: '\Google\Cloud\Vision\V1\UpdateProductSetRequest::__construct()' name: __construct @@ -150,3 +151,28 @@ items: returns: - var_type: $this + - + uid: '\Google\Cloud\Vision\V1\UpdateProductSetRequest::build()' + name: 'static::build' + id: build + parent: \Google\Cloud\Vision\V1\UpdateProductSetRequest + type: method + langs: + - php + syntax: + parameters: + - + id: productSet + var_type: 'Google\Cloud\Vision\V1\ProductSet' + description: 'Required. The ProductSet resource which replaces the one on the server.' + - + id: updateMask + var_type: 'Google\Protobuf\FieldMask' + description: |- + The FieldMask that specifies which fields to + update. + If update_mask isn't specified, all mutable fields are to be updated. + Valid mask path is `display_name`. + returns: + - + var_type: 'Google\Cloud\Vision\V1\UpdateProductSetRequest' diff --git a/dev/tests/fixtures/docfx/Vision/toc.yml b/dev/tests/fixtures/docfx/Vision/toc.yml index 6f5337a78ba0..82cd4b15169d 100644 --- a/dev/tests/fixtures/docfx/Vision/toc.yml +++ b/dev/tests/fixtures/docfx/Vision/toc.yml @@ -19,6 +19,14 @@ - uid: \Google\Cloud\Vision\V1\ProductSearchClient name: ProductSearchClient + - + uid: \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient + name: 'ImageAnnotatorClient (beta)' + status: beta + - + uid: \Google\Cloud\Vision\V1\Client\ProductSearchClient + name: 'ProductSearchClient (beta)' + status: beta - name: Messages uid: 'messages:Google\Cloud\Vision\V1' diff --git a/dev/tests/fixtures/phpdoc/clientsnippets.xml b/dev/tests/fixtures/phpdoc/clientsnippets.xml index dfbc44aa63dc..306bf56d4594 100644 --- a/dev/tests/fixtures/phpdoc/clientsnippets.xml +++ b/dev/tests/fixtures/phpdoc/clientsnippets.xml @@ -1,6 +1,6 @@ - + @@ -11,124 +11,17 @@ - - - - - - an_rpc_method_sample - \an_rpc_method_sample() - - - - - - - - - callSample - \callSample() - - Helper to execute the sample. - This sample has been automatically generated and should be regarded as a code -template only. It will require modifications to work: - - It may require correct/in-range values for request initialization. - - It may require specifying regional endpoints when creating the service client, - please see the apiEndpoint client configuration option for more details. - - - - - - - - - - - - - - - - - - - - - - - - - - - - ClientSnippetsBaseClient - \Google\Cloud\ClientSnippets\Client\BaseClient\ClientSnippetsBaseClient - - - - - - - - - - - - anRpcMethod - \Google\Cloud\ClientSnippets\Client\BaseClient\ClientSnippetsBaseClient::anRpcMethod() - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - + + + + ClientSnippetsClient \Google\Cloud\ClientSnippets\Client\ClientSnippetsClient - + - \Google\Cloud\ClientSnippets\Client\BaseClient\ClientSnippetsBaseClient - - - - + + + + + anRpcMethod - \Google\Cloud\ClientSnippets\Client\BaseClient\ClientSnippetsBaseClient::anRpcMethod() + \Google\Cloud\ClientSnippets\Client\ClientSnippetsClient::anRpcMethod() - \Google\Cloud\ClientSnippets\Client\BaseClient\ClientSnippetsBaseClient + - - - - + + + + - - - - - - - + + - - - - + @@ -188,19 +73,13 @@ template only. It will require modifications to work: - - - - + - - - - + @@ -209,10 +88,7 @@ template only. It will require modifications to work: - - - - + diff --git a/dev/tests/fixtures/phpdoc/newclient.xml b/dev/tests/fixtures/phpdoc/newclient.xml index 0be938dc403c..5a09e22f5d19 100644 --- a/dev/tests/fixtures/phpdoc/newclient.xml +++ b/dev/tests/fixtures/phpdoc/newclient.xml @@ -1,1089 +1,4 @@ - - - - - - - - - - - - - - - - - SecretManagerServiceBaseClient - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient - - Service Description: Secret Manager Service - Manages secrets and operations using those secrets. Implements a REST -model with the following objects: - -* [Secret][google.cloud.secretmanager.v1.Secret] -* [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] - -This class provides the ability to make remote calls to the backing service through method -calls that map to API methods. - -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. - -This class is currently experimental and may be subject to changes. - - - - - - - - - - - - - - - - - - - - - - - - SERVICE_NAME - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::SERVICE_NAME - 'google.cloud.secretmanager.v1.SecretManagerService' - - The name of the service. - - - - - - - SERVICE_ADDRESS - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::SERVICE_ADDRESS - 'secretmanager.googleapis.com' - - The default address of the service. - - - - - - - DEFAULT_SERVICE_PORT - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::DEFAULT_SERVICE_PORT - 443 - - The default port of the service. - - - - - - - CODEGEN_NAME - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::CODEGEN_NAME - 'gapic' - - The name of the code generator, to be included in the agent header. - - - - - - - - serviceScopes - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::$serviceScopes - ['https://www.googleapis.com/auth/cloud-platform'] - - The default scopes required by the service. - - - - - - - - getClientDefaults - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::getClientDefaults() - - - - - - - - - - projectName - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::projectName() - - - project - - string - - - - Formats a string containing the fully-qualified path to represent a project -resource. - - - - - - - - - secretName - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::secretName() - - - project - - string - - - - secret - - string - - - - Formats a string containing the fully-qualified path to represent a secret -resource. - - - - - - - - - - secretVersionName - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::secretVersionName() - - - project - - string - - - - secret - - string - - - - secretVersion - - string - - - - Formats a string containing the fully-qualified path to represent a -secret_version resource. - - - - - - - - - - - parseName - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::parseName() - - - formattedName - - string - - - - template - null - string - - - - 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} -- secret: projects/{project}/secrets/{secret} -- secretVersion: projects/{project}/secrets/{secret}/versions/{secret_version} - -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. - - - - - - - - - - __construct - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::__construct() - - - options - [] - array - - - - Constructor. - - - - - - - - - __call - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::__call() - - - method - - mixed - - - - args - - mixed - - - - Handles execution of the async variants for each documented method. - - - - - - - accessSecretVersion - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::accessSecretVersion() - - - request - - \Google\Cloud\SecretManager\V1\AccessSecretVersionRequest - - - - callOptions - [] - array - - - - Accesses a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. This call returns the secret data. - `projects/&#42;/secrets/&#42;/versions/latest` is an alias to the most recently -created [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. - -The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::accessSecretVersionAsync()} . - - - - - - - - - - addSecretVersion - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::addSecretVersion() - - - request - - \Google\Cloud\SecretManager\V1\AddSecretVersionRequest - - - - callOptions - [] - array - - - - Creates a new [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] containing secret data and attaches -it to an existing [Secret][google.cloud.secretmanager.v1.Secret]. - The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::addSecretVersionAsync()} . - - - - - - - - - - createSecret - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::createSecret() - - - request - - \Google\Cloud\SecretManager\V1\CreateSecretRequest - - - - callOptions - [] - array - - - - Creates a new [Secret][google.cloud.secretmanager.v1.Secret] containing no [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. - The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::createSecretAsync()} . - - - - - - - - - - deleteSecret - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::deleteSecret() - - - request - - \Google\Cloud\SecretManager\V1\DeleteSecretRequest - - - - callOptions - [] - array - - - - Deletes a [Secret][google.cloud.secretmanager.v1.Secret]. - The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::deleteSecretAsync()} . - - - - - - - - - destroySecretVersion - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::destroySecretVersion() - - - request - - \Google\Cloud\SecretManager\V1\DestroySecretVersionRequest - - - - callOptions - [] - array - - - - Destroys a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. - Sets the [state][google.cloud.secretmanager.v1.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] to -[DESTROYED][google.cloud.secretmanager.v1.SecretVersion.State.DESTROYED] and irrevocably destroys the -secret data. - -The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::destroySecretVersionAsync()} . - - - - - - - - - - disableSecretVersion - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::disableSecretVersion() - - - request - - \Google\Cloud\SecretManager\V1\DisableSecretVersionRequest - - - - callOptions - [] - array - - - - Disables a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. - Sets the [state][google.cloud.secretmanager.v1.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] to -[DISABLED][google.cloud.secretmanager.v1.SecretVersion.State.DISABLED]. - -The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::disableSecretVersionAsync()} . - - - - - - - - - - enableSecretVersion - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::enableSecretVersion() - - - request - - \Google\Cloud\SecretManager\V1\EnableSecretVersionRequest - - - - callOptions - [] - array - - - - Enables a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. - Sets the [state][google.cloud.secretmanager.v1.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] to -[ENABLED][google.cloud.secretmanager.v1.SecretVersion.State.ENABLED]. - -The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::enableSecretVersionAsync()} . - - - - - - - - - - getIamPolicy - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::getIamPolicy() - - - request - - \Google\Cloud\Iam\V1\GetIamPolicyRequest - - - - callOptions - [] - array - - - - Gets the access control policy for a secret. - Returns empty policy if the secret exists and does not have a policy set. - -The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::getIamPolicyAsync()} . - - - - - - - - - - getSecret - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::getSecret() - - - request - - \Google\Cloud\SecretManager\V1\GetSecretRequest - - - - callOptions - [] - array - - - - Gets metadata for a given [Secret][google.cloud.secretmanager.v1.Secret]. - The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::getSecretAsync()} . - - - - - - - - - - getSecretVersion - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::getSecretVersion() - - - request - - \Google\Cloud\SecretManager\V1\GetSecretVersionRequest - - - - callOptions - [] - array - - - - Gets metadata for a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. - `projects/&#42;/secrets/&#42;/versions/latest` is an alias to the most recently -created [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. - -The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::getSecretVersionAsync()} . - - - - - - - - - - listSecretVersions - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::listSecretVersions() - - - request - - \Google\Cloud\SecretManager\V1\ListSecretVersionsRequest - - - - callOptions - [] - array - - - - Lists [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. This call does not return secret -data. - The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::listSecretVersionsAsync()} . - - - - - - - - - - listSecrets - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::listSecrets() - - - request - - \Google\Cloud\SecretManager\V1\ListSecretsRequest - - - - callOptions - [] - array - - - - Lists [Secrets][google.cloud.secretmanager.v1.Secret]. - The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::listSecretsAsync()} . - - - - - - - - - - setIamPolicy - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::setIamPolicy() - - - request - - \Google\Cloud\Iam\V1\SetIamPolicyRequest - - - - callOptions - [] - array - - - - Sets the access control policy on the specified secret. Replaces any -existing policy. - Permissions on [SecretVersions][google.cloud.secretmanager.v1.SecretVersion] are enforced according -to the policy set on the associated [Secret][google.cloud.secretmanager.v1.Secret]. - -The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::setIamPolicyAsync()} . - - - - - - - - - - testIamPermissions - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::testIamPermissions() - - - request - - \Google\Cloud\Iam\V1\TestIamPermissionsRequest - - - - callOptions - [] - array - - - - Returns permissions that a caller has for the specified secret. - If the secret does not exist, this call returns an empty set of -permissions, not a NOT_FOUND error. - -Note: This operation is designed to be used for building permission-aware -UIs and command-line tools, not for authorization checking. This operation -may "fail open" without warning. - -The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::testIamPermissionsAsync()} . - - - - - - - - - - updateSecret - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::updateSecret() - - - request - - \Google\Cloud\SecretManager\V1\UpdateSecretRequest - - - - callOptions - [] - array - - - - Updates metadata of an existing [Secret][google.cloud.secretmanager.v1.Secret]. - The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::updateSecretAsync()} . - - - - - - - - - - accessSecretVersionAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::accessSecretVersionAsync() - - - request - - \Google\Cloud\SecretManager\V1\AccessSecretVersionRequest - - - - optionalArgs = [] - - array - - - - - - - - - - - - addSecretVersionAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::addSecretVersionAsync() - - - request - - \Google\Cloud\SecretManager\V1\AddSecretVersionRequest - - - - optionalArgs = [] - - array - - - - - - - - - - - - createSecretAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::createSecretAsync() - - - request - - \Google\Cloud\SecretManager\V1\CreateSecretRequest - - - - optionalArgs = [] - - array - - - - - - - - - - - - deleteSecretAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::deleteSecretAsync() - - - request - - \Google\Cloud\SecretManager\V1\DeleteSecretRequest - - - - optionalArgs = [] - - array - - - - - - - - - - - - destroySecretVersionAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::destroySecretVersionAsync() - - - request - - \Google\Cloud\SecretManager\V1\DestroySecretVersionRequest - - - - optionalArgs = [] - - array - - - - - - - - - - - - disableSecretVersionAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::disableSecretVersionAsync() - - - request - - \Google\Cloud\SecretManager\V1\DisableSecretVersionRequest - - - - optionalArgs = [] - - array - - - - - - - - - - - - enableSecretVersionAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::enableSecretVersionAsync() - - - request - - \Google\Cloud\SecretManager\V1\EnableSecretVersionRequest - - - - optionalArgs = [] - - array - - - - - - - - - - - - getIamPolicyAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::getIamPolicyAsync() - - - request - - \Google\Cloud\Iam\V1\GetIamPolicyRequest - - - - optionalArgs = [] - - array - - - - - - - - - - - - getSecretAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::getSecretAsync() - - - request - - \Google\Cloud\SecretManager\V1\GetSecretRequest - - - - optionalArgs = [] - - array - - - - - - - - - - - - getSecretVersionAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::getSecretVersionAsync() - - - request - - \Google\Cloud\SecretManager\V1\GetSecretVersionRequest - - - - optionalArgs = [] - - array - - - - - - - - - - - - listSecretVersionsAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::listSecretVersionsAsync() - - - request - - \Google\Cloud\SecretManager\V1\ListSecretVersionsRequest - - - - optionalArgs = [] - - array - - - - - - - - - - - - listSecretsAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::listSecretsAsync() - - - request - - \Google\Cloud\SecretManager\V1\ListSecretsRequest - - - - optionalArgs = [] - - array - - - - - - - - - - - - setIamPolicyAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::setIamPolicyAsync() - - - request - - \Google\Cloud\Iam\V1\SetIamPolicyRequest - - - - optionalArgs = [] - - array - - - - - - - - - - - - testIamPermissionsAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::testIamPermissionsAsync() - - - request - - \Google\Cloud\Iam\V1\TestIamPermissionsRequest - - - - optionalArgs = [] - - array - - - - - - - - - - - - updateSecretAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::updateSecretAsync() - - - request - - \Google\Cloud\SecretManager\V1\UpdateSecretRequest - - - - optionalArgs = [] - - array - - - - - - - - - - - - - - - - + @@ -1098,91 +13,121 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + SecretManagerServiceClient \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient - + Service Description: Secret Manager Service - This class is currently experimental and may be subject to changes. + Manages secrets and operations using those secrets. Implements a REST +model with the following objects: + +* [Secret][google.cloud.secretmanager.v1.Secret] +* [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] + +This class provides the ability to make remote calls to the backing service through method +calls that map to API methods. + +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. + +This class is currently experimental and may be subject to changes. See {@see \Google\Cloud\SecretManager\V1\SecretManagerServiceClient} for the stable +implementation + + + + + + + + + + + + + + + - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient - + + SERVICE_NAME - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::SERVICE_NAME + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::SERVICE_NAME 'google.cloud.secretmanager.v1.SecretManagerService' - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + The name of the service. - + SERVICE_ADDRESS - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::SERVICE_ADDRESS + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::SERVICE_ADDRESS 'secretmanager.googleapis.com' - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + The default address of the service. - + DEFAULT_SERVICE_PORT - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::DEFAULT_SERVICE_PORT + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::DEFAULT_SERVICE_PORT 443 - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + The default port of the service. - + CODEGEN_NAME - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::CODEGEN_NAME + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::CODEGEN_NAME 'gapic' - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + The name of the code generator, to be included in the agent header. - - + + serviceScopes - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::$serviceScopes + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::$serviceScopes ['https://www.googleapis.com/auth/cloud-platform'] - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + The default scopes required by the service. - - + + getClientDefaults - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::getClientDefaults() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::getClientDefaults() - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + - + projectName - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::projectName() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::projectName() - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + project string @@ -1198,11 +143,11 @@ resource. - + secretName - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::secretName() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::secretName() - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + project string @@ -1225,11 +170,11 @@ resource. - + secretVersionName - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::secretVersionName() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::secretVersionName() - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + project string @@ -1259,29 +204,57 @@ secret_version resource. - + + topicName + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::topicName() + + + project + + string + + + + topic + + string + + + + Formats a string containing the fully-qualified path to represent a topic +resource. + + + + + + + + + parseName - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::parseName() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::parseName() - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + formattedName string - + template null string - + 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} - secret: projects/{project}/secrets/{secret} - secretVersion: projects/{project}/secrets/{secret}/versions/{secret_version} +- topic: projects/{project}/topics/{topic} 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 @@ -1296,17 +269,17 @@ the first match. - + __construct - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::__construct() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::__construct() - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + options [] array - + Constructor. @@ -1315,51 +288,52 @@ the first match. - + __call - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::__call() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::__call() - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + method mixed - + args mixed - + Handles execution of the async variants for each documented method. - + accessSecretVersion - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::accessSecretVersion() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::accessSecretVersion() - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + request \Google\Cloud\SecretManager\V1\AccessSecretVersionRequest - + callOptions [] array - + Accesses a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. This call returns the secret data. `projects/&#42;/secrets/&#42;/versions/latest` is an alias to the most recently created [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. -The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::accessSecretVersionAsync()} . +The async variant is +{@see \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::accessSecretVersionAsync()} . @@ -1368,26 +342,27 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + addSecretVersion - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::addSecretVersion() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::addSecretVersion() - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + request \Google\Cloud\SecretManager\V1\AddSecretVersionRequest - + callOptions [] array - + Creates a new [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] containing secret data and attaches it to an existing [Secret][google.cloud.secretmanager.v1.Secret]. - The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::addSecretVersionAsync()} . + The async variant is {@see \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::addSecretVersionAsync()} +. @@ -1396,25 +371,25 @@ it to an existing [Secret][google.cloud.secretmanager.v1.Secret]. - + createSecret - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::createSecret() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::createSecret() - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + request \Google\Cloud\SecretManager\V1\CreateSecretRequest - + callOptions [] array - + Creates a new [Secret][google.cloud.secretmanager.v1.Secret] containing no [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. - The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::createSecretAsync()} . + The async variant is {@see \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::createSecretAsync()} . @@ -1423,25 +398,25 @@ it to an existing [Secret][google.cloud.secretmanager.v1.Secret]. - + deleteSecret - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::deleteSecret() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::deleteSecret() - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + request \Google\Cloud\SecretManager\V1\DeleteSecretRequest - + callOptions [] array - + Deletes a [Secret][google.cloud.secretmanager.v1.Secret]. - The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::deleteSecretAsync()} . + The async variant is {@see \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::deleteSecretAsync()} . @@ -1449,29 +424,30 @@ it to an existing [Secret][google.cloud.secretmanager.v1.Secret]. - + destroySecretVersion - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::destroySecretVersion() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::destroySecretVersion() - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + request \Google\Cloud\SecretManager\V1\DestroySecretVersionRequest - + callOptions [] array - + Destroys a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. Sets the [state][google.cloud.secretmanager.v1.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] to [DESTROYED][google.cloud.secretmanager.v1.SecretVersion.State.DESTROYED] and irrevocably destroys the secret data. -The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::destroySecretVersionAsync()} . +The async variant is +{@see \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::destroySecretVersionAsync()} . @@ -1480,28 +456,29 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + disableSecretVersion - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::disableSecretVersion() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::disableSecretVersion() - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + request \Google\Cloud\SecretManager\V1\DisableSecretVersionRequest - + callOptions [] array - + Disables a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. Sets the [state][google.cloud.secretmanager.v1.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] to [DISABLED][google.cloud.secretmanager.v1.SecretVersion.State.DISABLED]. -The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::disableSecretVersionAsync()} . +The async variant is +{@see \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::disableSecretVersionAsync()} . @@ -1510,28 +487,29 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + enableSecretVersion - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::enableSecretVersion() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::enableSecretVersion() - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + request \Google\Cloud\SecretManager\V1\EnableSecretVersionRequest - + callOptions [] array - + Enables a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. Sets the [state][google.cloud.secretmanager.v1.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] to [ENABLED][google.cloud.secretmanager.v1.SecretVersion.State.ENABLED]. -The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::enableSecretVersionAsync()} . +The async variant is +{@see \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::enableSecretVersionAsync()} . @@ -1540,27 +518,27 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + getIamPolicy - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::getIamPolicy() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::getIamPolicy() - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + request \Google\Cloud\Iam\V1\GetIamPolicyRequest - + callOptions [] array - + Gets the access control policy for a secret. Returns empty policy if the secret exists and does not have a policy set. -The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::getIamPolicyAsync()} . +The async variant is {@see \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::getIamPolicyAsync()} . @@ -1569,25 +547,25 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + getSecret - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::getSecret() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::getSecret() - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + request \Google\Cloud\SecretManager\V1\GetSecretRequest - + callOptions [] array - + Gets metadata for a given [Secret][google.cloud.secretmanager.v1.Secret]. - The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::getSecretAsync()} . + The async variant is {@see \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::getSecretAsync()} . @@ -1596,28 +574,29 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + getSecretVersion - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::getSecretVersion() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::getSecretVersion() - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + request \Google\Cloud\SecretManager\V1\GetSecretVersionRequest - + callOptions [] array - + Gets metadata for a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. `projects/&#42;/secrets/&#42;/versions/latest` is an alias to the most recently created [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. -The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::getSecretVersionAsync()} . +The async variant is {@see \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::getSecretVersionAsync()} +. @@ -1626,26 +605,27 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + listSecretVersions - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::listSecretVersions() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::listSecretVersions() - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + request \Google\Cloud\SecretManager\V1\ListSecretVersionsRequest - + callOptions [] array - + Lists [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. This call does not return secret data. - The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::listSecretVersionsAsync()} . + The async variant is +{@see \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::listSecretVersionsAsync()} . @@ -1654,25 +634,25 @@ data. - + listSecrets - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::listSecrets() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::listSecrets() - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + request \Google\Cloud\SecretManager\V1\ListSecretsRequest - + callOptions [] array - + Lists [Secrets][google.cloud.secretmanager.v1.Secret]. - The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::listSecretsAsync()} . + The async variant is {@see \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::listSecretsAsync()} . @@ -1681,29 +661,29 @@ data. - + setIamPolicy - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::setIamPolicy() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::setIamPolicy() - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + request \Google\Cloud\Iam\V1\SetIamPolicyRequest - + callOptions [] array - + Sets the access control policy on the specified secret. Replaces any existing policy. Permissions on [SecretVersions][google.cloud.secretmanager.v1.SecretVersion] are enforced according to the policy set on the associated [Secret][google.cloud.secretmanager.v1.Secret]. -The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::setIamPolicyAsync()} . +The async variant is {@see \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::setIamPolicyAsync()} . @@ -1712,23 +692,23 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + testIamPermissions - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::testIamPermissions() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::testIamPermissions() - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + request \Google\Cloud\Iam\V1\TestIamPermissionsRequest - + callOptions [] array - + Returns permissions that a caller has for the specified secret. If the secret does not exist, this call returns an empty set of permissions, not a NOT_FOUND error. @@ -1737,7 +717,8 @@ Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning. -The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::testIamPermissionsAsync()} . +The async variant is +{@see \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::testIamPermissionsAsync()} . @@ -1746,25 +727,25 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + updateSecret - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::updateSecret() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::updateSecret() - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient + request \Google\Cloud\SecretManager\V1\UpdateSecretRequest - + callOptions [] array - + Updates metadata of an existing [Secret][google.cloud.secretmanager.v1.Secret]. - The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self::updateSecretAsync()} . + The async variant is {@see \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::updateSecretAsync()} . @@ -1773,9 +754,9 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + accessSecretVersionAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::accessSecretVersionAsync() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::accessSecretVersionAsync() request @@ -1797,9 +778,9 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + addSecretVersionAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::addSecretVersionAsync() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::addSecretVersionAsync() request @@ -1821,9 +802,9 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + createSecretAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::createSecretAsync() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::createSecretAsync() request @@ -1845,9 +826,9 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + deleteSecretAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::deleteSecretAsync() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::deleteSecretAsync() request @@ -1869,9 +850,9 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + destroySecretVersionAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::destroySecretVersionAsync() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::destroySecretVersionAsync() request @@ -1893,9 +874,9 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + disableSecretVersionAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::disableSecretVersionAsync() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::disableSecretVersionAsync() request @@ -1917,9 +898,9 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + enableSecretVersionAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::enableSecretVersionAsync() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::enableSecretVersionAsync() request @@ -1941,9 +922,9 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + getIamPolicyAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::getIamPolicyAsync() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::getIamPolicyAsync() request @@ -1965,9 +946,9 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + getSecretAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::getSecretAsync() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::getSecretAsync() request @@ -1989,9 +970,9 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + getSecretVersionAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::getSecretVersionAsync() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::getSecretVersionAsync() request @@ -2013,9 +994,9 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + listSecretVersionsAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::listSecretVersionsAsync() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::listSecretVersionsAsync() request @@ -2037,9 +1018,9 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + listSecretsAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::listSecretsAsync() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::listSecretsAsync() request @@ -2061,9 +1042,9 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + setIamPolicyAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::setIamPolicyAsync() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::setIamPolicyAsync() request @@ -2085,9 +1066,9 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + testIamPermissionsAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::testIamPermissionsAsync() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::testIamPermissionsAsync() request @@ -2109,9 +1090,9 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + updateSecretAsync - \Google\Cloud\SecretManager\V1\Client\BaseClient\SecretManagerServiceBaseClient::updateSecretAsync() + \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient::updateSecretAsync() request @@ -2138,7 +1119,7 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + @@ -2153,10 +1134,10 @@ The async variant is {@see \Google\Cloud\SecretManager\V1\Client\BaseClient\self - + SecretManagerServiceGapicClient \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient - + Service Description: Secret Manager Service Manages secrets and operations using those secrets. Implements a REST model with the following objects: @@ -2180,50 +1161,53 @@ try { 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. +contained within formatted names that are returned by the API. + +This service has a new (beta) implementation. See {@see \Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient} to use the new +surface. - + SERVICE_NAME \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::SERVICE_NAME 'google.cloud.secretmanager.v1.SecretManagerService' - + The name of the service. - + SERVICE_ADDRESS \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::SERVICE_ADDRESS 'secretmanager.googleapis.com' - + The default address of the service. - + DEFAULT_SERVICE_PORT \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::DEFAULT_SERVICE_PORT 443 - + The default port of the service. - + CODEGEN_NAME \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::CODEGEN_NAME 'gapic' - + The name of the code generator, to be included in the agent header. @@ -2231,55 +1215,66 @@ contained within formatted names that are returned by the API. - + serviceScopes \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::$serviceScopes ['https://www.googleapis.com/auth/cloud-platform'] - + The default scopes required by the service. - + projectNameTemplate \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::$projectNameTemplate - + - + secretNameTemplate \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::$secretNameTemplate - + - + secretVersionNameTemplate \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::$secretVersionNameTemplate - + - + + topicNameTemplate + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::$topicNameTemplate + + + + + + + + + pathTemplateMap \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::$pathTemplateMap - + @@ -2287,72 +1282,83 @@ contained within formatted names that are returned by the API. - + getClientDefaults \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::getClientDefaults() - + - + getProjectNameTemplate \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::getProjectNameTemplate() - + - + getSecretNameTemplate \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::getSecretNameTemplate() - + - + getSecretVersionNameTemplate \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::getSecretVersionNameTemplate() - + + + + + + + + + getTopicNameTemplate + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::getTopicNameTemplate() + + - + getPathTemplateMap \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::getPathTemplateMap() - + - + projectName \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::projectName() - + project string - + Formats a string containing the fully-qualified path to represent a project resource. @@ -2362,23 +1368,23 @@ resource. - + secretName \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::secretName() - + project string - + secret string - + Formats a string containing the fully-qualified path to represent a secret resource. @@ -2389,29 +1395,29 @@ resource. - + secretVersionName \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::secretVersionName() - + project string - + secret string - + secretVersion string - + Formats a string containing the fully-qualified path to represent a secret_version resource. @@ -2423,29 +1429,57 @@ secret_version resource. - + + topicName + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::topicName() + + + project + + string + + + + topic + + string + + + + Formats a string containing the fully-qualified path to represent a topic +resource. + + + + + + + + + parseName \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::parseName() - + formattedName string - + template null string - + 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} - secret: projects/{project}/secrets/{secret} - secretVersion: projects/{project}/secrets/{secret}/versions/{secret_version} +- topic: projects/{project}/topics/{topic} 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 @@ -2460,17 +1494,17 @@ the first match. - + __construct \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::__construct() - + options [] array - + Constructor. @@ -2479,23 +1513,23 @@ the first match. - + accessSecretVersion \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::accessSecretVersion() - + name string - + optionalArgs [] array - + Accesses a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. This call returns the secret data. `projects/&#42;/secrets/&#42;/versions/latest` is an alias to the most recently created [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. @@ -2518,29 +1552,29 @@ try { - + addSecretVersion \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::addSecretVersion() - + parent string - + payload \Google\Cloud\SecretManager\V1\SecretPayload - + optionalArgs [] array - + Creates a new [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] containing secret data and attaches it to an existing [Secret][google.cloud.secretmanager.v1.Secret]. Sample code: @@ -2563,35 +1597,35 @@ try { - + createSecret \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::createSecret() - + parent string - + secretId string - + secret \Google\Cloud\SecretManager\V1\Secret - + optionalArgs [] array - + Creates a new [Secret][google.cloud.secretmanager.v1.Secret] containing no [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. Sample code: ``` @@ -2615,23 +1649,23 @@ try { - + deleteSecret \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::deleteSecret() - + name string - + optionalArgs [] array - + Deletes a [Secret][google.cloud.secretmanager.v1.Secret]. Sample code: ``` @@ -2650,23 +1684,23 @@ try { - + destroySecretVersion \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::destroySecretVersion() - + name string - + optionalArgs [] array - + Destroys a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. Sets the [state][google.cloud.secretmanager.v1.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] to [DESTROYED][google.cloud.secretmanager.v1.SecretVersion.State.DESTROYED] and irrevocably destroys the @@ -2690,23 +1724,23 @@ try { - + disableSecretVersion \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::disableSecretVersion() - + name string - + optionalArgs [] array - + Disables a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. Sets the [state][google.cloud.secretmanager.v1.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] to [DISABLED][google.cloud.secretmanager.v1.SecretVersion.State.DISABLED]. @@ -2729,23 +1763,23 @@ try { - + enableSecretVersion \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::enableSecretVersion() - + name string - + optionalArgs [] array - + Enables a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. Sets the [state][google.cloud.secretmanager.v1.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] to [ENABLED][google.cloud.secretmanager.v1.SecretVersion.State.ENABLED]. @@ -2768,23 +1802,23 @@ try { - + getIamPolicy \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::getIamPolicy() - + resource string - + optionalArgs [] array - + Gets the access control policy for a secret. Returns empty policy if the secret exists and does not have a policy set. @@ -2806,23 +1840,23 @@ try { - + getSecret \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::getSecret() - + name string - + optionalArgs [] array - + Gets metadata for a given [Secret][google.cloud.secretmanager.v1.Secret]. Sample code: ``` @@ -2842,23 +1876,23 @@ try { - + getSecretVersion \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::getSecretVersion() - + name string - + optionalArgs [] array - + Gets metadata for a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. `projects/&#42;/secrets/&#42;/versions/latest` is an alias to the most recently created [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. @@ -2881,23 +1915,23 @@ try { - + listSecretVersions \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::listSecretVersions() - + parent string - + optionalArgs [] array - + Lists [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. This call does not return secret data. Sample code: @@ -2930,23 +1964,23 @@ try { - + listSecrets \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::listSecrets() - + parent string - + optionalArgs [] array - + Lists [Secrets][google.cloud.secretmanager.v1.Secret]. Sample code: ``` @@ -2978,29 +2012,29 @@ try { - + setIamPolicy \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::setIamPolicy() - + resource string - + policy \Google\Cloud\Iam\V1\Policy - + optionalArgs [] array - + Sets the access control policy on the specified secret. Replaces any existing policy. Permissions on [SecretVersions][google.cloud.secretmanager.v1.SecretVersion] are enforced according @@ -3026,29 +2060,29 @@ try { - + testIamPermissions \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::testIamPermissions() - + resource string - + permissions string[] - + optionalArgs [] array - + Returns permissions that a caller has for the specified secret. If the secret does not exist, this call returns an empty set of permissions, not a NOT_FOUND error. @@ -3077,29 +2111,29 @@ try { - + updateSecret \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::updateSecret() - + secret \Google\Cloud\SecretManager\V1\Secret - + updateMask \Google\Protobuf\FieldMask - + optionalArgs [] array - + Updates metadata of an existing [Secret][google.cloud.secretmanager.v1.Secret]. Sample code: ``` @@ -3152,44 +2186,44 @@ try { \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient - + SERVICE_NAME \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::SERVICE_NAME 'google.cloud.secretmanager.v1.SecretManagerService' - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient The name of the service. - + SERVICE_ADDRESS \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::SERVICE_ADDRESS 'secretmanager.googleapis.com' - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient The default address of the service. - + DEFAULT_SERVICE_PORT \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::DEFAULT_SERVICE_PORT 443 - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient The default port of the service. - + CODEGEN_NAME \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::CODEGEN_NAME 'gapic' - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient The name of the code generator, to be included in the agent header. @@ -3197,55 +2231,66 @@ try { - + serviceScopes \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::$serviceScopes ['https://www.googleapis.com/auth/cloud-platform'] - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient The default scopes required by the service. - + projectNameTemplate \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::$projectNameTemplate - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient - + secretNameTemplate \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::$secretNameTemplate - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient - + secretVersionNameTemplate \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::$secretVersionNameTemplate - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient - + + topicNameTemplate + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::$topicNameTemplate + + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + + + + + + + pathTemplateMap \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::$pathTemplateMap - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient @@ -3253,72 +2298,83 @@ try { - + getClientDefaults \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::getClientDefaults() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient - + getProjectNameTemplate \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::getProjectNameTemplate() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient - + getSecretNameTemplate \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::getSecretNameTemplate() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient - + getSecretVersionNameTemplate \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::getSecretVersionNameTemplate() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient - + + getTopicNameTemplate + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::getTopicNameTemplate() + + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + + + + + + + getPathTemplateMap \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::getPathTemplateMap() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient - + projectName \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::projectName() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient project string - + Formats a string containing the fully-qualified path to represent a project resource. @@ -3328,23 +2384,23 @@ resource. - + secretName \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::secretName() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient project string - + secret string - + Formats a string containing the fully-qualified path to represent a secret resource. @@ -3355,29 +2411,29 @@ resource. - + secretVersionName \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::secretVersionName() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient project string - + secret string - + secretVersion string - + Formats a string containing the fully-qualified path to represent a secret_version resource. @@ -3389,29 +2445,57 @@ secret_version resource. - + + topicName + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::topicName() + + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + project + + string + + + + topic + + string + + + + Formats a string containing the fully-qualified path to represent a topic +resource. + + + + + + + + + parseName \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::parseName() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient formattedName string - + template null string - + 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} - secret: projects/{project}/secrets/{secret} - secretVersion: projects/{project}/secrets/{secret}/versions/{secret_version} +- topic: projects/{project}/topics/{topic} 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 @@ -3426,17 +2510,17 @@ the first match. - + __construct \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::__construct() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient options [] array - + Constructor. @@ -3445,23 +2529,23 @@ the first match. - + accessSecretVersion \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::accessSecretVersion() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient name string - + optionalArgs [] array - + Accesses a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. This call returns the secret data. `projects/&#42;/secrets/&#42;/versions/latest` is an alias to the most recently created [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. @@ -3484,29 +2568,29 @@ try { - + addSecretVersion \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::addSecretVersion() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient parent string - + payload \Google\Cloud\SecretManager\V1\SecretPayload - + optionalArgs [] array - + Creates a new [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] containing secret data and attaches it to an existing [Secret][google.cloud.secretmanager.v1.Secret]. Sample code: @@ -3529,35 +2613,35 @@ try { - + createSecret \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::createSecret() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient parent string - + secretId string - + secret \Google\Cloud\SecretManager\V1\Secret - + optionalArgs [] array - + Creates a new [Secret][google.cloud.secretmanager.v1.Secret] containing no [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. Sample code: ``` @@ -3581,23 +2665,23 @@ try { - + deleteSecret \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::deleteSecret() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient name string - + optionalArgs [] array - + Deletes a [Secret][google.cloud.secretmanager.v1.Secret]. Sample code: ``` @@ -3616,23 +2700,23 @@ try { - + destroySecretVersion \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::destroySecretVersion() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient name string - + optionalArgs [] array - + Destroys a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. Sets the [state][google.cloud.secretmanager.v1.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] to [DESTROYED][google.cloud.secretmanager.v1.SecretVersion.State.DESTROYED] and irrevocably destroys the @@ -3656,23 +2740,23 @@ try { - + disableSecretVersion \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::disableSecretVersion() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient name string - + optionalArgs [] array - + Disables a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. Sets the [state][google.cloud.secretmanager.v1.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] to [DISABLED][google.cloud.secretmanager.v1.SecretVersion.State.DISABLED]. @@ -3695,23 +2779,23 @@ try { - + enableSecretVersion \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::enableSecretVersion() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient name string - + optionalArgs [] array - + Enables a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. Sets the [state][google.cloud.secretmanager.v1.SecretVersion.state] of the [SecretVersion][google.cloud.secretmanager.v1.SecretVersion] to [ENABLED][google.cloud.secretmanager.v1.SecretVersion.State.ENABLED]. @@ -3734,23 +2818,23 @@ try { - + getIamPolicy \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::getIamPolicy() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient resource string - + optionalArgs [] array - + Gets the access control policy for a secret. Returns empty policy if the secret exists and does not have a policy set. @@ -3772,23 +2856,23 @@ try { - + getSecret \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::getSecret() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient name string - + optionalArgs [] array - + Gets metadata for a given [Secret][google.cloud.secretmanager.v1.Secret]. Sample code: ``` @@ -3808,23 +2892,23 @@ try { - + getSecretVersion \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::getSecretVersion() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient name string - + optionalArgs [] array - + Gets metadata for a [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. `projects/&#42;/secrets/&#42;/versions/latest` is an alias to the most recently created [SecretVersion][google.cloud.secretmanager.v1.SecretVersion]. @@ -3847,23 +2931,23 @@ try { - + listSecretVersions \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::listSecretVersions() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient parent string - + optionalArgs [] array - + Lists [SecretVersions][google.cloud.secretmanager.v1.SecretVersion]. This call does not return secret data. Sample code: @@ -3896,23 +2980,23 @@ try { - + listSecrets \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::listSecrets() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient parent string - + optionalArgs [] array - + Lists [Secrets][google.cloud.secretmanager.v1.Secret]. Sample code: ``` @@ -3944,29 +3028,29 @@ try { - + setIamPolicy \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::setIamPolicy() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient resource string - + policy \Google\Cloud\Iam\V1\Policy - + optionalArgs [] array - + Sets the access control policy on the specified secret. Replaces any existing policy. Permissions on [SecretVersions][google.cloud.secretmanager.v1.SecretVersion] are enforced according @@ -3992,29 +3076,29 @@ try { - + testIamPermissions \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::testIamPermissions() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient resource string - + permissions string[] - + optionalArgs [] array - + Returns permissions that a caller has for the specified secret. If the secret does not exist, this call returns an empty set of permissions, not a NOT_FOUND error. @@ -4043,29 +3127,29 @@ try { - + updateSecret \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient::updateSecret() - \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient + \Google\Cloud\SecretManager\V1\Gapic\SecretManagerServiceGapicClient secret \Google\Cloud\SecretManager\V1\Secret - + updateMask \Google\Protobuf\FieldMask - + optionalArgs [] array - + Updates metadata of an existing [Secret][google.cloud.secretmanager.v1.Secret]. Sample code: ``` diff --git a/dev/tests/fixtures/phpdoc/structure.xml b/dev/tests/fixtures/phpdoc/structure.xml index 938c842cf145..1b374d9b35e9 100644 --- a/dev/tests/fixtures/phpdoc/structure.xml +++ b/dev/tests/fixtures/phpdoc/structure.xml @@ -86,7 +86,7 @@ $info = $imageProperties->info(); - + @@ -224,6 +224,79 @@ $info = $imageProperties->info(); /> + + + + boundingPoly + \Google\Cloud\Vision\Annotation\CropHint::boundingPoly() + + + + { + The bounding polygon of the recommended crop. + + Example: + ``` + $poly = $hint->boundingPoly(); + ``` + + @return array [BoundingPoly](https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate#boundingpoly) +} + + + + + + + confidence + \Google\Cloud\Vision\Annotation\CropHint::confidence() + + + + { + Confidence of this being a salient region. Range [0, 1]. + + Example: + ``` + $confidence = $hint->confidence(); + ``` + + @return float +} + + + + + + + importanceFraction + \Google\Cloud\Vision\Annotation\CropHint::importanceFraction() + + + + { + Fraction of importance of this salient region with respect to the + original image. + + Example: + ``` + $importance = $hint->importanceFraction(); + ``` + + @return float +} + + + @@ -363,6 +436,78 @@ $info = $imageProperties->info(); /> + + + + pages + \Google\Cloud\Vision\Annotation\Document::pages() + + + + { + Get the document pages. + + Example: + ``` + $pages = $document->pages(); + ``` + + @return array +} + + + + + + + text + \Google\Cloud\Vision\Annotation\Document::text() + + + + { + Get the document text. + + Example: + ``` + $text = $document->text(); + ``` + + @return string +} + + + + + + + info + \Google\Cloud\Vision\Annotation\Document::info() + + + Get the raw annotation result + { + Get the Document Text detection result. + + Example: + ``` + $info = $document->info(); + ``` + + @return array +} + + + @@ -548,6 +693,276 @@ $info = $imageProperties->info(); /> + + + + mid + \Google\Cloud\Vision\Annotation\Entity::mid() + + + + { + Opaque entity ID. + + Some IDs might be available in Knowledge Graph(KG). + + Example: + ``` + echo $text->mid(); + ``` + + @see https://developers.google.com/knowledge-graph/ Knowledge Graph + + @return string +} + + + + + + + locale + \Google\Cloud\Vision\Annotation\Entity::locale() + + + + { + The language code for the locale in which the entity textual description + (next field) is expressed. + + Example: + ``` + echo $text->locale(); + ``` + + @return string +} + + + + + + + description + \Google\Cloud\Vision\Annotation\Entity::description() + + + + { + Entity textual description, expressed in its locale language. + + Example: + ``` + echo $text->description(); + ``` + + @return string +} + + + + + + + score + \Google\Cloud\Vision\Annotation\Entity::score() + + + + { + Overall score of the result. + + Range [0, 1]. + + Example: + ``` + echo $text->score(); + ``` + + @return float +} + + + + + + + confidence + \Google\Cloud\Vision\Annotation\Entity::confidence() + + + + { + The accuracy of the entity detection in an image. + + For example, for an image containing 'Eiffel Tower,' this field + represents the confidence that there is a tower in the query image. + + Range [0, 1]. + + Example: + ``` + echo $text->confidence(); + ``` + + @return float +} + + + + + + + topicality + \Google\Cloud\Vision\Annotation\Entity::topicality() + + + + { + The relevancy of the ICA (Image Content Annotation) label to the image. + + For example, the relevancy of 'tower' to an image containing + 'Eiffel Tower' is likely higher than an image containing a distant + towering building, though the confidence that there is a tower may be the + same. + + Range [0, 1]. + + Example: + ``` + echo $text->topicality(); + ``` + + @return float +} + + + + + + + boundingPoly + \Google\Cloud\Vision\Annotation\Entity::boundingPoly() + + + + { + Image region to which this entity belongs. + + Not filled currently for LABEL_DETECTION features. For TEXT_DETECTION + (OCR), boundingPolys are produced for the entire text detected in an + image region, followed by boundingPolys for each word within the detected + text. + + Example: + ``` + print_r($text->boundingPoly()); + ``` + + @return array +} + + + + + + + locations + \Google\Cloud\Vision\Annotation\Entity::locations() + + + + { + The location information for the detected entity. + + Multiple LocationInfo elements can be present since one location may + indicate the location of the scene in the query image, and another the + location of the place where the query image was taken. Location + information is usually present for landmarks. + + Example: + ``` + print_r($text->locations()); + ``` + + @return array +} + + + + + + + properties + \Google\Cloud\Vision\Annotation\Entity::properties() + + + + { + Some entities can have additional optional Property fields. For example a + different kind of score or string that qualifies the entity. + + Example: + ``` + print_r($text->properties()); + ``` + + @return array +} + + + + + + + info + \Google\Cloud\Vision\Annotation\Entity::info() + + + Get the raw annotation result + { + Get the raw annotation result + + Example: + ``` + $info = $text->info(); + ``` + + @return array +} + + + @@ -1143,6 +1558,30 @@ $info = $imageProperties->info(); /> + + + + info + \Google\Cloud\Vision\Annotation\Face\Landmarks::info() + + + Get the raw annotation result + { + Get the raw landmarks annotation result + + Example: + ``` + $info = $landmarks->info(); + ``` + + @return array +} + + + @@ -1152,7 +1591,7 @@ $info = $imageProperties->info(); - + Copyright 2016 Google Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); @@ -1200,31 +1639,31 @@ $face = $faces[0]; ``` + + + + boundingPoly + \Google\Cloud\Vision\Annotation\Face::boundingPoly() + + + + { + The bounding polygon around the face. + + Example: + ``` + print_r($face->boundingPoly()); + ``` + + @return array +} + + + + + + + fdBoundingPoly + \Google\Cloud\Vision\Annotation\Face::fdBoundingPoly() + + + + { + Bounding polygon around the face. + + Tighter than `boundingPoly` and encloses only the skin part of the face. + + Example: + ``` + print_r($face->fdBoundingPoly()); + ``` + + @return array +} + + + + + + + rollAngle + \Google\Cloud\Vision\Annotation\Face::rollAngle() + + + + { + Roll angle. + + Indicates the amount of clockwise/anti-clockwise rotation of the face. + Range [-180,180] + + Example: + ``` + print_r($face->rollAngle()); + ``` + + @return float +} + + + + + + + panAngle + \Google\Cloud\Vision\Annotation\Face::panAngle() + + + + { + Yaw angle. + + Indicates the leftward/rightward angle that the face is pointing. Range + [-180,180] + + Example: + ``` + print_r($face->panAngle()); + ``` + + @return float +} + + + + + + + tiltAngle + \Google\Cloud\Vision\Annotation\Face::tiltAngle() + + + + { + Pitch angle. + + Indicates the upwards/downwards angle that the face is pointing. Range + [-180,180] + + Example: + ``` + print_r($face->tiltAngle()); + ``` + + @return float +} + + + + + + + detectionConfidence + \Google\Cloud\Vision\Annotation\Face::detectionConfidence() + + + + { + The detection confidence. + + Range [0,1] + + Example: + ``` + print_r($face->detectionConfidence()); + ``` + + @return float +} + + + + + + + landmarkingConfidence + \Google\Cloud\Vision\Annotation\Face::landmarkingConfidence() + + + + { + Face landmarking confidence. + + Range [0,1] + + Example: + ``` + print_r($face->landmarkingConfidence()); + ``` + + @return float +} + + + + + + + joyLikelihood + \Google\Cloud\Vision\Annotation\Face::joyLikelihood() + + + + { + Joy likelihood. + + Example: + ``` + echo $face->joyLikelihood(); + ``` + + @return string +} + + + + + + + sorrowLikelihood + \Google\Cloud\Vision\Annotation\Face::sorrowLikelihood() + + + + { + Sorrow likelihood. + + Example: + ``` + echo $face->sorrowLikelihood(); + ``` + + @return string +} + + + + + + + angerLikelihood + \Google\Cloud\Vision\Annotation\Face::angerLikelihood() + + + + { + Anger likelihood. + + Example: + ``` + echo $face->angerLikelihood(); + ``` + + @return string +} + + + + + + + surpriseLikelihood + \Google\Cloud\Vision\Annotation\Face::surpriseLikelihood() + + + + { + Surprise likelihood. + + Example: + ``` + echo $face->surpriseLikelihood(); + ``` + + @return string +} + + + + + + + underExposedLikelihood + \Google\Cloud\Vision\Annotation\Face::underExposedLikelihood() + + + + { + Under exposure likelihood. + + Example: + ``` + echo $face->underExposedLikelihood(); + ``` + + @return string +} + + + + + + + blurredLikelihood + \Google\Cloud\Vision\Annotation\Face::blurredLikelihood() + + + + { + Blurred likelihood. + + Example: + ``` + echo $face->blurredLikelihood(); + ``` + + @return string +} + + + + + + + headwearLikelihood + \Google\Cloud\Vision\Annotation\Face::headwearLikelihood() + + + + { + Headwear likelihood. + + Example: + ``` + echo $face->headwearLikelihood(); + ``` + + @return string +} + + + + + + + info + \Google\Cloud\Vision\Annotation\Face::info() + + + Get the raw annotation result + { + Get the raw annotation result + + Example: + ``` + $info = $face->info(); + ``` + + @return array +} + + + @@ -1888,6 +2702,30 @@ $info = $imageProperties->info(); /> + + + + info + \Google\Cloud\Vision\Annotation\ImageProperties::info() + + + Get the raw annotation result + { + Get the raw annotation result + + Example: + ``` + $info = $imageProperties->info(); + ``` + + @return array +} + + + @@ -2342,6 +3180,151 @@ $info = $imageProperties->info(); /> + + + + adult + \Google\Cloud\Vision\Annotation\SafeSearch::adult() + + + + { + Represents the adult contents likelihood for the image. + + Example: + ``` + echo $safeSearch->adult(); + ``` + + @return string +} + + + + + + + spoof + \Google\Cloud\Vision\Annotation\SafeSearch::spoof() + + + + { + Spoof likelihood. The likelihood that an obvious modification was made to + the image's canonical version to make it appear funny or offensive. + + Example: + ``` + echo $safeSearch->spoof(); + ``` + + @return string +} + + + + + + + medical + \Google\Cloud\Vision\Annotation\SafeSearch::medical() + + + + { + Likelihood this is a medical image. + + Example: + ``` + echo $safeSearch->medical(); + ``` + + @return string +} + + + + + + + violence + \Google\Cloud\Vision\Annotation\SafeSearch::violence() + + + + { + Violence likelihood. + + Example: + ``` + echo $safeSearch->violence(); + ``` + + @return string +} + + + + + + + racy + \Google\Cloud\Vision\Annotation\SafeSearch::racy() + + + + { + Racy likelihood. + + Example: + ``` + echo $safeSearch->racy(); + ``` + + @return string +} + + + + + + + info + \Google\Cloud\Vision\Annotation\SafeSearch::info() + + + Get the raw annotation result + { + Get the raw annotation result + + Example: + ``` + $info = $safeSearch->info(); + ``` + + @return array +} + + + @@ -2482,6 +3465,80 @@ $info = $imageProperties->info(); /> + + + + entityId + \Google\Cloud\Vision\Annotation\Web\WebEntity::entityId() + + + + { + The Entity ID + + Example: + ``` + $id = $entity->entityId(); + ``` + + @return string +} + + + + + + + score + \Google\Cloud\Vision\Annotation\Web\WebEntity::score() + + + + { + Overall relevancy score for the image. + + Not normalized and not comparable across different image queries. + + Example: + ``` + $score = $entity->score(); + ``` + + @return float +} + + + + + + + description + \Google\Cloud\Vision\Annotation\Web\WebEntity::description() + + + + { + Canonical description of the entity, in English. + + Example: + ``` + $description = $entity->description(); + ``` + + @return string +} + + + @@ -2618,6 +3675,56 @@ $info = $imageProperties->info(); /> + + + + url + \Google\Cloud\Vision\Annotation\Web\WebImage::url() + + + + { + The result image URL + + Example: + ``` + $url = $image->url(); + ``` + + @return string +} + + + + + + + score + \Google\Cloud\Vision\Annotation\Web\WebImage::score() + + + + { + Overall relevancy score for the image. + + Not normalized and not comparable across different image queries. + + Example: + ``` + $score = $image->score(); + ``` + + @return float +} + + + @@ -2754,6 +3861,56 @@ $info = $imageProperties->info(); /> + + + + url + \Google\Cloud\Vision\Annotation\Web\WebPage::url() + + + + { + The result web page URL + + Example: + ``` + $url = $image->url(); + ``` + + @return string +} + + + + + + + score + \Google\Cloud\Vision\Annotation\Web\WebPage::score() + + + + { + Overall relevancy score for the image. + + Not normalized and not comparable across different image queries. + + Example: + ``` + $score = $image->score(); + ``` + + @return float +} + + + @@ -3021,7 +4178,7 @@ $info = $imageProperties->info(); - + @@ -3580,13 +4737,13 @@ $error = $annotation->error(); - + - + Copyright 2016 Google Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); @@ -3613,30 +4770,34 @@ limitations under the License. - + ConnectionInterface \Google\Cloud\Vision\Connection\ConnectionInterface - + Represents a connection to [Cloud Vision](https://cloud.google.com/vision). + - + annotate \Google\Cloud\Vision\Connection\ConnectionInterface::annotate() - + args array - + - + @@ -4223,13 +5384,13 @@ is specified. - + - + @@ -4291,17 +5452,56 @@ Generated from protobuf field <code>string product = 2 [(.google.api.field - + + build + \Google\Cloud\Vision\V1\AddProductToProductSetRequest::build() + + + name + + string + + + + product + + string + + + + + + + + + + + + + + __construct \Google\Cloud\Vision\V1\AddProductToProductSetRequest::__construct() - + data NULL array - + Constructor. - + getName \Google\Cloud\Vision\V1\AddProductToProductSetRequest::getName() - + Required. The resource name for the ProductSet to modify. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` @@ -4330,17 +5530,17 @@ Generated from protobuf field <code>string name = 1 [(.google.api.field_be - + setName \Google\Cloud\Vision\V1\AddProductToProductSetRequest::setName() - + var string - + Required. The resource name for the ProductSet to modify. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` @@ -4358,11 +5558,11 @@ Generated from protobuf field <code>string name = 1 [(.google.api.field_be - + getProduct \Google\Cloud\Vision\V1\AddProductToProductSetRequest::getProduct() - + Required. The resource name for the Product to be added to this ProductSet. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` @@ -4376,17 +5576,17 @@ Generated from protobuf field <code>string product = 2 [(.google.api.field - + setProduct \Google\Cloud\Vision\V1\AddProductToProductSetRequest::setProduct() - + var string - + Required. The resource name for the Product to be added to this ProductSet. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` @@ -4404,7 +5604,7 @@ Generated from protobuf field <code>string product = 2 [(.google.api.field - + @@ -4743,7 +5943,7 @@ Generated from protobuf field <code>repeated int32 pages = 4;</code> - + @@ -5059,7 +6259,7 @@ empty if the `error` field is set. - + @@ -5318,7 +6518,7 @@ image, with user-requested features, and with context information. - + @@ -6299,7 +7499,7 @@ comes from. - + @@ -6630,7 +7830,7 @@ comes from. - + @@ -6764,13 +7964,13 @@ comes from. - + - + @@ -6835,17 +8035,46 @@ Generated from protobuf field <code>string parent = 4;</code> - + + build + \Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest::build() + + + requests + + \Google\Cloud\Vision\V1\AsyncAnnotateFileRequest[] + + + + + + + + + + + + + __construct \Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest::__construct() - + data NULL array - + Constructor. - + getRequests \Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest::getRequests() - + Required. Individual async file annotation requests for this batch. Generated from protobuf field <code>repeated .google.cloud.vision.v1.AsyncAnnotateFileRequest requests = 1 [(.google.api.field_behavior) = REQUIRED];</code> - + setRequests \Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest::setRequests() - + var \Google\Cloud\Vision\V1\AsyncAnnotateFileRequest[]|\Google\Protobuf\Internal\RepeatedField - + Required. Individual async file annotation requests for this batch. Generated from protobuf field <code>repeated .google.cloud.vision.v1.AsyncAnnotateFileRequest requests = 1 [(.google.api.field_behavior) = REQUIRED];</code> - + getParent \Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest::getParent() - + Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. @@ -6919,17 +8148,17 @@ Generated from protobuf field <code>string parent = 4;</code> - + setParent \Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest::setParent() - + var string - + Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. @@ -6952,7 +8181,7 @@ Generated from protobuf field <code>string parent = 4;</code> - + @@ -7067,13 +8296,13 @@ AsyncBatchAnnotateFilesRequest. - + - + @@ -7148,17 +8377,56 @@ Generated from protobuf field <code>string parent = 4;</code> - + + build + \Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest::build() + + + requests + + \Google\Cloud\Vision\V1\AnnotateImageRequest[] + + + + outputConfig + + \Google\Cloud\Vision\V1\OutputConfig + + + + + + + + + + + + + + __construct \Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest::__construct() - + data NULL array - + Constructor. - + getRequests \Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest::getRequests() - + Required. Individual image annotation requests for this batch. Generated from protobuf field <code>repeated .google.cloud.vision.v1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED];</code> - + setRequests \Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest::setRequests() - + var \Google\Cloud\Vision\V1\AnnotateImageRequest[]|\Google\Protobuf\Internal\RepeatedField - + Required. Individual image annotation requests for this batch. Generated from protobuf field <code>repeated .google.cloud.vision.v1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED];</code> - + getOutputConfig \Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest::getOutputConfig() - + Required. The desired output location and metadata (e.g. format). Generated from protobuf field <code>.google.cloud.vision.v1.OutputConfig output_config = 2 [(.google.api.field_behavior) = REQUIRED];</code> - + hasOutputConfig \Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest::hasOutputConfig() - + - + clearOutputConfig \Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest::clearOutputConfig() - + - + setOutputConfig \Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest::setOutputConfig() - + var \Google\Cloud\Vision\V1\OutputConfig - + Required. The desired output location and metadata (e.g. format). Generated from protobuf field <code>.google.cloud.vision.v1.OutputConfig output_config = 2 [(.google.api.field_behavior) = REQUIRED];</code> - + getParent \Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest::getParent() - + Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. @@ -7294,17 +8562,17 @@ Generated from protobuf field <code>string parent = 4;</code> - + setParent \Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest::setParent() - + var string - + Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. @@ -7327,7 +8595,7 @@ Generated from protobuf field <code>string parent = 4;</code> - + @@ -7461,13 +8729,13 @@ Generated from protobuf field <code>string parent = 4;</code> - + - + @@ -7532,17 +8800,46 @@ Generated from protobuf field <code>string parent = 3;</code> - + + build + \Google\Cloud\Vision\V1\BatchAnnotateFilesRequest::build() + + + requests + + \Google\Cloud\Vision\V1\AnnotateFileRequest[] + + + + + + + + + + + + + __construct \Google\Cloud\Vision\V1\BatchAnnotateFilesRequest::__construct() - + data NULL array - + Constructor. - + getRequests \Google\Cloud\Vision\V1\BatchAnnotateFilesRequest::getRequests() - + Required. The list of file annotation requests. Right now we support only one AnnotateFileRequest in BatchAnnotateFilesRequest. Generated from protobuf field <code>repeated .google.cloud.vision.v1.AnnotateFileRequest requests = 1 [(.google.api.field_behavior) = REQUIRED];</code> @@ -7569,17 +8866,17 @@ AnnotateFileRequest in BatchAnnotateFilesRequest. - + setRequests \Google\Cloud\Vision\V1\BatchAnnotateFilesRequest::setRequests() - + var \Google\Cloud\Vision\V1\AnnotateFileRequest[]|\Google\Protobuf\Internal\RepeatedField - + Required. The list of file annotation requests. Right now we support only one AnnotateFileRequest in BatchAnnotateFilesRequest. Generated from protobuf field <code>repeated .google.cloud.vision.v1.AnnotateFileRequest requests = 1 [(.google.api.field_behavior) = REQUIRED];</code> @@ -7595,11 +8892,11 @@ AnnotateFileRequest in BatchAnnotateFilesRequest. - + getParent \Google\Cloud\Vision\V1\BatchAnnotateFilesRequest::getParent() - + Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. @@ -7618,17 +8915,17 @@ Generated from protobuf field <code>string parent = 3;</code> - + setParent \Google\Cloud\Vision\V1\BatchAnnotateFilesRequest::setParent() - + var string - + Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. @@ -7651,7 +8948,7 @@ Generated from protobuf field <code>string parent = 3;</code> - + @@ -7766,13 +9063,13 @@ AnnotateFileRequest in BatchAnnotateFilesRequest. - + - + @@ -7836,17 +9133,46 @@ Generated from protobuf field <code>string parent = 4;</code> - + + build + \Google\Cloud\Vision\V1\BatchAnnotateImagesRequest::build() + + + requests + + \Google\Cloud\Vision\V1\AnnotateImageRequest[] + + + + + + + + + + + + + __construct \Google\Cloud\Vision\V1\BatchAnnotateImagesRequest::__construct() - + data NULL array - + Constructor. - + getRequests \Google\Cloud\Vision\V1\BatchAnnotateImagesRequest::getRequests() - + Required. Individual image annotation requests for this batch. Generated from protobuf field <code>repeated .google.cloud.vision.v1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED];</code> - + setRequests \Google\Cloud\Vision\V1\BatchAnnotateImagesRequest::setRequests() - + var \Google\Cloud\Vision\V1\AnnotateImageRequest[]|\Google\Protobuf\Internal\RepeatedField - + Required. Individual image annotation requests for this batch. Generated from protobuf field <code>repeated .google.cloud.vision.v1.AnnotateImageRequest requests = 1 [(.google.api.field_behavior) = REQUIRED];</code> - + getParent \Google\Cloud\Vision\V1\BatchAnnotateImagesRequest::getParent() - + Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. @@ -7920,17 +9246,17 @@ Generated from protobuf field <code>string parent = 4;</code> - + setParent \Google\Cloud\Vision\V1\BatchAnnotateImagesRequest::setParent() - + var string - + Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. @@ -7953,7 +9279,7 @@ Generated from protobuf field <code>string parent = 4;</code> - + @@ -8065,7 +9391,7 @@ Generated from protobuf field <code>string parent = 4;</code> - + @@ -8208,7 +9534,7 @@ cancel command are output as specified in the request. - + @@ -8472,7 +9798,7 @@ Generated from protobuf message <code>google.cloud.vision.v1.BatchOperatio - + @@ -8516,7 +9842,7 @@ Generated from protobuf message <code>google.cloud.vision.v1.BatchOperatio - + @@ -8667,7 +9993,7 @@ Generated from protobuf message <code>google.cloud.vision.v1.BatchOperatio - + @@ -9072,7 +10398,7 @@ Generated from protobuf field <code>.google.cloud.vision.v1.BoundingPoly b - + @@ -9116,7 +10442,7 @@ Generated from protobuf field <code>.google.cloud.vision.v1.BoundingPoly b - + @@ -9279,13 +10605,13 @@ Generated from protobuf field <code>.google.cloud.vision.v1.BoundingPoly b - + - + @@ -9297,238 +10623,2794 @@ Generated from protobuf field <code>.google.cloud.vision.v1.BoundingPoly b - + - - ColorInfo - \Google\Cloud\Vision\V1\ColorInfo - - Color information consists of RGB channels, score, and the fraction of -the image that the color occupies in the image. - Generated from protobuf message <code>google.cloud.vision.v1.ColorInfo</code> + + ImageAnnotatorClient + \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient + + Service Description: Service that performs Google Cloud Vision API detection tasks over client +images, such as face, landmark, logo, label, and text detection. The +ImageAnnotator service returns detected entities from the images. + This class provides the ability to make remote calls to the backing service through method +calls that map to API methods. + +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. + +This class is currently experimental and may be subject to changes. See {@see \Google\Cloud\Vision\V1\ImageAnnotatorClient} for the stable implementation + + + + + - \Google\Protobuf\Internal\Message - - - color - \Google\Cloud\Vision\V1\ColorInfo::$color - null - - RGB components of the color. - Generated from protobuf field <code>.google.type.Color color = 1;</code> + + + SERVICE_NAME + \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::SERVICE_NAME + 'google.cloud.vision.v1.ImageAnnotator' + + The name of the service. + - + - - score - \Google\Cloud\Vision\V1\ColorInfo::$score - 0.0 - - Image-specific score for this color. Value in range [0, 1]. - Generated from protobuf field <code>float score = 2;</code> + + SERVICE_ADDRESS + \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::SERVICE_ADDRESS + 'vision.googleapis.com' + + The default address of the service. + - - - - pixel_fraction - \Google\Cloud\Vision\V1\ColorInfo::$pixel_fraction - 0.0 - - The fraction of pixels the color occupies in the image. - Value in range [0, 1]. + -Generated from protobuf field <code>float pixel_fraction = 3;</code> + + DEFAULT_SERVICE_PORT + \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::DEFAULT_SERVICE_PORT + 443 + + The default port of the service. + - - - - - __construct - \Google\Cloud\Vision\V1\ColorInfo::__construct() - - - data - NULL - array - + - - Constructor. + + CODEGEN_NAME + \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::CODEGEN_NAME + 'gapic' + + The name of the code generator, to be included in the agent header. - - + - + - - getColor - \Google\Cloud\Vision\V1\ColorInfo::getColor() - - - RGB components of the color. - Generated from protobuf field <code>.google.type.Color color = 1;</code> - - + + + serviceScopes + \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::$serviceScopes + ['https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/cloud-vision'] + + The default scopes required by the service. + + - + - - hasColor - \Google\Cloud\Vision\V1\ColorInfo::hasColor() - - + + operationsClient + \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::$operationsClient + + - + - + - - clearColor - \Google\Cloud\Vision\V1\ColorInfo::clearColor() + + + getClientDefaults + \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::getClientDefaults() - + - - setColor - \Google\Cloud\Vision\V1\ColorInfo::setColor() - - - var - - \Google\Type\Color - - - - RGB components of the color. - Generated from protobuf field <code>.google.type.Color color = 1;</code> - - - - - - - - getScore - \Google\Cloud\Vision\V1\ColorInfo::getScore() + + getOperationsClient + \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::getOperationsClient() - - Image-specific score for this color. Value in range [0, 1]. - Generated from protobuf field <code>float score = 2;</code> + + Return an OperationsClient object with the same endpoint as $this. + + type="\Google\ApiCore\LongRunning\OperationsClient"/> - - setScore - \Google\Cloud\Vision\V1\ColorInfo::setScore() + + resumeOperation + \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::resumeOperation() - - var + + operationName - float + string - - Image-specific score for this color. Value in range [0, 1]. - Generated from protobuf field <code>float score = 2;</code> + + methodName + null + string + + + + Resume an existing long running operation that was previously started by a long +running API method. If $methodName is not provided, or does not match a long +running API method, then the operation can still be resumed, but the +OperationResponse object will not deserialize the final response. + + description="The name of the long running operation" + variable="operationName" type="string"/> + + type="\Google\ApiCore\OperationResponse"/> - - getPixelFraction - \Google\Cloud\Vision\V1\ColorInfo::getPixelFraction() + + productSetName + \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::productSetName() - - The fraction of pixels the color occupies in the image. - Value in range [0, 1]. - -Generated from protobuf field <code>float pixel_fraction = 3;</code> - - - - + + project + + string + - - setPixelFraction - \Google\Cloud\Vision\V1\ColorInfo::setPixelFraction() - - - var + + location - float + string - - The fraction of pixels the color occupies in the image. - Value in range [0, 1]. + + productSet + + string + -Generated from protobuf field <code>float pixel_fraction = 3;</code> + + Formats a string containing the fully-qualified path to represent a product_set +resource. + + variable="project" type="string"/> + + + description="The formatted product_set resource." + type="string"/> - - - - - + + parseName + \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::parseName() + + + formattedName + + string + + + + template + null + string + + + + Parses a formatted name string and returns an associative array of the components in the name. + The following name formats are supported: +Template: Pattern +- productSet: projects/{project}/locations/{location}/productSets/{product_set} + +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. + + + + + + + + + + __construct + \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::__construct() + + + options + [] + array + + + + Constructor. + + + + + + + + + __call + \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::__call() + + + method + + mixed + + + + args + + mixed + + + + Handles execution of the async variants for each documented method. + + + + + + + asyncBatchAnnotateFiles + \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::asyncBatchAnnotateFiles() + + + request + + \Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest + + + + callOptions + [] + array + + + + Run asynchronous image detection and annotation for a list of generic +files, such as PDF files, which may contain multiple pages and multiple +images per page. Progress and results can be retrieved through the +`google.longrunning.Operations` interface. + `Operation.metadata` contains `OperationMetadata` (metadata). +`Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results). + +The async variant is {@see \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::asyncBatchAnnotateFilesAsync()} +. + + + + + + + + + + asyncBatchAnnotateImages + \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::asyncBatchAnnotateImages() + + + request + + \Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest + + + + callOptions + [] + array + + + + Run asynchronous image detection and annotation for a list of images. + Progress and results can be retrieved through the +`google.longrunning.Operations` interface. +`Operation.metadata` contains `OperationMetadata` (metadata). +`Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). + +This service will write image annotation outputs to json files in customer +GCS bucket, each json file containing BatchAnnotateImagesResponse proto. + +The async variant is +{@see \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::asyncBatchAnnotateImagesAsync()} . + + + + + + + + + + batchAnnotateFiles + \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::batchAnnotateFiles() + + + request + + \Google\Cloud\Vision\V1\BatchAnnotateFilesRequest + + + + callOptions + [] + array + + + + Service that performs image detection and annotation for a batch of files. + Now only "application/pdf", "image/tiff" and "image/gif" are supported. + +This service will extract at most 5 (customers can specify which 5 in +AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each +file provided and perform detection and annotation for each image +extracted. + +The async variant is {@see \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::batchAnnotateFilesAsync()} . + + + + + + + + + + batchAnnotateImages + \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::batchAnnotateImages() + + + request + + \Google\Cloud\Vision\V1\BatchAnnotateImagesRequest + + + + callOptions + [] + array + + + + Run image detection and annotation for a batch of images. + The async variant is {@see \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::batchAnnotateImagesAsync()} . + + + + + + + + + + asyncBatchAnnotateFilesAsync + \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::asyncBatchAnnotateFilesAsync() + + + request + + \Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + asyncBatchAnnotateImagesAsync + \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::asyncBatchAnnotateImagesAsync() + + + request + + \Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + batchAnnotateFilesAsync + \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::batchAnnotateFilesAsync() + + + request + + \Google\Cloud\Vision\V1\BatchAnnotateFilesRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + batchAnnotateImagesAsync + \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient::batchAnnotateImagesAsync() + + + request + + \Google\Cloud\Vision\V1\BatchAnnotateImagesRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ProductSearchClient + \Google\Cloud\Vision\V1\Client\ProductSearchClient + + Service Description: Manages Products and ProductSets of reference images for use in product +search. It uses the following resource model: + - The API has a collection of [ProductSet][google.cloud.vision.v1.ProductSet] resources, named +`projects/&#42;/locations/&#42;/productSets/*`, which acts as a way to put different +products into groups to limit identification. + +In parallel, + +- The API has a collection of [Product][google.cloud.vision.v1.Product] resources, named +`projects/&#42;/locations/&#42;/products/*` + +- Each [Product][google.cloud.vision.v1.Product] has a collection of [ReferenceImage][google.cloud.vision.v1.ReferenceImage] resources, named +`projects/&#42;/locations/&#42;/products/&#42;/referenceImages/*` + +This class provides the ability to make remote calls to the backing service through method +calls that map to API methods. + +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. + +This class is currently experimental and may be subject to changes. See {@see \Google\Cloud\Vision\V1\ProductSearchClient} for the stable implementation + + + + + + + + + + + + + + + + + + + + + + + + + + + SERVICE_NAME + \Google\Cloud\Vision\V1\Client\ProductSearchClient::SERVICE_NAME + 'google.cloud.vision.v1.ProductSearch' + + The name of the service. + + + + + + + SERVICE_ADDRESS + \Google\Cloud\Vision\V1\Client\ProductSearchClient::SERVICE_ADDRESS + 'vision.googleapis.com' + + The default address of the service. + + + + + + + DEFAULT_SERVICE_PORT + \Google\Cloud\Vision\V1\Client\ProductSearchClient::DEFAULT_SERVICE_PORT + 443 + + The default port of the service. + + + + + + + CODEGEN_NAME + \Google\Cloud\Vision\V1\Client\ProductSearchClient::CODEGEN_NAME + 'gapic' + + The name of the code generator, to be included in the agent header. + + + + + + + + serviceScopes + \Google\Cloud\Vision\V1\Client\ProductSearchClient::$serviceScopes + ['https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/cloud-vision'] + + The default scopes required by the service. + + + + + + + operationsClient + \Google\Cloud\Vision\V1\Client\ProductSearchClient::$operationsClient + + + + + + + + + + + getClientDefaults + \Google\Cloud\Vision\V1\Client\ProductSearchClient::getClientDefaults() + + + + + + + + + + getOperationsClient + \Google\Cloud\Vision\V1\Client\ProductSearchClient::getOperationsClient() + + + Return an OperationsClient object with the same endpoint as $this. + + + + + + + + resumeOperation + \Google\Cloud\Vision\V1\Client\ProductSearchClient::resumeOperation() + + + operationName + + string + + + + methodName + null + string + + + + Resume an existing long running operation that was previously started by a long +running API method. If $methodName is not provided, or does not match a long +running API method, then the operation can still be resumed, but the +OperationResponse object will not deserialize the final response. + + + + + + + + + + locationName + \Google\Cloud\Vision\V1\Client\ProductSearchClient::locationName() + + + project + + string + + + + location + + string + + + + Formats a string containing the fully-qualified path to represent a location +resource. + + + + + + + + + + productName + \Google\Cloud\Vision\V1\Client\ProductSearchClient::productName() + + + project + + string + + + + location + + string + + + + product + + string + + + + Formats a string containing the fully-qualified path to represent a product +resource. + + + + + + + + + + + productSetName + \Google\Cloud\Vision\V1\Client\ProductSearchClient::productSetName() + + + project + + string + + + + location + + string + + + + productSet + + string + + + + Formats a string containing the fully-qualified path to represent a product_set +resource. + + + + + + + + + + + referenceImageName + \Google\Cloud\Vision\V1\Client\ProductSearchClient::referenceImageName() + + + project + + string + + + + location + + string + + + + product + + string + + + + referenceImage + + string + + + + Formats a string containing the fully-qualified path to represent a +reference_image resource. + + + + + + + + + + + + parseName + \Google\Cloud\Vision\V1\Client\ProductSearchClient::parseName() + + + formattedName + + string + + + + template + null + string + + + + Parses a formatted name string and returns an associative array of the components in the name. + The following name formats are supported: +Template: Pattern +- location: projects/{project}/locations/{location} +- product: projects/{project}/locations/{location}/products/{product} +- productSet: projects/{project}/locations/{location}/productSets/{product_set} +- referenceImage: projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image} + +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. + + + + + + + + + + __construct + \Google\Cloud\Vision\V1\Client\ProductSearchClient::__construct() + + + options + [] + array + + + + Constructor. + + + + + + + + + __call + \Google\Cloud\Vision\V1\Client\ProductSearchClient::__call() + + + method + + mixed + + + + args + + mixed + + + + Handles execution of the async variants for each documented method. + + + + + + + addProductToProductSet + \Google\Cloud\Vision\V1\Client\ProductSearchClient::addProductToProductSet() + + + request + + \Google\Cloud\Vision\V1\AddProductToProductSetRequest + + + + callOptions + [] + array + + + + Adds a Product to the specified ProductSet. If the Product is already +present, no change is made. + One Product can be added to at most 100 ProductSets. + +Possible errors: + +* Returns NOT_FOUND if the Product or the ProductSet doesn't exist. + +The async variant is {@see \Google\Cloud\Vision\V1\Client\ProductSearchClient::addProductToProductSetAsync()} . + + + + + + + + + createProduct + \Google\Cloud\Vision\V1\Client\ProductSearchClient::createProduct() + + + request + + \Google\Cloud\Vision\V1\CreateProductRequest + + + + callOptions + [] + array + + + + Creates and returns a new product resource. + Possible errors: + +* Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 +characters. +* Returns INVALID_ARGUMENT if description is longer than 4096 characters. +* Returns INVALID_ARGUMENT if product_category is missing or invalid. + +The async variant is {@see \Google\Cloud\Vision\V1\Client\ProductSearchClient::createProductAsync()} . + + + + + + + + + + createProductSet + \Google\Cloud\Vision\V1\Client\ProductSearchClient::createProductSet() + + + request + + \Google\Cloud\Vision\V1\CreateProductSetRequest + + + + callOptions + [] + array + + + + Creates and returns a new ProductSet resource. + Possible errors: + +* Returns INVALID_ARGUMENT if display_name is missing, or is longer than +4096 characters. + +The async variant is {@see \Google\Cloud\Vision\V1\Client\ProductSearchClient::createProductSetAsync()} . + + + + + + + + + + createReferenceImage + \Google\Cloud\Vision\V1\Client\ProductSearchClient::createReferenceImage() + + + request + + \Google\Cloud\Vision\V1\CreateReferenceImageRequest + + + + callOptions + [] + array + + + + Creates and returns a new ReferenceImage resource. + The `bounding_poly` field is optional. If `bounding_poly` is not specified, +the system will try to detect regions of interest in the image that are +compatible with the product_category on the parent product. If it is +specified, detection is ALWAYS skipped. The system converts polygons into +non-rotated rectangles. + +Note that the pipeline will resize the image if the image resolution is too +large to process (above 50MP). + +Possible errors: + +* Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 +characters. +* Returns INVALID_ARGUMENT if the product does not exist. +* Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing +compatible with the parent product's product_category is detected. +* Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons. + +The async variant is {@see \Google\Cloud\Vision\V1\Client\ProductSearchClient::createReferenceImageAsync()} . + + + + + + + + + + deleteProduct + \Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteProduct() + + + request + + \Google\Cloud\Vision\V1\DeleteProductRequest + + + + callOptions + [] + array + + + + Permanently deletes a product and its reference images. + Metadata of the product and all its images will be deleted right away, but +search queries against ProductSets containing the product may still work +until all related caches are refreshed. + +The async variant is {@see \Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteProductAsync()} . + + + + + + + + + deleteProductSet + \Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteProductSet() + + + request + + \Google\Cloud\Vision\V1\DeleteProductSetRequest + + + + callOptions + [] + array + + + + Permanently deletes a ProductSet. Products and ReferenceImages in the +ProductSet are not deleted. + The actual image files are not deleted from Google Cloud Storage. + +The async variant is {@see \Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteProductSetAsync()} . + + + + + + + + + deleteReferenceImage + \Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteReferenceImage() + + + request + + \Google\Cloud\Vision\V1\DeleteReferenceImageRequest + + + + callOptions + [] + array + + + + Permanently deletes a reference image. + The image metadata will be deleted right away, but search queries +against ProductSets containing the image may still work until all related +caches are refreshed. + +The actual image files are not deleted from Google Cloud Storage. + +The async variant is {@see \Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteReferenceImageAsync()} . + + + + + + + + + getProduct + \Google\Cloud\Vision\V1\Client\ProductSearchClient::getProduct() + + + request + + \Google\Cloud\Vision\V1\GetProductRequest + + + + callOptions + [] + array + + + + Gets information associated with a Product. + Possible errors: + +* Returns NOT_FOUND if the Product does not exist. + +The async variant is {@see \Google\Cloud\Vision\V1\Client\ProductSearchClient::getProductAsync()} . + + + + + + + + + + getProductSet + \Google\Cloud\Vision\V1\Client\ProductSearchClient::getProductSet() + + + request + + \Google\Cloud\Vision\V1\GetProductSetRequest + + + + callOptions + [] + array + + + + Gets information associated with a ProductSet. + Possible errors: + +* Returns NOT_FOUND if the ProductSet does not exist. + +The async variant is {@see \Google\Cloud\Vision\V1\Client\ProductSearchClient::getProductSetAsync()} . + + + + + + + + + + getReferenceImage + \Google\Cloud\Vision\V1\Client\ProductSearchClient::getReferenceImage() + + + request + + \Google\Cloud\Vision\V1\GetReferenceImageRequest + + + + callOptions + [] + array + + + + Gets information associated with a ReferenceImage. + Possible errors: + +* Returns NOT_FOUND if the specified image does not exist. + +The async variant is {@see \Google\Cloud\Vision\V1\Client\ProductSearchClient::getReferenceImageAsync()} . + + + + + + + + + + importProductSets + \Google\Cloud\Vision\V1\Client\ProductSearchClient::importProductSets() + + + request + + \Google\Cloud\Vision\V1\ImportProductSetsRequest + + + + callOptions + [] + array + + + + Asynchronous API that imports a list of reference images to specified +product sets based on a list of image information. + The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the +progress and results of the request. +`Operation.metadata` contains `BatchOperationMetadata`. (progress) +`Operation.response` contains `ImportProductSetsResponse`. (results) + +The input source of this method is a csv file on Google Cloud Storage. +For the format of the csv file please see +[ImportProductSetsGcsSource.csv_file_uri][google.cloud.vision.v1.ImportProductSetsGcsSource.csv_file_uri]. + +The async variant is {@see \Google\Cloud\Vision\V1\Client\ProductSearchClient::importProductSetsAsync()} . + + + + + + + + + + listProductSets + \Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductSets() + + + request + + \Google\Cloud\Vision\V1\ListProductSetsRequest + + + + callOptions + [] + array + + + + Lists ProductSets in an unspecified order. + Possible errors: + +* Returns INVALID_ARGUMENT if page_size is greater than 100, or less +than 1. + +The async variant is {@see \Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductSetsAsync()} . + + + + + + + + + + listProducts + \Google\Cloud\Vision\V1\Client\ProductSearchClient::listProducts() + + + request + + \Google\Cloud\Vision\V1\ListProductsRequest + + + + callOptions + [] + array + + + + Lists products in an unspecified order. + Possible errors: + +* Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + +The async variant is {@see \Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductsAsync()} . + + + + + + + + + + listProductsInProductSet + \Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductsInProductSet() + + + request + + \Google\Cloud\Vision\V1\ListProductsInProductSetRequest + + + + callOptions + [] + array + + + + Lists the Products in a ProductSet, in an unspecified order. If the +ProductSet does not exist, the products field of the response will be +empty. + Possible errors: + +* Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1. + +The async variant is {@see \Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductsInProductSetAsync()} +. + + + + + + + + + + listReferenceImages + \Google\Cloud\Vision\V1\Client\ProductSearchClient::listReferenceImages() + + + request + + \Google\Cloud\Vision\V1\ListReferenceImagesRequest + + + + callOptions + [] + array + + + + Lists reference images. + Possible errors: + +* Returns NOT_FOUND if the parent product does not exist. +* Returns INVALID_ARGUMENT if the page_size is greater than 100, or less +than 1. + +The async variant is {@see \Google\Cloud\Vision\V1\Client\ProductSearchClient::listReferenceImagesAsync()} . + + + + + + + + + + purgeProducts + \Google\Cloud\Vision\V1\Client\ProductSearchClient::purgeProducts() + + + request + + \Google\Cloud\Vision\V1\PurgeProductsRequest + + + + callOptions + [] + array + + + + Asynchronous API to delete all Products in a ProductSet or all Products +that are in no ProductSet. + If a Product is a member of the specified ProductSet in addition to other +ProductSets, the Product will still be deleted. + +It is recommended to not delete the specified ProductSet until after this +operation has completed. It is also recommended to not add any of the +Products involved in the batch delete to a new ProductSet while this +operation is running because those Products may still end up deleted. + +It's not possible to undo the PurgeProducts operation. Therefore, it is +recommended to keep the csv files used in ImportProductSets (if that was +how you originally built the Product Set) before starting PurgeProducts, in +case you need to re-import the data after deletion. + +If the plan is to purge all of the Products from a ProductSet and then +re-use the empty ProductSet to re-import new Products into the empty +ProductSet, you must wait until the PurgeProducts operation has finished +for that ProductSet. + +The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the +progress and results of the request. +`Operation.metadata` contains `BatchOperationMetadata`. (progress) + +The async variant is {@see \Google\Cloud\Vision\V1\Client\ProductSearchClient::purgeProductsAsync()} . + + + + + + + + + + removeProductFromProductSet + \Google\Cloud\Vision\V1\Client\ProductSearchClient::removeProductFromProductSet() + + + request + + \Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest + + + + callOptions + [] + array + + + + Removes a Product from the specified ProductSet. + The async variant is +{@see \Google\Cloud\Vision\V1\Client\ProductSearchClient::removeProductFromProductSetAsync()} . + + + + + + + + + updateProduct + \Google\Cloud\Vision\V1\Client\ProductSearchClient::updateProduct() + + + request + + \Google\Cloud\Vision\V1\UpdateProductRequest + + + + callOptions + [] + array + + + + Makes changes to a Product resource. + Only the `display_name`, `description`, and `labels` fields can be updated +right now. + +If labels are updated, the change will not be reflected in queries until +the next index time. + +Possible errors: + +* Returns NOT_FOUND if the Product does not exist. +* Returns INVALID_ARGUMENT if display_name is present in update_mask but is +missing from the request or longer than 4096 characters. +* Returns INVALID_ARGUMENT if description is present in update_mask but is +longer than 4096 characters. +* Returns INVALID_ARGUMENT if product_category is present in update_mask. + +The async variant is {@see \Google\Cloud\Vision\V1\Client\ProductSearchClient::updateProductAsync()} . + + + + + + + + + + updateProductSet + \Google\Cloud\Vision\V1\Client\ProductSearchClient::updateProductSet() + + + request + + \Google\Cloud\Vision\V1\UpdateProductSetRequest + + + + callOptions + [] + array + + + + Makes changes to a ProductSet resource. + Only display_name can be updated currently. + +Possible errors: + +* Returns NOT_FOUND if the ProductSet does not exist. +* Returns INVALID_ARGUMENT if display_name is present in update_mask but +missing from the request or longer than 4096 characters. + +The async variant is {@see \Google\Cloud\Vision\V1\Client\ProductSearchClient::updateProductSetAsync()} . + + + + + + + + + + addProductToProductSetAsync + \Google\Cloud\Vision\V1\Client\ProductSearchClient::addProductToProductSetAsync() + + + request + + \Google\Cloud\Vision\V1\AddProductToProductSetRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + createProductAsync + \Google\Cloud\Vision\V1\Client\ProductSearchClient::createProductAsync() + + + request + + \Google\Cloud\Vision\V1\CreateProductRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + createProductSetAsync + \Google\Cloud\Vision\V1\Client\ProductSearchClient::createProductSetAsync() + + + request + + \Google\Cloud\Vision\V1\CreateProductSetRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + createReferenceImageAsync + \Google\Cloud\Vision\V1\Client\ProductSearchClient::createReferenceImageAsync() + + + request + + \Google\Cloud\Vision\V1\CreateReferenceImageRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + deleteProductAsync + \Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteProductAsync() + + + request + + \Google\Cloud\Vision\V1\DeleteProductRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + deleteProductSetAsync + \Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteProductSetAsync() + + + request + + \Google\Cloud\Vision\V1\DeleteProductSetRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + deleteReferenceImageAsync + \Google\Cloud\Vision\V1\Client\ProductSearchClient::deleteReferenceImageAsync() + + + request + + \Google\Cloud\Vision\V1\DeleteReferenceImageRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + getProductAsync + \Google\Cloud\Vision\V1\Client\ProductSearchClient::getProductAsync() + + + request + + \Google\Cloud\Vision\V1\GetProductRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + getProductSetAsync + \Google\Cloud\Vision\V1\Client\ProductSearchClient::getProductSetAsync() + + + request + + \Google\Cloud\Vision\V1\GetProductSetRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + getReferenceImageAsync + \Google\Cloud\Vision\V1\Client\ProductSearchClient::getReferenceImageAsync() + + + request + + \Google\Cloud\Vision\V1\GetReferenceImageRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + importProductSetsAsync + \Google\Cloud\Vision\V1\Client\ProductSearchClient::importProductSetsAsync() + + + request + + \Google\Cloud\Vision\V1\ImportProductSetsRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + listProductSetsAsync + \Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductSetsAsync() + + + request + + \Google\Cloud\Vision\V1\ListProductSetsRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + listProductsAsync + \Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductsAsync() + + + request + + \Google\Cloud\Vision\V1\ListProductsRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + listProductsInProductSetAsync + \Google\Cloud\Vision\V1\Client\ProductSearchClient::listProductsInProductSetAsync() + + + request + + \Google\Cloud\Vision\V1\ListProductsInProductSetRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + listReferenceImagesAsync + \Google\Cloud\Vision\V1\Client\ProductSearchClient::listReferenceImagesAsync() + + + request + + \Google\Cloud\Vision\V1\ListReferenceImagesRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + purgeProductsAsync + \Google\Cloud\Vision\V1\Client\ProductSearchClient::purgeProductsAsync() + + + request + + \Google\Cloud\Vision\V1\PurgeProductsRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + removeProductFromProductSetAsync + \Google\Cloud\Vision\V1\Client\ProductSearchClient::removeProductFromProductSetAsync() + + + request + + \Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + updateProductAsync + \Google\Cloud\Vision\V1\Client\ProductSearchClient::updateProductAsync() + + + request + + \Google\Cloud\Vision\V1\UpdateProductRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + updateProductSetAsync + \Google\Cloud\Vision\V1\Client\ProductSearchClient::updateProductSetAsync() + + + request + + \Google\Cloud\Vision\V1\UpdateProductSetRequest + + + + optionalArgs = [] + + array + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ColorInfo + \Google\Cloud\Vision\V1\ColorInfo + + Color information consists of RGB channels, score, and the fraction of +the image that the color occupies in the image. + Generated from protobuf message <code>google.cloud.vision.v1.ColorInfo</code> + + + + \Google\Protobuf\Internal\Message + + + + color + \Google\Cloud\Vision\V1\ColorInfo::$color + null + + RGB components of the color. + Generated from protobuf field <code>.google.type.Color color = 1;</code> + + + + + + score + \Google\Cloud\Vision\V1\ColorInfo::$score + 0.0 + + Image-specific score for this color. Value in range [0, 1]. + Generated from protobuf field <code>float score = 2;</code> + + + + + + pixel_fraction + \Google\Cloud\Vision\V1\ColorInfo::$pixel_fraction + 0.0 + + The fraction of pixels the color occupies in the image. + Value in range [0, 1]. + +Generated from protobuf field <code>float pixel_fraction = 3;</code> + + + + + + + __construct + \Google\Cloud\Vision\V1\ColorInfo::__construct() + + + data + NULL + array + + + + Constructor. + + + + + + + + getColor + \Google\Cloud\Vision\V1\ColorInfo::getColor() + + + RGB components of the color. + Generated from protobuf field <code>.google.type.Color color = 1;</code> + + + + + + + hasColor + \Google\Cloud\Vision\V1\ColorInfo::hasColor() + + + + + + + + + + clearColor + \Google\Cloud\Vision\V1\ColorInfo::clearColor() + + + + + + + + + + setColor + \Google\Cloud\Vision\V1\ColorInfo::setColor() + + + var + + \Google\Type\Color + + + + RGB components of the color. + Generated from protobuf field <code>.google.type.Color color = 1;</code> + + + + + + + + getScore + \Google\Cloud\Vision\V1\ColorInfo::getScore() + + + Image-specific score for this color. Value in range [0, 1]. + Generated from protobuf field <code>float score = 2;</code> + + + + + + + setScore + \Google\Cloud\Vision\V1\ColorInfo::setScore() + + + var + + float + + + + Image-specific score for this color. Value in range [0, 1]. + Generated from protobuf field <code>float score = 2;</code> + + + + + + + + getPixelFraction + \Google\Cloud\Vision\V1\ColorInfo::getPixelFraction() + + + The fraction of pixels the color occupies in the image. + Value in range [0, 1]. + +Generated from protobuf field <code>float pixel_fraction = 3;</code> + + + + + + + setPixelFraction + \Google\Cloud\Vision\V1\ColorInfo::setPixelFraction() + + + var + + float + + + + The fraction of pixels the color occupies in the image. + Value in range [0, 1]. + +Generated from protobuf field <code>float pixel_fraction = 3;</code> + + + + + + + + + + + - + @@ -9601,17 +13483,66 @@ long. It cannot contain the character `/`. - + + build + \Google\Cloud\Vision\V1\CreateProductRequest::build() + + + parent + + string + + + + product + + \Google\Cloud\Vision\V1\Product + + + + productId + + string + + + + + + + + + + + + + + + __construct \Google\Cloud\Vision\V1\CreateProductRequest::__construct() - + data NULL array - + Constructor. - + getParent \Google\Cloud\Vision\V1\CreateProductRequest::getParent() - + Required. The project in which the Product should be created. Format is `projects/PROJECT_ID/locations/LOC_ID`. @@ -9640,17 +13571,17 @@ Generated from protobuf field <code>string parent = 1 [(.google.api.field_ - + setParent \Google\Cloud\Vision\V1\CreateProductRequest::setParent() - + var string - + Required. The project in which the Product should be created. Format is `projects/PROJECT_ID/locations/LOC_ID`. @@ -9668,11 +13599,11 @@ Generated from protobuf field <code>string parent = 1 [(.google.api.field_ - + getProduct \Google\Cloud\Vision\V1\CreateProductRequest::getProduct() - + Required. The product to create. Generated from protobuf field <code>.google.cloud.vision.v1.Product product = 2 [(.google.api.field_behavior) = REQUIRED];</code> - + hasProduct \Google\Cloud\Vision\V1\CreateProductRequest::hasProduct() - + - + clearProduct \Google\Cloud\Vision\V1\CreateProductRequest::clearProduct() - + - + setProduct \Google\Cloud\Vision\V1\CreateProductRequest::setProduct() - + var \Google\Cloud\Vision\V1\Product - + Required. The product to create. Generated from protobuf field <code>.google.cloud.vision.v1.Product product = 2 [(.google.api.field_behavior) = REQUIRED];</code> - + getProductId \Google\Cloud\Vision\V1\CreateProductRequest::getProductId() - + A user-supplied resource id for this Product. If set, the server will attempt to use this value as the resource id. If it is already in use, an error is returned with code ALREADY_EXISTS. Must be at most 128 characters @@ -9748,17 +13679,17 @@ long. It cannot contain the character `/`. - + setProductId \Google\Cloud\Vision\V1\CreateProductRequest::setProductId() - + var string - + A user-supplied resource id for this Product. If set, the server will attempt to use this value as the resource id. If it is already in use, an error is returned with code ALREADY_EXISTS. Must be at most 128 characters @@ -9776,13 +13707,13 @@ long. It cannot contain the character `/`. - + - + @@ -9854,17 +13785,66 @@ long. It cannot contain the character `/`. - + + build + \Google\Cloud\Vision\V1\CreateProductSetRequest::build() + + + parent + + string + + + + productSet + + \Google\Cloud\Vision\V1\ProductSet + + + + productSetId + + string + + + + + + + + + + + + + + + __construct \Google\Cloud\Vision\V1\CreateProductSetRequest::__construct() - + data NULL array - + Constructor. - + getParent \Google\Cloud\Vision\V1\CreateProductSetRequest::getParent() - + Required. The project in which the ProductSet should be created. Format is `projects/PROJECT_ID/locations/LOC_ID`. @@ -9892,17 +13872,17 @@ Generated from protobuf field <code>string parent = 1 [(.google.api.field_ - + setParent \Google\Cloud\Vision\V1\CreateProductSetRequest::setParent() - + var string - + Required. The project in which the ProductSet should be created. Format is `projects/PROJECT_ID/locations/LOC_ID`. @@ -9919,11 +13899,11 @@ Generated from protobuf field <code>string parent = 1 [(.google.api.field_ - + getProductSet \Google\Cloud\Vision\V1\CreateProductSetRequest::getProductSet() - + Required. The ProductSet to create. Generated from protobuf field <code>.google.cloud.vision.v1.ProductSet product_set = 2 [(.google.api.field_behavior) = REQUIRED];</code> - + hasProductSet \Google\Cloud\Vision\V1\CreateProductSetRequest::hasProductSet() - + - + clearProductSet \Google\Cloud\Vision\V1\CreateProductSetRequest::clearProductSet() - + - + setProductSet \Google\Cloud\Vision\V1\CreateProductSetRequest::setProductSet() - + var \Google\Cloud\Vision\V1\ProductSet - + Required. The ProductSet to create. Generated from protobuf field <code>.google.cloud.vision.v1.ProductSet product_set = 2 [(.google.api.field_behavior) = REQUIRED];</code> - + getProductSetId \Google\Cloud\Vision\V1\CreateProductSetRequest::getProductSetId() - + A user-supplied resource id for this ProductSet. If set, the server will attempt to use this value as the resource id. If it is already in use, an error is returned with code ALREADY_EXISTS. Must be at most 128 characters @@ -9999,17 +13979,17 @@ long. It cannot contain the character `/`. - + setProductSetId \Google\Cloud\Vision\V1\CreateProductSetRequest::setProductSetId() - + var string - + A user-supplied resource id for this ProductSet. If set, the server will attempt to use this value as the resource id. If it is already in use, an error is returned with code ALREADY_EXISTS. Must be at most 128 characters @@ -10027,13 +14007,13 @@ long. It cannot contain the character `/`. - + - + @@ -10108,17 +14088,66 @@ most 128 characters long. It cannot contain the character `/`. - + + build + \Google\Cloud\Vision\V1\CreateReferenceImageRequest::build() + + + parent + + string + + + + referenceImage + + \Google\Cloud\Vision\V1\ReferenceImage + + + + referenceImageId + + string + + + + + + + + + + + + + + + __construct \Google\Cloud\Vision\V1\CreateReferenceImageRequest::__construct() - + data NULL array - + Constructor. - + getParent \Google\Cloud\Vision\V1\CreateReferenceImageRequest::getParent() - + Required. Resource name of the product in which to create the reference image. Format is `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. @@ -10147,17 +14176,17 @@ Generated from protobuf field <code>string parent = 1 [(.google.api.field_ - + setParent \Google\Cloud\Vision\V1\CreateReferenceImageRequest::setParent() - + var string - + Required. Resource name of the product in which to create the reference image. Format is `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. @@ -10175,11 +14204,11 @@ Generated from protobuf field <code>string parent = 1 [(.google.api.field_ - + getReferenceImage \Google\Cloud\Vision\V1\CreateReferenceImageRequest::getReferenceImage() - + Required. The reference image to create. If an image ID is specified, it is ignored. @@ -10192,39 +14221,39 @@ Generated from protobuf field <code>.google.cloud.vision.v1.ReferenceImage - + hasReferenceImage \Google\Cloud\Vision\V1\CreateReferenceImageRequest::hasReferenceImage() - + - + clearReferenceImage \Google\Cloud\Vision\V1\CreateReferenceImageRequest::clearReferenceImage() - + - + setReferenceImage \Google\Cloud\Vision\V1\CreateReferenceImageRequest::setReferenceImage() - + var \Google\Cloud\Vision\V1\ReferenceImage - + Required. The reference image to create. If an image ID is specified, it is ignored. @@ -10241,11 +14270,11 @@ Generated from protobuf field <code>.google.cloud.vision.v1.ReferenceImage - + getReferenceImageId \Google\Cloud\Vision\V1\CreateReferenceImageRequest::getReferenceImageId() - + A user-supplied resource id for the ReferenceImage to be added. If set, the server will attempt to use this value as the resource id. If it is already in use, an error is returned with code ALREADY_EXISTS. Must be at @@ -10259,17 +14288,17 @@ most 128 characters long. It cannot contain the character `/`. - + setReferenceImageId \Google\Cloud\Vision\V1\CreateReferenceImageRequest::setReferenceImageId() - + var string - + A user-supplied resource id for the ReferenceImage to be added. If set, the server will attempt to use this value as the resource id. If it is already in use, an error is returned with code ALREADY_EXISTS. Must be at @@ -10287,7 +14316,7 @@ most 128 characters long. It cannot contain the character `/`. - + @@ -10529,7 +14558,7 @@ image. - + @@ -10641,7 +14670,7 @@ image. - + @@ -10768,13 +14797,313 @@ ignored. - + + + + + + + + + + + + + + + + + + + + + + + DeleteProductRequest + \Google\Cloud\Vision\V1\DeleteProductRequest + + Request message for the `DeleteProduct` method. + Generated from protobuf message <code>google.cloud.vision.v1.DeleteProductRequest</code> + + + + \Google\Protobuf\Internal\Message + + + + name + \Google\Cloud\Vision\V1\DeleteProductRequest::$name + '' + + Required. Resource name of product to delete. + Format is: +`projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + +Generated from protobuf field <code>string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {</code> + + + + + + + build + \Google\Cloud\Vision\V1\DeleteProductRequest::build() + + + name + + string + + + + + + + + + + + + + + __construct + \Google\Cloud\Vision\V1\DeleteProductRequest::__construct() + + + data + NULL + array + + + + Constructor. + + + + + + + + getName + \Google\Cloud\Vision\V1\DeleteProductRequest::getName() + + + Required. Resource name of product to delete. + Format is: +`projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + +Generated from protobuf field <code>string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {</code> + + + + + + + setName + \Google\Cloud\Vision\V1\DeleteProductRequest::setName() + + + var + + string + + + + Required. Resource name of product to delete. + Format is: +`projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` + +Generated from protobuf field <code>string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {</code> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DeleteProductSetRequest + \Google\Cloud\Vision\V1\DeleteProductSetRequest + + Request message for the `DeleteProductSet` method. + Generated from protobuf message <code>google.cloud.vision.v1.DeleteProductSetRequest</code> + + + + \Google\Protobuf\Internal\Message + + + + name + \Google\Cloud\Vision\V1\DeleteProductSetRequest::$name + '' + + Required. Resource name of the ProductSet to delete. + Format is: +`projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + +Generated from protobuf field <code>string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {</code> + + + + + + + build + \Google\Cloud\Vision\V1\DeleteProductSetRequest::build() + + + name + + string + + + + + + + + + + + + + + __construct + \Google\Cloud\Vision\V1\DeleteProductSetRequest::__construct() + + + data + NULL + array + + + + Constructor. + + + + + + + + getName + \Google\Cloud\Vision\V1\DeleteProductSetRequest::getName() + + + Required. Resource name of the ProductSet to delete. + Format is: +`projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + +Generated from protobuf field <code>string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {</code> + + + + + + + setName + \Google\Cloud\Vision\V1\DeleteProductSetRequest::setName() + + + var + + string + + + + Required. Resource name of the ProductSet to delete. + Format is: +`projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` + +Generated from protobuf field <code>string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {</code> + + + + + + + - + @@ -10793,11 +15122,11 @@ ignored. - DeleteProductRequest - \Google\Cloud\Vision\V1\DeleteProductRequest + DeleteReferenceImageRequest + \Google\Cloud\Vision\V1\DeleteReferenceImageRequest - Request message for the `DeleteProduct` method. - Generated from protobuf message <code>google.cloud.vision.v1.DeleteProductRequest</code> + Request message for the `DeleteReferenceImage` method. + Generated from protobuf message <code>google.cloud.vision.v1.DeleteReferenceImageRequest</code> \Google\Protobuf\Internal\Message - + name - \Google\Cloud\Vision\V1\DeleteProductRequest::$name + \Google\Cloud\Vision\V1\DeleteReferenceImageRequest::$name '' - Required. Resource name of product to delete. + Required. The resource name of the reference image to delete. Format is: -`projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` +`projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` Generated from protobuf field <code>string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {</code> @@ -10822,259 +15151,46 @@ Generated from protobuf field <code>string name = 1 [(.google.api.field_be - - __construct - \Google\Cloud\Vision\V1\DeleteProductRequest::__construct() - - - data - NULL - array - - - - Constructor. - - - - - - - - getName - \Google\Cloud\Vision\V1\DeleteProductRequest::getName() + + build + \Google\Cloud\Vision\V1\DeleteReferenceImageRequest::build() - - Required. Resource name of product to delete. - Format is: -`projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - -Generated from protobuf field <code>string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {</code> - - - - - - - setName - \Google\Cloud\Vision\V1\DeleteProductRequest::setName() - - - var + + name string - - Required. Resource name of product to delete. - Format is: -`projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` - -Generated from protobuf field <code>string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {</code> - - - - - - - - - - - - - - + - - - - - - - - - - - - - - DeleteProductSetRequest - \Google\Cloud\Vision\V1\DeleteProductSetRequest - - Request message for the `DeleteProductSet` method. - Generated from protobuf message <code>google.cloud.vision.v1.DeleteProductSetRequest</code> - - - - \Google\Protobuf\Internal\Message - - - - name - \Google\Cloud\Vision\V1\DeleteProductSetRequest::$name - '' - - Required. Resource name of the ProductSet to delete. - Format is: -`projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - -Generated from protobuf field <code>string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {</code> - - - - - - - __construct - \Google\Cloud\Vision\V1\DeleteProductSetRequest::__construct() - - - data - NULL - array - - - - Constructor. - - - - - - getName - \Google\Cloud\Vision\V1\DeleteProductSetRequest::getName() - - - Required. Resource name of the ProductSet to delete. - Format is: -`projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - -Generated from protobuf field <code>string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {</code> - + - - - - - - setName - \Google\Cloud\Vision\V1\DeleteProductSetRequest::setName() - - - var - - string - - - - Required. Resource name of the ProductSet to delete. - Format is: -`projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` - -Generated from protobuf field <code>string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {</code> - + type="\Google\Cloud\Vision\V1\DeleteReferenceImageRequest"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - DeleteReferenceImageRequest - \Google\Cloud\Vision\V1\DeleteReferenceImageRequest - - Request message for the `DeleteReferenceImage` method. - Generated from protobuf message <code>google.cloud.vision.v1.DeleteReferenceImageRequest</code> - - \Google\Protobuf\Internal\Message - - - - name - \Google\Cloud\Vision\V1\DeleteReferenceImageRequest::$name - '' - - Required. The resource name of the reference image to delete. - Format is: -`projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` - -Generated from protobuf field <code>string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {</code> - - - + - - + __construct \Google\Cloud\Vision\V1\DeleteReferenceImageRequest::__construct() - + data NULL array - + Constructor. - + getName \Google\Cloud\Vision\V1\DeleteReferenceImageRequest::getName() - + Required. The resource name of the reference image to delete. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` @@ -11103,17 +15219,17 @@ Generated from protobuf field <code>string name = 1 [(.google.api.field_be - + setName \Google\Cloud\Vision\V1\DeleteReferenceImageRequest::setName() - + var string - + Required. The resource name of the reference image to delete. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID` @@ -11131,7 +15247,7 @@ Generated from protobuf field <code>string name = 1 [(.google.api.field_be - + @@ -11243,7 +15359,7 @@ Generated from protobuf field <code>string name = 1 [(.google.api.field_be - + @@ -11854,7 +15970,7 @@ fields, such a score or string that qualifies the entity. - + @@ -12350,7 +16466,7 @@ Protobuf type <code>google.cloud.vision.v1.FaceAnnotation.Landmark.Type< - + @@ -12535,7 +16651,7 @@ Protobuf type <code>google.cloud.vision.v1.FaceAnnotation.Landmark.Type< - + @@ -13456,7 +17572,7 @@ pointing relative to the image's horizontal plane. Range [-180,180]. - + @@ -13500,7 +17616,7 @@ pointing relative to the image's horizontal plane. Range [-180,180]. + @@ -13544,7 +17660,7 @@ pointing relative to the image's horizontal plane. Range [-180,180]. + @@ -13777,7 +17893,7 @@ image's dominant colors. - + @@ -14008,7 +18124,7 @@ Generated from protobuf field <code>string model = 3;</code> - + @@ -14052,13 +18168,13 @@ Generated from protobuf field <code>string model = 3;</code> + - + @@ -14076,10 +18192,10 @@ Generated from protobuf field <code>string model = 3;</code> + ImageAnnotatorGapicClient \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient - + Service Description: Service that performs Google Cloud Vision API detection tasks over client images, such as face, landmark, logo, label, and text detection. The ImageAnnotator service returns detected entities from the images. @@ -14094,7 +18210,7 @@ try { $operationResponse->pollUntilComplete(); if ($operationResponse->operationSucceeded()) { $result = $operationResponse->getResult(); - // doSomethingWith($result) + // doSomethingWith($result) } else { $error = $operationResponse->getError(); // handleError($error) @@ -14111,7 +18227,7 @@ try { } if ($newOperationResponse->operationSucceeded()) { $result = $newOperationResponse->getResult(); - // doSomethingWith($result) + // doSomethingWith($result) } else { $error = $newOperationResponse->getError(); // handleError($error) @@ -14119,7 +18235,14 @@ try { } finally { $imageAnnotatorClient->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. + +This service has a new (beta) implementation. See {@see \Google\Cloud\Vision\V1\Client\ImageAnnotatorClient} to use the new surface. + SERVICE_NAME \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::SERVICE_NAME 'google.cloud.vision.v1.ImageAnnotator' - + The name of the service. - + SERVICE_ADDRESS \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::SERVICE_ADDRESS 'vision.googleapis.com' - + The default address of the service. - + DEFAULT_SERVICE_PORT \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::DEFAULT_SERVICE_PORT 443 - + The default port of the service. - + CODEGEN_NAME \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::CODEGEN_NAME 'gapic' - + The name of the code generator, to be included in the agent header. @@ -14173,22 +18296,44 @@ try { - + serviceScopes \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::$serviceScopes ['https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/cloud-vision'] - + The default scopes required by the service. - + + productSetNameTemplate + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::$productSetNameTemplate + + + + + + + + + + pathTemplateMap + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::$pathTemplateMap + + + + + + + + + operationsClient \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::$operationsClient - + @@ -14196,22 +18341,137 @@ try { - + getClientDefaults \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::getClientDefaults() - + + + + + + + + + getProductSetNameTemplate + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::getProductSetNameTemplate() + + - + + getPathTemplateMap + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::getPathTemplateMap() + + + + + + + + + + productSetName + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::productSetName() + + + project + + string + + + + location + + string + + + + productSet + + string + + + + Formats a string containing the fully-qualified path to represent a product_set +resource. + + + + + + + + + + + parseName + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::parseName() + + + formattedName + + string + + + + template + null + string + + + + Parses a formatted name string and returns an associative array of the components in the name. + The following name formats are supported: +Template: Pattern +- productSet: projects/{project}/locations/{location}/productSets/{product_set} + +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. + + + + + + + + + getOperationsClient \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::getOperationsClient() - + Return an OperationsClient object with the same endpoint as $this. - + resumeOperation \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::resumeOperation() - + operationName string - + methodName null string - + Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the @@ -14260,17 +18520,17 @@ OperationResponse object will not deserialize the final response. - + __construct \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::__construct() - + options [] array - + Constructor. - + asyncBatchAnnotateFiles \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::asyncBatchAnnotateFiles() - + requests \Google\Cloud\Vision\V1\AsyncAnnotateFileRequest[] - + optionalArgs [] array - + Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the @@ -14318,7 +18578,7 @@ try { $operationResponse->pollUntilComplete(); if ($operationResponse->operationSucceeded()) { $result = $operationResponse->getResult(); - // doSomethingWith($result) + // doSomethingWith($result) } else { $error = $operationResponse->getError(); // handleError($error) @@ -14335,7 +18595,7 @@ try { } if ($newOperationResponse->operationSucceeded()) { $result = $newOperationResponse->getResult(); - // doSomethingWith($result) + // doSomethingWith($result) } else { $error = $newOperationResponse->getError(); // handleError($error) @@ -14364,29 +18624,29 @@ try { - + asyncBatchAnnotateImages \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::asyncBatchAnnotateImages() - + requests \Google\Cloud\Vision\V1\AnnotateImageRequest[] - + outputConfig \Google\Cloud\Vision\V1\OutputConfig - + optionalArgs [] array - + Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. @@ -14406,7 +18666,7 @@ try { $operationResponse->pollUntilComplete(); if ($operationResponse->operationSucceeded()) { $result = $operationResponse->getResult(); - // doSomethingWith($result) + // doSomethingWith($result) } else { $error = $operationResponse->getError(); // handleError($error) @@ -14423,7 +18683,7 @@ try { } if ($newOperationResponse->operationSucceeded()) { $result = $newOperationResponse->getResult(); - // doSomethingWith($result) + // doSomethingWith($result) } else { $error = $newOperationResponse->getError(); // handleError($error) @@ -14456,23 +18716,23 @@ try { - + batchAnnotateFiles \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::batchAnnotateFiles() - + requests \Google\Cloud\Vision\V1\AnnotateFileRequest[] - + optionalArgs [] array - + Service that performs image detection and annotation for a batch of files. Now only "application/pdf", "image/tiff" and "image/gif" are supported. @@ -14511,23 +18771,23 @@ try { - + batchAnnotateImages \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::batchAnnotateImages() - + requests \Google\Cloud\Vision\V1\AnnotateImageRequest[] - + optionalArgs [] array - + Run image detection and annotation for a batch of images. Sample code: ``` @@ -14559,13 +18819,13 @@ try { - + - + @@ -14583,10 +18843,10 @@ try { - + ProductSearchGapicClient \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient - + Service Description: Manages Products and ProductSets of reference images for use in product search. It uses the following resource model: - The API has a collection of [ProductSet][google.cloud.vision.v1.ProductSet] resources, named @@ -14618,7 +18878,9 @@ try { 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. +contained within formatted names that are returned by the API. + +This service has a new (beta) implementation. See {@see \Google\Cloud\Vision\V1\Client\ProductSearchClient} to use the new surface. + SERVICE_NAME \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::SERVICE_NAME 'google.cloud.vision.v1.ProductSearch' - + The name of the service. - + SERVICE_ADDRESS \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::SERVICE_ADDRESS 'vision.googleapis.com' - + The default address of the service. - + DEFAULT_SERVICE_PORT \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::DEFAULT_SERVICE_PORT 443 - + The default port of the service. - + CODEGEN_NAME \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::CODEGEN_NAME 'gapic' - + The name of the code generator, to be included in the agent header. @@ -14672,77 +18934,77 @@ contained within formatted names that are returned by the API. - + serviceScopes \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::$serviceScopes ['https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/cloud-vision'] - + The default scopes required by the service. - + locationNameTemplate \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::$locationNameTemplate - + - + productNameTemplate \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::$productNameTemplate - + - + productSetNameTemplate \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::$productSetNameTemplate - + - + referenceImageNameTemplate \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::$referenceImageNameTemplate - + - + pathTemplateMap \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::$pathTemplateMap - + - + operationsClient \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::$operationsClient - + @@ -14750,89 +19012,89 @@ contained within formatted names that are returned by the API. - + getClientDefaults \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::getClientDefaults() - + - + getLocationNameTemplate \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::getLocationNameTemplate() - + - + getProductNameTemplate \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::getProductNameTemplate() - + - + getProductSetNameTemplate \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::getProductSetNameTemplate() - + - + getReferenceImageNameTemplate \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::getReferenceImageNameTemplate() - + - + getPathTemplateMap \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::getPathTemplateMap() - + - + locationName \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::locationName() - + project string - + location string - + Formats a string containing the fully-qualified path to represent a location resource. @@ -14852,29 +19114,29 @@ resource. - + productName \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::productName() - + project string - + location string - + product string - + Formats a string containing the fully-qualified path to represent a product resource. @@ -14898,29 +19160,29 @@ resource. - + productSetName \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::productSetName() - + project string - + location string - + productSet string - + Formats a string containing the fully-qualified path to represent a product_set resource. @@ -14944,35 +19206,35 @@ resource. - + referenceImageName \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::referenceImageName() - + project string - + location string - + product string - + referenceImage string - + Formats a string containing the fully-qualified path to represent a reference_image resource. @@ -15000,23 +19262,23 @@ reference_image resource. - + parseName \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::parseName() - + formattedName string - + template null string - + Parses a formatted name string and returns an associative array of the components in the name. The following name formats are supported: Template: Pattern @@ -15050,11 +19312,11 @@ the first match. - + getOperationsClient \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::getOperationsClient() - + Return an OperationsClient object with the same endpoint as $this. - + resumeOperation \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::resumeOperation() - + operationName string - + methodName null string - + Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the @@ -15103,17 +19365,17 @@ OperationResponse object will not deserialize the final response. - + __construct \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::__construct() - + options [] array - + Constructor. - + addProductToProductSet \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::addProductToProductSet() - + name string - + product string - + optionalArgs [] array - + Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. @@ -15190,29 +19452,29 @@ try { - + createProduct \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::createProduct() - + parent string - + product \Google\Cloud\Vision\V1\Product - + optionalArgs [] array - + Creates and returns a new product resource. Possible errors: @@ -15256,29 +19518,29 @@ try { - + createProductSet \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::createProductSet() - + parent string - + productSet \Google\Cloud\Vision\V1\ProductSet - + optionalArgs [] array - + Creates and returns a new ProductSet resource. Possible errors: @@ -15320,29 +19582,29 @@ try { - + createReferenceImage \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::createReferenceImage() - + parent string - + referenceImage \Google\Cloud\Vision\V1\ReferenceImage - + optionalArgs [] array - + Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are @@ -15397,23 +19659,23 @@ try { - + deleteProduct \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::deleteProduct() - + name string - + optionalArgs [] array - + Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work @@ -15445,23 +19707,23 @@ try { - + deleteProductSet \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::deleteProductSet() - + name string - + optionalArgs [] array - + Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. The actual image files are not deleted from Google Cloud Storage. @@ -15492,23 +19754,23 @@ try { - + deleteReferenceImage \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::deleteReferenceImage() - + name string - + optionalArgs [] array - + Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related @@ -15542,23 +19804,23 @@ try { - + getProduct \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::getProduct() - + name string - + optionalArgs [] array - + Gets information associated with a Product. Possible errors: @@ -15594,23 +19856,23 @@ try { - + getProductSet \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::getProductSet() - + name string - + optionalArgs [] array - + Gets information associated with a ProductSet. Possible errors: @@ -15646,23 +19908,23 @@ try { - + getReferenceImage \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::getReferenceImage() - + name string - + optionalArgs [] array - + Gets information associated with a ReferenceImage. Possible errors: @@ -15698,29 +19960,29 @@ try { - + importProductSets \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::importProductSets() - + parent string - + inputConfig \Google\Cloud\Vision\V1\ImportProductSetsInputConfig - + optionalArgs [] array - + Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the @@ -15742,7 +20004,7 @@ try { $operationResponse->pollUntilComplete(); if ($operationResponse->operationSucceeded()) { $result = $operationResponse->getResult(); - // doSomethingWith($result) + // doSomethingWith($result) } else { $error = $operationResponse->getError(); // handleError($error) @@ -15759,7 +20021,7 @@ try { } if ($newOperationResponse->operationSucceeded()) { $result = $newOperationResponse->getResult(); - // doSomethingWith($result) + // doSomethingWith($result) } else { $error = $newOperationResponse->getError(); // handleError($error) @@ -15792,23 +20054,23 @@ try { - + listProductSets \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::listProductSets() - + parent string - + optionalArgs [] array - + Lists ProductSets in an unspecified order. Possible errors: @@ -15857,23 +20119,23 @@ try { - + listProducts \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::listProducts() - + parent string - + optionalArgs [] array - + Lists products in an unspecified order. Possible errors: @@ -15921,23 +20183,23 @@ try { - + listProductsInProductSet \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::listProductsInProductSet() - + name string - + optionalArgs [] array - + Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. @@ -15987,23 +20249,23 @@ try { - + listReferenceImages \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::listReferenceImages() - + parent string - + optionalArgs [] array - + Lists reference images. Possible errors: @@ -16053,23 +20315,23 @@ try { - + purgeProducts \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::purgeProducts() - + parent string - + optionalArgs [] array - + Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. If a Product is a member of the specified ProductSet in addition to other @@ -16147,29 +20409,29 @@ try { - + removeProductFromProductSet \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::removeProductFromProductSet() - + name string - + product string - + optionalArgs [] array - + Removes a Product from the specified ProductSet. Sample code: ``` @@ -16202,23 +20464,23 @@ try { - + updateProduct \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::updateProduct() - + product \Google\Cloud\Vision\V1\Product - + optionalArgs [] array - + Makes changes to a Product resource. Only the `display_name`, `description`, and `labels` fields can be updated right now. @@ -16265,23 +20527,23 @@ try { - + updateProductSet \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::updateProductSet() - + productSet \Google\Cloud\Vision\V1\ProductSet - + optionalArgs [] array - + Makes changes to a ProductSet resource. Only display_name can be updated currently. @@ -16321,7 +20583,7 @@ try { - + @@ -16487,7 +20749,7 @@ Generated from protobuf field <code>string uri = 1;</code> - + @@ -16602,13 +20864,13 @@ Google Cloud Storage object. Wildcards are not currently supported. - + - + @@ -16656,17 +20918,46 @@ Generated from protobuf field <code>string name = 1 [(.google.api.field_be - + + build + \Google\Cloud\Vision\V1\GetProductRequest::build() + + + name + + string + + + + + + + + + + + + + __construct \Google\Cloud\Vision\V1\GetProductRequest::__construct() - + data NULL array - + Constructor. - + getName \Google\Cloud\Vision\V1\GetProductRequest::getName() - + Required. Resource name of the Product to get. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` @@ -16695,17 +20986,17 @@ Generated from protobuf field <code>string name = 1 [(.google.api.field_be - + setName \Google\Cloud\Vision\V1\GetProductRequest::setName() - + var string - + Required. Resource name of the Product to get. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` @@ -16723,13 +21014,13 @@ Generated from protobuf field <code>string name = 1 [(.google.api.field_be - + - + @@ -16777,17 +21068,46 @@ Generated from protobuf field <code>string name = 1 [(.google.api.field_be - + + build + \Google\Cloud\Vision\V1\GetProductSetRequest::build() + + + name + + string + + + + + + + + + + + + + __construct \Google\Cloud\Vision\V1\GetProductSetRequest::__construct() - + data NULL array - + Constructor. - + getName \Google\Cloud\Vision\V1\GetProductSetRequest::getName() - + Required. Resource name of the ProductSet to get. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` @@ -16816,17 +21136,17 @@ Generated from protobuf field <code>string name = 1 [(.google.api.field_be - + setName \Google\Cloud\Vision\V1\GetProductSetRequest::setName() - + var string - + Required. Resource name of the ProductSet to get. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` @@ -16844,13 +21164,13 @@ Generated from protobuf field <code>string name = 1 [(.google.api.field_be - + - + @@ -16898,17 +21218,46 @@ Generated from protobuf field <code>string name = 1 [(.google.api.field_be - + + build + \Google\Cloud\Vision\V1\GetReferenceImageRequest::build() + + + name + + string + + + + + + + + + + + + + __construct \Google\Cloud\Vision\V1\GetReferenceImageRequest::__construct() - + data NULL array - + Constructor. - + getName \Google\Cloud\Vision\V1\GetReferenceImageRequest::getName() - + Required. The resource name of the ReferenceImage to get. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. @@ -16937,17 +21286,17 @@ Generated from protobuf field <code>string name = 1 [(.google.api.field_be - + setName \Google\Cloud\Vision\V1\GetReferenceImageRequest::setName() - + var string - + Required. The resource name of the ReferenceImage to get. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. @@ -16965,7 +21314,7 @@ Generated from protobuf field <code>string name = 1 [(.google.api.field_be - + @@ -17171,7 +21520,7 @@ takes precedence and is used to perform the image annotation request. - + @@ -17338,7 +21687,7 @@ the file used to produce the image. - + @@ -17378,44 +21727,44 @@ ImageAnnotator service returns detected entities from the images. \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient - + SERVICE_NAME \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::SERVICE_NAME 'google.cloud.vision.v1.ImageAnnotator' - \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient The name of the service. - + SERVICE_ADDRESS \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::SERVICE_ADDRESS 'vision.googleapis.com' - \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient The default address of the service. - + DEFAULT_SERVICE_PORT \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::DEFAULT_SERVICE_PORT 443 - \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient The default port of the service. - + CODEGEN_NAME \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::CODEGEN_NAME 'gapic' - \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient The name of the code generator, to be included in the agent header. @@ -17438,22 +21787,44 @@ ImageAnnotator service returns detected entities from the images. - + serviceScopes \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::$serviceScopes ['https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/cloud-vision'] - \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient The default scopes required by the service. - + + productSetNameTemplate + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::$productSetNameTemplate + + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient + + + + + + + + pathTemplateMap + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::$pathTemplateMap + + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient + + + + + + + operationsClient \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::$operationsClient - \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient @@ -18292,22 +22663,137 @@ $response = $imageAnnotatorClient->productSearch( - + getClientDefaults \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::getClientDefaults() - \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient + + + + + + + + getProductSetNameTemplate + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::getProductSetNameTemplate() + + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient + + + + + + + + getPathTemplateMap + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::getPathTemplateMap() + + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient - + + productSetName + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::productSetName() + + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient + project + + string + + + + location + + string + + + + productSet + + string + + + + Formats a string containing the fully-qualified path to represent a product_set +resource. + + + + + + + + + + + parseName + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::parseName() + + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient + formattedName + + string + + + + template + null + string + + + + Parses a formatted name string and returns an associative array of the components in the name. + The following name formats are supported: +Template: Pattern +- productSet: projects/{project}/locations/{location}/productSets/{product_set} + +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. + + + + + + + + + getOperationsClient \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::getOperationsClient() - \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient Return an OperationsClient object with the same endpoint as $this. - + resumeOperation \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::resumeOperation() - \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient operationName string - + methodName null string - + Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the @@ -18356,17 +22842,17 @@ OperationResponse object will not deserialize the final response. - + __construct \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::__construct() - \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient options [] array - + Constructor. - + asyncBatchAnnotateFiles \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::asyncBatchAnnotateFiles() - \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient requests \Google\Cloud\Vision\V1\AsyncAnnotateFileRequest[] - + optionalArgs [] array - + Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the @@ -18414,7 +22900,7 @@ try { $operationResponse->pollUntilComplete(); if ($operationResponse->operationSucceeded()) { $result = $operationResponse->getResult(); - // doSomethingWith($result) + // doSomethingWith($result) } else { $error = $operationResponse->getError(); // handleError($error) @@ -18431,7 +22917,7 @@ try { } if ($newOperationResponse->operationSucceeded()) { $result = $newOperationResponse->getResult(); - // doSomethingWith($result) + // doSomethingWith($result) } else { $error = $newOperationResponse->getError(); // handleError($error) @@ -18460,29 +22946,29 @@ try { - + asyncBatchAnnotateImages \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::asyncBatchAnnotateImages() - \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient requests \Google\Cloud\Vision\V1\AnnotateImageRequest[] - + outputConfig \Google\Cloud\Vision\V1\OutputConfig - + optionalArgs [] array - + Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. @@ -18502,7 +22988,7 @@ try { $operationResponse->pollUntilComplete(); if ($operationResponse->operationSucceeded()) { $result = $operationResponse->getResult(); - // doSomethingWith($result) + // doSomethingWith($result) } else { $error = $operationResponse->getError(); // handleError($error) @@ -18519,7 +23005,7 @@ try { } if ($newOperationResponse->operationSucceeded()) { $result = $newOperationResponse->getResult(); - // doSomethingWith($result) + // doSomethingWith($result) } else { $error = $newOperationResponse->getError(); // handleError($error) @@ -18552,23 +23038,23 @@ try { - + batchAnnotateFiles \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::batchAnnotateFiles() - \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient requests \Google\Cloud\Vision\V1\AnnotateFileRequest[] - + optionalArgs [] array - + Service that performs image detection and annotation for a batch of files. Now only "application/pdf", "image/tiff" and "image/gif" are supported. @@ -18607,23 +23093,23 @@ try { - + batchAnnotateImages \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient::batchAnnotateImages() - \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient + \Google\Cloud\Vision\V1\Gapic\ImageAnnotatorGapicClient requests \Google\Cloud\Vision\V1\AnnotateImageRequest[] - + optionalArgs [] array - + Run image detection and annotation for a batch of images. Sample code: ``` @@ -18655,7 +23141,7 @@ try { - + @@ -18933,7 +23419,7 @@ images per page. Progress and results can be retrieved through the - + @@ -19431,7 +23917,7 @@ error if one or more of the specified languages is not one of the - + @@ -19565,7 +24051,7 @@ error if one or more of the specified languages is not one of the - + @@ -19782,7 +24268,7 @@ Generated from protobuf field <code>string image_uri = 2;</code> - + @@ -20036,7 +24522,7 @@ Generated from protobuf field <code>string csv_file_uri = 1;</code>< - + @@ -20176,13 +24662,13 @@ of ImportProductSetRequests in each line. - + - + @@ -20240,17 +24726,56 @@ Generated from protobuf field <code>string parent = 1 [(.google.api.field_ - + + build + \Google\Cloud\Vision\V1\ImportProductSetsRequest::build() + + + parent + + string + + + + inputConfig + + \Google\Cloud\Vision\V1\ImportProductSetsInputConfig + + + + + + + + + + + + + + __construct \Google\Cloud\Vision\V1\ImportProductSetsRequest::__construct() - + data NULL array - + Constructor. - + getParent \Google\Cloud\Vision\V1\ImportProductSetsRequest::getParent() - + Required. The project in which the ProductSets should be imported. Format is `projects/PROJECT_ID/locations/LOC_ID`. @@ -20278,17 +24803,17 @@ Generated from protobuf field <code>string parent = 1 [(.google.api.field_ - + setParent \Google\Cloud\Vision\V1\ImportProductSetsRequest::setParent() - + var string - + Required. The project in which the ProductSets should be imported. Format is `projects/PROJECT_ID/locations/LOC_ID`. @@ -20305,11 +24830,11 @@ Generated from protobuf field <code>string parent = 1 [(.google.api.field_ - + getInputConfig \Google\Cloud\Vision\V1\ImportProductSetsRequest::getInputConfig() - + Required. The input content for the list of requests. Generated from protobuf field <code>.google.cloud.vision.v1.ImportProductSetsInputConfig input_config = 2 [(.google.api.field_behavior) = REQUIRED];</code> - + hasInputConfig \Google\Cloud\Vision\V1\ImportProductSetsRequest::hasInputConfig() - + - + clearInputConfig \Google\Cloud\Vision\V1\ImportProductSetsRequest::clearInputConfig() - + - + setInputConfig \Google\Cloud\Vision\V1\ImportProductSetsRequest::setInputConfig() - + var \Google\Cloud\Vision\V1\ImportProductSetsInputConfig - + Required. The input content for the list of requests. Generated from protobuf field <code>.google.cloud.vision.v1.ImportProductSetsInputConfig input_config = 2 [(.google.api.field_behavior) = REQUIRED];</code> - + @@ -20549,7 +25074,7 @@ Generated from protobuf field <code>repeated .google.rpc.Status statuses = - + @@ -20803,7 +25328,7 @@ Generated from protobuf field <code>bytes content = 3;</code> - + @@ -21010,7 +25535,7 @@ Generated from protobuf field <code>bytes content = 3;</code> - + @@ -21162,13 +25687,13 @@ highly stable results across model upgrades. - + - + @@ -21237,17 +25762,46 @@ Generated from protobuf field <code>string parent = 1 [(.google.api.field_ - + + build + \Google\Cloud\Vision\V1\ListProductSetsRequest::build() + + + parent + + string + + + + + + + + + + + + + __construct \Google\Cloud\Vision\V1\ListProductSetsRequest::__construct() - + data NULL array - + Constructor. - + getParent \Google\Cloud\Vision\V1\ListProductSetsRequest::getParent() - + Required. The project from which ProductSets should be listed. Format is `projects/PROJECT_ID/locations/LOC_ID`. @@ -21275,17 +25829,17 @@ Generated from protobuf field <code>string parent = 1 [(.google.api.field_ - + setParent \Google\Cloud\Vision\V1\ListProductSetsRequest::setParent() - + var string - + Required. The project from which ProductSets should be listed. Format is `projects/PROJECT_ID/locations/LOC_ID`. @@ -21302,11 +25856,11 @@ Generated from protobuf field <code>string parent = 1 [(.google.api.field_ - + getPageSize \Google\Cloud\Vision\V1\ListProductSetsRequest::getPageSize() - + The maximum number of items to return. Default 10, maximum 100. Generated from protobuf field <code>int32 page_size = 2;</code> - + setPageSize \Google\Cloud\Vision\V1\ListProductSetsRequest::setPageSize() - + var int - + The maximum number of items to return. Default 10, maximum 100. Generated from protobuf field <code>int32 page_size = 2;</code> - + getPageToken \Google\Cloud\Vision\V1\ListProductSetsRequest::getPageToken() - + The next_page_token returned from a previous List request, if any. Generated from protobuf field <code>string page_token = 3;</code> - + setPageToken \Google\Cloud\Vision\V1\ListProductSetsRequest::setPageToken() - + var string - + The next_page_token returned from a previous List request, if any. Generated from protobuf field <code>string page_token = 3;</code> - + @@ -21548,13 +26102,13 @@ results in the list. - + - + @@ -21624,17 +26178,46 @@ Generated from protobuf field <code>string name = 1 [(.google.api.field_be - + + build + \Google\Cloud\Vision\V1\ListProductsInProductSetRequest::build() + + + name + + string + + + + + + + + + + + + + __construct \Google\Cloud\Vision\V1\ListProductsInProductSetRequest::__construct() - + data NULL array - + Constructor. - + getName \Google\Cloud\Vision\V1\ListProductsInProductSetRequest::getName() - + Required. The ProductSet resource for which to retrieve Products. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` @@ -21663,17 +26246,17 @@ Generated from protobuf field <code>string name = 1 [(.google.api.field_be - + setName \Google\Cloud\Vision\V1\ListProductsInProductSetRequest::setName() - + var string - + Required. The ProductSet resource for which to retrieve Products. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` @@ -21691,11 +26274,11 @@ Generated from protobuf field <code>string name = 1 [(.google.api.field_be - + getPageSize \Google\Cloud\Vision\V1\ListProductsInProductSetRequest::getPageSize() - + The maximum number of items to return. Default 10, maximum 100. Generated from protobuf field <code>int32 page_size = 2;</code> - + setPageSize \Google\Cloud\Vision\V1\ListProductsInProductSetRequest::setPageSize() - + var int - + The maximum number of items to return. Default 10, maximum 100. Generated from protobuf field <code>int32 page_size = 2;</code> - + getPageToken \Google\Cloud\Vision\V1\ListProductsInProductSetRequest::getPageToken() - + The next_page_token returned from a previous List request, if any. Generated from protobuf field <code>string page_token = 3;</code> - + setPageToken \Google\Cloud\Vision\V1\ListProductsInProductSetRequest::setPageToken() - + var string - + The next_page_token returned from a previous List request, if any. Generated from protobuf field <code>string page_token = 3;</code> - + @@ -21937,13 +26520,13 @@ results in the list. - + - + @@ -22013,17 +26596,46 @@ Generated from protobuf field <code>string parent = 1 [(.google.api.field_ - + + build + \Google\Cloud\Vision\V1\ListProductsRequest::build() + + + parent + + string + + + + + + + + + + + + + __construct \Google\Cloud\Vision\V1\ListProductsRequest::__construct() - + data NULL array - + Constructor. - + getParent \Google\Cloud\Vision\V1\ListProductsRequest::getParent() - + Required. The project OR ProductSet from which Products should be listed. Format: `projects/PROJECT_ID/locations/LOC_ID` @@ -22052,17 +26664,17 @@ Generated from protobuf field <code>string parent = 1 [(.google.api.field_ - + setParent \Google\Cloud\Vision\V1\ListProductsRequest::setParent() - + var string - + Required. The project OR ProductSet from which Products should be listed. Format: `projects/PROJECT_ID/locations/LOC_ID` @@ -22080,11 +26692,11 @@ Generated from protobuf field <code>string parent = 1 [(.google.api.field_ - + getPageSize \Google\Cloud\Vision\V1\ListProductsRequest::getPageSize() - + The maximum number of items to return. Default 10, maximum 100. Generated from protobuf field <code>int32 page_size = 2;</code> - + setPageSize \Google\Cloud\Vision\V1\ListProductsRequest::setPageSize() - + var int - + The maximum number of items to return. Default 10, maximum 100. Generated from protobuf field <code>int32 page_size = 2;</code> - + getPageToken \Google\Cloud\Vision\V1\ListProductsRequest::getPageToken() - + The next_page_token returned from a previous List request, if any. Generated from protobuf field <code>string page_token = 3;</code> - + setPageToken \Google\Cloud\Vision\V1\ListProductsRequest::setPageToken() - + var string - + The next_page_token returned from a previous List request, if any. Generated from protobuf field <code>string page_token = 3;</code> - + @@ -22326,13 +26938,13 @@ results in the list. - + - + @@ -22405,17 +27017,46 @@ Generated from protobuf field <code>string page_token = 3;</code> - + + build + \Google\Cloud\Vision\V1\ListReferenceImagesRequest::build() + + + parent + + string + + + + + + + + + + + + + __construct \Google\Cloud\Vision\V1\ListReferenceImagesRequest::__construct() - + data NULL array - + Constructor. - + getParent \Google\Cloud\Vision\V1\ListReferenceImagesRequest::getParent() - + Required. Resource name of the product containing the reference images. Format is `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. @@ -22444,17 +27085,17 @@ Generated from protobuf field <code>string parent = 1 [(.google.api.field_ - + setParent \Google\Cloud\Vision\V1\ListReferenceImagesRequest::setParent() - + var string - + Required. Resource name of the product containing the reference images. Format is `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. @@ -22472,11 +27113,11 @@ Generated from protobuf field <code>string parent = 1 [(.google.api.field_ - + getPageSize \Google\Cloud\Vision\V1\ListReferenceImagesRequest::getPageSize() - + The maximum number of items to return. Default 10, maximum 100. Generated from protobuf field <code>int32 page_size = 2;</code> - + setPageSize \Google\Cloud\Vision\V1\ListReferenceImagesRequest::setPageSize() - + var int - + The maximum number of items to return. Default 10, maximum 100. Generated from protobuf field <code>int32 page_size = 2;</code> - + getPageToken \Google\Cloud\Vision\V1\ListReferenceImagesRequest::getPageToken() - + A token identifying a page of results to be returned. This is the value of `nextPageToken` returned in a previous reference image list request. Defaults to the first page if not specified. @@ -22530,17 +27171,17 @@ Generated from protobuf field <code>string page_token = 3;</code> - + setPageToken \Google\Cloud\Vision\V1\ListReferenceImagesRequest::setPageToken() - + var string - + A token identifying a page of results to be returned. This is the value of `nextPageToken` returned in a previous reference image list request. Defaults to the first page if not specified. @@ -22558,7 +27199,7 @@ Generated from protobuf field <code>string page_token = 3;</code> - + @@ -22772,7 +27413,7 @@ Generated from protobuf field <code>string page_token = 3;</code> - + @@ -23116,7 +27757,7 @@ http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - + @@ -23250,7 +27891,7 @@ http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - + @@ -23416,7 +28057,7 @@ Generated from protobuf message <code>google.cloud.vision.v1.NormalizedVer - + @@ -23556,7 +28197,7 @@ Generated from protobuf message <code>google.cloud.vision.v1.NormalizedVer - + @@ -23814,7 +28455,7 @@ Generated from protobuf message <code>google.cloud.vision.v1.NormalizedVer - + @@ -23858,7 +28499,7 @@ Generated from protobuf message <code>google.cloud.vision.v1.NormalizedVer - + @@ -24070,7 +28711,7 @@ Generated from protobuf field <code>int32 batch_size = 2;</code> - + @@ -24414,7 +29055,7 @@ TIFFs) the unit is pixels. - + @@ -24768,7 +29409,7 @@ Generated from protobuf field <code>.google.cloud.vision.v1.BoundingPoly b - + @@ -24985,7 +29626,7 @@ Generated from protobuf message <code>google.cloud.vision.v1.Position</ - + @@ -25154,7 +29795,7 @@ cannot exceed 128 bytes. - + @@ -25527,7 +30168,7 @@ Generated from protobuf field <code>repeated .google.cloud.vision.v1.Produ - + @@ -25571,7 +30212,7 @@ Generated from protobuf field <code>repeated .google.cloud.vision.v1.Produ - + @@ -25610,44 +30251,44 @@ search. It uses the following resource model: \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient - + SERVICE_NAME \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::SERVICE_NAME 'google.cloud.vision.v1.ProductSearch' - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient The name of the service. - + SERVICE_ADDRESS \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::SERVICE_ADDRESS 'vision.googleapis.com' - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient The default address of the service. - + DEFAULT_SERVICE_PORT \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::DEFAULT_SERVICE_PORT 443 - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient The default port of the service. - + CODEGEN_NAME \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::CODEGEN_NAME 'gapic' - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient The name of the code generator, to be included in the agent header. @@ -25655,77 +30296,77 @@ search. It uses the following resource model: - + serviceScopes \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::$serviceScopes ['https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/cloud-vision'] - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient The default scopes required by the service. - + locationNameTemplate \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::$locationNameTemplate - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient - + productNameTemplate \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::$productNameTemplate - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient - + productSetNameTemplate \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::$productSetNameTemplate - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient - + referenceImageNameTemplate \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::$referenceImageNameTemplate - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient - + pathTemplateMap \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::$pathTemplateMap - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient - + operationsClient \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::$operationsClient - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient @@ -25733,89 +30374,89 @@ search. It uses the following resource model: - + getClientDefaults \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::getClientDefaults() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient - + getLocationNameTemplate \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::getLocationNameTemplate() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient - + getProductNameTemplate \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::getProductNameTemplate() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient - + getProductSetNameTemplate \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::getProductSetNameTemplate() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient - + getReferenceImageNameTemplate \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::getReferenceImageNameTemplate() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient - + getPathTemplateMap \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::getPathTemplateMap() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient - + locationName \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::locationName() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient project string - + location string - + Formats a string containing the fully-qualified path to represent a location resource. @@ -25835,29 +30476,29 @@ resource. - + productName \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::productName() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient project string - + location string - + product string - + Formats a string containing the fully-qualified path to represent a product resource. @@ -25881,29 +30522,29 @@ resource. - + productSetName \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::productSetName() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient project string - + location string - + productSet string - + Formats a string containing the fully-qualified path to represent a product_set resource. @@ -25927,35 +30568,35 @@ resource. - + referenceImageName \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::referenceImageName() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient project string - + location string - + product string - + referenceImage string - + Formats a string containing the fully-qualified path to represent a reference_image resource. @@ -25983,23 +30624,23 @@ reference_image resource. - + parseName \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::parseName() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient formattedName string - + template null string - + Parses a formatted name string and returns an associative array of the components in the name. The following name formats are supported: Template: Pattern @@ -26033,11 +30674,11 @@ the first match. - + getOperationsClient \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::getOperationsClient() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient Return an OperationsClient object with the same endpoint as $this. - + resumeOperation \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::resumeOperation() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient operationName string - + methodName null string - + Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the @@ -26086,17 +30727,17 @@ OperationResponse object will not deserialize the final response. - + __construct \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::__construct() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient options [] array - + Constructor. - + addProductToProductSet \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::addProductToProductSet() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient name string - + product string - + optionalArgs [] array - + Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. @@ -26173,29 +30814,29 @@ try { - + createProduct \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::createProduct() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient parent string - + product \Google\Cloud\Vision\V1\Product - + optionalArgs [] array - + Creates and returns a new product resource. Possible errors: @@ -26239,29 +30880,29 @@ try { - + createProductSet \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::createProductSet() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient parent string - + productSet \Google\Cloud\Vision\V1\ProductSet - + optionalArgs [] array - + Creates and returns a new ProductSet resource. Possible errors: @@ -26303,29 +30944,29 @@ try { - + createReferenceImage \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::createReferenceImage() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient parent string - + referenceImage \Google\Cloud\Vision\V1\ReferenceImage - + optionalArgs [] array - + Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are @@ -26380,23 +31021,23 @@ try { - + deleteProduct \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::deleteProduct() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient name string - + optionalArgs [] array - + Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work @@ -26428,23 +31069,23 @@ try { - + deleteProductSet \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::deleteProductSet() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient name string - + optionalArgs [] array - + Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. The actual image files are not deleted from Google Cloud Storage. @@ -26475,23 +31116,23 @@ try { - + deleteReferenceImage \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::deleteReferenceImage() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient name string - + optionalArgs [] array - + Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related @@ -26525,23 +31166,23 @@ try { - + getProduct \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::getProduct() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient name string - + optionalArgs [] array - + Gets information associated with a Product. Possible errors: @@ -26577,23 +31218,23 @@ try { - + getProductSet \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::getProductSet() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient name string - + optionalArgs [] array - + Gets information associated with a ProductSet. Possible errors: @@ -26629,23 +31270,23 @@ try { - + getReferenceImage \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::getReferenceImage() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient name string - + optionalArgs [] array - + Gets information associated with a ReferenceImage. Possible errors: @@ -26681,29 +31322,29 @@ try { - + importProductSets \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::importProductSets() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient parent string - + inputConfig \Google\Cloud\Vision\V1\ImportProductSetsInputConfig - + optionalArgs [] array - + Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The [google.longrunning.Operation][google.longrunning.Operation] API can be used to keep track of the @@ -26725,7 +31366,7 @@ try { $operationResponse->pollUntilComplete(); if ($operationResponse->operationSucceeded()) { $result = $operationResponse->getResult(); - // doSomethingWith($result) + // doSomethingWith($result) } else { $error = $operationResponse->getError(); // handleError($error) @@ -26742,7 +31383,7 @@ try { } if ($newOperationResponse->operationSucceeded()) { $result = $newOperationResponse->getResult(); - // doSomethingWith($result) + // doSomethingWith($result) } else { $error = $newOperationResponse->getError(); // handleError($error) @@ -26775,23 +31416,23 @@ try { - + listProductSets \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::listProductSets() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient parent string - + optionalArgs [] array - + Lists ProductSets in an unspecified order. Possible errors: @@ -26840,23 +31481,23 @@ try { - + listProducts \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::listProducts() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient parent string - + optionalArgs [] array - + Lists products in an unspecified order. Possible errors: @@ -26904,23 +31545,23 @@ try { - + listProductsInProductSet \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::listProductsInProductSet() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient name string - + optionalArgs [] array - + Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. @@ -26970,23 +31611,23 @@ try { - + listReferenceImages \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::listReferenceImages() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient parent string - + optionalArgs [] array - + Lists reference images. Possible errors: @@ -27036,23 +31677,23 @@ try { - + purgeProducts \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::purgeProducts() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient parent string - + optionalArgs [] array - + Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. If a Product is a member of the specified ProductSet in addition to other @@ -27130,29 +31771,29 @@ try { - + removeProductFromProductSet \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::removeProductFromProductSet() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient name string - + product string - + optionalArgs [] array - + Removes a Product from the specified ProductSet. Sample code: ``` @@ -27185,23 +31826,23 @@ try { - + updateProduct \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::updateProduct() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient product \Google\Cloud\Vision\V1\Product - + optionalArgs [] array - + Makes changes to a Product resource. Only the `display_name`, `description`, and `labels` fields can be updated right now. @@ -27248,23 +31889,23 @@ try { - + updateProductSet \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient::updateProductSet() - \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient + \Google\Cloud\Vision\V1\Gapic\ProductSearchGapicClient productSet \Google\Cloud\Vision\V1\ProductSet - + optionalArgs [] array - + Makes changes to a ProductSet resource. Only display_name can be updated currently. @@ -27304,7 +31945,7 @@ try { - + @@ -28354,7 +32995,7 @@ progress and results of the request. - + @@ -28695,7 +33336,7 @@ Generated from protobuf field <code>string filter = 8;</code> - + @@ -28932,7 +33573,7 @@ image. - + @@ -29203,7 +33844,7 @@ http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - + @@ -29445,7 +34086,7 @@ to the query. - + @@ -29696,7 +34337,7 @@ matches in the union of all the per-product results. - + @@ -29740,7 +34381,7 @@ matches in the union of all the per-product results. - + @@ -29784,7 +34425,7 @@ matches in the union of all the per-product results. - + @@ -29828,7 +34469,7 @@ matches in the union of all the per-product results. - + @@ -30178,7 +34819,7 @@ Generated from protobuf field <code>.google.rpc.Status index_error = 4 [(. - + @@ -30296,7 +34937,7 @@ still be deleted. - + @@ -30510,13 +35151,13 @@ still be deleted. - + - + @@ -30586,17 +35227,46 @@ the purge. - + + build + \Google\Cloud\Vision\V1\PurgeProductsRequest::build() + + + parent + + string + + + + + + + + + + + + + __construct \Google\Cloud\Vision\V1\PurgeProductsRequest::__construct() - + data NULL array - + Constructor. - + getProductSetPurgeConfig \Google\Cloud\Vision\V1\PurgeProductsRequest::getProductSetPurgeConfig() - + Specify which ProductSet contains the Products to be deleted. Generated from protobuf field <code>.google.cloud.vision.v1.ProductSetPurgeConfig product_set_purge_config = 2;</code> - + hasProductSetPurgeConfig \Google\Cloud\Vision\V1\PurgeProductsRequest::hasProductSetPurgeConfig() - + - + setProductSetPurgeConfig \Google\Cloud\Vision\V1\PurgeProductsRequest::setProductSetPurgeConfig() - + var \Google\Cloud\Vision\V1\ProductSetPurgeConfig - + Specify which ProductSet contains the Products to be deleted. Generated from protobuf field <code>.google.cloud.vision.v1.ProductSetPurgeConfig product_set_purge_config = 2;</code> - + getDeleteOrphanProducts \Google\Cloud\Vision\V1\PurgeProductsRequest::getDeleteOrphanProducts() - + If delete_orphan_products is true, all Products that are not in any ProductSet will be deleted. Generated from protobuf field <code>bool delete_orphan_products = 3;</code> @@ -30674,28 +35344,28 @@ ProductSet will be deleted. - + hasDeleteOrphanProducts \Google\Cloud\Vision\V1\PurgeProductsRequest::hasDeleteOrphanProducts() - + - + setDeleteOrphanProducts \Google\Cloud\Vision\V1\PurgeProductsRequest::setDeleteOrphanProducts() - + var bool - + If delete_orphan_products is true, all Products that are not in any ProductSet will be deleted. Generated from protobuf field <code>bool delete_orphan_products = 3;</code> @@ -30711,11 +35381,11 @@ ProductSet will be deleted. - + getParent \Google\Cloud\Vision\V1\PurgeProductsRequest::getParent() - + Required. The project and location in which the Products should be deleted. Format is `projects/PROJECT_ID/locations/LOC_ID`. @@ -30728,17 +35398,17 @@ Generated from protobuf field <code>string parent = 1 [(.google.api.field_ - + setParent \Google\Cloud\Vision\V1\PurgeProductsRequest::setParent() - + var string - + Required. The project and location in which the Products should be deleted. Format is `projects/PROJECT_ID/locations/LOC_ID`. @@ -30755,11 +35425,11 @@ Generated from protobuf field <code>string parent = 1 [(.google.api.field_ - + getForce \Google\Cloud\Vision\V1\PurgeProductsRequest::getForce() - + The default value is false. Override this value to true to actually perform the purge. Generated from protobuf field <code>bool force = 4;</code> @@ -30771,17 +35441,17 @@ the purge. - + setForce \Google\Cloud\Vision\V1\PurgeProductsRequest::setForce() - + var bool - + The default value is false. Override this value to true to actually perform the purge. Generated from protobuf field <code>bool force = 4;</code> @@ -30797,11 +35467,11 @@ the purge. - + getTarget \Google\Cloud\Vision\V1\PurgeProductsRequest::getTarget() - + - + @@ -31066,13 +35736,13 @@ Generated from protobuf field <code>repeated .google.cloud.vision.v1.Bound - + - + @@ -31134,17 +35804,56 @@ Generated from protobuf field <code>string product = 2 [(.google.api.field - + + build + \Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest::build() + + + name + + string + + + + product + + string + + + + + + + + + + + + + + __construct \Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest::__construct() - + data NULL array - + Constructor. - + getName \Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest::getName() - + Required. The resource name for the ProductSet to modify. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` @@ -31173,17 +35882,17 @@ Generated from protobuf field <code>string name = 1 [(.google.api.field_be - + setName \Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest::setName() - + var string - + Required. The resource name for the ProductSet to modify. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID` @@ -31201,11 +35910,11 @@ Generated from protobuf field <code>string name = 1 [(.google.api.field_be - + getProduct \Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest::getProduct() - + Required. The resource name for the Product to be removed from this ProductSet. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` @@ -31219,17 +35928,17 @@ Generated from protobuf field <code>string product = 2 [(.google.api.field - + setProduct \Google\Cloud\Vision\V1\RemoveProductFromProductSetRequest::setProduct() - + var string - + Required. The resource name for the Product to be removed from this ProductSet. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID` @@ -31247,13 +35956,13 @@ Generated from protobuf field <code>string product = 2 [(.google.api.field - + - + @@ -31275,7 +35984,7 @@ Generated from protobuf field <code>string product = 2 [(.google.api.field - + @@ -31297,7 +36006,7 @@ Generated from protobuf field <code>string product = 2 [(.google.api.field - + @@ -31319,7 +36028,7 @@ Generated from protobuf field <code>string product = 2 [(.google.api.field - + @@ -31974,7 +36683,7 @@ confident. - + @@ -32328,7 +37037,7 @@ Generated from protobuf field <code>.google.cloud.vision.v1.BoundingPoly b - + @@ -32480,7 +37189,7 @@ Generated from protobuf field <code>.google.cloud.vision.v1.BoundingPoly b - + @@ -32643,7 +37352,7 @@ Generated from protobuf field <code>.google.cloud.vision.v1.BoundingPoly b - + @@ -32812,7 +37521,7 @@ http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - + @@ -32997,7 +37706,7 @@ http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - + @@ -33167,7 +37876,7 @@ Generated from protobuf message <code>google.cloud.vision.v1.TextAnnotatio - + @@ -33211,7 +37920,7 @@ Generated from protobuf message <code>google.cloud.vision.v1.TextAnnotatio - + @@ -33255,7 +37964,7 @@ Generated from protobuf message <code>google.cloud.vision.v1.TextAnnotatio - + @@ -33299,7 +38008,7 @@ Generated from protobuf message <code>google.cloud.vision.v1.TextAnnotatio - + @@ -33343,7 +38052,7 @@ Generated from protobuf message <code>google.cloud.vision.v1.TextAnnotatio - + @@ -33513,13 +38222,13 @@ score for TEXT_DETECTION as well. - + - + @@ -33582,17 +38291,56 @@ Generated from protobuf field <code>.google.protobuf.FieldMask update_mask - + + build + \Google\Cloud\Vision\V1\UpdateProductRequest::build() + + + product + + \Google\Cloud\Vision\V1\Product + + + + updateMask + + \Google\Protobuf\FieldMask + + + + + + + + + + + + + + __construct \Google\Cloud\Vision\V1\UpdateProductRequest::__construct() - + data NULL array - + Constructor. - + getProduct \Google\Cloud\Vision\V1\UpdateProductRequest::getProduct() - + Required. The Product resource which replaces the one on the server. product.name is immutable. @@ -33620,39 +38368,39 @@ Generated from protobuf field <code>.google.cloud.vision.v1.Product produc - + hasProduct \Google\Cloud\Vision\V1\UpdateProductRequest::hasProduct() - + - + clearProduct \Google\Cloud\Vision\V1\UpdateProductRequest::clearProduct() - + - + setProduct \Google\Cloud\Vision\V1\UpdateProductRequest::setProduct() - + var \Google\Cloud\Vision\V1\Product - + Required. The Product resource which replaces the one on the server. product.name is immutable. @@ -33669,11 +38417,11 @@ Generated from protobuf field <code>.google.cloud.vision.v1.Product produc - + getUpdateMask \Google\Cloud\Vision\V1\UpdateProductRequest::getUpdateMask() - + The [FieldMask][google.protobuf.FieldMask] that specifies which fields to update. If update_mask isn't specified, all mutable fields are to be updated. @@ -33689,39 +38437,39 @@ Generated from protobuf field <code>.google.protobuf.FieldMask update_mask - + hasUpdateMask \Google\Cloud\Vision\V1\UpdateProductRequest::hasUpdateMask() - + - + clearUpdateMask \Google\Cloud\Vision\V1\UpdateProductRequest::clearUpdateMask() - + - + setUpdateMask \Google\Cloud\Vision\V1\UpdateProductRequest::setUpdateMask() - + var \Google\Protobuf\FieldMask - + The [FieldMask][google.protobuf.FieldMask] that specifies which fields to update. If update_mask isn't specified, all mutable fields are to be updated. @@ -33741,13 +38489,13 @@ Generated from protobuf field <code>.google.protobuf.FieldMask update_mask - + - + @@ -33807,17 +38555,56 @@ Generated from protobuf field <code>.google.protobuf.FieldMask update_mask - + + build + \Google\Cloud\Vision\V1\UpdateProductSetRequest::build() + + + productSet + + \Google\Cloud\Vision\V1\ProductSet + + + + updateMask + + \Google\Protobuf\FieldMask + + + + + + + + + + + + + + __construct \Google\Cloud\Vision\V1\UpdateProductSetRequest::__construct() - + data NULL array - + Constructor. - + getProductSet \Google\Cloud\Vision\V1\UpdateProductSetRequest::getProductSet() - + Required. The ProductSet resource which replaces the one on the server. Generated from protobuf field <code>.google.cloud.vision.v1.ProductSet product_set = 1 [(.google.api.field_behavior) = REQUIRED];</code> - + hasProductSet \Google\Cloud\Vision\V1\UpdateProductSetRequest::hasProductSet() - + - + clearProductSet \Google\Cloud\Vision\V1\UpdateProductSetRequest::clearProductSet() - + - + setProductSet \Google\Cloud\Vision\V1\UpdateProductSetRequest::setProductSet() - + var \Google\Cloud\Vision\V1\ProductSet - + Required. The ProductSet resource which replaces the one on the server. Generated from protobuf field <code>.google.cloud.vision.v1.ProductSet product_set = 1 [(.google.api.field_behavior) = REQUIRED];</code> - + getUpdateMask \Google\Cloud\Vision\V1\UpdateProductSetRequest::getUpdateMask() - + The [FieldMask][google.protobuf.FieldMask] that specifies which fields to update. If update_mask isn't specified, all mutable fields are to be updated. @@ -33909,39 +38696,39 @@ Generated from protobuf field <code>.google.protobuf.FieldMask update_mask - + hasUpdateMask \Google\Cloud\Vision\V1\UpdateProductSetRequest::hasUpdateMask() - + - + clearUpdateMask \Google\Cloud\Vision\V1\UpdateProductSetRequest::clearUpdateMask() - + - + setUpdateMask \Google\Cloud\Vision\V1\UpdateProductSetRequest::setUpdateMask() - + var \Google\Protobuf\FieldMask - + The [FieldMask][google.protobuf.FieldMask] that specifies which fields to update. If update_mask isn't specified, all mutable fields are to be updated. @@ -33960,7 +38747,7 @@ Generated from protobuf field <code>.google.protobuf.FieldMask update_mask - + @@ -34125,7 +38912,7 @@ Generated from protobuf message <code>google.cloud.vision.v1.Vertex</co - + @@ -34345,7 +39132,7 @@ Generated from protobuf field <code>float score = 2;</code> - + @@ -34508,7 +39295,7 @@ Generated from protobuf field <code>float score = 2;</code> - + @@ -34680,7 +39467,7 @@ Generated from protobuf field <code>string language_code = 2;</code> - + @@ -35014,7 +39801,7 @@ Generated from protobuf field <code>repeated .google.cloud.vision.v1.WebDe - + @@ -35402,7 +40189,7 @@ Generated from protobuf field <code>repeated .google.cloud.vision.v1.WebDe - + @@ -35446,7 +40233,7 @@ Generated from protobuf field <code>repeated .google.cloud.vision.v1.WebDe - + @@ -35490,7 +40277,7 @@ Generated from protobuf field <code>repeated .google.cloud.vision.v1.WebDe - + @@ -35534,7 +40321,7 @@ Generated from protobuf field <code>repeated .google.cloud.vision.v1.WebDe - + @@ -35578,7 +40365,7 @@ Generated from protobuf field <code>repeated .google.cloud.vision.v1.WebDe - + @@ -35690,7 +40477,7 @@ Generated from protobuf field <code>repeated .google.cloud.vision.v1.WebDe - + @@ -36050,13 +40837,13 @@ Generated from protobuf field <code>repeated .google.cloud.vision.v1.Symbo - + - + Copyright 2016 Google Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); @@ -36117,7 +40904,7 @@ $vision = new VisionClient(); VERSION \Google\Cloud\Vision\VisionClient::VERSION - '1.6.2' + '1.7.4' @@ -36137,33 +40924,37 @@ $vision = new VisionClient(); - + connection \Google\Cloud\Vision\VisionClient::$connection - + + - + __construct \Google\Cloud\Vision\VisionClient::__construct() - + config [] array - + Create a Vision client. Note that when creating a VisionClient instance, setting `$config.projectId` is not supported. To switch between projects, you @@ -36180,29 +40971,29 @@ must provide credentials with access to the project. - + image \Google\Cloud\Vision\VisionClient::image() - + image resource|string|\Google\Cloud\Storage\StorageObject - + features array - + options [] array - + Create an instance of {@see \Google\Cloud\Vision\Image} with required features and options. This method should be used to configure a single image, or when a set of @@ -36264,29 +41055,29 @@ $image = $vision->image($imageResource, [ - + images \Google\Cloud\Vision\VisionClient::images() - + images resource[]|string[]|\Google\Cloud\Storage\StorageObject[] - + features array - + options [] array - + Create an array of type {@see \Google\Cloud\Vision\Image} with required features and options set for each member of the set. This method is useful for quickly configuring every member of a set of @@ -36341,23 +41132,23 @@ $images = $vision->images([$familyPhotoResource, $weddingPhotoResource], [ - + annotate \Google\Cloud\Vision\VisionClient::annotate() - + image \Google\Cloud\Vision\Image - + options [] array - + Annotate a single image. Example: ``` @@ -36389,23 +41180,23 @@ $result = $vision->annotate($image); - + annotateBatch \Google\Cloud\Vision\VisionClient::annotateBatch() - + images \Google\Cloud\Vision\Image[] - + options [] array - + Annotate a set of images. Example: ``` @@ -36444,7 +41235,7 @@ $result = $vision->annotateBatch($images); - + @@ -36684,6 +41475,8 @@ limitations under the License. + + @@ -36717,6 +41510,8 @@ limitations under the License. + + @@ -36745,6 +41540,8 @@ limitations under the License. + + @@ -36789,6 +41586,8 @@ limitations under the License. + + @@ -36837,6 +41636,8 @@ limitations under the License. + + @@ -36882,6 +41683,8 @@ limitations under the License. + +